From 1d9b9ddaf7e76a625105d791c4d88a246f4407de Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Mon, 2 May 2011 23:05:05 -0400 Subject: adeed proc to pull grades categories from the DB and use along the lib Ignore-this: 966901270828decd00b5cb38184ea4eb darcs-hash:20110503030505-067c0-61d278fe9ca574f5c90b9d0b0bfe29edc26341a5.gz --- GradeBook_lib.tcl | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'GradeBook_lib.tcl') diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 92df017..373159e 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -11,22 +11,40 @@ source ./libBasicTableOperations.tcl # internal version of this code set VERSION 1.5.1 -# Grades category and their html names -set grades_category [list \ - "unset"\ - Quiz\ - HomeWork\ - LabReport\ - MidTerm\ - FinalExam\ - ] - +# ######################################################################## +# this should be in config file array set GradebookServerConfig [list \ icon_dir "/~evmik/icons" \ use_icons true \ ] +# ######################################################################## # ########################## procs begin ################################# +# Grades category and their html names +proc get_grades_category {} { + set eval_str "SELECT CategoryName FROM GradesCategoryTable" + set grades_category {} + set err [catch { + db eval $eval_str v { + lappend grades_category $v(CategoryName) + } + } errStat ] + if { $err } { + htmlErrorMsg $errStat + dbg "the following error happen: $errStat" 3 + } + #set grades_category [list \ + #"unset"\ + #Quiz\ + #HomeWork\ + #LabReport\ + #MidTerm\ + #FinalExam\ + #] + return $grades_category +} + + proc default_grades_category {} { set grades_category [list \ "unset"\ @@ -156,7 +174,8 @@ proc calculteSumOfPointsForStudentInCategory { student category } { } proc calculteWeightedTotals { } { - global grades_category + set grades_category [ get_grades_category ] + #global grades_category set all_column_names [getColListFromTable GradesTable] set students_list [ allUserNamesInGroup student ] @@ -627,7 +646,8 @@ proc htmlDBout {db permission_list user {sort_col {}}} { array set permission $permission_list global GradebookServerConfig global script_name - global grades_category + #global grades_category + set grades_category [ get_grades_category ] set defSortCol LastName if { $sort_col == {} } { @@ -1304,7 +1324,8 @@ proc ChangeColumn { permission_list user } { set category "unset" set category [SelectColValue4User $columnname _Col_Category_] set maxpoints [SelectColValue4User $columnname _Max_Points_] - global grades_category + #global grades_category + set grades_category [ get_grades_category ] puts {
} puts "
" @@ -1545,7 +1566,8 @@ proc AddColumn { permission_list user } { proc AddColumnRequest { permission_list user } { global script_name - global grades_category + #global grades_category + set grades_category [ get_grades_category ] puts {
} puts "" puts {Column Name:
} @@ -1568,7 +1590,8 @@ proc AddColumnRequest { permission_list user } { proc ShowControls { permission_list user } { array set permission $permission_list global script_name - global grades_category + #global grades_category + set grades_category [ get_grades_category ] dbg "outputing contol list" puts "
" set action_list [ list \ -- cgit v1.2.3