aboutsummaryrefslogtreecommitdiff
path: root/GradeBook_lib.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2013-12-08 18:36:00 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2013-12-08 18:36:00 -0500
commit6480a208f52afd02cbfe18fed68b294273ac777a (patch)
tree2d08eeceaac850b0f421f2969befc91fe127bbea /GradeBook_lib.tcl
parent6a2d55ceb7bdc1df307aaaca6acfb8f9216cc1cd (diff)
downloadGradeBook-6480a208f52afd02cbfe18fed68b294273ac777a.tar.gz
GradeBook-6480a208f52afd02cbfe18fed68b294273ac777a.zip
number of points for a students calculated with taking in account the lowest dropped
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-xGradeBook_lib.tcl42
1 files changed, 35 insertions, 7 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index dff6624..d2c4fc5 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -254,29 +254,57 @@ proc dropTheLowestGrades {num_to_drop grades grades_max_possible} {
}
proc calculteSumOfPointsForStudentInCategory { student category } {
- set all_col_in($category) [ findColumnNamesInCategory $category ]
+ # these will be sum of students gains and max possible
set gained_points 0
- set excused_points 0 ; # some assignment can be incomplete for a reasonable excuse (i.e. medical)
+ set max_points 0 ;
+ # some assignment can be incomplete for a reasonable excuse (i.e. medical)
+ # alternatively if the category has a flag of drop the lowest score it will be counted
+ # as excused points as well
+ set num_of_excuses 0
+
+ # these will contain values from not excused points
+ set list_col_val {}
+ set list_col_max {}
+
+ # create the list of grades and respective maximums
+ # but exclude excused grades from calculations
+ set all_col_in($category) [ findColumnNamesInCategory $category ]
foreach col $all_col_in($category) {
set col_val [SelectColValue4User $col $student]
+ set col_max_possible [getMaxPointsForColumn $col]
if { $col_val eq "" } {
set col_val 0
}
# special cases for grades which are not a number: excuses or other notes
+ set isItExcuse false
if { ![string is double -strict $col_val] } {
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]}]
+ set isItExcuse true
+ incr num_of_excuses
} 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
- }
+ }
+ }
+ if { !$isItExcuse } {
+ lappend list_col_val $col_val
+ lappend list_col_max $col_max_possible
}
- set gained_points [expr { $gained_points + $col_val}]
}
- set PointsSum(gained_points) $gained_points
- set PointsSum(excused_points) $excused_points
+ dbg "num of excuses for student $student in category $category: $num_of_excuses" msg_level_critical
+ dbg "col vals for student $student in category $category: $list_col_val" msg_level_critical
+ dbg "col maxs for student $student in category $category: $list_col_max" msg_level_critical
+
+ set num_of_the_lowest_grades_to_drop [howManyGradesToDropForCategorySet $category]
+ # excused points are counted towards lowest grades to be dropped
+ set num_of_the_lowest_grades_to_drop [expr {$num_of_the_lowest_grades_to_drop - $num_of_excuses}]
+ # note the following procedure is smart to not drop negative number of grades
+ # and additionally counts the sum
+ set ret [dropTheLowestGrades $num_of_the_lowest_grades_to_drop $list_col_val $list_col_max]
+ set PointsSum(gained_points) [lindex $ret 0]
+ set PointsSum(max_points) [lindex $ret 1]
return [array get PointsSum]
}