From b4bd0ea48da3db6937b91b14dd894022dc4e7e1e Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 10 May 2018 22:00:12 -0400 Subject: more conner cases covering in histogram generation --- GradeBook_lib.tcl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 ] -- cgit v1.2.3