summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook.tcl61
1 files changed, 58 insertions, 3 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index a080e10..966de76 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -62,7 +62,7 @@ proc AddUserNonWeb { first_name last_name user_name password_hash {group_name {g
}
proc CreateGradesTable {db} {
- set err [catch {db eval {CREATE TABLE GradesTable(FirstName text, LastName text, UserName text, PasswordHash text, GroupName text, UserHiddenColums text)} } errStat]
+ set err [catch {db eval {CREATE TABLE GradesTable(FirstName text, LastName text, UserName text, PasswordHash text, GroupName text, UserHiddenColums text, UserHiddenGroups text)} } errStat]
if { $err } {
htmlErrorMsg $errStat
dbg "the following error happen: $errStat" 1
@@ -79,7 +79,7 @@ proc CreateGradesTable {db} {
AddUserNonWeb Jon "Jonovich" jon [::md5::md5 -hex qwerty] student
AddUserNonWeb Ins "Instruch I" instructor [::md5::md5 -hex qwerty] instructor
# reasonable defaults for hidden columns
- set instructor_hidden_columns [list UserHiddenColums PasswordHash]
+ set instructor_hidden_columns [list UserHiddenColums PasswordHash UserHiddenGroups]
UpdateColValue4GroupNameNonWeb UserHiddenColums instructor $instructor_hidden_columns
}
@@ -117,6 +117,8 @@ proc CreateAccessRightsTable {db} {
AddAccessRightNonWeb changeusername 1 0 0 0
AddAccessRightNonWeb userhidecolumn 1 1 1 0
AddAccessRightNonWeb userunhidecolumn 1 1 1 0
+ AddAccessRightNonWeb userhidegroup 1 0 0 0
+ AddAccessRightNonWeb userunhidegroup 1 0 0 0
}
proc htmlErrorMsg { msg } {
@@ -169,8 +171,21 @@ proc htmlDBout {db permission_list user {sort_col {}}} {
}
set sql_column_str [colList2sqlColStr $column_list]
# set users of what group user can see, i.e. set WHERE statement
+ set where_statement {}
switch $permission(GroupName) {
- instructor { set where_statement {} }
+ instructor {
+ # hide unwanted user groups
+ set user_groups_for_hide [SelectColValue4User UserHiddenGroups $user]
+ if {$user_groups_for_hide != {} } {
+ foreach grp $user_groups_for_hide {
+ if { $where_statement == {} } {
+ set where_statement "WHERE GroupName<>\"$grp\""
+ } else {
+ set where_statement [concat $where_statement "AND GroupName<>\"$grp\""]
+ }
+ }
+ }
+ }
ta { set where_statement "WHERE GroupName=\"student\"" }
student { set where_statement "WHERE UserName=\"$user\"" }
guest { dbg "Guest must not be allowed to set table view port. Aborting. This line is never executed" 0; exit }
@@ -374,6 +389,10 @@ proc ChoseAction {action permission_list user} {
htmlDefaultView $permission_list $user }
userunhidecolumn { UserUnHideColumn $permission_list $user
htmlDefaultView $permission_list $user }
+ userhidegroup { UserHideGroup $permission_list $user
+ htmlDefaultView $permission_list $user }
+ userunhidegroup { UserUnHideGroup $permission_list $user
+ htmlDefaultView $permission_list $user }
showgrades { htmlGradesTable db $permission_list $user }
defaultview { htmlDefaultView $permission_list $user }
default { htmlErrorMsg "requested action <b>$action</b> is granted but not implemented yet" }
@@ -384,6 +403,19 @@ proc ChoseAction {action permission_list user} {
}
}
+proc UserUnHideGroup { permission_list user } {
+ set groupname [::ncgi::value groupname {}]
+ set currently_hidden_groups [SelectColValue4User UserHiddenGroups $user]
+ set currently_hidden_groups [removeElementFromList $groupname $currently_hidden_groups]
+ UpdateColValue4UserNameNonWeb UserHiddenGroups $user $currently_hidden_groups
+}
+proc UserHideGroup { permission_list user } {
+ set groupname [::ncgi::value groupname {}]
+ set currently_hidden_groups [SelectColValue4User UserHiddenGroups $user]
+ lappend currently_hidden_groups $groupname
+ UpdateColValue4UserNameNonWeb UserHiddenGroups $user $currently_hidden_groups
+}
+
proc UserHideColumn { permission_list user } {
set columnname [::ncgi::value columnname {}]
set currently_hidden_columns [SelectColValue4User UserHiddenColums $user]
@@ -720,6 +752,29 @@ proc ShowControls { permission_list user } {
puts "<span class=\"controls\"><a href=\"$script_name?action=userunhidecolumn&columnname=[::ncgi::encode $col]\">$col</a></span>"
}
}
+ # hide user groups
+ set user_groups_for_hide [list inforow student ta instructor]
+ set currently_hidden_groups [SelectColValue4User UserHiddenGroups $user]
+ # remove already hidden group from offering
+ foreach grp $currently_hidden_groups {
+ set user_groups_for_hide [removeElementFromList $grp $user_groups_for_hide]
+ }
+ # output group to hide offering
+ if { $user_groups_for_hide ne "" } {
+ puts "<br>"
+ puts "HideGroup: "
+ foreach grp $user_groups_for_hide {
+ puts "<span class=\"controls\"><a href=\"$script_name?action=userhidegroup&groupname=[::ncgi::encode $grp]\">$grp</a></span>"
+ }
+ }
+ if { $currently_hidden_groups ne "" } {
+ puts "<br>"
+ puts {Unhide groups: }
+ foreach grp $currently_hidden_groups {
+ puts "<span class=\"controls\"><a href=\"$script_name?action=userunhidegroup&groupname=[::ncgi::encode $grp]\">$grp</a></span>"
+ }
+ }
+
puts "</div>"
}