summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook_lib.tcl44
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 {