File:  [LON-CAPA] / capa / capa51 / GUITools / scorer.anon.tcl
Revision 1.5: download - view: text, annotated - select for diffs
Tue Sep 26 13:34:48 2000 UTC (23 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_spring, stable_2002_july, stable_2002_april, stable_2001_fall, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, STABLE, HEAD, GCI_3, GCI_2, GCI_1, CAPA_5-1-6, CAPA_5-1-5, CAPA_5-1-4_RC1, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
- fixed scorer to actually pick highest score instead of lowest

    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
    5: #  modify it under the terms of the GNU General Public License as
    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
   12: #  General Public License for more details.
   13: #
   14: #  You should have received a copy of the GNU General Public
   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: 
   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]
   58:     if {$highest != 6} { return "" }
   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
   94:     set scores [lsort -decreasing -index 0 -integer $scores]
   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:     }
  192: }

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