version 1.8, 1999/12/07 19:45:45
|
version 1.11, 2000/07/07 18:25:12
|
Line 1
|
Line 1
|
|
# grade subjective responses |
|
# 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. |
|
|
set gMaxSet 99 |
set gMaxSet 99 |
|
|
proc gradeSubjective {} { |
proc gradeSubjective {} { |
Line 20 proc gradeSubjective {} {
|
Line 43 proc gradeSubjective {} {
|
gets $fileid aline |
gets $fileid aline |
gets $fileid aline |
gets $fileid aline |
set gSubj(max) [lindex [split $aline {}] [expr $gSubj(quest) - 1]] |
set gSubj(max) [lindex [split $aline {}] [expr $gSubj(quest) - 1]] |
|
set gSubj(keywords) "" |
createGradeSubjWindow |
createGradeSubjWindow |
} |
} |
|
|
Line 124 proc createGradeSubjWindow {} {
|
Line 148 proc createGradeSubjWindow {} {
|
|
|
set gSubj(keyword) [text $right.keyword -width 60 -height 5 \ |
set gSubj(keyword) [text $right.keyword -width 60 -height 5 \ |
-yscrollcommand "$right.scroll set" ] |
-yscrollcommand "$right.scroll set" ] |
puts $gSubj(keyword) |
|
puts $right |
|
scrollbar $right.scroll -command "$right.response yview" |
scrollbar $right.scroll -command "$right.response yview" |
pack $gSubj(keyword) $right.scroll -side left |
pack $gSubj(keyword) $right.scroll -side left |
pack configure $right.scroll -fill y |
pack configure $right.scroll -fill y |
|
|
|
bindtags $gSubj(keyword) "$gSubj(keyword) all" |
|
bind $gSubj(keyword) <1> "[bind Text <1>][bind Text <Double-1>]" |
|
|
button $left.add -command "subjAddKeyword" -text "Add" |
button $left.add -command "subjAddKeyword" -text "Add" |
button $left2.addsp -command "subjAddKeywordSpelling" -text "Add Sp" |
button $left2.addsp -command "subjAddKeywordSpelling" -text "Add Sp" |
button $left.delete -command "subjDeleteKeyword" -text "Delete" |
button $left.delete -command "subjDeleteKeyword" -text "Delete" |
Line 225 proc updateSecCount {} {
|
Line 250 proc updateSecCount {} {
|
|
|
proc subjCheckForNew {} { |
proc subjCheckForNew {} { |
global gSubj |
global gSubj |
|
|
|
foreach file [glob ?????????] { |
|
if { [lsearch $gSubj(stunums) $file] == -1 } { lappend gSubj(stunums) $file } |
|
} |
|
set gSubj(togo) [expr [llength $gSubj(stunums)]-$gSubj(done)] |
} |
} |
|
|
proc checkGSubj {} { |
proc checkGSubj {} { |
Line 290 proc subjInitAllLists {} {
|
Line 320 proc subjInitAllLists {} {
|
incr i |
incr i |
set aline [gets $fileId] |
set aline [gets $fileId] |
if { [eof $fileId]} {break} |
if { [eof $fileId]} {break} |
|
# skip blank lines |
|
if { [string trim $aline] == "" } { continue } |
lappend gSubj(allstunum) [string toupper [string range $aline 14 22]] |
lappend gSubj(allstunum) [string toupper [string range $aline 14 22]] |
#lappend gSubj(allname) [string toupper [string range $aline 24 59]] |
#lappend gSubj(allname) [string toupper [string range $aline 24 59]] |
lappend gSubj(allname) [string range $aline 24 59] |
lappend gSubj(allname) [string range $aline 24 59] |
Line 313 proc subjInit {} {
|
Line 345 proc subjInit {} {
|
set gSubj(togo) [llength $gSubj(stunums)] |
set gSubj(togo) [llength $gSubj(stunums)] |
subjNext |
subjNext |
} |
} |
|
subjUpdateKeywords |
after 300 updateSecCount |
after 300 updateSecCount |
} |
} |
|
|
Line 393 proc subjNext {} {
|
Line 426 proc subjNext {} {
|
subjInsertIds $gSubj(done.$id.idlist) |
subjInsertIds $gSubj(done.$id.idlist) |
update idletasks |
update idletasks |
} |
} |
|
subjUpdateResponse |
subjPicts |
subjPicts |
} |
} |
|
|
Line 415 proc subjFindIds2 {} {
|
Line 449 proc subjFindIds2 {} {
|
set text [string toupper [$gSubj(response) get 0.0 end]] |
set text [string toupper [$gSubj(response) get 0.0 end]] |
set result "" |
set result "" |
if { [catch {lsearch $text a}] } { |
if { [catch {lsearch $text a}] } { |
puts badlist; return subjFindIds1 |
#puts badlist |
|
return subjFindIds1 |
} else { |
} else { |
foreach id $gSubj(allstunum) { |
foreach id $gSubj(allstunum) { |
if { [lsearch -glob $text *$id*] != -1 } { |
if { [lsearch -glob $text *$id*] != -1 } { |
Line 735 proc subjGetOneStudent { window path idV
|
Line 770 proc subjGetOneStudent { window path idV
|
########################################################### |
########################################################### |
########################################################### |
########################################################### |
proc subjSendResponse {} { |
proc subjSendResponse {} { |
global gSubj |
global gSubj gCapaConfig |
|
|
if { "" == [set which [$gSubj(responseList) curselection]]} { |
if { "" == [set which [$gSubj(responseList) curselection]]} { |
displayMessage "Please select a message to send." |
displayMessage "Please select a message to send." |
Line 751 proc subjSendResponse {} {
|
Line 786 proc subjSendResponse {} {
|
set index [lsearch $gSubj(allstunum) $stu] |
set index [lsearch $gSubj(allstunum) $stu] |
set name [lindex $gSubj(allname) $index] |
set name [lindex $gSubj(allname) $index] |
set email [lindex $gSubj(allemail) $index] |
set email [lindex $gSubj(allemail) $index] |
puts "$name:[split $name ,]:[lindex [split $name ,] 1]:[lindex [lindex [split $name ,] 1] 0]:$index:$stu" |
#puts "$name:[split $name ,]:[lindex [split $name ,] 1]:[lindex [lindex [split $name ,] 1] 0]:$index:$stu" |
puts [lsearch $gSubj(allemail) albertel@pilot.msu.edu] |
#puts [lsearch $gSubj(allemail) albertel@pilot.msu.edu] |
set first_name [lindex [lindex [split $name ,] 1] 0] |
set first_name [lindex [lindex [split $name ,] 1] 0] |
set last_name [lindex [split $name , ] 0] |
set last_name [lindex [split $name , ] 0] |
set score $gSubj(score) |
set score $gSubj(score) |
Line 761 proc subjSendResponse {} {
|
Line 796 proc subjSendResponse {} {
|
regsub -all -- \\\$score $message $score message |
regsub -all -- \\\$score $message $score message |
# set message [subst -nobackslashes -nocommands $gSubj(response.$which)] |
# set message [subst -nobackslashes -nocommands $gSubj(response.$which)] |
if { [regexp -- (^Subject:\[^\n\]*)(\n)(.*) $message matchvar subjline newline messagebody] } { |
if { [regexp -- (^Subject:\[^\n\]*)(\n)(.*) $message matchvar subjline newline messagebody] } { |
set message "$subjline Class [file tail $gSubj(dir)], Set $gSubj(set), Question $gSubj(quest) \n$messagebody" |
set subject "$subjline Class [file tail $gSubj(dir)], Set $gSubj(set), Question $gSubj(quest)" |
|
set message $messagebody |
} else { |
} else { |
set message "Subject: Class [file tail $gSubj(dir)], Set $gSubj(set), Question $gSubj(quest) \n$message" |
set subject "Subject: Class [file tail $gSubj(dir)], Set $gSubj(set), Question $gSubj(quest)" |
} |
} |
displayMessage "$message sent to $email" |
displayMessage "$message sent to $email" |
exec echo $message | mail $email |
exec echo $message | $gCapaConfig(mail_command) -s $subject $email |
} |
} |
} |
} |
|
|
Line 848 proc subjDeleteResponse {} {
|
Line 884 proc subjDeleteResponse {} {
|
if { "" == [set which [$gSubj(responseList) curselection]]} { return } |
if { "" == [set which [$gSubj(responseList) curselection]]} { return } |
incr which |
incr which |
if { [catch {unset gSubj(response.$which)}] } { |
if { [catch {unset gSubj(response.$which)}] } { |
puts [array names gSubj response.*] |
#puts [array names gSubj response.*] |
return |
return |
} |
} |
for {set i [expr $which + 1]} { [info exists gSubj(response.$i)] } {incr i} { |
for {set i [expr $which + 1]} { [info exists gSubj(response.$i)] } {incr i} { |
Line 940 proc subjViewResponse {} {
|
Line 976 proc subjViewResponse {} {
|
########################################################### |
########################################################### |
########################################################### |
########################################################### |
proc subjUpdateResponse {} { |
proc subjUpdateResponse {} { |
gSubj |
global gSubj |
|
|
|
$gSubj(response) tag delete keyword |
|
$gSubj(response) tag configure keyword -background green |
|
set startindex 0.0 |
|
set lastindex [$gSubj(response) index end] |
|
while { 1 } { |
|
set endindex [$gSubj(response) index "$startindex wordend"] |
|
# puts "$startindex -> $endindex" |
|
set word [string trim [string toupper [$gSubj(response) get $startindex $endindex]]] |
|
if { $word != "" } { |
|
# puts "Word :$word:" |
|
foreach keyword $gSubj(keywords) { |
|
set keyword [string toupper [lindex $keyword 1]] |
|
if { [lsearch -exact $keyword $word] != -1 } { |
|
$gSubj(response) tag add keyword $startindex $endindex |
|
} |
|
} |
|
# puts [$gSubj(response) index "$endindex+1c"] |
|
# puts [$gSubj(response) index "$endindex wordstart"] |
|
# puts [$gSubj(response) index "$endindex+1c wordstart"] |
|
|
|
# set startindex [$gSubj(response) index "$endindex + 1c"] |
|
} |
|
set startindex $endindex |
|
if { $startindex == $lastindex } { break } |
|
} |
} |
} |
|
|
########################################################### |
########################################################### |
Line 951 proc subjUpdateResponse {} {
|
Line 1013 proc subjUpdateResponse {} {
|
proc subjUpdateKeywords {} { |
proc subjUpdateKeywords {} { |
global gSubj |
global gSubj |
$gSubj(keyword) delete 0.0 end |
$gSubj(keyword) delete 0.0 end |
puts $gSubj(keywords) |
set lokeyword "" |
|
# puts $gSubj(keywords) |
foreach keyword $gSubj(keywords) { lappend lokeyword [lindex $keyword 0] } |
foreach keyword $gSubj(keywords) { lappend lokeyword [lindex $keyword 0] } |
|
if { $lokeyword == "" } { return } |
set lokeyword [lsort $lokeyword] |
set lokeyword [lsort $lokeyword] |
set max 0 |
set max 0 |
foreach key $lokeyword { |
foreach key $lokeyword { |
Line 965 proc subjUpdateKeywords {} {
|
Line 1029 proc subjUpdateKeywords {} {
|
for { set i 0 } { $i < $end } { incr i } { |
for { set i 0 } { $i < $end } { incr i } { |
set line [expr $i/$numcol] |
set line [expr $i/$numcol] |
set col [expr $i%$numcol*$max] |
set col [expr $i%$numcol*$max] |
puts $line.$col |
# puts $line.$col |
$gSubj(keyword) insert end [format "%-[set max]s" [lindex $lokeyword $i]] |
$gSubj(keyword) insert end [format "%-[set max]s" [lindex $lokeyword $i]] |
if {($col + (2*$max)) > 60} { |
if {($col + (2*$max)) > 60} { |
puts "Putting in newlne" |
# puts "Putting in newlne" |
$gSubj(keyword) insert end "\n" |
$gSubj(keyword) insert end "\n" |
set lastline $line |
set lastline $line |
} |
} |
Line 982 proc subjUpdateKeywords {} {
|
Line 1046 proc subjUpdateKeywords {} {
|
########################################################### |
########################################################### |
########################################################### |
########################################################### |
proc subjAddKeyword {} { |
proc subjAddKeyword {} { |
global gSubj gUniqueNumber |
global gSubj |
|
|
if { "" == [set keyword [getString [winfo toplevel $gSubj(keyword)] "Enter a new keyword"]]} { |
if { "" == [set newword [getString [winfo toplevel $gSubj(keyword)] "Enter a new keyword" nospace ]]} { |
return |
return |
} |
} |
puts "New keyword $keyword" |
set i 0 |
lappend gSubj(keywords) [list $keyword [list $keyword]] |
foreach keyword $gSubj(keywords) { |
|
if {-1 != [lsearch $keyword $newword]} { break } |
|
incr i |
|
} |
|
if { $i >= [llength $gSubj(keywords)] } { |
|
lappend gSubj(keywords) [list $newword [list $newword]] |
|
subjUpdateKeywords |
|
} |
|
} |
|
|
|
########################################################### |
|
# subjAddKeywordSpelling |
|
########################################################### |
|
########################################################### |
|
########################################################### |
|
proc subjAddKeywordSpelling {} { |
|
global gSubj |
|
|
|
if { [catch {set word [$gSubj(keyword) get sel.first sel.last]}]} { return } |
|
if { "" == [set newspell [getString [winfo toplevel $gSubj(keyword)] "Enter a new spelling for $word" nospace ]]} { |
|
return |
|
} |
|
set i 0 |
|
foreach keyword $gSubj(keywords) { |
|
if {-1 != [lsearch $keyword $word]} { break } |
|
incr i |
|
} |
|
|
|
set gSubj(keywords) [lreplace $gSubj(keywords) $i $i \ |
|
[list $word [concat [lindex $keyword 1] $newspell]]] |
|
subjUpdateKeywords |
|
} |
|
|
|
########################################################### |
|
# subjSeeKeyword |
|
########################################################### |
|
########################################################### |
|
########################################################### |
|
proc subjSeeKeyword {} { |
|
global gSubj gPromptMC |
|
|
|
if { [catch {set word [$gSubj(keyword) get sel.first sel.last]}]} { return } |
|
set i 0 |
|
foreach keyword $gSubj(keywords) { |
|
if {-1 != [lsearch $keyword $word]} { break } |
|
incr i |
|
} |
|
|
|
set which $i |
|
set setWin [toplevel $gSubj(keyword).keyword] |
|
|
|
set msgFrame [frame $setWin.msgFrame] |
|
set valFrame [frame $setWin.valFrame] |
|
set buttonFrame [frame $setWin.buttonFrame] |
|
pack $msgFrame $valFrame $buttonFrame |
|
pack configure $valFrame -expand 1 -fill both |
|
|
|
message $msgFrame.msg -text "Alternate spellings for [lindex $keyword 0]" \ |
|
-aspect 3000 |
|
pack $msgFrame.msg |
|
|
|
set maxWidth 1 |
|
foreach choice [lindex $keyword 1] { |
|
if {[string length $choice] > $maxWidth} {set maxWidth [string length $choice]} |
|
} |
|
listbox $valFrame.val -width [expr $maxWidth + 2] \ |
|
-yscrollcommand "$valFrame.scroll set" -selectmode single |
|
scrollbar $valFrame.scroll -command "$valFrame.val yview" |
|
pack $valFrame.val $valFrame.scroll -side left |
|
pack configure $valFrame.val -expand 1 -fill both |
|
pack configure $valFrame.scroll -expand 0 -fill y |
|
foreach choice [lsort [lrange [lindex $keyword 1] 1 end]] { |
|
$valFrame.val insert end $choice |
|
} |
|
|
|
button $buttonFrame.select -text "Delete" -command { set gPromptMC(ok) 1 } |
|
frame $buttonFrame.spacer -width 10 |
|
button $buttonFrame.cancel -text "Dismiss" -command { set gPromptMC(ok) 0 } |
|
pack $buttonFrame.select $buttonFrame.cancel -side left |
|
|
|
bind $setWin <Return> "set gPromptMC(ok) 0" |
|
Centre_Dialog $setWin default |
|
update idletasks |
|
focus $setWin |
|
capaRaise $setWin |
|
capaGrab $setWin |
|
while { 1 } { |
|
update idletasks |
|
vwait gPromptMC(ok) |
|
if { $gPromptMC(ok) == 0 } { break } |
|
set select [$valFrame.val curselection] |
|
if { $select != "" } { |
|
$valFrame.val delete $select |
|
} |
|
} |
|
set spellings [lindex $keyword 0] |
|
for {set i 0} {$i < [$valFrame.val index end]} { incr i } { |
|
lappend spellings [$valFrame.val get $i] |
|
} |
|
capaGrab release $setWin |
|
destroy $setWin |
|
|
|
set gSubj(keywords) [lreplace $gSubj(keywords) $which $which \ |
|
[list [lindex $keyword 0] $spellings ]] |
|
|
|
subjUpdateKeywords |
|
} |
|
|
|
########################################################### |
|
# subjDeleteKeyword |
|
########################################################### |
|
########################################################### |
|
########################################################### |
|
proc subjDeleteKeyword {} { |
|
global gSubj |
|
|
|
if { [catch {set word [$gSubj(keyword) get sel.first sel.last]}]} { return } |
|
set newkeyword "" |
|
foreach keyword $gSubj(keywords) { |
|
if {-1 == [lsearch $keyword $word]} { lappend newkeyword $keyword } |
|
} |
|
set gSubj(keywords) $newkeyword |
subjUpdateKeywords |
subjUpdateKeywords |
} |
} |