summaryrefslogtreecommitdiff
path: root/GradeBook.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2010-12-17 00:30:50 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2010-12-17 00:30:50 -0500
commit8a2513e79abd713eac1c1296b585aab173ead7e1 (patch)
tree6bab4973e4956a585d883f23e0a64560680a09c7 /GradeBook.tcl
parent67599974aa966eadfbcf743701424c2c5dfe7999 (diff)
downloadGradeBook-8a2513e79abd713eac1c1296b585aab173ead7e1.tar.gz
GradeBook-8a2513e79abd713eac1c1296b585aab173ead7e1.zip
add column is working
darcs-hash:20101217053050-067c0-aef041b09ae251cf003b750e0c49b9b7fb3858df.gz
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-xGradeBook.tcl32
1 files 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 "<form name=\"input\" action=\"$script_name\" method=\"post\" />"
- puts {Column Name: <input type="text" name="columnname"><br>}
+ puts {Column Name: <input type="text" name="columnname2add"><br>}
puts {Max Point Possible:<input type="text" name="maxpointpossible"><br>}
puts {<input type="hidden" name="action" value="addcolumn"/>}
puts {<input type="submit" value="Submit" />}
@@ -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