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