From 4da4c10870e6da4a17112c88e434d6cbdaa1f835 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 28 Mar 2014 22:16:41 -0400 Subject: added update of high/low for parent category and Grand Total --- GradeBook_lib.tcl | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'GradeBook_lib.tcl') diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index c9581f7..49bed90 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -1855,6 +1855,13 @@ proc UpdateColumnHighestGrade { columnname } { set val [expr max([join $col_values ,])] } CheckAndCreateAsNeededInfoRow _The_Highest_Grade_ + + set column_category [SelectColValue4User $columnname _Col_Category_] + if { $column_category eq "weighted_column" } { + #convert val to percent for weighted_column + set val [format "%04.2f%%" [expr {100.* $val} ] ] + } + UpdateColValue4UserNameNonWeb $columnname _The_Highest_Grade_ $val } @@ -1867,9 +1874,34 @@ proc UpdateColumnLowestGrade { columnname } { set val [expr min([join $col_values ,])] } CheckAndCreateAsNeededInfoRow _The_Lowest_Grade_ + + set column_category [SelectColValue4User $columnname _Col_Category_] + if { $column_category eq "weighted_column" } { + #convert val to percent for weighted_column + set val [format "%04.2f%%" [expr {100.* $val} ] ] + } + UpdateColValue4UserNameNonWeb $columnname _The_Lowest_Grade_ $val } +proc UpdateHighLowForColumn { columnname } { + set all_column_names [getColListFromTable GradesTable] + if { $columnname ni $all_column_names } { + return + } + UpdateColumnHighestGrade $columnname + UpdateColumnLowestGrade $columnname + if { $columnname eq "Grand Total" } return + + set column_category [SelectColValue4User $columnname _Col_Category_] + if { $column_category ne "weighted_column" } { + set root_category_column ${column_category}Total + } else { + set root_category_column "Grand Total" + } + UpdateHighLowForColumn $root_category_column +} + proc UpdateGrades { permission_list user } { global script_name set subaction [::ncgi::value subaction {}] @@ -1892,11 +1924,9 @@ proc UpdateGrades { permission_list user } { dbg "the following error happen: $errStat" msg_level_critical } else { calculteWeightedTotals - UpdateColumnHighestGrade $columnname - UpdateColumnLowestGrade $columnname + UpdateHighLowForColumn $columnname } } - } proc ChangeGrades { permission_list user } { -- cgit v1.2.3