aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook_lib.tcl21
1 files changed, 20 insertions, 1 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 45bb025..52bb0bd 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -2295,6 +2295,24 @@ proc UpdateAndCreateAsNeededInfoRow { columnname inforow val } {
UpdateColValue4UserNameNonWeb $columnname $inforow $val
}
+proc data2txtPlot { data } {
+ set maxVal [::math::statistics::max $data ]
+ set minVal [::math::statistics::min $data ]
+ set diffVal [expr {$maxVal-$minVal}]
+ if { $diffVal == 0 } {
+ set diffVal 1
+ }
+ set chars {▁ ▂ ▃ ▄ ▅ ▆ ▇ █}; # 8 bars
+ set barsNum 8;
+ foreach x $data {
+ # funky 1.1 are needed to convert it to floats
+ set cnt [expr { round((1.0*$x-$minVal)/(1.1*$diffVal)*(1.1*($barsNum-1.0))) }]
+ set bar [lrange $chars $cnt $cnt]
+ lappend strPlot $bar
+ }
+ return [join $strPlot ""]
+}
+
proc UpdateColumnGradesHistogram { columnname } {
# find maximum in the column with a given name among active students
set hist "N/A"
@@ -2304,13 +2322,14 @@ proc UpdateColumnGradesHistogram { columnname } {
if { 0 != [llength $col_values] } {
set maxVal [::math::statistics::max $col_values ]; # fixme should it be _Max_Points_?
set minVal 0
- set barsNum 5;
+ set barsNum 10;
set limits [::math::statistics::minmax-histogram-limits $minVal $maxVal [incr barsNum]]
set limits [lrange $limits 1 end-1]; # shave first and last interval limits
set hist [::math::statistics::histogram $limits $col_values ]
}
UpdateAndCreateAsNeededInfoRow $columnname _The_Grades_Histogram_ $hist
UpdateAndCreateAsNeededInfoRow $columnname _The_Grades_Hist_Limits_ $limits
+ UpdateAndCreateAsNeededInfoRow $columnname _The_Grades_Hist_Text_Plot_ [data2txtPlot $hist]
}
proc UpdateColumnHighestGrade { columnname } {