aboutsummaryrefslogtreecommitdiff
path: root/GradeBook_lib.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-03-11 12:48:30 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2011-03-11 12:48:30 -0500
commit587555f2ae5d10c11a70086a5429d9e7c9a684fc (patch)
tree579bfcbd9abe966ac4f338005a1f4e230b1c6659 /GradeBook_lib.tcl
parent767b9d5f263db37161e3f828eda4f02e70d8d783 (diff)
downloadGradeBook-587555f2ae5d10c11a70086a5429d9e7c9a684fc.tar.gz
GradeBook-587555f2ae5d10c11a70086a5429d9e7c9a684fc.zip
added gran total calculation
Ignore-this: f708e156d5edf108bfa08ed561b12f96 darcs-hash:20110311174830-067c0-252c0efab06334fea2ed924c3e47dd10ea56cd66.gz
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-xGradeBook_lib.tcl33
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 } {