aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook_lib.tcl16
1 files changed, 15 insertions, 1 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 7ca586f..129a0ea 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -2330,11 +2330,25 @@ proc UpdateColumnGradesHistogram { columnname } {
set col_values [GetGroupValuesInColumn student $columnname]
set col_values [LeaveOnlyNumbersInList $col_values]
if { 0 != [llength $col_values] } {
- set maxVal [::math::statistics::max $col_values ]; # fixme should it be _Max_Points_?
set minVal 0
+ set maxVal [getMaxPointsForColumn $columnname ]
+ if { $minVal >= $maxVal } {
+ # most likely column has maximum points undefined or zero
+ # like for bonuses or fudge columns
+ set maxVal [::math::statistics::max $col_values ]; # fixme should it be _Max_Points_?
+ }
+ if { $minVal >= $maxVal } {
+ set errorMessage "something really messed up with column $columnname min and max points, applying kludge recovery."
+ htmlErrorMsg $errorMessage
+ dbg $errorMessage msg_level_critical [lindex [info level 0] 0]
+ # kludge/hack to make ::math::statistics::minmax-histogram-limits happy
+ set maxVal [expr {$minVal+1}]
+ }
set barsNum 10;
set uniqNum [llength [lsort -unique $col_values]]
set barsNum [expr {min($uniqNum, $barsNum)}]; # heuristic about number of bars/intervals
+ set barsNum [expr {max(2, $barsNum)}]; # at least 2 bars since we strip left and right
+
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 ]