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

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

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