diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-03-09 00:38:50 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-03-09 00:38:50 -0500 |
commit | 2a62c27f658ee43a93a55258584d66dec42bbda2 (patch) | |
tree | 5829f5e502f399209e285efb7f44fcb8358e6c95 /GradeBook_lib.tcl | |
parent | f6b7f3b4037bd6d747745e4907de58ced3dfe071 (diff) | |
download | GradeBook-2a62c27f658ee43a93a55258584d66dec42bbda2.tar.gz GradeBook-2a62c27f658ee43a93a55258584d66dec42bbda2.zip |
table created drom the provided list of columns and their types
Ignore-this: 4c2cec2eee20127627871c47ab94cde6
darcs-hash:20110309053850-067c0-ee68e87bc95507add9d39f2184a6295340941ca9.gz
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 7b7fd7f..c2c8cb0 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -233,10 +233,40 @@ proc SelectItemFromCourseInfoTable { item } { return $value } - +proc GetDefaultGradesTableColumn {} { + # this is the list of crucial GradesTable columns + # column name and type + set l [list \ + FirstName text\ + LastName text\ + UserName text\ + PasswordHash text\ + GroupName text\ + UserHiddenColums text\ + UserHiddenGroups text\ + UserHiddenGradeCategories text\ + IdNum text\ + SectionNum text\ + ] + return $l +} proc CreateGradesTable {db} { - set err [catch {db eval {CREATE TABLE GradesTable(FirstName text, LastName text, UserName text, PasswordHash text, GroupName text, UserHiddenColums text, UserHiddenGroups text, IdNum text, SectionNum text)} } errStat] + # construct sql string for table creation + set sql_str {CREATE TABLE GradesTable(} + set flag_firsttime true + foreach {col coltype} [GetDefaultGradesTableColumn] { + if { $flag_firsttime} { + set flag_firsttime false + set sql_str [concat $sql_str $col $coltype] + } else { + set sql_str [concat $sql_str , $col $coltype] + } + } + set sql_str [concat $sql_str )] + puts $sql_str + + set err [catch {db eval $sql_str } errStat] if { $err } { htmlErrorMsg $errStat dbg "the following error happen: $errStat" 1 |