diff options
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-x | GradeBook.tcl | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl index 29be3e0..3351150 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -86,6 +86,8 @@ proc CreateAccessRightsTable {db} { db eval {INSERT INTO AccessRightsTable VALUES('showcontrols', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('changegrades', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('updategrades', 1, 1, 0, 0)} + db eval {INSERT INTO AccessRightsTable VALUES('changecolumn', 1, 1, 0, 0)} + db eval {INSERT INTO AccessRightsTable VALUES('updatecolumn', 1, 1, 0, 0)} } proc htmlErrorMsg { msg } { @@ -130,7 +132,7 @@ proc htmlDBout {db permission_list {sort_col {}}} { foreach col $v(*) { puts -nonewline "<th><a href=$script_name?action=sort&sortCol=$col>$col</a>" # below list has action and action_label pairs - set action_list [list changegrades "change grades" deletecolumn delete renamecolumn rename] + set action_list [list changegrades "change grades" deletecolumn delete renamecolumn rename changecolumn "change column"] set separator {<br>} foreach {act act_label} $action_list { if { [info exist permission($act) ] } { @@ -281,6 +283,8 @@ proc ChoseAction {action permission_list user} { htmlDefaultView $permission_list $user } renamecolumn { } + changecolumn { ChangeColumn $permission_list $user } + updatecolumn { UpdateColumn $permission_list $user } showcontrols { ShowControls $permission_list $user } showgrades { htmlGradesTable db $permission_list $user } defaultview { htmlDefaultView $permission_list $user } @@ -289,6 +293,72 @@ proc ChoseAction {action permission_list user} { } } +proc ChangeColumn { permission_list user } { + set columnname [::ncgi::value columnname {}] + set category "none" + set eval_str "SELECT \"$columnname\" FROM GradesTable where UserName=\"_Col_Category_\"" + set err [catch { + db eval $eval_str v { + set category $v($columnname) + } + } errStat ] + if { $err } { + htmlErrorMsg $errStat + dbg "the following error happen: $errStat" 3 + } + + set eval_str "SELECT \"$columnname\" FROM GradesTable where UserName=\"_Max_Points_\"" + set err [catch { + db eval $eval_str v { + set maxpoints $v($columnname) + } + } errStat ] + if { $err } { + htmlErrorMsg $errStat + dbg "the following error happen: $errStat" 3 + } + + + puts {<div class="add_new_column">} + puts "<form name=\"input\" method=\"post\" />" + set out_str {} + append out_str {Column Name: <input type="text" name="newcolumnname" value="} $columnname {"><br>} + puts $out_str + set out_str {} + append out_str {Category: <select name="category" value="} $category {">} + puts $out_str + # opt list has option name and corresponding text pairs + set opt_list [list \ + none --Select--\ + Quiz Quiz\ + HomeWork HomeWork\ + LabReport LabReport\ + MidTerm MidTerm\ + FinalExam FinalExam\ + ] + foreach {name txt} $opt_list { + set out_str {} + if { $name eq $category } { + append out_str {<option value="} $name {" selected>} $txt {</option>} + } else { + append out_str {<option value="} $name {">} $txt {</option>} + } + + puts $out_str + } + puts {</select> <br>} + set out_str {} + append out_str {Max Point Possible:<input type="text" name="maxpointpossible" value="} $maxpoints {"> <br>} + puts $out_str + puts {<input type="hidden" name="action" value="updatecolumn"/>} + set out_str {} + append out_str {<input type="hidden" name="oldcolumnname" value="} $columnname {"/>} + puts $out_str + puts {<input type="submit" value="Submit" />} + puts {</form>} + puts {</div>} +} + proc UpdateGrades { permission_list user } { global script_name set subaction [::ncgi::value subaction {}] |