--- capa/capa51/GUITools/quizzer.tcl 1999/09/28 21:25:36 1.1.1.1 +++ capa/capa51/GUITools/quizzer.tcl 1999/10/20 19:57:37 1.4 @@ -1162,7 +1162,7 @@ proc addDate { listbox } { ########################################################### proc createDBHeader {} { global gNumberParsedText gPrompt gLoadHeaderSet gControlDates \ - gSetNumberText gHeaderQCount + gSetNumberText gHeaderQCount gEnableDiscussion gFile if { $gNumberParsedText == "" } { displayError "You must first preview the file before creating the \ @@ -1182,8 +1182,9 @@ proc createDBHeader {} { message $dialog.msg -text "Header Information" -aspect 1000 set loadFrame [frame $dialog.loadFrame -borderwidth 4 -relief sunken] set infoFrame [frame $dialog.infoFrame -borderwidth 4 -relief sunken] + set optionFrame [frame $dialog.options] set buttonFrame [frame $dialog.buttons -bd 10] - pack $dialog.msg $loadFrame $infoFrame $buttonFrame -side top -fill x + pack $dialog.msg $loadFrame $infoFrame $optionFrame $buttonFrame -side top -fill x set legendFrame [frame $infoFrame.legendFrame] set listFrame [frame $infoFrame.listFrame] @@ -1212,6 +1213,15 @@ proc createDBHeader {} { button $loadFrame.load -text "load" -command "loadDates $listbox" pack $loadFrame.msg $loadFrame.entry $loadFrame.load -side left + if { [file exists [file join [file dirname $gFile] discussion $gSetNumberText]] } { + set gEnableDiscussion 1 + } else { + set gEnableDiscussion 0 + } + checkbutton $optionFrame.discuss -text "Enable Discussion Forum" \ + -variable gEnableDiscussion + pack $optionFrame.discuss + button $buttonFrame.ok -text Set -command { set gPrompt(ok) 1 } \ -underline 0 button $buttonFrame.cancel -text Cancel -command { set gPrompt(ok) 0 } \ @@ -1241,6 +1251,7 @@ proc createDBHeader {} { capaGrab release $dialog destroy $dialog if {$gPrompt(ok) == 1 } { + updateDiscussion eval updateHeader [ eval concat $gControlDates ] } @@ -1249,12 +1260,40 @@ proc createDBHeader {} { } ########################################################### +# updateDiscussion +########################################################### +########################################################### +########################################################### +proc updateDiscussion {} { + global gFile gSetNumberText gEnableDiscussion + set dir [file dirname $gFile] + set disDir [file join $dir discussion $gSetNumberText] + set logDir [file join $dir discussion logs] + if { $gEnableDiscussion } { + if { ![file exists $disDir] } { + if { [file exists $disDir.unavailable] } { + exec mv $disDir.unavailable $disDir + } else { + file mkdir $disDir + file attributes $disDir -permissions 0777 + } + } + if { ![file exists $logDir] } { + file mkdir [file join $dir discussion logs] + file attributes [file join $dir discussion logs] -permissions 0777 + } + } else { + if { [file exists $disDir] } { exec mv $disDir $disDir.unavailable } + } +} + +########################################################### # allFieldsComplete2 ########################################################### ########################################################### ########################################################### proc allFieldsComplete2 {} { - global gLoadHeaderSet gControlDates + global gLoadHeaderSet gControlDates if { [string length $gOpenDate] != 8 } { return 0 @@ -3220,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 @@ -4424,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 ########################################################### ########################################################### @@ -4444,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 } @@ -4467,11 +4575,24 @@ proc analyzeUpdate { {newProbNumber 0} } set center [expr $center+25] $c create rectangle [expr $center - 1] 40 [expr $center + 1] 60 } + set lastpoint [lindex $gAnalyze($gAnalyze(prob).ans) 0] + set num 0 foreach point $gAnalyze($gAnalyze(prob).ans) { - set center [expr ($gAnalyze(canvaswidth)-50)*(($point-$low)/$diff)] - set center [expr $center+25] - $c create oval [expr $center - 2] 48 [expr $center + 2] 52 -fill green + if { $lastpoint != $point } { + 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 + 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 48-$num] \ + [expr $center + 2] [expr 52+$num] -fill green update idletasks }