aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook_lib.tcl35
1 files changed, 34 insertions, 1 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 4bc29e7..f2ef344 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -1897,13 +1897,46 @@ proc UpdateColumnLowestGrade { columnname } {
UpdateColValue4UserNameNonWeb $columnname _The_Lowest_Grade_ $val
}
-proc UpdateColumnStatistic { columnname } {
+proc UpdateGradesTableStatistic { permission_list user } {
+ set grades_categories [get_grades_category]
+
+ # remove unset and deleted categories from stats calculation
+ set grades_categories [lsearch -all -inline -not -exact $grades_categories unset]
+ set grades_categories [lsearch -all -inline -not -exact $grades_categories deleted]
+
+ set all_column_names [getColListFromTable GradesTable]
+
+ set columns_to_update {}
+ # select columns only with grades
+ foreach columnname $all_column_names {
+ set column_category [SelectColValue4User $columnname _Col_Category_]
+ if { $column_category in $grades_categories } {
+ lappend columns_to_update $columnname
+ }
+ }
+ # add column with totals for each grades category
+ foreach category $grades_categories {
+ lappend columns_to_update ${category}Total
+ }
+ lappend columns_to_update "Grand Total"
+
+ # update all of this columns
+ foreach columnname $columns_to_update {
+ set update_parent_flag false
+ UpdateColumnStatistic $columnname $update_parent_flag
+ }
+}
+
+proc UpdateColumnStatistic { columnname {update_parent_flag true} } {
set all_column_names [getColListFromTable GradesTable]
if { $columnname ni $all_column_names } {
return
}
UpdateColumnHighestGrade $columnname
UpdateColumnLowestGrade $columnname
+
+ # check recursion exit conditions
+ if { !$update_parent_flag } return
if { $columnname eq "Grand Total" } return
set column_category [SelectColValue4User $columnname _Col_Category_]