From 223cc32442432c125e71c6204492f0bf0755cb8d Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Sun, 6 Mar 2011 15:07:40 -0500 Subject: grades category match to its htmls name automatically Ignore-this: 44290dbfe92d2d67b1bc4379a1d1c873 darcs-hash:20110306200740-067c0-2b07184729d67b679103b9a6db3f21f2f60398ff.gz --- GradeBook_lib.tcl | 68 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'GradeBook_lib.tcl') diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index d04d00e..2031dd6 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -6,7 +6,31 @@ exec tclsh "$0" "$@" # require Tcl version of at least 8.5 since I use 'ni' and 'in' in expressions for lists package require Tcl 8.5 # internal version of this code -set VERSION 1.1.2 +set VERSION 1.1.3 + +# Grades category and their html names +set grades_category [list \ + "unset"\ + Quiz\ + HomeWork\ + LabReport\ + MidTerm\ + FinalExam\ + ] + +proc grade_Category2html_name { category } { + switch $category { + "unset" {set html_name --Select--} + Quiz {set html_name Quiz} + HomeWork {set html_name HomeWork} + LabReport {set html_name LabReport} + MidTerm {set html_name MidTerm} + FinalExam {set html_name FinalExam} + default {set html_name unknown} + } + return $html_name +} + # ########################## procs begin ################################# proc dbg {msg {level 1}} { @@ -167,6 +191,7 @@ proc htmlReplaceEmptyString { string } { proc htmlDBout {db permission_list user {sort_col {}}} { array set permission $permission_list global script_name + global grades_category set defSortCol LastName if { $sort_col == {} } { @@ -228,16 +253,13 @@ proc htmlDBout {db permission_list user {sort_col {}}} { default { dbg "Default must not be allowed to set table view port. Aborting. This line is never executed." 0; exit } } if { $sql_column_str ne "" } { - switch [SelectColValue4User $sort_col _Col_Category_] { - Quiz { set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] } - LabReport { set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] } - HomeWork { set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] } - MidTerm { set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] } - FinalExam { set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] } - FinalExam { set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] } - default { set ordered_by_str \"$sort_col\" } + # assign type cast for different sort_col + if { [SelectColValue4User $sort_col _Col_Category_] in $grades_category } { + set ordered_by_str [concat CAST(\"$sort_col\" AS REAL)] + } else { + set ordered_by_str \"$sort_col\" } - # get all allowed columns and rows + r get all allowed columns and rows set eval_str [concat SELECT $sql_column_str FROM GradesTable $where_statement ORDER BY $ordered_by_str] set err [catch { db eval $eval_str v { @@ -765,6 +787,7 @@ proc ChangeColumn { permission_list user } { set category "unset" set category [SelectColValue4User $columnname _Col_Category_] set maxpoints [SelectColValue4User $columnname _Max_Points_] + global grades_category puts {
} puts "
" @@ -774,16 +797,8 @@ proc ChangeColumn { permission_list user } { set out_str {} append out_str {Category:
} puts {Category:
} puts {Max Point Possible:
} puts {} -- cgit v1.2.3