diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2010-12-17 13:34:13 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2010-12-17 13:34:13 -0500 |
commit | 0666f334b8ff86b82d5827f4f27bb8d5b3507150 (patch) | |
tree | 2321706fe4ded2c7bd85a348355ee3ed0fad3973 | |
parent | 1473b6f96443b66e3fe88ca54f296ca4eb024a56 (diff) | |
download | GradeBook-0666f334b8ff86b82d5827f4f27bb8d5b3507150.tar.gz GradeBook-0666f334b8ff86b82d5827f4f27bb8d5b3507150.zip |
change grades action draft
darcs-hash:20101217183413-067c0-5b0e852b18ad56bd4ca0b43c1642f2201907ece6.gz
-rwxr-xr-x | GradeBook.tcl | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl index 08d8a58..7df3c76 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -79,8 +79,8 @@ proc CreateAccessRightsTable {db} { db eval {INSERT INTO AccessRightsTable VALUES('addcolumn', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('deletecolumn', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('renamecolumn', 1, 1, 0, 0)} - db eval {INSERT INTO AccessRightsTable VALUES('editcolumn', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('showcontrols', 1, 1, 0, 0)} + db eval {INSERT INTO AccessRightsTable VALUES('changegrades', 1, 1, 0, 0)} } proc htmlDBout {db permission_list {sort_col {}}} { @@ -113,7 +113,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 editcolumn edit deletecolumn delete renamecolumn rename] + set action_list [list changegrades "change grades" deletecolumn delete renamecolumn rename] set separator {<br>} foreach {act act_label} $action_list { if { [info exist permission($act) ] } { @@ -243,7 +243,7 @@ proc isActionGranted { action permission_list user } { proc ChoseAction {action permission_list user} { array set permission $permission_list - dbg "requested action: $action" 3 + dbg "requested action: $action" 1 if { [isActionGranted $action $permission_list $user] } { switch $action { sort { SetSortColumn; ChoseAction defaultview $permission_list $user } @@ -256,6 +256,7 @@ proc ChoseAction {action permission_list user} { DeleteColumn $permission_list $user; htmlDefaultView $permission_list $user } + changegrades { ChangeGrades $permission_list $user } renamecolumn { } showcontrols { ShowControls $permission_list $user } showgrades { htmlGradesTable db $permission_list $user } @@ -265,6 +266,58 @@ proc ChoseAction {action permission_list user} { } } + +proc ChangeGrades { permission_list user } { + global script_name + set columnname [::ncgi::value columnname {}] + if { $columnname != "" } { + # output only selected columns + set column_list {} + lappend column_list FirstName LastName + lappend column_list \"$columnname\" + set sql_column_list [join $column_list ","] + # output only selected columns + set eval_str "SELECT $sql_column_list FROM GradesTable ORDER BY LastName" + set show_header 1 + set err [catch { + db eval $eval_str v { + if { $show_header } { + set show_header 0 + puts {<table border="1">} + puts "<tr>" + foreach col $v(*) { + puts -nonewline "<th>$col</th>" + } + puts "<tr>" + } else { + puts "<tr>" + } + foreach index $v(*) { + if { $index != "*" } { + puts -nonewline "<td>$v($index)</td>" + } + } + puts "</tr>" + } + } errStat ] + puts "</table>" + if { $err } { + puts "the following error happen: $errStat" + dbg "the following error happen: $errStat" 3 + } + puts "<form name=\"input\" action=\"$script_name\" method=\"post\" />" + #puts {<input type="hidden" name="action" value="updategrades"/>} + puts {Column Name: <input type="text" name="columnname2add"><br>} + puts {<input type="submit" name="action" value="Cancel" />} + puts {<input type="submit" name="action" value="Submit" />} + puts {</form>} + puts "<a href=\"$script_name\">Cancel changes</a>" + + } else { + puts "error: empty column names are not permitted" + } +} + proc DeleteColumn { permission_list user } { global script_name set columnname [::ncgi::value columnname {}] |