Annotation of capa/capa51/GUITools/scorer.tcl, revision 1.10
1.1 albertel 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
1.5 albertel 156: # trace variable gScorer(quit.$num) w "scorerClose $num 0"
1.1 albertel 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" ] } ] } {
1.10 ! albertel 169: displayMessage "Creating a new scorer.output file for set $gScorer(set.$num)."
1.1 albertel 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
1.6 albertel 415: update
416: $gScorer(quest.$num) see $where
1.1 albertel 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
1.6 albertel 512: $gScorer(quest.$num) see end
1.1 albertel 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:
1.2 albertel 647: button $statusButtons.handleErrors -text "Save Errors" \
1.1 albertel 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:
1.4 albertel 767: scorerMessage $num "\nGetting Responses"
1.1 albertel 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
1.9 albertel 833: set parsedIn(maxQuest) $maxQuest
1.1 albertel 834: for { set i 0 } { $i < $maxQuest } { incr i } {
835: if { [ catch { set gScorer(quest.$i.type.$num) } ] } {
836: set parsedIn(maxQuest) $i
837: set gScorer(numQuest.$num) $i
838: break
839: }
840: set array $letter
841: set start [expr $i * $perQuest + $offset ]
842: set stop [expr $start + $perQuest - 1 ]
843: set response [string range "$answerLine" $start $stop]
844: switch $gScorer(quest.$i.type.$num) {
845: ASSIGNED -
846: SINGLE_DIGIT -
847: ONE_OUT_OF_10 {
848: if { $gScorer(quest.$i.type.$num) != "ONE_OUT_OF_10" } {
849: set array $number
850: }
851: set howmany [oneResponse "$response" $perQuest which]
852: if { $howmany == 1 } {
853: set parsedIn(answer.$i) [string index $array $which]
854: } else {
855: if { $howmany > 1 } {
856: set parsedIn(answer.$i) " "
857: incr parsedIn(multiplemarks)
858: } else {
859: if { $howmany < 1 } {
860: set parsedIn(answer.$i) " "
861: incr parsedIn(spaces)
862: }
863: }
864: }
865: }
866: GLE -
867: TF {
868: if { $gScorer(quest.$i.type.$num) != "GLE" } {
869: set stepsize 2
870: } else {
871: set stepsize 3
872: }
873: set leafs $gScorer(quest.$i.leafs.$num)
874: for { set j 0 } { $j < $leafs } { incr j } {
875: set start [expr $j*$stepsize]
876: set stop [expr $start + $stepsize - 1]
877: set howmany [oneResponse [string range \
878: $response $start $stop] $perQuest which]
879: if { $howmany == 1 } {
880: append parsedIn(answer.$i) [string index $array \
881: [expr {$start + $which}]]
882: } else {
883: if { $howmany > 1 } {
884: append parsedIn(answer.$i) " "
885: incr parsedIn(multiplemarks)
886: } else {
887: if { $howmany < 1 } {
888: append parsedIn(answer.$i) " "
889: incr parsedIn(spaces)
890: }
891: }
892: }
893: }
894: }
895: N_OUT_OF_M -
896: STRING_MATCH {
897: set found 0
898: for { set j 0 } { $j < $perQuest } { incr j } {
899: set char [string index "$response" $j]
900: if { "$char" == 1 } {
901: append parsedIn(answer.$i) [string index $array $j]
902: incr found
903: }
904: }
905: if { ! $found } {
906: incr parsedIn(spaces)
907: set parsedIn(answer.$i) ""
908: }
909: }
910: }
911: }
912: #if there isn't a capaId already, treat the first four questions as
913: # capaID
914: # if { $parsedIn(CapaID) == "" && $gScorer(CheckPIN.$num) } {
915: # set pinWrong 0
916: # for {set j 0} {$j < 4} {incr j} {
917: # switch -regexp "$parsedIn(answer.$j)" {
918: # ^[A-J]$ {
919: # append parsedIn(CapaID) \
920: [string first $parsedIn(answer.$j) "ABCDEFGHIJ" ]
921: # }
922: # default {
923: # set pinWrong 1
924: # }
925: # }
926: # }
927: # if { $pinWrong } {
928: # scorerError $num PINWRONG parsedIn
929: # lappend result PINWRONG
930: # }
931: # }
932: # parray parsedIn
933: if { $result != "" } {
934: error "$result"
935: }
936: }
937:
938: proc getAnswers2 { PID set maxQuest num } {
939: global gFile
940: set pwd [pwd]
941: cd $gFile($num)
942: set result [getAnswersFromSet $PID $set $maxQuest]
943: cd $pwd
944: return $result
945: }
946:
947: proc getAnswers { PID set maxQuest num } {
948: global gFile gCapaConfig
949: set pwd [pwd]
950: cd $gFile($num)
1.7 albertel 951: set temp [exec $gCapaConfig($num.answers_command) $PID {} 0 $set]
1.1 albertel 952: cd $pwd
953: set result ""
954: foreach line [split $temp "\n"] {
955: switch [lindex [split $line :] 0] {
956: ANS { lappend result [string range $line 4 end] }
957: }
958: }
959: return $result
960: }
961:
962: ###########################################################
963: # checkStudentNumber
964: ###########################################################
965: ###########################################################
966: ###########################################################
967: proc checkStudentNumber { num answerStructVar } {
968: global gScorer gFile
969: upvar $answerStructVar answerStruct
970:
971: # puts "Stunum1:$answerStruct(StudentNumber):"
972: if { ![inClasslist $num $answerStruct(StudentNumber)] } {
973: # puts "Stunum2:$answerStruct(StudentNumber):"
974: set matched [findByStudentName [string trim $answerStruct(LastName)] $gFile($num)]
975: if { [llength $matched] != 1 } {
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: set id [lindex [lindex $matched 0] 0]
979: if { [makeSure "Unable to find bubbled id: $answerStruct(StudentNumber), name: $answerStruct(LastName) in classl, however I did find $matched. Use this one?"] != "Yes" } {
980: 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)"
981: } else {
982: }
983: }
984: if { $id == "" } {
985: scorerError $num NO_SUCH_STUDENT "$answerStruct(orignalLine)" \
986: $answerStruct(StudentNumber)
987: return 0
988: } else {
989: scorerMessage $num "Student Number $answerStruct(StudentNumber) not found in classl using $id instead." info
990: set answerStruct(StudentNumber) $id
991: }
992: }
993: # puts "Stunum3:$answerStruct(StudentNumber):"
994: return 1
995: }
996:
997: ###########################################################
998: # handleStudent
999: ###########################################################
1000: ###########################################################
1001: ###########################################################
1002: proc handleStudent { num answerStructVar} {
1003: global gScorer gFile
1004: upvar $answerStructVar answerStruct
1005:
1006: if { ![checkStudentNumber $num answerStruct] } { return 0 }
1007:
1008: scorerMessage $num "Finding Possible Students. . ."
1009: if { ! $gScorer(AnonMode.$num) } {
1010: set answerStruct(questionPID) $answerStruct(StudentNumber)
1011: } else {
1012: # puts "$answerStruct(StudentNumber):$answerStruct(CapaID):"
1013: if { [string trim $answerStruct(CapaID)] == "" } {
1014: scorerError $num NO_CODE_IN_ANON_MODE "$answerStruct(orignalLine)" \
1015: $answerStruct(StudentNumber)
1016: return 0
1017: }
1018: set answerStruct(questionPID) [getAnonModeID $num answerStruct]
1019: if { [llength $answerStruct(questionPID)] > 6 } {
1020: scorerError $num LOTS_OF_ANON_MODE_MATCHES "$answerStruct(orignalLine)" \
1021: $answerStruct(StudentNumber)
1022: return 0
1023: }
1024: }
1025:
1026: set answerStruct(Name) "$answerStruct(LastName) $answerStruct(FirstName) $answerStruct(MiddleInitial)"
1027:
1028: scorerMessage $num "Getting Possible Answers for $answerStruct(StudentNumber), paper# $answerStruct(SerialNumber). . ."
1029: foreach questionPID $answerStruct(questionPID) {
1030: scorerMessage $num "Getting Answers for $questionPID. . ."
1031: if { [catch { set answerStruct(correct.$questionPID) \
1032: [getAnswers $questionPID $gScorer(set.$num) \
1033: $answerStruct(maxQuest) $num] } errorMsg ] } {
1.8 albertel 1034: catch {puts $errorMsg}
1.1 albertel 1035: scorerError $num UNABLE_TO_PARSE "$answerStruct(orignalLine)" \
1036: $answerStruct(StudentNumber)
1037: error UNABLE_TO_PARSE
1038: }
1039: # puts "$answerStruct(correct.$questionPID)"
1040: }
1041:
1042: scorerMessage $num "Grading Answers. . ."
1043: foreach questionPID $answerStruct(questionPID) {
1044: set answerStruct($questionPID.grade) [gradeSet $num answerStruct $questionPID]
1045: scorerMessage $num "Correct: $answerStruct($questionPID.correct) #correct: $answerStruct($questionPID.grade) PID: $questionPID"
1046: }
1047: scorerMessage $num "Given: $answerStruct($questionPID.given)"
1048: if { [llength $answerStruct(questionPID)] > 1 } {
1049: scorerMessage $num "Selecting Student. . ."
1050: if { $gScorer(QueryAboutPID.$num) } {
1051: set answerStruct(questionPID) \
1052: [getWhichAnon $num answerStruct $answerStruct(indices)]
1053: } else {
1054: set answerStruct(questionPID) \
1055: [pickAnonHighest $num answerStruct $answerStruct(indices)]
1056: }
1057: scorerMessage $num "Student $answerStruct(StudentNumber) selected $answerStruct(questionPID)'s paper." info
1058: }
1059: return 1
1060: }
1061:
1062: ###########################################################
1063: # gradeQuestion
1064: ###########################################################
1065: ###########################################################
1066: ###########################################################
1067: proc gradeQuestion { num questNum correct given answerStructVar } {
1068: global gScorer
1069: upvar $answerStructVar answerStruct
1070: set numRight 0
1071: switch $gScorer(quest.$questNum.type.$num) {
1072: ONE_OUT_OF_10 -
1073: GLE -
1074: TF -
1075: SINGLE_DIGIT {
1076: # scorerMessage $num "The correct answer: $correct, The student's answer: $given"
1077: set fmt "%-$gScorer(quest.$questNum.leafs.$num)s,"
1078: append answerStruct(correct) [format $fmt $correct]
1079: append answerStruct(given) [format $fmt $given]
1080: for { set leafs 0 } { $leafs < $gScorer(quest.$questNum.leafs.$num)
1081: } { incr leafs } {
1082: if { [string index $correct $leafs] ==
1083: [string index $given $leafs] } {
1084: incr numRight
1085: }
1086: }
1087: }
1088: ASSIGNED {
1089: # scorerMessage $num "The student got a $given out of $gScorer(quest.$questNum.points.$num) "
1090: append answerStruct(correct) "$gScorer(quest.$questNum.points.$num),"
1091: append answerStruct(given) "$given,"
1092: if { [catch {incr given 0}] } {
1093: set numRight 0
1094: } else {
1095: set numRight $given
1096: }
1097: }
1098: N_OUT_OF_M {
1099: # scorerMessage $num "The correct answer: $correct, The student's answer: $given"
1100: set fmt "%-$gScorer(quest.$questNum.leafs.$num)s,"
1101: append answerStruct(correct) [format $fmt $correct]
1102: append answerStruct(given) [format $fmt $given]
1103: set letters "ABCDEFGHIJ"
1104: set maxLeaf $gScorer(quest.$questNum.leafs.$num)
1105: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1106: if { [string first [string index $letters $leaf] $correct] != -1 } {
1107: set ansOn($leaf) 1
1108: } else {
1109: set ansOn($leaf) 0
1110: }
1111: }
1112: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1113: if { [string first [string index $letters $leaf] $given] != -1 } {
1114: set stuOn($leaf) 1
1115: } else {
1116: set stuOn($leaf) 0
1117: }
1118: }
1119: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1120: if { $ansOn($leaf) == $stuOn($leaf) } { incr numRight }
1121: }
1122: }
1123: STRING_MATCH {
1124: # scorerMessage $num "The correct answer: $correct, The student's answer: $given"
1125: set fmt "%-$gScorer(quest.$questNum.leafs.$num)s,"
1126: append answerStruct(correct) [format $fmt $correct]
1127: append answerStruct(given) [format $fmt $given]
1128: set letters "ABCDEFGHIJ"
1129: set maxLeaf 10
1130: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1131: if { [string first [string index $letters $leaf] $correct] != -1 } {
1132: set ansOn($leaf) 1
1133: } else {
1134: set ansOn($leaf) 0
1135: }
1136: }
1137: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1138: if { [string first [string index $letters $leaf] $given] != -1 } {
1139: set stuOn($leaf) 1
1140: } else {
1141: set stuOn($leaf) 0
1142: }
1143: }
1144: for { set leaf 0 } { $leaf < $maxLeaf } { incr leaf } {
1145: if { $ansOn($leaf) == $stuOn($leaf) } { incr numRight }
1146: }
1147: if { $numRight != $maxLeaf } { set numRight 0 }
1148: }
1149: default {
1150: scorerMessage $num "Unknown question type while grading,"
1151: }
1152: }
1153: return $numRight
1154: }
1155:
1156: ###########################################################
1157: # gradeSet
1158: ###########################################################
1159: ###########################################################
1160: ###########################################################
1161: proc gradeSet { num answerStructVar questionPID } {
1162: global gScorer
1163: upvar $answerStructVar answerStruct
1164:
1165: set numRight 0
1166: for { set i 0 } { $i < $answerStruct(maxQuest) } { incr i } {
1167: set correct [lindex $answerStruct(correct.$questionPID) $i]
1168: set given $answerStruct(answer.$i)
1169: set probRight [gradeQuestion $num $i $correct $given answerStruct]
1170: incr numRight $probRight
1171: append answerStruct($questionPID.numRight) $probRight
1172: }
1173: set answerStruct($questionPID.correct) $answerStruct(correct)
1174: set answerStruct(correct) ""
1175: set answerStruct($questionPID.given) $answerStruct(given)
1176: set answerStruct(given) ""
1177: return $numRight
1178: }
1179:
1180:
1181: ###########################################################
1182: # getScorerEntry
1183: ###########################################################
1184: ###########################################################
1185: ###########################################################
1186: proc getScorerEntry { num PID } {
1187: global gScorer
1188:
1189: set fileId $gScorer(out.$num)
1190: seek $fileId 0 start
1191: set done 0
1192: set found 0
1193: set aline ""
1194: set offset 0
1195: while { ! $done } {
1196: set readamt [gets $fileId aline]
1197: if { [eof $fileId] } { set done 0 ; break}
1198: if { 0 == [ string compare [string toupper [lindex $aline 0]] \
1199: [string toupper $PID] ] } {
1200: set done 1
1201: set found 1
1202: } else {
1203: #plus one because gets swallows the newline it reads
1204: set offset [expr $offset + $readamt + 1]
1205: }
1206: }
1207: if { ! $found } { set offset -$offset }
1208: return $offset
1209: }
1210:
1211: ###########################################################
1212: # setScorerEntry
1213: ###########################################################
1214: ###########################################################
1215: ###########################################################
1216: proc setScorerEntry { num aline offset } {
1217: global gScorer
1218:
1219: set fileId $gScorer(out.$num)
1220: seek $fileId [expr abs($offset)] start
1221: puts $fileId $aline
1222: }
1223:
1224: ###########################################################
1225: # setOutput
1226: ###########################################################
1227: ###########################################################
1228: ###########################################################
1229: proc setOutput { num answerStructVar} {
1230: global gScorer
1231: upvar $answerStructVar answerStruct
1232:
1233: #FIXME what if questions PID is empty
1234: set questionPID $answerStruct(questionPID)
1235: set out [format "%9s %-30s %s %4s %3s %s %s %s" $answerStruct(StudentNumber) \
1236: $answerStruct(Name) $answerStruct($questionPID.numRight) \
1237: $answerStruct($questionPID.grade) $answerStruct(Section) \
1238: $answerStruct($questionPID.given) $questionPID \
1239: $answerStruct(SerialNumber)]
1240: set offset [getScorerEntry $num $answerStruct(StudentNumber)]
1241: setScorerEntry $num "$out" $offset
1242: }
1243:
1244: ###########################################################
1245: # finishScoring
1246: ###########################################################
1247: ###########################################################
1248: ###########################################################
1249: proc finishScoring { num answerStructVar} {
1250: global gScorer
1251: scorerMessage $num "Finishing . . ."
1252: # puts "errors:"
1253: # puts "$gScorer(errors.$num)"
1254: scorerMessage $num "Finished, Feel free to Update .sb"
1255: if { [makeSure "Would you like to update the .sb file?"] == "Yes" } {
1256: scorerToSet $num
1257: }
1258: trace variable gScorer(quit.$num) w "scorerClose $num 0"
1259: }
1260:
1261: proc scorerStudentTime { num } {
1262: puts [ time "scorerStudent $num" ]
1263: }
1264:
1265: ###########################################################
1266: # scorerStudent
1267: ###########################################################
1268: ###########################################################
1269: ###########################################################
1270: proc scorerStudent { num } {
1271: global gScorer
1272:
1273: if { $gScorer(pause.$num) } {
1274: if { [array names gScorer quit.$num] != "" } {
1275: if { ![scorerClose $num] } {
1276: unset gScorer(quit.$num)
1277: set gScorer(pause.$num) 0
1278: } else {
1279: return
1280: }
1281: }
1282: if { $gScorer(pause.$num) == 1 } {
1283: scorerMessage $num "Pausing. . . " info
1284: set gScorer(pause.$num) 2
1285: }
1286: after 100 "scorerStudent $num"
1287: return
1288: }
1289: #getanswerline
1290: if { [ catch { set answer [ getLine $num ] } ] } {
1291: finishScoring $num answerStruct
1292: return
1293: }
1294: set gScorer(needToUpdateDB) 1
1295: #parseanswerline
1296: if { [catch {parseLine $num $answer answerStruct} errorMsg ] } {
1297: displayError "Error parsing line: $errorMsg"
1298: } else {
1299: #parse the set and grades it for any possiblely matching student
1300: if { ! [ catch { set result [handleStudent $num answerStruct]} errorMsg ] } {
1301: #write entry to outputfile if student was succesfully handled
1302: if { $result } { setOutput $num answerStruct }
1303: } else { #error handling Student
1304: global errorCode errorInfo
1305: displayError "An error occured when attempting to grade a student. The error is: $errorMsg"
1306: }
1307: }
1.4 albertel 1308: incr gScorer(student.$num)
1309: update
1.1 albertel 1310: after idle "scorerStudent $num"
1311: }
1312:
1313: ###########################################################
1314: # restartScorer
1315: ###########################################################
1316: ###########################################################
1317: ###########################################################
1318: proc restartScorer { num } {
1319: global gScorer
1320: if { ! [info exists gScorer(pause.$num) ] } {
1321: initScorer $num
1322: set gScorer(pause.$num) 0
1323: } else {
1324: }
1325: after idle "scorerStudent $num"
1326: }
1327:
1328: ###########################################################
1329: # pauseScorer
1330: ###########################################################
1331: ###########################################################
1332: ###########################################################
1333: proc pauseScorer { num } {
1334: global gScorer
1335: set gScorer(pause.$num) 1
1336: }
1337:
1338: ###########################################################
1339: # stopScorer
1340: ###########################################################
1341: ###########################################################
1342: ###########################################################
1343: proc stopScorer { num } {
1344: }
1345:
1346: ###########################################################
1347: # unpauseScorer
1348: ###########################################################
1349: ###########################################################
1350: ###########################################################
1351: proc unpauseScorer { num } {
1352: global gScorer
1353: set gScorer(pause.$num) 0
1354: }
1355:
1356: ###########################################################
1357: ###########################################################
1358: ###########################################################
1359: ###########################################################
1360: proc finalScorer { num method studentNumber numRight } {
1361: global gScorer
1362:
1363: set answers ""
1364: for { set i 0 } { $i < $gScorer(numQuest.$num) } { incr i } {
1365: switch $gScorer(quest.$i.type.$num) {
1366: ONE_OUT_OF_10 -
1367: SINGLE_DIGIT {
1368: append answers [ expr [string index $numRight $i] * \
1369: $gScorer(quest.$i.points.$num) ]
1370: }
1371: GLE -
1372: TF -
1373: N_OUT_OF_M {
1374: set right [string index $numRight $i]
1375: set leafs $gScorer(quest.$i.leafs.$num)
1376: set points $gScorer(quest.$i.points.$num)
1377: set unit [expr double($points)/double($leafs)]
1378: if { $unit == 0 } { set unit $points }
1379: switch $method {
1380: CAPA {
1381: set score [expr int($points-(2*$unit*($leafs-$right)))]
1382: if { $score < 0 } { set score 0 }
1383: }
1384: Lenient {
1385: set score [expr int($points-($unit*($leafs-$right)))]
1386: }
1387: Strict {
1388: if { $right == $leafs } {
1389: set score $points
1390: } else {
1391: set score 0
1392: }
1393: }
1394: default {
1395: scorerError $num UNKNOWN_GRADING_METHOD $method
1396: }
1397: }
1398: append answers $score
1399: }
1400: STRING_MATCH -
1401: ASSIGNED {
1402: append answers [string index $numRight $i]
1403: }
1404: default {
1405: }
1406: }
1407: }
1408: return $answers
1409: }
1410:
1411: ###########################################################
1412: # scorerToSet2
1413: ###########################################################
1414: ###########################################################
1415: ###########################################################
1416: proc scorerToSet2 { num method } {
1417: global gScorer gFile
1418: destroy .getGradingMethod$num
1419:
1420: set processed 0
1421: set done 0
1422: set fileId $gScorer(out.$num)
1423: set setId $gScorer(set.$num)
1424: seek $fileId 0 start
1425:
1426: #remove the header line
1427: gets $fileId aline
1428:
1429: scorerMessage $num "Processing. . ."
1430: while { ! $done } {
1431: gets $fileId aline
1432: if { [eof $fileId] } {
1433: set done 1
1434: break
1435: }
1436: set studentNumber [lindex $aline 0]
1437: incr processed
1438: if { [ expr $processed % 100 ] == 0 } { scorerMessage $num $processed }
1439: update idletasks
1440: set cwd [pwd]
1441: cd $gFile($num)
1442: if { ![file exists [file join records set$setId.sb] ] } {
1443: if { ![file exists [file join records set$setId.db] ] } {
1444: cd $cwd
1445: scorerMessage $num "set$setId.db does not exist" error
1446: return
1447: } else {
1448: scorerMessage $num "Copying set$setId.db to set$setId.sb"
1449: if { [catch {file copy [file join records set$setId.db] \
1450: [file join records set$setId.sb] }] } {
1451: cd $cwd
1452: scorerMessage $num "Unable to create set$setId.sb from set$setId.db, please create it by hand" error
1453: return
1454: }
1455: }
1456: }
1457: if { [catch { set offset [ scorer_get_entry $studentNumber $setId ] } errors] } {
1458: cd $cwd
1459: scorerMessage $num "Error trying to read set$setId.sb" error
1460: return
1461: }
1462: cd $cwd
1463: set name [string range $aline 10 39]
1464: set numRight [lindex [string range $aline 40 end] 0]
1465: set entry(answers) [ finalScorer $num $method $studentNumber $numRight ]
1466: set entry(tries) ""
1467: for { set i 0 } { $i < $gScorer(numQuest.$num) } { incr i } {
1468: append entry(tries) ", 1"
1469: }
1470: set entry(tries) [string range $entry(tries) 1 end]
1471: set cwd [pwd]
1472: cd $gFile($num)
1473: if { [ catch { scorer_set_entry $studentNumber $setId $offset \
1474: $entry(answers) $entry(tries) } errors ] } {
1475: cd $cwd
1476: scorerMessage $num "Error trying to update set$setId.sb" error
1477: return
1478: }
1479: cd $cwd
1480: }
1481: scorerMessage $num "Finished updating. . ."
1482: update idletasks
1483:
1484: set gScorer(needToUpdateDB) 0
1485: if { [makeSure "Should I copy the updated set$setId.sb to set$setId.db"] == "Yes" } {
1486: if { [file exists [file join $gFile($num) records set$setId.db] ] } {
1487: if { [catch {file delete [file join $gFile($num) records set$setId.db]}]} {
1488: scorerMessage $num "An error occured while trying to copy. Please do this by hand." error
1489: }
1490: }
1491: if { [catch {file copy [file join $gFile($num) records set$setId.sb] \
1492: [file join $gFile($num) records set$setId.db] }] } {
1493: scorerMessage $num "An error occured while trying to copy. Please do this by hand." error
1494: }
1495: }
1496: scorerMessage $num "Done"
1497: }
1498:
1499: ###########################################################
1500: # scorerToSet
1501: ###########################################################
1502: ###########################################################
1503: ###########################################################
1504: proc scorerToSet { num } {
1505: global gScorer
1506:
1507: #getGradingMethod
1508: set gradeWindow [toplevel .getGradingMethod$num]
1509:
1510: set messageFrame [frame $gradeWindow.mesg]
1511: set capaFrame [frame $gradeWindow.capa]
1512: set lenientFrame [frame $gradeWindow.lenient]
1513: set strictFrame [frame $gradeWindow.strict]
1514: set cancelFrame [frame $gradeWindow.cancel]
1515: pack $messageFrame $capaFrame $lenientFrame $strictFrame $cancelFrame \
1516: -side top
1517:
1518: label $messageFrame.mesg -text "Please Select a Grading Method:"
1519: pack $messageFrame.mesg
1520:
1521: button $capaFrame.capa -text "CAPA Standard" -command "scorerToSet2 $num CAPA"
1522: # button $capaFrame.huh -text "Huh?"
1523: pack $capaFrame.capa -side left
1524:
1525: button $lenientFrame.lenient -text "Lenient Method" \
1526: -command "scorerToSet2 $num Lenient"
1527: # button $lenientFrame.huh -text "Huh?"
1528: pack $lenientFrame.lenient -side left
1529:
1530: button $strictFrame.strict -text "Strict Method" \
1531: -command "scorerToSet2 $num Strict"
1532: # button $strictFrame.huh -text "Huh?"
1533: pack $strictFrame.strict -side left
1534:
1535: button $cancelFrame.cancel -text "Cancel" -command "destroy $gradeWindow"
1536: pack $cancelFrame.cancel
1537: Centre_Dialog $gradeWindow default
1538: }
1539:
1540: ###########################################################
1541: # scorerQuit
1542: ###########################################################
1543: ###########################################################
1544: ###########################################################
1545: proc scorerQuit { num } {
1546: global gScorer
1547: set gScorer(pause.$num) 1
1548: set gScorer(quit.$num) 1
1.8 albertel 1549: #puts [trace vinfo gScorer(quit.$num)]
1.1 albertel 1550: catch {scorerMessage $num "Quitting. . . " info}
1551: }
1552:
1553: ###########################################################
1554: # scorerClose
1555: ###########################################################
1556: ###########################################################
1557: ###########################################################
1558: proc scorerClose { num {mustClose 0} {dummy ""} {dummy2 ""} {dummy3 ""}} {
1559: global gScorer
1560:
1.5 albertel 1561: set message "Are you sure you wish to close?"
1562: catch {
1563: if { $gScorer(needToUpdateDB) } {
1564: set message \
1565: "Are you sure you wish to close, you haven't yet updated the .sb file."
1566: }
1.1 albertel 1567: }
1568: if { (! $mustClose ) && [makeSure $message ] == "Cancel" } { return 0 }
1569: stopScorer $num
1570: destroy .beginScorer$num
1571: # freeStudentList $num
1572: return 1
1573: }
1574:
1575: ###########################################################
1576: # loadScorerQuest
1577: ###########################################################
1578: ###########################################################
1579: ###########################################################
1580: proc loadScorerQuest { num } {
1581: global gScorer gFile
1582:
1583: set filename [file join $gFile($num) records scorer.output.$gScorer(set.$num)]
1584: if { [ catch { set fileId [ open $filename "r" ] } ] } {
1585: displayError "The set $gScorer(set.$num) does not yet have an scorer.output file. "
1586: return
1587: }
1588: set line [gets $fileId ]
1589: close $fileId
1590: set numQuestions [lindex $line 2]
1591: set flags [lindex $line 4]
1592: $gScorer(quest.$num) delete 0 end
1593: for { set i 0 } { $i < $numQuestions } { incr i } {
1594: switch [string index $flags [expr $i * 3] ] {
1595: a { set gScorer(questType.$num) ONE_OUT_OF_10 }
1596: b { set gScorer(questType.$num) GLE }
1597: c { set gScorer(questType.$num) TF }
1598: d { set gScorer(questType.$num) ASSIGNED }
1599: e { set gScorer(questType.$num) N_OUT_OF_M }
1600: f { set gScorer(questType.$num) SINGLE_DIGIT }
1601: g { set gScorer(questType.$num) STRING_MATCH }
1602: }
1603: set gScorer(questPoint.$num) [string index $flags [expr $i * 3 + 1] ]
1604: set gScorer(questLeaf.$num) [string index $flags [expr $i * 3 + 2] ]
1605: insertQuest $num end
1606: }
1607: }
1608:
1609: ###########################################################
1610: # reScore
1611: ###########################################################
1612: ###########################################################
1613: ###########################################################
1614: proc reScore { file } {
1615: global gUniqueNumber gScorer gFile
1616: set num [incr gUniqueNumber]
1617: if { [catch {set gScorer(out.$num) [open $file "r"]}]} {
1618: displayError "Unable to open $file"
1619: return
1620: }
1621: set gScorer(set.$num) [lindex [split $file .] end]
1622: set gFile($num) [file dirname [file dirname $file]]
1623: set line [gets $gScorer(out.$num) ]
1624: set gScorer(numQuest.$num) [lindex $line 2]
1625: set flags [lindex $line 4]
1626: for { set i 0 } { $i < $gScorer(numQuest.$num) } { incr i } {
1627: switch [string index $flags [expr $i * 3] ] {
1628: a { set gScorer(quest.$i.type.$num) ONE_OUT_OF_10 }
1629: b { set gScorer(quest.$i.type.$num) GLE }
1630: c { set gScorer(quest.$i.type.$num) TF }
1631: d { set gScorer(quest.$i.type.$num) ASSIGNED }
1632: e { set gScorer(quest.$i.type.$num) N_OUT_OF_M }
1633: f { set gScorer(quest.$i.type.$num) SINGLE_DIGIT }
1634: g { set gScorer(quest.$i.type.$num) STRING_MATCH }
1635: }
1636: set gScorer(quest.$i.points.$num) [string index $flags [expr $i * 3 + 1] ]
1637: set gScorer(quest.$i.leafs.$num) [string index $flags [expr $i * 3 + 2] ]
1638: }
1639:
1640: set reScore [toplevel .reScore$num]
1641: wm title $reScore "ReScoring $file"
1642:
1643: set windowFrame [frame $reScore.windowFrame]
1644: set buttonFrame [frame $reScore.buttonFrame]
1645: pack $windowFrame $buttonFrame -side bottom
1646: pack configure $windowFrame -expand true -fill both
1647: pack configure $buttonFrame -anchor e
1648:
1649: scrollbar $windowFrame.scroll -orient vertical -command \
1650: "$windowFrame.text yview"
1651: set gScorer(status.$num) [text $windowFrame.text -yscrollcommand \
1652: "$windowFrame.scroll set" -wrap char -height 40]
1653: pack $windowFrame.scroll $gScorer(status.$num) -side left -expand 0
1654: pack configure $windowFrame.scroll -expand 0 -fill y
1655: pack configure $gScorer(status.$num) -expand true -fill both
1656:
1657: button $buttonFrame.ok -text Dismiss -command \
1658: "destroy $reScore
1659: catch {close $gScorer(out.$num)}"
1660: bind $reScore <Destroy> "catch {close $gScorer(out.$num)}"
1661: button $buttonFrame.save -text "Save Messages" -command "saveScorerMsg $num"
1662: button $buttonFrame.print -text "Print Messages" -command "printScorerMsg $num"
1663: pack $buttonFrame.print $buttonFrame.save $buttonFrame.ok -side left
1664:
1665: Centre_Dialog $reScore default
1666: update
1667: scorerToSet $num
1668: }
1669:
1670: #The flags struct is
1671: # name
1672: # question to ask
1673: # yes (1) response
1674: # no (0) response
1675: set gScorer(flags) \
1676: {
1677: {
1678: CheckPIN
1679: {Is there a capaID/CODE on the paper?}
1680: Yes
1681: No
1682: 1
1683: }
1684: {
1685: AnonMode
1686: {Is this an anonymous Exam?}
1687: Yes
1688: No
1689: 0
1690: }
1691: {
1692: QueryAboutPID
1693: {When finding multiple PIDs matching a capaID:}
1694: {Ask which to use}
1695: {Pick one with highest score}
1696: 0
1697: }
1698: }
1699: # {
1700: # SurveyMode
1701: # {What is being scanned?}
1702: # Survey
1703: # Exam/Quiz
1704: # 0
1705: # }
1706: # {
1707: # SurveyHeader
1708: # {Does the Survey have a header?}
1709: # Yes
1710: # No
1711: # 0
1712: # }
1713:
1714: # {
1715: # CheckSpaces
1716: # {Should scorer worry about blank questions?}
1717: # Yes
1718: # No
1719: # 0
1720: # }
1721: # {
1722: # CheckMultipleMarks
1723: # {Should scorer worry about multiple marks on single mark questions?}
1724: # Yes
1725: # No
1726: # 0
1727: # }
1728: # {
1729: # IdFormat
1730: # {What format is the student number in?}
1731: # A<number>
1732: # {Social Security}
1733: # 1
1734: # }
1735: # {
1736: # Form
1737: # {Which form size is being used? Select Half Sheet}
1738: # {Full sheet}
1739: # {Half Sheet}
1740: # 0
1741: # }
1742: # {
1743: # log
1744: # {When encountering errors: Select Query the User}
1745: # {Log them}
1746: # {Query the user}
1747: # 1
1748: # }
1749:
1750: #Counting from zero, first number is column of start of the field,
1751: #second number is end of the field. The Question field is an
1752: #exception first comes start of question responses then # of
1753: #responses, and then the number of bubbles per response
1754: #Full Sheet Specs
1755: set gScorer(FullSheet.SerialNumber) { 5 8 }
1756: set gScorer(FullSheet.LastName) { 40 49 }
1757: set gScorer(FullSheet.FirstName) { 50 54 }
1758: set gScorer(FullSheet.MiddleInitial) { 55 55 }
1759: set gScorer(FullSheet.StudentNumber) { 56 64 }
1760: set gScorer(FullSheet.Section) { 65 67 }
1761: set gScorer(FullSheet.CapaID) { }
1762: #No CapaID spot on full sheet
1763: set gScorer(FullSheet.Question) { 76 50 10 }
1764:
1765: #Half Sheet Specs
1766: set gScorer(HalfSheet.SerialNumber) { 5 8 }
1767: set gScorer(HalfSheet.LastName) { 40 49 }
1768: set gScorer(HalfSheet.FirstName) { 50 50 }
1769: set gScorer(HalfSheet.MiddleInitial) { }
1770: #No Middle Initial
1771: set gScorer(HalfSheet.StudentNumber) { 56 64 }
1772: set gScorer(HalfSheet.Section) { 65 67 }
1773: set gScorer(HalfSheet.CapaID) { 68 73 }
1774: set gScorer(HalfSheet.Question) { 76 50 10 }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>