Parent Directory
|
Revision Log
Revision 1723 - (view) (download) (as text)
| 1 : | malsyned | 831 | ################################################################################ |
| 2 : | sh002i | 1663 | # WeBWorK Online Homework Delivery System |
| 3 : | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ | ||
| 4 : | gage | 1723 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/Index.pm,v 1.24 2004/01/16 04:15:46 gage Exp $ |
| 5 : | sh002i | 1663 | # |
| 6 : | # This program is free software; you can redistribute it and/or modify it under | ||
| 7 : | # the terms of either: (a) the GNU General Public License as published by the | ||
| 8 : | # Free Software Foundation; either version 2, or (at your option) any later | ||
| 9 : | # version, or (b) the "Artistic License" which comes with this package. | ||
| 10 : | # | ||
| 11 : | # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 : | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 13 : | # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the | ||
| 14 : | # Artistic License for more details. | ||
| 15 : | malsyned | 831 | ################################################################################ |
| 16 : | |||
| 17 : | package WeBWorK::ContentGenerator::Instructor::Index; | ||
| 18 : | use base qw(WeBWorK::ContentGenerator::Instructor); | ||
| 19 : | |||
| 20 : | =head1 NAME | ||
| 21 : | |||
| 22 : | WeBWorK::ContentGenerator::Instructor::Index - Menu interface to the Instructor pages | ||
| 23 : | |||
| 24 : | =cut | ||
| 25 : | |||
| 26 : | use strict; | ||
| 27 : | use warnings; | ||
| 28 : | gage | 1579 | use Apache::Constants qw(:common REDIRECT DONE); |
| 29 : | malsyned | 831 | use CGI qw(); |
| 30 : | gage | 1579 | sub pre_header_initialize { |
| 31 : | my ($self, $setName, $problemNumber) = @_; | ||
| 32 : | my $r = $self->{r}; | ||
| 33 : | my $ce = $self->{ce}; | ||
| 34 : | my $db = $self->{db}; | ||
| 35 : | my $authz = $self->{authz}; | ||
| 36 : | my $userName = $r->param('user'); | ||
| 37 : | my $effectiveUserName = $r->param('effectiveUser'); | ||
| 38 : | my $key = $r->param('key'); | ||
| 39 : | gage | 1667 | my $user = $db->getUser($userName); #checked |
| 40 : | sh002i | 1681 | die "user $user (real user) not found." unless $user; |
| 41 : | gage | 1667 | my $effectiveUser = $db->getUser($effectiveUserName); #checked |
| 42 : | die "effective user $effectiveUser not found. One 'acts as' the effective user." unless $effectiveUser; | ||
| 43 : | sh002i | 1681 | my $PermissionLevelRecord = $db->getPermissionLevel($userName); #checked |
| 44 : | die "permisson level for user $userName not found." unless $PermissionLevelRecord; | ||
| 45 : | my $permissionLevel = $PermissionLevelRecord->permission(); | ||
| 46 : | gage | 1667 | |
| 47 : | |||
| 48 : | |||
| 49 : | gage | 1579 | unless ($authz->hasPermissions($userName, "modify_student_data")) { |
| 50 : | $self->{submitError} = "You are not authorized to modify student data"; | ||
| 51 : | return; | ||
| 52 : | } | ||
| 53 : | my @submit_actions = qw(student-dates act-as-student edit-set-dates reset-password assign-passwords | ||
| 54 : | set-stats drop-students edit-students-sets edit-sets student-stats edit-class-data | ||
| 55 : | gage | 1581 | add-students send-email score-sets); |
| 56 : | gage | 1579 | foreach my $act (@submit_actions) { |
| 57 : | $self->{current_action } .= "The action <$act> "". $r->param($act) . "" was requested" | ||
| 58 : | if defined($r->param($act)); | ||
| 59 : | } | ||
| 60 : | $self->{selected_sets} = "Set(s) chosen: " . join(" ", $r->param("setList")); | ||
| 61 : | $self->{selected_users} = "Student(s) chosen: " .join(" ", $r->param("classList")) ; | ||
| 62 : | # Redirect actions | ||
| 63 : | defined($r->param('student-dates')) && do { | ||
| 64 : | #FIXME will only do one student and one set at a time | ||
| 65 : | # it would be good to be able to do many sets for many student | ||
| 66 : | # this would require a separate module | ||
| 67 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 68 : | my $courseName = $ce->{courseName}; | ||
| 69 : | my @userList = $r->param("classList"); | ||
| 70 : | # can only become the first user listed. | ||
| 71 : | my $student = shift @userList; | ||
| 72 : | my @setList = $r->param("setList"); | ||
| 73 : | # can only become the first user listed. | ||
| 74 : | my $setName = shift @setList; | ||
| 75 : | my $uri="$root/$courseName/instructor/sets/$setName/?editForUser=$student&".$self->url_authen_args; | ||
| 76 : | $r->header_out(Location => $uri); | ||
| 77 : | $self->{noContent} = 1; # forces redirect | ||
| 78 : | return; | ||
| 79 : | }; | ||
| 80 : | defined($r->param('act-as-student')) && do { | ||
| 81 : | # fix url and redirect | ||
| 82 : | my @userList = $r->param("classList"); | ||
| 83 : | # can only become the first user listed. | ||
| 84 : | my $effectiveUser = shift @userList; | ||
| 85 : | my @setList = $r->param("setList"); | ||
| 86 : | my $setName = shift @setList; | ||
| 87 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 88 : | my $courseName = $ce->{courseName}; | ||
| 89 : | sh002i | 1566 | |
| 90 : | gage | 1579 | my $uri="$root/$courseName/$setName/?effectiveUser=$effectiveUser&".$self->url_authen_args; |
| 91 : | #FIXME does the display mode need to be defined? | ||
| 92 : | #FIXME url_authen_args also includes an effective user, so the new one must come first. | ||
| 93 : | # even that might not work with every browser since there are two effective User assignments. | ||
| 94 : | $r->header_out(Location => $uri); | ||
| 95 : | $self->{noContent} = 1; # forces redirect | ||
| 96 : | return; | ||
| 97 : | }; | ||
| 98 : | defined($r->param('edit-set-dates')) && do { | ||
| 99 : | #FIXME this should be replaced by redirecting to a module where you can edit | ||
| 100 : | # dates for several sets at once | ||
| 101 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 102 : | my $courseName = $ce->{courseName}; | ||
| 103 : | my @setList = $r->param("setList"); | ||
| 104 : | # can only become the first user listed. | ||
| 105 : | my $setName = shift @setList; | ||
| 106 : | my $uri="$root/$courseName/instructor/sets/$setName/?".$self->url_authen_args; | ||
| 107 : | $r->header_out(Location => $uri); | ||
| 108 : | $self->{noContent} = 1; # forces redirect | ||
| 109 : | return; | ||
| 110 : | }; | ||
| 111 : | defined($r->param('reset-password')) && do { | ||
| 112 : | # FIXME this should allow me to assign studentID to a number of students | ||
| 113 : | # requires a new module | ||
| 114 : | my @userList = $r->param("classList"); | ||
| 115 : | # can only become the first user listed. | ||
| 116 : | my $effectiveUser = shift @userList; | ||
| 117 : | my @setList = $r->param("setList"); | ||
| 118 : | my $setName = shift @setList; | ||
| 119 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 120 : | my $courseName = $ce->{courseName}; | ||
| 121 : | |||
| 122 : | my $uri="$root/$courseName/options/?effectiveUser=$effectiveUser&".$self->url_authen_args; | ||
| 123 : | #FIXME does the display mode need to be defined? | ||
| 124 : | #FIXME url_authen_args also includes an effective user, so the new one must come first. | ||
| 125 : | # even that might not work with every browser since there are two effective User assignments. | ||
| 126 : | $r->header_out(Location => $uri); | ||
| 127 : | $self->{noContent} = 1; # forces redirect | ||
| 128 : | return; | ||
| 129 : | }; | ||
| 130 : | defined($r->param('assign-passwords')) && do { | ||
| 131 : | my @userList = $r->param("classList"); | ||
| 132 : | # can only become the first user listed. | ||
| 133 : | my $effectiveUser = shift @userList; | ||
| 134 : | my @setList = $r->param("setList"); | ||
| 135 : | my $setName = shift @setList; | ||
| 136 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 137 : | my $courseName = $ce->{courseName}; | ||
| 138 : | |||
| 139 : | my $uri="$root/$courseName/options/?effectiveUser=$effectiveUser&".$self->url_authen_args; | ||
| 140 : | #FIXME does the display mode need to be defined? | ||
| 141 : | #FIXME url_authen_args also includes an effective user, so the new one must come first. | ||
| 142 : | # even that might not work with every browser since there are two effective User assignments. | ||
| 143 : | $r->header_out(Location => $uri); | ||
| 144 : | $self->{noContent} = 1; # forces redirect | ||
| 145 : | return; | ||
| 146 : | }; | ||
| 147 : | defined($r->param('set-stats')) && do { | ||
| 148 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 149 : | my $courseName = $ce->{courseName}; | ||
| 150 : | my @setList = $r->param("setList"); | ||
| 151 : | # can only become the first user listed. | ||
| 152 : | my $setName = shift @setList; | ||
| 153 : | my $uri="$root/$courseName/instructor/stats/set/$setName?".$self->url_authen_args; | ||
| 154 : | $r->header_out(Location => $uri); | ||
| 155 : | $self->{noContent} = 1; # forces redirect | ||
| 156 : | return; | ||
| 157 : | }; | ||
| 158 : | defined($r->param('drop-students')) && do { | ||
| 159 : | #FIXME this operation should be made faster | ||
| 160 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 161 : | my $courseName = $ce->{courseName}; | ||
| 162 : | my @setList = $r->param("setList"); | ||
| 163 : | # can only become the first user listed. | ||
| 164 : | my $setName = shift @setList; | ||
| 165 : | my $uri="$root/$courseName/instructor/users/?".$self->url_authen_args; | ||
| 166 : | $r->header_out(Location => $uri); | ||
| 167 : | $self->{noContent} = 1; # forces redirect | ||
| 168 : | return; | ||
| 169 : | }; | ||
| 170 : | defined($r->param('edit-students-sets')) && do { | ||
| 171 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 172 : | my $courseName = $ce->{courseName}; | ||
| 173 : | my @userList = $r->param("classList"); | ||
| 174 : | # can only become the first user listed. | ||
| 175 : | my $student = shift @userList; | ||
| 176 : | my @setList = $r->param("setList"); | ||
| 177 : | # can only become the first user listed. | ||
| 178 : | my $setName = shift @setList; | ||
| 179 : | my $uri="$root/$courseName/instructor/sets/$setName/?editForUser=$student&".$self->url_authen_args; | ||
| 180 : | $r->header_out(Location => $uri); | ||
| 181 : | $self->{noContent} = 1; # forces redirect | ||
| 182 : | return; | ||
| 183 : | }; | ||
| 184 : | defined($r->param('edit-sets')) && do { | ||
| 185 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 186 : | my $courseName = $ce->{courseName}; | ||
| 187 : | my @setList = $r->param("setList"); | ||
| 188 : | # can only become the first user listed. | ||
| 189 : | my $setName = shift @setList; | ||
| 190 : | my $uri="$root/$courseName/instructor/sets/$setName/?".$self->url_authen_args; | ||
| 191 : | $r->header_out(Location => $uri); | ||
| 192 : | $self->{noContent} = 1; # forces redirect | ||
| 193 : | return; | ||
| 194 : | }; | ||
| 195 : | defined($r->param('student-stats')) && do { | ||
| 196 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 197 : | my $courseName = $ce->{courseName}; | ||
| 198 : | my @userList = $r->param("classList"); | ||
| 199 : | # can only become the first user listed. | ||
| 200 : | my $studentName = shift @userList; | ||
| 201 : | my $uri="$root/$courseName/instructor/stats/student/$studentName?".$self->url_authen_args; | ||
| 202 : | $r->header_out(Location => $uri); | ||
| 203 : | $self->{noContent} = 1; # forces redirect | ||
| 204 : | return; | ||
| 205 : | }; | ||
| 206 : | defined($r->param('edit-class-data')) && do { | ||
| 207 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 208 : | my $courseName = $ce->{courseName}; | ||
| 209 : | sh002i | 1594 | #my @setList = $r->param("setList"); |
| 210 : | ## can only become the first user listed. | ||
| 211 : | #my $setName = shift @setList; | ||
| 212 : | # ...not sure what those are about | ||
| 213 : | # get list of users selected | ||
| 214 : | my @userIDs = $r->param("classList"); | ||
| 215 : | my $uri="$root/$courseName/instructor/users/?"; | ||
| 216 : | $uri .= join("&", map { "visible_users=$_" } @userIDs); | ||
| 217 : | $uri .= "&editMode=1", | ||
| 218 : | $uri .= "&" . $self->url_authen_args; | ||
| 219 : | gage | 1579 | $r->header_out(Location => $uri); |
| 220 : | $self->{noContent} = 1; # forces redirect | ||
| 221 : | return; | ||
| 222 : | }; | ||
| 223 : | defined($r->param('add-students')) && do { | ||
| 224 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 225 : | my $courseName = $ce->{courseName}; | ||
| 226 : | |||
| 227 : | my $uri="$root/$courseName/instructor/add_users/?".$self->url_authen_args; | ||
| 228 : | $r->header_out(Location => $uri); | ||
| 229 : | $self->{noContent} = 1; # forces redirect | ||
| 230 : | return; | ||
| 231 : | }; | ||
| 232 : | defined($r->param('send-email')) && do { | ||
| 233 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 234 : | my $courseName = $ce->{courseName}; | ||
| 235 : | |||
| 236 : | my $uri="$root/$courseName/instructor/send_mail/?".$self->url_authen_args; | ||
| 237 : | $r->header_out(Location => $uri); | ||
| 238 : | $self->{noContent} = 1; # forces redirect | ||
| 239 : | return; | ||
| 240 : | }; | ||
| 241 : | gage | 1581 | defined($r->param('score-sets')) && do { |
| 242 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 243 : | my $courseName = $ce->{courseName}; | ||
| 244 : | gage | 1579 | |
| 245 : | gage | 1581 | my $uri="$root/$courseName/instructor/scoring/?scoreSelected=Score%20Selected&".$self->url_authen_args; |
| 246 : | my @selectedSets = $r->param('setList'); | ||
| 247 : | $uri .= "&selectedSet=$_" foreach (@selectedSets); | ||
| 248 : | $r->header_out(Location => $uri); | ||
| 249 : | $self->{noContent} = 1; # forces redirect | ||
| 250 : | return; | ||
| 251 : | }; | ||
| 252 : | |||
| 253 : | gage | 1579 | } |
| 254 : | # override contentGenerator header routine for now | ||
| 255 : | # FIXME | ||
| 256 : | sub header { | ||
| 257 : | my $self = shift; | ||
| 258 : | return REDIRECT if $self->{noContent}; | ||
| 259 : | my $r = $self->{r}; | ||
| 260 : | $r->content_type('text/html'); | ||
| 261 : | $r->send_http_header(); | ||
| 262 : | return OK; | ||
| 263 : | } | ||
| 264 : | gage | 1486 | sub initialize { |
| 265 : | my ($self) = @_; | ||
| 266 : | my $r = $self->{r}; | ||
| 267 : | my $db = $self->{db}; | ||
| 268 : | my $ce = $self->{ce}; | ||
| 269 : | my $authz = $self->{authz}; | ||
| 270 : | my $user = $r->param('user'); | ||
| 271 : | malsyned | 831 | |
| 272 : | gage | 1486 | unless ($authz->hasPermissions($user, "modify_student_data")) { |
| 273 : | $self->{submitError} = "You are not authorized to modify student data"; | ||
| 274 : | return; | ||
| 275 : | } | ||
| 276 : | |||
| 277 : | gage | 1579 | ############################################################################################# |
| 278 : | # gather database data | ||
| 279 : | ############################################################################################# | ||
| 280 : | # FIXME this might be better done in body? We don't always need all of this data. or do we? | ||
| 281 : | # Obtaining the list of users | ||
| 282 : | gage | 1667 | $WeBWorK::timer->continue("Begin listing users") if defined $WeBWorK::timer; |
| 283 : | my @userNames = $db->listUsers; # checked | ||
| 284 : | $WeBWorK::timer->continue("End listing users") if defined $WeBWorK::timer; | ||
| 285 : | $WeBWorK::timer->continue("Begin obtaining users") if defined $WeBWorK::timer; | ||
| 286 : | my @user_records = $db->getUsers(@userNames); # checked | ||
| 287 : | $WeBWorK::timer->continue("End obtaining users: ".@user_records) if defined $WeBWorK::timer; | ||
| 288 : | gage | 1579 | |
| 289 : | # store data | ||
| 290 : | $self->{ra_users} = \@userNames; | ||
| 291 : | $self->{ra_user_records} = \@user_records; | ||
| 292 : | |||
| 293 : | # Obtaining list of sets: | ||
| 294 : | gage | 1667 | $WeBWorK::timer->continue("Begin listing sets") if defined $WeBWorK::timer; |
| 295 : | gage | 1579 | my @setNames = $db->listGlobalSets(); |
| 296 : | gage | 1667 | $WeBWorK::timer->continue("End listing sets") if defined $WeBWorK::timer; |
| 297 : | gage | 1579 | my @set_records = (); |
| 298 : | gage | 1667 | $WeBWorK::timer->continue("Begin obtaining sets") if defined $WeBWorK::timer; |
| 299 : | gage | 1596 | @set_records = $db->getGlobalSets( @setNames); |
| 300 : | gage | 1667 | $WeBWorK::timer->continue("End obtaining sets: ".@set_records) if defined $WeBWorK::timer; |
| 301 : | gage | 1579 | # foreach my $name (@setNames) { |
| 302 : | # my $set_record; | ||
| 303 : | # $set_record = $db->getMergedSet($user,$name,) ; | ||
| 304 : | # | ||
| 305 : | # #warn "Adding set $name", ref($set_record); | ||
| 306 : | # push @set_records, $set_record; | ||
| 307 : | # } | ||
| 308 : | |||
| 309 : | |||
| 310 : | # store data | ||
| 311 : | $self->{ra_sets} = \@setNames; | ||
| 312 : | $self->{ra_set_records} = \@set_records; | ||
| 313 : | |||
| 314 : | gage | 1486 | } |
| 315 : | gage | 1295 | sub path { |
| 316 : | gage | 1579 | my $self = shift; |
| 317 : | my $args = $_[-1]; | ||
| 318 : | |||
| 319 : | gage | 1295 | my $ce = $self->{ce}; |
| 320 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 321 : | my $courseName = $ce->{courseName}; | ||
| 322 : | return $self->pathMacro($args, | ||
| 323 : | sh002i | 1681 | "Home" => "$root", |
| 324 : | $courseName => "$root/$courseName", | ||
| 325 : | "Instructor Tools" => "", | ||
| 326 : | gage | 1295 | ); |
| 327 : | } | ||
| 328 : | |||
| 329 : | malsyned | 831 | sub title { |
| 330 : | my $self = shift; | ||
| 331 : | sh002i | 1681 | return "Instructor Tools"; |
| 332 : | malsyned | 831 | } |
| 333 : | |||
| 334 : | sub body { | ||
| 335 : | my $self = shift; | ||
| 336 : | malsyned | 834 | my $r = $self->{r}; |
| 337 : | my $ce = $self->{ce}; | ||
| 338 : | malsyned | 1017 | my $db = $self->{db}; |
| 339 : | my $authz = $self->{authz}; | ||
| 340 : | malsyned | 834 | my $courseName = $ce->{courseName}; |
| 341 : | my $authen_args = $self->url_authen_args(); | ||
| 342 : | malsyned | 1017 | my $user = $r->param('user'); |
| 343 : | malsyned | 834 | my $prof_url = $ce->{webworkURLs}->{oldProf}; |
| 344 : | my $full_url = "$prof_url?course=$courseName&$authen_args"; | ||
| 345 : | malsyned | 996 | my $userEditorURL = "users/?" . $self->url_args; |
| 346 : | malsyned | 998 | my $problemSetEditorURL = "sets/?" . $self->url_args; |
| 347 : | sh002i | 1681 | my $statsURL = "stats/?" . $self->url_args; |
| 348 : | my $emailURL = "send_mail/?" . $self->url_args; | ||
| 349 : | my $scoringURL = "scoring/?" . $self->url_args; | ||
| 350 : | my $filexferURL = "files/?" . $self->url_args; | ||
| 351 : | my $actionURL = $r->uri; | ||
| 352 : | |||
| 353 : | gage | 1579 | return CGI::em('You are not authorized to access the Instructor tools.') unless $authz->hasPermissions($user, 'access_instructor_tools'); |
| 354 : | sh002i | 1681 | |
| 355 : | gage | 1723 | print join("", |
| 356 : | CGI::start_table({-border=>2,-cellpadding=>20}), | ||
| 357 : | CGI::Tr({-align=>'center'}, | ||
| 358 : | CGI::td([ | ||
| 359 : | CGI::a({href=>$userEditorURL}, "User List"), | ||
| 360 : | CGI::a({href=>$problemSetEditorURL}, "Set List"), | ||
| 361 : | CGI::a({-href=>$emailURL}, "Mail Merge"), | ||
| 362 : | CGI::a({-href=>$scoringURL}, "Scoring"), | ||
| 363 : | CGI::a({-href=>$statsURL}, "Statistics"), | ||
| 364 : | CGI::a({-href=>$emailURL}, "File Transfer"), | ||
| 365 : | ]), | ||
| 366 : | "\n", | ||
| 367 : | ), | ||
| 368 : | |||
| 369 : | CGI::Tr({ -align=>'left'}, | ||
| 370 : | CGI::td({-colspan=>6}, | ||
| 371 : | CGI::a({-href=>$full_url}, 'WeBWorK 1.x Instructor Tools'), | ||
| 372 : | " (" . CGI::a({-href=>$full_url, -target=>'_new'}, 'open in a new window') . ")", | ||
| 373 : | ), | ||
| 374 : | "\n", | ||
| 375 : | ), | ||
| 376 : | CGI::end_table(), | ||
| 377 : | ); | ||
| 378 : | sh002i | 1681 | |
| 379 : | print join("", | ||
| 380 : | gage | 1723 | CGI::p('Quick access to common instructor tools.'), |
| 381 : | gage | 1579 | CGI::start_form(-method=>"POST", -action=>$actionURL),"\n", |
| 382 : | $self->hidden_authen_fields,"\n", | ||
| 383 : | CGI::start_table({-border=>2,-cellpadding=>5}), | ||
| 384 : | CGI::Tr({ -align=>'center'}, | ||
| 385 : | CGI::td({colspan=>2},[ | ||
| 386 : | CGI::input({type=>'submit',value=>'Add students...',name=>'add-students'}), | ||
| 387 : | CGI::input({type=>'submit',value=>'Send email...',name=>'send-email'}), | ||
| 388 : | ] | ||
| 389 : | gage | 1433 | ), |
| 390 : | gage | 1579 | |
| 391 : | |||
| 392 : | ), | ||
| 393 : | CGI::Tr({ -align=>'center'}, | ||
| 394 : | CGI::td({colspan=>1},[ | ||
| 395 : | gage | 1433 | |
| 396 : | gage | 1579 | CGI::input({type=>'submit',value=>'Reset password',name=>'reset-password'}), |
| 397 : | CGI::input({type=>'submit',value=>'Assign passwords...',name=>'assign-passwords'}), | ||
| 398 : | CGI::input({type=>'submit',value=>'View set statistics...',name=>'set-stats'}), | ||
| 399 : | CGI::input({type=>'submit',value=>'Edit set(s) dates...',name=>'edit-set-dates'}) | ||
| 400 : | ] | ||
| 401 : | ) | ||
| 402 : | |||
| 403 : | ), | ||
| 404 : | CGI::Tr({ -align=>'center'}, | ||
| 405 : | CGI::td({colspan=>1},[ | ||
| 406 : | CGI::input({type=>'submit',value=>'View student statistics...',name=>'student-stats'}), | ||
| 407 : | CGI::input({type=>'submit',value=>'Edit class data for students...',name=>'edit-class-data'}), | ||
| 408 : | CGI::input({type=>'submit',value=>'Edit set(s) data...',name=>'edit-sets'}), | ||
| 409 : | gage | 1581 | CGI::input({type=>'submit',value=>'Score selected set(s)...',name=>'score-sets'}), |
| 410 : | gage | 1579 | ] |
| 411 : | sh002i | 1566 | ), |
| 412 : | gage | 1433 | ), |
| 413 : | gage | 1579 | |
| 414 : | |||
| 415 : | gage | 1433 | CGI::Tr({ -align=>'center'}, |
| 416 : | gage | 1579 | CGI::td({colspan=>2},[ |
| 417 : | $self->popup_user_form, | ||
| 418 : | $self->popup_set_form, | ||
| 419 : | ] | ||
| 420 : | ) | ||
| 421 : | |||
| 422 : | gage | 1433 | ), |
| 423 : | CGI::Tr({ -align=>'center'}, | ||
| 424 : | gage | 1579 | CGI::td({colspan=>1},[ |
| 425 : | |||
| 426 : | CGI::input({type=>'submit',value=>'Edit student(s)/set(s) dates',name=>'student-dates'}), | ||
| 427 : | CGI::input({type=>'submit',value=>'Act as student in set...',name=>'act-as-student'}), | ||
| 428 : | ] | ||
| 429 : | ), | ||
| 430 : | CGI::td({colspan=>2}, | ||
| 431 : | gage | 1581 | CGI::input({type=>'submit',value=>'Edit student(s) data for selected set(s)...',name=>'edit-students-sets'}), |
| 432 : | gage | 1579 | |
| 433 : | gage | 1581 | |
| 434 : | gage | 1579 | ) |
| 435 : | |||
| 436 : | gage | 1433 | ), |
| 437 : | gage | 1579 | |
| 438 : | CGI::Tr({ -align=>'center'}, | ||
| 439 : | CGI::td({colspan=>2},[ | ||
| 440 : | CGI::input({type=>'submit',value=>'Drop student(s)',name=>'drop-students'}), | ||
| 441 : | ' ' | ||
| 442 : | ] | ||
| 443 : | ), | ||
| 444 : | |||
| 445 : | gage | 1433 | |
| 446 : | gage | 1579 | ), |
| 447 : | |||
| 448 : | gage | 1433 | CGI::end_table(), |
| 449 : | gage | 1723 | CGI::end_form(), |
| 450 : | gage | 1433 | ); |
| 451 : | gage | 1723 | return ""; |
| 452 : | |||
| 453 : | malsyned | 831 | } |
| 454 : | gage | 1486 | sub addStudentForm { |
| 455 : | my $self = shift; | ||
| 456 : | my $r = $self->{r}; | ||
| 457 : | |||
| 458 : | # Add a student form | ||
| 459 : | gage | 1579 | join( "", |
| 460 : | gage | 1486 | CGI::p("Add new students"), |
| 461 : | CGI::start_form({method=>"post", action=>$r->uri()}), | ||
| 462 : | $self->hidden_authen_fields(), | ||
| 463 : | CGI::start_table({border=>'1', cellpadding=>'2'}), | ||
| 464 : | CGI::Tr({}, | ||
| 465 : | CGI::th({}, | ||
| 466 : | ['Last Name', 'First Name', 'Student ID', 'Login Name', 'Email Address', 'Section','Recitation', 'Comment'] | ||
| 467 : | ) | ||
| 468 : | ), | ||
| 469 : | CGI::Tr({}, | ||
| 470 : | CGI::td({}, | ||
| 471 : | [ CGI::input({name=>'last_name'}), | ||
| 472 : | CGI::input({name=>'first_name'}), | ||
| 473 : | CGI::input({name=>'student_id',size=>'16'}), | ||
| 474 : | CGI::input({name=>'new_user_id',size=>'10'}), | ||
| 475 : | CGI::input({name=>'email_address'}), | ||
| 476 : | CGI::input({name=>'section',size=>'10'}), | ||
| 477 : | CGI::input({name=>'recitation',size=>'10'}), | ||
| 478 : | CGI::input({name=>'comment'}), | ||
| 479 : | |||
| 480 : | |||
| 481 : | ] | ||
| 482 : | ) | ||
| 483 : | ), | ||
| 484 : | CGI::end_table(), | ||
| 485 : | CGI::submit({name=>"addStudent", value=>"Add Student"}), | ||
| 486 : | CGI::end_form(), | ||
| 487 : | ); | ||
| 488 : | gage | 1579 | |
| 489 : | |||
| 490 : | |||
| 491 : | |||
| 492 : | |||
| 493 : | |||
| 494 : | gage | 1486 | } |
| 495 : | gage | 1579 | sub popup_user_form { |
| 496 : | my $self = shift; | ||
| 497 : | my $r = $self->{r}; | ||
| 498 : | my $authz = $self->{authz}; | ||
| 499 : | my $user = $r->param('user'); | ||
| 500 : | my $db = $self->{db}; | ||
| 501 : | my $ce = $self->{ce}; | ||
| 502 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 503 : | my $courseName = $ce->{courseName}; | ||
| 504 : | sh002i | 1566 | |
| 505 : | gage | 1579 | # return CGI::em("You are not authorized to access the Instructor tools.") unless $authz->hasPermissions($user, "access_instructor_tools"); |
| 506 : | |||
| 507 : | # This code will require changing if the permission and user tables ever have different keys. | ||
| 508 : | my @users = (); | ||
| 509 : | my $ra_user_records = $self->{ra_user_records}; | ||
| 510 : | my %classlistLabels = ();# %$hr_classlistLabels; | ||
| 511 : | my @user_records = sort { ( lc($a->section) cmp lc($b->section) ) || | ||
| 512 : | ( lc($a->last_name) cmp lc($b->last_name )) } @{$ra_user_records}; | ||
| 513 : | foreach my $ur (@{user_records}) { | ||
| 514 : | $classlistLabels{$ur->user_id} = $ur->last_name. ', '. $ur->first_name.' - '.$ur->section.' '.$ur->user_id; | ||
| 515 : | push(@users, $ur->user_id); | ||
| 516 : | } | ||
| 517 : | return CGI::popup_menu(-name=>'classList', | ||
| 518 : | -values=>\@users, | ||
| 519 : | -labels=>\%classlistLabels, | ||
| 520 : | -size => 10, | ||
| 521 : | -multiple => 1, | ||
| 522 : | sh002i | 1601 | #-default=>$user |
| 523 : | gage | 1579 | ), |
| 524 : | |||
| 525 : | |||
| 526 : | } | ||
| 527 : | sub popup_set_form { | ||
| 528 : | my $self = shift; | ||
| 529 : | my $r = $self->{r}; | ||
| 530 : | my $authz = $self->{authz}; | ||
| 531 : | my $user = $r->param('user'); | ||
| 532 : | my $db = $self->{db}; | ||
| 533 : | my $ce = $self->{ce}; | ||
| 534 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 535 : | my $courseName = $ce->{courseName}; | ||
| 536 : | |||
| 537 : | # return CGI::em("You are not authorized to access the Instructor tools.") unless $authz->hasPermissions($user, "access_instructor_tools"); | ||
| 538 : | |||
| 539 : | # This code will require changing if the permission and user tables ever have different keys. | ||
| 540 : | my @setNames = (); | ||
| 541 : | my $ra_set_records = $self->{ra_set_records}; | ||
| 542 : | my %setLabels = ();# %$hr_classlistLabels; | ||
| 543 : | my @set_records = sort {$a->set_id cmp $b->set_id } @{$ra_set_records}; | ||
| 544 : | foreach my $sr (@set_records) { | ||
| 545 : | $setLabels{$sr->set_id} = $sr->set_id; | ||
| 546 : | push(@setNames, $sr->set_id); # reorder sets | ||
| 547 : | } | ||
| 548 : | return CGI::popup_menu(-name=>'setList', | ||
| 549 : | -values=>\@setNames, | ||
| 550 : | -labels=>\%setLabels, | ||
| 551 : | -size => 10, | ||
| 552 : | -multiple => 1, | ||
| 553 : | #-default=>$user | ||
| 554 : | ), | ||
| 555 : | |||
| 556 : | |||
| 557 : | } | ||
| 558 : | malsyned | 831 | 1; |
| 559 : | |||
| 560 : | __END__ | ||
| 561 : | |||
| 562 : | =head1 AUTHOR | ||
| 563 : | |||
| 564 : | Written by Dennis Lambe Jr., malsyned (at) math.rochester.edu | ||
| 565 : | |||
| 566 : | =cut |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |