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

1.1       albertel    1: proc runGroupEmail { capaConfigFile } {
1.2       albertel    2:     global gUniqueNumber gFile gWindowMenu gCT
1.1       albertel    3:     set num [incr gUniqueNumber]
                      4:     set gFile($num) [file dirname $capaConfigFile]
                      5:     parseCapaConfig $num $gFile($num)
                      6:     parseCapaUtilsConfig $num $gFile($num)
                      7:     
                      8:     set emailwin [toplevel .email$num]
                      9:     $gWindowMenu add command -label "Sending Email $gFile($num)" \
                     10: 	-command "capaRaise \"$emailwin\""
                     11:     wm title $scorerWin $classDir
1.2       albertel   12:     
                     13:     set fileFrame [frame $emailwin.file]
                     14:     set sentFrame [frame $emailwin.sent]
                     15:     set buttonFrame [frame $emailwin.button]
                     16:     pack $fileFrame $sentFrame $buttonFrame -side top
                     17: 
                     18:     label $fileFrame.label -text "Mail Template:"
                     19:     entry $fileFrame.file -textvariable gCT($num.template)
                     20:     button $fileFrame.select -text "Browse" \
                     21: 	-command "set gCT($num.template) [tk_fileOpen]"
                     22:     pack $fileFrame.label $fileFrame.file $fileFrame.select -side left
                     23:     
                     24:     label $sentFrame.text -text "Send To:"
                     25:     set classFrame [frame $sentFrame.class]
                     26:     set sectionFrame [frame $sentFrame.section]
                     27:     set studentFrame [frame $sentFrame.student]
                     28:     set scriptFrame [frame $sentFrame.script]
                     29:     pack $sentFrame.text $classFrame $sectionFrame $studentFrame $scriptFrame -side top
                     30:     
                     31:     #class
                     32:     radiobutton $classFrame.class -text "Whole Class" \
                     33: 	-variable gCT($num.emailtype) -value "Class"
                     34:     pack $classFrame.class
                     35: 
                     36:     #sections
                     37:     radiobutton $sectionFrame.button -text "Sections" \
                     38: 	-variable gCT($num.emailtype) -value "Sections"
                     39:     message $sectionFrame.sections -textvariable gCt($num.sections)
                     40:     button $sectionFrame.select -text "Select Section" -command emailSelectSections
                     41:     pack $sectionFrame.button $sectionFrame.sections $sectionFrame.select -side top
                     42: 
                     43:     #student
                     44:     radiobutton $studentFrame.specific -text "Specify the student by:" \
                     45: 	    -value "Specific" -variable gCT($num.emailtype)
                     46:     set studentNumber [frame $studentFrame.studentNumber]
                     47:     set fullName [frame $studentFrame.fullName]
                     48:     pack $studentFrame.specific $studentNumber $fullName -side top
                     49:     pack configure $studentFrame.specific -anchor w
                     50:     pack configure $studentNumber $fullName -anchor e
                     51: 
                     52:     radiobutton $sectionFrame.section 
                     53:     label $studentNumber.msg -text "Student Number: " 
                     54:     entry $studentNumber.entry -textvariable gCT($num.studentNumber) \
                     55: 	    -width 9 -validate key -validatecommand "limitEntry %W 9 any %P"
                     56:     pack $studentNumber.msg $studentNumber.entry -side left
                     57: 
                     58:     label $fullName.msg -text "Student Name: "  
                     59:     entry $fullName.msg2 -textvariable gCT($num.studentName) -width 35 \
                     60: 	-validate key -validatecommand "limitEntry %W 35 any %P"
                     61:     pack $fullName.msg $fullName.msg2 -side left
                     62:     
                     63:     trace variable gCT($num.studentNumber) w \
                     64: 	"global gCT; set gCT($num.emailtype) Specific ;#"
                     65:     trace variable gCT($num.studentName) w \
                     66: 	"global gCT; set gCT($num.emailtype) Specific ;#"
                     67:     
                     68:     bind $studentNumber.entry <KeyPress-Return> \
                     69: 	"fillInStudent gCT($num.studentName) gCT($num.studentNumber) 0"
                     70:     bind $fullName.msg2 <KeyPress-Return> \
                     71: 	"fillInStudent gCT($num.studentName) gCT($num.studentNumber) 1"
                     72: 
                     73:     #script
                     74:     label $scriptFrame.label -text "Script Selection:"
                     75:     entry $scriptFrame.file -textvariable gCT($num.template)
                     76:     button $scriptFrame.select -text "Browse" \
                     77: 	-command "set gCT($num.template) [tk_fileOpen]"
                     78:     pack $scriptFrame.label $scriptFrame.file $scriptFrame.select -side left
                     79: 
                     80:     button $buttonFrame.send -text "Send" -command "emailSend $num"
                     81:     button $buttonFrame.cancel -text "Cancel" -command "emailClose $num"
                     82:     pack $buttonFrame.send $buttonFrame.cancel -side top
                     83: }
                     84: 
                     85: proc emailSend { num } {
                     86:     global gCT gFile
                     87: 
                     88:     if { "Cancel" == [emailConfirm $num]} { return }
                     89:     emailGetStudents $num
                     90: 
                     91:     foreach student gCT($num.studentlist) {
                     92: #	foreach {email firstname lastname stunum} $student {break}
                     93: 	set message [emailMessage $student]
                     94: 	emailSendMessage $student $message
                     95:     }
1.3     ! albertel   96: }
        !            97: 
        !            98: proc emailGetStudents { num } {
        !            99:     global gCT gFile
        !           100:     
        !           101:     switch gCT($num.emailtype) {
        !           102: 	Class { emailGetClass $num }
        !           103: 	Sections { }
        !           104: 	Specific { }
        !           105: 	Script { }
        !           106:     }
        !           107: }
        !           108: 
        !           109: proc emailGetClass { num } {
        !           110:     global gCT gFile
        !           111:     set classlid [open [file join $gFile($num) classl] r]
        !           112:     set aline [gets $classlid]
        !           113:     while { ![eof $classlid] } {
        !           114: 	set email [string trim [string range $aline 60 99]]
        !           115: 	set firstname [string trim [lindex [lindex [split [string range $aline 24 59] ","] 1] 0]]
        !           116: 	set lastname [string trim [lindex [split [string range $aline 24 59] ","] 0]]
        !           117: 	set stunum [string trim [string range $aline 14 22]]
        !           118: 	lappend gCT($num.studentlist) [list $email $firstname $lastname $stunum]
        !           119: 	set aline [gets $classlid]
        !           120:     }
1.1       albertel  121: }

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