[資料3]
スタックResourceForQandA の
スタックスクリプト


on startQandA
  global teacherMode
  global nProblem, nRightAns
  if the cantModify of this stack is false then    --変更可=教師用スタックの場合
    setMenuBarQuestion
    setTeacherMode
  else
    setStudentMode
  end if
  set the userModify to true
end startQandA
-----------------
on endQandA
  if there is a menu "自習ドリル" then delete menu "自習ドリル"
  enable menu 2
  enable menu 3
  enable menu 4
end endQandA
--------------
on openBkgndQuestion
end openBkgndQuestion
---------------
on closeBkgndQuestion
end closeBkgndQuestion
---------
on openQuestion
  global teacherMode, answered
  put false into answered
  prEstimate
  if teacherMode is true then
    showAllFandB
  else
    showFandB
  end if
end openQuestion
----------
on setMenuBarQuestion
  if there is not a menu "自習ドリル" then
    create menu "自習ドリル"
    put "teacherMode" into menu "自習ドリル"
    set menuMessage of menuItem  "teacherMode" of menu "自習ドリル" to "changeMode"
    put "質問カード作成" after  menu "自習ドリル"
    set menuMessage of menuItem  "質問カード作成" of menu "自習ドリル" to "makeQuesCard"
  end if
end setMenuBarQuestion
-------------
on closeQuestion
  global rightAnsLine
  if the first word of field "CardType" is 10 then
    set textStyle of line rightAnsLine of field "問題文" to plain
  end if
  hideAllFandB
end closeQuestion
---------------
on mouseUp
  if the short name of this bkgnd is not "Question" then pass mouseUp
  get the short name of the target
  if the first word of field "CardType" is 10 then
    if it is "問題文" then
      mouseUpType10
    else
      answer "問題文中の選択肢をクリックしてください"
    end if
  else if it is "そうでない" then
    if field "正解" is 0 then estimate 1
    else estimate 0
  else if it is "そのとおり" then
    if field "正解" is 1 then estimate 1
    else estimate 0
  else if it is "解説表示" then
    show field "解説"
  end if
end mouseUp
--------------
on enterInField
  if the target is bkgnd field "解答欄" then  checkAnswer
  pass enterInField
end enterInField
---------------
on returnInField
  if the target is bkgnd field "解答欄" then checkAnswer
  pass returnInField
end returnInField
-----------------
on checkAnswer
  if the first line of me is the first line of field "正解" then estimate 1
  else    estimate 0
end checkAnswer
-------------
on mouseUpType10
  global userAns
  global rightAnsLine
  put the second word of the clickLine into userAns
  put  the first line of field "正解" into possibleAns
  put the number of words of possibleAns into nn
  put false into ansFlag
  repeat with n=1 to nn
    if userAns is word n of possibleAns then
      put true into ansFlag
      exit repeat
    end if
  end repeat
  if ansFlag is false then
    answer "選択肢のある行をクリックしてください"
    exit mouseUpType10
  end if
  set textStyle of line userAns of field "問題文" to bold
  wait for 30
  set textStyle of line userAns of field "問題文" to plain
  put the second line of field "正解" into rightAnsLine
  set textStyle of line rightAnsLine of field "問題文" to shadow
  if rightAnsLine is userAns then estimate 1
  else estimate 0
end mouseUpType10
---------------------
on showAllFandB
  repeat with n = 1 to number of fields
    show field n
    set the lockText of field n to false
  end repeat
  repeat with n = 1 to number of bkgnd buttons
    show bkgnd button n
  end repeat
end showAllFandB
--------------------
on showFandB
  if field "標題" is not empty then
    show field "標題"
  else
    hide field "標題"
  end if
  show field "問題文"
  show field "正解率"
  repeat with n = 1 to number of fields
    set the lockText of field n to true
  end repeat
  put the first line of field "CardType" into theType
  
  if theType is 1 then
    show bkgnd button "Next"
  else  if theType is 2  then
    show bkgnd button "そのとおり"
    show bkgnd button "そうでない"
  else if theType is  3 or theType is 4 then
    if theType is 3 then
      put "答えをここにタイプ" into field "解答欄"
    else
      put "答えをタイプ(文字数は、問題文の▲の数と同じ)してからリターンキーを押す" into field "解答欄"
    end if
    show field "解答欄"
    select text of field "解答欄"
    set the lockText of field "解答欄" to false
  end if
end showFandB
-------------------
on hideAllFandB
  repeat with n = 1 to number of fields
    hide field n
  end repeat
  repeat with n = 1 to number of bg buttons
    hide bg button n
  end repeat
end hideAllFandB
--------------
on changeMode
  global teacherMode
  global answered
  if teacherMode is false then
    setTeacherMode
  else
    put  false into answered
    setStudentMode
  end if
end changeMode
------------------
on setTeacherMode
  global teacherMode
  put true into teacherMode
  set the checkMark of  menuItem "teacherMode" of menu "自習ドリル" to true
  set userLevel to 5
  enable menu 2
  enable menu 3
  enable menu 4
  if the short name of this bkgnd is "Question" then showAllFandB
end  setTeacherMode
-----------------
on setStudentMode
  global teacherMode
  put false into teacherMode
  if there is a menu "自習ドリル" then
    set the checkMark of  menuItem "teacherMode" of menu "自習ドリル" to false
  end if
  set userLevel to 2
  disable  menu 2
  disable menu 3
  disable menu 4
  if the short name of this bkgnd is "Question" then
    hideAllFandB
    showFandB
  end if
end  setStudentMode
-----------------
on  arrowKey direction
  global teacherMode
  global answered
  if teacherMode is true then
    if direction is "right" then visual effect scroll left
    else visual effect scroll right
    pass arrowKey
  else if answered is true and direction is "right" then
    goNext
  end if
