Annotation of capa/capa51/GUITools/manager.tcl, revision 1.1.1.1

1.1       albertel    1: ###########################################################
                      2: # manager.tcl - 
                      3: # Copyright Guy Albertelli II 1998
                      4: ###########################################################
                      5: set gTclVer 1.0
                      6: 
                      7: ###########################################################
                      8: # createControlWindow
                      9: ###########################################################
                     10: # Creates the menu window 
                     11: ###########################################################
                     12: # Arguments: none
                     13: # Returns: nothing
                     14: # Globals: gWindowMenu - set to the name of Menu for the windows
                     15: #                        menu
                     16: ###########################################################
                     17: proc createControlWindow {} {
                     18:     global gWindowMenu gCapaConfig
                     19:     
                     20:     after 500 { dateUpdate }
                     21:     after 1000 { cleanWindowList }
                     22: 
                     23:     set gCapaConfig(Printer_selected) "0"
                     24:     set gCapaConfig(lprOneSided_command) "lpr "
                     25:     set gCapaConfig(lprTwoSided_command) ""
                     26:     set gCapaConfig(printer_option) ""
                     27:     
                     28:     wm withdraw .
                     29: 
                     30:     set menuFrame [menu .main -tearoff 0 -type tearoff -font 8x13bold \
                     31: 	  -disabledforeground grey85 ]
                     32:     
                     33:     wm title $menuFrame "Manager"
                     34: 
                     35:     $menuFrame post 0 0
                     36: 
                     37:     wm geometry $menuFrame "+0+20"
                     38:     $menuFrame add command -label "Manager" -foreground grey85 -background \
                     39: 	    black -state disabled 
                     40:     $menuFrame add command -label "Info..." -command { createInfoWindow }
                     41:     $menuFrame add cascade -label "Actions" -menu $menuFrame.actions
                     42:     $menuFrame add cascade -label "Windows" -menu $menuFrame.windows
                     43:     $menuFrame add cascade -label "Print" -menu $menuFrame.print
                     44:     $menuFrame add command -label "Remap..." -command { createRemapWindow }
                     45:     $menuFrame add command -label "Quit" -command { quit }
                     46: 
                     47:     set action  [menu $menuFrame.actions -tearoff 1 -font 8x13bold]
                     48:     set windows [menu $menuFrame.windows -tearoff 1 -font 8x13bold]
                     49:     set print   [menu $menuFrame.print -tearoff 1  -font 8x13bold]
                     50:     set score   [menu $menuFrame.scoring -tearoff 1 -font 8x13bold]
                     51:     set gWindowMenu $windows
                     52:     
                     53:     $action add command -label "Manage Classl" -command \
                     54:  	    { specifyClass "Pick classl file" "Classl" "classl" createClasslEditor }
                     55: #    $action add command -label "Edit capa.config" -command \
                     56: 	    { specifyClass "Pick a capa.config file" "CAPA configuration" \
                     57: 		  "capa.config" editCapaConfig }
                     58:     $action add cascade -label "Scoring" -menu $menuFrame.scoring
                     59:     $action add command -label "Generate Stats" -command \
                     60: 	    { specifyClass "Select the capa.config in the class directory" \
                     61: 		  "CAPA configuration" "capa.config" runCapaTools }
                     62:     $action add command -label "Randomize Seating File" \
                     63: 	-command { RSstart [incr gUniqueNumber] }
                     64: 
                     65:     $score add command -label "Run Scorer" -command \
                     66: 	{ specifyClass "Pick set.qz file" "QZ file" "*.qz" runScorer }
                     67:     $score add command -label "ReScore a scorer.output" -command \
                     68: 	{ specifyClass "Pick scorer.output file" "scorer.output file" \
                     69: 	      "scorer.output.*" reScore }
                     70: 
                     71:     $print add command -label "Print Assignment" -command \
                     72: 	{ specifyClass "Select the capa.config in the class directory" \
                     73: 	      "CAPA configuration" "capa.config" printAssignment  }
                     74: 
                     75:     bind $menuFrame <Destroy> { quit 0 }
                     76: }
                     77: 
                     78: ###########################################################
                     79: # createInfoWindow
                     80: ###########################################################
                     81: # creates the Information window
                     82: ###########################################################
                     83: # Arguments: None
                     84: # Returns: Nothing
                     85: # Globals: gDate - the variable containg the current date 
                     86: #          gWindowMenu - used to register the new window in the
                     87: #                        windows menu
                     88: #          gVer - Stores the current version of Grader (set in 
                     89: #                 C init code
                     90: ###########################################################
                     91: proc createInfoWindow {} {
                     92:     global gDate gWindowMenu gVer gTclVer gCmd gCompileDate
                     93: 
                     94:     if { [winfo exists .about] } {
                     95: 	capaRaise .about
                     96: 	return 
                     97:     }
                     98: 
                     99:     set about [toplevel .about]
                    100: 
                    101:     $gWindowMenu add command -label "About" -command "capaRaise $about"
                    102: 
                    103:     wm title $about "About" 
                    104:     
                    105:     label $about.l1 -font 12x24 -text "Manager $gVer" -pady 20
                    106:     label $about.l4 -font 8x13 -text "Manager.tcl Version $gTclVer" -pady 20
                    107:     label $about.l6  -font 8x13 -text "$gCompileDate" 
                    108:     message $about.l2 -font 8x13 -text "Code by: Y. Tsai, G. Albertelli II Copyright Michigan State University Board of Trustees, 1992-1999, No Unauthorized Commercial Use" \
                    109: 	-pady 20 -aspect 300
                    110:     label $about.l3 -font 8x13 -textvariable gDate 
                    111:     label $about.l5  -font 8x13 -textvariable gCmd
                    112: 
                    113:     button $about.close -text "Close" -command "destroy $about
                    114:                                                 removeWindowEntry About"
                    115:     
                    116:     pack $about.l1 $about.l4 $about.l6 $about.l2 $about.l3 $about.l5 \
                    117: 	    $about.close -side top 
                    118: 
                    119:     Centre_Dialog $about default
                    120: }
                    121: 
                    122: ###########################################################
                    123: # quit
                    124: ###########################################################
                    125: # called when the quit option is selected on the menu, unmaps
                    126: # all keys.
                    127: ###########################################################
                    128: # Arguments: None
                    129: # Returns: Nothing
                    130: # Globals: None
                    131: ###########################################################
                    132: proc quit { { ask 1} } {
                    133:     if { $ask && [makeSure "Are you sure you wish to quit?"] == "Cancel" } {
                    134: 	return 
                    135:     }
                    136:     
                    137:     unmapAllKeys
                    138:     exit
                    139: }
                    140: 
                    141: ###########################################################
                    142: # specifyClass
                    143: ###########################################################
                    144: # runs tk_getOpenFile and creates the class window if a directory is chosen
                    145: ###########################################################
                    146: # Arguments: None
                    147: # Returns: Nothing
                    148: # Globals: gClassDir - remembers the directory the class is in
                    149: ###########################################################
                    150: proc specifyClass { title typename type followupCommand } {
                    151: #    set var [tk_getOpenFile]
                    152:     set var [tk_getOpenFile -title $title -filetypes \
                    153: 		 [list  [list  $typename $type ] { {All Files} {"*"} } ] ]
                    154:     
                    155:     if { $var == "" } {	return }
                    156:     
                    157:     $followupCommand $var
                    158: }
                    159: 
                    160: ###########################################################
                    161: # dateUpdate
                    162: ###########################################################
                    163: # updates the gDate var, and register to run again in .8 seconds
                    164: ###########################################################
                    165: # Arguments: None
                    166: # Returns: Nothing
                    167: # Globals: gDate - gets set to the current time and date
                    168: ###########################################################
                    169: proc dateUpdate { } {
                    170:     global gDate
                    171:     set gDate [clock format [clock seconds]]
                    172:     after 800 dateUpdate
                    173: }
                    174: 
                    175: ###########################################################
                    176: ###########################################################
                    177: ###########################################################
                    178: ###########################################################
                    179: proc askToSave { msg cmd } {
                    180:     global gChanged gPrompt
                    181:     
                    182:     set dialog [toplevel .askToSavePrompt -borderwidth 10]
                    183:     wm title $dialog "Do you wish to Save"
                    184:     wm geo $dialog "+200+200"
                    185:     message $dialog.msg -text $msg -aspect 800
                    186:     
                    187:     set gPrompt(result) ""
                    188:     set buttonFrame [frame $dialog.buttons -bd 10]
                    189:     pack $dialog.msg $buttonFrame -side top -fill x
                    190:     
                    191:     bind $dialog <Destroy> { 
                    192: 	set gPrompt(result) Cancel
                    193: 	set gPrompt(yes) 0
                    194:     }
                    195: 
                    196:     button $buttonFrame.yes -text Yes -underline 0 -command {
                    197: 	set gPrompt(yes) 1
                    198:     }
                    199:     button $buttonFrame.no -text No -underline 0 -command {
                    200: 	set gPrompt(yes) 0
                    201:     } 
                    202:     button $buttonFrame.cancel -text Cancel  -underline 0 -command { 
                    203: 	set gPrompt(yes) 0 
                    204: 	set gPrompt(result) Cancel
                    205:     }
                    206:     pack $buttonFrame.yes $buttonFrame.no $buttonFrame.cancel -side left
                    207:     bind $dialog <Alt-Key> break
                    208: 
                    209:     Centre_Dialog $dialog default
                    210:     update
                    211: 
                    212:     focus $dialog
                    213:     capaRaise $dialog
                    214:     capaGrab $dialog
                    215:     vwait gPrompt(yes)
                    216:     capaGrab release $dialog
                    217:     bind $dialog <Destroy> ""
                    218:     destroy $dialog
                    219:     if {$gPrompt(yes)} {
                    220: 	eval $cmd
                    221:     } else {
                    222: 	return $gPrompt(result)
                    223:     }
                    224: }    
                    225: 
                    226: ###########################################################
                    227: # printAssignment
                    228: ###########################################################
                    229: ###########################################################
                    230: ###########################################################
                    231: proc printAssignment { classconfig } {
                    232:     global gCT gFile gUniqueNumber gCapaConfig
                    233: 
                    234:     set num [incr gUniqueNumber]
                    235:     set gFile($num) [file dirname $classconfig]
                    236:     getOneStudent "" $gFile($num) s_id s_name    
                    237:     if { $s_id == "" } { return }
                    238:     set s_id [string toupper $s_id]
                    239:     if { "" == [set setlist [getSetRange "" $gFile($num)]] } { return }
                    240:     set cmdnum [incr gUniqueNumber]
                    241:     if { "Yes" != [makeSure "Are you sure you want to print set(s) [linsert $setlist 1 to] for student: $s_name"] } { 
                    242: 	return
                    243:     }
                    244:     displayStatus "Running qzparse" message $num
                    245:     parseCapaConfig $num $gFile($num)
                    246:     set command "$gCapaConfig($num.qzparse_command) -c $gFile($num) \
                    247:                  -set [lindex $setlist 0]:[lindex $setlist 1] -stu $s_id"
                    248:     eval "exec $command"
                    249:     set tex_file [file join $gFile($num) TeX $s_id.tex]
                    250:     set command "$gCapaConfig($num.latex_command) $tex_file"
                    251:     removeStatus $num
                    252:     if { "Yes" != [makeSure "Planning on running LaTeX, Continue?"] } { return }
                    253:     displayStatus "Running LaTeX" message $num
                    254:     set directory [pwd]
                    255:     cd [file join $gFile($num) TeX]
                    256:     eval "exec $command"
                    257:     cd $directory
                    258:     set dvi_file [file join $gFile($num) TeX $s_id.dvi]
                    259:     set ps_file [file join $gFile($num) TeX $s_id.ps]
                    260:     set command "$gCapaConfig($num.dvips_command) $dvi_file -o $ps_file >& /dev/null"
                    261:     removeStatus $num
                    262:     if { "Yes" != [makeSure "Planning on running dvips, Continue?"] } { return }
                    263:     displayStatus "Running dvips" message $num
                    264:     eval "exec $command"
                    265:     removeStatus $num
                    266:     if { "Cancel" == [set lprcmd [getLprCommand $ps_file $num]] } { return }
                    267:     if { [catch { eval "exec $lprcmd" } errors ] } {
                    268: 	displayError "An error occurred while printing: $errors"
                    269:     }
                    270:     foreach name [array names gCapaConfig "$num.*"] {
                    271: 	unset gCapaConfig($name)
                    272:     }
                    273: }
                    274: 
                    275: source common.tcl
                    276: source utils.tcl
                    277: source classl.tcl
                    278: source scorer.tcl
                    279: source scorer.anon.tcl
                    280: source scorer.errors.tcl
                    281: source capastats.tcl
                    282: source seating.tcl
                    283: 
                    284: set gUniqueNumber 0
                    285: set gMaxSet 99
                    286: set gMaxTries 99
                    287: option add *font 8x13bold
                    288: option add selectbackground #b4b4ff
                    289: createControlWindow

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