--- capa/capa51/GUITools/gradesubjective.tcl 1999/11/18 17:55:24 1.4 +++ capa/capa51/GUITools/gradesubjective.tcl 1999/12/07 19:45:45 1.8 @@ -31,8 +31,9 @@ proc createGradeSubjWindow {} { set info [frame $gradSubj.info] set grade [frame $gradSubj.grade] + set keyword [frame $gradSubj.keyword] set gSubj(pictFrame) [set picts [frame $gradSubj.picts -borderwidth 4 -relief groove]] - pack $info $grade -side top + pack $info $grade $keyword -side top set msg [frame $info.msg] set id [frame $info.id] @@ -88,7 +89,7 @@ proc createGradeSubjWindow {} { set scoreandcom [toplevel $gradSubj.scoreandcom] wm title $scoreandcom "Control Panel" - wm protocol $gradSubj WM_DELETE_WINDOW "subjDone" + wm protocol $scoreandcom WM_DELETE_WINDOW "subjDone" set score [frame $scoreandcom.score] set command [frame $scoreandcom.command] @@ -116,6 +117,25 @@ proc createGradeSubjWindow {} { pack $bot.scroll pack configure $bot.scroll -expand 0 -fill x + set left [frame $keyword.left] + set left2 [frame $keyword.left2] + set right [frame $keyword.right] + pack $left $left2 $right -side left + + set gSubj(keyword) [text $right.keyword -width 60 -height 5 \ + -yscrollcommand "$right.scroll set" ] + puts $gSubj(keyword) + puts $right + scrollbar $right.scroll -command "$right.response yview" + pack $gSubj(keyword) $right.scroll -side left + pack configure $right.scroll -fill y + + button $left.add -command "subjAddKeyword" -text "Add" + button $left2.addsp -command "subjAddKeywordSpelling" -text "Add Sp" + button $left.delete -command "subjDeleteKeyword" -text "Delete" + button $left2.see -command "subjSeeKeyword" -text "See Sp" + pack $left.add $left2.addsp $left.delete $left2.see -side top + wm geometry $gradSubj "-10+0" set score0 [frame $score.score0] @@ -143,18 +163,18 @@ proc createGradeSubjWindow {} { frame $command2.space2 -height 30 frame $command2.space22 -height 5 button $command1.next -text "Next" -command subjNext -width $buttonwidth - button $command2.prev -text "Prev" -command subjPrev -width $buttonwidth - button $command1.findid -text "Find ID" -command subjFindId -width $buttonwidth - button $command2.addid -text "Add ID" -command subjAddId -width $buttonwidth - button $command1.findname -text "Find Name" -command subjFindName -width $buttonwidth - button $command2.goto -text "GoTo" -command subjGoto -width $buttonwidth + button $command1.prev -text "Prev" -command subjPrev -width $buttonwidth + button $command1.goto -text "GoTo" -command subjGoto -width $buttonwidth button $command1.exit -text "Exit" -command subjDone -width $buttonwidth + button $command2.findid -text "Find ID" -command subjFindId -width $buttonwidth + button $command2.addid -text "Add ID" -command subjAddId -width $buttonwidth + button $command2.findname -text "Find Name" -command subjFindName -width $buttonwidth checkbutton $command2.wrap -text wrap -command subjWrap -variable gSubj(wrap) checkbutton $command2.pict -text pict -command subjPict -variable gSubj(pict) checkbutton $command1.done -text graded -variable gSubj(donestat) -state disabled pack $command1.setnext $command2.set $command1.space1 $command2.space2 \ - $command1.next $command2.prev $command1.findid \ - $command2.addid $command1.findname $command1.exit $command2.goto \ + $command1.next $command1.prev $command2.findid \ + $command2.addid $command2.findname $command1.goto $command1.exit \ $command2.wrap $command2.pict $command1.done $command2.space22 button $morebut.print -text "Print Response" -command subjPrint \ @@ -207,14 +227,36 @@ proc subjCheckForNew {} { global gSubj } +proc checkGSubj {} { + global gSubj + if {[catch {set gSubj(stunums)}]} { + cd [file join $gSubj(dir) records set$gSubj(set) problem$gSubj(quest)] + set gSubj(stunums) [lsort -dictionary [glob *]] + if { [set num [lsearch $gSubj(stunums) gradingstatus]] != -1} { + set gSubj(stunums) [lreplace $gSubj(stunums) $num $num] + } + cd $gSubj(dir) + } + if {[catch {set gSubj(current)}]} {set gSubj(current) -1} + if {[catch {set gSubj(totalsec)}]} {set gSubj(totalsec) 0} + if {[catch {set gSubj(seconds)}]} {set gSubj(seconds) [clock seconds]} + if {[catch {set gSubj(togo)}]} {set gSubj(togo) [llength $gSubj(stunums)]} + if {[catch {set gSubj(allstunum)}] || + [catch {set gSubj(allname)}] || + [catch {set gSubj(allemail)}] } { + subjInitAllLists + } +} + proc subjRestore {} { global gSubj source gradingstatus subjCheckForNew set gSubj(seconds) [expr {[clock seconds] - $gSubj(sec)}] cd $gSubj(dir) - incr gSubj(current) -1 + if { [catch {incr gSubj(current) -1}]} { set gSubj(current) -1 } if { $gSubj(redoalllists) } { subjInitAllLists; set gSubj(redoalllists) 0 } + checkGSubj subjIndexResponse subjNext } @@ -230,14 +272,15 @@ proc subjSave {} { proc subjDone {} { global gSubj - subjSave + if { [catch {subjSave}] } { + displayMessage "Unable to save." + } unset gSubj destroy .gradesubjective } proc subjInitAllLists {} { global gSubj - puts "doing all lists" set i 0 catch {unset gSubj(allstunum)} catch {unset gSubj(allname)} @@ -252,7 +295,6 @@ proc subjInitAllLists {} { lappend gSubj(allname) [string range $aline 24 59] lappend gSubj(allemail) [string range $aline 60 99] } - puts "did $i lines" } proc subjInit {} { @@ -518,7 +560,7 @@ proc subjPrev {} { proc subjMessage { mesg {tag normal} } { global gSubj - displayMessage $message + displayMessage $mesg # $gSubj(msg) insert end "[clock format [clock seconds] -format {%I:%M:%S}] - $mesg\n" $tag # $gSubj(msg) see end } @@ -701,6 +743,8 @@ proc subjSendResponse {} { } incr which + set message "" + set stuList [$gSubj(idlist) get 0 end] foreach stu $stuList { set stu [lindex $stu 0] @@ -889,3 +933,61 @@ proc subjViewResponse {} { button $buttonFrame.forget -text Dismiss -command "destroy $response" pack $buttonFrame.forget -side left } + +########################################################### +# subjUpdateResponse +########################################################### +########################################################### +########################################################### +proc subjUpdateResponse {} { + gSubj +} + +########################################################### +# subjUpdateKeywords +########################################################### +########################################################### +########################################################### +proc subjUpdateKeywords {} { + global gSubj + $gSubj(keyword) delete 0.0 end + puts $gSubj(keywords) + foreach keyword $gSubj(keywords) { lappend lokeyword [lindex $keyword 0] } + set lokeyword [lsort $lokeyword] + set max 0 + foreach key $lokeyword { + if { [string length $key] > $max } { set max [string length $key] } + } + incr max + set numcol [expr 60/$max] + set end [llength $lokeyword] + set lastline 0 + for { set i 0 } { $i < $end } { incr i } { + set line [expr $i/$numcol] + set col [expr $i%$numcol*$max] + puts $line.$col + $gSubj(keyword) insert end [format "%-[set max]s" [lindex $lokeyword $i]] + if {($col + (2*$max)) > 60} { + puts "Putting in newlne" + $gSubj(keyword) insert end "\n" + set lastline $line + } + } + subjUpdateResponse +} + +########################################################### +# subjAddKeyword +########################################################### +########################################################### +########################################################### +proc subjAddKeyword {} { + global gSubj gUniqueNumber + + if { "" == [set keyword [getString [winfo toplevel $gSubj(keyword)] "Enter a new keyword"]]} { + return + } + puts "New keyword $keyword" + lappend gSubj(keywords) [list $keyword [list $keyword]] + subjUpdateKeywords +}