diff options
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 |