diff options
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-x | GradeBook.tcl | 108 |
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>} } |