aboutsummaryrefslogtreecommitdiff
path: root/GradeBook_lib.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2014-03-27 21:59:42 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2014-03-27 21:59:42 -0400
commite9fcd4652fd302ed85f5c7453deec626c69fa9cc (patch)
tree67b2a410900a287c8ef53af04e6c74163d8cfa5a /GradeBook_lib.tcl
parenta2efcc4eed047412ce5b0e9b4e95636b56014652 (diff)
downloadGradeBook-e9fcd4652fd302ed85f5c7453deec626c69fa9cc.tar.gz
GradeBook-e9fcd4652fd302ed85f5c7453deec626c69fa9cc.zip
moved grades table html header formatting into separate proc
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-xGradeBook_lib.tcl133
1 files changed, 71 insertions, 62 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index 4495274..a5a06b4 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -838,6 +838,75 @@ proc number2letter_grade { num } {
return "NA"
}
+proc htmlGradesTableHeadersRaw { permission_list user sql_column_str hidden_columns v_array_list } {
+ global GradebookServerConfig
+ global script_name
+ array set permission $permission_list
+ array set v $v_array_list
+ puts "<tr>"
+ foreach col $v(*) {
+ if { $col in $hidden_columns } continue
+ # 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}
+ switch $col {
+ FirstName { lappend action_list changefirstname }
+ LastName { lappend action_list changelastname }
+ UserName { lappend action_list changeusername }
+ UserHiddenColums { }
+ UserHiddenGroups { }
+ UserHiddenGradeCategories { }
+ IdNum { }
+ GroupName { }
+ SectionNum { }
+ default {
+ switch $category {
+ "weighted_column" {
+ # modify actions for weighted_column
+ if { $permission(GroupName) eq "instructor" } {
+ if { [SelectColValue4User $col _Visible_To_Students_] eq "true" } {
+ lappend action_list hidecolfromstudents
+ } else {
+ lappend action_list unhidecolfromstudents
+ }
+ }
+ }
+ default {
+ lappend action_list changegrades deletecolumn changecolumn
+ if { [SelectColValue4User $col _Visible_To_Students_] eq "true" } {
+ lappend action_list hidecolfromstudents
+ } else {
+ lappend action_list unhidecolfromstudents
+ }
+ }
+ }
+ }
+ }
+ set separator {<br>}
+ foreach act $action_list {
+ set attributes [action2atributes $act]
+ set act_label [lindex $attributes 1]
+ set act_icon [lindex $attributes 2]
+ if { [isActionGranted $act $permission_list $user] } {
+ if { $GradebookServerConfig(use_icons) } {
+ puts -nonewline "$separator<a href=\"$script_name?action=$act&columnname=[::ncgi::encode $col]\">"
+ puts -nonewline "<img src=\"$act_icon\" alt=\"$act_label\" title=\"$act_label\">"
+ puts -nonewline "</a>"
+ } else {
+ puts -nonewline "$separator<span class=\"column_control_$act\"><a href=\"$script_name?action=$act&columnname=[::ncgi::encode $col]\">"
+ puts -nonewline "$act_label"
+ puts -nonewline "</a></span>"
+ }
+ }
+ }
+ puts -nonewline "</th>"
+ puts ""
+ }
+ puts "</tr>"
+}
+
proc htmlFormatMaxPossibleRaw { sql_column_str hidden_columns } {
# show max point values in html format
puts "<tr>"
@@ -955,68 +1024,8 @@ proc htmlDBout {db permission_list user {sort_col {}}} {
if { $show_header } {
set show_header 0
puts {<table class="gradestable" border="1">}
- puts "<tr>"
- foreach col $v(*) {
- if { $col in $hidden_columns } continue
- # 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}
- switch $col {
- FirstName { lappend action_list changefirstname }
- LastName { lappend action_list changelastname }
- UserName { lappend action_list changeusername }
- UserHiddenColums { }
- UserHiddenGroups { }
- UserHiddenGradeCategories { }
- IdNum { }
- GroupName { }
- SectionNum { }
- default {
- switch $category {
- "weighted_column" {
- # modify actions for weighted_column
- if { $permission(GroupName) eq "instructor" } {
- if { [SelectColValue4User $col _Visible_To_Students_] eq "true" } {
- lappend action_list hidecolfromstudents
- } else {
- lappend action_list unhidecolfromstudents
- }
- }
- }
- default {
- lappend action_list changegrades deletecolumn changecolumn
- if { [SelectColValue4User $col _Visible_To_Students_] eq "true" } {
- lappend action_list hidecolfromstudents
- } else {
- lappend action_list unhidecolfromstudents
- }
- }
- }
- }
- }
- set separator {<br>}
- foreach act $action_list {
- set attributes [action2atributes $act]
- set act_label [lindex $attributes 1]
- set act_icon [lindex $attributes 2]
- if { [isActionGranted $act $permission_list $user] } {
- if { $GradebookServerConfig(use_icons) } {
- puts -nonewline "$separator<a href=\"$script_name?action=$act&columnname=[::ncgi::encode $col]\">"
- puts -nonewline "<img src=\"$act_icon\" alt=\"$act_label\" title=\"$act_label\">"
- puts -nonewline "</a>"
- } else {
- puts -nonewline "$separator<span class=\"column_control_$act\"><a href=\"$script_name?action=$act&columnname=[::ncgi::encode $col]\">"
- puts -nonewline "$act_label"
- puts -nonewline "</a></span>"
- }
- }
- }
- puts -nonewline "</th>"
- puts ""
- }
- puts "</tr>"
+ set v_array_list [array get v]
+ htmlGradesTableHeadersRaw $permission_list $user $sql_column_str $hidden_columns $v_array_list
htmlFormatMaxPossibleRaw $sql_column_str $hidden_columns
puts "<tr>"
} else {