diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2018-05-10 22:00:12 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2018-05-10 22:22:52 -0400 |
commit | b4bd0ea48da3db6937b91b14dd894022dc4e7e1e (patch) | |
tree | 3cd28fcfdeb4bc2fad2a42b586c466124e61a237 /GradeBook_lib.tcl | |
parent | d2407136249bd574189f9d9e3eb0e2fe07dc1d5c (diff) | |
download | GradeBook-b4bd0ea48da3db6937b91b14dd894022dc4e7e1e.tar.gz GradeBook-b4bd0ea48da3db6937b91b14dd894022dc4e7e1e.zip |
more conner cases covering in histogram generation
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 16 |
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 ] |