aboutsummaryrefslogtreecommitdiff
path: root/GradeBook_lib.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'GradeBook_lib.tcl')
-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"
}