end   arrowKey
----------
on goNext
  send "goNext" to stack "ResourceForLecture"
end goNext
-------------------
on makeQuesCard
  if there is not a background "Question" then
    doMenu "新規バックグラウンド"
    lock screen
    set the name of this bkgnd to "Question"
    
    doMenu "新規フィールド"
    set the name of the last bg field to "標題"
    set the rectangle of the last bg field to 30,26,370,55
    set the fixedLineHeight of the last bg field to true
    set the style of the last bg field to shadow
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 18
    set the textstyle of the last bg field to extend
    
    doMenu "新規フィールド"
    set the name of the last bg field to "問題文"
    set the rectangle of the last bg field to 6,70,525,315
    set the fixedLineHeight of the last bg field to true
    set the style of the last bg field to shadow
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 18
    
    doMenu "新規ボタン"
    set the name of the last bg button to "解説表示"
    set the rectangle of the last bg button to 470,417,518,468
    set the icon of the last bg button to "Background Art"
    
    doMenu "新規フィールド"
    set the name of the last bg field to "解説"
    set the rectangle of the last bg field to 5,325,525,470
    set the fixedLineHeight of the last bg field to true
    set the style of the last bg field to scrolling
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 18
    
    doMenu "新規フィールド"
    set the name of the last bg field to "CardType"
    set the rectangle of the last bg field to 585,40,630,55
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 12
    
    doMenu "新規フィールド"
    set the name of the last bg field to "正解率"
    set the rectangle of the last bg field to 535,80,625,96
    set the style of the last bg field to shadow
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 12
    
    doMenu "新規フィールド"
    set the name of the last bg field to "正解"
    set the rectangle of the last bg field to 535,185,635,230
    set the style of the last bg field to scrolling
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 12
    
    doMenu "新規フィールド"
    set the name of the last bg field to "解答欄"
    set the rectangle of the last bg field to 535,340,635,420
    set the style of the last bg field to shadow
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 12
    
    doMenu "新規フィールド"
    set the name of the last bg field to "再学習"
    set the rectangle of the last bg field to 535,255,635,335
    set the style of the last bg field to scrolling
    set the textFont of the last bg field to "細明朝"
    set the textSize of the last bg field to 12
    
    doMenu "新規ボタン"
    set the name of the last bg button to "そうでない"
    set the rectangle of the last bg button to 555,350,621,376
     set the script of the last bg button to empty
    
    doMenu "新規ボタン"
    set the name of the last bg button to "そのとおり"
    set the rectangle of the last bg button to 560,390,621,413
     set the script of the last bg button to empty
   
    doMenu "新規ボタン"
    set the name of the last bg button to "Next"
    set the rectangle of the last bg button to 595,440,625,470
    set the icon of the last bg button to "XL Next Arrow"
    set the showName of the last bg button to false
    set the style of  the last bg button to transparent
    set the script of the last bg button to~
    "on mouseUp"&return&"goNext"&return&"end mouseUp"
    
    doMenu "新規ボタン"
    set the name of the last bg button to "Previous"
    set the rectangle of the last bg button to 545,440,575,470
    set the icon of the last bg button to "XL Prev Arrow"
    set the showName of the last bg button to false
    set the style of  the last bg button to transparent
    set the script of the last bg button to~
    "on mouseUp"&return&"go prev"&return&"end mouseUp"
    
    doMenu "新規ボタン"
    set the name of the last bg button to "SetMenu"
    set the showName of the last bg button to false
    set the style of the last bg button to transparent
    set the rect of the last bg button to 5,25,25,45
    set the script of the last bg button to ~
    "on mouseUp"&return&"setMenuBar"&return&"end mouseUp"
    doMenu "バックグラウンド"
  else
    lock screen
    push card
    go to the first card of background "Question"
    doMenu "コピーカード"
    pop card
    doMenu "ペースト カード"
  end if
  choose browse tool
  unlock screen
end makeQuesCard
------------------
on studyAgain
  push card
  put bg field "再学習" into reStudy
  repeat with nn=1 to number of lines of reStudy
    get line nn of  reStudy
    if it is not empty then
      go to card it
      lecture
    end if
  end repeat
  pop card
end studyAgain
-------------------
on estimate rightWrong    --1=wrightAns, 0=worngAns
  global nProblem, nRightAns, rightAnsLine, answered
  if answered is true then
    answer "既に解答済みです。次のカードに進んでください"
    show bkgnd button "Next"
    exit estimate
  end if
  add 1 to nProblem
  put  true into answered
  if rightWrong is 1 then
    play "Harpsichord" "gq rx eh"
    AddColor colorPict, "cd", "笑い顔", "350,150","t"
    add 1 to nRightAns
    if field "解説" is not empty then show bkgnd button "解説表示"
    show bkgnd button "Next"
  else
    beep 2
    AddColor colorPict, "cd", "泣き顔", "380,120","t"
    if field "解説" is not empty then show  field "解説"
    if field "再学習" is empty then
      show bkgnd button "Next"
    else
      AddColor colorPict, "cd", "もう一度勉強", "360,220","t"
      wait until the mouseClick
      studyAgain
    end if
  end if
  prEstimate
end estimate
----------------
on prEstimate
  global nProblem, nRightAns
  if nProblem > 0 then
    put         ((nRightAns * 100) div nProblem)  into n1
  else
    put 0 into n1
  end if
  put n1 &"%" & "(" &  nRightAns & "/"  & nProblem & ")"  into field "正解率"
end prEstimate


[本文] [栗田隆のホームページ]

Copyright: 栗田隆
Contact: 栗田隆 Email: <KURITA@kansai-u.ac.jp>
Last Updated: 1996年 3月 19日 (火)