--- capa/capa51/GUITools/capastats.tcl 1999/09/28 21:25:37 1.1.1.1 +++ capa/capa51/GUITools/capastats.tcl 1999/10/28 16:32:07 1.4 @@ -44,6 +44,7 @@ proc runCapaTools { classDirConfigFile } $utilsMenu add command -label "Analyze Class Report" -command "CTanalyzeReport $num" $utilsMenu add command -label "Analyze Responses" -command "CTanalyzeScorer $num" $utilsMenu add command -label "Graph a Responses Analysis" -command "CTgraphAnalyzeScorer $num" + $utilsMenu add command -label "Discussion Stats" -command "CTdiscussStats $num" $utilsMenu add command -label "Quit" -command "CTquit $num" $utilsMenu post 0 0 Centre_Dialog $utilsMenu default @@ -672,6 +673,24 @@ proc CTgraphAnalyzeScorer { num } { } ########################################################### +# CTdiscussStats +########################################################### +########################################################### +########################################################### +proc CTdiscussStats { num } { + global gCT gUniqueNumber gFile + set cmdnum [incr gUniqueNumber] + set gCT(cmd.$cmdnum) discussstats + set file [file join $gFile($num) discussion logs access.log] + displayStatus "Generating discussion Stats" both $cmdnum + CTdiscussForum $cmdnum $file $gFile($num) discussData 0 + CTputsDiscussResults $cmdnum discussData + CToutput $num $cmdnum + removeStatus $cmdnum + unset gCT(cmd.$cmdnum) +} + +########################################################### # CTquit ########################################################### ########################################################### @@ -903,27 +922,27 @@ proc CTlogAnalysis2 { num cmdnum setId } set logFile [file join $gFile($num) records "log$setId.db"] if { [file exists $logFile] } { CTputs $cmdnum "Log analysis for telnet session log$setId.db\n" - CTscanLogDB $cmdnum $logFile l(Y) l(N) l(S) l(U) l(u) + CTscanLogDB $cmdnum $logFile l(Y) l(N) l(S) l(U) l(u) l(A) l(F) } else { - set l(Y) [set l(N) [set l(S) [set l(U) [set l(u) 0]]]] + set l(Y) [set l(N) [set l(S) [set l(U) [set l(u) [set l(A) [set l(F) 0]]]]]] } set webLogFile [file join $gFile($num) records "weblog$setId.db" ] if { [file exists $webLogFile] } { CTputs $cmdnum "===============================================\n" CTputs $cmdnum "Log analysis for web session weblog$setId.db\n" - CTscanLogDB $cmdnum $webLogFile w(Y) w(N) w(S) w(U) w(u) + CTscanLogDB $cmdnum $webLogFile w(Y) w(N) w(S) w(U) w(u) w(A) w(F) } else { - set w(Y) [set w(N) [set w(S) [set w(U) [set w(u) 0]]]] + set w(Y) [set w(N) [set w(S) [set w(U) [set w(u) [set w(A) [set w(F) 0]]]]]] } - set telnet_total [expr $l(Y)+$l(N)+$l(S)+$l(U)+$l(u)] - set web_total [expr $w(Y)+$w(N)+$w(S)+$w(U)+$w(u)] + set telnet_total [expr $l(Y)+$l(N)+$l(S)+$l(U)+$l(u)+$l(A)+$l(F)] + set web_total [expr $w(Y)+$w(N)+$w(S)+$w(U)+$w(u)+$w(A)+$w(F)] CTputs $cmdnum "============== SUMMARY ====================\n" - CTputs $cmdnum " #Y #N #S #U #u Total\n" - CTputs $cmdnum [format "telnet: %6d %6d %6d %6d %6d %6d\n" \ - $l(Y) $l(N) $l(S) $l(U) $l(u) $telnet_total ] - CTputs $cmdnum [format " web: %6d %6d %6d %6d %6d %6d\n" \ - $w(Y) $w(N) $w(S) $w(U) $w(u) $web_total] - foreach v { Y N S U u } { + CTputs $cmdnum " #Y #N #S #U #u #A #F Total\n" + CTputs $cmdnum [format "telnet: %6d %6d %6d %6d %6d %6d %6d %6d\n" \ + $l(Y) $l(N) $l(S) $l(U) $l(u) $l(A) $l(F) $telnet_total ] + CTputs $cmdnum [format " web: %6d %6d %6d %6d %6d %6d %6d %6d\n" \ + $w(Y) $w(N) $w(S) $w(U) $w(u) $w(A) $w(F) $web_total] + foreach v { Y N S U u A F} { set sum($v) [expr $l($v) + $w($v)] if { $sum($v) > 0 } { set ratio($v) [expr 100.0*$w($v)/double($sum($v))] @@ -937,8 +956,8 @@ proc CTlogAnalysis2 { num cmdnum setId } } else { set ratio(web) 0.0 } - CTputs $cmdnum [format " %%web: % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f\n" \ - $ratio(Y) $ratio(N) $ratio(S) $ratio(U) $ratio(u) $ratio(web) ] + CTputs $cmdnum [format " %%web: % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f % 6.1f\n" \ + $ratio(Y) $ratio(N) $ratio(S) $ratio(U) $ratio(u) $ratio(A) $ratio(F) $ratio(web) ] } @@ -947,12 +966,14 @@ proc CTlogAnalysis2 { num cmdnum setId } ########################################################### ########################################################### ########################################################### -proc CTscanLogDB { num file Y_lVar N_lVar S_lVar U_lVar u_lVar } { +proc CTscanLogDB { num file Y_lVar N_lVar S_lVar U_lVar u_lVar A_lVar F_lVar } { upvar $Y_lVar Y_l upvar $N_lVar N_l upvar $S_lVar S_l upvar $U_lVar U_l upvar $u_lVar u_l + upvar $A_lVar A_l + upvar $F_lVar F_l set line_cnt 0 @@ -972,10 +993,12 @@ proc CTscanLogDB { num file Y_lVar N_lVa if { ! [info exists count] } { for { set i 0 } { $i < [llength $ans_char] } { incr i } { set count(Y.$i) 0; set count(N.$i) 0; set count(S.$i) 0 - set count(U.$i) 0; set count(u.$i) 0 + set count(U.$i) 0; set count(u.$i) 0; set count(A.$i) 0 + set count(F.$i) 0 } set count(Y.total) 0; set count(N.total) 0; set count(S.total) 0 - set count(U.total) 0; set count(u.total) 0 + set count(U.total) 0; set count(u.total) 0; set count(A.total) 0 + set count(F.total) 0 } set i -1 foreach char $ans_char { @@ -983,7 +1006,8 @@ proc CTscanLogDB { num file Y_lVar N_lVa if { $char == "-" } { continue } if { [catch {incr count($char.$i)}] } { set count(Y.$i) 0; set count(N.$i) 0; set count(S.$i) 0 - set count(U.$i) 0; set count(u.$i) 0 + set count(U.$i) 0; set count(u.$i) 0; set count(A.$i) 0 + set count(F.$i) 0 incr count($char.$i) } incr count($char.total) @@ -992,19 +1016,23 @@ proc CTscanLogDB { num file Y_lVar N_lVa } close $fileId removeStatus $num - CTputs $num "Prob #: #Y #N #S #U #u\n" + CTputs $num "Prob #: #Y #N #S #U #u #A #F\n" for { set i 0 } { $i < [llength $ans_char] } { incr i } { - CTputs $num [format " %2d: %6d %6d %6d %6d %6d\n" [expr $i + 1] \ - $count(Y.$i) $count(N.$i) $count(S.$i) $count(U.$i) $count(u.$i) ] + CTputs $num [format " %2d: %6d %6d %6d %6d %6d %6d %6d\n" [expr $i + 1] \ + $count(Y.$i) $count(N.$i) $count(S.$i) $count(U.$i) $count(u.$i) \ + $count(A.$i) $count(F.$i) ] } CTputs $num "===========================================\n" - CTputs $num [format " Total: %6d %6d %6d %6d %6d\n" $count(Y.total) $count(N.total) \ - $count(S.total) $count(U.total) $count(u.total) ] + CTputs $num [format " Total: %6d %6d %6d %6d %6d %6d %6d\n" $count(Y.total) \ + $count(N.total) $count(S.total) $count(U.total) $count(u.total) \ + $count(A.total) $count(F.total) ] set Y_l $count(Y.total) set N_l $count(N.total) set S_l $count(S.total) set U_l $count(U.total) set u_l $count(u.total) + set A_l $count(A.total) + set F_l $count(F.total) return } @@ -1483,11 +1511,11 @@ proc CTitemCorrelation { num classpath s updateStatusBar [expr {$line_cnt/double($maxLine)}] $num } if { $line_cnt == 2 } { - set aline [string trim $aline] + set aline [string trimright $aline] set weights [split $aline {}] } if { $line_cnt > 3} { - set aline [string trim $aline] + set aline [string trimright $aline] set data [string range $aline 10 end] set ans_str [lindex [split $data ","] 0] set ans_char_list [split $ans_str {} ] @@ -1548,9 +1576,10 @@ proc CTitemCorrelation { num classpath s close $fileId removeStatus $num # print out the correlation matrix -# parray sum_x -# parray sum_y -# parray prod_xy + #parray sum_x + #parray sum_y + #parray prod_xy + #puts $question_cnt CTputs $num " " for { set ii 1 } { $ii < $question_cnt } { incr ii } { CTputs $num [format " %2d" [expr {$ii+1}] ] @@ -2605,3 +2634,99 @@ proc CTcreateSubset { num cmdnum day set catch {unset answerArray} catch {unset exist} } + +########################################################### +# CTdiscussForum +########################################################### +########################################################### +########################################################### +proc CTdiscussForum { num file dir resultVar {specificSet 0}} { + global gCT + upvar $resultVar result + + if { $specificSet == 0 } { + set start 1 + } else { + set start $specificSet + } + set fileId [open $file r] + set maxLine [lindex [exec wc $file] 0] + set aline [gets $fileId] + set last 0 + set line_cnt 0 + while {![eof $fileId]} { + incr line_cnt + if { ($line_cnt%20) == 0 } { updateStatusBar [expr $line_cnt/double($maxLine)] $num } + foreach {stunum capaid name email action set prob date time} [split $aline "|"] {} + if {$specificSet && ($specificSet == $set)} {set aline [gets $fileId];continue} + if { $action == "ViewProblem" } { + if { [catch {incr count($set,$prob)}]} { + set count($set,$prob) 1 + if { $set > $last } { set last $set } + if { [catch {set max($set)}]} { set max($set) 0 } + if { $prob > $max($set)} { set max($set) $prob } + if { [catch {set posts($set,$prob) [llength [glob $dir/discussion/$set/[format "%06d" $prob]-*-*-*.msg]]}]} { set posts($set,$prob) 0 } + } + set ever($name) 1 + set names($set,$name) 1 + set nameprob($set,$prob,$name) 1 + } + set aline [gets $fileId] + } + + updateStatusMessage "Summarizing Data" $num + updateStatusBar 0 $num + for {set i 1} { $i <= $last } { incr i } { + updateStatusBar [expr $i/$last] $num + set total($i) 0 + for {set j 1} { $j <= $max($i) } { incr j } { + set message "" + if {[catch { set result($num.$i.$j.posts) $posts($i,$j) }]} { + set result($num.$i.$j.posts) 0 + } + if {[catch {set result($num.$i.$j.views) $count($i,$j)}]} { + set result($num.$i.$j.views) 0 + } + catch {incr total($i) $count($i,$j)} + if { [catch { set result($num.$i.$j.ratio) \ + [expr $result($num.$i.$j.views)/double($result($num.$i.$j.posts))]} error]} { + set result($num.$i.$j.ratio) 0.0 + } + set result($num.$i.$j.viewers) [llength [array names nameprob $i,$j,*]] + } + set result($num.$i.views) $total($i) + set result($num.$i.max) $max($i) + } + + for {set i 1} { $i<=$last } { incr i } { + set result($num.$i.viewers) [llength [array names names $i,*]] + } + close $fileId + set result($num.viewers) [llength [array names ever]] + set result($num.last) $last + #IDEAS: stick into capastats + # : howmany viws are repeats + # : Student Course Profile, add #ViewProblems #Posts + # : add some portion of these stats to analyze log files? +} + +########################################################### +# CTputsDiscussResults +########################################################### +########################################################### +proc CTputsDiscussResults { num resultsVar } { + upvar $resultsVar result + for {set i 1} { $i <= $result($num.last) } { incr i } { + CTputs $num "For Set $i #Visitors:$result($num.$i.viewers) did #views:$result($num.$i.views)\n" + CTputs $num "Prob# #Posts #Views Ratio #UniqueStu\n" + CTputs $num "------------------------------------\n" + for {set j 1} { $j <= $result($num.$i.max)} { incr j } { + CTputs $num [format "%5d %6d %6d %5s %6d\n" $j \ + $result($num.$i.$j.posts) $result($num.$i.$j.views) \ + [if {$result($num.$i.$j.ratio) == 0.0} {set temp " "} \ + {format %.1f $result($num.$i.$j.ratio)}] \ + $result($num.$i.$j.viewers)] + } + } + CTputs $num "Overall Unique #viewers: $result($num.viewers)\n" +} \ No newline at end of file