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

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 }
1.2       albertel   62:     $action add command -label "Send Class Email" -command \
1.3     ! albertel   63: 	{ specifyClass "Select the capa.config in the class directory" \
        !            64: 	      "CAPA configuration" "capa.config" runGroupEmail }
1.1       albertel   65:     $action add command -label "Randomize Seating File" \
                     66: 	-command { RSstart [incr gUniqueNumber] }
                     67: 
                     68:     $score add command -label "Run Scorer" -command \
                     69: 	{ specifyClass "Pick set.qz file" "QZ file" "*.qz" runScorer }
                     70:     $score add command -label "ReScore a scorer.output" -command \
                     71: 	{ specifyClass "Pick scorer.output file" "scorer.output file" \
                     72: 	      "scorer.output.*" reScore }
                     73: 
                     74:     $print add command -label "Print Assignment" -command \
                     75: 	{ specifyClass "Select the capa.config in the class directory" \
                     76: 	      "CAPA configuration" "capa.config" printAssignment  }
                     77: 
                     78:     bind $menuFrame <Destroy> { quit 0 }
                     79: }
                     80: 
                     81: ###########################################################
                     82: # createInfoWindow
                     83: ###########################################################
                     84: # creates the Information window
                     85: ###########################################################
                     86: # Arguments: None
                     87: # Returns: Nothing
                     88: # Globals: gDate - the variable containg the current date 
                     89: #          gWindowMenu - used to register the new window in the
                     90: #                        windows menu
                     91: #          gVer - Stores the current version of Grader (set in 
                     92: #                 C init code
                     93: ###########################################################
                     94: proc createInfoWindow {} {
                     95:     global gDate gWindowMenu gVer gTclVer gCmd gCompileDate
                     96: 
                     97:     if { [winfo exists .about] } {
                     98: 	capaRaise .about
                     99: 	return 
                    100:     }
                    101: 
                    102:     set about [toplevel .about]
                    103: 
                    104:     $gWindowMenu add command -label "About" -command "capaRaise $about"
                    105: 
                    106:     wm title $about "About" 
                    107:     
                    108:     label $about.l1 -font 12x24 -text "Manager $gVer" -pady 20
                    109:     label $about.l4 -font 8x13 -text "Manager.tcl Version $gTclVer" -pady 20
                    110:     label $about.l6  -font 8x13 -text "$gCompileDate" 
                    111:     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" \
                    112: 	-pady 20 -aspect 300
                    113:     label $about.l3 -font 8x13 -textvariable gDate 
                    114:     label $about.l5  -font 8x13 -textvariable gCmd
                    115: 
                    116:     button $about.close -text "Close" -command "destroy $about
                    117:                                                 removeWindowEntry About"
                    118:     
                    119:     pack $about.l1 $about.l4 $about.l6 $about.l2 $about.l3 $about.l5 \
                    120: 	    $about.close -side top 
                    121: 
                    122:     Centre_Dialog $about default
                    123: }
                    124: 
                    125: ###########################################################
                    126: # quit
                    127: ###########################################################
                    128: # called when the quit option is selected on the menu, unmaps
                    129: # all keys.
                    130: ###########################################################
                    131: # Arguments: None
                    132: # Returns: Nothing
                    133: # Globals: None
                    134: ###########################################################
                    135: proc quit { { ask 1} } {
                    136:     if { $ask && [makeSure "Are you sure you wish to quit?"] == "Cancel" } {
                    137: 	return 
                    138:     }
                    139:     
                    140:     unmapAllKeys
                    141:     exit
                    142: }
                    143: 
                    144: ###########################################################
                    145: # specifyClass
                    146: ###########################################################
                    147: # runs tk_getOpenFile and creates the class window if a directory is chosen
                    148: ###########################################################
                    149: # Arguments: None
                    150: # Returns: Nothing
                    151: # Globals: gClassDir - remembers the directory the class is in
                    152: ###########################################################
                    153: proc specifyClass { title typename type followupCommand } {
                    154: #    set var [tk_getOpenFile]
                    155:     set var [tk_getOpenFile -title $title -filetypes \
                    156: 		 [list  [list  $typename $type ] { {All Files} {"*"} } ] ]
                    157:     
                    158:     if { $var == "" } {	return }
                    159:     
                    160:     $followupCommand $var
                    161: }
                    162: 
                    163: ###########################################################
                    164: # dateUpdate
                    165: ###########################################################
                    166: # updates the gDate var, and register to run again in .8 seconds
                    167: ###########################################################
                    168: # Arguments: None
                    169: # Returns: Nothing
                    170: # Globals: gDate - gets set to the current time and date
                    171: ###########################################################
                    172: proc dateUpdate { } {
                    173:     global gDate
                    174:     set gDate [clock format [clock seconds]]
                    175:     after 800 dateUpdate
                    176: }
                    177: 
                    178: ###########################################################
                    179: ###########################################################
                    180: ###########################################################
                    181: ###########################################################
                    182: proc askToSave { msg cmd } {
                    183:     global gChanged gPrompt
                    184:     
                    185:     set dialog [toplevel .askToSavePrompt -borderwidth 10]
                    186:     wm title $dialog "Do you wish to Save"
                    187:     wm geo $dialog "+200+200"
                    188:     message $dialog.msg -text $msg -aspect 800
                    189:     
                    190:     set gPrompt(result) ""
                    191:     set buttonFrame [frame $dialog.buttons -bd 10]
                    192:     pack $dialog.msg $buttonFrame -side top -fill x
                    193:     
                    194:     bind $dialog <Destroy> { 
                    195: 	set gPrompt(result) Cancel
                    196: 	set gPrompt(yes) 0
                    197:     }
                    198: 
                    199:     button $buttonFrame.yes -text Yes -underline 0 -command {
                    200: 	set gPrompt(yes) 1
                    201:     }
                    202:     button $buttonFrame.no -text No -underline 0 -command {
                    203: 	set gPrompt(yes) 0
                    204:     } 
                    205:     button $buttonFrame.cancel -text Cancel  -underline 0 -command { 
                    206: 	set gPrompt(yes) 0 
                    207: 	set gPrompt(result) Cancel
                    208:     }
                    209:     pack $buttonFrame.yes $buttonFrame.no $buttonFrame.cancel -side left
                    210:     bind $dialog <Alt-Key> break
                    211: 
                    212:     Centre_Dialog $dialog default
                    213:     update
                    214: 
                    215:     focus $dialog
                    216:     capaRaise $dialog
                    217:     capaGrab $dialog
                    218:     vwait gPrompt(yes)
                    219:     capaGrab release $dialog
                    220:     bind $dialog <Destroy> ""
                    221:     destroy $dialog
                    222:     if {$gPrompt(yes)} {
                    223: 	eval $cmd
                    224:     } else {
                    225: 	return $gPrompt(result)
                    226:     }
                    227: }    
                    228: 
                    229: ###########################################################
                    230: # printAssignment
                    231: ###########################################################
                    232: ###########################################################
                    233: ###########################################################
                    234: proc printAssignment { classconfig } {
                    235:     global gCT gFile gUniqueNumber gCapaConfig
                    236: 
                    237:     set num [incr gUniqueNumber]
                    238:     set gFile($num) [file dirname $classconfig]
                    239:     getOneStudent "" $gFile($num) s_id s_name    
                    240:     if { $s_id == "" } { return }
                    241:     set s_id [string toupper $s_id]
                    242:     if { "" == [set setlist [getSetRange "" $gFile($num)]] } { return }
                    243:     set cmdnum [incr gUniqueNumber]
                    244:     if { "Yes" != [makeSure "Are you sure you want to print set(s) [linsert $setlist 1 to] for student: $s_name"] } { 
                    245: 	return
                    246:     }
                    247:     displayStatus "Running qzparse" message $num
                    248:     parseCapaConfig $num $gFile($num)
                    249:     set command "$gCapaConfig($num.qzparse_command) -c $gFile($num) \
                    250:                  -set [lindex $setlist 0]:[lindex $setlist 1] -stu $s_id"
                    251:     eval "exec $command"
                    252:     set tex_file [file join $gFile($num) TeX $s_id.tex]
                    253:     set command "$gCapaConfig($num.latex_command) $tex_file"
                    254:     removeStatus $num
                    255:     if { "Yes" != [makeSure "Planning on running LaTeX, Continue?"] } { return }
                    256:     displayStatus "Running LaTeX" message $num
                    257:     set directory [pwd]
                    258:     cd [file join $gFile($num) TeX]
                    259:     eval "exec $command"
                    260:     cd $directory
                    261:     set dvi_file [file join $gFile($num) TeX $s_id.dvi]
                    262:     set ps_file [file join $gFile($num) TeX $s_id.ps]
                    263:     set command "$gCapaConfig($num.dvips_command) $dvi_file -o $ps_file >& /dev/null"
                    264:     removeStatus $num
                    265:     if { "Yes" != [makeSure "Planning on running dvips, Continue?"] } { return }
                    266:     displayStatus "Running dvips" message $num
                    267:     eval "exec $command"
                    268:     removeStatus $num
                    269:     if { "Cancel" == [set lprcmd [getLprCommand $ps_file $num]] } { return }
                    270:     if { [catch { eval "exec $lprcmd" } errors ] } {
                    271: 	displayError "An error occurred while printing: $errors"
                    272:     }
                    273:     foreach name [array names gCapaConfig "$num.*"] {
                    274: 	unset gCapaConfig($name)
                    275:     }
                    276: }
                    277: 
                    278: source common.tcl
                    279: source utils.tcl
                    280: source classl.tcl
                    281: source scorer.tcl
                    282: source scorer.anon.tcl
                    283: source scorer.errors.tcl
                    284: source capastats.tcl
                    285: source seating.tcl
1.2       albertel  286: source groupemail.tcl
1.1       albertel  287: 
                    288: set gUniqueNumber 0
                    289: set gMaxSet 99
                    290: set gMaxTries 99
                    291: option add *font 8x13bold
                    292: option add selectbackground #b4b4ff
                    293: createControlWindow

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