--- capa/capa51/GUITools/common.tcl 1999/09/28 21:25:36 1.1 +++ capa/capa51/GUITools/common.tcl 1999/12/16 22:18:35 1.4 @@ -573,6 +573,9 @@ proc parseCapaConfig { {num "" } { path "exam_path *= *" - "quiz_path *= *" - "supp_path *= *" - + "default_try_val *= *" - + "default_prob_val *= *" - + "default_hint_val *= *" - "others_path *= *" { set gCapaConfig($prefix[lindex $aline 0]) [lindex $aline end] } @@ -1132,7 +1135,7 @@ proc getOneStudent { window path idVar n ########################################################### ########################################################### ########################################################### -proc getString { window message } { +proc getString { window message {type "any"}} { global gPrompt set setWin [toplevel $window.getstring] @@ -1143,7 +1146,8 @@ proc getString { window message } { set gPrompt(val) "" - entry $valFrame.val -textvariable gPrompt(val) + entry $valFrame.val -textvariable gPrompt(val) -validate key \ + -validatecommand "limitEntry %W -1 $type %P" pack $valFrame.val message $msgFrame.msg -text $message -aspect 3000 @@ -1179,7 +1183,7 @@ proc getString { window message } { proc multipleChoice { window message choices {single 1}} { global gPromptMC - set setWin [toplevel $window.getstring] + set setWin [toplevel $window.choice] set msgFrame [frame $setWin.msgFrame] set valFrame [frame $setWin.valFrame] @@ -1438,7 +1442,7 @@ proc getSet { pid set followupCommand {s if { [array names gGetSet exit] == "" } { set gGetSet(exit) 0 } } if { [catch {set gCapaConfig(getSet.answers_command)}] } {parseCapaConfig getSet} - set command "$gCapaConfig(getSet.answers_command) $pid {} {} $set" + set command "$gCapaConfig(getSet.answers_command) $pid {} 1 $set" foreach var [array names gCapaConfig $num.*] { unset gCapaConfig($var) } set fileId [open "|$command" "r"] fileevent $fileId readable "getSetLine $num $fileId" @@ -1685,11 +1689,12 @@ proc winprintText { num } { ########################################################### proc limitEntry { window max type {newvalue ""}} { after idle "$window config -validate key" - if {[string length $newvalue] > $max } { return 0 } + if {($max != -1) && ([string length $newvalue] > $max)} { return 0 } switch $type { any {} number { if {(![regexp ^\[0-9\]+$ $newvalue])&&($newvalue!="")} { return 0 } } - letter {if {(![regexp ^\[A-Za-z\]+$ $newvalue])&& ($newvalue!="")} { return 0 }} + letter { if {(![regexp ^\[A-Za-z\]+$ $newvalue])&& ($newvalue!="")} { return 0 }} + nospace {if {(![regexp "^\[^ \]+$" $newvalue])&& ($newvalue!="")} { return 0 }} } return 1 }