Parent Directory
|
Revision Log
Revision 1212 - (view) (download) (as text)
| 1 : | malsyned | 832 | package WeBWorK::ContentGenerator::Instructor::UserList; |
| 2 : | use base qw(WeBWorK::ContentGenerator::Instructor); | ||
| 3 : | |||
| 4 : | =head1 NAME | ||
| 5 : | |||
| 6 : | WeBWorK::ContentGenerator::Instructor::UserList - Entry point for User-specific data editing | ||
| 7 : | |||
| 8 : | =cut | ||
| 9 : | |||
| 10 : | use strict; | ||
| 11 : | use warnings; | ||
| 12 : | use CGI qw(); | ||
| 13 : | |||
| 14 : | malsyned | 1015 | sub initialize { |
| 15 : | malsyned | 1211 | my ($self) = @_; |
| 16 : | my $r = $self->{r}; | ||
| 17 : | my $db = $self->{db}; | ||
| 18 : | my $ce = $self->{ce}; | ||
| 19 : | my $authz = $self->{authz}; | ||
| 20 : | my $user = $r->param('user'); | ||
| 21 : | |||
| 22 : | unless ($authz->hasPermissions($user, "modify_student_data")) { | ||
| 23 : | $self->{submitError} = "You are not authorized to modify student data"; | ||
| 24 : | return; | ||
| 25 : | } | ||
| 26 : | |||
| 27 : | if (defined($r->param('save_classlist'))) { | ||
| 28 : | my @userList = $db->listUsers; | ||
| 29 : | foreach my $user (@userList) { | ||
| 30 : | my $userRecord = $db->getUser($user); | ||
| 31 : | my $permissionLevelRecord = $db->getPermissionLevel($user); | ||
| 32 : | foreach my $field ($userRecord->NONKEYFIELDS()) { | ||
| 33 : | my $paramName = "user.${user}.${field}"; | ||
| 34 : | if (defined($r->param($paramName))) { | ||
| 35 : | $userRecord->$field($r->param($paramName)); | ||
| 36 : | } | ||
| 37 : | } | ||
| 38 : | foreach my $field ($permissionLevelRecord->NONKEYFIELDS()) { | ||
| 39 : | my $paramName = "permission.${user}.${field}"; | ||
| 40 : | if (defined($r->param($paramName))) { | ||
| 41 : | $permissionLevelRecord->$field($r->param($paramName)); | ||
| 42 : | } | ||
| 43 : | } | ||
| 44 : | $db->putUser($userRecord); | ||
| 45 : | $db->putPermissionLevel($permissionLevelRecord); | ||
| 46 : | } | ||
| 47 : | } | ||
| 48 : | malsyned | 1015 | } |
| 49 : | |||
| 50 : | malsyned | 1014 | sub body { |
| 51 : | malsyned | 1015 | my ($self, $setID) = @_; |
| 52 : | malsyned | 1014 | my $r = $self->{r}; |
| 53 : | malsyned | 1017 | my $authz = $self->{authz}; |
| 54 : | my $user = $r->param('user'); | ||
| 55 : | malsyned | 1110 | my $db = $self->{db}; |
| 56 : | malsyned | 1017 | |
| 57 : | return CGI::em("You are not authorized to access the Instructor tools.") unless $authz->hasPermissions($user, "access_instructor_tools"); | ||
| 58 : | |||
| 59 : | malsyned | 1110 | my @users = $db->listUsers; |
| 60 : | malsyned | 1211 | print CGI::start_form({method=>"post", action=>$r->uri()}); |
| 61 : | malsyned | 1110 | print CGI::start_table({}); |
| 62 : | print CGI::Tr({}, | ||
| 63 : | CGI::td({}, [ | ||
| 64 : | $db->{user}->{record}->FIELDS(), | ||
| 65 : | grep {! m/^user_id$/} $db->{permission}->{record}->FIELDS(), | ||
| 66 : | ]) | ||
| 67 : | ); | ||
| 68 : | malsyned | 1211 | |
| 69 : | malsyned | 1110 | foreach my $currentUser (@users) { |
| 70 : | my $userRecord = $db->getUser($currentUser); | ||
| 71 : | my $permissionLevel = $db->getPermissionLevel($currentUser); | ||
| 72 : | |||
| 73 : | print CGI::Tr({}, | ||
| 74 : | CGI::td({}, [ | ||
| 75 : | malsyned | 1211 | (map {CGI::input({type=>"text", size=>"8", name=> "user.".$userRecord->user_id().".".$_, value=>$userRecord->$_})} $userRecord->FIELDS()), |
| 76 : | (map {CGI::input({type=>"text", size=>"8", name => "permission.".$permissionLevel->user_id().".".$_, value=>$permissionLevel->$_})} grep {! m/^user_id$/} $permissionLevel->FIELDS()), | ||
| 77 : | malsyned | 1110 | ]) |
| 78 : | ); | ||
| 79 : | |||
| 80 : | # foreach my $key ($userRecord->FIELDS) { | ||
| 81 : | # print "$key: ", $userRecord->$key, CGI::br(); | ||
| 82 : | # } | ||
| 83 : | # foreach my $key ($permissionLevel->FIELDS) { | ||
| 84 : | # print "$key: ", $permissionLevel->$key, CGI::br(); | ||
| 85 : | # } | ||
| 86 : | # print CGI::p(); | ||
| 87 : | } | ||
| 88 : | print CGI::end_table(); | ||
| 89 : | malsyned | 1211 | print $self->hidden_authen_fields(); |
| 90 : | print CGI::submit({name=>"save_classlist", value=>"Save Changes to Users"}); | ||
| 91 : | print CGI::end_form(); | ||
| 92 : | malsyned | 1017 | |
| 93 : | malsyned | 1014 | return ""; |
| 94 : | } | ||
| 95 : | |||
| 96 : | malsyned | 832 | 1; |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |