From f650fc5d56b6d7c82b0d9d11dd1f1de14718caa6 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 10 May 2018 00:21:02 -0400 Subject: added grade histogram calculation --- GradeBook_lib.tcl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 6715a1f..f2b87cf 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -2288,6 +2288,29 @@ proc GetGroupValuesInColumn { group_name columnname } { return $col_values } +proc UpdateAndCreateAsNeededInfoRow { columnname inforow val } { + CheckAndCreateAsNeededInfoRow $inforow + UpdateColValue4UserNameNonWeb $columnname $inforow $val +} + +proc UpdateColumnGradesHistogram { columnname } { + # find maximum in the column with a given name among active students + set hist "N/A" + set limits "N/A" + 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 barsNum 5; + 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 +} + proc UpdateColumnHighestGrade { columnname } { # find maximum in the column with a given name among active students set val "N/A" @@ -2411,11 +2434,13 @@ proc UpdateColumnStatistic { columnname {update_parent_flag true} } { return } begin_db_transaction + # FIXME all updates pull the same data. Cache it and reuse UpdateColumnHighestGrade $columnname UpdateColumnLowestGrade $columnname UpdateColumnMeanGrade $columnname UpdateColumnMedianGrade $columnname UpdateColumnStDevGrade $columnname + UpdateColumnGradesHistogram $columnname end_db_transaction # check recursion exit conditions -- cgit v1.2.3