From e9fcd4652fd302ed85f5c7453deec626c69fa9cc Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Thu, 27 Mar 2014 21:59:42 -0400 Subject: moved grades table html header formatting into separate proc --- GradeBook_lib.tcl | 133 +++++++++++++++++++++++++++++------------------------- 1 file 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 "" + foreach col $v(*) { + if { $col in $hidden_columns } continue + # detect what column category it is + set category [SelectColValue4User $col _Col_Category_] + puts -nonewline "$col" + # 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 {
} + 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" + puts -nonewline "\"$act_label\"" + puts -nonewline "" + } else { + puts -nonewline "$separator" + puts -nonewline "$act_label" + puts -nonewline "" + } + } + } + puts -nonewline "" + puts "" + } + puts "" +} + proc htmlFormatMaxPossibleRaw { sql_column_str hidden_columns } { # show max point values in html format puts "" @@ -955,68 +1024,8 @@ proc htmlDBout {db permission_list user {sort_col {}}} { if { $show_header } { set show_header 0 puts {} - puts "" - foreach col $v(*) { - if { $col in $hidden_columns } continue - # detect what column category it is - set category [SelectColValue4User $col _Col_Category_] - puts -nonewline "" - puts "" - } - puts "" + 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 "" } else { -- cgit v1.2.3
$col" - # 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 {
} - 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" - puts -nonewline "\"$act_label\"" - puts -nonewline "" - } else { - puts -nonewline "$separator" - puts -nonewline "$act_label" - puts -nonewline "" - } - } - } - puts -nonewline "