From f34d180b567b3537fc31dc02441749c61f423b4b Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 15 Apr 2011 21:17:24 -0400 Subject: weighted column properly respond to GradesCategoryTable values Ignore-this: 5500855bf4c4488ab0ffa5cc0ebe1b7f darcs-hash:20110416011724-067c0-c8aaee1dde04ef19026cd6813a2813b8ef459516.gz --- GradeBook_lib.tcl | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'GradeBook_lib.tcl') 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" } -- cgit v1.2.3