aboutsummaryrefslogtreecommitdiff
path: root/GradeBook.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-01-23 21:59:11 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2011-01-23 21:59:11 -0500
commitb322dd885e403492f818a5110a9a7957a6b304ce (patch)
treed5b25ffe8e396bb4d86cfb659231e23976b8ab54 /GradeBook.tcl
parent1d7aecfdf638d7fb8cbf886fe34638f9285a050a (diff)
downloadGradeBook-b322dd885e403492f818a5110a9a7957a6b304ce.tar.gz
GradeBook-b322dd885e403492f818a5110a9a7957a6b304ce.zip
Added condition which checks against empty column least for GradesTable
Ignore-this: bee0512330d11599d088cc2364ee669b darcs-hash:20110124025911-067c0-10a27efcbc51056bb4ce9ffa14af29b10270c85e.gz
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-xGradeBook.tcl108
1 files changed, 56 insertions, 52 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index 916ce47..078db4f 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -187,65 +187,69 @@ proc htmlDBout {db permission_list user {sort_col {}}} {
guest { dbg "Guest must not be allowed to set table view port. Aborting. This line is never executed" 0; exit }
default { dbg "Default must not be allowed to set table view port. Aborting. This line is never executed." 0; exit }
}
- # get all allowed columns and rows
- set eval_str [concat SELECT $sql_column_str FROM GradesTable $where_statement ORDER BY $sort_col]
- set err [catch {
- db eval $eval_str v {
- if { $show_header } {
- set show_header 0
- puts {<table class="gradestable" border="1">}
- puts "<tr>"
- foreach col $v(*) {
- # detect what column category it is
- set category [SelectColValue4User $col _Col_Category_]
- puts -nonewline "<th class=\"$category\"><a href=\"$script_name?action=sort&sortCol=$col\">$col</a>"
- # below list has action and action_label pairs
- set action_list {userhidecolumn hide}
- switch $col {
- FirstName { lappend action_list changefirstname "change first name" }
- LastName { lappend action_list changelastname "change last name" }
- UserName { lappend action_list changeusername "change user name" }
- PasswordHash { }
- UserHiddenColums { }
- UserHiddenGroups { }
- IdNum { }
- GroupName { }
- SectionNum { }
- default {
- lappend action_list changegrades "change grades" deletecolumn delete changecolumn "change column"
+ if { $sql_column_str ne "" } {
+ # get all allowed columns and rows
+ set eval_str [concat SELECT $sql_column_str FROM GradesTable $where_statement ORDER BY $sort_col]
+ set err [catch {
+ db eval $eval_str v {
+ if { $show_header } {
+ set show_header 0
+ puts {<table class="gradestable" border="1">}
+ puts "<tr>"
+ foreach col $v(*) {
+ # detect what column category it is
+ set category [SelectColValue4User $col _Col_Category_]
+ puts -nonewline "<th class=\"$category\"><a href=\"$script_name?action=sort&sortCol=$col\">$col</a>"
+ # below list has action and action_label pairs
+ set action_list {userhidecolumn hide}
+ switch $col {
+ FirstName { lappend action_list changefirstname "change first name" }
+ LastName { lappend action_list changelastname "change last name" }
+ UserName { lappend action_list changeusername "change user name" }
+ PasswordHash { }
+ UserHiddenColums { }
+ UserHiddenGroups { }
+ IdNum { }
+ GroupName { }
+ SectionNum { }
+ default {
+ lappend action_list changegrades "change grades" deletecolumn delete changecolumn "change column"
+ }
+ }
+ set separator {<br>}
+ foreach {act act_label} $action_list {
+ if { [isActionGranted $act $permission_list $user] } {
+ puts -nonewline "$separator<span class=\"controls\"><a href=\"$script_name?action=$act&columnname=[::ncgi::encode $col]\">$act_label</a></span>"
+ }
}
+ puts -nonewline "</th>"
+ puts ""
}
- set separator {<br>}
- foreach {act act_label} $action_list {
- if { [isActionGranted $act $permission_list $user] } {
- puts -nonewline "$separator<span class=\"controls\"><a href=\"$script_name?action=$act&columnname=[::ncgi::encode $col]\">$act_label</a></span>"
- }
+ puts "</tr>"
+ puts "<tr>"
+ } else {
+ puts "<tr>"
+ }
+ foreach index $v(*) {
+ if { $index != "*" } {
+ # detect what column category it is
+ set category [SelectColValue4User $index _Col_Category_]
+ set col_value [htmlReplaceEmptyString $v($index)]
+ puts -nonewline "<td class=\"$category\">$col_value</td>"
}
- puts -nonewline "</th>"
- puts ""
}
puts "</tr>"
- puts "<tr>"
- } else {
- puts "<tr>"
}
- foreach index $v(*) {
- if { $index != "*" } {
- # detect what column category it is
- set category [SelectColValue4User $index _Col_Category_]
- set col_value [htmlReplaceEmptyString $v($index)]
- puts -nonewline "<td class=\"$category\">$col_value</td>"
- }
- }
- puts "</tr>"
- }
- } errStat ]
- if { $err } {
- dbg "we should never be here if $sortCol exist in the table" 1
- dbg $errStat 1
- htmlErrorMsg $errStat
+ } errStat ]
+ if { $err } {
+ dbg "we should never be here if $sortCol exist in the table" 1
+ dbg $errStat 1
+ htmlErrorMsg $errStat
+ }
+ puts "</table>"
+ } else {
+ puts {There is no grades yet.}
}
- puts "</table>"
puts {</div>}
}