aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-01-18 00:59:53 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2011-01-18 00:59:53 -0500
commit6e3d890b9f44ae850925679af3e2074a08fbc23a (patch)
tree19244fb7e4589332628cc1a794572f3a499399fe
parentb60f0322117df1695b4ad055d759d3a415819a84 (diff)
downloadGradeBook-6e3d890b9f44ae850925679af3e2074a08fbc23a.tar.gz
GradeBook-6e3d890b9f44ae850925679af3e2074a08fbc23a.zip
added action to change column
Ignore-this: 6b12a4d658c9f00aa6005d3e5915ba3d darcs-hash:20110118055953-067c0-9a5f8799eec616d74f6be88c19d3d22804efc3a6.gz
-rwxr-xr-xGradeBook.tcl72
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 {}]