summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook.tcl35
1 files changed, 28 insertions, 7 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index 24aa194..a1cca36 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -517,12 +517,25 @@ proc removeElementFromList { element2remove old_list } {
set new_list {}
foreach element $old_list {
if { $element2remove ne $element } {
- lappend new_list \"$element\"
+ lappend new_list $element
}
}
return $new_list
}
+proc colList2sqlColStr { col_list } {
+ set sqlStr {}
+ foreach col $col_list {
+ if {$sqlStr ne ""} {
+ set sqlStr $sqlStr,\"$col\"
+ } else {
+ set sqlStr \"$col\"
+ }
+ }
+ return $sqlStr
+}
+
+
proc DeleteColumnNonWeb { columnname } {
if { $columnname != "" } {
@@ -530,13 +543,13 @@ proc DeleteColumnNonWeb { columnname } {
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 sql_new_column_str [colList2sqlColStr $new_column_list]
set eval_str "BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE GradesTable_backup($sql_new_column_list);
- INSERT INTO GradesTable_backup SELECT $sql_new_column_list FROM GradesTable;
+ CREATE TEMPORARY TABLE GradesTable_backup($sql_new_column_str);
+ INSERT INTO GradesTable_backup SELECT $sql_new_column_str FROM GradesTable;
DROP TABLE GradesTable;
- CREATE TABLE GradesTable($sql_new_column_list);
- INSERT INTO GradesTable SELECT $sql_new_column_list FROM GradesTable_backup;
+ CREATE TABLE GradesTable($sql_new_column_str);
+ INSERT INTO GradesTable SELECT $sql_new_column_str FROM GradesTable_backup;
DROP TABLE GradesTable_backup;
COMMIT;"
set err [catch {db eval $eval_str } errStat]
@@ -655,8 +668,16 @@ proc htmlStudentGrades { db user } {
puts {<div class="gradestable">}
set show_header 1
+
+ set do_not_show_columns [list FirstName LastName UserName]
+ set cols_to_show [getColListFromTable GradesTable]
+ foreach col $do_not_show_columns {
+ set cols_to_show [removeElementFromList $col $cols_to_show]
+ }
+ set sql_column_str [colList2sqlColStr $cols_to_show]
+
# show the table with grades
- set eval_str [list SELECT * FROM GradesTable WHERE UserName='$user' ORDER BY $sort_col]
+ set eval_str [concat SELECT $sql_column_str FROM GradesTable WHERE UserName='$user' ORDER BY $sort_col]
set err [catch {
db eval $eval_str v {
if { $show_header } {