summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-01-19 23:14:34 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2011-01-19 23:14:34 -0500
commitea3a7a8a7b1325f0224c40eaf2b446a115f4559e (patch)
tree2ad0f351a5533f6f2c1a1a6bbbd278af400f8af6
parent2dcd502529c7e58c2df11df9cf87b9797671484f (diff)
downloadGradeBook-ea3a7a8a7b1325f0224c40eaf2b446a115f4559e.tar.gz
GradeBook-ea3a7a8a7b1325f0224c40eaf2b446a115f4559e.zip
use of helping routines for list to sql col list conversion, student view does not show first name, laet name, and login info
Ignore-this: 46896be9fce0d4afc678cc3203835fd9 darcs-hash:20110120041434-067c0-7c424e19e85f39ce4fdecbe9d6f03a23ac74016a.gz
-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 } {