aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook.tcl30
1 files changed, 21 insertions, 9 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index f75d910..24aa194 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -506,18 +506,30 @@ proc ChangeGrades { permission_list user } {
}
}
-proc DeleteColumnNonWeb { columnname } {
- if { $columnname != "" } {
- set eval_str [concat SELECT * FROM GradesTable ]
+proc getColListFromTable { table } {
+ set eval_str [concat SELECT * FROM \'$table\' ]
set err [catch {db eval $eval_str v {} } errStat]
set old_column_list $v(*)
- # removing the column name to be deleted from total list
- set new_column_list {}
- foreach cname $old_column_list {
- if { $cname ne $columnname } {
- lappend new_column_list \"$cname\"
- }
+ return $old_column_list
+}
+
+proc removeElementFromList { element2remove old_list } {
+ set new_list {}
+ foreach element $old_list {
+ if { $element2remove ne $element } {
+ lappend new_list \"$element\"
}
+ }
+ return $new_list
+}
+
+proc DeleteColumnNonWeb { columnname } {
+ if { $columnname != "" } {
+
+ # removing the column name to be deleted from total list
+
+ set old_column_list [getColListFromTable GradesTable]
+ set new_column_list [removeElementFromList $columnname $old_column_list]
set sql_new_column_list [join $new_column_list ","]
set eval_str "BEGIN TRANSACTION;
CREATE TEMPORARY TABLE GradesTable_backup($sql_new_column_list);