Annotation of capa/capa51/GUITools/scorer.anon.tcl, revision 1.5

1.3       albertel    1: # handles figuring out which student was to have taken this quiz
                      2: #  Copyright (C) 1992-2000 Michigan State University
                      3: #
                      4: #  The CAPA system is free software; you can redistribute it and/or
1.4       albertel    5: #  modify it under the terms of the GNU General Public License as
1.3       albertel    6: #  published by the Free Software Foundation; either version 2 of the
                      7: #  License, or (at your option) any later version.
                      8: #
                      9: #  The CAPA system is distributed in the hope that it will be useful,
                     10: #  but WITHOUT ANY WARRANTY; without even the implied warranty of
                     11: #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1.4       albertel   12: #  General Public License for more details.
1.3       albertel   13: #
1.4       albertel   14: #  You should have received a copy of the GNU General Public
1.3       albertel   15: #  License along with the CAPA system; see the file COPYING.  If not,
                     16: #  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
                     17: #  Boston, MA 02111-1307, USA.
                     18: #
                     19: #  As a special exception, you have permission to link this program
                     20: #  with the TtH/TtM library and distribute executables, as long as you
                     21: #  follow the requirements of the GNU GPL in regard to all of the
                     22: #  software in the executable aside from TtH/TtM.
                     23: 
