From 8a2513e79abd713eac1c1296b585aab173ead7e1 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 17 Dec 2010 00:30:50 -0500 Subject: add column is working darcs-hash:20101217053050-067c0-aef041b09ae251cf003b750e0c49b9b7fb3858df.gz --- GradeBook.tcl | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/GradeBook.tcl b/GradeBook.tcl index b366adc..ed845f5 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -247,11 +247,14 @@ proc ChoseAction {action permission_list user} { if { [isActionGranted $action $permission_list $user] } { switch $action { sort { SetSortColumn; ChoseAction defaultview $permission_list $user } - addcolumn { AddColumn } - addcolumnrequest { AddColumnRequest } + addcolumn { + AddColumn $permission_list $user; + htmlDefaultView $permission_list $user + } + addcolumnrequest { AddColumnRequest $permission_list $user } deletecolumn { } renamecolumn { } - showcontrols { ShowControls $permission_list $user } + showcontrols { ShowControls $permission_list $user } showgrades { htmlGradesTable db $permission_list $user } defaultview { htmlDefaultView $permission_list $user } default { } @@ -259,9 +262,28 @@ proc ChoseAction {action permission_list user} { } } +proc AddColumn { permission_list user } { + global script_name + set columnname2add [::ncgi::value columnname2add {}] + if { $columnname2add != "" } { + + set eval_str [concat ALTER TABLE GradesTable ADD \"$columnname2add\" real] + puts $eval_str + set err [catch {db eval $eval_str } errStat] + if { $err } { + puts "the following error happen: $errStat" + dbg "the following error happen: $errStat" 3 + } + + } else { + puts "error: empty column names are not permitted" + } +} + proc AddColumnRequest { permission_list user } { + global script_name puts "
" - puts {Column Name:
} + puts {Column Name:
} puts {Max Point Possible:
} puts {} puts {} @@ -359,7 +381,6 @@ proc htmlGradesTable {db permission_list user} { proc htmlDefaultView { permission_list user } { ChoseAction showcontrols $permission_list $user ChoseAction showgrades $permission_list $user - htmlBottom $permission_list } @@ -385,5 +406,6 @@ ChoseAction $action $permission_list $user #htmlGradesTable db $permission_list $user #htmlDBout db $sortCol +htmlBottom $permission_list -- cgit v1.2.3