From 78175721074da61524c881bc4c8369072cd34f1d Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 21 Jan 2011 12:56:34 -0500 Subject: added and used SelectColValue4User instead of verbal db call Ignore-this: 48650945a6c6454490b75dc219b8429c darcs-hash:20110121175634-067c0-161505fdc665a63bd2ab4b45c92481cb6d69ea7e.gz --- GradeBook.tcl | 63 +++++++++++++++++++++-------------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/GradeBook.tcl b/GradeBook.tcl index 1257cab..4d68eb7 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -243,34 +243,31 @@ proc htmlFooter {permission_list} { puts "" } -proc Greetings {} { - global user password script_name - - set FirstName UnknownFirstName - set LastName UnknownLastName - # get First name info - set eval_str "SELECT \"FirstName\" FROM GradesTable where UserName=\"$user\"" - set err [catch { - db eval $eval_str v { - set FirstName $v(FirstName) - } - } errStat ] - if { $err } { - htmlErrorMsg $errStat - dbg "the following error happen: $errStat" 3 - } - # get Last name info - set eval_str "SELECT \"LastName\" FROM GradesTable where UserName=\"$user\"" +proc SelectColValue4User { colname user } { + set value {} + set eval_str "SELECT \"$colname\" FROM GradesTable where UserName=\"$user\"" set err [catch { db eval $eval_str v { - set LastName $v(LastName) + set value $v($colname) } } errStat ] if { $err } { htmlErrorMsg $errStat dbg "the following error happen: $errStat" 3 } + return $value +} + +proc Greetings {} { + global user password script_name + + set FirstName UnknownFirstName + set LastName UnknownLastName + + # get First and Last name info + set FirstName [SelectColValue4User FirstName $user] + set LastName [SelectColValue4User LastName $user] puts "
" puts ", you are logged in as ." @@ -364,6 +361,10 @@ proc ChoseAction {action permission_list user} { htmlDefaultView $permission_list $user } showcontrols { ShowControls $permission_list $user } + userhidecolumn { UserHideColumn $permission_list $user + htmlDefaultView $permission_list $user } + userunhidecolumn { UserUnHideColumn $permission_list $user + htmlDefaultView $permission_list $user } showgrades { htmlGradesTable db $permission_list $user } defaultview { htmlDefaultView $permission_list $user } default { htmlErrorMsg "requested action $action is granted but not implemented yet" } @@ -377,28 +378,8 @@ proc ChoseAction {action permission_list user} { proc ChangeColumn { permission_list user } { set columnname [::ncgi::value columnname {}] set category "none" - set eval_str "SELECT \"$columnname\" FROM GradesTable where UserName=\"_Col_Category_\"" - set err [catch { - db eval $eval_str v { - set category $v($columnname) - } - } errStat ] - if { $err } { - htmlErrorMsg $errStat - dbg "the following error happen: $errStat" 3 - } - - set eval_str "SELECT \"$columnname\" FROM GradesTable where UserName=\"_Max_Points_\"" - set err [catch { - db eval $eval_str v { - set maxpoints $v($columnname) - } - } errStat ] - if { $err } { - htmlErrorMsg $errStat - dbg "the following error happen: $errStat" 3 - } - + set category [SelectColValue4User $columnname _Col_Category_] + set maxpoints [SelectColValue4User $columnname _Max_Points_] puts {
} puts "
" -- cgit v1.2.3