From 0666f334b8ff86b82d5827f4f27bb8d5b3507150 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 17 Dec 2010 13:34:13 -0500 Subject: change grades action draft darcs-hash:20101217183413-067c0-5b0e852b18ad56bd4ca0b43c1642f2201907ece6.gz --- GradeBook.tcl | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) (limited to 'GradeBook.tcl') 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 "$col" # 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 {
} 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 {} + puts "" + foreach col $v(*) { + puts -nonewline "" + } + puts "" + } else { + puts "" + } + foreach index $v(*) { + if { $index != "*" } { + puts -nonewline "" + } + } + puts "" + } + } errStat ] + puts "
$col
$v($index)
" + if { $err } { + puts "the following error happen: $errStat" + dbg "the following error happen: $errStat" 3 + } + puts "
" + #puts {} + puts {Column Name:
} + puts {} + puts {} + puts {
} + puts "Cancel changes" + + } else { + puts "error: empty column names are not permitted" + } +} + proc DeleteColumn { permission_list user } { global script_name set columnname [::ncgi::value columnname {}] -- cgit v1.2.3