diff options
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 509f8b8..26ff60a 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -4,7 +4,7 @@ exec tclsh "$0" "$@" # internal version of this code -set VERSION 1.0 +set VERSION 1.1 # ########################## procs begin ################################# proc dbg {msg {level 1}} { @@ -139,6 +139,8 @@ proc CreateAccessRightsTable {db} { AddAccessRightNonWeb addnewuserinfo 1 0 0 0 AddAccessRightNonWeb choosenewpassword 1 1 1 0 AddAccessRightNonWeb setnewpassword 1 1 1 0 + AddAccessRightNonWeb changegroupname 1 0 0 0 + AddAccessRightNonWeb setgroupname 1 0 0 0 AddAccessRightNonWeb resetforgottenpassword 0 0 0 1 } @@ -261,12 +263,28 @@ proc htmlDBout {db permission_list user {sort_col {}}} { } else { puts "<tr>" } + + if { [info exist v(UserName)] } { + set user_shown [htmlReplaceEmptyString $v(UserName)] + } else { + set user_shown "_UNSET_" + } foreach index $v(*) { if { $index != "*" } { # detect what column category it is set category [SelectColValue4User $index _Col_Category_] set col_value [htmlReplaceEmptyString $v($index)] - puts -nonewline "<td class=\"$category\">$col_value</td>" + switch $index { + GroupName { + if { [isActionGranted changegroupname $permission_list $user] && ($user_shown ne "_UNSET_") } { + set action_html_code "$separator<span class=\"controls\"><a href=\"$script_name?action=changegroupname&user2modify=$user_shown\">Change</a></span>" + } else { + set action_html_code {} + } + puts -nonewline "<td class=\"$category\">$col_value $action_html_code</td>" + } + default {puts -nonewline "<td class=\"$category\">$col_value</td>"} + } } } puts "</tr>" @@ -508,6 +526,9 @@ proc ChoseAction {action permission_list user} { setnewpassword { SetNewPassword db $permission_list $user htmlDefaultView $permission_list $user } resetforgottenpassword { ResetForgottenPassword $permission_list $user } + changegroupname { ChangeGroupName $permission_list $user } + setgroupname { SetGroupName $permission_list $user + htmlDefaultView $permission_list $user } defaultview { htmlDefaultView $permission_list $user } default { htmlErrorMsg "requested action <b>$action</b> is granted but not implemented yet" } } @@ -517,6 +538,62 @@ proc ChoseAction {action permission_list user} { } } +proc ChangeGroupName {permission_list user } { + global script_name + set modified_user [::ncgi::value user2modify {}] + + set current_group_name [SelectColValue4User GroupName $modified_user] + set FirstName [SelectColValue4User FirstName $modified_user] + set LastName [SelectColValue4User LastName $modified_user] + puts "<div class=changegroupname>" + puts "New group name for $FirstName $LastName $modified_user" + puts "<form name=\"input\" action=\"$script_name\" method=\"post\" />" + puts {GroupName: <select name="groupname">} + # opt list has option name and corresponding text pairs + set opt_list [list \ + student student\ + dropped "Dropped Student"\ + ta ta\ + instructor instructor + ] + foreach {name txt} $opt_list { + set out_str {} + if { $name eq $current_group_name } { + append out_str {<option value="} $name {" selected>} $txt {</option>} + } else { + append out_str {<option value="} $name {">} $txt {</option>} + } + puts $out_str + } + puts {</select> <br>} + puts {<input type="hidden" name="action" value="setgroupname"/>} + puts "<input type=\"hidden\" name=\"user2modify\" value=\"$modified_user\"/>" + puts {<input type="submit" name="subaction" value="Submit" />} + puts {<input type="submit" name="subaction" value="Cancel" />} + puts {</form>} + puts "</div>" +} + +proc SetGroupName { permission_list user } { + set subaction [::ncgi::value subaction {}] + set modified_user [::ncgi::value user2modify {}] + set new_group_name [::ncgi::value groupname {}] + + if { $subaction eq "Cancel" } { + return + } + + if { $new_group_name eq "" } { + htmlErrorMsg "Empty groupname are not permitted" + return + } + + if { $subaction eq "Submit" } { + UpdateColValue4UserNameNonWeb GroupName $modified_user $new_group_name + } +} + + proc ChooseNewPassword {db permission_list user } { global script_name @@ -988,7 +1065,7 @@ proc ShowControls { permission_list user } { } } # hide user groups - set user_groups_for_hide [list inforow student ta instructor] + set user_groups_for_hide [list inforow student ta instructor dropped] set currently_hidden_groups [SelectColValue4User UserHiddenGroups $user] # remove already hidden group from offering foreach grp $currently_hidden_groups { |