Diff for /capa/capa51/GUITools/gradesubjective.tcl between versions 1.1.1.1 and 1.5

version 1.1.1.1, 1999/09/28 21:25:37 version 1.5, 1999/11/23 18:35:12
Line 50  proc createGradeSubjWindow {} { Line 50  proc createGradeSubjWindow {} {
     pack $msglist $msgbutton -side top      pack $msglist $msgbutton -side top
     pack configure $msgbutton -anchor w      pack configure $msgbutton -anchor w
   
     set gSubj(response) [listbox $msglist.list -width 40 -height 5 \      set gSubj(responseList) [listbox $msglist.list -width 40 -height 5 \
      -yscrollcommand "$msglist.scroll set"]   -yscrollcommand "$msglist.scroll set"]
     scrollbar $msglist.scroll -command "$msglist.text yview"      scrollbar $msglist.scroll -command "$msglist.list yview"
     pack $gSubj(response) $msglist.scroll -side left      pack $gSubj(responseList) $msglist.scroll -side left
     pack configure $msglist.scroll -fill y      pack configure $msglist.scroll -fill y
           
     set gSubj(numresponse) 0      set gSubj(numresponse) 0
Line 78  proc createGradeSubjWindow {} { Line 78  proc createGradeSubjWindow {} {
     pack configure $idlist.scroll -fill y      pack configure $idlist.scroll -fill y
   
     button $idbutton.delete -text Delete -command subjDeleteId      button $idbutton.delete -text Delete -command subjDeleteId
     pack $idbutton.delete      frame $idbutton.spacer -width 30
       label $idbutton.l1 -text "\# Words:"
       label $idbutton.words -textvariable gSubj(numwords)
       pack $idbutton.delete $idbutton.spacer $idbutton.l1 $idbutton.words -side left 
           
     set response [frame $grade.response]      set response [frame $grade.response]
     pack $response       pack $response 
   
     set scoreandcom [toplevel $gradSubj.scoreandcom]      set scoreandcom [toplevel $gradSubj.scoreandcom]
     wm title $scoreandcom "Control Panel"        wm title $scoreandcom "Control Panel"  
     wm protocol $gradSubj WM_DELETE_WINDOW "subjDone"      wm protocol $scoreandcom WM_DELETE_WINDOW "subjDone"
   
     set score [frame $scoreandcom.score]      set score [frame $scoreandcom.score]
     set command [frame $scoreandcom.command]      set command [frame $scoreandcom.command]
Line 204  proc subjCheckForNew {} { Line 207  proc subjCheckForNew {} {
     global gSubj      global gSubj
 }  }
   
   proc checkGSubj {} {
       global gSubj
       if {[catch {set gSubj(stunums)}]} {
    cd [file join $gSubj(dir) records set$gSubj(set) problem$gSubj(quest)]
    set gSubj(stunums) [lsort -dictionary [glob *]]
    if { [set num [lsearch $gSubj(stunums) gradingstatus]] != -1} {
       set gSubj(stunums) [lreplace $gSubj(stunums) $num $num]
    }
    cd $gSubj(dir)
       }
       if {[catch {set gSubj(current)}]} {set gSubj(current) -1}
       if {[catch {set gSubj(totalsec)}]} {set gSubj(totalsec) 0}
       if {[catch {set gSubj(seconds)}]} {set gSubj(seconds) [clock seconds]}
       if {[catch {set gSubj(togo)}]} {set gSubj(togo) [llength $gSubj(stunums)]}
       if {[catch {set gSubj(allstunum)}] || 
    [catch {set gSubj(allname)}] || 
    [catch {set gSubj(allemail)}] } {
    subjInitAllLists
       }
   }
   
 proc subjRestore {} {  proc subjRestore {} {
     global gSubj      global gSubj
     source gradingstatus      source gradingstatus
     subjCheckForNew      subjCheckForNew
     set gSubj(seconds) [expr {[clock seconds] - $gSubj(sec)}]      set gSubj(seconds) [expr {[clock seconds] - $gSubj(sec)}]
     cd $gSubj(dir)      cd $gSubj(dir)
     incr gSubj(current) -1      if { [catch {incr gSubj(current) -1}]} { set gSubj(current) -1 }
       if { $gSubj(redoalllists) } { subjInitAllLists; set gSubj(redoalllists) 0 }
       checkGSubj
       subjIndexResponse
     subjNext      subjNext
 }  }
   
Line 219  proc subjSave {} { Line 246  proc subjSave {} {
     set file [file join $gSubj(dir) records set$gSubj(set) \      set file [file join $gSubj(dir) records set$gSubj(set) \
   problem$gSubj(quest) gradingstatus]    problem$gSubj(quest) gradingstatus]
     set fileId [open $file w]      set fileId [open $file w]
     puts $fileId "array set gSubj \"[array get gSubj]\""      puts $fileId "array set gSubj \{[array get gSubj]\}"
     close $fileId      close $fileId
 }  }
   
 proc subjDone {} {  proc subjDone {} {
     global gSubj      global gSubj
     subjSave      if { [catch {subjSave}] } {
    displayMessage "Unable to save."
       }
     unset gSubj      unset gSubj
     destroy .gradesubjective      destroy .gradesubjective
 }  }
   
   proc subjInitAllLists {} {
       global gSubj
       set i 0
       catch {unset gSubj(allstunum)}
       catch {unset gSubj(allname)}
       catch {unset gSubj(allemail)}
       set fileId [open classl r]
       while { 1 } {
    incr i
    set aline [gets $fileId]
    if { [eof $fileId]} {break}
    lappend gSubj(allstunum) [string toupper [string range $aline 14 22]]
    #lappend gSubj(allname) [string toupper [string range $aline 24 59]]
    lappend gSubj(allname) [string range $aline 24 59]
    lappend gSubj(allemail) [string range $aline 60 99]
       }
   }
   
 proc subjInit {} {  proc subjInit {} {
     global gSubj      global gSubj
           
     set dir [file join $gSubj(dir) records set$gSubj(set) problem$gSubj(quest)]      set dir [file join $gSubj(dir) records set$gSubj(set) problem$gSubj(quest)]
     cd $dir      cd $dir
       set gSubj(redoalllists) 0
     if { [file exists gradingstatus] } { subjRestore } else {      if { [file exists gradingstatus] } { subjRestore } else {
  set gSubj(stunums) [lsort -dictionary [glob *]]   set gSubj(stunums) [lsort -dictionary [glob *]]
  cd $gSubj(dir)   cd $gSubj(dir)
  set gSubj(current) -1   set gSubj(current) -1
  set gSubj(totalsec) 0   set gSubj(totalsec) 0
  set gSubj(seconds) [clock seconds]   set gSubj(seconds) [clock seconds]
  set fileId [open classl r]   subjInitAllLists
  while { 1 } {  
     set aline [gets $fileId]  
     if { [eof $fileId]} {break}  
     lappend gSubj(allstunum) [string toupper [string range $aline 14 22]]  
 #    lappend gSubj(allname) [string toupper [string range $aline 24 59]]  
     lappend gSubj(allname) [string range $aline 24 59]  
  }  
  set gSubj(togo) [llength $gSubj(stunums)]   set gSubj(togo) [llength $gSubj(stunums)]
  subjNext   subjNext
     }      }
Line 318  proc subjNext {} { Line 359  proc subjNext {} {
  subjInsertIds $id   subjInsertIds $id
     }      }
   
       append words [string trim [$gSubj(response) get 0.0 end-1c]] " "
       set ws [format " \t\n"]
       set gSubj(numwords) [regsub -all -- \[$ws\]+  $words {} b]
     wm title .gradesubjective "Grading Subjective, Set $gSubj(set), Prob $gSubj(quest), $id"      wm title .gradesubjective "Grading Subjective, Set $gSubj(set), Prob $gSubj(quest), $id"
     if { [catch {set gSubj(score) $gSubj(done.$id.score)}] } {      if { [catch {set gSubj(score) $gSubj(done.$id.score)}] } {
  set gSubj(score) ""   set gSubj(score) ""
Line 496  proc subjPrev {} { Line 540  proc subjPrev {} {
   
 proc subjMessage { mesg {tag normal} } {  proc subjMessage { mesg {tag normal} } {
     global gSubj      global gSubj
     displayMessage $message      displayMessage $mesg
 #    $gSubj(msg) insert end "[clock format [clock seconds] -format {%I:%M:%S}] - $mesg\n" $tag  #    $gSubj(msg) insert end "[clock format [clock seconds] -format {%I:%M:%S}] - $mesg\n" $tag
 #    $gSubj(msg) see end  #    $gSubj(msg) see end
 }  }
Line 672  proc subjGetOneStudent { window path idV Line 716  proc subjGetOneStudent { window path idV
 ###########################################################  ###########################################################
 proc subjSendResponse {} {  proc subjSendResponse {} {
     global gSubj      global gSubj
   
       if { "" == [set which [$gSubj(responseList) curselection]]} {
    displayMessage "Please select a message to send."
    return
       }
       incr which
   
       set message ""
   
       set stuList [$gSubj(idlist) get 0 end]
       foreach stu $stuList {
    set stu [lindex $stu 0]
    set index [lsearch $gSubj(allstunum) $stu]
    set name [lindex $gSubj(allname) $index]
    set email [lindex $gSubj(allemail) $index]
    puts "$name:[split $name ,]:[lindex [split $name ,] 1]:[lindex [lindex [split $name ,] 1] 0]:$index:$stu"
    puts [lsearch $gSubj(allemail) albertel@pilot.msu.edu]
    set first_name [lindex [lindex [split $name ,] 1] 0]
    set last_name [lindex [split $name , ] 0]
    set score $gSubj(score)
    regsub -all -- \\\$last_name $gSubj(response.$which) $last_name message
    regsub -all -- \\\$first_name $message $first_name message
    regsub -all -- \\\$score $message $score message
   # set message [subst -nobackslashes -nocommands $gSubj(response.$which)]
    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"
    } else {
       set message "Subject: Class [file tail $gSubj(dir)], Set $gSubj(set), Question $gSubj(quest) \n$message"
    }
    displayMessage "$message sent to $email"
    exec echo $message | mail $email
       }
 }  }
   
   ###########################################################
   # subjIndexResponse
   ###########################################################
   ###########################################################
   ###########################################################
 proc subjIndexResponse {} {  proc subjIndexResponse {} {
     global gSubj      global gSubj
           
     $gSubj(response) delete 0 end      $gSubj(responseList) delete 0 end
   
     set i 0      set i 0
     foreach element [lsort -dictionary [array names gSubj "response.*"]] {      foreach element [lsort -dictionary [array names gSubj "response.*"]] {
  set head [string range $gSubj($element) 0 30]   regsub -all -- "\[\n\r\t\]+" [string range $gSubj($element) 0 37] " " head
  $gSubj(response) insert end "[incr i]. $head"   $gSubj(responseList) insert end "[incr i].$head"
     }      }
 }  }
   
Line 695  proc subjSaveResponse {} { Line 776  proc subjSaveResponse {} {
     global gSubj      global gSubj
           
     set num [incr gSubj(numresponse)]      set num [incr gSubj(numresponse)]
     set gSubj(response.$num) [$gSubj(responseEdit) get 0.0 end]      set gSubj(response.$num) [$gSubj(responseNew) get 0.0 end-1c]
       destroy [winfo toplevel $gSubj(responseNew)]
     subjIndexResponse      subjIndexResponse
       $gSubj(responseList) selection set end
       $gSubj(responseList) see end
 }  }
   
 ###########################################################  ###########################################################
Line 717  proc subjNewResponse {} { Line 801  proc subjNewResponse {} {
   
     set textFrame [frame $response.text]      set textFrame [frame $response.text]
     set buttonFrame [frame $response.button]      set buttonFrame [frame $response.button]
       pack $textFrame $buttonFrame
   
     set gSubj(responseEdit) [text $textFrame.text -yscrollcommand \      set gSubj(responseNew) [text $textFrame.text -yscrollcommand \
     "$textFrame.scroll set" -wrap char -height 15]      "$textFrame.scroll set" -wrap char -height 15]
     scrollbar $textFrame.scroll -command "$textFrame.text yview"      scrollbar $textFrame.scroll -command "$textFrame.text yview"
     pack $textFrame.scroll $textFrame.text -side left -expand 1      pack $textFrame.text $textFrame.scroll -side left -expand 1
       pack configure $textFrame.scroll -fill y
   
     button $buttonFrame.save -text Save -command "subjSaveResponse"      button $buttonFrame.save -text Save -command "subjSaveResponse"
     button $buttonFrame.forget -text Cancel -command "destroy $response"      button $buttonFrame.forget -text Cancel -command "destroy $response"
Line 735  proc subjNewResponse {} { Line 821  proc subjNewResponse {} {
 ###########################################################  ###########################################################
 proc subjDeleteResponse {} {  proc subjDeleteResponse {} {
     global gSubj      global gSubj
       if { [winfo exists .editresponse] } { 
    displayMessage "Please finish with editing the response, before deleting responses."
    return
       }
       if { "" == [set which [$gSubj(responseList) curselection]]} { return }
       incr which
       if { [catch {unset gSubj(response.$which)}] } {
    puts [array names gSubj response.*]
    return
       }
       for {set i [expr $which + 1]} { [info exists gSubj(response.$i)] } {incr i} {
    set j [expr $i - 1]
    set gSubj(response.$j) $gSubj(response.$i)
    unset gSubj(response.$i)
       }
       set gSubj(numresponse) [expr $i - 2]
       subjIndexResponse
       $gSubj(responseList) see [incr which -2]
 }  }
   
 ###########################################################  ###########################################################
Line 743  proc subjDeleteResponse {} { Line 847  proc subjDeleteResponse {} {
 ###########################################################  ###########################################################
 ###########################################################  ###########################################################
 proc subjEditResponse {} {  proc subjEditResponse {} {
     global gSubj      global gSubj gWindowMenu
   
       if { [winfo exists .editresponse] } { capaRaise .editresponse ; return }
       if { "" == [set which [$gSubj(responseList) curselection]]} { return }
       incr which
   
       set response [toplevel .editresponse ]
       $gWindowMenu add command -label "EditingResponse" -command "capaRaise $response"
       wm title $response "Editing a Response"  
   
       set textFrame [frame $response.text]
       set buttonFrame [frame $response.button]
       pack $textFrame $buttonFrame
   
       set gSubj(responseEdit) [text $textFrame.text -yscrollcommand \
       "$textFrame.scroll set" -wrap char -height 15]
       scrollbar $textFrame.scroll -command "$textFrame.text yview"
       pack $textFrame.text $textFrame.scroll -side left -expand 1
       pack configure $textFrame.scroll -fill y
       $gSubj(responseEdit) insert 0.0 $gSubj(response.$which)
   
       set gSubj(editresponsedone) 0
       button $buttonFrame.save -text Save -command "set gSubj(editresponsedone) 1"
       button $buttonFrame.forget -text Cancel -command "set gSubj(editresponsedone) 0"
       pack $buttonFrame.save $buttonFrame.forget -side left
       vwait gSubj(editresponsedone)
       if { $gSubj(editresponsedone) } {
    set gSubj(response.$which) [$gSubj(responseEdit) get 0.0 end-1c]
    subjIndexResponse
    $gSubj(responseList) selection set $which
    $gSubj(responseList) see $which
       } 
       destroy $response
 }  }
   
 ###########################################################  ###########################################################
Line 752  proc subjEditResponse {} { Line 888  proc subjEditResponse {} {
 ###########################################################  ###########################################################
 ###########################################################  ###########################################################
 proc subjViewResponse {} {  proc subjViewResponse {} {
     global gSubj      global gSubj gUniqueNumber gWindowMenu
   
       if { "" == [set which [$gSubj(responseList) curselection]]} { return }
       incr which
       set num [incr gUniqueNumber]
   
       set response [toplevel .viewresponse$num ]
       $gWindowMenu add command -label "ViewingResponse $which" \
    -command "capaRaise $response"
       wm title $response "Viewing Response $which"  
   
       set textFrame [frame $response.text]
       set buttonFrame [frame $response.button]
       pack $textFrame $buttonFrame
   
       text $textFrame.text -yscrollcommand "$textFrame.scroll set" -wrap char -height 15
       scrollbar $textFrame.scroll -command "$textFrame.text yview"
       pack $textFrame.text $textFrame.scroll -side left -expand 1
       pack configure $textFrame.scroll -fill y
       $textFrame.text insert 0.0 $gSubj(response.$which)
       $textFrame.text configure -state disabled
   
       button $buttonFrame.forget -text Dismiss -command "destroy $response"
       pack $buttonFrame.forget -side left
 }  }

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


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