summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-01-21 12:56:34 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2011-01-21 12:56:34 -0500
commit78175721074da61524c881bc4c8369072cd34f1d (patch)
treebcb0d45dd02ecc37ce2531f4ec03f1c13524113d
parent32ba1e91ee3be0ac0863c132b3922b6a131d70b4 (diff)
downloadGradeBook-78175721074da61524c881bc4c8369072cd34f1d.tar.gz
GradeBook-78175721074da61524c881bc4c8369072cd34f1d.zip
added and used SelectColValue4User instead of verbal db call
Ignore-this: 48650945a6c6454490b75dc219b8429c darcs-hash:20110121175634-067c0-161505fdc665a63bd2ab4b45c92481cb6d69ea7e.gz
-rwxr-xr-xGradeBook.tcl63
1 files 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 "</div>"
}
-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 "<div class=\"greetings\">"
puts "<span class=login_info>$FirstName $LastName</span>, you are logged in as <span class=login_info>$user</span>."
@@ -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 <b>$action</b> 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 {<div class="add_new_column">}
puts "<form name=\"input\" method=\"post\" />"