--- capa/capa51/GUITools/quizzer.tcl 1999/10/18 21:29:12 1.3 +++ capa/capa51/GUITools/quizzer.tcl 1999/10/20 19:57:37 1.4 @@ -3259,7 +3259,7 @@ proc createStopButton {} { if {[winfo exists .stopbutton]} {destroy .stopbutton} set top [toplevel .stopbutton] button $top.stop -text "Stop Parser" -command "stopParser" - label $top.status -textvariable gStopStatus -width 35 + label $top.status -textvariable gStopStatus -width 35 -anchor w pack $top.stop $top.status set gStopStatus "" grab $top @@ -4463,6 +4463,67 @@ proc analyzeRandom { } { } ########################################################### +# analyzeStrings +########################################################### +########################################################### +########################################################### +proc analyzeStrings { prob window create} { + global gAnalyze + + if { ![winfo exists $window.analyzestrings] } { if {!$create} { return } } + if { ![catch {set setWin [toplevel $window.analyzestrings]}] } { + set msgFrame [frame $setWin.msgFrame] + set valFrame [frame $setWin.valFrame] + set buttonFrame [frame $setWin.buttonFrame] + pack $msgFrame $valFrame $buttonFrame + pack configure $valFrame -expand 1 -fill both + + message $msgFrame.msg -text "Correct Answers" -aspect 3000 + pack $msgFrame.msg + + set maxWidth 1 + foreach choice $gAnalyze($prob.ans) { + if {[string length $choice]>$maxWidth} {set maxWidth [string length $choice]} + } + set maxStringWidth $maxWidth + incr maxWidth 6 + + set selectMode none + listbox $valFrame.val -width [expr $maxWidth + 2] \ + -yscrollcommand "$valFrame.scroll set" -selectmode $selectMode + scrollbar $valFrame.scroll -command "$valFrame.val yview" + pack $valFrame.val $valFrame.scroll -side left + pack configure $valFrame.val -expand 1 -fill both + pack configure $valFrame.scroll -expand 0 -fill y + button $buttonFrame.cancel -text "Dismiss" -command "destroy $setWin" + pack $buttonFrame.cancel + } else { + set maxWidth 1 + set valFrame $window.analyzestrings.valFrame + $valFrame.val delete 0 end + foreach choice $gAnalyze($prob.ans) { + if {[string length $choice]>$maxWidth} {set maxWidth [string length $choice]} + } + set maxStringWidth $maxWidth + incr maxWidth 6 + } + set lastchoice [lindex $gAnalyze($gAnalyze(prob).ans) 0] + set num 1 + foreach choice [lsort $gAnalyze($gAnalyze(prob).ans)] { + if { $lastchoice != $choice } { + $valFrame.val insert end \ + "[format %-[set maxStringWidth]s $lastchoice] [format %5d $num]" + set lastchoice $choice + set num 1 + } else { + incr num + } + } + $valFrame.val insert end \ + "[format %-[set maxStringWidth]s $lastchoice] [format %5d $num]" +} + +########################################################### # analyzeUpdate ########################################################### ########################################################### @@ -4483,13 +4544,21 @@ proc analyzeUpdate { {newProbNumber 0} } set gAnalyze(highnum) [set high [lindex $gAnalyze($gAnalyze(prob).ans) end]] set gAnalyze(numuniq) [llength [lunique $gAnalyze($gAnalyze(prob).ans)]] #don't draw anything if the answers aren't numbers - if { [catch {expr $low + 1}]} { update idletask;return } + if { [catch {expr $low + 1}]} { + catch {destroy $c.button} + update idletask + button $c.button -text "List of strings" -command \ + "analyzeStrings $gAnalyze(prob) $c 1" + $c create window [expr $gAnalyze(canvaswidth)/2.0] 40 -window $c.button + analyzeStrings $gAnalyze(prob) $c 0 + return + } $c create line 25 50 [expr $gAnalyze(canvaswidth) - 25] 50 set diff [expr double($high-$low)] if { $diff == 0 } { set center [expr $gAnalyze(canvaswidth)/2.0] - $c create oval [expr $center - 2] 48 [expr $center + 2] 52 -fill green + $c create rectangle [expr $center - 2] 48 [expr $center + 2] 52 -fill green update idletasks return } @@ -4512,18 +4581,18 @@ proc analyzeUpdate { {newProbNumber 0} } if { $lastpoint != $point } { set center [expr ($gAnalyze(canvaswidth)-50)*(($lastpoint-$low)/$diff)] set center [expr $center+25] - $c create rectangle [expr $center - 2] [expr 49-$num] \ - [expr $center + 2] [expr 51+$num] -fill green + $c create rectangle [expr $center - 2] [expr 48-$num] \ + [expr $center + 2] [expr 52+$num] -fill green set lastpoint $point set num 0 } else { incr num } } - set center [expr ($gAnalyze(canvaswidth)-50)*(($lastpoint-$low)/$diff)] - set center [expr $center+25] - $c create rectangle [expr $center - 2] [expr 49-$num] \ - [expr $center + 2] [expr 51+$num] -fill green + set center [expr ($gAnalyze(canvaswidth)-50)*(($lastpoint-$low)/$diff)] + set center [expr $center+25] + $c create rectangle [expr $center - 2] [expr 48-$num] \ + [expr $center + 2] [expr 52+$num] -fill green update idletasks }