Diff for /capa/capa51/GUITools/groupemail.tcl between versions 1.4 and 1.5

version 1.4, 2000/02/22 18:10:27 version 1.5, 2000/03/22 21:08:02
Line 52  proc runGroupEmail { capaConfigFile } { Line 52  proc runGroupEmail { capaConfigFile } {
     pack $bottom.spacer $bottom.sections -anchor w -side left      pack $bottom.spacer $bottom.sections -anchor w -side left
           
     #student      #student
     radiobutton $studentFrame.specific -text "Specify the student by:" \      radiobutton $studentFrame.specific -text "Students from file:" \
     -value "Specific" -variable gCT($num.emailtype)      -value "Specific" -variable gCT($num.emailtype)
     set studentNumber [frame $studentFrame.studentNumber]      entry $studentFrame.file -textvariable gCT($num.studentlist)
     set fullName [frame $studentFrame.fullName]      button $studentFrame.select -text "Browse" \
     pack $studentFrame.specific $studentNumber $fullName -side top   -command "set gCT($num.studentlist) \[tk_getOpenFile\]"
     pack configure $studentFrame.specific -anchor w      pack $studentFrame.specific $studentFrame.file $studentFrame.select -side left
     pack configure $studentNumber $fullName -anchor e  
   
     radiobutton $sectionFrame.section   
     label $studentNumber.msg -text "Student Number: "   
     entry $studentNumber.entry -textvariable gCT($num.studentNumber) \  
     -width 9 -validate key -validatecommand "limitEntry %W 9 any %P"  
     pack $studentNumber.msg $studentNumber.entry -side left  
   
     label $fullName.msg -text "Student Name: "    
     entry $fullName.msg2 -textvariable gCT($num.studentName) -width 35 \  
  -validate key -validatecommand "limitEntry %W 35 any %P"  
     pack $fullName.msg $fullName.msg2 -side left  
       
     trace variable gCT($num.studentNumber) w \  
  "global gCT; set gCT($num.emailtype) Specific ;#"  
     trace variable gCT($num.studentName) w \  
  "global gCT; set gCT($num.emailtype) Specific ;#"  
       
     bind $studentNumber.entry <KeyPress-Return> \  
  "fillInStudent gCT($num.studentName) gCT($num.studentNumber) 0"  
     bind $fullName.msg2 <KeyPress-Return> \  
  "fillInStudent gCT($num.studentName) gCT($num.studentNumber) 1"  
   
     #script      #script
     radiobutton $scriptFrame.label -text "Script Selection:" -value "Script" \      radiobutton $scriptFrame.label -text "Script Selection:" -value "Script" \
  -variable gCT($num.emailtype)   -variable gCT($num.emailtype)
     entry $scriptFrame.file -textvariable gCT($num.emailscript)      entry $scriptFrame.file -textvariable gCT($num.emailscript)
     button $scriptFrame.select -text "Browse" \      button $scriptFrame.select -text "Browse" \
  -command "set gCT($num.template) \[tk_getOpenFile\]"   -command "set gCT($num.emailscript) \[tk_getOpenFile\]"
     pack $scriptFrame.label $scriptFrame.file $scriptFrame.select -side left      pack $scriptFrame.label $scriptFrame.file $scriptFrame.select -side left
   
     button $buttonFrame.send -text "Send" -command "emailSend $num"      button $buttonFrame.send -text "Send" -command "emailSend $num"
Line 96  proc runGroupEmail { capaConfigFile } { Line 74  proc runGroupEmail { capaConfigFile } {
     Centre_Dialog $emailwin default      Centre_Dialog $emailwin default
 }  }
   
   proc emailClose { num } {
       global gFile
       destroy .email$num
       removeWindowEntry "Sending Email $gFile($num)"
   }
   
 proc emailSelectSections { num } {  proc emailSelectSections { num } {
     global gCT gFile      global gCT gFile
     set pwd [pwd]; cd $gFile($num)      set pwd [pwd]; cd $gFile($num)
Line 127  proc emailSend { num } { Line 111  proc emailSend { num } {
     foreach student $gCT($num.studentlist) {      foreach student $gCT($num.studentlist) {
  incr i   incr i
 # foreach {email firstname lastname stunum} $student {break}  # foreach {email firstname lastname stunum} $student {break}
  set message [emailMessage $num $student]   set subject ""
  emailSendMessage $num $student $message   set message [emailMessage $num $student subject]
    emailSendMessage $num $student $message $subject
  updateStatusBar [expr $i/double($max)] $num   updateStatusBar [expr $i/double($max)] $num
     }      }
     removeStatus $num      removeStatus $num
Line 140  proc emailConfirm { num } { Line 125  proc emailConfirm { num } {
     switch $gCT($num.emailtype) {      switch $gCT($num.emailtype) {
  Class { append msg " the whole class." }   Class { append msg " the whole class." }
  Sections { append msg " the sections $gCT($num.emailsections)." }   Sections { append msg " the sections $gCT($num.emailsections)." }
  Specific { append msg " to the students $gCT($num.emailstudents)." }   Specific { append msg " to the student numbers in $gCT($num.studentlist)." }
  Script {    Script { 
     append msg " to the students generated by the script $gCT($num.emailscript)."      append msg " to the students generated by the script $gCT($num.emailscript)."
  }   }
Line 158  proc emailGetStudents { num } { Line 143  proc emailGetStudents { num } {
     switch $gCT($num.emailtype) {      switch $gCT($num.emailtype) {
  Class { emailGetClass $num }   Class { emailGetClass $num }
   Sections { emailGetSections $num }    Sections { emailGetSections $num }
  Specific { }   Specific { emailGetSpecific $num }
  Script { }   Script { }
     }      }
 }  }
Line 199  proc emailGetSections { num } { Line 184  proc emailGetSections { num } {
     }      }
 }  }
   
 proc emailMessage { num student } {  proc emailGetSpecific { num } {
       global gCT gFile
       
       set fileId [open $gCT($num.studentlist)]
       set temp [split [read $fileId] "\n"]
       set allids ""
       foreach element $temp { if { $element != "" } { lappend allids $element } }
       close $fileId
       puts $allids
       set classlid [open [file join $gFile($num) classl] r]
       set aline [gets $classlid]
       while { ![eof $classlid] } {
    set stunum [string trim [string range $aline 14 22]]
    if { [lsearch $allids $stunum] !=-1 } {
       set section [string trimleft [string trim [string range $aline 10 12]] "0"]
       set email [string trim [string range $aline 60 99]]
       set firstname [string trim [lindex [lindex [split [string range $aline 24 59] ","] 1] 0]]
       set lastname [string trim [lindex [split [string range $aline 24 59] ","] 0]]
       set section [string trimleft [string trim [string range $aline 10 12] ] 0]
       lappend gCT($num.studentlist) [list $email $firstname $lastname $stunum $section]
    }
    set aline [gets $classlid]
       }
   }
   
   proc emailMessage { num student subjectVar } {
     global gCT gFile gCapaConfig      global gCT gFile gCapaConfig
       upvar $subjectVar subject
     set message $gCT($num.message)      set message $gCT($num.message)
   
     regsub -all -- \\\$email $message [lindex $student 0] message      regsub -all -- \\\$email $message [lindex $student 0] message
Line 296  proc emailMessage { num student } { Line 307  proc emailMessage { num student } {
     set examt [getTotals $i $stunum $section $gCapaConfig($num.exam_path)]      set examt [getTotals $i $stunum $section $gCapaConfig($num.exam_path)]
     set corrs [getScores $i $stunum $section $gCapaConfig($num.exam_path)]      set corrs [getScores $i $stunum $section $gCapaConfig($num.exam_path)]
     set corrt [getTotals $i $stunum $section $gCapaConfig($num.exam_path)]      set corrt [getTotals $i $stunum $section $gCapaConfig($num.exam_path)]
     set exam [expr $exams/double($examt)]      if { [catch {set exam [expr $exams/double($examt)]}] } { set exam 0 }
     set corr [expr $corrs/double($corrt)]      if { [catch {set corr [expr $corrs/double($corrt)]}] } { set corr 0 }
     if { $corr > $exam } {      if { $corr > $exam } {
  set totalexam [expr $totalexam + \   set totalexam [expr $totalexam + \
    [expr $exam + $gCapaConfig($num.correction_weight) \     [expr $exam + $gCapaConfig($num.correction_weight) \
Line 306  proc emailMessage { num student } { Line 317  proc emailMessage { num student } {
  set totalexam [expr $totalexam + $exam]   set totalexam [expr $totalexam + $exam]
     }      }
  }   }
  set totalexam [expr $totalexam / ($i-1)]   if { [catch {set totalexam [expr $totalexam / ($i-1)]}] } { set totalexam 0 }
  set finals [getScores $finalset $stunum $section $gCapaConfig($num.exam_path)]   set finals [getScores $finalset $stunum $section $gCapaConfig($num.exam_path)]
  set finalt [getTotals $finalset $stunum $section $gCapaConfig($num.exam_path)]   set finalt [getTotals $finalset $stunum $section $gCapaConfig($num.exam_path)]
  set final [expr $finals/double($finalt)]   if { [catch {set final [expr $finals/double($finalt)]}]} {set final 0}
  set homework [expr $all(homework.score)/double($all(homework.total))]   if { [catch {set homework [expr $all(homework.score)/double($all(homework.total))]}] } { set homework 0 }
  set quiz [expr $all(quiz.score)/double($all(quiz.total))]   if { [catch {set quiz [expr $all(quiz.score)/double($all(quiz.total))]}] } { set quiz 0 }
  set grade [expr $gCapaConfig($num.homework_weight)*$homework +\   set grade [expr $gCapaConfig($num.homework_weight)*$homework +\
        $gCapaConfig($num.quiz_weight)*$quiz +\         $gCapaConfig($num.quiz_weight)*$quiz +\
        $gCapaConfig($num.exam_weight)*$totalexam +\         $gCapaConfig($num.exam_weight)*$totalexam +\
Line 319  proc emailMessage { num student } { Line 330  proc emailMessage { num student } {
  set grade [format "%2.1f" [expr $grade * 100 ]]   set grade [format "%2.1f" [expr $grade * 100 ]]
  regsub -all -- \\\$grade $message $grade message   regsub -all -- \\\$grade $message $grade message
     }      }
       regexp "^Subject:(\[^\n]*)" $message garbage subject
       regsub "^Subject:(\[^\n]*)" $message {} message
     return $message      return $message
 }  }
   
 proc emailSendMessage { num student message } {  proc emailSendMessage { num student message subject } {
     global gCT gCapaConfig      global gCT gCapaConfig
     exec echo $message | $gCapaConfig($num.mail_command) [lindex $student 0]      exec echo $message | $gCapaConfig($num.mail_command) -s $subject [lindex $student 0]
 }  }
   

Removed from v.1.4  
changed lines
  Added in v.1.5


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