diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-05-03 23:50:24 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-05-03 23:50:24 -0400 |
commit | a22a734d8485a3d85ed8a7a99c1f984bfc01b669 (patch) | |
tree | c013a3755f14703a2051610f90ce0e569208babf /GradeBook_lib.tcl | |
parent | b0016e4ee75297737b1fcd9cac4beb9842e717c5 (diff) | |
download | GradeBook-a22a734d8485a3d85ed8a7a99c1f984bfc01b669.tar.gz GradeBook-a22a734d8485a3d85ed8a7a99c1f984bfc01b669.zip |
added grading scheme and its output in Grand Total column
Ignore-this: 257eae3ee3ee011565ba68e2044606a3
darcs-hash:20110504035024-067c0-0f636633ef4628114b2554242dca771049eeee5c.gz
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 749bcba..5174e85 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -20,6 +20,27 @@ array set GradebookServerConfig [list \ # ######################################################################## # ########################## procs begin ################################# + +proc get_grading_scheme {} { + # pair of letter grade and lower boundary for this grade + # should be sorted in descended order! + set grading_scheme [ list \ + A 0.94 \ + A- 0.90 \ + B+ 0.87 \ + B 0.84 \ + B- 0.80 \ + C+ 0.77 \ + C 0.74 \ + C- 0.70 \ + D+ 0.67 \ + D 0.64 \ + D- 0.60 \ + F 0.00 \ + ] + return $grading_scheme +} + # Grades category and their html names proc get_grades_category {} { set eval_str "SELECT CategoryName FROM GradesCategoryTable" @@ -642,6 +663,18 @@ proc action2atributes { action_name } { return $attrib } +proc number2letter_grade { num } { + # grading_scheme MUST be sorted in descending order! + set grading_scheme [get_grading_scheme] + foreach {letter threshold} $grading_scheme { + if { $num >= $threshold } { + return $letter + } + } + # should never reach this point if grading scheme set properly + return "NA" +} + proc htmlDBout {db permission_list user {sort_col {}}} { array set permission $permission_list global GradebookServerConfig @@ -847,9 +880,16 @@ proc htmlDBout {db permission_list user {sort_col {}}} { if { $col_value eq "" } { set col_value 0 } + # calculate letter grade to Grand Total + if { $index eq "Grand Total" } { + set col_value_letter_grade [number2letter_grade $col_value] + } # promote to percent format - set col_value [format "%.1f" [expr {100.* $col_value} ] ] - set col_value [concat $col_value "%"] + set col_value [format "%04.1f%%" [expr {100.* $col_value} ] ] + # add letter grade to Grand Total + if { $index eq "Grand Total" } { + set col_value [ concat $col_value "=" $col_value_letter_grade ] + } } set col_value [htmlReplaceEmptyString $col_value] switch $index { |