Annotation of capa/capa51/GUITools/capastats.tcl, revision 1.12
1.1 albertel 1: ###########################################################
2: # runCapaTools
3: ###########################################################
4: ###########################################################
5: ###########################################################
6: proc runCapaTools { classDirConfigFile } {
7: global gUniqueNumber gWindowMenu gFile gCT
8:
9: set num [incr gUniqueNumber]
10:
11: set classDir [file dirname $classDirConfigFile]
12: set gFile($num) $classDir
13:
14: set utilsMenu [menu .utilsMenu$num -tearoff 0 -type tearoff -font 8x13bold \
15: -disabledforeground grey85 ]
16: set gCT($num) $utilsMenu
17:
18: set pathLength [string length $gFile($num)]
19: if { $pathLength > 22 } {
20: set pathSubset ...[string range $gFile($num) [expr $pathLength - 22 ] end]
21: } else {
22: set pathSubset $gFile($num)
23: }
24: $utilsMenu add command -label "CapaUtils Ver 1.1" -foreground grey85 -background \
25: black -state disabled
26: $utilsMenu add command -label $pathSubset -foreground white -background \
27: grey30 -state disabled
28:
29: $utilsMenu add command -label "Change Class path" -command "CTchangePath $num"
30: $utilsMenu add command -label "Run capastat" -command "CTcapaStat $num"
31: $utilsMenu add command -label "Run capastat2" -command "CTcapaStat2 $num"
32: $utilsMenu add command -label "Summarize Log files" -command "CTlogAnalysis $num"
33: $utilsMenu add command -label "Student Course Profile" -command \
34: "CTstartStudentCourseProfile $num"
35: $utilsMenu add command -label "CAPA IDs for one student" \
36: -command "CToneStudentCapaID $num"
37: $utilsMenu add command -label "All CAPA IDs" -command "CTclassCapaID $num"
38: $utilsMenu add command -label "Item Analysis" -command "CTitemAnalysisStart $num"
39: $utilsMenu add command -label "Item Correlation" \
40: -command "CTitemCorrelationStart $num"
41: # $utilsMenu add command -label "Email" -command ""
42: # $utilsMenu add command -label "View Score File" -command ""
43: $utilsMenu add command -label "View Submissions" -command "CTsubmissions $num"
1.6 albertel 44: $utilsMenu add command -label "Create a Class Report" -command "CTcreateReport $num"
1.1 albertel 45: $utilsMenu add command -label "Analyze Class Report" -command "CTanalyzeReport $num"
46: $utilsMenu add command -label "Analyze Responses" -command "CTanalyzeScorer $num"
47: $utilsMenu add command -label "Graph a Responses Analysis" -command "CTgraphAnalyzeScorer $num"
1.2 albertel 48: $utilsMenu add command -label "Discussion Stats" -command "CTdiscussStats $num"
1.1 albertel 49: $utilsMenu add command -label "Quit" -command "CTquit $num"
50: $utilsMenu post 0 0
51: Centre_Dialog $utilsMenu default
52: set geometry [wm geometry $utilsMenu]
53: wm geometry $utilsMenu +0+[lindex [split $geometry +] end]
54: parseCapaConfig $num $gFile($num)
55: parseCapaUtilsConfig $num $gFile($num)
56: }
57:
58: #menu commands
59:
60: ###########################################################
61: # CTchangePath
62: ###########################################################
63: ###########################################################
64: ###########################################################
65: #FIXME need to wait unit all running commands are done
66: proc CTchangePath { num } {
67: global gFile gCapaConfig
68: set path [tk_getOpenFile -title "Please select a capa.config file" -filetypes \
69: { { {Capa Config} {capa.config} } }]
70: if { $path == "" } { return }
71: set gFile($num) [file dirname $path]
72: foreach temp [array names gCapaConfig "$num.*"] { unset gCapaConfig($temp) }
73: parseCapaConfig $num $gFile($num)
74: parseCapaUtilsConfig $num $gFile($num)
75: set pathLength [string length $gFile($num)]
76: if { $pathLength > 22 } {
77: set pathSubset ...[string range $gFile($num) [expr $pathLength - 22 ] end]
78: } else {
79: set pathSubset $gFile($num)
80: }
81: .utilsMenu$num entryconfigure 1 -label $pathSubset
82: }
83:
84: ###########################################################
85: # CTcapaStat2
86: ###########################################################
87: ###########################################################
88: ###########################################################
89: proc CTcapaStat2 { num } {
90: global gFile gCT gUniqueNumber
1.9 albertel 91: # if { [set setId [getOneSet $gCT($num) $gFile($num)]] == "" } { return }
92: if {[set setId [pickSets [CTsetList $gFile($num)] single "Pick A Set" \
93: $gCT($num)]] == "Cancel" } { return }
1.1 albertel 94: set cmdnum [incr gUniqueNumber]
95: set gCT(cmd.$cmdnum) capastat
96: if { [
97: catch {
98: CTdatestamp $cmdnum
99: set day [CTgetWhen $cmdnum]
100: set file [file join $gFile($num) records "subset$setId.db"]
101: displayStatus "Generating [file tail $file]" both $cmdnum
102: CTcreateSubset $num $cmdnum $day $setId
103: updateStatusBar 0.0 $cmdnum
104: updateStatusMessage "Generating Stats [file tail $file]" $cmdnum
105: CTscanSetDB $cmdnum $file Q_cnt L_cnt
106: updateStatusBar 0.0 $cmdnum
107: updateStatusMessage "Generating Averages [file tail $file]" $cmdnum
108: CTpercentageScores $cmdnum $setId $L_cnt
109: CTaverage $cmdnum $Q_cnt $L_cnt faillist dodifflist numyes
110: if { $L_cnt != 0 } {
111: CTbargraph $gCT($num) $num [incr gUniqueNumber] $faillist $gFile($num) "Not-Yet-Correct Distribution for set $setId" "Problem \#" "%Wrong"
112: CTbargraph $gCT($num) $num [incr gUniqueNumber] $dodifflist $gFile($num) "Degree of Difficulty Distribution for set $setId" "Problem \#" "Degree Of Diff."
113: CTbargraph $gCT($num) $num [incr gUniqueNumber] $numyes $gFile($num) "Number of Yeses received for set $setId" "Problem \#" "\#Students"
114: }
115: removeStatus $cmdnum
116: CToutput $num $cmdnum
117: } errors ] } {
118: global errorCode errorInfo
119: displayError "$errors\n$errorCode\n$errorInfo"
120: unset gCT(cmd.$cmdnum)
121: } else {
122: unset gCT(cmd.$cmdnum)
123: }
124: }
125:
126: ###########################################################
127: # CTcapaStat
128: ###########################################################
129: ###########################################################
130: ###########################################################
131: proc CTcapaStat { num } {
132: global gFile gCT gUniqueNumber
1.9 albertel 133: # if { [set setId [getOneSet $gCT($num) $gFile($num)]] == "" } { return }
134: if {[set setId [pickSets [CTsetList $gFile($num)] single "Pick A Set" \
135: $gCT($num)]] == "Cancel" } { return }
1.1 albertel 136: set cmdnum [incr gUniqueNumber]
137: set gCT(cmd.$cmdnum) capastat
138: if { [
139: catch {
140: CTdatestamp $cmdnum
141: set file [file join $gFile($num) records "set$setId.db"]
142: displayStatus "Generating Stats [file tail $file]" both $cmdnum
143: CTscanSetDB $cmdnum $file Q_cnt L_cnt
144: updateStatusBar 0.0 $cmdnum
145: updateStatusMessage "Generating Averages [file tail $file]" $cmdnum
146: CTpercentageScores $cmdnum $setId $L_cnt
147: CTaverage $cmdnum $Q_cnt $L_cnt faillist dodifflist numyes
148: CTbargraph $gCT($num) $num [incr gUniqueNumber] $faillist $gFile($num) "Not-Yet-Correct Distribution for set $setId" "Problem \#" "%Wrong"
149: CTbargraph $gCT($num) $num [incr gUniqueNumber] $dodifflist $gFile($num) "Degree of Difficulty Distribution for set $setId" "Problem \#" "Degree Of Diff."
150: CTbargraph $gCT($num) $num [incr gUniqueNumber] $numyes $gFile($num) "Number of Yeses received for set $setId" "Problem \#" "\#Students"
151: removeStatus $cmdnum
152: CToutput $num $cmdnum
153: } errors ] } {
154: global errorCode errorInfo
155: displayError "$errors\n$errorCode\n$errorInfo"
156: unset gCT(cmd.$cmdnum)
157: } else {
158: unset gCT(cmd.$cmdnum)
159: }
160: }
161:
162: ###########################################################
163: # CTlogAnalysis
164: ###########################################################
165: ###########################################################
166: ###########################################################
167: proc CTlogAnalysis { num } {
168: global gFile gUniqueNumber gCT
1.9 albertel 169: #if { [set setId [getOneSet $gCT($num) $gFile($num)]] == "" } { return }
170: if {[set setId [pickSets [CTsetList $gFile($num)] single "Pick A Set" \
171: $gCT($num)]] == "Cancel" } { return }
1.1 albertel 172: set cmdnum [incr gUniqueNumber]
173: set gCT(cmd.$cmdnum) loganalysis
174: CTdatestamp $cmdnum
175: if { [ catch { CTlogAnalysis2 $num $cmdnum $setId } errors ] } {
176: displayError $errors
177: unset gCT(cmd.$cmdnum)
178: } else {
179: unset gCT(cmd.$cmdnum)
180: }
181: CToutput $num $cmdnum
182: }
183:
184: ###########################################################
185: # CTstartStudentCourseProfile
186: ###########################################################
187: ###########################################################
188: ###########################################################
189: proc CTstartStudentCourseProfile { num } {
190: global gFile gCT
191: getOneStudent $gCT($num) $gFile($num) s_id s_name
192: if { $s_id == "" } { return }
193: CTstudentCourseProfile $num $s_id $s_name
194: }
195:
196: ###########################################################
197: # CTstudentCourseProfile
198: ###########################################################
199: ###########################################################
200: ###########################################################
201: proc CTstudentCourseProfile { num s_id s_name {loginAnalysis 2} } {
202: global gFile gUniqueNumber gCapaConfig gCT
203:
204: set cmdnum [incr gUniqueNumber]
205: set gCT(cmd.$cmdnum) studentcourseprofile
206: displayStatus "Collecting homework scores for $s_name" both $cmdnum
207: CTdatestamp $cmdnum
208: CTputs $cmdnum "$s_name\n"
209: if { [ catch { CTcollectSetScores $cmdnum $gFile($num) $s_id 1 \
210: $gCapaConfig($num.homework_scores_limit_set) } error ] } {
211: global errorCode errorInfo
212: displayError "$error \n $errorCode \n $errorInfo"
213: }
214: foreach type { quiz exam supp others } {
215: updateStatusMessage "Collecting $type scores for $s_name" $cmdnum
216: catch {
217: if { [file isdirectory $gCapaConfig($num.[set type]_path)] } {
218: CTcollectSetScores $cmdnum $gCapaConfig($num.[set type]_path) $s_id 1 \
219: $gCapaConfig($num.[set type]_scores_limit_set)
220: }
221: }
222: }
223: removeStatus $cmdnum
224: if { ($loginAnalysis == 2 && "Yes" == [makeSure \
225: "Do you wish to do a Login Analysis? It may take a while." ])
226: || ($loginAnalysis == 1) } {
227: displayStatus "Analyzing login data." both $cmdnum
228: if { [catch { CTloginAnalysis $cmdnum $gFile($num) $s_id \
229: $gCapaConfig($num.homework_scores_limit_set) } error] } {
230: displayError error
231: }
232: if { [catch { CTstudentSetAnalysis $cmdnum $gFile($num) $s_id \
233: $gCapaConfig($num.homework_scores_limit_set) } error] } {
234: displayError error
235: }
236: removeStatus $cmdnum
237: }
238: CTdisplayStudent $cmdnum $gCT($num) $gFile($num) $s_id
239: unset gCT(cmd.$cmdnum)
240: CToutput $num $cmdnum
241: }
242:
243: ###########################################################
244: # CToneStudentCapaID
245: ###########################################################
246: ###########################################################
247: ###########################################################
248: proc CToneStudentCapaID { num } {
249: global gFile gUniqueNumber gCapaConfig gCT
250:
251: getOneStudent $gCT($num) $gFile($num) s_id s_name
252: if { $s_id == "" } { return }
253:
254: set cmdnum [incr gUniqueNumber]
255: set gCT(cmd.$cmdnum) onestudentcapaid
256: set setlist [getSetRange $gCT($num) $gFile($num)]
257: set command "$gCapaConfig($num.allcapaid_command) -i -stu $s_id -s [lindex $setlist 0] -e [lindex $setlist 1] -c $gFile($num)"
258: if { "Yes" == [makeSure "CMD: $command\n Do you wish to execute this command?"] } {
259: CTdatestamp $cmdnum
260: CTputs $cmdnum "CapaIDs for: $s_id, $s_name\n"
261: displayStatus "Getting CapaIDs" spinner $cmdnum
262: set fileId [open "|$command" "r"]
263: fconfigure $fileId -blocking 0
264: fileevent $fileId readable "CTrunCommand $num $cmdnum $fileId"
265: }
266: }
267:
268: ###########################################################
269: # CTclassCapaID
270: ###########################################################
271: ###########################################################
272: ###########################################################
273: proc CTclassCapaID { num } {
274: global gFile gUniqueNumber gCapaConfig gCT
275:
276: set cmdnum [incr gUniqueNumber]
277: set gCT(cmd.$cmdnum) classcapaid
278: set setlist [getSetRange $gCT($num) $gFile($num)]
279: if { $setlist == "" } { return }
280: set command "$gCapaConfig($num.allcapaid_command) -i -s [lindex $setlist 0] -e [lindex $setlist 1] -c $gFile($num)"
281: if { "Yes" == [makeSure "CMD: $command\n Do you wish to execute this command?"] } {
282: CTdatestamp $cmdnum
283: displayStatus "Getting all CapaIDs" spinner $cmdnum
284: set fileId [open "|$command" "r"]
285: fconfigure $fileId -blocking 0
286: fileevent $fileId readable "CTrunCommand $num $cmdnum $fileId"
287: }
288: }
289:
290: ###########################################################
291: # CTitemAnalysisStart
292: ###########################################################
293: ###########################################################
294: ###########################################################
295: proc CTitemAnalysisStart { num } {
296: global gFile gUniqueNumber gCapaConfig gCT
297:
298: set cmdnum [incr gUniqueNumber]
299: set gCT(cmd.$cmdnum) itemanalysis
300: set paths ""
301: lappend paths [list "classpath" $gFile($num)]
302: foreach path [lsort [array names gCapaConfig "$num.*_path"]] {
303: lappend paths [list [lindex [split $path "."] 1] $gCapaConfig($path) ]
304: }
305: if {[set select [multipleChoice $gCT($num) "Select a class path" $paths ] ] == ""} {
306: unset gCT(cmd.$cmdnum)
307: return
308: }
1.9 albertel 309: # if { [set sets [getSetRange $gCT($num) [lindex $select 1]]] == "" } \{
310: if { [set sets [pickSets [CTsetList [lindex $select 1]] \
311: "extended" "Select Sets" $gCT($num)]] == "Cancel" } {
1.1 albertel 312: unset gCT(cmd.$cmdnum)
313: return
314: }
315: CTdatestamp $cmdnum
1.9 albertel 316: if { [ catch {CTitemAnalysisRange $cmdnum [lindex $select 1] $sets } errors ] } {
1.1 albertel 317: displayError $errors
318: }
319: unset gCT(cmd.$cmdnum)
320: CToutput $num $cmdnum
321: }
322:
323: ###########################################################
324: # CTitemCorrelationStart
325: ###########################################################
326: ###########################################################
327: ###########################################################
328: proc CTitemCorrelationStart { num } {
329: global gFile gUniqueNumber gCapaConfig gCT
330:
331: ## FIXME:
332: ## Let user specify how many categories to calculate correlation
333: ## For each category, the user can specify problem numbers to
334: ## be in that category
335: ## Then, the correlations between each category is calculated
336: ##
337: set cmdnum [incr gUniqueNumber]
338: set gCT(cmd.$cmdnum) itemanalysis
339: set paths ""
340: lappend paths [list "classpath" $gFile($num)]
341: foreach path [lsort [array names gCapaConfig "$num.*_path"]] {
342: lappend paths [list [lindex [split $path "."] 1] $gCapaConfig($path) ]
343: }
1.9 albertel 344: if {[set select [multipleChoice $gCT($num) "Select a class path" $paths]] == ""} {
1.1 albertel 345: unset gCT(cmd.$cmdnum)
346: return
347: }
1.9 albertel 348: #if { [set setId [getOneSet $gCT($num) [lindex $select 1]]] == "" } \{
349: if {[set setId [pickSets [CTsetList [lindex $select 1]] single "Pick A Set" \
350: $gCT($num)]] == "Cancel" } {
1.1 albertel 351: unset gCT(cmd.$cmdnum)
352: return
353: }
354: CTdatestamp $cmdnum
355: if { [ catch { CTitemCorrelation $cmdnum [lindex $select 1] \
356: $setId } errors ] } { displayError $errors }
357: unset gCT(cmd.$cmdnum)
358: CToutput $num $cmdnum
359: }
360:
361: ###########################################################
362: # CTsubmissions
363: ###########################################################
364: ###########################################################
365: ###########################################################
366: proc CTsubmissions { num } {
367: global gCT gFile gUniqueNumber gCapaConfig
368:
369: getOneStudent $gCT($num) $gFile($num) s_id s_name
370: if { $s_id == "" } { return }
371:
372: set cmdnum [incr gUniqueNumber]
373: set gCT(cmd.$cmdnum) submissions
1.9 albertel 374: if { [set sets [pickSets [CTsetList $gFile($num)] \
375: "extended" "Select Sets" $gCT($num)]] == "Cancel" } { return }
376: # if { "" == [set setlist [getSetRange $gCT($num) $gFile($num)]] } { return }
1.1 albertel 377: CTdatestamp $cmdnum
378: CTputs $cmdnum "Submissions for: $s_id, $s_name\n"
379: displayStatus "Getting submissions" spinner $cmdnum
1.9 albertel 380: CTsubmissionsLaunch $num $cmdnum telnet $s_id $s_name 0 $sets
1.1 albertel 381: }
382:
383: ###########################################################
1.6 albertel 384: # CTcreateReport
385: ###########################################################
386: ###########################################################
387: ###########################################################
388: proc CTcreateReport { num } {
389: global gUniqueNumber gCT gFile
390:
391: set cmdnum [incr gUniqueNumber]
392: set gCT(cmd.$cmdnum) createreport
393: CTcreateReportDialog $num $cmdnum
394: }
395:
396: ###########################################################
1.1 albertel 397: # CTanalyzeReport
398: ###########################################################
399: ###########################################################
400: ###########################################################
401: proc CTanalyzeReport { num } {
402: global gUniqueNumber gCT gFile
403:
404: set cmdnum [incr gUniqueNumber]
405: set gCT(cmd.$cmdnum) analyzereport
406:
407: set reportFile [tk_getOpenFile -title "Please select the Report file" \
408: -filetypes { {{Capa Reports} {*.rpt}} {{All Files} {*}} }]
409: if { $reportFile == "" } { return }
410: set percentage [tk_dialog $gCT($num).dialog "How would you like scores displayed?" \
411: "How would you like scores displayed?" "" "" "Points Earned" \
412: "Percentage" "Cancel"]
413: if { $percentage == 2 } { return }
414: set pwd [pwd];cd $gFile($num)
415: set sectionList [pickSections [getExistingSections] "Select Sections To Analyze:" $gCT($num) ]
416: CTdatestamp $cmdnum
417: CTputs $cmdnum "Analyzing Report File $reportFile\n"
418: CTputs $cmdnum " For Sections $sectionList\n"
419: CTputs $cmdnum " Report Created at [clock format [file mtime $reportFile]]\n"
420: cd $pwd
421: set scorelist [CTreportDist $cmdnum $reportFile $percentage $sectionList]
422: set label [lindex "{Grade} {Grade(%)}" $percentage]
423: set ptsearned 0
424: set totalnumstu 0
425: foreach element $scorelist {
426: set numstu [lindex $element 0]
427: set score [lindex $element 1]
428: set ptsearned [expr $ptsearned + ($numstu*$score)]
429: incr totalnumstu $numstu
430: }
431: set average [expr $ptsearned / double($totalnumstu)]
432: set avgmsg [format "Average: %.2f" $average]
433: CTputs $cmdnum $avgmsg\n
434: CTbargraph $gCT($num) $num $cmdnum $scorelist $gFile($num) "Score Distribution for [file tail $reportFile] $avgmsg" $label "\# Students" SCP
435: unset gCT(cmd.$cmdnum)
436: CToutput $num $cmdnum
437: }
438:
439: ###########################################################
440: # CTanalyzeScorer
441: ###########################################################
442: ###########################################################
443: ###########################################################
444: proc CTanalyzeScorer { num } {
445: global gFile gUniqueNumber gCapaConfig gCT
446: set cmdnum [incr gUniqueNumber]
447: set gCT(cmd.$cmdnum) analyzescorer
448: if { "" == [set file [tk_getOpenFile -title "Pick a scorer.output file" -filetypes { { {scorer.output} {scorer.output.*} } { {Submissions File} {*submissions*.db} } { {All Files} {*} } }]] } { return }
449: set path [file dirname [file dirname $file]]
450: if { "" == [set gCT($cmdnum.questNum) [getString $gCT($num) "Which questions?"]]} {
451: return
452: }
453: set gCT($cmdnum.max) [lindex [exec wc -l $file] 0]
454: set gCT($cmdnum.done) 1
455: set gCT($cmdnum.graphup) 0
456: set gCT($cmdnum.num) $num
457: displayStatus "Getting student reponses" both $cmdnum
458: set gCT($cmdnum.fileId) [open $file r]
459: if { [regexp {scorer\.output\.([0-9]|([0-9][0-9]))} $file] } {
460: set gCT($cmdnum.setId) [string range [file extension $file] 1 end]
461: set gCT($cmdnum.parse) CTparseScorerOutputLine
462: set aline [gets $gCT($cmdnum.fileId)]
463: } else {
464: set gCT($cmdnum.setId) [lindex [split [file tail $file] s.] 4]
465: set gCT($cmdnum.parse) CTparseSubmissionsLine
466: }
467: set aline [gets $gCT($cmdnum.fileId)]
468: $gCT($cmdnum.parse) $aline $cmdnum
469: set pwd [pwd];cd $path
470: getSet $gCT($cmdnum.question) $gCT($cmdnum.setId) "CTcontinueAnalyze $cmdnum $path"
471: cd $pwd
472: }
473:
474: proc CTcontinueAnalyze { num path arrayVar } {
475: global gCT gResponse
476: upvar $arrayVar question
477: CTgetQuestions $num question
478: set numAdded 0
479: foreach which $gCT($num.questNum) {
480: incr numAdded [CTgetStudentResponses $num [lindex $gCT($num.response) \
481: [expr $which-1]] $which \
482: question]
483: }
484: updateStatusBar [expr $gCT($num.done)/double($gCT($num.max))] $num
485: if { $numAdded > 0 } { CTupdateAnalyzeScorer $num }
486: set interesting 0
487: while {!$interesting} {
488: incr gCT($num.done)
489: set stunum $gCT($num.question)
490: set aline [gets $gCT($num.fileId)]
491: if { [eof $gCT($num.fileId)] } { CTfinishAnalyzeScorer $num; return }
492: set interesting [$gCT($num.parse) $aline $num]
493: }
494: if { $stunum != $gCT($num.question) } {
495: set pwd [pwd];cd $path
496: getSet $gCT($num.question) $gCT($num.setId) "CTcontinueAnalyze $num $path"
497: cd $pwd
498: } else {
499: CTcontinueAnalyze $num $path question
500: }
501: }
502:
503: proc CTupdateAnalyzeScorer { cmdnum } {
504: global gCT gResponse gUniqueNumber gFile
505: set num $gCT($cmdnum.num)
506: set i 0
507: foreach correct [array names gResponse "$cmdnum.correct.*"] {
508: set probnum [lindex [split $correct .] 2]
509: set answer [join [lrange [split $correct .] 3 end] .]
510: if { $gResponse($correct) } {
511: set color($probnum.$answer) green
512: } else {
513: set color($probnum.$answer) red
514: }
515: }
516: set results ""
517: set oldprobnum [lindex [split [lindex [lsort [array names gResponse $cmdnum.\[0-9\]*]] 0] .] 1]
518: foreach response [lsort -dictionary [array names gResponse $cmdnum.\[0-9\]*]] {
519: incr i
520: set probnum [lindex [split $response .] 1]
521: if { $probnum > $oldprobnum } {
522: set oldprobnum $probnum
523: lappend results [list 0 0 "Problem Divider" white]
524: }
525: set answer [join [lrange [split $response .] 2 end] .]
526: lappend results [list $gResponse($response) $i $answer $color($probnum.$answer)]
527: }
528: if { $results == "" } { return }
529: if { $gCT($cmdnum.graphup)} {
530: CTchangeBargraphData $cmdnum $results
531: } else {
532: CTbargraph $gCT($num) $num $cmdnum $results $gFile($num) "Reponse Distribution" "Which Response" "\#Picked" "Showresponse"
533: set gCT($cmdnum.graphup) 1
534: }
535:
536: update idletasks
537: }
538:
539: proc CTsaveAnalyzeScorer { num cmdnum } {
540: global gResponse gCT gFile
541: set file [tk_getSaveFile -initialdir $gFile($num)]
542: set fileId [open $file w]
543: puts $fileId [array get gResponse "$cmdnum.*"]
544: close $fileId
545: }
546:
547: proc CTfinishAnalyzeScorer { cmdnum } {
548: global gCT gResponse gUniqueNumber gFile
549:
550: set num $gCT($cmdnum.num)
551: set i 0
552: removeStatus $cmdnum
553: foreach correct [array names gResponse "$cmdnum.correct.*"] {
554: set probnum [lindex [split $correct .] 2]
555: set answer [join [lrange [split $correct .] 3 end] .]
556: if { $gResponse($correct) } {
557: set color($probnum.$answer) green
558: } else {
559: set color($probnum.$answer) red
560: }
561: }
562: foreach response [lsort -dictionary [array names gResponse $cmdnum.\[0-9\]*]] {
563: incr i
564: set probnum [lindex [split $response .] 1]
565: set answer [join [lrange [split $response .] 2 end] .]
566: lappend results($probnum) [list $gResponse($response) $i $answer $color($probnum.$answer)]
567: }
568: foreach probnum [lsort -dictionary [array names results]] {
569: CTputs $cmdnum "\nFor Problem $probnum #, Responses:\n"
570: foreach response $results($probnum) {
571: CTputs $cmdnum "[lindex $response 0], [lindex $response 2]\n"
572: }
573: }
574: if { "Yes" ==[makeSure "Would you like to save the results to a file?"] } {
575: CTsaveAnalyzeScorer $num $cmdnum
576: }
577: unset gCT(cmd.$cmdnum)
578: CToutput $num $cmdnum
579: }
580:
581: proc CTparseScorerOutputLine { aline num } {
582: global gCT
583: set gCT($num.stunum) [lindex $aline 0]
584: set aline [string range $aline 40 end]
585: set length [llength [split [lrange $aline 3 end] ,] ]
586: set gCT($num.response) [lrange [split [lrange $aline 3 end] ,] 0 \
587: [expr {$length-2}]]
588: set gCT($num.question) [lindex [lindex [split $aline ,] end] 0]
589: return 1
590: }
591:
592: proc CTparseSubmissionsLine { aline num } {
593: global gCT
594: set aline [split $aline \t]
595: set gCT($num.stunum) [lindex $aline 0]
596: set gCT($num.question) $gCT($num.stunum)
597: set gCT($num.response) ""
598: set interesting 0
599: set current 1
600: foreach {quest response} [lrange $aline 2 end] {
601: if { $quest == "" } break
602: while { $quest > $current } {
603: lappend gCT($num.response) {}
604: incr current
605: }
606: if { [lsearch $gCT($num.questNum) $quest] != -1} { set interesting 1 }
607: lappend gCT($num.response) [string toupper $response]
608: incr current
609: }
610: return $interesting
611: }
612:
613: proc CTgetQuestions { num questionVar } {
614: global gCT
615: upvar $questionVar question
616: # parray question
617: foreach quest $gCT($num.questNum) {
618: foreach line $question($quest.quest) {
619: if { [regexp {^ *([A-Z])\)(.*)} $line temp letter rest] } {
620: set question($quest.$letter) $rest
621: if { [string first $letter $question($quest.ans)] != -1} {
622: set question($quest.correct.$letter) 1
623: set question($quest.$letter) "$rest - Correct"
624: } else {
625: set question($quest.correct.$letter) 0
626: set question($quest.$letter) "$rest - Incorrect"
627: }
628: }
629: }
630: }
631: }
632:
633: proc CTgetStudentResponses { num responses which questionVar } {
634: global gCT gResponse
635: upvar $questionVar question
636: # parray question
637: set i 0
638: foreach response [split $responses {}] {
639: if { $response == "" || $response == " "} { continue }
640: incr i
641: if { [catch {incr gResponse($num.$which.$question($which.$response))}] } {
642: if {[catch {set gResponse($num.$which.$question($which.$response)) 1}]} {
643: #set gResponse($num.$which.Illegal\ Bubble) 1
644: puts "not an option $response $which"
645: continue
646: }
647: }
648: if { $question($which.correct.$response) } {
649: set gResponse($num.correct.$which.$question($which.$response)) 1
650: } else {
651: set gResponse($num.correct.$which.$question($which.$response)) 0
652: }
653: }
654: return $i
655: }
656:
657: ###########################################################
658: # CTgraphAnalyzeScorer
659: ###########################################################
660: ###########################################################
661: ###########################################################
662: proc CTgraphAnalyzeScorer { num } {
663: global gFile gUniqueNumber gCapaConfig gCT gResponse
664: set cmdnum [incr gUniqueNumber]
665: set gCT(cmd.$cmdnum) graphanalyzescorer
666: if { "" == [set file [tk_getOpenFile -title "Pick a Output file" -filetypes { { {All Files} {*} } } -initialdir $gFile($num)]] } { return }
667: set fileId [open $file r]
668: set temp [read $fileId [file size $file]]
669: close $fileId
670: foreach {name value} $temp {
671: set name [join "$cmdnum [lrange [split $name .] 1 end]" .]
672: set gResponse($name) $value
673: }
674: unset temp
675: foreach name [array names gResponse $cmdnum.\[0-9\]*] {
676: puts "[split $name .]"
677: puts "[lindex [split $name .] 1]"
678: lappend probnums [lindex [split $name .] 1]
679: }
680: set probnums [lsort [lunique $probnums]]
681: event generate . <1> -x 1 -y 1
682: event generate . <ButtonRelease-1>
683: if { "" == [set probnums [multipleChoice $gCT($num) "Select which problems" $probnums 0]] } { return }
684: foreach name [array names gResponse $cmdnum.\[0-9\]*] {
685: set probnum [lindex [split $name .] 1]
686: if { -1 == [lsearch $probnums $probnum] } {
687: set answer [join [lrange [split $name .] 2 end] .]
688: unset gResponse($name)
689: unset gResponse($cmdnum.correct.$probnum.$answer)
690: }
691: }
692: set gCT($cmdnum.num) $num
693: set gCT($cmdnum.graphup) 0
694: CTupdateAnalyzeScorer $cmdnum
695: unset gCT(cmd.$cmdnum)
696: }
697:
698: ###########################################################
1.2 albertel 699: # CTdiscussStats
700: ###########################################################
701: ###########################################################
702: ###########################################################
703: proc CTdiscussStats { num } {
704: global gCT gUniqueNumber gFile
705: set cmdnum [incr gUniqueNumber]
706: set gCT(cmd.$cmdnum) discussstats
707: set file [file join $gFile($num) discussion logs access.log]
708: displayStatus "Generating discussion Stats" both $cmdnum
1.3 albertel 709: CTdiscussForum $cmdnum $file $gFile($num) discussData 0
710: CTputsDiscussResults $cmdnum discussData
1.2 albertel 711: CToutput $num $cmdnum
712: removeStatus $cmdnum
713: unset gCT(cmd.$cmdnum)
714: }
715:
716: ###########################################################
1.1 albertel 717: # CTquit
718: ###########################################################
719: ###########################################################
720: ###########################################################
721: proc CTquit { num } {
722: global gCT
723: destroy $gCT($num)
724: }
725:
726: #menu command helpers
727: ###########################################################
728: # CTscanSetDB
729: ###########################################################
730: ###########################################################
731: ###########################################################
732: proc CTscanSetDB { num file Q_cntVar L_cntVar } {
733: global gMaxSet gTotal_try gYes_cnt gyes_cnt gStudent_cnt gStudent_try \
734: gTotal_weight gTotal_scores gEntry gScore gNewStudent_cnt
735: upvar $Q_cntVar Q_cnt
736: upvar $L_cntVar L_cnt
737:
738: set line_cnt 0
739: set valid_cnt 0
740:
741: for { set ii 0 } { $ii <= $gMaxSet } { incr ii } {
742: set gTotal_try($num.$ii) 0
743: set gYes_cnt($num.$ii) 0
744: set gyes_cnt($num.$ii) 0
745: for { set jj 0 } { $jj <= $gMaxSet } { incr jj } {
746: set gStudent_cnt($num.$ii.$jj) 0
747: set gStudent_try($num.$ii.$jj) 0
748: }
749: set gNewStudent_cnt($num.$ii) 0
750: }
751: set gTotal_weight($num) 0
752: set gTotal_scores($num) 0
753:
754: set maxLine [lindex [exec wc $file] 0]
755: set tries ""
756: set fileId [open $file "r"]
757: set aline [gets $fileId]
758: while { ! [eof $fileId] } {
759: incr line_cnt
760: if { ($line_cnt%20) == 0 } {
761: updateStatusBar [expr $line_cnt/double($maxLine)] $num
762: }
763: if { $line_cnt == 2 } {
764: set aline [string trim $aline]
765: set weight [split $aline {}]
766: }
767: if { $line_cnt > 3 } {
768: catch {
769: set aline [string trim $aline]
770: set prefix [lindex [split $aline ,] 0]
771: set s_num [lindex [split $aline " "] 0]
772: set ans_str [lindex [split $prefix " "] 1]
773: set ans_char [split $ans_str {} ]
774: set tries [lrange [split $aline ,] 1 end]
775: for { set valid 0; set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
776: if {([lindex $ans_char $ii] != "-")&&([lindex $ans_char $ii] != "E")
777: && ([lindex $ans_char $ii] != "e") } { set valid 1 }
778: }
779: if { $valid } {
780: for {set score 0; set ii 0} { $ii < [llength $tries] } { incr ii } {
781: set triesii 0
782: incr gTotal_weight($num) [lindex $weight $ii]
783: if { [lindex $ans_char $ii] == "Y" } {
784: set triesii [string trim [lindex $tries $ii]]
785: incr gYes_cnt($num.$ii)
786: incr score [lindex $weight $ii]
787: incr gNewStudent_cnt($num.$ii)
788: } elseif { [lindex $ans_char $ii] == "y" } {
789: set triesii [string trim [lindex $tries $ii]]
790: incr triesii
791: incr gyes_cnt($num.$ii)
792: incr score [lindex $weight $ii]
793: incr gNewStudent_cnt($num.$ii)
794: } elseif { ( [lindex $ans_char $ii] > 0 ) && \
795: ( [lindex $ans_char $ii] <= 9) } {
796: set triesii [string trim [lindex $tries $ii]]
797: incr score [lindex $ans_char $ii]
798: incr gYes_cnt($num.$ii)
799: incr gNewStudent_cnt($num.$ii)
800: } elseif { ( [lindex $ans_char $ii] == 0 ) } {
801: set triesii [string trim [lindex $tries $ii]]
802: incr gNewStudent_cnt($num.$ii)
803: } elseif {([lindex $ans_char $ii]=="n") || \
804: ([lindex $ans_char $ii]=="N")} {
805: set triesii [string trim [lindex $tries $ii]]
806: if { [lindex $ans_char $ii] == "n" } { incr triesii }
807: incr gNewStudent_cnt($num.$ii)
808: }
809: set gStudent_try($num.$valid_cnt.$ii) $triesii
810: incr gTotal_try($num.$ii) $triesii
811: incr gStudent_cnt($num.$ii.$triesii)
812: }
813: incr gTotal_scores($num) $score
814: set gEntry($num.$valid_cnt) "$aline"
815: set gScore($num.$valid_cnt) $score
816: incr valid_cnt
817: }
818: }
819: }
820: set aline [gets $fileId]
821: }
822: close $fileId
823: set Q_cnt [llength $tries]
824: set L_cnt $valid_cnt
825: return
826: }
827:
828: ###########################################################
829: # CTpercentageScores
830: ###########################################################
831: ###########################################################
832: ###########################################################
833: proc CTpercentageScores { num setId valid_cnt } {
834: global gTotal_weight gTotal_scores
835:
836: if { $gTotal_weight($num) > 0 } {
837: set ratio [expr double($gTotal_scores($num)) / double($gTotal_weight($num))]
838: set ratio [expr $ratio * 100.0 ]
839: CTputs $num "\nScore (total scores / total valid weights) for set$setId.db: [format %7.2f%% $ratio]\n"
840: }
841: CTputs $num "The number of valid records for set$setId.db is: $valid_cnt\n"
842: }
843:
844: ###########################################################
845: # CTaverage
846: ###########################################################
847: ###########################################################
848: ###########################################################
849: proc CTaverage { num q_cnt l_cnt faillistVar dodifflistVar numyesVar} {
850: upvar $faillistVar faillist $dodifflistVar dodifflist $numyesVar numyes
851: global gMaxTries gStudent_cnt gStudent_try gTotal_try gYes_cnt gyes_cnt \
852: gNewStudent_cnt
853:
854: set maxIter [expr $q_cnt * 4]
855:
856: for { set ii 0 } { $ii < $q_cnt } { incr ii } {
857: updateStatusBar [expr $ii/double($maxIter)] $num
858: set s_cnt($ii) 0
859: set avg($ii) 0.0
860: set max_try($ii) 0
861: for { set jj 1 } { $jj < $gMaxTries } { incr jj } {
862: if { $gStudent_cnt($num.$ii.$jj) > 0 } {
863: set avg($ii) [expr $avg($ii) + ($jj * $gStudent_cnt($num.$ii.$jj))]
864: incr s_cnt($ii) $gStudent_cnt($num.$ii.$jj)
865: }
866: }
867: set s_cnt($ii) $gNewStudent_cnt($num.$ii)
868: if { $s_cnt($ii) > 0 } { set avg($ii) [expr $avg($ii) / $s_cnt($ii)] }
869: }
870:
871: for { set ii 0 } { $ii < $q_cnt } { incr ii } {
872: updateStatusBar [expr ($ii+$q_cnt)/double($maxIter)] $num
873: set sd($ii) 0.0
874: set sum 0.0
875: for { set jj 0 } { $jj < $l_cnt } { incr jj } {
876: if { $gStudent_try($num.$jj.$ii) > $max_try($ii) } {
877: set max_try($ii) $gStudent_try($num.$jj.$ii)
878: }
879: if { $gStudent_try($num.$jj.$ii) > 0 } {
880: set sq [expr ( $gStudent_try($num.$jj.$ii) - $avg($ii) ) * \
881: ( $gStudent_try($num.$jj.$ii) - $avg($ii)) ]
882: set sum [expr $sum + $sq]
883: }
884: if { $s_cnt($ii) > 1 } {
885: set sd($ii) [expr $sum / ( $s_cnt($ii) - 1.0 )]
886: }
887: if { $sd($ii) > 0 } { set sd($ii) [ expr sqrt($sd($ii)) ] }
888: }
889: }
890:
891: for { set ii 0 } { $ii < $q_cnt } { incr ii } {
892: updateStatusBar [expr ($ii+(2*$q_cnt))/double($maxIter)] $num
893: set sd3($ii) 0.0
894: set sum 0.0
895: for { set jj 0 } { $jj < $l_cnt } { incr jj } {
896: if { $gStudent_try($num.$jj.$ii) > 0 } {
897: set tmp1 [expr $gStudent_try($num.$jj.$ii) - $avg($ii)]
898: set tmp2 [expr $tmp1 * $tmp1 * $tmp1]
899: set sum [expr $sum + $tmp2]
900: }
901: if { ( $s_cnt($ii) > 0 ) && ( $sd($ii) != 0.0 ) } {
902: set sd3($ii) [expr $sum / $s_cnt($ii) ]
903: set sd3($ii) [expr $sd3($ii) / ($sd($ii) * $sd($ii) * $sd($ii)) ]
904: }
905: }
906: }
907: CTputs $num "This is the statistics for each problem: \n"
908: CTputs $num "Prob\# MxTries avg. s.d. s.k. \#Stdnts"
909: CTputs $num " \#Yes \#yes Tries DoDiff %Wrong\n"
910: set numyes [set dodifflist [set faillist ""]]
911: # parray s_cnt
912: for { set ii 0 } { $ii < $q_cnt } { incr ii } {
913: updateStatusBar [expr ($ii+(3*$q_cnt))/double($maxIter)] $num
914: if { $gTotal_try($num.$ii) > 0 } {
915: set dod [expr $gTotal_try($num.$ii)/(0.1 + $gYes_cnt($num.$ii) \
916: + $gyes_cnt($num.$ii))]
917: } else {
918: set dod 0.0
919: }
920: if {[catch {set success [expr 100.0*($s_cnt($ii)-($gYes_cnt($num.$ii)+ \
921: $gyes_cnt($num.$ii)))/$s_cnt($ii)]}]} {
922: set success 0.0
923: set s_cnt($ii) 0
924: }
925: CTputs $num [format "P %2d" [expr int($ii + 1)] ]
926: CTputs $num [format "%6d %8.2f %7.2f %6.2f %5d %5d %5d %5d %5.1f %6.2f\n"\
927: $max_try($ii) $avg($ii) $sd($ii) $sd3($ii) $s_cnt($ii) \
928: $gYes_cnt($num.$ii) $gyes_cnt($num.$ii) \
929: $gTotal_try($num.$ii) $dod $success]
930: if { $success < 0 } { set success 0 }
931: lappend faillist [list $success [expr int($ii + 1)]]
932: lappend dodifflist [list $dod [expr int($ii + 1)]]
933: lappend numyes [list [expr $gYes_cnt($num.$ii)+$gyes_cnt($num.$ii)] \
934: [expr int($ii + 1)]]
935: }
936: }
937:
938: ###########################################################
939: # CTlogAnalysis2
940: ###########################################################
941: ###########################################################
942: ###########################################################
943: proc CTlogAnalysis2 { num cmdnum setId } {
944: global gFile
945: set logFile [file join $gFile($num) records "log$setId.db"]
946: if { [file exists $logFile] } {
947: CTputs $cmdnum "Log analysis for telnet session log$setId.db\n"
1.3 albertel 948: CTscanLogDB $cmdnum $logFile l(Y) l(N) l(S) l(U) l(u) l(A) l(F)
1.1 albertel 949: } else {
1.3 albertel 950: set l(Y) [set l(N) [set l(S) [set l(U) [set l(u) [set l(A) [set l(F) 0]]]]]]
1.1 albertel 951: }
952: set webLogFile [file join $gFile($num) records "weblog$setId.db" ]
953: if { [file exists $webLogFile] } {
954: CTputs $cmdnum "===============================================\n"
955: CTputs $cmdnum "Log analysis for web session weblog$setId.db\n"
1.3 albertel 956: CTscanLogDB $cmdnum $webLogFile w(Y) w(N) w(S) w(U) w(u) w(A) w(F)
1.1 albertel 957: } else {
1.3 albertel 958: set w(Y) [set w(N) [set w(S) [set w(U) [set w(u) [set w(A) [set w(F) 0]]]]]]
1.1 albertel 959: }
1.3 albertel 960: set telnet_total [expr $l(Y)+$l(N)+$l(S)+$l(U)+$l(u)+$l(A)+$l(F)]
961: set web_total [expr $w(Y)+$w(N)+$w(S)+$w(U)+$w(u)+$w(A)+$w(F)]
1.1 albertel 962: CTputs $cmdnum "============== SUMMARY ====================\n"
1.3 albertel 963: CTputs $cmdnum " #Y #N #S #U #u #A #F Total\n"
964: CTputs $cmdnum [format "telnet: %6d %6d %6d %6d %6d %6d %6d %6d\n" \
965: $l(Y) $l(N) $l(S) $l(U) $l(u) $l(A) $l(F) $telnet_total ]
966: CTputs $cmdnum [format " web: %6d %6d %6d %6d %6d %6d %6d %6d\n" \
967: $w(Y) $w(N) $w(S) $w(U) $w(u) $w(A) $w(F) $web_total]
968: foreach v { Y N S U u A F} {
1.1 albertel 969: set sum($v) [expr $l($v) + $w($v)]
970: if { $sum($v) > 0 } {
971: set ratio($v) [expr 100.0*$w($v)/double($sum($v))]
972: } else {
973: set ratio($v) 0.0
974: }
975: }
976: set overall_entries [expr $telnet_total + $web_total]
977: if { $overall_entries > 0 } {
978: set ratio(web) [expr 100.0*(double($web_total)/double($overall_entries))]
979: } else {
980: set ratio(web) 0.0
981: }
1.3 albertel 982: CTputs $cmdnum [format " %%web: % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f\n" \
983: $ratio(Y) $ratio(N) $ratio(S) $ratio(U) $ratio(u) $ratio(A) $ratio(F) $ratio(web) ]
1.1 albertel 984: }
985:
986:
987: ###########################################################
988: # CTscanLogDB
989: ###########################################################
990: ###########################################################
991: ###########################################################
1.3 albertel 992: proc CTscanLogDB { num file Y_lVar N_lVar S_lVar U_lVar u_lVar A_lVar F_lVar } {
1.1 albertel 993: upvar $Y_lVar Y_l
994: upvar $N_lVar N_l
995: upvar $S_lVar S_l
996: upvar $U_lVar U_l
997: upvar $u_lVar u_l
1.3 albertel 998: upvar $A_lVar A_l
999: upvar $F_lVar F_l
1.1 albertel 1000:
1001: set line_cnt 0
1002:
1003: displayStatus "Analyzing [file tail $file]" both $num
1004: set maxLine [lindex [exec wc $file] 0]
1005: set fileId [open $file "r"]
1006:
1007: set aline [gets $fileId]
1008: while { ! [eof $fileId] } {
1009: incr line_cnt
1010: if { ($line_cnt%20) == 0 } {
1011: updateStatusBar [expr $line_cnt/double($maxLine)] $num
1012: }
1013: set aline [string trim $aline]
1014: set ans_str [string range $aline 35 end]
1015: set ans_char [split $ans_str {}]
1016: if { ! [info exists count] } {
1017: for { set i 0 } { $i < [llength $ans_char] } { incr i } {
1018: set count(Y.$i) 0; set count(N.$i) 0; set count(S.$i) 0
1.3 albertel 1019: set count(U.$i) 0; set count(u.$i) 0; set count(A.$i) 0
1020: set count(F.$i) 0
1.1 albertel 1021: }
1022: set count(Y.total) 0; set count(N.total) 0; set count(S.total) 0
1.3 albertel 1023: set count(U.total) 0; set count(u.total) 0; set count(A.total) 0
1024: set count(F.total) 0
1.1 albertel 1025: }
1026: set i -1
1027: foreach char $ans_char {
1028: incr i
1029: if { $char == "-" } { continue }
1030: if { [catch {incr count($char.$i)}] } {
1031: set count(Y.$i) 0; set count(N.$i) 0; set count(S.$i) 0
1.3 albertel 1032: set count(U.$i) 0; set count(u.$i) 0; set count(A.$i) 0
1033: set count(F.$i) 0
1.1 albertel 1034: incr count($char.$i)
1035: }
1036: incr count($char.total)
1037: }
1038: set aline [gets $fileId]
1039: }
1040: close $fileId
1041: removeStatus $num
1.3 albertel 1042: CTputs $num "Prob #: #Y #N #S #U #u #A #F\n"
1.1 albertel 1043: for { set i 0 } { $i < [llength $ans_char] } { incr i } {
1.3 albertel 1044: CTputs $num [format " %2d: %6d %6d %6d %6d %6d %6d %6d\n" [expr $i + 1] \
1045: $count(Y.$i) $count(N.$i) $count(S.$i) $count(U.$i) $count(u.$i) \
1046: $count(A.$i) $count(F.$i) ]
1.1 albertel 1047: }
1048: CTputs $num "===========================================\n"
1.3 albertel 1049: CTputs $num [format " Total: %6d %6d %6d %6d %6d %6d %6d\n" $count(Y.total) \
1050: $count(N.total) $count(S.total) $count(U.total) $count(u.total) \
1051: $count(A.total) $count(F.total) ]
1.1 albertel 1052: set Y_l $count(Y.total)
1053: set N_l $count(N.total)
1054: set S_l $count(S.total)
1055: set U_l $count(U.total)
1056: set u_l $count(u.total)
1.3 albertel 1057: set A_l $count(A.total)
1058: set F_l $count(F.total)
1.1 albertel 1059: return
1060: }
1061:
1062: ###########################################################
1063: # CTcollectSetScores
1064: ###########################################################
1065: ###########################################################
1066: ###########################################################
1067: proc CTcollectSetScores { num path id on_screen limit } {
1068: set id [ string toupper $id ]
1069: set total_scores 0
1070: set total_weights 0
1071: set set_idx 0
1072: set done 0
1073: while { ! $done } {
1074: incr set_idx
1075: if { $set_idx > $limit } { set done 1; continue }
1076: updateStatusBar [expr $set_idx/double($limit)] $num
1077: set filename [file join $path records "set$set_idx.db"]
1078: if { ![file readable $filename ] } { continue }
1079: set fileId [open $filename "r"]
1080: set line_cnt 0
1081: set found 0
1082: set aline [ gets $fileId ]
1083: while { ! [eof $fileId] && ! $found } {
1084: incr line_cnt
1085: if { $line_cnt > 3 } {
1086: set aline [string trim $aline]
1087: set prefix [lindex [split $aline ","] 0]
1088: set s_num [string toupper [lindex [split $aline " "] 0] ]
1089: set ans_str [lindex [split $prefix " "] 1]
1090: if { $id == $s_num } {
1091: set ans_char [split $ans_str {} ]
1092: set valid 0
1093: foreach char $ans_char { if { $char != "-" } { set valid 1; break } }
1094: if { ! $valid } {
1095: set score "-"
1096: } else {
1097: set score 0
1098: for {set i 0} { $i < [llength $ans_char] } { incr i } {
1099: set char [lindex $ans_char $i]
1100: if { $char == "N" || $char == "n"} { set found 1 }
1101: if { $char == "Y" || $char == "y"} {
1.11 albertel 1102: catch {incr score [lindex $weights $i]}
1103: set found 1
1.1 albertel 1104: }
1105: if { $char >= 0 && $char <= 9 } {
1106: incr score $char;set found 1
1107: }
1108: if { $char == "E" } {
1.11 albertel 1109: catch {incr valid_weights "-[lindex $weights $i]"}
1.1 albertel 1110: }
1111: }
1112: incr total_scores $score
1113: }
1114: }
1115: } elseif { $line_cnt == 2 } {
1116: set aline [string trim $aline]
1117: set weights [split $aline {} ]
1118: set valid_weights 0
1119: foreach weight $weights { incr valid_weights $weight }
1120: } else {
1121: #do nothing for line 1 and 3
1122: }
1123: set aline [ gets $fileId ]
1124: }
1125: close $fileId
1126: incr total_weights $valid_weights
1127: set set_weights([expr $set_idx - 1]) $valid_weights
1128: if { $found } {
1129: set set_scores([expr $set_idx - 1]) $score
1130: } else {
1131: set set_scores([expr $set_idx - 1]) "-"
1132: }
1133: }
1134: set abscent_cnt 0
1135: set present_cnt 0
1136: set summary_str ""
1137: if { $on_screen } { CTputs $num " " }
1138: foreach i [lsort -integer [array names set_scores]] {
1139: if { $set_scores($i) == "-" || $set_scores($i) == "" } {
1140: if { $on_screen } { CTputs $num " - " }
1141: append summary_str "x/$set_weights($i) "
1142: incr abscent_cnt
1143: } else {
1144: if { $on_screen } { CTputs $num [format " %3d" $set_scores($i)] }
1145: append summary_str "$set_scores($i)/$set_weights($i) "
1146: incr present_cnt
1147: }
1148: }
1149: if { $on_screen } {
1150: CTputs $num "\n [file tail $path]:"
1151: foreach i [lsort -integer [array names set_scores]] { CTputs $num " ---" }
1152: CTputs $num "\n "
1153: if { [info exists set_weights] } {
1154: set num_set_weights [llength [array names set_weights]]
1155: } else {
1156: set num_set_weights 0
1157: }
1158: for {set i 0} {$i < $num_set_weights} {incr i} {
1159: if { [info exists set_weights($i)] } {
1160: CTputs $num [format " %3d" $set_weights($i)]
1161: } else {
1162: set num_set_weights $i
1163: }
1164: }
1165: CTputs $num "\n"
1166: if { $total_weights != 0 } {
1167: set ratio [expr 100.0 * $total_scores / double($total_weights) ]
1168: CTputs $num [format " %5d\n" $total_scores]
1169: if { [info exists set_scores] } {
1170: CTputs $num [format " ------- = %3.2f%%, scores absent in %d/%d\n" \
1171: $ratio $abscent_cnt [llength [array names set_scores]]]
1172: } else {
1173: CTputs $num [format " ------- = %3.2f%%, scores absent in %d/%d\n" \
1174: $ratio $abscent_cnt 0 ]
1175: }
1176: } else {
1177: set ratio "-"
1178: CTputs $num [format " %5d\n" $total_scores]
1179: if { [info exists set_scores] } {
1180: CTputs $num [format " ------- = %s%%, scores absent in %d/%d\n" \
1181: $ratio $abscent_cnt [llength [array names set_scores]]]
1182: } else {
1183: CTputs $num [format " ------- = %s%%, scores absent in %d/%d\n" \
1184: $ratio $abscent_cnt 0 ]
1185: }
1186: }
1187:
1188: CTputs $num [format " %5d\n" $total_weights]
1189: }
1190: return [list $total_scores $total_weights $abscent_cnt \
1191: [llength [array names set_scores] ] $summary_str]
1192: }
1193:
1194: ###########################################################
1195: # CTloginAnalysis
1196: ###########################################################
1197: ###########################################################
1198: ###########################################################
1199: proc CTloginAnalysis { num path id limit } {
1200:
1201: CTputs $num "Login analysis: telnet session web session\n\n"
1202: CTputs $num " set #: #Y #N #S #U #u #Y #N #S #U #u\n"
1203: set set_idx 0
1204: set done 0
1205: while { ! $done } {
1206: incr set_idx
1207: if { $set_idx > $limit } { set done 1; continue }
1208: CTputs $num [format " %2d: " $set_idx]
1209: set filename [file join $path records "log$set_idx.db"]
1210: updateStatusMessage "Analyzing [file tail $filename]" $num
1211: updateStatusBar 0.0 $num
1212: if { [file readable $filename] } {
1213: set result [CTstudentLoginData $num $filename $id]
1214: CTputs $num [eval format \"%4d %4d %4d %4d %4d\" $result]
1215: set no_log 0
1216: } else {
1217: CTputs $num "========================"
1218: set no_log 1
1219: }
1220: CTputs $num " "
1221: set filename [file join $path records "weblog$set_idx.db"]
1222: updateStatusMessage "Analyzing [file tail $filename]" $num
1223: updateStatusBar 0.0 $num
1224: if { [file readable $filename] } {
1225: set result [CTstudentLoginData $num $filename $id]
1226: CTputs $num [eval format \"%4d %4d %4d %4d %4d\" $result]
1227: set no_weblog 0
1228: } else {
1229: CTputs $num "========================"
1230: set no_weblog 1
1231: }
1232: CTputs $num "\n"
1233: if { $no_log && $no_weblog } { set done 1 }
1234: }
1235: }
1236:
1237: ###########################################################
1238: # CTstudentSetAnalysis
1239: ###########################################################
1240: ###########################################################
1241: ###########################################################
1242: proc CTstudentSetAnalysis { num path id limit } {
1243: set set_idx 0
1244: set id [string toupper $id]
1245: CTputs $num " set \#:\n"
1246: set done 0
1247: while { ! $done } {
1248: incr set_idx
1249: if { $set_idx > $limit } { set done 1; continue }
1250: set filename [file join $path records "set$set_idx.db"]
1251: updateStatusMessage "Analyzing [file tail $filename]" $num
1252: if { ![file readable $filename] } { continue }
1253: CTputs $num [format " %2d: " $set_idx]
1254: set fileId [open $filename "r"]
1255: set line_cnt 0
1256: set found 0
1257: set aline [gets $fileId]
1258: while { ! [eof $fileId] && !$found } {
1259: incr line_cnt
1260: if { $line_cnt > 3 } {
1261: set aline [string trim $aline]
1262: set s_id [string toupper [string range $aline 0 8]]
1263: if {$id == $s_id} {
1264: set found 1
1265: set breakpt [string first "," $aline]
1266: set data [list [string range $aline 10 [expr $breakpt - 1] ] \
1267: [string range $aline [expr $breakpt + 1] end ] ]
1268: CTputs $num "[lindex $data 0]\n [lindex $data 1]\n"
1269: }
1270: }
1271: set aline [gets $fileId]
1272: }
1273: close $fileId
1274: if { ! $found } { CTputs $num "\n\n" }
1275: }
1276: }
1277:
1278: ###########################################################
1279: # CTstudentLoginData
1280: ###########################################################
1281: ###########################################################
1282: ###########################################################
1283: proc CTstudentLoginData { num filename id } {
1284:
1285: set Y_total 0
1286: set N_total 0
1287: set U_total 0
1288: set u_total 0
1289: set S_total 0
1290: set maxLine [expr double([lindex [exec wc $filename] 0])]
1291: set line_cnt 0
1292: set fileId [open $filename "r"]
1293: set aline [gets $fileId]
1294: while { ![eof $fileId] } {
1295: incr line_cnt
1296: if { $line_cnt%300 == 0 } {
1297: updateStatusBar [expr $line_cnt/$maxLine] $num
1298: }
1299: set aline [string trim $aline]
1300: set s_id [string toupper [string range $aline 0 8]]
1301: set id [string toupper $id]
1302: if {$id == $s_id} {
1303: set ans_char [split [string range $aline 35 end] {} ]
1304: for {set i 0} {$i< [llength $ans_char]} {incr i} {
1305: if {[lindex $ans_char $i] == "Y"} { incr Y_total
1306: } elseif {[lindex $ans_char $i] == "N"} { incr N_total
1307: } elseif {[lindex $ans_char $i] == "U"} { incr U_total
1308: } elseif {[lindex $ans_char $i] == "u"} { incr u_total
1309: } elseif {[lindex $ans_char $i] == "S"} { incr S_total }
1310: }
1311: }
1312: set aline [gets $fileId]
1313: }
1314: close $fileId
1315: return [list $Y_total $N_total $S_total $U_total $u_total]
1316: }
1317:
1318: ###########################################################
1319: # CTrunCommand
1320: ###########################################################
1321: ###########################################################
1322: ###########################################################
1323: proc CTrunCommand { num cmdnum fileId {followup "" }} {
1324: global gCT
1325:
1326: set data [read $fileId]
1327: updateStatusSpinner $cmdnum
1328: if { $data != "" } {
1329: CTputs $cmdnum $data
1330: }
1331: if { [eof $fileId] } {
1332: fileevent $fileId readable ""
1333: catch {close $fileId}
1334: if { $followup == "" } {
1335: CToutput $num $cmdnum
1336: removeStatus $cmdnum
1337: unset gCT(cmd.$cmdnum)
1338: } else {
1339: eval $followup
1340: }
1341: }
1342: }
1343:
1344: ###########################################################
1345: # CTitemAnalysisRange
1346: ###########################################################
1347: ###########################################################
1348: ###########################################################
1.9 albertel 1349: proc CTitemAnalysisRange { num classpath sets } {
1350: foreach i $sets {
1.1 albertel 1351: if { [ catch { CTitemAnalysis $num $classpath $i } errors ] } {
1352: displayError $errors
1353: }
1354: }
1355: }
1356:
1357: ###########################################################
1358: # CTitemAnalysis
1359: ###########################################################
1360: ###########################################################
1361: ###########################################################
1362: proc CTitemAnalysis { num classpath setId } {
1363: global gMaxSet
1364: set done 0
1365:
1366: set total_scores 0
1367: set total_weights 0
1368: set upper_percent 0.0
1369: set lower_percent 0.0
1370:
1371: set Y_total 0
1372: set N_total 0
1373: for { set ii 0} { $ii<$gMaxSet } {incr ii} {
1374: set Y_cnt($ii) 0
1375: set N_cnt($ii) 0
1376: set Ycnt_upper($ii) 0.0
1377: set Ycnt_lower($ii) 0.0
1378: }
1379:
1380: set filename [file join $classpath records "set$setId.db"]
1381: if { ! [file readable $filename] } {
1382: CTputs $num "FILE: $filename does not exist!\n"
1383: return
1384: }
1385:
1386: displayStatus "Analyzing [file tail $filename]" both $num
1387: set maxLine [lindex [exec wc $filename] 0]
1388:
1389: set fileId [open "$filename" "r"]
1390: set valid_cnt 0
1391: set line_cnt 0
1392: set ans_char ""
1393: set aline [gets $fileId]
1394: while {![eof $fileId]} {
1395: incr line_cnt
1396: if { ($line_cnt%20) == 0 } {
1397: updateStatusBar [expr $line_cnt/double($maxLine)] $num
1398: }
1399: if { $line_cnt == 2 } {
1400: set aline [string trim $aline]
1401: set weights [split $aline {}]
1402: # set valid_weights 0
1403: # for { set ii 0 } { $ii < [llength $weights] } { incr ii } {
1404: # incr valid_weights [lindex $weights $ii]
1405: # }
1406: } elseif { $line_cnt > 3} {
1407: set aline [string trim $aline]
1408: set prefix [lindex [split $aline ","] 0]
1409: set s_num [string toupper [lindex [split $aline " " ] 0 ] ]
1410: set ans_str [lindex [split $prefix " "] 1]
1411: set ans_char [split $ans_str {} ]
1412: set valid 0
1413: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1414: if { [lindex $ans_char $ii] != "-"} { set valid 1 }
1415: }
1416: if { $valid } {
1417: incr valid_cnt
1418: set score 0
1419: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1.9 albertel 1420: #Can't use incr because the numbers might be doubles
1.1 albertel 1421: if { [lindex $ans_char $ii] == "Y" || \
1422: [lindex $ans_char $ii] == "y" } {
1.9 albertel 1423: catch {incr score [lindex $weights $ii]}
1424: set Y_cnt($ii) [expr {$Y_cnt($ii) + 1}]
1425: set Y_total [expr {$Y_total + 1}]
1.1 albertel 1426: }
1427: if { [lindex $ans_char $ii] == "N" || \
1428: [lindex $ans_char $ii] == "n" } {
1.9 albertel 1429: set N_cnt($ii) [expr {$N_cnt($ii) + 1}]
1430: set N_total [expr {$N_total + 1}]
1.1 albertel 1431: }
1432: if { [lindex $ans_char $ii] >= 0 && \
1433: [lindex $ans_char $ii] <= 9 } {
1434: incr score [lindex $ans_char $ii]
1.9 albertel 1435: if {[catch {set yes_part [expr [lindex $ans_char $ii] / \
1436: double([lindex $weights $ii])]}]} {
1437: set yes_part 1
1438: }
1.1 albertel 1439: set no_part [expr 1.0 - $yes_part]
1440: set Y_cnt($ii) [expr $Y_cnt($ii) + $yes_part]
1441: set Y_total [expr $Y_total + $yes_part]
1442: set N_cnt($ii) [expr $N_cnt($ii) + $no_part]
1443: set N_total [expr $N_total + $no_part]
1444: }
1445: # if { [lindex $ans_char $ii] == "E"} {
1446: # incr valid_weights -[lindex $weights $ii]
1447: # }
1448: }
1449: set s_db([format "%08d%s" $score $s_num]) $ans_str
1450: }
1451: }
1452: set aline [gets $fileId]
1453: }
1454: close $fileId
1455: removeStatus $num
1456: for { set ii 0 } { $ii < $gMaxSet } { incr ii } {
1457: set Ycnt_upper($ii) 0
1458: set Ycnt_lower($ii) 0
1459: }
1460: displayStatus "Pondering data . . ." spinner $num
1461: set upperpart_cnt [expr int(0.27 * double($valid_cnt))]
1462: set lowerpart_limit [expr $valid_cnt - $upperpart_cnt]
1463: set line_cnt 0
1464: foreach sort_key [lsort -decreasing [array names s_db]] {
1465: incr line_cnt
1466: if { ($line_cnt%20) == 0 } { updateStatusSpinner $num }
1467: set ans_str $s_db($sort_key)
1468: set ans_char [split $ans_str {} ]
1469: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1470: if { [lindex $ans_char $ii] == "Y" || \
1471: [lindex $ans_char $ii] == "y" || \
1472: [lindex $ans_char $ii] == [lindex $weights $ii] } {
1473: if { $line_cnt <= $upperpart_cnt } {
1474: incr Ycnt_upper($ii)
1475: } elseif { $line_cnt > $lowerpart_limit } {
1476: incr Ycnt_lower($ii)
1477: }
1478: }
1479: }
1480: }
1481: CTputs $num " There are $valid_cnt entries in file $filename\n"
1482: CTputs $num [format " The upper 27%% has %d records, the lower 27%% has %d records\n"\
1483: $upperpart_cnt [expr $valid_cnt - $lowerpart_limit] ]
1484: CTputs $num " question \# DoDiff. Disc. Factor (%upper - %lower) \[\#records,\#records\]\n";
1485:
1486: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1487: updateStatusSpinner $num
1488: set tmp_total [expr $N_cnt($ii) + $Y_cnt($ii)]
1489: if { $tmp_total > 0 } {
1490: set diff [expr 100.0*($N_cnt($ii) / double($N_cnt($ii) + $Y_cnt($ii)))]
1491: } else {
1492: set diff "-"
1493: }
1494: set upper_percent [expr 100.0 * ($Ycnt_upper($ii) /double($upperpart_cnt))]
1495: set lower_percent [expr 100.0 * ($Ycnt_lower($ii) /double($upperpart_cnt))]
1496: set disc [expr $upper_percent - $lower_percent]
1497: CTputs $num [format " %2d: " [expr $ii + 1]]
1498: CTputs $num [format "%6.1f %5.1f (%6.1f - %6.1f) \[%8d,%8d\]\n" \
1499: $diff $disc $upper_percent $lower_percent $Ycnt_upper($ii) \
1500: $Ycnt_lower($ii) ]
1501: }
1502: removeStatus $num
1503: }
1504:
1505: ###########################################################
1506: # CTitemCorrelation
1507: ###########################################################
1508: # INPUTS: class name with full path, set number
1509: #
1510: # r = \frac{\sum{x_i y_i} - \frac{(\sum x_i)(\sum y_i)}{n}}
1511: # {\sqrt{(\sum x_i^2 - \frac{}{}}}
1512: #
1513: # corr = (sum of prod_xy - (sum_x*sum_y / n) ) / sqrt( (sum of sqr_x - (sum_x*sum_x/n))*
1514: #
1515: ###########################################################
1516: ###########################################################
1517: proc CTitemCorrelation { num classpath setId } {
1518: global gMaxSet
1519:
1520: set filename [file join $classpath records "set$setId.db"]
1521: if { ! [file readable $filename] } {
1522: CTputs $num "FILE: $filename does not exist!\n"
1523: return
1524: }
1525:
1526: displayStatus "Analyzing [file tail $filename]" both $num
1527: set maxLine [lindex [exec wc $filename] 0]
1528:
1529: set initialized 0
1530: set question_cnt 0
1531: set fileId [open "$filename" "r"]
1532: set line_cnt 0
1533: set aline [gets $fileId]
1534: while {![eof $fileId]} {
1535: incr line_cnt
1536: if { ($line_cnt%20) == 0 } {
1537: updateStatusBar [expr {$line_cnt/double($maxLine)}] $num
1538: }
1539: if { $line_cnt == 2 } {
1.4 albertel 1540: set aline [string trimright $aline]
1.1 albertel 1541: set weights [split $aline {}]
1542: }
1543: if { $line_cnt > 3} {
1.4 albertel 1544: set aline [string trimright $aline]
1.1 albertel 1545: set data [string range $aline 10 end]
1546: set ans_str [lindex [split $data ","] 0]
1547: set ans_char_list [split $ans_str {} ]
1548: set try_str [string range $aline [expr {[string first "," $data] +1}] end ]
1549: set question_cnt [llength $ans_char_list]
1550: for { set ii 0 } { $ii < $question_cnt } { incr ii } {
1551: set ans_char($ii) [lindex $ans_char_list $ii]
1552: }
1553: if { $question_cnt > $initialized } {
1554: for {set ii 0} {$ii < [expr {$question_cnt - 1}]} {incr ii} {
1555: set start [expr {($initialized>($ii+1)) ? $initialized : ($ii+1)}]
1556: for { set jj $start } { $jj < $question_cnt } { incr jj } {
1557: set index_key "$ii.$jj"
1558: set prod_xy($index_key) 0.0
1559: set sum_x($index_key) 0
1560: set sum_y($index_key) 0
1561: set sum_x2($index_key) 0
1562: set sum_y2($index_key) 0
1563: set valid_cnt($index_key) 0
1564: }
1565: }
1566: set initialized $question_cnt
1567: }
1568: for { set ii 0 } { $ii < [expr {$question_cnt - 1}] } { incr ii } {
1569: for { set jj [expr {$ii+1}] } { $jj < $question_cnt } { incr jj } {
1570: set index_key "$ii.$jj"
1571: if { $ans_char($ii) != "-" && $ans_char($ii) != "E" && \
1572: $ans_char($jj) != "-" && $ans_char($jj) != "E" } {
1573: ## $ans_char($ii) is one of 0 .. 9, Y, y, N, n
1574: ## $ans_char($jj) is one of 0 .. 9, Y, y, N, n
1575: if { $ans_char($ii) == "Y" || $ans_char($ii) == "y" } {
1.11 albertel 1576: if {[set x_data [lindex $weights $ii]]==""} {set x_data 0}
1.1 albertel 1577: } elseif { $ans_char($ii) == "N" || $ans_char($ii) == "n" } {
1578: set x_data 0
1579: } else { ## must be in 0 .. 9
1580: set x_data $ans_char($ii)
1581: }
1582: if { $ans_char($jj) == "Y" || $ans_char($jj) == "y" } {
1.11 albertel 1583: if {[set y_data [lindex $weights $jj]]==""} {set y_data 0}
1.1 albertel 1584: } elseif { $ans_char($jj) == "N" || $ans_char($jj) == "n" } {
1585: set y_data 0
1586: } else { ## must be in 0 .. 9
1587: set y_data $ans_char($jj)
1588: }
1589: set prod_xy($index_key) [expr {$x_data * $y_data +
1590: $prod_xy($index_key)} ]
1591: incr sum_x($index_key) $x_data
1592: incr sum_y($index_key) $y_data
1593: incr sum_x2($index_key) [expr {$x_data * $x_data}]
1594: incr sum_y2($index_key) [expr {$y_data * $y_data}]
1595: incr valid_cnt($index_key) 1
1596: }
1597: }
1598: }
1599: }
1600: set aline [gets $fileId]
1601: }
1602: close $fileId
1603: removeStatus $num
1604: # print out the correlation matrix
1.4 albertel 1605: #parray sum_x
1606: #parray sum_y
1607: #parray prod_xy
1608: #puts $question_cnt
1.1 albertel 1609: CTputs $num " "
1610: for { set ii 1 } { $ii < $question_cnt } { incr ii } {
1611: CTputs $num [format " %2d" [expr {$ii+1}] ]
1612: }
1613: CTputs $num "\n"
1614: # --------------------------------------
1615: for { set ii 0 } { $ii < [expr {$question_cnt -1}] } { incr ii } {
1616: CTputs $num [format " %2d:" [expr {$ii+1}] ]
1617: for { set jj 0 } { $jj < $ii } { incr jj } { CTputs $num " " }
1618: for { set jj [expr {$ii+1}] } { $jj < $question_cnt } { incr jj } {
1619: set index_key "$ii.$jj"
1620: if { $valid_cnt($index_key) != "0" } {
1621: set upper_part [ expr { $prod_xy($index_key) -
1622: ( ($sum_x($index_key) * $sum_y($index_key))
1623: / double($valid_cnt($index_key)))}]
1624: set lower_part [expr {$sum_x2($index_key) -
1625: ($sum_x($index_key) * $sum_x($index_key)
1626: / double($valid_cnt($index_key)))} ]
1627: set lower_part [expr {$lower_part * ($sum_y2($index_key) -
1628: ($sum_y($index_key) *
1629: $sum_y($index_key)
1630: /double($valid_cnt($index_key))))}]
1631: set lower_part [expr {sqrt($lower_part)}]
1632: if { $lower_part != 0.0 } {
1633: set ratio [expr {$upper_part / double($lower_part)}]
1634: CTputs $num [format " % .2f" $ratio]
1635: } else {
1636: CTputs $num " INF "
1637: }
1638: } else {
1639: CTputs $num " ----"
1640: }
1641: }
1642: CTputs $num "\n"
1643: }
1644: }
1645:
1646: ###########################################################
1647: # CTsubmissionsLaunch
1648: ###########################################################
1649: ###########################################################
1650: ###########################################################
1.9 albertel 1651: proc CTsubmissionsLaunch { num cmdnum type s_id s_nm index setlist } {
1.1 albertel 1652: global gCT gFile gUniqueNumber gCapaConfig
1653:
1.9 albertel 1654: set curset [lindex $setlist $index]
1655: CTputs $cmdnum "$type submissions for $s_nm for set $curset\n"
1.1 albertel 1656: if { $type == "telnet" } {
1.9 albertel 1657: set command "grep -i $s_id [file join $gFile($num) records submissions$curset.db]"
1.1 albertel 1658: set followtype web
1659: } else {
1660: set command "grep -i $s_id [file join $gFile($num) \
1.9 albertel 1661: records websubmissions$curset.db]"
1.1 albertel 1662: set followtype telnet
1.9 albertel 1663: incr index
1.1 albertel 1664: }
1665: set done 0
1666: set followcmd ""
1.9 albertel 1667: while { !$done && ($index <= [llength $setlist]) } {
1668: if { [lindex $setlist $index] != "" } {
1.1 albertel 1669: set followcmd "CTsubmissionsLaunch $num $cmdnum $followtype $s_id {$s_nm} \
1.9 albertel 1670: $index \"$setlist\""
1.1 albertel 1671: }
1.9 albertel 1672: if { ![catch {set fileId [open "|$command" "r"]} error ] } { set done 1 }
1.1 albertel 1673: }
1674: fconfigure $fileId -blocking 0
1675: fileevent $fileId readable "CTrunCommand $num $cmdnum $fileId {$followcmd}"
1676: }
1677:
1678: ###########################################################
1679: # CTreportDist
1680: ###########################################################
1681: ###########################################################
1682: ###########################################################
1683: proc CTreportDist { num file percentage sectionlist } {
1684: set fileId [open $file "r"]
1685: set aline [gets $fileId]
1686: set which [expr [llength [split $aline "\t"]] - 2]
1687: set maximum [lindex [lrange [split $aline "\t"] $which end] 1]
1688: if { $percentage } {
1689: for {set i 0} {$i<=100} {incr i} {
1690: set totals($i.score) 0
1691: set totals($i.stunum) ""
1692: }
1693: } else {
1694: for { set i 0 } { $i <= $maximum } { incr i } {
1695: set totals($i.score) 0
1696: set totals($i.stunum) ""
1697: }
1698: }
1699: while { ![eof $fileId]} {
1700: set temp [lrange [split $aline "\t"] $which end]
1701: set score [lindex $temp 0]
1702: regsub -- "-" $score "0" score
1703: set max [lindex $temp 1]
1704: set temp [lindex [split $aline "\t"] 1]
1705: set section [lindex $temp 1]
1706: set stunum [lindex $temp 0]
1707: if { ([lsearch $sectionlist $section] != -1) && ($max!=0) } {
1708: if { $percentage } {
1709: set percent [expr int($score/double($max)*100)]
1710: incr totals($percent.score)
1711: lappend totals($percent.stunum) $stunum
1712: } else {
1713: if { $max > $maximum } {
1714: for {set i [expr $maximum+1]} {$i<=$max} {incr i} {set totals($i) 0}
1715: set maximum $max
1716: }
1717: set score [string trim $score]
1718: incr totals($score.score)
1719: lappend totals($score.stunum) $stunum
1720: }
1721: }
1722: set aline [gets $fileId]
1723: }
1.12 ! albertel 1724: CTputs $num "Scores #achieved\n"
1.1 albertel 1725: set scorelist ""
1726: set templist [array names totals *.score]
1727: foreach temp $templist {lappend possiblescores [lindex [split $temp .] 0]}
1728: foreach score [lsort -integer $possiblescores] {
1729: CTputs $num [format "%5d:%6d\n" $score $totals($score.score)]
1730: lappend scorelist [list $totals($score.score) $score $totals($score.stunum)]
1731: }
1732: return $scorelist
1733: }
1734:
1735: ###########################################################
1736: # CTgradeDistribution
1737: ###########################################################
1738: ###########################################################
1739: ###########################################################
1740: proc CTgradeDistribution { num classpath setId } {
1741: set filename [file join $classpath records "set$setId.db"]
1742: if { ! [file readable $filename] } {
1743: CTputs $num "FILE: $filename does not exist!\n"
1744: return
1745: }
1746:
1747: displayStatus "Analyzing [file tail $filename]" both $num
1748: set maxLine [lindex [exec wc $filename] 0]
1749: set fileId [open "$filename" "r"]
1750: set valid_cnt 0
1751: set line_cnt 0
1752: set aline [gets $fileId]
1753: while {![eof $fileId]} {
1754: incr line_cnt
1755: if { ($line_cnt%20) == 0 } {
1756: updateStatusBar [expr $line_cnt/double($maxLine)] $num
1757: }
1758: if { $line_cnt == 2 } {
1759: set aline [string trim $aline]
1760: set weights [split $aline {}]
1761: set valid_weights 0
1762: foreach weight $weights { incr valid_weights $weight }
1763: for { set i 0 } { $i <= $valid_weights } { incr i } {
1764: set total_score($i) 0
1765: }
1766: } elseif { $line_cnt > 3} {
1767: set aline [string trim $aline]
1768: set prefix [lindex [split $aline ","] 0]
1769: set s_num [string toupper [lindex [split $aline " " ] 0 ] ]
1770: set ans_str [lindex [split $prefix " "] 1]
1771: set ans_char [split $ans_str {} ]
1772: set valid 0
1773: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1774: if { [lindex $ans_char $ii] != "-"} { set valid 1 }
1775: }
1776: if { $valid } {
1777: incr valid_cnt
1778: set score 0
1779: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1780: if { [lindex $ans_char $ii] == "Y" || \
1781: [lindex $ans_char $ii] == "y" } {
1782: incr score [lindex $weights $ii]
1783: }
1784: if { [lindex $ans_char $ii] >= 0 && \
1785: [lindex $ans_char $ii] <= 9 } {
1786: incr score [lindex $ans_char $ii]
1787: }
1788: }
1789: if { [catch {incr total_score($score)} ] } {
1790: puts "$aline:$prefix:$s_num:$ans_str:$ans_char"
1791: }
1792:
1793: }
1794: }
1795: set aline [gets $fileId]
1796: }
1797: close $fileId
1798: removeStatus $num
1799: displayStatus "Pondering data . . ." spinner $num
1800: CTputs $num " There are $valid_cnt entries in file $filename\n"
1.12 ! albertel 1801: CTputs $num "Score #achieved\n"
1.1 albertel 1802: set scorelist ""
1803: foreach score [lsort -integer [array names total_score]] {
1804: CTputs $num [format "%5d:%6d\n" $score $total_score($score)]
1805: lappend scorelist [list $total_score($score) $score]
1806: }
1807: removeStatus $num
1808: return $scorelist
1809: }
1810:
1811: ###########################################################
1812: # CTgetStudentScores
1813: ###########################################################
1814: ###########################################################
1815: ###########################################################
1816: proc CTgetStudentScores { studentScoresVar classpath setId num } {
1817: upvar $studentScoresVar studentScores
1818:
1819: set filename [file join $classpath records "set$setId.db"]
1820: if { ! [file readable $filename] } {
1821: CTputs $num "FILE: $filename does not exist!\n"
1822: error
1823: }
1824:
1825: displayStatus "Analyzing [file tail $filename]" both $num
1826: set maxLine [lindex [exec wc $filename] 0]
1827: set fileId [open "$filename" "r"]
1828: set valid_cnt 0
1829: set line_cnt 0
1830: set aline [gets $fileId]
1831: set aline [gets $fileId]
1832: set weights [split [string trim $aline] {}]
1833: set valid_weights 0
1834: foreach weight $weights { incr valid_weights $weight }
1835: set aline [gets $fileId]
1836: set aline [gets $fileId]
1837: while {![eof $fileId]} {
1838: incr line_cnt
1839: if { ($line_cnt%20) == 0 } {
1840: updateStatusBar [expr $line_cnt/double($maxLine)] $num
1841: }
1842: set aline [string trim $aline]
1843: set prefix [lindex [split $aline ","] 0]
1844: set s_num [string toupper [lindex [split $aline " " ] 0 ] ]
1845: set ans_str [lindex [split $prefix " "] 1]
1846: set ans_char [split $ans_str {} ]
1847: set valid 0
1848: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1849: if { [lindex $ans_char $ii] != "-"} { set valid 1 }
1850: }
1851: if { $valid } {
1852: incr valid_cnt
1853: if {[array names studentScores $s_num] == ""} {set studentScores($s_num) 0}
1854: for { set ii 0 } { $ii < [llength $ans_char] } { incr ii } {
1855: if { [lindex $ans_char $ii] == "Y" || [lindex $ans_char $ii] == "y" } {
1856: incr studentScores($s_num) [lindex $weights $ii]
1857: }
1858: if { [lindex $ans_char $ii] >= 0 && [lindex $ans_char $ii] <= 9 } {
1859: incr studentScores($s_num) [lindex $ans_char $ii]
1860: }
1861: }
1862: }
1863: set aline [gets $fileId]
1864: }
1865: close $fileId
1866: removeStatus $num
1867: return $valid_weights
1868: }
1869:
1870: ###########################################################
1871: # CTgradeDistributionRange
1872: ###########################################################
1873: ###########################################################
1874: ###########################################################
1875: proc CTgradeDistributionRange { num classpath setIdstart setIdend } {
1876: set totalpoints 0
1877: for {set setId $setIdstart} {$setId <= $setIdend} {incr setId} {
1878: set points [CTgetStudentScores studentScores $classpath $setId $num]
1879: incr totalpoints $points
1880: # parray studentScores
1881: }
1882:
1883: displayStatus "Pondering data . . ." spinner $num
1884: for { set i 0 } { $i <= $totalpoints } { incr i } {
1885: set total_score($i) 0
1886: }
1887: foreach sNum [array names studentScores] { incr total_score($studentScores($sNum)) }
1.12 ! albertel 1888: CTputs $num "Scores #achieved\n"
1.1 albertel 1889: set scorelist ""
1890: foreach score [lsort -integer [array names total_score]] {
1891: CTputs $num [format "%5d:%6d\n" $score $total_score($score)]
1892: lappend scorelist [list $total_score($score) $score]
1893: }
1894: removeStatus $num
1895: return $scorelist
1896: }
1897:
1898: #common Input dialogs
1899:
1900: #common output methods
1901: proc CTdatestamp { cmdnum } {
1902: CTputs $cmdnum [clock format [clock seconds]]\n
1903: }
1904:
1905: ###########################################################
1906: # CTputs
1907: ###########################################################
1908: ###########################################################
1909: ###########################################################
1910: proc CTputs { num message {tag normal} } {
1911: global gCT
1912:
1913: lappend gCT(output.$num) [list $message $tag]
1914: }
1915:
1916: ###########################################################
1917: # CToutputWrap
1918: ###########################################################
1919: ###########################################################
1920: ###########################################################
1921: proc CToutputWrap { num } {
1922: global gCT
1923: if { $gCT($num.wrap) } {
1924: $gCT($num.output) configure -wrap char
1925: } else {
1926: $gCT($num.output) configure -wrap none
1927: }
1928: }
1929:
1930: ###########################################################
1931: # CToutput
1932: ###########################################################
1933: ###########################################################
1934: ###########################################################
1935: proc CToutput { num cmdnum } {
1936: global gCT
1937:
1938: if { ![winfo exists $gCT($num).output] } {
1939: set outputWin [toplevel $gCT($num).output]
1940:
1941: set buttonFrame [frame $outputWin.button]
1942: set textFrame [frame $outputWin.text]
1943: set bottomFrame [frame $outputWin.bottom]
1944: pack $buttonFrame $textFrame $bottomFrame
1945: pack configure $buttonFrame -anchor e -expand 0 -fill x
1946: pack configure $textFrame -expand 1 -fill both
1947: pack configure $bottomFrame -expand 0 -fill x
1948:
1949: set gCT($num.output) [text $textFrame.text \
1950: -yscrollcommand "$textFrame.scroll set" \
1951: -xscrollcommand "$bottomFrame.scroll set"]
1952: scrollbar $textFrame.scroll -command "$textFrame.text yview"
1953: pack $gCT($num.output) $textFrame.scroll -side left
1954: pack configure $textFrame.text -expand 1 -fill both
1955: pack configure $textFrame.scroll -expand 0 -fill y
1956:
1957: scrollbar $bottomFrame.scroll -command "$textFrame.text xview" -orient h
1958: pack $bottomFrame.scroll -expand 0 -fill x
1959:
1960: set gCT($num.wrap) 1
1961: checkbutton $buttonFrame.wrap -text "Wrap" -command "CToutputWrap $num" \
1962: -variable gCT($num.wrap)
1963: button $buttonFrame.save -text "Save Text" -command "CTsaveText $num"
1964: button $buttonFrame.print -text "Print Text" -command "CTprintText $num"
1965: button $buttonFrame.dismiss -text "Dismiss" -command "destroy $outputWin"
1966: pack $buttonFrame.wrap $buttonFrame.save $buttonFrame.print \
1967: $buttonFrame.dismiss -side left
1968: }
1.7 albertel 1969: set index [$gCT($num.output) index end-1c]
1.1 albertel 1970: foreach line $gCT(output.$cmdnum) {
1971: eval $gCT($num.output) insert end $line
1972: }
1973: unset gCT(output.$cmdnum)
1974: raise $gCT($num).output
1975: $gCT($num.output) see $index
1976: update idletasks
1977: }
1978:
1979: ###########################################################
1980: # CTsaveText
1981: ###########################################################
1982: # saves the contents of a text window
1983: ###########################################################
1984: # Arguments: num (the unique number of the path, and window)
1985: # Returns : nothing
1986: # Globals :
1987: ###########################################################
1988: proc CTsaveText { num } {
1989: global gFile gCT
1990:
1991: set window $gCT($num.output)
1992: if {![winfo exists $window]} { return }
1993: set dir $gFile($num)
1994: set file ""
1995:
1996: if { $dir == "" || $dir == "."} { set dir [pwd] }
1997: set file [tk_getSaveFile -title "Enter the name to Save As" \
1998: -initialdir "$dir" ]
1999: if { $file == "" } {
2000: displayError "File not saved"
2001: return
2002: }
2003: set fileId [open $file w]
2004: puts -nonewline $fileId [$window get 0.0 end-1c]
2005: close $fileId
2006: }
2007:
2008: ###########################################################
2009: # CTprintText
2010: ###########################################################
2011: # prints the contents of the text window, creates a temp file named
2012: # quiztemp.txt
2013: ###########################################################
2014: # Arguments: num (the unique number of the path, and window)
2015: # Returns : nothing
2016: # Globals : gFile gCT
2017: ###########################################################
2018: proc CTprintText { num } {
2019: global gFile gCT
2020:
2021: set window $gCT($num.output)
2022: if { ![winfo exists $window]} { return }
2023: catch {parseCapaConfig $num $gFile($num)}
2024: set lprCommand [getLprCommand [file join $gFile($num) managertemp.txt] $num]
2025: if {$lprCommand == "Cancel"} { return }
2026:
2027: set fileId [open [file join $gFile($num) managertemp.txt] w]
2028: puts -nonewline $fileId [$window get 0.0 end-1c]
2029: close $fileId
2030:
2031: set errorMsg ""
2032: if { [catch {set output [ eval "exec $lprCommand" ] } errorMsg ]} {
2033: displayError "An error occurred while printing: $errorMsg"
2034: } else {
2035: displayMessage "Print job sent to the printer.\n $output"
2036: }
2037: exec rm -f [file join $gFile($num) mangertemp.txt]
2038: }
2039:
2040: ###########################################################
2041: # CTprintCanvas
2042: ###########################################################
2043: ###########################################################
2044: ###########################################################
2045: proc CTprintCanvas { num window path } {
2046:
2047: if { ![winfo exists $window]} { return }
2048: catch {parseCapaConfig $num $gFile($num)}
2049: set lprCommand [getLprCommand [file join $path managertemp.txt] $num]
2050: if {$lprCommand == "Cancel"} { return }
2051:
2052: set rotate 0
2053: if { [tk_messageBox -title "Print in landscape mode" -message "Would you like to print in landscape mode?" -icon question -type yesno] == "yes" } { set rotate 1 }
2054: $window postscript -file [file join $path managertemp.txt] -rotate $rotate
2055:
2056: set errorMsg ""
2057: if { [catch {set output [ eval "exec $lprCommand" ] } errorMsg ]} {
2058: displayError "An error occurred while printing: $errorMsg"
2059: } else {
2060: displayMessage "Print job sent to the printer.\n $output"
2061: }
2062: exec rm -f [file join $path mangertemp.txt]
2063: }
2064:
2065: ###########################################################
2066: # CTsaveCanvas
2067: ###########################################################
2068: ###########################################################
2069: ###########################################################
2070: proc CTsaveCanvas { window path } {
2071: if { ![winfo exists $window] } { return }
2072: set dir $path
2073: set file ""
2074:
2075: if { $dir == "" } { set dir [pwd] }
2076: set file [tk_getSaveFile -title "Enter the name to Save As" \
2077: -initialdir "$dir" ]
2078: if { $file == "" } {
2079: displayError "File not saved"
2080: return
2081: }
2082: $window postscript -file $file
2083: }
2084:
2085: ###########################################################
2086: # CTbargraph
2087: ###########################################################
2088: ###########################################################
2089: ###########################################################
2090: proc CTbargraph {window num barnum data {path ""} {title "" } {xlabel ""} {ylabel ""}
2091: {suffix ""} } {
2092: global gBarGraph
2093: set height 300
2094: set width 500
2095:
2096: global gWindowMenu
2097:
2098: set bargraph [toplevel $window.bargraph$barnum]
2099: if { $title != "" } { wm title $bargraph $title }
2100: $gWindowMenu add command -label "$title $barnum" -command "capaRaise $bargraph"
2101:
2102: set buttonFrame [frame $bargraph.buttons]
2103: set canvasFrame [frame $bargraph.canvas]
2104: pack $buttonFrame $canvasFrame -side top
2105: pack configure $canvasFrame -expand 1 -fill both
2106:
2107: set canvas [canvas $canvasFrame.canvas -height $height -width $width -background white]
2108: pack $canvas -expand 1 -fill both
2109: bind $canvas <Configure> "CTdrawBargraph $barnum"
2110:
2111: button $buttonFrame.change -text "Change Graph" -command "CTchangeBargraph $window $barnum"
2112: button $buttonFrame.save -text "Save Graph" -command "CTsaveCanvas $canvas $path"
2113: button $buttonFrame.print -text "Print Graph" -command "CTprintCanvas $num $canvas $path"
2114: button $buttonFrame.dismiss -text "Dismiss" -command "CTdestroyBargraph $barnum"
2115: pack $buttonFrame.change $buttonFrame.save $buttonFrame.print \
2116: $buttonFrame.dismiss -side left
2117: bind $bargraph <Destroy> "CTdestroyBargraph $barnum"
2118:
2119: set gBarGraph($barnum.num) $num
2120: set gBarGraph($barnum.suffix) $suffix
2121: set gBarGraph($barnum) $data
2122: set gBarGraph($barnum.canvas) $canvas
2123: set gBarGraph($barnum.title) $title
2124: set gBarGraph($barnum.xlabel) $xlabel
2125: set gBarGraph($barnum.ylabel) $ylabel
2126: set gBarGraph($barnum.color) green
2127: set gBarGraph($barnum.bucketscores) 0
2128: CTautoscaleBargraph $barnum
2129: CTdrawBargraph $barnum
2130: }
2131:
2132: ###########################################################
2133: # CTautoscaleBargraph
2134: ###########################################################
2135: ###########################################################
2136: ###########################################################
2137: proc CTautoscaleBargraph { barnum } {
2138: global gBarGraph
2139: set data $gBarGraph($barnum)
2140: set max [lindex [lindex [lsort -decreasing -index 0 -real $data] 0] 0]
2141: if { $max > int($max) } { set max [expr int($max+1)] }
2142: set gBarGraph($barnum.yoften) [expr int([format "%1.e" [expr $max/10.0]])]
2143: if { $gBarGraph($barnum.yoften) == 0 } { set gBarGraph($barnum.yoften) 1 }
2144: set total [llength $data]
2145: set gBarGraph($barnum.xoften) [expr ($total/25) + 1]
2146: }
2147:
2148: ###########################################################
2149: # CTchangeBargraphData
2150: ###########################################################
2151: ###########################################################
2152: ###########################################################
2153: proc CTchangeBargraphData { barnum data } {
2154: global gBarGraph
2155: set gBarGraph($barnum) $data
2156: CTautoscaleBargraph $barnum
2157: CTdrawBargraph $barnum
2158: }
2159:
2160: ###########################################################
2161: # CTdestroyBargraph
2162: ###########################################################
2163: ###########################################################
2164: ###########################################################
2165: proc CTdestroyBargraph { num } {
2166: global gBarGraph
2167:
2168: if { [catch {set window [winfo toplevel $gBarGraph($num.canvas)]}]} { return }
2169: set window2 [file rootname $window].changeBarGraph$num
2170: foreach name [array names gBarGraph "$num.*" ] {
2171: unset gBarGraph($name)
2172: }
2173: unset gBarGraph($num)
2174: destroy $window
2175: catch {destroy $window2}
2176: }
2177:
2178: ###########################################################
2179: # CTdrawBargraph
2180: ###########################################################
2181: ###########################################################
2182: ###########################################################
2183: proc CTdrawBargraph { num } {
2184: global gBarGraph
2185:
2186: set data $gBarGraph($num)
2187: set canvas $gBarGraph($num.canvas)
2188: set suffix $gBarGraph($num.suffix)
2189:
2190: set height [winfo height $canvas]
2191: set width [winfo width $canvas]
2192: set titleoffset 0
2193: set titleheight 15
2194: set labelheight 15
2195: set tickheight 15
2196: set textheight [expr $labelheight+$tickheight]
2197: set textwidth 40
2198: set graphheight [expr $height - $textheight - $titleheight]
2199: set graphwidth [expr $width - $textwidth]
2200: $canvas delete all
2201:
2202: #draw data
2203: set total [llength $data]
2204: set eachwidth [expr $graphwidth/$total]
2205: # set howoften [expr ($total/$gBarGraph($num.numlabels)) + 1]
2206: set howoften $gBarGraph($num.xoften)
2207: set when [expr ($total-1)%$howoften]
2208: set max 0
2209: set i 0
2210: set value 0
2211: if { $gBarGraph($num.bucketscores) } {
2212: foreach datum $data {
2213: set value [expr {$value + [lindex $datum 0]}]
2214: if { $i % $howoften == $when } {
2215: if { $value > $max } { set max $value }
2216: set value 0
2217: }
2218: incr i
2219: }
2220: } else {
2221: set max [lindex [lindex [lsort -decreasing -index 0 -real $data] 0] 0]
2222: }
2223: if { $max > int($max) } { set max [expr int($max+1)] }
2224: if { [catch {set pixelvalue [expr ($graphheight-1)/double($max)]} ] } {
2225: set pixelvalue 10
2226: }
2227: set i 0
2228: set value 0
2229: foreach datum $data {
2230: set value [expr {$value + [lindex $datum 0]}]
2231: set which [lindex $datum 1]
2232: set y1 [expr {$graphheight + $titleheight}]
2233: set x2 [expr {$eachwidth * ($i+1) + $textwidth}]
2234: set y2 [expr {($graphheight-1) + $titleheight - $value * $pixelvalue}]
2235: set tag bar.$which.[expr $which-$howoften]
2236: if { [set color [lindex $datum 3]] == "" } {set color $gBarGraph($num.color)}
2237: if { $gBarGraph($num.bucketscores) && ($i % $howoften == $when) } {
2238: if { $i == $when } {
1.6 albertel 2239: # puts "$value-$which-$howoften"
1.1 albertel 2240: $canvas create rectangle $textwidth \
2241: $y1 $x2 $y2 -fill $color -tag $tag
2242: } else {
1.6 albertel 2243: # puts "$value:$which:$howoften"
1.1 albertel 2244: $canvas create rectangle [expr {$eachwidth*($i-$howoften+1)+$textwidth}]\
2245: $y1 $x2 $y2 -fill $color -tag $tag
2246: }
2247: } elseif { !$gBarGraph($num.bucketscores) } {
2248: $canvas create rectangle [expr {$eachwidth * $i + $textwidth}] \
2249: $y1 $x2 $y2 -fill $color -tag bar.$which.[expr $which-1]
2250: set value 0
2251: }
2252: if { $i % $howoften == $when } {
2253: $canvas create text [expr {$eachwidth * $i + $textwidth + $eachwidth/2}] \
2254: [expr $graphheight+(($tickheight)/2)+$titleheight] -text $which
2255: set value 0
2256: }
2257: incr i
2258: }
2259:
2260: #draw title
2261: $canvas create text [expr $textwidth+$titleoffset+($graphwidth/2)] 1 -anchor n\
2262: -text $gBarGraph($num.title)
2263: #draw axis
2264: $canvas create line $textwidth [expr {$graphheight + $titleheight}] \
2265: $textwidth [expr {$titleheight + 1}]
2266: #label xaxis
2267: $canvas create text [expr ($textwidth+($graphwidth/2))] \
2268: [expr $titleheight+$graphheight+$tickheight+($labelheight/2)] \
2269: -text $gBarGraph($num.xlabel)
2270: #label yaxis
2271: $canvas create text 1 1 -anchor nw -text $gBarGraph($num.ylabel)
2272: #draw tickmarks
2273: # set delta [format "%1.e" [expr ($max)/double($gBarGraph($num.numticks))]]
2274: set delta $gBarGraph($num.yoften)
2275: set start 0.0
2276: while { $start < $max } {
2277: set center [expr {($graphheight-1)*(($start)/$max)+$titleheight+1}]
2278: $canvas create line $textwidth $center [expr $textwidth - 20] $center
2279: $canvas create text [expr $textwidth-3] $center -anchor ne -text [expr int($max-$start)]
2280: set start [expr $start + $delta]
2281: }
2282: if { [llength [lindex $data 0]] > 2} {
2283: $canvas bind current <1> "CTbargraphClick$suffix $num"
2284: bind $canvas <Enter> "CTbargraphDisplayCreate $num"
2285: bind $canvas <Leave> "CTbargraphDisplayRemove $num"
2286: bind $canvas <Motion> "CTbargraphDisplayMove $num"
2287: $canvas bind all <Enter> "CTbargraphDisplay$suffix $num"
2288: }
2289: }
2290:
2291: ###########################################################
2292: # CTbargraphDisplayCreate
2293: ###########################################################
2294: ###########################################################
2295: ###########################################################
2296: proc CTbargraphDisplayCreate { barnum } {
2297: global gBarGraph gCT gFile
2298: set canvas $gBarGraph($barnum.canvas)
2299: if {[winfo exists $canvas.bubble$barnum]} { return }
2300: set bubble [toplevel $canvas.bubble$barnum]
2301: wm overrideredirect $bubble 1
2302: wm positionfrom $bubble program
2303: wm withdraw $bubble
2304: pack [label $bubble.l -highlightthickness 0 -relief raised -bd 1 -background yellow]
2305: }
2306: ###########################################################
2307: # CTbargraphDisplayRemove
2308: ###########################################################
2309: ###########################################################
2310: ###########################################################
2311: proc CTbargraphDisplayRemove { barnum } {
2312: global gBarGraph gCT gFile
2313: set canvas $gBarGraph($barnum.canvas)
2314: catch {destroy $canvas.bubble$barnum}
2315: }
2316: ###########################################################
2317: # CTbargraphDisplayBlank
2318: ###########################################################
2319: ###########################################################
2320: ###########################################################
2321: proc CTbargraphDisplayBlank { barnum } {
2322: global gBarGraph gCT gFile
2323: set canvas $gBarGraph($barnum.canvas)
2324: catch {$canvas.bubble$barnum.l configure -text ""}
2325: }
2326: ###########################################################
2327: # CTbargraphDisplayMove
2328: ###########################################################
2329: ###########################################################
2330: ###########################################################
2331: proc CTbargraphDisplayMove { barnum } {
2332: global gBarGraph gCT gFile
2333: set canvas $gBarGraph($barnum.canvas)
2334: catch {wm geometry $canvas.bubble$barnum +[expr 20+[winfo pointerx .]]+[expr 20+[winfo pointery .]]}
2335: if {[$canvas gettags current] == ""} {CTbargraphDisplayRemove $barnum}
2336: }
2337: ###########################################################
2338: # CTbargraphDisplayShowresponse
2339: ###########################################################
2340: ###########################################################
2341: ###########################################################
2342: proc CTbargraphDisplayShowresponse { barnum } {
2343: global gBarGraph gCT gFile
2344: set num $gBarGraph($barnum.num)
2345: set canvas $gBarGraph($barnum.canvas)
2346:
2347: set high [lindex [split [lindex [$canvas gettags current] 0] .] 1]
2348: foreach datum $gBarGraph($barnum) {
2349: set bar [lindex $datum 1]
2350: if { $bar != $high } { continue }
2351: if {![winfo exists $canvas.bubble$barnum.l]} {CTbargraphDisplayCreate $barnum}
2352: $canvas.bubble$barnum.l configure -text "[lindex $datum 0] - \"[splitline [lindex $datum 2] 35]\""
2353: wm geometry $canvas.bubble$barnum +[expr 20+[winfo pointerx .]]+[expr 20+[winfo pointery .]]
2354: wm deiconify $canvas.bubble$barnum
2355: return
2356: }
2357: CTbargraphDisplayRemove $barnum
2358: }
2359: ###########################################################
2360: # CTbargraphDisplaySCP
2361: ###########################################################
2362: ###########################################################
2363: ###########################################################
2364: proc CTbargraphDisplaySCP { barnum } {
2365: global gBarGraph gCT gFile
2366: set num $gBarGraph($barnum.num)
2367: set canvas $gBarGraph($barnum.canvas)
2368:
2369: set high [lindex [split [lindex [$canvas gettags current] 0] .] 1]
2370: foreach datum $gBarGraph($barnum) {
2371: set bar [lindex $datum 1]
2372: if { $bar != $high } { continue }
2373: if {![winfo exists $canvas.bubble$barnum.l]} {CTbargraphDisplayCreate $barnum}
2374: $canvas.bubble$barnum.l configure -text "[lindex $datum 0]"
2375: wm geometry $canvas.bubble$barnum +[expr 20+[winfo pointerx .]]+[expr 20+[winfo pointery .]]
2376: wm deiconify $canvas.bubble$barnum
2377: return
2378: }
2379: CTbargraphDisplayRemove $barnum
2380: }
2381:
2382: ###########################################################
2383: # CTbargraphClickSCP
2384: ###########################################################
2385: ###########################################################
2386: ###########################################################
2387: proc CTbargraphClickSCP { barnum } {
2388: global gBarGraph gCT gFile
2389:
2390: set num $gBarGraph($barnum.num)
2391: set canvas $gBarGraph($barnum.canvas)
2392: set bucket $gBarGraph($barnum.bucketscores)
2393:
2394: set high [lindex [split [lindex [$canvas gettags current] 0] .] 1]
2395: set low [lindex [split [lindex [$canvas gettags current] 0] .] 2]
2396: set stunums ""
2397: if { $high == "" || $low == "" } { return }
2398: foreach datum $gBarGraph($barnum) {
2399: set bar [lindex $datum 1]
2400: if { $bar > $high || $bar <= $low } { continue }
2401: set stunums [concat $stunums [lindex $datum 2]]
2402: }
2403: if { $stunums == "" } { return }
2404: if {"" == [set stuSCP [multipleChoice $gCT($num) "Select a student" $stunums 0]]} {
2405: return
2406: }
2407: set loginAnalysis [expr {"Yes" == [makeSure "Do you wish to do a Login Analysis? It may take a while." ]}]
2408: foreach s_id $stuSCP {
2409: CTstudentCourseProfile $num $s_id \
2410: [findByStudentNumber $s_id $gFile($num)] $loginAnalysis
2411: }
2412: }
2413:
2414: ###########################################################
2415: # CTbargraphClickShowresponse
2416: ###########################################################
2417: ###########################################################
2418: ###########################################################
2419: proc CTbargraphClickShowresponse { barnum } {
2420: global gBarGraph gCT gFile gUniqueNumber
2421:
2422: set num $gBarGraph($barnum.num)
2423: set canvas $gBarGraph($barnum.canvas)
2424: set bucket $gBarGraph($barnum.bucketscores)
2425:
2426: if { [catch {set datanum $gBarGraph($barnum.shownum1)}] } {
2427: set datanum [set gBarGraph($barnum.shownum1) [incr gUniqueNumber]]
2428: set winnum [set gBarGraph($barnum.shownum2) [incr gUniqueNumber]]
2429: } else {
2430: set winnum $gBarGraph($barnum.shownum2)
2431: }
2432: set gCT($winnum) ""
2433: set high [lindex [split [lindex [$canvas gettags current] 0] .] 1]
2434: foreach datum $gBarGraph($barnum) {
2435: set bar [lindex $datum 1]
2436: if { $bar != $high } { continue }
2437: CTputs $datanum "[lindex $datum 0] responses \"[lindex $datum 2]\"\n"
2438: }
2439: CToutput $winnum $datanum
2440: }
2441:
2442: ###########################################################
2443: # CTchangeBargraph
2444: ###########################################################
2445: ###########################################################
2446: ###########################################################
2447: proc CTchangeBargraph { window num } {
2448: global gBarGraph
2449:
2450: set change [toplevel $window.changeBarGraph$num]
2451:
2452: set infoFrame [frame $change.info]
2453: set buttonFrame [frame $change.button]
2454: set title [frame $change.title]
2455: set xlabel [frame $change.xlabel]
2456: set ylabel [frame $change.ylabel]
2457: set xoften [frame $change.xoften]
2458: set yoften [frame $change.yoften]
2459: set color [frame $change.color]
2460: set bucket [frame $change.bucket]
2461: set font [frame $change.font]
2462: pack $infoFrame $buttonFrame $title $xlabel $ylabel $xoften $yoften $color $bucket
2463: pack configure $title $xlabel $ylabel $xoften $yoften -anchor e -expand 1 -fill both
2464: button $buttonFrame.update -text Update -command "CTdrawBargraph $num"
2465: bind $change <Return> "CTdrawBargraph $num"
2466: button $buttonFrame.dismiss -text Dismiss -command "destroy $change"
2467: pack $buttonFrame.update $buttonFrame.dismiss -side left
2468:
2469: foreach {frame label var
2470: } "$title { Title} title
2471: $xlabel { X-Axis Label} xlabel
2472: $ylabel { Y-Axis Label} ylabel
2473: $xoften {Increment on X-Axis} xoften
2474: $yoften {Increment on Y-Axis} yoften" {
2475: label $frame.label -text $label
2476: set entryFrame [frame $frame.entry]
2477: pack $frame.label $entryFrame -side left
2478: pack configure $entryFrame -expand 1 -fill both
2479: entry $entryFrame.entry -textvariable gBarGraph($num.$var) \
2480: -xscrollcommand "$entryFrame.scroll set"
2481: scrollbar $entryFrame.scroll -orient h -command \
2482: "$entryFrame.entry xview"
2483: pack $entryFrame.entry $entryFrame.scroll -fill x
2484: }
2485:
2486: label $color.label -text "Color of Bars"
2487: label $color.color -relief ridge -background $gBarGraph($num.color) \
2488: -text " "
2489: button $color.change -text "Change" -command "CTchangeBargraphColor $color $num"
2490: pack $color.label $color.color $color.change -side left
2491:
2492: checkbutton $bucket.bucket -text "Bucket Scores" -variable \
2493: gBarGraph($num.bucketscores) -command "CTdrawBargraph $num"
2494: pack $bucket.bucket
2495: }
2496:
2497: ###########################################################
2498: # CTchangeBargraphColor
2499: ###########################################################
2500: ###########################################################
2501: ###########################################################
2502: proc CTchangeBargraphColor { color num } {
2503: global gBarGraph
2504: set temp [tk_chooseColor -initialcolor $gBarGraph($num.color)]
2505: if { $temp != "" } {
2506: $color.color configure -background [set gBarGraph($num.color) $temp]
2507: }
2508: CTdrawBargraph $num
2509: }
2510:
2511: ###########################################################
2512: # CTdisplayStudent
2513: ###########################################################
2514: ###########################################################
2515: ###########################################################
2516: proc CTdisplayStudent { num window path id } {
2517:
2518: if { ![file exists [file join $path photo gif $id.gif]] } {
2519: if { [file exists [file join $path photo jpg $id.jpg]] } {
2520: exec /usr/local/bin/djpeg -outfile [file join $path photo gif $id.gif] \
2521: [file join $path photo jpg $id.jpg]
2522: } else {
2523: return
2524: }
2525: }
2526: set image [image create photo]
2527: $image read [file join $path photo gif $id.gif]
2528:
2529: set imageWin [toplevel $window.image$num]
2530:
2531: set buttonFrame [frame $imageWin.button]
2532: set infoFrame [frame $imageWin.info]
2533: set imageFrame [frame $imageWin.image]
2534: pack $buttonFrame $infoFrame $imageFrame
2535:
2536: button $buttonFrame.dismiss -command "destroy $imageWin" -text Dismiss
2537: pack $buttonFrame.dismiss
2538:
2539: label $infoFrame.label -text $id
2540: pack $infoFrame.label
1.11 albertel 2541:
2542: set height [image height $image]
2543: set width [image width $image]
2544: set canvas [canvas $imageFrame.canvas -height $height -width $width]
1.1 albertel 2545: pack $canvas
2546: $canvas create image 1 1 -image $image -anchor nw
2547: }
2548:
2549: ###########################################################
2550: # CTgetWhen
2551: ###########################################################
2552: ###########################################################
2553: ###########################################################
2554: proc CTgetWhen { num } {
2555: set day [getString . "Enter a date"]
2556: update
2557: return $day
2558: }
2559:
2560: ###########################################################
2561: # CTscanDB
2562: ###########################################################
2563: ###########################################################
2564: ###########################################################
2565: proc CTscanDB { num file outId startdate enddate } {
2566: global answerArray exist
2567: set fileId [open $file r]
2568: set Yes_cnt 0
2569: set No_cnt 0
2570: set line_cnt 0
2571: set prob_cnt 0
2572: set maxLine [lindex [exec wc $file] 0]
2573: puts $maxLine
2574: set aline [gets $fileId]
2575: while { ! [eof $fileId] } {
2576: incr line_cnt
2577: if { ($line_cnt%20) == 0 } {
2578: puts $curdate
2579: updateStatusBar [expr $line_cnt/double($maxLine)] $num
2580: }
2581: set length [llength $aline]
2582: set date [lrange $aline 1 [expr $length - 2]]
2583: set curdate [clock scan $date]
2584: if { $curdate < $startdate } { set aline [gets $fileId]; continue }
2585: if { $curdate > $enddate } { break }
2586: set s_num [string toupper [lindex $aline 0]]
2587: set ans_char [split [lindex $aline end] ""]
2588: set usr_ans "$s_num.ans"
2589: set usr_try "$s_num.try"
2590: if {$prob_cnt == 0} { set prob_cnt [llength $ans_char] }
2591: if { [array names answerArray "$usr_ans.*"] == "" } {
2592: for {set ii 0} { $ii <= $prob_cnt } { incr ii} {
2593: set answerArray($usr_ans.$ii) "-"
2594: }
2595: }
2596: if { [array names answerArray "$usr_try.*"] == "" } {
2597: for {set ii 0} { $ii <= $prob_cnt } { incr ii} {
2598: set answerArray($usr_try.$ii) 0
2599: }
2600: }
2601: for {set ii 0} { $ii <= $prob_cnt } { incr ii} {
2602: if { [lindex $ans_char $ii] == "Y" } {
2603: set answerArray($usr_ans.$ii) "Y"
2604: incr answerArray($usr_try.$ii)
2605: }
2606: if { [lindex $ans_char $ii] == "N"} {
2607: if {$answerArray($usr_ans.$ii) != "Y"} {
2608: set answerArray($usr_ans.$ii) "Y"
2609: }
2610: incr answerArray($usr_try.$ii)
2611: }
2612: }
2613: if { [array names exist $s_num] == "" } { set exist($s_num) $s_num }
2614: set aline [gets $fileId]
2615: }
2616: close $fileId
2617: return $prob_cnt
2618: }
2619:
2620: ###########################################################
2621: # CTcreateSubset
2622: ###########################################################
2623: ###########################################################
2624: ###########################################################
2625: proc CTcreateSubset { num cmdnum day setId } {
2626: global gFile gCT answerArray exist
2627:
2628: set outId [open [file join $gFile($num) records "subset$setId.db"] w]
2629: set inId [open [file join $gFile($num) records "set$setId.db"] r]
2630:
2631: set startdate [clock scan "$day 12:00 AM"]
2632: set enddate [clock scan "$day 11:59 PM"]
2633:
2634: puts $startdate:$enddate
2635: set prob_cntt [CTscanDB $cmdnum [file join $gFile($num) records log$setId.db] $outId $startdate $enddate]
2636: puts $startdate:$enddate
2637: set prob_cntw [CTscanDB $cmdnum [file join $gFile($num) records weblog$setId.db] $outId $startdate $enddate]
2638: puts $startdate:$enddate
2639: puts "$day 12:00 AM : $day 11:59 PM"
2640: if { $prob_cntt > $prob_cntw } {
2641: set prob_cnt $prob_cntt
2642: } else {
2643: set prob_cnt $prob_cntw
2644: }
2645:
2646: puts $outId [gets $inId]
2647: puts $outId [gets $inId]
2648: puts $outId [gets $inId]
2649: foreach s_num [lsort [array names exist]] {
2650: set usr_ans $s_num.ans
2651: set usr_try $s_num.try
2652: puts -nonewline $outId "$s_num "
2653: for { set ii 0 } { $ii< $prob_cnt } { incr ii } {
2654: puts -nonewline $outId $answerArray($usr_ans.$ii)
2655: }
2656: for { set ii 0 } { $ii< $prob_cnt } { incr ii } {
2657: puts -nonewline $outId [format ",%2d" $answerArray($usr_try.$ii)]
2658: }
2659: puts $outId ""
2660: }
2661: close $outId
2662: close $inId
2663: catch {unset answerArray}
2664: catch {unset exist}
2665: }
1.2 albertel 2666:
2667: ###########################################################
2668: # CTdiscussForum
2669: ###########################################################
2670: ###########################################################
2671: ###########################################################
1.3 albertel 2672: proc CTdiscussForum { num file dir resultVar {specificSet 0}} {
2673: global gCT
2674: upvar $resultVar result
1.2 albertel 2675:
1.3 albertel 2676: if { $specificSet == 0 } {
2677: set start 1
2678: } else {
2679: set start $specificSet
2680: }
1.2 albertel 2681: set fileId [open $file r]
2682: set maxLine [lindex [exec wc $file] 0]
2683: set aline [gets $fileId]
2684: set last 0
2685: set line_cnt 0
2686: while {![eof $fileId]} {
2687: incr line_cnt
2688: if { ($line_cnt%20) == 0 } { updateStatusBar [expr $line_cnt/double($maxLine)] $num }
1.11 albertel 2689: foreach {stunum capaid name email action set prob date time blank} [split $aline "|"] {}
1.3 albertel 2690: if {$specificSet && ($specificSet == $set)} {set aline [gets $fileId];continue}
1.2 albertel 2691: if { $action == "ViewProblem" } {
2692: if { [catch {incr count($set,$prob)}]} {
2693: set count($set,$prob) 1
2694: if { $set > $last } { set last $set }
2695: if { [catch {set max($set)}]} { set max($set) 0 }
2696: if { $prob > $max($set)} { set max($set) $prob }
2697: if { [catch {set posts($set,$prob) [llength [glob $dir/discussion/$set/[format "%06d" $prob]-*-*-*.msg]]}]} { set posts($set,$prob) 0 }
2698: }
2699: set ever($name) 1
2700: set names($set,$name) 1
2701: set nameprob($set,$prob,$name) 1
2702: }
2703: set aline [gets $fileId]
2704: }
2705:
1.3 albertel 2706: updateStatusMessage "Summarizing Data" $num
1.2 albertel 2707: updateStatusBar 0 $num
2708: for {set i 1} { $i <= $last } { incr i } {
2709: updateStatusBar [expr $i/$last] $num
2710: set total($i) 0
1.3 albertel 2711: for {set j 1} { $j <= $max($i) } { incr j } {
1.2 albertel 2712: set message ""
1.3 albertel 2713: if {[catch { set result($num.$i.$j.posts) $posts($i,$j) }]} {
2714: set result($num.$i.$j.posts) 0
2715: }
2716: if {[catch {set result($num.$i.$j.views) $count($i,$j)}]} {
2717: set result($num.$i.$j.views) 0
2718: }
2719: catch {incr total($i) $count($i,$j)}
2720: if { [catch { set result($num.$i.$j.ratio) \
2721: [expr $result($num.$i.$j.views)/double($result($num.$i.$j.posts))]} error]} {
2722: set result($num.$i.$j.ratio) 0.0
1.2 albertel 2723: }
1.3 albertel 2724: set result($num.$i.$j.viewers) [llength [array names nameprob $i,$j,*]]
1.2 albertel 2725: }
1.3 albertel 2726: set result($num.$i.views) $total($i)
2727: set result($num.$i.max) $max($i)
1.2 albertel 2728: }
2729:
1.3 albertel 2730: for {set i 1} { $i<=$last } { incr i } {
2731: set result($num.$i.viewers) [llength [array names names $i,*]]
1.2 albertel 2732: }
2733: close $fileId
1.3 albertel 2734: set result($num.viewers) [llength [array names ever]]
2735: set result($num.last) $last
1.12 ! albertel 2736: #IDEAS:
! 2737: # : how many views are repeats
1.2 albertel 2738: # : Student Course Profile, add #ViewProblems #Posts
2739: # : add some portion of these stats to analyze log files?
1.3 albertel 2740: }
2741:
2742: ###########################################################
2743: # CTputsDiscussResults
2744: ###########################################################
2745: ###########################################################
2746: proc CTputsDiscussResults { num resultsVar } {
2747: upvar $resultsVar result
2748: for {set i 1} { $i <= $result($num.last) } { incr i } {
2749: CTputs $num "For Set $i #Visitors:$result($num.$i.viewers) did #views:$result($num.$i.views)\n"
2750: CTputs $num "Prob# #Posts #Views Ratio #UniqueStu\n"
2751: CTputs $num "------------------------------------\n"
2752: for {set j 1} { $j <= $result($num.$i.max)} { incr j } {
2753: CTputs $num [format "%5d %6d %6d %5s %6d\n" $j \
2754: $result($num.$i.$j.posts) $result($num.$i.$j.views) \
2755: [if {$result($num.$i.$j.ratio) == 0.0} {set temp " "} \
2756: {format %.1f $result($num.$i.$j.ratio)}] \
2757: $result($num.$i.$j.viewers)]
2758: }
2759: }
2760: CTputs $num "Overall Unique #viewers: $result($num.viewers)\n"
1.6 albertel 2761: }
2762:
2763: ###########################################################
2764: # CTcreateReportDialog
2765: ###########################################################
2766: ###########################################################
2767: ###########################################################
2768: proc CTcreateReportDialog { num cmdnum } {
2769: global gCT gFile
2770:
2771:
2772: set gCT(summary.section.$cmdnum) 1
2773: set gCT(summary.set.$cmdnum) 1
2774:
2775: set summary [toplevel $gCT($num).summary]
2776: set whoFrame [frame $summary.whoFrame -borderwidth 4 -relief groove]
2777: set whichFrame [frame $summary.whichFrame -borderwidth 4 -relief groove]
2778: set sortFrame [frame $summary.sortFrame]
2779: set file2Frame [frame $summary.file2Frame]
2780: set buttonFrame [frame $summary.buttonFrame]
2781: pack $whoFrame $whichFrame $sortFrame $file2Frame $buttonFrame -side top
2782: pack configure $whoFrame $whichFrame -padx 10 -pady 10
2783:
2784: set sectionFrame [frame $whoFrame.section]
2785: set allFrame [frame $whoFrame.all]
2786: pack $sectionFrame $allFrame -side top
2787:
2788: set gCT(summary.who.$cmdnum) section
2789:
2790: radiobutton $sectionFrame.section -text \
2791: "For students in default section:" -variable gCT(summary.who.$cmdnum) \
2792: -value section
2793: entry $sectionFrame.entry -textvariable gCT(summary.section.$cmdnum) -width 3
2794: pack $sectionFrame.section $sectionFrame.entry -side left
2795:
2796: radiobutton $allFrame.all -text "For all students in the class" \
2797: -variable gCT(summary.who.$cmdnum) -value all
2798: pack $allFrame.all
2799:
2800: set sectionFrame [frame $whichFrame.section]
2801: set allFrame [frame $whichFrame.all]
2802: pack $sectionFrame $allFrame -side top
2803:
2804: set gCT(summary.which.$cmdnum) specific
2805:
2806: radiobutton $sectionFrame.section -text "For set:" \
2807: -variable gCT(summary.which.$cmdnum) -value specific
2808: entry $sectionFrame.entry -textvariable gCT(summary.set.$cmdnum) -width 3
2809: pack $sectionFrame.section $sectionFrame.entry -side left
2810:
2811: radiobutton $allFrame.all -text "For all sets up to:" -variable \
2812: gCT(summary.which.$cmdnum) -value upto
2813: entry $allFrame.entry -textvariable gCT(summary.set.$cmdnum) -width 3
2814: pack $allFrame.all $allFrame.entry -side left
2815:
2816: set firstFrame [frame $sortFrame.firstFrame -borderwidth 4 -relief groove]
2817: set secondFrame [frame $sortFrame.secondFrame -borderwidth 4 \
2818: -relief groove]
2819: pack $firstFrame $secondFrame -side left
2820:
2821: set gCT(summary.first.$cmdnum) name
2822:
2823: label $firstFrame.label -text "Sorting Order - Primary"
2824: radiobutton $firstFrame.name -text "Student Name" -variable \
2825: gCT(summary.first.$cmdnum) -value name
2826: radiobutton $firstFrame.number -text "Student Number" -variable \
2827: gCT(summary.first.$cmdnum) -value number
2828: radiobutton $firstFrame.section -text "Section" -variable \
2829: gCT(summary.first.$cmdnum) -value section
2830: radiobutton $firstFrame.grade -text "Grade" -variable gCT(summary.first.$cmdnum) \
2831: -value grade
2832: pack $firstFrame.label $firstFrame.name $firstFrame.number \
2833: $firstFrame.section $firstFrame.grade -side top -anchor w
2834:
2835: set gCT(summary.second.$cmdnum) number
2836:
2837: label $secondFrame.label -text "Sorting Order - Secondary"
2838: radiobutton $secondFrame.name -text "Student Name" -variable \
2839: gCT(summary.second.$cmdnum) -value name
2840: radiobutton $secondFrame.number -text "Student Number" -variable \
2841: gCT(summary.second.$cmdnum) -value number
2842: radiobutton $secondFrame.section -text "Section" -variable \
2843: gCT(summary.second.$cmdnum) -value section
2844: radiobutton $secondFrame.grade -text "Grade" -variable gCT(summary.second.$cmdnum) \
2845: -value grade
2846: pack $secondFrame.label $secondFrame.name $secondFrame.number \
2847: $secondFrame.section $secondFrame.grade -side top -anchor w
2848:
2849: set defaultFrame [frame $file2Frame.defaultFrame]
2850: set fileFrame [frame $file2Frame.fileFrame]
2851: pack $defaultFrame $fileFrame -side top
2852:
2853: set gCT(summary.filename.$cmdnum) default
2854:
2855: radiobutton $defaultFrame.default -text "Grader Chooses File Name" \
2856: -variable gCT(summary.filename.$cmdnum) -value default
2857: pack $defaultFrame.default
2858:
2859: radiobutton $fileFrame.label -text "Specified Output File:" \
2860: -variable gCT(summary.filename.$cmdnum) -value specified
2861: set entryFrame [frame $fileFrame.entryFrame]
2862: button $fileFrame.select -text "Select File" \
1.7 albertel 2863: -command "CTselectOutputFile $cmdnum"
1.6 albertel 2864: pack $fileFrame.label $entryFrame $fileFrame.select -side left
2865: entry $entryFrame.entry -textvariable gCT(summary.file.$cmdnum) \
2866: -xscrollcommand "$entryFrame.scroll set"
2867: scrollbar $entryFrame.scroll -orient h -command \
2868: "$entryFrame.entry xview"
2869: pack $entryFrame.entry $entryFrame.scroll
2870: pack configure $entryFrame.scroll -fill x
2871:
2872: button $buttonFrame.create -text "Create" -command \
2873: "removeWindowEntry Summary
2874: destroy $summary
2875: CTcreateSummaryReport $num $cmdnum"
2876: button $buttonFrame.cancel -text "Cancel" -command \
2877: "removeWindowEntry Summary
2878: destroy $summary"
2879: pack $buttonFrame.create $buttonFrame.cancel -side left
2880:
2881: Centre_Dialog $summary default
2882: }
1.7 albertel 2883:
2884: ###########################################################
2885: # CTselectOutputFile
2886: ###########################################################
2887: ###########################################################
2888: ###########################################################
2889: proc CTselectOutputFile { num } {
2890: global gCT
2891: set gCT(summary.filename.$num) specified
2892: if { "" != [ set temp [tk_getSaveFile] ] } {set gCT(summary.file.$num) $temp}
2893: }
1.6 albertel 2894:
2895: ###########################################################
2896: # CTcreateSummaryReport
2897: ###########################################################
2898: ###########################################################
2899: ###########################################################
2900: proc CTcreateSummaryReport { num cmdnum } {
2901: global gCT gFile
2902:
2903: displayStatus "Opening File" both $cmdnum
2904:
2905: switch $gCT(summary.who.$cmdnum) {
2906: all {
2907: set file ClassSet$gCT(summary.set.$cmdnum).rpt
2908: }
2909: section {
2910: set file Sec$gCT(summary.section.$cmdnum)Set$gCT(summary.set.$cmdnum).rpt
2911: }
2912: default {
1.10 albertel 2913: displayError "An error has occurred while creating a summary \
1.6 albertel 2914: report $gCT(summary.section.$cmdnum)"
2915: return
2916: }
2917: }
2918:
2919: if { $gCT(summary.filename.$cmdnum) == "specified" } {
2920: set file $gCT(summary.file.$cmdnum)
2921: }
2922: if { $file == "" } {
2923: removeStatus
2924: displayError "Must specify a valid filename"
2925: return
2926: }
2927: updateStatusMessage "Creating Summary" $cmdnum
2928:
2929: set cwd [pwd]
2930: cd $gFile($num)
2931: set error [ catch {CTcreateSummary $file $cmdnum} ]
2932: cd $cwd
2933:
2934: removeStatus $cmdnum
2935:
1.9 albertel 2936: if {!$error && "Yes" == [makeSure \
2937: "Created summary file $file, would you like to see it?"]} {
1.6 albertel 2938: set fileId [open [file join $gFile($num) $file] r]
2939: CTputs $cmdnum [read $fileId]
2940: CToutput $num $cmdnum
2941: }
1.8 albertel 2942: }
2943:
2944: ###########################################################
2945: # CTsetList
2946: ###########################################################
2947: ###########################################################
2948: ###########################################################
1.9 albertel 2949: proc CTsetList { file } {
1.8 albertel 2950: set list ""
1.9 albertel 2951: for { set i 0 } { $i < 100 } { incr i } {
2952: if { [file readable [file join $file records set$i.db]] } {
2953: lappend list $i
2954: }
1.8 albertel 2955: }
1.9 albertel 2956: return $list
1.10 albertel 2957: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>