Diff for /capa/capa51/GUITools/quizzer.tcl between versions 1.2 and 1.5

version 1.2, 1999/10/13 18:45:28 version 1.5, 1999/10/26 16:47:36
Line 2282  proc showParseErrors {} { Line 2282  proc showParseErrors {} {
     $gParseErrorsText delete 0.0 end      $gParseErrorsText delete 0.0 end
     capaRaise .parseErrors      capaRaise .parseErrors
  }   }
    foreach line [split $parseErrors "\n"] {
       if { [regexp {File:.+->(.+), Line ([0-9]+): ERROR:} $line a one two three four five]} {
    puts a:$a
    puts one:$one
    puts two:$two
    puts three:$three
    puts four:$four
    puts five:$five
       } else {
    if { [regexp {File:(.+), Line ([0-9]+): ERROR:} $line a one two three four five]} {
       puts a:$a
       puts one:$one
       puts two:$two
       puts three:$three
       puts four:$four
       puts five:$five
    }
       }
    }
  $gParseErrorsText insert end $parseErrors   $gParseErrorsText insert end $parseErrors
     } else {      } else {
  if { [winfo exists .parseErrors] } { $gParseErrorsText delete 0.0 end }   if { [winfo exists .parseErrors] } { $gParseErrorsText delete 0.0 end }
Line 2420  proc rereadCapaConfig { } { Line 2438  proc rereadCapaConfig { } {
  displayError "Invalid capa.config file"    displayError "Invalid capa.config file" 
  set gCapaConfig(printer_option) $printer_option   set gCapaConfig(printer_option) $printer_option
     }       } 
       setDefaultValues
     updateColors      updateColors
 }  }
   
Line 2438  proc pickCapaConfig { } { Line 2457  proc pickCapaConfig { } {
  cd [file dirname $file]   cd [file dirname $file]
  set error [parseCapaConfig]   set error [parseCapaConfig]
  if { $error != "OK" } { displayError "Invalid capa.config file"; cd $oldDir }    if { $error != "OK" } { displayError "Invalid capa.config file"; cd $oldDir } 
    setDefaultValues
     }       } 
 }  }
   
   proc setDefaultValues {} {
       global gProbVal gTryVal gHintVal gCapaConfig
       catch {set gProbVal $gCapaConfig(default_prob_val)}
       catch {set gTryVal $gCapaConfig(default_try_val)}
       catch {set gHintVal $gCapaConfig(default_hint_val)}
   }
   
 ###########################################################  ###########################################################
 # openDocument  # openDocument
 ###########################################################  ###########################################################
 ###########################################################  ###########################################################
 ###########################################################  ###########################################################
 proc openDocument {} {  proc openDocument {} {
     global gFile gTextWindow gSetNumberText gPrefs gChanged gQuizTemp gUndo      global gFile gTextWindow gSetNumberText gPrefs gChanged gQuizTemp gUndo 
   
     if { $gChanged } { if { [askToSave 0 0] == "Cancel" } { return } }      if { $gChanged } { if { [askToSave 0 0] == "Cancel" } { return } }
     if { ![catch {set gTextWindow}] } {       if { ![catch {set gTextWindow}] } { 
Line 2517  proc openDocument {} { Line 2544  proc openDocument {} {
  set gQuizTemp true   set gQuizTemp true
         return          return
     }      }
       setDefaultValues
   
     createEditingWindow 0      createEditingWindow 0
     $gTextWindow delete 0.0 end      $gTextWindow delete 0.0 end
     $gTextWindow insert 0.0 [read $fileId [file size $gFile]]      $gTextWindow insert 0.0 [read $fileId [file size $gFile]]
Line 3259  proc createStopButton {} { Line 3287  proc createStopButton {} {
     if {[winfo exists .stopbutton]} {destroy .stopbutton}      if {[winfo exists .stopbutton]} {destroy .stopbutton}
     set top [toplevel .stopbutton]      set top [toplevel .stopbutton]
     button $top.stop -text "Stop Parser" -command "stopParser"      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      pack $top.stop $top.status
     set gStopStatus ""      set gStopStatus ""
     grab $top      grab $top
Line 4463  proc analyzeRandom { } { Line 4491  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  # analyzeUpdate
 ###########################################################  ###########################################################
 ###########################################################  ###########################################################
Line 4483  proc analyzeUpdate { {newProbNumber 0} } Line 4572  proc analyzeUpdate { {newProbNumber 0} }
     set gAnalyze(highnum) [set high [lindex $gAnalyze($gAnalyze(prob).ans) end]]      set gAnalyze(highnum) [set high [lindex $gAnalyze($gAnalyze(prob).ans) end]]
     set gAnalyze(numuniq) [llength [lunique $gAnalyze($gAnalyze(prob).ans)]]      set gAnalyze(numuniq) [llength [lunique $gAnalyze($gAnalyze(prob).ans)]]
 #don't draw anything if the answers aren't numbers  #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      $c create line 25 50 [expr $gAnalyze(canvaswidth) - 25] 50
     set diff [expr double($high-$low)]      set diff [expr double($high-$low)]
     if { $diff == 0 } {      if { $diff == 0 } {
  set center [expr $gAnalyze(canvaswidth)/2.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   update idletasks
  return   return
     }      }
Line 4506  proc analyzeUpdate { {newProbNumber 0} } Line 4603  proc analyzeUpdate { {newProbNumber 0} }
  set center [expr $center+25]   set center [expr $center+25]
  $c create rectangle [expr $center - 1] 40 [expr $center + 1] 60   $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) {          foreach point $gAnalyze($gAnalyze(prob).ans) {    
  set center [expr ($gAnalyze(canvaswidth)-50)*(($point-$low)/$diff)]   if { $lastpoint != $point } {
  set center [expr $center+25]      set center [expr ($gAnalyze(canvaswidth)-50)*(($lastpoint-$low)/$diff)]
  $c create oval [expr $center - 2] 48 [expr $center + 2] 52 -fill green      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      update idletasks
 }  }

Removed from v.1.2  
changed lines
  Added in v.1.5


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