From 2a62c27f658ee43a93a55258584d66dec42bbda2 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Wed, 9 Mar 2011 00:38:50 -0500 Subject: table created drom the provided list of columns and their types Ignore-this: 4c2cec2eee20127627871c47ab94cde6 darcs-hash:20110309053850-067c0-ee68e87bc95507add9d39f2184a6295340941ca9.gz --- GradeBook_lib.tcl | 34 ++++++++++++++++++++++++++++++++-- 1 file 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 -- cgit v1.2.3