diff options
-rwxr-xr-x | GradeBook.tcl | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl index 363617f..d62590c 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -127,7 +127,21 @@ proc htmlDBout {db permission_list user {sort_col {}}} { puts {<div class="gradestable">} set show_header 1 # show the table with grades - set eval_str [list SELECT * FROM GradesTable ORDER BY $sort_col] + set column_list [getColListFromTable GradesTable] + switch $permission(GroupName) { + instructor { set hidden_columns {} } + ta { set hidden_columns [list UserName] } + student { set hidden_columns [list FirstName LastName UserName] } + guest { set hidden_columns $column_list } + default { set hidden_columns $column_list } + } + # remove hidden columns from sql request + foreach col $hidden_columns { + set column_list [removeElementFromList $col $column_list] + } + set sql_column_str [colList2sqlColStr $column_list] + # get all allowed columns + set eval_str [concat SELECT $sql_column_str FROM GradesTable ORDER BY $sort_col] set err [catch { db eval $eval_str v { if { $show_header } { @@ -137,7 +151,15 @@ proc htmlDBout {db permission_list user {sort_col {}}} { foreach col $v(*) { puts -nonewline "<th><a href=\"$script_name?action=sort&sortCol=$col\">$col</a>" # below list has action and action_label pairs - set action_list [list changegrades "change grades" deletecolumn delete renamecolumn rename changecolumn "change column"] + set action_list {} + 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" } + 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] } { |