diff options
-rwxr-xr-x | GradeBook_lib.tcl | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 436f6bc..e9807db 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -35,7 +35,7 @@ proc get_list_of_courses_db {} { return $db_files_list } -proc get_grading_scheme {} { +proc get_default_grading_scheme {} { # pair of letter grade and lower boundary for this grade # should be sorted in descended order! set grading_scheme [ list \ @@ -55,6 +55,45 @@ proc get_grading_scheme {} { return $grading_scheme } +proc CreateGradingSchemeTable {db} { + begin_db_transaction + set err [catch {db eval {CREATE TABLE GradingSchemeTable(LetterGrade text, LowerCutoff real)} } errStat] + if { $err } { + htmlErrorMsg $errStat + dbg "Could not create GradingSchemeTable: $errStat" msg_level_critical [lindex [info level 0] 0] + end_db_transaction; return + } + foreach {letter cutoff} [get_default_grading_scheme] { + set eval_str [concat INSERT INTO GradingSchemeTable (LetterGrade, LowerCutoff) VALUES('$letter', '$cutoff')] + set err [catch {db eval $eval_str } errStat] + if { $err } { + htmlErrorMsg $errStat + dbg "$errStat for $eval_str" msg_level_critical [lindex [info level 0] 0] + } + } + end_db_transaction +} + +proc get_grading_scheme {} { + set grading_scheme {} + set eval_str [concat SELECT LetterGrade,LowerCutoff FROM GradingSchemeTable] + set err [catch { + db eval $eval_str v { + lappend grading_scheme $v(LetterGrade) $v(LowerCutoff) + } + } errStat ] + if { $err } { + set grading_scheme [get_default_grading_scheme] + if { $errStat eq "no such table: GradingSchemeTable" } { + CreateGradingSchemeTable db + } else { + htmlErrorMsg $errStat + dbg "$errStat" msg_level_critical [lindex [info level 0] 0] + } + } + return $grading_scheme +} + # Grades category and their html names proc get_grades_category {} { set eval_str "SELECT CategoryName FROM GradesCategoryTable" @@ -858,6 +897,8 @@ proc FillDefaultAccessRights {} { AddDefaultAccessRight update_grades_stats 1 0 0 0 0 AddDefaultAccessRight edit_user_grade_request 1 1 0 0 0 AddDefaultAccessRight edit_user_grade 1 1 0 0 0 + AddDefaultAccessRight edit_letter_grade_request 1 0 0 0 0 + AddDefaultAccessRight edit_letter_grade 1 0 0 0 0 } proc getDefaultPermissionsForGroup { group } { @@ -1737,6 +1778,7 @@ 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_user_grade_request { htmlEditUserGradeValue $permission_list $user } edit_user_grade { EditUserGradeValue $permission_list $user htmlDefaultView $permission_list $user } @@ -2267,6 +2309,12 @@ 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] @@ -2547,6 +2595,7 @@ proc ShowControls { permission_list user } { defaultview "Refresh"\ addcolumnrequest "Add Column"\ editcourseinfo "Edit Course Info"\ + edit_letter_grade_request "Letter grade settings"\ editnewuserinfo "Add new user"\ choosenewpassword "Choose new password"\ edit_grades_categories "Edit Grades Categories and Weights"\ |