aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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\" />"