File:  [LON-CAPA] / capa / capa51 / GUITools / scorer.anon.tcl
Revision 1.1: download - view: text, annotated - select for diffs
Tue Sep 28 21:25:37 1999 UTC (24 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
Initial revision

    1: ###########################################################
    2: # compareCapaID2
    3: ###########################################################
    4: ###########################################################
    5: ###########################################################
    6: proc compareCapaID2 { onPaper onList } {
    7:     set length [string length $onPaper]
    8:     set same 0
    9:     for { set i 0 } { $i < $length } { incr i } {
   10: 	if { [string index $onPaper $i] == [string index $onList $i] } {
   11: 	    incr same
   12: 	}
   13:     }
   14:     return $same
   15: }
   16: 
   17: ###########################################################
   18: # getAnonModeID
   19: ###########################################################
   20: ###########################################################
   21: ###########################################################
   22: proc getAnonModeID { num answerStructVar} {
   23:     global gScorer
   24:     upvar $answerStructVar answerStruct
   25: 
   26:     set i 0
   27:     set length [llength $gScorer(studentList.$num)]
   28: #    puts ofrloop:\ [time { 
   29: 	foreach student $gScorer(studentList.$num) {
   30: 	    lappend which([compareCapaID $answerStruct(CapaID) [lindex $student 3]]) $i
   31: 	    incr i
   32: 	}
   33: #    }]
   34:     set highest [lindex [lsort -decreasing -integer [array names which]] 0]
   35:     set answerStruct(indices) $which($highest)
   36:     foreach index $which($highest) {
   37: 	lappend result [lindex [lindex $gScorer(studentList.$num) $index] 1]
   38:     }
   39:     return $result
   40: }
   41: 
   42: ###########################################################
   43: # scorerSum
   44: ###########################################################
   45: ###########################################################
   46: ###########################################################
   47: proc scorerSum { scores } {
   48:     set total 0
   49:     foreach score [split $scores {}] { incr total $score }
   50:     return $total
   51: }
   52: 
   53: ###########################################################
   54: # pickAnonHighest
   55: ###########################################################
   56: ###########################################################
   57: ###########################################################
   58: proc pickAnonHighest { num answerStructVar which } {
   59:     global gPrompt gScorer
   60:     upvar $answerStructVar answerStruct
   61: 
   62:     set scores ""
   63:     foreach index $which {
   64: 	set studentNumber [lindex [lindex $gScorer(studentList.$num) $index] 1]
   65: 	lappend scores [list [scorerSum [finalScorer $num Lenient $studentNumber \
   66: 					     $answerStruct($studentNumber.numRight)]] \
   67: 			    $studentNumber]
   68:     }
   69: #    puts $scores
   70:     set scores [lsort -index 0 -integer $scores]
   71: #    puts $scores
   72: #    puts [lindex [lindex $scores 0] 1]
   73:     return [lindex [lindex $scores 0] 1]    
   74: }
   75: 
   76: ###########################################################
   77: # getWhichAnon
   78: ###########################################################
   79: ###########################################################
   80: ###########################################################
   81: proc getWhichAnon { num answerStructVar which } {
   82:     global gPrompt gScorer
   83:     upvar $answerStructVar answerStruct
   84: 
   85:     set dialog [toplevel .getWhichAnon$num -borderwidth 10]
   86:     wm title $dialog "Getting Which Anonymous"
   87: 
   88:     set msgFrame [frame $dialog.msg ]
   89:     set listFrame [frame $dialog.list ]
   90:     set typeInFrame [frame $dialog.typein]
   91:     set buttonFrame [frame $dialog.button]
   92:     pack $msgFrame $listFrame $typeInFrame $buttonFrame
   93: 
   94:     label $msgFrame.lbl -text "Grading:"
   95:     label $msgFrame.lbl2 -text "Student Number: $answerStruct(StudentNumber)"
   96:     label $msgFrame.lbl3 -text "CapaID:         $answerStruct(CapaID)"
   97:     label $msgFrame.lbl4 -text "Name:           $answerStruct(FirstName) $answerStruct(LastName)"
   98:     label $msgFrame.lbl5 -text "Select the paper used to grade student." 
   99:     label $msgFrame.lbl6 -text "Name                          StuNumber capa  capa      score"
  100:     label $msgFrame.lbl7 -text "                                         ID  IDplus  Std  Len  Str "
  101: 
  102:     pack $msgFrame.lbl $msgFrame.lbl2 $msgFrame.lbl3 $msgFrame.lbl4 $msgFrame.lbl5 \
  103: 	$msgFrame.lbl6 $msgFrame.lbl7 -anchor w
  104: 
  105:     set listbox [listbox $listFrame.list -yscrollcommand "$listFrame.scroll set" \
  106: 		     -width 67]
  107:     scrollbar $listFrame.scroll -command "$listFrame.list yview"
  108:     pack $listFrame.list $listFrame.scroll -side left
  109:     pack configure $listFrame.scroll -fill y
  110: 
  111:     label $typeInFrame.lbl -text "Type In Student Number:"
  112:     entry $typeInFrame.typein -width 9 -textvariable gPrompt(typedin)
  113:     pack $typeInFrame.lbl $typeInFrame.typein -side left
  114: 
  115:     button $buttonFrame.button -text Select -command "set gPrompt(ok) 1"
  116:     button $buttonFrame.typein -text "Use Typed In Value" -command "set gPrompt(ok) 2"
  117:     pack $buttonFrame.button $buttonFrame.typein -side left
  118:     foreach index $which {
  119: 	set studentNumber [lindex [lindex $gScorer(studentList.$num) $index] 1]
  120: 	set scores ""
  121: 	foreach methodtype {CAPA Lenient Strict} {
  122: 	    lappend scores [scorerSum [finalScorer $num $methodtype $studentNumber \
  123: 					   $answerStruct($studentNumber.numRight)] ]
  124: 	}
  125: 	$listbox insert end [eval format {{%30s %s %4d %6s %4d %4d %4d}} [lindex $gScorer(studentList.$num) $index] $scores]
  126:     }
  127: 
  128:     Centre_Dialog $dialog default
  129:     focus $dialog
  130:     capaRaise $dialog
  131:     capaGrab $dialog
  132:     while { 1 } {
  133: 	update
  134: 	vwait gPrompt(ok)
  135: 	if { $gPrompt(ok) == 1 } {
  136: 	    if { [$listbox curselection] != ""} { break }
  137: 	} else { 
  138: 	    if { [inClasslist $num $gPrompt(typedin)] } { break } else {
  139: 		displayError "$gPrompt(typedin) is not in the classl file"
  140: 	    }
  141: 	}
  142: 	set gPrompt(ok) 0
  143:     }
  144:     if { $gPrompt(ok) == 1 } {
  145: 	set selected [lindex $which [$listbox curselection]]
  146: 	set result [lindex [lindex $gScorer(studentList.$num) $selected] 1]
  147:     } else {
  148: 	set result $gPrompt(typedin)
  149:     }
  150:     capaGrab release $dialog
  151:     destroy $dialog
  152:     
  153:     return $result
  154: }
  155: 
  156: ###########################################################
  157: # inClasslist
  158: ###########################################################
  159: ###########################################################
  160: ###########################################################
  161: proc inClasslist { num pid } {
  162:     global gScorer
  163:     if {[lsearch -regexp $gScorer(studentList.$num) "\{.*\} .*$pid.*"]!=-1} {
  164: 	return 1
  165:     } {
  166: 	return 0
  167:     }
  168: }

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