1.1       albertel   24: ###########################################################
                     25: # compareCapaID2
                     26: ###########################################################
                     27: ###########################################################
                     28: ###########################################################
                     29: proc compareCapaID2 { onPaper onList } {
                     30:     set length [string length $onPaper]
                     31:     set same 0
                     32:     for { set i 0 } { $i < $length } { incr i } {
                     33: 	if { [string index $onPaper $i] == [string index $onList $i] } {
                     34: 	    incr same
                     35: 	}
                     36:     }
                     37:     return $same
                     38: }
                     39: 
                     40: ###########################################################
                     41: # getAnonModeID
                     42: ###########################################################
                     43: ###########################################################
                     44: ###########################################################
                     45: proc getAnonModeID { num answerStructVar} {
                     46:     global gScorer
                     47:     upvar $answerStructVar answerStruct
                     48: 
                     49:     set i 0
                     50:     set length [llength $gScorer(studentList.$num)]
                     51: #    puts ofrloop:\ [time { 
                     52: 	foreach student $gScorer(studentList.$num) {
                     53: 	    lappend which([compareCapaID $answerStruct(CapaID) [lindex $student 3]]) $i
                     54: 	    incr i
                     55: 	}
                     56: #    }]
                     57:     set highest [lindex [lsort -decreasing -integer [array names which]] 0]
1.2       albertel   58:     if {$highest != 6} { return "" }
1.1       albertel   59:     set answerStruct(indices) $which($highest)
                     60:     foreach index $which($highest) {
                     61: 	lappend result [lindex [lindex $gScorer(studentList.$num) $index] 1]
                     62:     }
                     63:     return $result
                     64: }
                     65: 
                     66: ###########################################################
                     67: # scorerSum
                     68: ###########################################################
                     69: ###########################################################
                     70: ###########################################################
                     71: proc scorerSum { scores } {
                     72:     set total 0
                     73:     foreach score [split $scores {}] { incr total $score }
                     74:     return $total
                     75: }
                     76: 
                     77: ###########################################################
                     78: # pickAnonHighest
                     79: ###########################################################
                     80: ###########################################################
                     81: ###########################################################
                     82: proc pickAnonHighest { num answerStructVar which } {
                     83:     global gPrompt gScorer
                     84:     upvar $answerStructVar answerStruct
                     85: 
                     86:     set scores ""
                     87:     foreach index $which {
                     88: 	set studentNumber [lindex [lindex $gScorer(studentList.$num) $index] 1]
                     89: 	lappend scores [list [scorerSum [finalScorer $num Lenient $studentNumber \
                     90: 					     $answerStruct($studentNumber.numRight)]] \
                     91: 			    $studentNumber]
                     92:     }
                     93: #    puts $scores
1.5     ! albertel   94:     set scores [lsort -decreasing -index 0 -integer $scores]
1.1       albertel   95: #    puts $scores
                     96: #    puts [lindex [lindex $scores 0] 1]
                     97:     return [lindex [lindex $scores 0] 1]    
                     98: }
                     99: 
                    100: ###########################################################
                    101: # getWhichAnon
                    102: ###########################################################
                    103: ###########################################################
                    104: ###########################################################
                    105: proc getWhichAnon { num answerStructVar which } {
                    106:     global gPrompt gScorer
                    107:     upvar $answerStructVar answerStruct
                    108: 
                    109:     set dialog [toplevel .getWhichAnon$num -borderwidth 10]
                    110:     wm title $dialog "Getting Which Anonymous"
                    111: 
                    112:     set msgFrame [frame $dialog.msg ]
                    113:     set listFrame [frame $dialog.list ]
                    114:     set typeInFrame [frame $dialog.typein]
                    115:     set buttonFrame [frame $dialog.button]
                    116:     pack $msgFrame $listFrame $typeInFrame $buttonFrame
                    117: 
                    118:     label $msgFrame.lbl -text "Grading:"
                    119:     label $msgFrame.lbl2 -text "Student Number: $answerStruct(StudentNumber)"
                    120:     label $msgFrame.lbl3 -text "CapaID:         $answerStruct(CapaID)"
                    121:     label $msgFrame.lbl4 -text "Name:           $answerStruct(FirstName) $answerStruct(LastName)"
                    122:     label $msgFrame.lbl5 -text "Select the paper used to grade student." 
                    123:     label $msgFrame.lbl6 -text "Name                          StuNumber capa  capa      score"
                    124:     label $msgFrame.lbl7 -text "                                         ID  IDplus  Std  Len  Str "
                    125: 
                    126:     pack $msgFrame.lbl $msgFrame.lbl2 $msgFrame.lbl3 $msgFrame.lbl4 $msgFrame.lbl5 \
                    127: 	$msgFrame.lbl6 $msgFrame.lbl7 -anchor w
                    128: 
                    129:     set listbox [listbox $listFrame.list -yscrollcommand "$listFrame.scroll set" \
                    130: 		     -width 67]
                    131:     scrollbar $listFrame.scroll -command "$listFrame.list yview"
                    132:     pack $listFrame.list $listFrame.scroll -side left
                    133:     pack configure $listFrame.scroll -fill y
                    134: 
                    135:     label $typeInFrame.lbl -text "Type In Student Number:"
                    136:     entry $typeInFrame.typein -width 9 -textvariable gPrompt(typedin)
                    137:     pack $typeInFrame.lbl $typeInFrame.typein -side left
                    138: 
                    139:     button $buttonFrame.button -text Select -command "set gPrompt(ok) 1"
                    140:     button $buttonFrame.typein -text "Use Typed In Value" -command "set gPrompt(ok) 2"
                    141:     pack $buttonFrame.button $buttonFrame.typein -side left
                    142:     foreach index $which {
                    143: 	set studentNumber [lindex [lindex $gScorer(studentList.$num) $index] 1]
                    144: 	set scores ""
                    145: 	foreach methodtype {CAPA Lenient Strict} {
                    146: 	    lappend scores [scorerSum [finalScorer $num $methodtype $studentNumber \
                    147: 					   $answerStruct($studentNumber.numRight)] ]
                    148: 	}
                    149: 	$listbox insert end [eval format {{%30s %s %4d %6s %4d %4d %4d}} [lindex $gScorer(studentList.$num) $index] $scores]
                    150:     }
                    151: 
                    152:     Centre_Dialog $dialog default
                    153:     focus $dialog
                    154:     capaRaise $dialog
                    155:     capaGrab $dialog
                    156:     while { 1 } {
                    157: 	update
                    158: 	vwait gPrompt(ok)
                    159: 	if { $gPrompt(ok) == 1 } {
                    160: 	    if { [$listbox curselection] != ""} { break }
                    161: 	} else { 
                    162: 	    if { [inClasslist $num $gPrompt(typedin)] } { break } else {
                    163: 		displayError "$gPrompt(typedin) is not in the classl file"
                    164: 	    }
                    165: 	}
                    166: 	set gPrompt(ok) 0
                    167:     }
                    168:     if { $gPrompt(ok) == 1 } {
                    169: 	set selected [lindex $which [$listbox curselection]]
                    170: 	set result [lindex [lindex $gScorer(studentList.$num) $selected] 1]
                    171:     } else {
                    172: 	set result $gPrompt(typedin)
                    173:     }
                    174:     capaGrab release $dialog
                    175:     destroy $dialog
                    176:     
                    177:     return $result
                    178: }
                    179: 
                    180: ###########################################################
                    181: # inClasslist
                    182: ###########################################################
                    183: ###########################################################
                    184: ###########################################################
                    185: proc inClasslist { num pid } {
                    186:     global gScorer
                    187:     if {[lsearch -regexp $gScorer(studentList.$num) "\{.*\} .*$pid.*"]!=-1} {
                    188: 	return 1
                    189:     } {
                    190: 	return 0
                    191:     }
1.3       albertel  192: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>