aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-03-23 12:22:54 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2011-03-23 12:22:54 -0400
commit9de40f614dff07d6bf8e99901bc8a5524b75db78 (patch)
tree5189bfb4aebd590955de7f4d1f8d09adb8d6b950
parentb2247665fce26e325f6fe3e7db47e7d3e0af6b62 (diff)
downloadGradeBook-9de40f614dff07d6bf8e99901bc8a5524b75db78.tar.gz
GradeBook-9de40f614dff07d6bf8e99901bc8a5524b75db78.zip
calculation of the weighted category count excuses now
Ignore-this: d3a00ee6a36e75d318ffec494fb520e9 darcs-hash:20110323162254-067c0-ffa19fa6c297666ce875320eb7c328266ae37e00.gz
-rwxr-xr-xGradeBook_lib.tcl56
1 files changed, 38 insertions, 18 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 7422457..00b16fa 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -98,6 +98,15 @@ proc findColumnNamesInCategory { category } {
return $all_col_in($category)
}
+proc getMaxPointsForColumn { col } {
+ set col_max [SelectColValue4User $col _Max_Points_]
+ if { $col_max eq "" } {
+ htmlInfoMsg "Column \{$col\} does not have Max Point value set"
+ set col_max 0
+ }
+ return $col_max
+}
+
proc calculteMaxPointsInCategory { category } {
set all_col_in($category) [ findColumnNamesInCategory $category ]
@@ -105,11 +114,7 @@ proc calculteMaxPointsInCategory { category } {
set max_points($category) 0
foreach col $all_col_in($category) {
- set col_max [SelectColValue4User $col _Max_Points_]
- if { $col_max eq "" } {
- htmlInfoMsg "Column \{$col\} does not have Max Point value set"
- set col_max 0
- }
+ set col_max [getMaxPointsForColumn $col ]
set max_points($category) [expr { $max_points($category) + $col_max }]
}
return [list $max_points($category) $col_number_in_category $all_col_in($category)]
@@ -117,25 +122,34 @@ proc calculteMaxPointsInCategory { category } {
proc calculteSumOfPointsForStudentInCategory { student category } {
set all_col_in($category) [ findColumnNamesInCategory $category ]
- set points_sum 0
+ set gained_points 0
+ set excused_points 0 ; # some assignment can be incomplete for a reasonable excuse (i.e. medical)
foreach col $all_col_in($category) {
set col_val [SelectColValue4User $col $student]
if { $col_val eq "" } {
set col_val 0
}
+ # special cases for grades which are not a number: excuses or other notes
if { ![string is double -strict $col_val] } {
- htmlInfoMsg "the cell in column $col contains $col_val which is not number, using 0 instead"
- set col_val 0
+ if { [regexp -nocase -- {excuse} $col_val] } {
+ # this grade will not be counted and maximum points for this student adjusted accordingly
+ set col_val 0
+ set excused_points [expr { $excused_points + [getMaxPointsForColumn $col]}]
+ } else {
+ htmlInfoMsg "the user $student has a grade $col_val in column $col, which is not a number. Using 0 instead"
+ set col_val 0
+ }
}
- set points_sum [expr { $points_sum + $col_val}]
+ set gained_points [expr { $gained_points + $col_val}]
}
- return $points_sum
+ set PointsSum(gained_points) $gained_points
+ set PointsSum(excused_points) $excused_points
+ return [array get PointsSum]
}
proc calculteWeightedTotals { } {
global grades_category
set all_column_names [getColListFromTable GradesTable]
- calculteMaxPointsInCategory sss
# locate all column names of this category
foreach category $grades_category {
@@ -162,10 +176,13 @@ proc calculteWeightedTotals { } {
set students_list [ allUserNamesInGroup student ]
set students_list [concat $students_list [ allUserNamesInGroup dropped ] ]
foreach student $students_list {
- set points_sum($category,$student) [ calculteSumOfPointsForStudentInCategory $student $category ]
- if { $max_points($category) != 0 } {
+ array set PointsSum [ calculteSumOfPointsForStudentInCategory $student $category ]
+ set points_sum($category,$student) $PointsSum(gained_points)
+ set excused_points($category,$student) $PointsSum(excused_points)
+ set max_points($category,$student) [expr { $max_points($category) - $excused_points($category,$student)}]
+ if { $max_points($category,$student) != 0 } {
# normalizing
- set points_sum($category,$student) [expr { 1. * $points_sum($category,$student) / $max_points($category) } ]
+ set points_sum($category,$student) [expr { 1. * $points_sum($category,$student) / $max_points($category,$student) } ]
}
UpdateColValue4UserNameNonWeb $CategoryWeightedTolalName $student $points_sum($category,$student)
}
@@ -187,13 +204,16 @@ proc calculteWeightedTotals { } {
set max_points($category) [lindex $tmpList 0]
}
if { ![info exist points_sum($category,$student)] } {
- set points_sum($category,$student) [ calculteSumOfPointsForStudentInCategory $student $category ]
- if { $max_points($category) != 0 } {
+ array set PointsSum [ calculteSumOfPointsForStudentInCategory $student $category ]
+ set points_sum($category,$student) $PointsSum(gained_points)
+ set excused_points($category,$student) $PointsSum(excused_points)
+ set max_points($category,$student) [expr { $max_points($category) - $excused_points($category,$student)}]
+ if { $max_points($category,$student) != 0 } {
# normalizing
- set points_sum($category,$student) [expr { 1. * $points_sum($category,$student) / $max_points($category) } ]
+ set points_sum($category,$student) [expr { 1. * $points_sum($category,$student) / $max_points($category,$student) } ]
}
}
- if { $max_points($category) == 0} {
+ if { $max_points($category,$student) == 0} {
dbg "Category: $category has 0 for total maximum points. Skipping it." 4
continue
}