Parent Directory
|
Revision Log
Revision 1667 - (view) (download) (as text)
| 1 : | gage | 1577 | ################################################################################ |
| 2 : | sh002i | 1663 | # WeBWorK Online Homework Delivery System |
| 3 : | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ | ||
| 4 : | gage | 1667 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/AddUsers.pm,v 1.2 2003/12/09 01:12:31 sh002i 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 : | gage | 1577 | ################################################################################ |
| 16 : | |||
| 17 : | package WeBWorK::ContentGenerator::Instructor::AddUsers; | ||
| 18 : | use base qw(WeBWorK::ContentGenerator::Instructor); | ||
| 19 : | |||
| 20 : | =head1 NAME | ||
| 21 : | |||
| 22 : | WeBWorK::ContentGenerator::Instructor::AddUsers - Menu interface for adding users | ||
| 23 : | |||
| 24 : | |||
| 25 : | =cut | ||
| 26 : | |||
| 27 : | use strict; | ||
| 28 : | use warnings; | ||
| 29 : | use CGI qw(); | ||
| 30 : | |||
| 31 : | sub initialize { | ||
| 32 : | my ($self) = @_; | ||
| 33 : | my $r = $self->{r}; | ||
| 34 : | my $db = $self->{db}; | ||
| 35 : | my $ce = $self->{ce}; | ||
| 36 : | my $authz = $self->{authz}; | ||
| 37 : | my $user = $r->param('user'); | ||
| 38 : | |||
| 39 : | unless ($authz->hasPermissions($user, "modify_student_data")) { | ||
| 40 : | $self->{submitError} = "You are not authorized to modify student data"; | ||
| 41 : | return; | ||
| 42 : | } | ||
| 43 : | |||
| 44 : | if (defined($r->param('addStudent'))) { | ||
| 45 : | my $newUser = $db->newUser; | ||
| 46 : | my $newPermissionLevel = $db->newPermissionLevel; | ||
| 47 : | my $newPassword = $db->newPassword; | ||
| 48 : | $newUser->user_id($r->param('new_user_id')); | ||
| 49 : | $newPermissionLevel->user_id($r->param('new_user_id')); | ||
| 50 : | $newPassword->user_id($r->param('new_user_id')); | ||
| 51 : | $newUser->last_name($r->param('last_name')); | ||
| 52 : | $newUser->first_name($r->param('first_name')); | ||
| 53 : | $newUser->student_id($r->param('student_id')); | ||
| 54 : | $newUser->email_address($r->param('email_address')); | ||
| 55 : | $newUser->section($r->param('section')); | ||
| 56 : | $newUser->recitation($r->param('recitation')); | ||
| 57 : | $newUser->comment($r->param('comment')); | ||
| 58 : | $newUser->status('C'); | ||
| 59 : | $newPermissionLevel->permission(0); | ||
| 60 : | #FIXME handle errors if user exists already | ||
| 61 : | $db->addUser($newUser); | ||
| 62 : | $db->addPermissionLevel($newPermissionLevel); | ||
| 63 : | $db->addPassword($newPassword); | ||
| 64 : | $self->{studentEntryReport} = join("", | ||
| 65 : | "Entered student", CGI::br(), | ||
| 66 : | "Name: ", $newUser->last_name, ", ",$newUser->first_name,CGI::br(), | ||
| 67 : | " login/studentID: ", $newUser->user_id, "/",$newUser->student_id,CGI::br(), | ||
| 68 : | " email: ", $newUser->email_address,CGI::br(), | ||
| 69 : | " section: ", $newUser->section,CGI::br(), | ||
| 70 : | |||
| 71 : | ); | ||
| 72 : | } | ||
| 73 : | } | ||
| 74 : | |||
| 75 : | sub path { | ||
| 76 : | my $self = shift; | ||
| 77 : | my $args = $_[-1]; | ||
| 78 : | my $ce = $self->{ce}; | ||
| 79 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 80 : | my $courseName = $ce->{courseName}; | ||
| 81 : | |||
| 82 : | return $self->pathMacro($args, | ||
| 83 : | "Home" => "$root", | ||
| 84 : | $courseName => "$root/$courseName", | ||
| 85 : | 'Instructor Tools' => '', | ||
| 86 : | ); | ||
| 87 : | } | ||
| 88 : | |||
| 89 : | sub title { | ||
| 90 : | my $self = shift; | ||
| 91 : | return "Instructor Tools"; | ||
| 92 : | } | ||
| 93 : | |||
| 94 : | sub body { | ||
| 95 : | my $self = shift; | ||
| 96 : | my $r = $self->{r}; | ||
| 97 : | my $ce = $self->{ce}; | ||
| 98 : | my $db = $self->{db}; | ||
| 99 : | my $authz = $self->{authz}; | ||
| 100 : | my $courseName = $ce->{courseName}; | ||
| 101 : | my $authen_args = $self->url_authen_args(); | ||
| 102 : | my $user = $r->param('user'); | ||
| 103 : | my $prof_url = $ce->{webworkURLs}->{oldProf}; | ||
| 104 : | my $full_url = "$prof_url?course=$courseName&$authen_args"; | ||
| 105 : | my $userEditorURL = "users/?" . $self->url_args; | ||
| 106 : | my $problemSetEditorURL = "sets/?" . $self->url_args; | ||
| 107 : | my $statsURL = "stats/?" . $self->url_args; | ||
| 108 : | my $emailURL = "send_mail/?" . $self->url_args; | ||
| 109 : | |||
| 110 : | ################### debug code | ||
| 111 : | gage | 1667 | #my $permissonLevel = $self->{db}->getPermissionLevel($user)->permission(); #checked |
| 112 : | gage | 1577 | #my $courseEnvironmentLevels = $self->{ce}->{permissionLevels}; |
| 113 : | #return CGI::em(" user $permissonLevel permlevels ".join("<>",%$courseEnvironmentLevels)); | ||
| 114 : | ################### debug code | ||
| 115 : | |||
| 116 : | return CGI::em('You are not authorized to access the Instructor tools.') | ||
| 117 : | unless $authz->hasPermissions($user, 'access_instructor_tools'); | ||
| 118 : | |||
| 119 : | return join("", | ||
| 120 : | CGI::start_table({-border=>2,-cellpadding=>20}), | ||
| 121 : | CGI::Tr({-align=>'center'}, | ||
| 122 : | CGI::td( | ||
| 123 : | CGI::a({href=>$userEditorURL}, "Edit $courseName class list") , | ||
| 124 : | ), | ||
| 125 : | CGI::td( | ||
| 126 : | CGI::a({href=>$problemSetEditorURL}, "Edit $courseName problem sets"), | ||
| 127 : | |||
| 128 : | ), | ||
| 129 : | "\n", | ||
| 130 : | ), | ||
| 131 : | CGI::Tr({ -align=>'center'}, | ||
| 132 : | CGI::td([ | ||
| 133 : | CGI::a({-href=>$emailURL}, "Send e-mail to $courseName"), | ||
| 134 : | CGI::a({-href=>$statsURL}, "Statistics for $courseName"), | ||
| 135 : | ]), | ||
| 136 : | "\n", | ||
| 137 : | ), | ||
| 138 : | CGI::Tr({ -align=>'center'}, | ||
| 139 : | CGI::td([ | ||
| 140 : | 'WeBWorK 1.9 Instructor '.CGI::a({-href=>$full_url}, 'Tools'), | ||
| 141 : | 'Open WeBWorK 1.9 Instructor '.CGI::a({-href=>$full_url, -target=>'_new'}, 'Tools').' in new window', | ||
| 142 : | ]), | ||
| 143 : | "\n", | ||
| 144 : | ), | ||
| 145 : | |||
| 146 : | CGI::end_table(), | ||
| 147 : | CGI::hr(), | ||
| 148 : | CGI::p( | ||
| 149 : | defined($self->{studentEntryReport}) | ||
| 150 : | ? $self->{studentEntryReport} | ||
| 151 : | : '' | ||
| 152 : | ), | ||
| 153 : | $self->addStudentForm, | ||
| 154 : | ); | ||
| 155 : | } | ||
| 156 : | |||
| 157 : | sub addStudentForm { | ||
| 158 : | my $self = shift; | ||
| 159 : | my $r = $self->{r}; | ||
| 160 : | |||
| 161 : | # Add a student form | ||
| 162 : | return join("", | ||
| 163 : | CGI::p("Add new students"), | ||
| 164 : | CGI::start_form({method=>"post", action=>$r->uri()}), | ||
| 165 : | $self->hidden_authen_fields(), | ||
| 166 : | CGI::start_table({border=>'1', cellpadding=>'2'}), | ||
| 167 : | CGI::Tr({}, | ||
| 168 : | CGI::th({}, | ||
| 169 : | ['Last Name', 'First Name', 'Student ID', 'Login Name', 'Email Address', 'Section','Recitation', 'Comment'] | ||
| 170 : | ) | ||
| 171 : | ), | ||
| 172 : | CGI::Tr({}, | ||
| 173 : | CGI::td({}, | ||
| 174 : | [ CGI::input({name=>'last_name'}), | ||
| 175 : | CGI::input({name=>'first_name'}), | ||
| 176 : | CGI::input({name=>'student_id',size=>'16'}), | ||
| 177 : | CGI::input({name=>'new_user_id',size=>'10'}), | ||
| 178 : | CGI::input({name=>'email_address'}), | ||
| 179 : | CGI::input({name=>'section',size=>'10'}), | ||
| 180 : | CGI::input({name=>'recitation',size=>'10'}), | ||
| 181 : | CGI::input({name=>'comment'}), | ||
| 182 : | |||
| 183 : | |||
| 184 : | ] | ||
| 185 : | ) | ||
| 186 : | ), | ||
| 187 : | CGI::end_table(), | ||
| 188 : | CGI::submit({name=>"addStudent", value=>"Add Student"}), | ||
| 189 : | CGI::end_form(), | ||
| 190 : | ); | ||
| 191 : | } | ||
| 192 : | |||
| 193 : | 1; | ||
| 194 : | |||
| 195 : | __END__ | ||
| 196 : | |||
| 197 : | =head1 AUTHOR | ||
| 198 : | |||
| 199 : | Written by Dennis Lambe Jr., malsyned (at) math.rochester.edu | ||
| 200 : | |||
| 201 : | =cut |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |