aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2018-05-09 11:22:56 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2018-05-09 11:22:56 -0400
commit0e1ac4ebba97e9fbb049848ae36491e8a7d4fa1b (patch)
tree0eb8b4ecde5c99fe421f233afaba7b56a668cb48
parent13a3bdd44d13de17834a3d85488baba5271695ec (diff)
downloadGradeBook-0e1ac4ebba97e9fbb049848ae36491e8a7d4fa1b.tar.gz
GradeBook-0e1ac4ebba97e9fbb049848ae36491e8a7d4fa1b.zip
we can modify letter grading scheme \o/
-rwxr-xr-xGradeBook_lib.tcl76
1 files changed, 66 insertions, 10 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 702a2df..6715a1f 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -95,6 +95,68 @@ proc get_grading_scheme {} {
return $grading_scheme
}
+proc htmlEditLetterGradeRequest { permission_list user } {
+ global script_name
+ puts {<div class="edit_letter_grade">}
+ puts {<p>}
+ puts {Assigning normalized to 1 cutoffs for letter grades.}
+ puts {</p>}
+ puts {<p>}
+ puts {If you want to disable "A+" make cutoff significantly higher than 1.}
+ puts {</p>}
+ puts {<p>}
+ puts {For example, "A-" = 0.9 and "A" = 0.94 means that a student with score in the range [0.9, 0.94) gets "A-", and any score >= 0.94 gets "A".}
+ puts {</p>}
+ puts {<div class="grading_scheme">}
+ puts "<form name=\"input\" action=\"$script_name\" method=\"post\" >"
+
+ # table header
+ puts {<table class="grading_scheme_table" border="1">}
+ puts "<tr>"
+ foreach col {Letter Cutoff} {
+ puts -nonewline "<th>$col</th>"
+ }
+ puts "</tr>"
+ # the rest of the table
+ foreach {letter cutoff} [get_grading_scheme] {
+ puts "<tr>"
+ puts -nonewline "<td>$letter</td>"
+ # column with cutoff
+ puts "<th><input type=\"text\" name=\"$letter\" value=\"$cutoff\" size=5></th>"
+ puts "</tr>"
+ }
+ puts "</table>"
+ puts {<input type="hidden" name="action" value="edit_letter_grade"/>}
+ puts {<input type="submit" name="subaction" value="Submit" />}
+ puts {<input type="submit" name="subaction" value="Cancel" />}
+ puts {</form>}
+ puts {</div>}
+ puts {</div>}
+}
+
+proc EditLetterGrade { permission_list user } {
+ global script_name
+ set subaction [::ncgi::value subaction {}]
+ set nv [::ncgi::nvlist]
+ array set colval $nv
+ if { $subaction eq "Submit" } {
+ begin_db_transaction
+ set eval_str [concat SELECT LetterGrade FROM GradingSchemeTable]
+ set err [catch {
+ db eval $eval_str v {
+ if { [info exist colval($v(LetterGrade))] } {
+ UpdateColumnWithValueInTableWhere GradingSchemeTable LowerCutoff $colval($v(LetterGrade)) LetterGrade $v(LetterGrade)
+ }
+ }
+ } errStat ]
+ end_db_transaction
+ if { $err } {
+ htmlErrorMsg $errStat
+ dbg "$errStat for $eval_str" msg_level_critical [lindex [info level 0] 0]
+ }
+ }
+}
+
# Grades category and their html names
proc get_grades_category {} {
set eval_str "SELECT CategoryName FROM GradesCategoryTable"
@@ -119,7 +181,6 @@ proc get_grades_category {} {
return $grades_category
}
-
proc default_grades_category {} {
set grades_category [list \
"unset"\
@@ -133,7 +194,7 @@ proc default_grades_category {} {
]
return $grades_category
}
-
+
proc getGradingWeights { } {
set category_name_weight_list {}
set eval_str [concat SELECT CategoryName,CategoryWeight FROM GradesCategoryTable]
@@ -1779,7 +1840,9 @@ proc ChoseAction {action permission_list user} {
htmlDefaultView $permission_list $user }
update_grades_stats { UpdateGradesTableStatistic $permission_list $user
htmlDefaultView $permission_list $user }
- edit_letter_grade_request { EditLetterGradeRequest $permission_list $user }
+ edit_letter_grade_request { htmlEditLetterGradeRequest $permission_list $user }
+ edit_letter_grade { EditLetterGrade $permission_list $user
+ htmlDefaultView $permission_list $user }
edit_user_grade_request { htmlEditUserGradeValue $permission_list $user }
edit_user_grade { EditUserGradeValue $permission_list $user
htmlDefaultView $permission_list $user }
@@ -2310,13 +2373,6 @@ proc UpdateColumnStDevGrade { columnname } {
UpdateColValue4UserNameNonWeb $columnname _The_StDev_Grade_ $val
}
-proc EditLetterGradeRequest { permission_list user } {
- foreach {letter cutoff} [get_default_grading_scheme] {
- # fixme
- htmlErrorMsg "$letter $cutoff"
- }
-}
-
proc UpdateGradesTableStatistic { permission_list user } {
set grades_categories [get_grades_category]