aUCBLogo Demos and Tests / score_a_test
be score_a_test
f=(Frame [][MyFrame]
wxFrame_Tool_Window+wxCaption+wxClose_Box
+wxSystem_Menu+wxResize_Border+wxTab_traversal+wxStay_on_Top
[400 300][-1 -1])
FrameSetBackgroundColor f [.9 .9 .85]
FrameSetClientSize f 400 300
running=true
quit=false
FrameOnClose f [running=false quit=true]
questions=
{ { [Who led the British colonies in North America not including Canada?]
{ [Issac Newton]
[John Adams]
[Samuel Adams]
[George Washington]
}
{0 0 0 100}
}
{ [Which is closest to the value of Pi?]
{ 3
3.141592654
2.718281828
3.146436455
}
{-1 100 -100 -10}
}
{ [Which is closest to the value of Euler's number?]
{ 3
3.141592654
2.718281828
3.146436455
}
{-30 -30 100 -30}
}
}
results=mdarray List count questions 6
nr=1
while [and nr <= count questions not quit]
[ quest
questions.nr.1
questions.nr.2
GC
]
Report
be quest question answers
local [tc0 tc bnext bprev n cb bs bspn]
n=count answers
tc0=(StaticText f ")
tc=(StaticText f question wxalign_centre)
bnext=Button f [&Next]
[ nr=nr+1
running=false
]
bprev=Button f [&Previous]
[ if nr > 1 [nr=nr-1]
running=false
]
cb=Array n
for [j 1 n]
[ cb.j=
(CheckBox f answers.j
(Sentence "setItem j
[item nr results
not item] j [item nr results]))
if empty? results.nr.j [results.nr.j=false]
CheckBoxSet cb.j results.nr.j==true
]
bs=BoxSizer wxVertical
BoxSizerAdd bs tc0 50 wxexpand 0
BoxSizerAdd bs tc 100
wxexpand+wxalign_center+wxalign_center_vertical 0
repeat n
[ BoxSizerAdd bs cb.repcount 100 wxExpand 0
]
bspn=BoxSizer wxHorizontal
BoxSizerAdd bspn bprev 100 wxExpand 0
BoxSizerAdd bspn bnext 100 wxExpand 0
BoxSizerAdd bs bspn 100 wxExpand 0
FrameSetSizer f bs
running=true
while [running]
[ dispatchMessages
waitMS 100
]
end
be Report
local [v p]
nrs=count questions
p=0
for [nr 1 nrs]
[ (foreach questions.nr.2 results.nr questions.nr.3
[ p=p+ifelse ?2 [?3][0]
])
]
tc=TextControl f [Score:] p
end
end