aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2014-03-29 17:27:07 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2014-03-29 17:27:07 -0400
commitecbce6b0b728ef8347b1696bc8a6c8321bc0e1ca (patch)
treefe4d32fc087681ea8095e1fab2ed37bae0944cdb
parent2a1dc4271f052d91d095a8845a4e9bd7413a320f (diff)
downloadGradeBook-ecbce6b0b728ef8347b1696bc8a6c8321bc0e1ca.tar.gz
GradeBook-ecbce6b0b728ef8347b1696bc8a6c8321bc0e1ca.zip
Added update of statistics for the whole table
-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_]