aboutsummaryrefslogtreecommitdiff
path: root/GradeBook_lib.tcl
diff options
context:
space:
mode:
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 {