version 1.4, 2000/02/22 18:10:27
|
version 1.6, 2000/07/07 18:25:12
|
Line 1
|
Line 1
|
#Copyright 2000 by Guy Albertelli |
# allow mass emailing to students |
|
# Copyright (C) 1992-2000 Michigan State University |
|
# |
|
# The CAPA system is free software; you can redistribute it and/or |
|
# modify it under the terms of the GNU Library General Public License as |
|
# published by the Free Software Foundation; either version 2 of the |
|
# License, or (at your option) any later version. |
|
# |
|
# The CAPA system is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
# Library General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU Library General Public |
|
# License along with the CAPA system; see the file COPYING. If not, |
|
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
# Boston, MA 02111-1307, USA. |
|
# |
|
# As a special exception, you have permission to link this program |
|
# with the TtH/TtM library and distribute executables, as long as you |
|
# follow the requirements of the GNU GPL in regard to all of the |
|
# software in the executable aside from TtH/TtM. |
|
|
|
#Created 2000 by Guy Albertelli |
proc runGroupEmail { capaConfigFile } { |
proc runGroupEmail { capaConfigFile } { |
global gUniqueNumber gFile gWindowMenu gCT |
global gUniqueNumber gFile gWindowMenu gCT |
set num [incr gUniqueNumber] |
set num [incr gUniqueNumber] |
Line 52 proc runGroupEmail { capaConfigFile } {
|
Line 75 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 97 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 134 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 148 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 166 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 207 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 330 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 340 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 353 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] |
} |
} |
|
|