aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-04-15 21:17:24 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2011-04-15 21:17:24 -0400
commitf34d180b567b3537fc31dc02441749c61f423b4b (patch)
tree5dbf3475f092080cbf3d2291898819e78dab2a66
parente1f40958894955957fa3c8d0c2039c087d14fec4 (diff)
downloadGradeBook-f34d180b567b3537fc31dc02441749c61f423b4b.tar.gz
GradeBook-f34d180b567b3537fc31dc02441749c61f423b4b.zip
weighted column properly respond to GradesCategoryTable valuesv1.5.0
Ignore-this: 5500855bf4c4488ab0ffa5cc0ebe1b7f darcs-hash:20110416011724-067c0-c8aaee1dde04ef19026cd6813a2813b8ef459516.gz
-rwxr-xr-xGradeBook_lib.tcl21
1 files changed, 18 insertions, 3 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 24df524..b0dd7db 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -156,8 +156,13 @@ proc calculteWeightedTotals { } {
global grades_category
set all_column_names [getColListFromTable GradesTable]
+ set students_list [ allUserNamesInGroup student ]
+ set students_list [concat $students_list [ allUserNamesInGroup dropped ] ]
+
# locate all column names of this category
foreach category $grades_category {
+ set flag_delete_CategoryWeightedTolal false
+ set CategoryWeightedTolalName ${category}Total
if { [isCalculateTotalForCategorySet $category] } {
set all_col_in($category) [ findColumnNamesInCategory $category ]
@@ -165,7 +170,6 @@ proc calculteWeightedTotals { } {
set max_points($category) [lindex $tmpList 0]
set num_of_cols($category) [lindex $tmpList 1]
- set CategoryWeightedTolalName ${category}Total
if { $num_of_cols($category) >= 2 } {
# no weighted total column created for categories which do no have at least 2 columns
# check if Weighted Category Column exists
@@ -173,13 +177,13 @@ proc calculteWeightedTotals { } {
dbg "Column $CategoryWeightedTolalName does not exist, will create it now" 1
AddColumnNonWeb $CategoryWeightedTolalName weighted_column 0
}
+ } else {
+ set flag_delete_CategoryWeightedTolal true
}
if { [doesColumnExists $CategoryWeightedTolalName GradesTable] } {
UpdateColValue4UserNameNonWeb $CategoryWeightedTolalName _Max_Points_ $max_points($category)
# calculated weighted sum for each student in this category
- set students_list [ allUserNamesInGroup student ]
- set students_list [concat $students_list [ allUserNamesInGroup dropped ] ]
foreach student $students_list {
array set PointsSum [ calculteSumOfPointsForStudentInCategory $student $category ]
set points_sum($category,$student) $PointsSum(gained_points)
@@ -192,6 +196,11 @@ proc calculteWeightedTotals { } {
UpdateColValue4UserNameNonWeb $CategoryWeightedTolalName $student $points_sum($category,$student)
}
}
+ } else {
+ set flag_delete_CategoryWeightedTolal true
+ }
+ if { $flag_delete_CategoryWeightedTolal && ([doesColumnExists $CategoryWeightedTolalName GradesTable]) } {
+ DeleteColumnFromTable GradesTable $CategoryWeightedTolalName
}
}
@@ -412,6 +421,8 @@ proc UpdateGradesCategores { db permission_list user } {
if { [info exist colval($v(CategoryName)_needs_total)] } {
# check box existance means it set to true
ModifyNeedsTotalForGradesCategory db $v(CategoryName) true
+ } else {
+ ModifyNeedsTotalForGradesCategory db $v(CategoryName) false
}
}
} errStat ]
@@ -1478,6 +1489,10 @@ proc AddColumnNonWeb { columnname2add column_category maxpointpossible {sql_type
UpdateColValue4UserNameNonWeb $columnname2add _Col_Category_ $column_category
UpdateColValue4UserNameNonWeb $columnname2add _Max_Points_ $maxpointpossible
+
+ if { $column_category ne "weighted_column" } {
+ calculteWeightedTotals
+ }
} else {
htmlErrorMsg "empty column names are not permitted"
}