1: ###########################################################
2: # scorer.output.num file looks like this
3: # classname setNum numQuest flags questiondescriptor
4: # flags come in the order of CheckPIN, AnonMode, (CheckSpaces, Gone)
5: # (SurveyMode, Gone) (SurveyHeader, Gone) (IdFormat, Gone)
6: # (CheckMultipleMarks, Gone) QueryAboutPID, (log gone)
7: ###########################################################
8:
9: ###########################################################
10: # scorerMessage
11: ###########################################################
12: ###########################################################
13: ###########################################################
14: proc scorerMessage { num mesg {tag normal} } {
15: global gScorer
16: $gScorer(status.$num) insert end "$mesg\n" $tag
17: $gScorer(status.$num) see end
18: # update
19: }
20:
21: ###########################################################
22: # scorerError
23: ###########################################################
24: ###########################################################
25: ###########################################################
26: proc scorerError { num errorCode args } {
27: global gScorer
28: switch $errorCode {
29: LOTS_OF_ANON_MODE_MATCHES {
30: lappend gScorer(errortype.$num) $errorCode
31: lappend gScorer(errors.$num) [lindex $args 0]
32: scorerMessage $num "More than 6 Student IDs generate the closest match to the capaID specified on [lindex $args 1]'s paper" error
33: }
34: NO_CODE_IN_ANON_MODE {
35: lappend gScorer(errortype.$num) $errorCode
36: lappend gScorer(errors.$num) [lindex $args 0]
37: scorerMessage $num "There was no CapaID/CODE on [lindex $args 1]'s paper" error
38: }
39: NO_SUCH_STUDENT {
40: lappend gScorer(errortype.$num) $errorCode
41: lappend gScorer(errors.$num) [lindex $args 0]
42: scorerMessage $num "Unable to find [lindex $args 1] in classl" error
43: }
44: UNABLE_TO_PARSE {
45: lappend gScorer(errortype.$num) $errorCode
46: lappend gScorer(errors.$num) [lindex $args 0]
47: scorerMessage $num "An error occured while trying to parse the set for [lindex $args 1]'s paper" error
48: }
49: PINWRONG -
50: UNKNOWN_GRADING_METHOD -
51: CANT_OPEN_SB -
52: CANT_UPDATE_SB -
53: default {
54: displayError "$errorCode $args"
55: }
56: }
57: incr gScorer(numerrors.$num)
58: update
59: }
60:
61: ###########################################################
62: # runScorer
63: ###########################################################
64: ###########################################################
65: ###########################################################
66: proc runScorer { setFile } {
67: global gUniqueNumber gWindowMenu gFile gScorer
68:
69: set num [incr gUniqueNumber]
70:
71: set classDir [file dirname $setFile]
72: set gFile($num) $classDir
73: # puts "set gFile($num) to $gFile($num)"
74: set scorerWin [toplevel .beginScorer$num]
75: $gWindowMenu add command -label "ScorerConfig $classDir" \
76: -command "capaRaise \"$scorerWin\""
77: wm title $scorerWin $classDir
78:
79: set infoFrame [frame $scorerWin.infoFrame ]
80: set buttonFrame [frame $scorerWin.buttonFrame ]
81: set configFrame [frame $scorerWin.configFrame ]
82: pack $infoFrame $buttonFrame $configFrame -side top
83:
84: set classNameFrame [frame $infoFrame.classNameFrame]
85: set setNumFrame [frame $infoFrame.setNumFrame]
86: set scoreFileFrame [frame $infoFrame.scoreFileFrame]
87: pack $classNameFrame $setNumFrame $scoreFileFrame -side top -anchor w
88:
89: #classname
90: label $classNameFrame.label -text "Class Name:"
91: entry $classNameFrame.entry -textvariable gScorer(class.$num)\
92: -width 8
93: # button $classNameFrame.button -text "What Goes Here" \
94: -command "helpScorer className"
95: pack $classNameFrame.label $classNameFrame.entry -side left
96: set gScorer(class.$num) [file tail $classDir]
97:
98: #set number
99: set gScorer(set.$num) [string range [file rootname [file tail $setFile]] 3 end]
100: label $setNumFrame.label -text "Set Number:"
101: entry $setNumFrame.set -width 2 -textvariable gScorer(set.$num)
102: pack $setNumFrame.label $setNumFrame.set -side left
103:
104: #scoring file
105: label $scoreFileFrame.label -text "Scoring Office File:"
106: set entryFrame [frame $scoreFileFrame.entryFrame]
107: button $scoreFileFrame.select -text "Select File" \
108: -command "selectScoringFile $num"
109: pack $scoreFileFrame.label $entryFrame $scoreFileFrame.select -side left
110: entry $entryFrame.entry -textvariable gScorer(scoreFile.$num) \
111: -xscrollcommand "$entryFrame.scroll set"
112: scrollbar $entryFrame.scroll -orient h -command \
113: "$entryFrame.entry xview"
114: pack $entryFrame.entry $entryFrame.scroll
115: pack configure $entryFrame.scroll -fill x
116:
117: #buttons
118: button $buttonFrame.cancel -text Cancel -command "destroy $scorerWin\
119: removeWindowEntry \"ScorerConfig $classDir\""
120: button $buttonFrame.continue -text "Continue" \
121: -command "getScorerQuest $num"
122: button $buttonFrame.load -text "Load Previous Settings" \
123: -command "loadScorerConfig $num"
124: pack $buttonFrame.cancel $buttonFrame.continue $buttonFrame.load \
125: -side left
126:
127: #config options
128: #flag list is from scorer.h
129: foreach flaglist $gScorer(flags) {
130: set flag [lindex $flaglist 0]
131: set question [lindex $flaglist 1]
132: set oneVal [lindex $flaglist 2]
133: set zeroVal [lindex $flaglist 3]
134: set defaultVal [lindex $flaglist 4]
135: set frame($flag) [frame $configFrame.[string tolower $flag] \
136: -relief groove -borderwidth 2]
137: set gScorer($flag.frame.$num) $frame($flag)
138: pack $frame($flag) -side top -anchor w
139: set frame($flag.top) [frame $frame($flag).top]
140: set frame($flag.bot) [frame $frame($flag).bot]
141: pack $frame($flag.top) $frame($flag.bot) -side top -anchor w
142: label $frame($flag.top).label -text "$question" -anchor w -width 70
143: # button $frame($flag.top).help -text "Huh?" -command "helpScorerFlags $flag"
144: pack $frame($flag.top).label -side left
145: radiobutton $frame($flag.bot).one -variable gScorer($flag.$num) \
146: -value 1 -text $oneVal -command "configureOptions $num"
147: radiobutton $frame($flag.bot).zero -variable gScorer($flag.$num) \
148: -value 0 -text $zeroVal -command "configureOptions $num"
149: set gScorer($flag.$num) $defaultVal
150: pack $frame($flag.bot).one $frame($flag.bot).zero -side left
151: }
152: parseCapaConfig $num $gFile($num)
153: configureOptions $num
154: loadScorerConfig $num
155: Centre_Dialog $scorerWin default
156: # trace variable gScorer(quit.$num) w "scorerClose $num 0"
157: }
158:
159: ###########################################################
160: # loadScorerConfig
161: ###########################################################
162: ###########################################################
163: ###########################################################
164: proc loadScorerConfig { num } {
165: global gScorer gFile
166:
167: set filename [file join $gFile($num) records scorer.output.$gScorer(set.$num)]
168: if { [ catch { set fileId [ open $filename "r" ] } ] } {
169: displayError "The set \"$gScorer(set.$num)\" does not yet have an scorer.output file. "
170: return
171: }
172: set line [gets $fileId ]
173: close $fileId
174: set flags [lindex $line 3]
175: #When uncommenting or commenting the following lines make sure to update the actual
176: #index values
177: set gScorer(CheckPIN.$num) [string index $flags 0]
178: set gScorer(AnonMode.$num) [string index $flags 1]
179: # set gScorer(CheckSpaces.$num) [string index $flags 2]
180: # set gScorer(SurveyMode.$num) [string index $flags 3]
181: # set gScorer(SurveyHeader.$num) [string index $flags 4]
182: # set gScorer(IdFormat.$num) [string index $flags 5]
183: # set gScorer(CheckMultipleMarks.$num) [string index $flags 6]
184: set gScorer(QueryAboutPID.$num) [string index $flags 2]
185: # set gScorer(Form.$num) [string index $flags 8]
186: # set gScorer(log.$num) [string index $flags 9]
187: configureOptions $num
188: }
189:
190: ###########################################################
191: ###########################################################
192: ###########################################################
193: ###########################################################
194: proc configureOptions { num } {
195: global gScorer
196:
197: foreach frame [array names gScorer "*.frame.$num"] {
198: pack forget $gScorer($frame)
199: }
200:
201: # pack $gScorer(SurveyMode.frame.$num) -side top
202: # if { $gScorer(SurveyMode.$num) } {}
203: # pack $gScorer(SurveyHeader.frame.$num)
204: # {}
205: pack $gScorer(CheckPIN.frame.$num)
206: if { $gScorer(CheckPIN.$num) } {
207: pack $gScorer(AnonMode.frame.$num)
208: if { $gScorer(AnonMode.$num) } {
209: pack $gScorer(QueryAboutPID.frame.$num)
210: } else {
211: set gScorer(QueryAboutPID.$num) 0
212: }
213: } else {
214: set gScorer(AnonMode.$num) 0
215: }
216: # pack $gScorer(CheckSpaces.frame.$num)
217: # pack $gScorer(CheckMultipleMarks.frame.$num)
218: # pack $gScorer(IdFormat.frame.$num)
219: # {}
220: # pack $gScorer(Form.frame.$num)
221: # pack $gScorer(log.frame.$num)
222: }
223:
224: ###########################################################
225: # selectScoringFile
226: ###########################################################
227: ###########################################################
228: ###########################################################
229: proc selectScoringFile { num } {
230: global gScorer
231: if { "" != [ set temp [tk_getOpenFile] ] } {set gScorer(scoreFile.$num) $temp}
232: }
233:
234: ###########################################################
235: ###########################################################
236: ###########################################################
237: ###########################################################
238: proc helpScorerFlags { flag } {
239: global gUniqueNumber gWindowMenu
240:
241: set num [incr gUniqueNumber]
242: set helpWin [toplevel .beginScorer$num]
243: $gWindowMenu add command -label "HelpFlag $flag" \
244: -command "capaRaise \" $helpWin\""
245: wm title $helpWin $flag
246:
247: button $helpWin.dismiss -text Dismiss -command "destroy $helpWin"
248: message $helpWin.help -aspect 2000
249: set help ""
250: switch $flag {
251: # SurveyMode { set help "An examination will include the student number on the answer sheet of the student who answered the questions, whereas a survey will have no student number at all." }
252: # SurveyHeader { set help "If the Survey given include a header portion this will let ."}
253: CheckPIN { set help "bluh" }
254: AnonMode { set help "bluh" }
255: QueryAboutPID { set help "bluh" }
256: # CheckSpaces { set help "bluh" }
257: # CheckMultipleMarks { set help "bluh" }
258: # IdFormat { set help "bluh" }
259: # Form { set help "bluh" }
260: # log { set help "bluh" }
261: }
262: $helpWin.help configure -text "$help"
263: pack $helpWin.dismiss $helpWin.help
264: Centre_Dialog $helpWin default
265: }
266:
267: ###########################################################
268: # getScorerQuest
269: ###########################################################
270: ###########################################################
271: ###########################################################
272: proc getScorerQuest { num } {
273: global gUniqueNumber gWindowMenu gFile gScorer
274:
275: if { ![file readable $gScorer(scoreFile.$num)] } {
276: displayMessage "Please Select a readable scoring office report file before continuing."
277: return
278: }
279:
280: set classDir $gFile($num)
281:
282: set scorerWin ".beginScorer$num"
283:
284: set infoFrame $scorerWin.infoFrame
285: set buttonFrame $scorerWin.buttonFrame
286: set configFrame $scorerWin.configFrame
287: set classNameFrame $infoFrame.classNameFrame
288: set setNumFrame $infoFrame.setNumFrame
289: set scoreFileFrame $infoFrame.scoreFileFrame
290: set entryFrame $scoreFileFrame.entryFrame
291:
292: destroy $configFrame
293: pack [frame $configFrame]
294:
295: destroy $scoreFileFrame.select
296: $entryFrame.entry configure -state disabled
297: $classNameFrame.entry configure -state disabled
298: $setNumFrame.set configure -state disabled
299:
300: #disabeling the config options
301: set classNameFrame $infoFrame.classNameFrame
302: set setNumFrame $infoFrame.setNumFrame
303: $classNameFrame.entry configure -state disabled
304: $setNumFrame.set configure -state disabled
305:
306: $buttonFrame.continue configure -command "startScorer $num"
307: $buttonFrame.load configure -command "loadScorerQuest $num"
308:
309: #question
310: set questButFrame [ frame $configFrame.butFrame ]
311: set questLabelFrame [frame $configFrame.label ]
312: set questListFrame [ frame $configFrame.listFrame ]
313: pack $questButFrame $questLabelFrame $questListFrame
314: pack configure $questLabelFrame -anchor w
315:
316: button $questButFrame.add -text "Add" -command "addScorerQuest $num"
317: button $questButFrame.clone -text "Clone" -command "cloneScorerQuest $num"
318: button $questButFrame.rm -text "Remove" -command "rmScorerQuest $num"
319: button $questButFrame.change -text "Change" -command "changeScorerQuest $num"
320: pack $questButFrame.add $questButFrame.clone $questButFrame.rm \
321: $questButFrame.change -side left
322:
323: label $questLabelFrame.label -text "Num Type Points Leafs"
324: pack $questLabelFrame.label
325:
326: #listbox
327: set gScorer(questNum.$num) [ listbox $questListFrame.questNum \
328: -width 3 -height 20 \
329: -yscrollcommand "$questListFrame.scroll set" ]
330: set gScorer(quest.$num) [ listbox $questListFrame.quest -width 50 -height 20 \
331: -yscrollcommand "$questListFrame.scroll set"]
332: scrollbar $questListFrame.scroll -orient v -command \
333: "scrolltwo \"$questListFrame.quest yview\" \"$questListFrame.questNum yview\""
334: pack $questListFrame.scroll $questListFrame.quest \
335: $questListFrame.questNum -side right
336: pack configure $questListFrame.scroll -fill y
337: loadScorerQuest $num
338: update idletasks
339: Centre_Dialog $scorerWin default
340: }
341:
342: ###########################################################
343: # configQuestWin
344: ###########################################################
345: ###########################################################
346: ###########################################################
347: proc configQuestWin { num action {message ""} {max 1} } {
348: global gScorer
349:
350: if { ![winfo exists .scorerQuestWin$num] } { return }
351: set frame .scorerQuestWin$num.add.leaf
352:
353: switch $action {
354: hide
355: { pack forget $frame }
356: show
357: {
358: pack $frame
359: $frame.leafs configure -label $message
360: $frame.leafs configure -to $max
361: }
362: }
363: }
364:
365:
366: ###########################################################
367: # renumberScorerQuest
368: ###########################################################
369: ###########################################################
370: ###########################################################
371: proc renumberScorerQuest { num } {
372: global gScorer
373: $gScorer(questNum.$num) delete 0 end
374: set max [$gScorer(quest.$num) index end ]
375: for { set i 1 } { $i <= $max } { incr i } {
376: lappend numList $i
377: }
378: eval "$gScorer(questNum.$num) insert 0 $numList"
379: $gScorer(questNum.$num) yview [ $gScorer(quest.$num) nearest 5 ]
380: }
381:
382: ###########################################################
383: # insertQuest
384: ###########################################################
385: ###########################################################
386: ###########################################################
387: proc insertQuest { num where } {
388: global gScorer
389:
390: if { $where != "end" } { $gScorer(quest.$num) delete $where }
391: switch $gScorer(questType.$num) {
392: ONE_OUT_OF_10
393: -
394: ASSIGNED
395: -
396: SINGLE_DIGIT
397: -
398: STRING_MATCH
399: {
400: $gScorer(quest.$num) insert $where [format "%-13s %7s" \
401: $gScorer(questType.$num) $gScorer(questPoint.$num)]
402: }
403: GLE
404: -
405: TF
406: -
407: N_OUT_OF_M
408: {
409: $gScorer(quest.$num) insert $where [format "%-13s %7s %6s" \
410: $gScorer(questType.$num) $gScorer(questPoint.$num) \
411: $gScorer(questLeaf.$num)]
412: }
413: }
414: renumberScorerQuest $num
415: }
416:
417: ###########################################################
418: # addScorerQuest
419: ###########################################################
420: ###########################################################
421: ###########################################################
422: proc addScorerQuest { num {position end} } {
423: global gUniqueNumber gWindowMenu gFile gScorer
424:
425: if { [winfo exists .scorerQuestWin$num] } { return }
426: set questWin [ toplevel .scorerQuestWin$num ]
427:
428: if { ! [ info exists gScorer(questType.$num) ] } {
429: set gScorer(questType.$num) ONE_OUT_OF_10
430: }
431:
432: set buttonFrame [ frame $questWin.button ]
433: set optionFrame [ frame $questWin.add ]
434: pack $buttonFrame $optionFrame -side top
435:
436: set text Change
437: if { $position == "end" } {
438: set text Add
439: }
440: button $buttonFrame.done -text $text -command "insertQuest $num $position
441: destroy $questWin"
442: button $buttonFrame.cancel -text "Cancel" -command "destroy $questWin"
443: pack $buttonFrame.done $buttonFrame.cancel -side left
444:
445: set typeFrame [ frame $optionFrame.type ]
446: set pointFrame [ frame $optionFrame.point ]
447: set leafFrame [ frame $optionFrame.leaf ]
448: pack $typeFrame $pointFrame $leafFrame -side top
449:
450: radiobutton $typeFrame.oneoutof8 -text "One out of no more than 10" -value "ONE_OUT_OF_10" \
451: -variable gScorer(questType.$num) -command "configQuestWin $num hide"
452: radiobutton $typeFrame.gletype -text "GLE type" -value "GLE" \
453: -variable gScorer(questType.$num) \
454: -command "configQuestWin $num show \"Number of Leafs\" 3 "
455: radiobutton $typeFrame.tftype -text "TF type" -value "TF" \
456: -variable gScorer(questType.$num) \
457: -command "configQuestWin $num show \"Number of Leafs\" 5 "
458: radiobutton $typeFrame.assigned -text "Assigned score" -value "ASSIGNED" \
459: -variable gScorer(questType.$num) -command "configQuestWin $num hide "
460: radiobutton $typeFrame.noutofm -text "N out of M" -value "N_OUT_OF_M" \
461: -variable gScorer(questType.$num) \
462: -command "configQuestWin $num show \"What is the value of M\" 10 "
463: radiobutton $typeFrame.singledigit -text "Single digit" -value "SINGLE_DIGIT" \
464: -variable gScorer(questType.$num) -command "configQuestWin $num hide"
465: radiobutton $typeFrame.exactstring -text "Exact string matching" \
466: -value "STRING_MATCH" -variable gScorer(questType.$num) \
467: -command "configQuestWin $num hide"
468: pack $typeFrame.oneoutof8 $typeFrame.gletype $typeFrame.tftype \
469: $typeFrame.assigned $typeFrame.noutofm $typeFrame.singledigit \
470: $typeFrame.exactstring -side top -anchor w
471:
472: scale $pointFrame.points -from 0 -to 9 -variable gScorer(questPoint.$num) \
473: -label "Point Value" -orient h -length 300
474: pack $pointFrame.points
475:
476: scale $leafFrame.leafs -from 1 -to 10 -variable gScorer(questLeaf.$num) \
477: -label "Number of Leafs" -orient h -length 300
478: pack $leafFrame.leafs
479:
480: switch $gScorer(questType.$num) {
481: ONE_OUT_OF_10
482: -
483: ASSIGNED
484: -
485: SINGLE_DIGIT
486: -
487: STRING_MATCH { configQuestWin $num hide }
488: GLE { configQuestWin $num show "Number of Leafs" 3 }
489: TF { configQuestWin $num show "Number of Leafs" 5 }
490: N_OUT_OF_M { configQuestWin $num show "What is the value of M" 10 }
491: }
492: Centre_Dialog $questWin default
493: }
494:
495: ###########################################################
496: # cloneScorerQuest
497: ###########################################################
498: ###########################################################
499: ###########################################################
500: proc cloneScorerQuest { num } {
501: global gUniqueNumber gWindowMenu gFile gScorer
502:
503: if { [ $gScorer(quest.$num) curselection ] == "" } {
504: displayError "Please select an exisiting question to clone."
505: return
506: }
507:
508: set temp [ $gScorer(quest.$num) get [ $gScorer(quest.$num) curselection ] ]
509: $gScorer(quest.$num) insert end $temp
510: renumberScorerQuest $num
511: }
512:
513: ###########################################################
514: # rmScorerQuest
515: ###########################################################
516: ###########################################################
517: ###########################################################
518: proc rmScorerQuest { num } {
519: global gUniqueNumber gWindowMenu gFile gScorer
520:
521: if { [winfo exists .scorerQuestWin$num] } { return }
522: if { [ $gScorer(quest.$num) curselection ] == "" } {
523: displayError "Please select an exisiting question to delete."
524: return
525: }
526: $gScorer(quest.$num) delete [$gScorer(quest.$num) curselection]
527: renumberScorerQuest $num
528: }
529:
530: ###########################################################
531: # changeScorerQuest
532: ###########################################################
533: ###########################################################
534: ###########################################################
535: proc changeScorerQuest { num } {
536: global gUniqueNumber gWindowMenu gFile gScorer
537:
538: if { [winfo exists .scorerQuestWin$num] } { return }
539: if { [ $gScorer(quest.$num) curselection ] == "" } {
540: displayError "Please select an exisiting question to change."
541: return
542: }
543:
544: set position [ $gScorer(quest.$num) curselection ]
545: set gScorer(questType.$num) [lindex [$gScorer(quest.$num) get $position ] 0 ]
546: set gScorer(questPoint.$num) [lindex [$gScorer(quest.$num) get $position ] 1 ]
547: set gScorer(questLeaf.$num) [lindex [$gScorer(quest.$num) get $position ] 2 ]
548: addScorerQuest $num $position
549: }
550:
551: ###########################################################
552: # startScorer
553: ###########################################################
554: ###########################################################
555: ###########################################################
556: proc startScorer { num } {
557: global gScorer gFile
558:
559: set scorerWin .beginScorer$num
560:
561: set filename [file join $gFile($num) records scorer.output.$gScorer(set.$num)]
562: if { [ catch { set fileId [ open $filename "w+" ] } ] } {
563: displayError "Unable to write to the scorer.output file. "
564: return
565: }
566: #When deleting or adding anything to the flags var make sure to update loadScorerConfig
567: # set flags $gScorer(CheckPIN.$num)$gScorer(AnonMode.$num)$gScorer(CheckSpaces.$num)$gScorer(SurveyMode.$num)$gScorer(SurveyHeader.$num)$gScorer(IdFormat.$num)$gScorer(CheckMultipleMarks.$num)$gScorer(QueryAboutPID.$num)$gScorer(Form.$num)$gScorer(log.$num)
568: set flags $gScorer(CheckPIN.$num)$gScorer(AnonMode.$num)$gScorer(QueryAboutPID.$num)
569: set numQuestion [ $gScorer(quest.$num) index end ]
570: set questString ""
571: for { set i 0 } { $i < $numQuestion } { incr i } {
572: set line [ $gScorer(quest.$num) get $i ]
573: set gScorer(quest.$i.type.$num) [lindex $line 0]
574: switch [lindex $line 0 ] {
575: ONE_OUT_OF_10 { append questString a }
576: GLE { append questString b }
577: TF { append questString c }
578: ASSIGNED { append questString d }
579: N_OUT_OF_M { append questString e }
580: SINGLE_DIGIT { append questString f }
581: STRING_MATCH { append questString g }
582: }
583: append questString [lindex $line 1]
584: set gScorer(quest.$i.points.$num) [lindex $line 1]
585: if { [ lindex $line 2 ] == "" } {
586: set gScorer(quest.$i.leafs.$num) 1
587: append questString 1
588: } else {
589: set gScorer(quest.$i.leafs.$num) [lindex $line 2]
590: append questString [lindex $line 2]
591: }
592: }
593: set outputLine "$gScorer(class.$num) $gScorer(set.$num) $numQuestion $flags $questString"
594: puts $fileId [format "%-500s" $outputLine]
595: close $fileId
596: destroy $scorerWin.buttonFrame
597: destroy $scorerWin.configFrame
598:
599: set gScorer(student.$num) 0
600: set gScorer(numerrors.$num) 0
601:
602: set buttonFrame [frame $scorerWin.buttonFrame]
603: set statusFrame [frame $scorerWin.statusFrame]
604: pack $buttonFrame $statusFrame
605:
606: button $buttonFrame.pause -text Pause -command "pauseScorer $num"
607: button $buttonFrame.cont -text Continue -command "unpauseScorer $num"
608: button $buttonFrame.restart -text Restart -command "restartScorer $num"
609: button $buttonFrame.final -text "Update .sb" -command "scorerToSet $num"
610: button $buttonFrame.exit -text "Quit" -command "scorerQuit $num"
611: pack $buttonFrame.pause $buttonFrame.cont $buttonFrame.restart \
612: $buttonFrame.final $buttonFrame.exit -side left
613:
614:
615: message $statusFrame.mesg -text "Messages:" -aspect 2000
616: set statusText [frame $statusFrame.statusText]
617: set student [frame $statusFrame.student]
618: set errors [frame $statusFrame.errors]
619: set statusButtons [frame $statusFrame.button]
620: pack $statusFrame.mesg $statusFrame.statusText $statusFrame.student \
621: $statusFrame.errors $statusFrame.button
622: pack configure $statusFrame.mesg $statusFrame.student $statusFrame.errors \
623: -anchor w
624: pack configure $statusText -expand 1 -fill both
625:
626: set gScorer(status.$num) [text $statusText.text -wrap char \
627: -yscrollcommand "$statusText.scroll set"]
628: $gScorer(status.$num) tag configure error -foreground red
629: $gScorer(status.$num) tag configure info -foreground #006c00
630:
631: scrollbar $statusText.scroll -orient v -command "$statusText.text yview"
632: pack $statusText.text $statusText.scroll -side left
633: pack configure $statusText.scroll -fill y
634: pack configure $gScorer(status.$num) -expand 1 -fill both
635:
636: label $student.mesg -text "Students completed:"
637: label $student.num -textvariable gScorer(student.$num)
638: pack $student.mesg $student.num -side left
639:
640: label $errors.mesg -text "Errors To Be Handled:"
641: label $errors.num -textvariable gScorer(numerrors.$num)
642: pack $errors.mesg $errors.num -side left
643:
644: button $statusButtons.handleErrors -text "Save Errors" \
645: -command "handleErrorsScorer $num"
646: button $statusButtons.printMsg -text "Print Messages" \
647: -command "printScorerMsg $num"
648: button $statusButtons.saveMsg -text "Save Messages" \
649: -command "saveScorerMsg $num"
650: button $statusButtons.clearMsg -text "Clear Messages" \
651: -command "clearScorerMsg $num"
652: pack $statusButtons.handleErrors $statusButtons.printMsg \
653: $statusButtons.saveMsg -side left
654:
655: wm protocol $scorerWin WM_DELETE_WINDOW "usequit $num"
656: update idletasks
657: Centre_Dialog $scorerWin default
658: # set gScorer(quit.$num) 0
659: restartScorer $num
660: }
661:
662: ###########################################################
663: # usequit
664: ###########################################################
665: ###########################################################
666: ###########################################################
667: proc usequit { num } { scorerMessage $num "Please use the Quit Button." info }
668:
669: ###########################################################
670: # saveScorerMsg
671: ###########################################################
672: ###########################################################
673: ###########################################################
674: proc saveScorerMsg { num } {
675: global gScorer
676:
677: set file [tk_getSaveFile -title "Enter the name to save messages to."]
678: if { $file == "" } { return }
679: if { [catch {set fileId [open $file "w"] } ] } {
680: displayError "Unable to open $file"
681: return
682: }
683: set tag [getWhichTags "All {Errors Only} {NonErrors Only}" "{} error normal" "saved"]
684: puts -nonewline $fileId [getTextTagged $gScorer(status.$num) $tag ]
685: close $fileId
686: }
687:
688: ###########################################################
689: # printScorerMsg
690: ###########################################################
691: ###########################################################
692: ###########################################################
693: proc printScorerMsg { num } {
694: global gScorer gFile
695:
696: set file [file join $gFile($num) managertemp.txt]
697: set lprCommand [getLprCommand $file $num]
698: if { $lprCommand == "Cancel" } { return }
699: if { [catch {set fileId [open $file "w"] } ] } {
700: displayError "Unable to open $file"
701: return
702: }
703: set tag [getWhichTags "All {Errors Only} {NonErrors Only}" "{} error normal" printed]
704: puts -nonewline $fileId [getTextTagged $gScorer(status.$num) $tag ]
705: close $fileId
706: set errorMsg ""
707: set error [catch {set output [ eval "exec $lprCommand" ] } errorMsg ]
708: exec rm -f $file
709: if { $error == 1 } {
710: displayError "An error occurred while printing: $errorMsg"
711: } else {
712: displayMessage "Print job sent to the printer.\n $output"
713: }
714: }
715:
716: ###########################################################
717: # initScorer
718: ###########################################################
719: ###########################################################
720: ###########################################################
721: proc initScorer { num } {
722: global gScorer gFile
723:
724: scorerMessage $num "Initializing. . ."
725:
726: if { ![info exists gScorer(in.$num)] || ( $gScorer(in.$num) == "" ) } {
727: if { [catch {set gScorer(in.$num) \
728: [ open $gScorer(scoreFile.$num) "r" ] } ] } {
729: displayError "Unable to open input file $gScorer(scoreFile.$num)"
730: exit
731: }
732: }
733:
734: set filename [file join $gFile($num) records scorer.output.$gScorer(set.$num)]
735: if { ![info exists gScorer(out.$num)] || ( $gScorer(out.$num) == "" ) } {
736: if { [catch {set gScorer(out.$num) [ open $filename "a+" ] } ] } {
737: displayError "Unable to open input file $filename"
738: exit
739: }
740: }
741:
742: scorerMessage $num "Building List of Students. . ."
743: update
744: set oldDir [pwd]
745: cd $gFile($num)
746:
747: #4 is the length of the CapaID
748: set a $gScorer(HalfSheet.CapaID)
749: set capaidplus [expr {[lindex $a 1] - [lindex $a 0] - 3}]
750: # puts "$capaidplus, $a"
751: set gScorer(studentList.$num) [buildStudentList $num $gScorer(class.$num) \
752: $gScorer(set.$num) $capaidplus]
753: cd $oldDir
754: }
755:
756: ###########################################################
757: # getLine
758: ###########################################################
759: ###########################################################
760: ###########################################################
761: proc getLine { num } {
762: global gScorer
763:
764: scorerMessage $num "\nGetting Responses"
765:
766: set done 0
767: while { ! $done } {
768: gets $gScorer(in.$num) aline
769: if { [eof $gScorer(in.$num) ] } { error EOF }
770: if { ![string match "#*" $aline] } {
771: set done 1
772: }
773: }
774: return $aline
775: }
776:
777: ###########################################################
778: # oneResponse
779: ###########################################################
780: ###########################################################
781: ###########################################################
782: proc oneResponse { response max which } {
783: upvar $which whichVar
784: set whichVar ""
785: set howmany 0
786: for { set i 0 } { $i < $max } { incr i } {
787: if { [string index "$response" $i] == "1" } {
788: lappend whichVar $i
789: incr howmany
790: }
791: }
792: return $howmany
793: }
794: ###########################################################
795: # parseLine
796: ###########################################################
797: ###########################################################
798: ###########################################################
799: proc parseLine { num answerLine answerStruct } {
800: global gScorer
801: upvar $answerStruct parsedIn
802: set result ""
803:
804: scorerMessage $num "Understanding Responses"
805:
806: # Only support HalfSheets
807: # if { $gScorer(Form.$num) } {
808: # set sheet FullSheet
809: # } else {
810: # set sheet HalfSheet
811: # }
812: set sheet HalfSheet
813:
814: set parsedIn(orignalLine) "$answerLine"
815: foreach type { SerialNumber LastName FirstName MiddleInitial
816: StudentNumber Section CapaID } {
817: if { [ catch {set parsedIn($type) [string range "$answerLine" \
818: [lindex $gScorer($sheet.$type) 0] \
819: [lindex $gScorer($sheet.$type) 1] ] } ] } {
820: set parsedIn($type) ""
821: }
822: }
823: set letter "ABCDEFGHIJ"
824: set number "1234567890"
825: set offset [lindex $gScorer($sheet.Question) 0]
826: set maxQuest [lindex $gScorer($sheet.Question) 1]
827: set perQuest [lindex $gScorer($sheet.Question) 2]
828: set parsedIn(multiplemarks) 0
829: set parsedIn(spaces) 0
830: for { set i 0 } { $i < $maxQuest } { incr i } {
831: if { [ catch { set gScorer(quest.$i.type.$num) } ] } {
832: set parsedIn(maxQuest) $i
833: set gScorer(numQuest.$num) $i
834: break
835: }
836: set array $letter
837: set start [expr $i * $perQuest + $offset ]
838: set stop [expr $start + $perQuest - 1 ]
839: set response [string range "$answerLine" $start $stop]
840: switch $gScorer(quest.$i.type.$num) {
841: ASSIGNED -
842: SINGLE_DIGIT -
843: ONE_OUT_OF_10 {
844: if { $gScorer(quest.$i.type.$num) != "ONE_OUT_OF_10" } {
845: set array $number
846: }
847: set howmany [oneResponse "$response" $perQuest which]
848: if { $howmany == 1 } {
849: set parsedIn(answer.$i) [string index $array $which]
850: } else {
851: if { $howmany > 1 } {
852: set parsedIn(answer.$i) " "
853: incr parsedIn(multiplemarks)
854: } else {
855: if { $howmany < 1 } {
856: set parsedIn(answer.$i) " "
857: incr parsedIn(spaces)
858: }
859: }
860: }
861: }
862: GLE -
863: TF {
864: if { $gScorer(quest.$i.type.$num) != "GLE" } {
865: set stepsize 2
866: } else {
867: set stepsize 3
868: }
869: set leafs $gScorer(quest.$i.leafs.$num)
870: for { set j 0 } { $j < $leafs } { incr j } {
871: set start [expr $j*$stepsize]
872: set stop [expr $start + $stepsize - 1]
873: set howmany [oneResponse [string range \
874: $response $start $stop] $perQuest which]
875: if { $howmany == 1 } {
876: append parsedIn(answer.$i) [string index $array \
877: [expr {$start + $which}]]
878: } else {
879: if { $howmany > 1 } {
880: append parsedIn(answer.$i) " "
881: incr parsedIn(multiplemarks)
882: } else {
883: if { $howmany < 1 } {
884: append parsedIn(answer.$i) " "
885: incr parsedIn(spaces)
886: }
887: }
888: }
889: }
890: }
891: N_OUT_OF_M -
892: STRING_MATCH {
893: set found 0
894: for { set j 0 } { $j < $perQuest } { incr j } {
895: set char [string index "$response" $j]
896: if { "$char" == 1 } {
897: append parsedIn(answer.$i) [string index $array $j]
898: incr found
899: }
900: }
901: if { ! $found } {
902: incr parsedIn(spaces)
903: set parsedIn(answer.$i) ""
904: }
905: }
906: }
907: }
908: #if there isn't a capaId already, treat the first four questions as
909: # capaID
910: # if { $parsedIn(CapaID) == "" && $gScorer(CheckPIN.$num) } {
911: # set pinWrong 0
912: # for {set j 0} {$j < 4} {incr j} {
913: # switch -regexp "$parsedIn(answer.$j)" {
914: # ^[A-J]$ {
915: # append parsedIn(CapaID) \
916: [string first $parsedIn(answer.$j) "ABCDEFGHIJ" ]
917: # }
918: # default {
919: # set pinWrong 1
920: # }
921: # }
922: # }
923: # if { $pinWrong } {
924: # scorerError $num PINWRONG parsedIn
925: # lappend result PINWRONG
926: # }
927: # }
928: # parray parsedIn
929: if { $result != "" } {
930: error "$result"
931: }
932: }
933:
934: proc getAnswers2 { PID set maxQuest num } {
935: global gFile
936: set pwd [pwd]
937: cd $gFile($num)
938: set result [getAnswersFromSet $PID $set $maxQuest]
939: cd $pwd
940: return $result
941: }
942:
943: proc getAnswers { PID set maxQuest num } {
944: global gFile gCapaConfig
945: set pwd [pwd]
946: cd $gFile($num)
947: set temp [exec $gCapaConfig($num.answers_command) $PID {} 1 $set]
948: cd $pwd
949: set result ""
950: foreach line [split $temp "\n"] {
951: switch [lindex [split $line :] 0] {
952: ANS { lappend result [string range $line 4 end] }
953: }
954: }
955: return $result
956: }
957:
958: ###########################################################
959: # checkStudentNumber
960: ###########################################################
961: ###########################################################
962: ###########################################################
963: proc checkStudentNumber { num answerStructVar } {
964: global gScorer gFile
965: upvar $answerStructVar answerStruct
966:
967: # puts "Stunum1:$answerStruct(StudentNumber):"
968: if { ![inClasslist $num $answerStruct(StudentNumber)] } {
969: # puts "Stunum2:$answerStruct(StudentNumber):"
970: set matched [findByStudentName [string trim $answerStruct(LastName)] $gFile($num)]
971: if { [llength $matched] != 1 } {
972: getOneStudent "" $gFile($num) id name "Unable to find student id: $answerStruct(StudentNumber), entered name is $answerStruct(LastName), $answerStruct(FirstName)." "Name on paper:$answerStruct(LastName), $answerStruct(FirstName), Number on Paper: $answerStruct(StudentNumber)"
973: } else {
974: set id [lindex [lindex $matched 0] 0]
975: if { [makeSure "Unable to find bubbled id: $answerStruct(StudentNumber), name: $answerStruct(LastName) in classl, however I did find $matched. Use this one?"] != "Yes" } {
976: getOneStudent "" $gFile($num) id name "Unable to find student id: $answerStruct(StudentNumber), entered name is $answerStruct(LastName), $answerStruct(FirstName)." "Name on paper:$answerStruct(LastName), $answerStruct(FirstName), Number on Paper: $answerStruct(StudentNumber)"
977: } else {
978: }
979: }
980: if { $id == "" } {
981: scorerError $num NO_SUCH_STUDENT "$answerStruct(orignalLine)" \
982: $answerStruct(StudentNumber)
983: return 0
984: } else {
985: scorerMessage $num "Student Number $answerStruct(StudentNumber) not found in classl using $id instead." info
986: set answerStruct(StudentNumber) $id
987: }
988: }
989: # puts "Stunum3:$answerStruct(StudentNumber):"
990: return 1
991: }
992:
993: ###########################################################
994: # handleStudent
995: ###########################################################
996: ###########################################################
997: ###########################################################
998: proc handleStudent { num answerStructVar} {
999: global gScorer gFile
1000: upvar $answerStructVar answerStruct
1001:
1002: if { ![checkStudentNumber $num answerStruct] } { return 0 }
1003:
1004: scorerMessage $num "Finding Possible Students. . ."
1005: if { ! $gScorer(AnonMode.$num) } {
1006: set answerStruct(questionPID) $answerStruct(StudentNumber)
1007: } else {
1008: # puts "$answerStruct(StudentNumber):$answerStruct(CapaID):"
1009: if { [string trim $answerStruct(CapaID)] == "" } {
1010: scorerError $num NO_CODE_IN_ANON_MODE "$answerStruct(orignalLine)" \
1011: $answerStruct(StudentNumber)
1012: return 0
1013: }
1014: set answerStruct(questionPID) [getAnonModeID $num answerStruct]
1015: if { [llength $answerStruct(questionPID)] > 6 } {
1016: scorerError $num LOTS_OF_ANON_MODE_MATCHES "$answerStruct(orignalLine)" \
1017: $answerStruct(StudentNumber)
1018: return 0
1019: }
1020: }
1021:
1022: set answerStruct(Name) "$answerStruct(LastName) $answerStruct(FirstName) $answerStruct(MiddleInitial)"
1023:
1024: scorerMessage $num "Getting Possible Answers for $answerStruct(StudentNumber), paper# $answerStruct(SerialNumber). . ."
1025: foreach questionPID $answerStruct(questionPID) {
1026: scorerMessage $num "Getting Answers for $questionPID. . ."
1027: if { [catch { set answerStruct(correct.$questionPID) \
1028: [getAnswers $questionPID $gScorer(set.$num) \
1029: $answerStruct(maxQuest) $num] } errorMsg ] } {
1030: puts $errorMsg
1031: scorerError $num UNABLE_TO_PARSE "$answerStruct(orignalLine)" \
1032: $answerStruct(StudentNumber)
1033: error UNABLE_TO_PARSE
1034: }
1035: # puts "$answerStruct(correct.$questionPID)"
1036: }
1037:
1038: scorerMessage $num "Grading Answers. . ."
1039: foreach questionPID $answerStruct(questionPID) {
1040: set answerStruct($questionPID.grade) [gradeSet $num answerStruct $questionPID]
1041: scorerMessage $num "Correct: $answerStruct($questionPID.correct) #correct: $answerStruct($questionPID.grade) PID: $questionPID"
1042: }
1043: scorerMessage $num "Given: $answerStruct($questionPID.given)"
1044: if { [llength $answerStruct(questionPID)] > 1 } {
1045: scorerMessage $num "Selecting Student. . ."
1046: if { $gScorer(QueryAboutPID.$num) } {
1047: set answerStruct(questionPID) \
1048: [getWhichAnon $num answerStruct $answerStruct(indices)]
1049: } else {
1050: set answerStruct(questionPID) \
1051: [pickAnonHighest $num answerStruct $answerStruct(indices)]
1052: }
1053: scorerMessage $num "Student $answerStruct(StudentNumber) selected $answerStruct(questionPID)'s paper." info
1054: }
1055: return 1
1056: }
1057:
1058: ###########################################################
1059: # gradeQuestion
1060: ###########################################################
1061: ###########################################################
1062: ###########################################################
1063: proc gradeQuestion { num questNum correct given answerStructVar } {
1064: global gScorer
1065: upvar $answerStructVar answerStruct
1066: set numRight 0
1067: switch $gScorer(quest.$questNum.type.$num) {
1068: ONE_OUT_OF_10 -
1069: GLE -
1070: TF -
1071: SINGLE_DIGIT {
1072: # scorerMessage $num "The correct answer: $correct, The student's answer: $given"
1073: set fmt "%-$gScorer(quest.$questNum.leafs.$num)s,"
1074: append answerStruct(correct) [format $fmt $correct]
1075: append answerStruct(given) [format $fmt $given]
1076: for { set leafs 0 } { $leafs < $gScorer(quest.$questNum.leafs.$num)
1077: } { incr leafs } {
1078: if { [string index $correct $leafs] ==
1079: [string index $given $leafs] } {
1080: incr numRight
1081: }
1082: }
1083: }
1084: ASSIGNED {
1085: # scorerMessage $num "The student got a $given out of $gScorer(quest.$questNum.points.$num) "
1086: append answerStruct(correct) "$gScorer(quest.$questNum.points.$num),"
1087: append answerStruct(given) "$given,"
1088: if { [catch {incr given 0}] } {
1089: set numRight 0
1090: } else {
1091: set numRight $given
1092: }
1093: }
1094: N_OUT_OF_M {
1095: # scorerMessage $num "The correct answer: $correct, The student's answer: $given"
1096: set fmt "%-$gScorer(quest.$questNum.leafs.$num)s,"
1097: append answerStruct(correct) [format $fmt $correct]
1098: append answerStruct(given) [format $fmt $given]
1099: set letters "ABCDEFGHIJ"
1100: set maxLeaf $gScorer(quest.$questNum.leafs.$num)
1101: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1102: if { [string first [string index $letters $leaf] $correct] != -1 } {
1103: set ansOn($leaf) 1
1104: } else {
1105: set ansOn($leaf) 0
1106: }
1107: }
1108: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1109: if { [string first [string index $letters $leaf] $given] != -1 } {
1110: set stuOn($leaf) 1
1111: } else {
1112: set stuOn($leaf) 0
1113: }
1114: }
1115: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1116: if { $ansOn($leaf) == $stuOn($leaf) } { incr numRight }
1117: }
1118: }
1119: STRING_MATCH {
1120: # scorerMessage $num "The correct answer: $correct, The student's answer: $given"
1121: set fmt "%-$gScorer(quest.$questNum.leafs.$num)s,"
1122: append answerStruct(correct) [format $fmt $correct]
1123: append answerStruct(given) [format $fmt $given]
1124: set letters "ABCDEFGHIJ"
1125: set maxLeaf 10
1126: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1127: if { [string first [string index $letters $leaf] $correct] != -1 } {
1128: set ansOn($leaf) 1
1129: } else {
1130: set ansOn($leaf) 0
1131: }
1132: }
1133: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1134: if { [string first [string index $letters $leaf] $given] != -1 } {
1135: set stuOn($leaf) 1
1136: } else {
1137: set stuOn($leaf) 0
1138: }
1139: }
1140: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1141: if { $ansOn($leaf) == $stuOn($leaf) } { incr numRight }
1142: }
1143: if { $numRight != $maxLeaf } { set numRight 0 }
1144: }
1145: default {
1146: scorerMessage $num "Unknown question type while grading,"
1147: }
1148: }
1149: return $numRight
1150: }
1151:
1152: ###########################################################
1153: # gradeSet
1154: ###########################################################
1155: ###########################################################
1156: ###########################################################
1157: proc gradeSet { num answerStructVar questionPID } {
1158: global gScorer
1159: upvar $answerStructVar answerStruct
1160:
1161: set numRight 0
1162: for { set i 0 } { $i < $answerStruct(maxQuest) } { incr i } {
1163: set correct [lindex $answerStruct(correct.$questionPID) $i]
1164: set given $answerStruct(answer.$i)
1165: set probRight [gradeQuestion $num $i $correct $given answerStruct]
1166: incr numRight $probRight
1167: append answerStruct($questionPID.numRight) $probRight
1168: }
1169: set answerStruct($questionPID.correct) $answerStruct(correct)
1170: set answerStruct(correct) ""
1171: set answerStruct($questionPID.given) $answerStruct(given)
1172: set answerStruct(given) ""
1173: return $numRight
1174: }
1175:
1176:
1177: ###########################################################
1178: # getScorerEntry
1179: ###########################################################
1180: ###########################################################
1181: ###########################################################
1182: proc getScorerEntry { num PID } {
1183: global gScorer
1184:
1185: set fileId $gScorer(out.$num)
1186: seek $fileId 0 start
1187: set done 0
1188: set found 0
1189: set aline ""
1190: set offset 0
1191: while { ! $done } {
1192: set readamt [gets $fileId aline]
1193: if { [eof $fileId] } { set done 0 ; break}
1194: if { 0 == [ string compare [string toupper [lindex $aline 0]] \
1195: [string toupper $PID] ] } {
1196: set done 1
1197: set found 1
1198: } else {
1199: #plus one because gets swallows the newline it reads
1200: set offset [expr $offset + $readamt + 1]
1201: }
1202: }
1203: if { ! $found } { set offset -$offset }
1204: return $offset
1205: }
1206:
1207: ###########################################################
1208: # setScorerEntry
1209: ###########################################################
1210: ###########################################################
1211: ###########################################################
1212: proc setScorerEntry { num aline offset } {
1213: global gScorer
1214:
1215: set fileId $gScorer(out.$num)
1216: seek $fileId [expr abs($offset)] start
1217: puts $fileId $aline
1218: }
1219:
1220: ###########################################################
1221: # setOutput
1222: ###########################################################
1223: ###########################################################
1224: ###########################################################
1225: proc setOutput { num answerStructVar} {
1226: global gScorer
1227: upvar $answerStructVar answerStruct
1228:
1229: #FIXME what if questions PID is empty
1230: set questionPID $answerStruct(questionPID)
1231: set out [format "%9s %-30s %s %4s %3s %s %s %s" $answerStruct(StudentNumber) \
1232: $answerStruct(Name) $answerStruct($questionPID.numRight) \
1233: $answerStruct($questionPID.grade) $answerStruct(Section) \
1234: $answerStruct($questionPID.given) $questionPID \
1235: $answerStruct(SerialNumber)]
1236: set offset [getScorerEntry $num $answerStruct(StudentNumber)]
1237: setScorerEntry $num "$out" $offset
1238: }
1239:
1240: ###########################################################
1241: # finishScoring
1242: ###########################################################
1243: ###########################################################
1244: ###########################################################
1245: proc finishScoring { num answerStructVar} {
1246: global gScorer
1247: scorerMessage $num "Finishing . . ."
1248: # puts "errors:"
1249: # puts "$gScorer(errors.$num)"
1250: scorerMessage $num "Finished, Feel free to Update .sb"
1251: if { [makeSure "Would you like to update the .sb file?"] == "Yes" } {
1252: scorerToSet $num
1253: }
1254: trace variable gScorer(quit.$num) w "scorerClose $num 0"
1255: }
1256:
1257: proc scorerStudentTime { num } {
1258: puts [ time "scorerStudent $num" ]
1259: }
1260:
1261: ###########################################################
1262: # scorerStudent
1263: ###########################################################
1264: ###########################################################
1265: ###########################################################
1266: proc scorerStudent { num } {
1267: global gScorer
1268:
1269: if { $gScorer(pause.$num) } {
1270: if { [array names gScorer quit.$num] != "" } {
1271: if { ![scorerClose $num] } {
1272: unset gScorer(quit.$num)
1273: set gScorer(pause.$num) 0
1274: } else {
1275: return
1276: }
1277: }
1278: if { $gScorer(pause.$num) == 1 } {
1279: scorerMessage $num "Pausing. . . " info
1280: set gScorer(pause.$num) 2
1281: }
1282: after 100 "scorerStudent $num"
1283: return
1284: }
1285: #getanswerline
1286: if { [ catch { set answer [ getLine $num ] } ] } {
1287: finishScoring $num answerStruct
1288: return
1289: }
1290: set gScorer(needToUpdateDB) 1
1291: #parseanswerline
1292: if { [catch {parseLine $num $answer answerStruct} errorMsg ] } {
1293: displayError "Error parsing line: $errorMsg"
1294: } else {
1295: #parse the set and grades it for any possiblely matching student
1296: if { ! [ catch { set result [handleStudent $num answerStruct]} errorMsg ] } {
1297: #write entry to outputfile if student was succesfully handled
1298: if { $result } { setOutput $num answerStruct }
1299: } else { #error handling Student
1300: global errorCode errorInfo
1301: displayError "An error occured when attempting to grade a student. The error is: $errorMsg"
1302: }
1303: }
1304: incr gScorer(student.$num)
1305: update
1306: after idle "scorerStudent $num"
1307: }
1308:
1309: ###########################################################
1310: # restartScorer
1311: ###########################################################
1312: ###########################################################
1313: ###########################################################
1314: proc restartScorer { num } {
1315: global gScorer
1316: if { ! [info exists gScorer(pause.$num) ] } {
1317: initScorer $num
1318: set gScorer(pause.$num) 0
1319: } else {
1320: }
1321: after idle "scorerStudent $num"
1322: }
1323:
1324: ###########################################################
1325: # pauseScorer
1326: ###########################################################
1327: ###########################################################
1328: ###########################################################
1329: proc pauseScorer { num } {
1330: global gScorer
1331: set gScorer(pause.$num) 1
1332: }
1333:
1334: ###########################################################
1335: # stopScorer
1336: ###########################################################
1337: ###########################################################
1338: ###########################################################
1339: proc stopScorer { num } {
1340: }
1341:
1342: ###########################################################
1343: # unpauseScorer
1344: ###########################################################
1345: ###########################################################
1346: ###########################################################
1347: proc unpauseScorer { num } {
1348: global gScorer
1349: set gScorer(pause.$num) 0
1350: }
1351:
1352: ###########################################################
1353: ###########################################################
1354: ###########################################################
1355: ###########################################################
1356: proc finalScorer { num method studentNumber numRight } {
1357: global gScorer
1358:
1359: set answers ""
1360: for { set i 0 } { $i < $gScorer(numQuest.$num) } { incr i } {
1361: switch $gScorer(quest.$i.type.$num) {
1362: ONE_OUT_OF_10 -
1363: SINGLE_DIGIT {
1364: append answers [ expr [string index $numRight $i] * \
1365: $gScorer(quest.$i.points.$num) ]
1366: }
1367: GLE -
1368: TF -
1369: N_OUT_OF_M {
1370: set right [string index $numRight $i]
1371: set leafs $gScorer(quest.$i.leafs.$num)
1372: set points $gScorer(quest.$i.points.$num)
1373: set unit [expr double($points)/double($leafs)]
1374: if { $unit == 0 } { set unit $points }
1375: switch $method {
1376: CAPA {
1377: set score [expr int($points-(2*$unit*($leafs-$right)))]
1378: if { $score < 0 } { set score 0 }
1379: }
1380: Lenient {
1381: set score [expr int($points-($unit*($leafs-$right)))]
1382: }
1383: Strict {
1384: if { $right == $leafs } {
1385: set score $points
1386: } else {
1387: set score 0
1388: }
1389: }
1390: default {
1391: scorerError $num UNKNOWN_GRADING_METHOD $method
1392: }
1393: }
1394: append answers $score
1395: }
1396: STRING_MATCH -
1397: ASSIGNED {
1398: append answers [string index $numRight $i]
1399: }
1400: default {
1401: }
1402: }
1403: }
1404: return $answers
1405: }
1406:
1407: ###########################################################
1408: # scorerToSet2
1409: ###########################################################
1410: ###########################################################
1411: ###########################################################
1412: proc scorerToSet2 { num method } {
1413: global gScorer gFile
1414: destroy .getGradingMethod$num
1415:
1416: set processed 0
1417: set done 0
1418: set fileId $gScorer(out.$num)
1419: set setId $gScorer(set.$num)
1420: seek $fileId 0 start
1421:
1422: #remove the header line
1423: gets $fileId aline
1424:
1425: scorerMessage $num "Processing. . ."
1426: while { ! $done } {
1427: gets $fileId aline
1428: if { [eof $fileId] } {
1429: set done 1
1430: break
1431: }
1432: set studentNumber [lindex $aline 0]
1433: incr processed
1434: if { [ expr $processed % 100 ] == 0 } { scorerMessage $num $processed }
1435: update idletasks
1436: set cwd [pwd]
1437: cd $gFile($num)
1438: if { ![file exists [file join records set$setId.sb] ] } {
1439: if { ![file exists [file join records set$setId.db] ] } {
1440: cd $cwd
1441: scorerMessage $num "set$setId.db does not exist" error
1442: return
1443: } else {
1444: scorerMessage $num "Copying set$setId.db to set$setId.sb"
1445: if { [catch {file copy [file join records set$setId.db] \
1446: [file join records set$setId.sb] }] } {
1447: cd $cwd
1448: scorerMessage $num "Unable to create set$setId.sb from set$setId.db, please create it by hand" error
1449: return
1450: }
1451: }
1452: }
1453: if { [catch { set offset [ scorer_get_entry $studentNumber $setId ] } errors] } {
1454: cd $cwd
1455: scorerMessage $num "Error trying to read set$setId.sb" error
1456: return
1457: }
1458: cd $cwd
1459: set name [string range $aline 10 39]
1460: set numRight [lindex [string range $aline 40 end] 0]
1461: set entry(answers) [ finalScorer $num $method $studentNumber $numRight ]
1462: set entry(tries) ""
1463: for { set i 0 } { $i < $gScorer(numQuest.$num) } { incr i } {
1464: append entry(tries) ", 1"
1465: }
1466: set entry(tries) [string range $entry(tries) 1 end]
1467: set cwd [pwd]
1468: cd $gFile($num)
1469: if { [ catch { scorer_set_entry $studentNumber $setId $offset \
1470: $entry(answers) $entry(tries) } errors ] } {
1471: cd $cwd
1472: scorerMessage $num "Error trying to update set$setId.sb" error
1473: return
1474: }
1475: cd $cwd
1476: }
1477: scorerMessage $num "Finished updating. . ."
1478: update idletasks
1479:
1480: set gScorer(needToUpdateDB) 0
1481: if { [makeSure "Should I copy the updated set$setId.sb to set$setId.db"] == "Yes" } {
1482: if { [file exists [file join $gFile($num) records set$setId.db] ] } {
1483: if { [catch {file delete [file join $gFile($num) records set$setId.db]}]} {
1484: scorerMessage $num "An error occured while trying to copy. Please do this by hand." error
1485: }
1486: }
1487: if { [catch {file copy [file join $gFile($num) records set$setId.sb] \
1488: [file join $gFile($num) records set$setId.db] }] } {
1489: scorerMessage $num "An error occured while trying to copy. Please do this by hand." error
1490: }
1491: }
1492: scorerMessage $num "Done"
1493: }
1494:
1495: ###########################################################
1496: # scorerToSet
1497: ###########################################################
1498: ###########################################################
1499: ###########################################################
1500: proc scorerToSet { num } {
1501: global gScorer
1502:
1503: #getGradingMethod
1504: set gradeWindow [toplevel .getGradingMethod$num]
1505:
1506: set messageFrame [frame $gradeWindow.mesg]
1507: set capaFrame [frame $gradeWindow.capa]
1508: set lenientFrame [frame $gradeWindow.lenient]
1509: set strictFrame [frame $gradeWindow.strict]
1510: set cancelFrame [frame $gradeWindow.cancel]
1511: pack $messageFrame $capaFrame $lenientFrame $strictFrame $cancelFrame \
1512: -side top
1513:
1514: label $messageFrame.mesg -text "Please Select a Grading Method:"
1515: pack $messageFrame.mesg
1516:
1517: button $capaFrame.capa -text "CAPA Standard" -command "scorerToSet2 $num CAPA"
1518: # button $capaFrame.huh -text "Huh?"
1519: pack $capaFrame.capa -side left
1520:
1521: button $lenientFrame.lenient -text "Lenient Method" \
1522: -command "scorerToSet2 $num Lenient"
1523: # button $lenientFrame.huh -text "Huh?"
1524: pack $lenientFrame.lenient -side left
1525:
1526: button $strictFrame.strict -text "Strict Method" \
1527: -command "scorerToSet2 $num Strict"
1528: # button $strictFrame.huh -text "Huh?"
1529: pack $strictFrame.strict -side left
1530:
1531: button $cancelFrame.cancel -text "Cancel" -command "destroy $gradeWindow"
1532: pack $cancelFrame.cancel
1533: Centre_Dialog $gradeWindow default
1534: }
1535:
1536: ###########################################################
1537: # scorerQuit
1538: ###########################################################
1539: ###########################################################
1540: ###########################################################
1541: proc scorerQuit { num } {
1542: global gScorer
1543: set gScorer(pause.$num) 1
1544: set gScorer(quit.$num) 1
1545: puts [trace vinfo gScorer(quit.$num)]
1546: catch {scorerMessage $num "Quitting. . . " info}
1547: }
1548:
1549: ###########################################################
1550: # scorerClose
1551: ###########################################################
1552: ###########################################################
1553: ###########################################################
1554: proc scorerClose { num {mustClose 0} {dummy ""} {dummy2 ""} {dummy3 ""}} {
1555: global gScorer
1556:
1557: puts "scorerClose"
1558: set message "Are you sure you wish to close?"
1559: catch {
1560: if { $gScorer(needToUpdateDB) } {
1561: set message \
1562: "Are you sure you wish to close, you haven't yet updated the .sb file."
1563: }
1564: }
1565: if { (! $mustClose ) && [makeSure $message ] == "Cancel" } { return 0 }
1566: stopScorer $num
1567: destroy .beginScorer$num
1568: # freeStudentList $num
1569: return 1
1570: }
1571:
1572: ###########################################################
1573: # loadScorerQuest
1574: ###########################################################
1575: ###########################################################
1576: ###########################################################
1577: proc loadScorerQuest { num } {
1578: global gScorer gFile
1579:
1580: set filename [file join $gFile($num) records scorer.output.$gScorer(set.$num)]
1581: if { [ catch { set fileId [ open $filename "r" ] } ] } {
1582: displayError "The set $gScorer(set.$num) does not yet have an scorer.output file. "
1583: return
1584: }
1585: set line [gets $fileId ]
1586: close $fileId
1587: set numQuestions [lindex $line 2]
1588: set flags [lindex $line 4]
1589: $gScorer(quest.$num) delete 0 end
1590: for { set i 0 } { $i < $numQuestions } { incr i } {
1591: switch [string index $flags [expr $i * 3] ] {
1592: a { set gScorer(questType.$num) ONE_OUT_OF_10 }
1593: b { set gScorer(questType.$num) GLE }
1594: c { set gScorer(questType.$num) TF }
1595: d { set gScorer(questType.$num) ASSIGNED }
1596: e { set gScorer(questType.$num) N_OUT_OF_M }
1597: f { set gScorer(questType.$num) SINGLE_DIGIT }
1598: g { set gScorer(questType.$num) STRING_MATCH }
1599: }
1600: set gScorer(questPoint.$num) [string index $flags [expr $i * 3 + 1] ]
1601: set gScorer(questLeaf.$num) [string index $flags [expr $i * 3 + 2] ]
1602: insertQuest $num end
1603: }
1604: }
1605:
1606: ###########################################################
1607: # reScore
1608: ###########################################################
1609: ###########################################################
1610: ###########################################################
1611: proc reScore { file } {
1612: global gUniqueNumber gScorer gFile
1613: set num [incr gUniqueNumber]
1614: if { [catch {set gScorer(out.$num) [open $file "r"]}]} {
1615: displayError "Unable to open $file"
1616: return
1617: }
1618: set gScorer(set.$num) [lindex [split $file .] end]
1619: set gFile($num) [file dirname [file dirname $file]]
1620: set line [gets $gScorer(out.$num) ]
1621: set gScorer(numQuest.$num) [lindex $line 2]
1622: set flags [lindex $line 4]
1623: for { set i 0 } { $i < $gScorer(numQuest.$num) } { incr i } {
1624: switch [string index $flags [expr $i * 3] ] {
1625: a { set gScorer(quest.$i.type.$num) ONE_OUT_OF_10 }
1626: b { set gScorer(quest.$i.type.$num) GLE }
1627: c { set gScorer(quest.$i.type.$num) TF }
1628: d { set gScorer(quest.$i.type.$num) ASSIGNED }
1629: e { set gScorer(quest.$i.type.$num) N_OUT_OF_M }
1630: f { set gScorer(quest.$i.type.$num) SINGLE_DIGIT }
1631: g { set gScorer(quest.$i.type.$num) STRING_MATCH }
1632: }
1633: set gScorer(quest.$i.points.$num) [string index $flags [expr $i * 3 + 1] ]
1634: set gScorer(quest.$i.leafs.$num) [string index $flags [expr $i * 3 + 2] ]
1635: }
1636:
1637: set reScore [toplevel .reScore$num]
1638: wm title $reScore "ReScoring $file"
1639:
1640: set windowFrame [frame $reScore.windowFrame]
1641: set buttonFrame [frame $reScore.buttonFrame]
1642: pack $windowFrame $buttonFrame -side bottom
1643: pack configure $windowFrame -expand true -fill both
1644: pack configure $buttonFrame -anchor e
1645:
1646: scrollbar $windowFrame.scroll -orient vertical -command \
1647: "$windowFrame.text yview"
1648: set gScorer(status.$num) [text $windowFrame.text -yscrollcommand \
1649: "$windowFrame.scroll set" -wrap char -height 40]
1650: pack $windowFrame.scroll $gScorer(status.$num) -side left -expand 0
1651: pack configure $windowFrame.scroll -expand 0 -fill y
1652: pack configure $gScorer(status.$num) -expand true -fill both
1653:
1654: button $buttonFrame.ok -text Dismiss -command \
1655: "destroy $reScore
1656: catch {close $gScorer(out.$num)}"
1657: bind $reScore <Destroy> "catch {close $gScorer(out.$num)}"
1658: button $buttonFrame.save -text "Save Messages" -command "saveScorerMsg $num"
1659: button $buttonFrame.print -text "Print Messages" -command "printScorerMsg $num"
1660: pack $buttonFrame.print $buttonFrame.save $buttonFrame.ok -side left
1661:
1662: Centre_Dialog $reScore default
1663: update
1664: scorerToSet $num
1665: }
1666:
1667: #The flags struct is
1668: # name
1669: # question to ask
1670: # yes (1) response
1671: # no (0) response
1672: set gScorer(flags) \
1673: {
1674: {
1675: CheckPIN
1676: {Is there a capaID/CODE on the paper?}
1677: Yes
1678: No
1679: 1
1680: }
1681: {
1682: AnonMode
1683: {Is this an anonymous Exam?}
1684: Yes
1685: No
1686: 0
1687: }
1688: {
1689: QueryAboutPID
1690: {When finding multiple PIDs matching a capaID:}
1691: {Ask which to use}
1692: {Pick one with highest score}
1693: 0
1694: }
1695: }
1696: # {
1697: # SurveyMode
1698: # {What is being scanned?}
1699: # Survey
1700: # Exam/Quiz
1701: # 0
1702: # }
1703: # {
1704: # SurveyHeader
1705: # {Does the Survey have a header?}
1706: # Yes
1707: # No
1708: # 0
1709: # }
1710:
1711: # {
1712: # CheckSpaces
1713: # {Should scorer worry about blank questions?}
1714: # Yes
1715: # No
1716: # 0
1717: # }
1718: # {
1719: # CheckMultipleMarks
1720: # {Should scorer worry about multiple marks on single mark questions?}
1721: # Yes
1722: # No
1723: # 0
1724: # }
1725: # {
1726: # IdFormat
1727: # {What format is the student number in?}
1728: # A<number>
1729: # {Social Security}
1730: # 1
1731: # }
1732: # {
1733: # Form
1734: # {Which form size is being used? Select Half Sheet}
1735: # {Full sheet}
1736: # {Half Sheet}
1737: # 0
1738: # }
1739: # {
1740: # log
1741: # {When encountering errors: Select Query the User}
1742: # {Log them}
1743: # {Query the user}
1744: # 1
1745: # }
1746:
1747: #Counting from zero, first number is column of start of the field,
1748: #second number is end of the field. The Question field is an
1749: #exception first comes start of question responses then # of
1750: #responses, and then the number of bubbles per response
1751: #Full Sheet Specs
1752: set gScorer(FullSheet.SerialNumber) { 5 8 }
1753: set gScorer(FullSheet.LastName) { 40 49 }
1754: set gScorer(FullSheet.FirstName) { 50 54 }
1755: set gScorer(FullSheet.MiddleInitial) { 55 55 }
1756: set gScorer(FullSheet.StudentNumber) { 56 64 }
1757: set gScorer(FullSheet.Section) { 65 67 }
1758: set gScorer(FullSheet.CapaID) { }
1759: #No CapaID spot on full sheet
1760: set gScorer(FullSheet.Question) { 76 50 10 }
1761:
1762: #Half Sheet Specs
1763: set gScorer(HalfSheet.SerialNumber) { 5 8 }
1764: set gScorer(HalfSheet.LastName) { 40 49 }
1765: set gScorer(HalfSheet.FirstName) { 50 50 }
1766: set gScorer(HalfSheet.MiddleInitial) { }
1767: #No Middle Initial
1768: set gScorer(HalfSheet.StudentNumber) { 56 64 }
1769: set gScorer(HalfSheet.Section) { 65 67 }
1770: set gScorer(HalfSheet.CapaID) { 68 73 }
1771: set gScorer(HalfSheet.Question) { 76 50 10 }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>