diff options
-rwxr-xr-x | GradeBook_lib.tcl | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 073ac60..efb5f92 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -162,16 +162,43 @@ proc calculteWeightedTotals { } { set students_list [ allUserNamesInGroup student ] set students_list [concat $students_list [ allUserNamesInGroup dropped ] ] foreach student $students_list { - set points_sum [ calculteSumOfPointsForStudentInCategory $student $category ] + set points_sum($category,$student) [ calculteSumOfPointsForStudentInCategory $student $category ] if { $max_points($category) != 0 } { # normalizing - set points_sum [expr { 1. * $points_sum / $max_points($category) } ] + set points_sum($category,$student) [expr { 1. * $points_sum($category,$student) / $max_points($category) } ] } - UpdateColValue4UserNameNonWeb $CategoryWeightedTolalName $student $points_sum + UpdateColValue4UserNameNonWeb $CategoryWeightedTolalName $student $points_sum($category,$student) } } } } + + # now calculation of weighted grand total + set grand_total_col_name "Grand Total" + if { $grand_total_col_name ni $all_column_names } { + dbg "Column $grand_total_col_name does not exist, will create it now" 1 + AddColumnNonWeb $grand_total_col_name weighted_column 0 + } + foreach student $students_list { + set grand_total($student) 0 + foreach {category weight} [getGradingWeights] { + if { ![info exist max_points($category)] } { + set tmpList [ calculteMaxPointsInCategory $category ] + set max_points($category) [lindex $tmpList 0] + } + if { $max_points($category) == 0} { + dbg "Category: $category has 0 for total maximum points. Skipping it." 4 + continue + } + set grand_total($student) [ expr { $grand_total($student) + $weight*$points_sum($category,$student) } ] + } + UpdateColValue4UserNameNonWeb $grand_total_col_name $student $grand_total($student) + } + set max_weighted_sum 0 + foreach {category weight} [getGradingWeights] { + set max_weighted_sum [ expr {$max_weighted_sum +$weight} ] + } + UpdateColValue4UserNameNonWeb $grand_total_col_name _Max_Points_ $max_weighted_sum } proc grade_Category2html_name { category } { |