Annotation of loncom/enrollment/Enrollment.pm, revision 1.41
1.7 albertel 1: # Automated Enrollment manager
1.41 ! raeburn 2: # $Id: Enrollment.pm,v 1.40 2009/03/09 01:58:52 weissno Exp $
1.7 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
1.1 raeburn 26: package LONCAPA::Enrollment;
27:
28: use Apache::loncoursedata;
29: use Apache::lonnet;
1.32 albertel 30: use Apache::loncommon();
1.8 raeburn 31: use Apache::lonmsg;
1.28 raeburn 32: use Apache::lonlocal;
1.1 raeburn 33: use HTML::Entities;
34: use LONCAPA::Configuration;
1.8 raeburn 35: use Time::Local;
36: use lib '/home/httpd/lib/perl';
1.1 raeburn 37:
38: use strict;
39:
40: sub update_LC {
1.28 raeburn 41: my ($dom,$crs,$adds,$drops,$startdate,$enddate,$authtype,$autharg,$classesref,$groupref,$logmsg,$newusermsg,$context,$phototypes) = @_;
1.19 raeburn 42: # Get institutional code and title of this class
43: my %courseinfo = ();
44: &get_courseinfo($dom,$crs,\%courseinfo);
1.1 raeburn 45: # Get current LON-CAPA student enrollment for this class
46: my $configvars = &LONCAPA::Configuration::read_conf('loncapa.conf');
47: my $cid = $dom."_".$crs;
1.26 raeburn 48: my $roster = &Apache::loncoursedata::get_classlist($dom,$crs);
1.1 raeburn 49: my $cend = &Apache::loncoursedata::CL_END;
50: my $cstart = &Apache::loncoursedata::CL_START;
51: my $stuid=&Apache::loncoursedata::CL_ID;
52: my $sec=&Apache::loncoursedata::CL_SECTION;
53: my $status=&Apache::loncoursedata::CL_STATUS;
54: my $type=&Apache::loncoursedata::CL_TYPE;
1.16 raeburn 55: my $lockedtype=&Apache::loncoursedata::CL_LOCKEDTYPE;
1.1 raeburn 56: my @localstudents = ();
1.15 raeburn 57: my @futurestudents = ();
58: my @activestudents = ();
1.18 raeburn 59: my @excludedstudents = ();
1.1 raeburn 60: my $currlist;
61: foreach my $uname (keys %{$roster} ) {
62: if ($uname =~ m/^(.+):$dom$/) {
63: if ($$roster{$uname}[$status] eq "Active") {
1.15 raeburn 64: push @activestudents, $1;
65: @{$$currlist{$1}} = @{$$roster{$uname}};
1.1 raeburn 66: push @localstudents, $1;
1.15 raeburn 67: } elsif ( ($$roster{$uname}[$cstart] > time) && ($$roster{$uname}[$cend] > time || $$roster{$uname}[$cend] == 0 || $$roster{$uname}[$cend] eq '') ) {
68: push @futurestudents, $1;
1.1 raeburn 69: @{$$currlist{$1}} = @{$$roster{$uname}};
1.15 raeburn 70: push @localstudents, $1;
1.18 raeburn 71: } elsif ($$roster{$uname}[$lockedtype] == 1) {
72: push @excludedstudents, $1;
1.1 raeburn 73: }
74: }
75: }
76: my $linefeed = '';
77: my $addresult = '';
78: my $dropresult = '';
1.21 raeburn 79: my $switchresult = '';
1.28 raeburn 80: my $photoresult = '';
1.1 raeburn 81: if ($context eq "updatenow") {
82: $linefeed = "</li>\n<li>";
83: } elsif ($context eq "automated") {
84: $linefeed = "\n";
85: }
86: my $enrollcount = 0;
87: my $dropcount = 0;
1.21 raeburn 88: my $switchcount = 0;
1.1 raeburn 89:
1.19 raeburn 90: # Get role names
91: my %longroles = ();
92: open(FILE,"<$$configvars{'lonTabDir'}.'/rolesplain.tab");
93: my @rolesplain = <FILE>;
94: close(FILE);
95: foreach (@rolesplain) {
96: if ($_ =~ /^(st|ta|ex|ad|in|cc):([\w\s]+)$/) {
97: $longroles{$1} = $2;
98: }
99: }
100:
1.8 raeburn 101: srand( time() ^ ($$ + ($$ << 15)) ); # Seed rand in case initial passwords have to be generated for new users.
102:
1.1 raeburn 103: # Get mapping of IDs to usernames for current LON-CAPA student enrollment for this class
104: my @LCids = ();
105: my %unameFromLCid = ();
106: foreach my $uname (sort keys %{$currlist}) {
107: my $stuID = $$currlist{$uname}[$stuid];
108: if (!grep/^$stuID$/,@LCids) {
109: push @LCids, $stuID;
110: @{$unameFromLCid{$stuID}} = ();
111: }
112: push @{$unameFromLCid{$stuID}},$uname;
113: }
114:
115: # Get latest institutional enrollment for this class.
116: my %allenrolled = ();
117: my @reg_students = ();
1.38 raeburn 118: my %place = &place_hash();
1.1 raeburn 119: my %ucount = ();
120: my %enrollinfo = ();
121: foreach my $class (@{$classesref}) {
122: my %enrolled = ();
123: &parse_classlist($$configvars{'lonDaemons'},$dom,$crs,$class,\%place,$$groupref{$class},\%enrolled);
124: foreach my $uname (sort keys %enrolled ) {
125: if (!grep/^$uname$/,@reg_students) {
126: push @reg_students,$uname;
127: $ucount{$uname} = 0;
128: @{$allenrolled{$uname}} = ();
129: }
130: @{$allenrolled{$uname}[$ucount{$uname}]} = @{$enrolled{$uname}};
131: $ucount{$uname} ++;
132: }
133: }
134:
135: # Check for multiple sections for a single student
136: my @okusers = ();
137: foreach my $uname (@reg_students) {
1.18 raeburn 138: if (grep/^$uname$/,@excludedstudents) {
1.33 raeburn 139: $$logmsg .= &mt('No re-enrollment for [_1] - user was previously manually unenrolled and locked.',$uname).$linefeed;
1.18 raeburn 140: } elsif (@{$allenrolled{$uname}} > 1) {
1.1 raeburn 141: my @sections = ();
142: my $saved;
143: for (my $i=0; $i<@{$allenrolled{$uname}}; $i++) {
144: my @stuinfo = @{$allenrolled{$uname}[$i]};
145: my $secnum = $stuinfo[ $place{'groupID'} ];
146: unless ($secnum eq '') {
147: unless (grep/^$secnum$/,@sections) {
148: $saved = $i;
149: push @sections,$secnum;
150: }
151: }
152: }
153: if (@sections == 0) {
154: @{$enrollinfo{$uname}} = @{$allenrolled{$uname}[0]};
155: push @okusers, $uname;
156: }
157: elsif (@sections == 1) {
158: @{$enrollinfo{$uname}} = @{$allenrolled{$uname}[$saved]};
159: push @okusers, $uname;
160: }
161: elsif (@sections > 1) {
1.33 raeburn 162: $$logmsg .= &mt('[_1] appears in classlists for more than one section of this course, i.e. in sections: ',$uname);
1.1 raeburn 163: foreach (@sections) {
1.5 raeburn 164: $$logmsg .= " $_,";
1.1 raeburn 165: }
1.5 raeburn 166: chop($$logmsg);
1.33 raeburn 167: $$logmsg .= '. '.&mt('Because of this ambiguity, no enrollment action was taken for this student.').$linefeed;
1.1 raeburn 168: }
169: } else {
170: @{$enrollinfo{$uname}} = @{$allenrolled{$uname}[0]};
171: push @okusers, $uname;
172: }
173: }
1.40 weissno 174: # Get mapping of student/employee IDs to usernames for users in institutional data for this class
1.1 raeburn 175: my @allINids = ();
1.3 raeburn 176: my %unameFromINid = ();
1.1 raeburn 177: foreach my $uname (@okusers) {
178: $enrollinfo{$uname}[ $place{'studentID'} ] =~ tr/A-Z/a-z/;
179: my $stuID = $enrollinfo{$uname}[ $place{'studentID'} ];
180: if (grep/^$stuID$/,@allINids) {
181: push @{$unameFromINid{$stuID}},$uname;
182: } else {
183: push @allINids, $stuID;
184: @{$unameFromINid{$stuID}} = $uname;
185: }
186: }
1.28 raeburn 187:
1.5 raeburn 188: # Explicitly allow access to creation/modification of students if called as an automated process.
189: if ($context eq 'automated') {
1.22 albertel 190: $env{'allowed.cst'}='F';
1.5 raeburn 191: }
192:
1.1 raeburn 193: # Compare IDs with existing LON-CAPA enrollment for this class
194: foreach my $uname (@okusers) {
1.5 raeburn 195: unless ($uname eq '') {
196: my %uidhash=&Apache::lonnet::idrget($dom,$uname);
197: my @stuinfo = @{$enrollinfo{$uname}};
1.15 raeburn 198: my $access = '';
1.5 raeburn 199: if (grep/^$uname$/,@localstudents) {
1.1 raeburn 200: # Check for studentID changes
1.5 raeburn 201: if ( ($uidhash{$uname}) && ($uidhash{$uname} !~ /error\:/) ) {
202: unless ( ($uidhash{$uname}) eq ($stuinfo[ $place{studentID} ]) ) {
1.33 raeburn 203: $$logmsg .= &mt('Change in ID for [_1]. StudentID in LON-CAPA system is [_2]; StudentID in institutional data is [_3].',$uname,$uidhash{$uname},$stuinfo[ $place{studentID} ]).$linefeed;
1.5 raeburn 204: }
1.1 raeburn 205: }
1.16 raeburn 206: # Check for switch from manual to auto
207: unless (($$currlist{$uname}[$type] eq "auto") || ($$currlist{$uname}[$lockedtype] eq "1") || (!$adds) ) {
208: # drop manually added student
1.38 raeburn 209: my $drop_reply = &Apache::lonnet::modifystudent($dom,$uname,'','','',undef,undef,undef,undef,$$currlist{$uname}[$sec],time,undef,undef,undef,undef,'auto','',$cid,'',$context);
1.16 raeburn 210: # re-enroll as auto student
211: if ($drop_reply !~ /^ok/) {
1.33 raeburn 212: $$logmsg .= &mt('An error occured during the attempt to convert [_1] from a manual type to an auto type student - [_2].',$uname,$drop_reply).$linefeed;
1.16 raeburn 213: } else {
214: # re-enroll as auto student
215: my ($auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,$emailaddr,$pid,$emailenc);
216: &prepare_add($authtype,$autharg,$enddate,$startdate,\@stuinfo,\%place,\$dom,\$uname,\$auth,\$authparam,\$first,\$middle,\$last,\$gene,\$usec,\$end,\$start,\$emailaddr,\$pid,\$emailenc);
217: if ($$currlist{$uname}[$sec] ne $usec) {
1.33 raeburn 218: my $showoldsec = $$currlist{$uname}[$sec];
219: if ($$currlist{$uname}[$sec] eq '') {
220: $showoldsec = &mt('none');
221: }
222: my $showsec = $usec;
223: if ($usec eq '') {
224: $showsec = &mt('none');
225: }
226: $switchresult .= &mt("Section for [_1] switched from '[_2]' to '[_3]'.",$uname,$showoldsec,$showsec).$linefeed;
1.21 raeburn 227: if ($context eq 'automated') {
1.33 raeburn 228: $$logmsg .= &mt("Section switch for [_1] from '[_2]' to '[_3]'.",$uname,$showoldsec,$usec).$linefeed;
1.21 raeburn 229: }
230: $switchcount ++;
1.16 raeburn 231: }
232: &execute_add($context,'switchtype',$uname,$dom,$auth,$authparam,$first,$middle,$last,$gene,$pid,$usec,$end,$start,$emailenc,$cid,\$addresult,\$enrollcount,$linefeed,$logmsg);
233: }
234: }
1.1 raeburn 235: # Check for section changes
1.15 raeburn 236: if ($$currlist{$uname}[$sec] eq $stuinfo[ $place{groupID} ]) {
237: # Check for access date changes for students with access starting in the future.
238: if ( (grep/^$uname$/,@futurestudents) && ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) {
1.16 raeburn 239: my $datechange = &datechange_check($$currlist{$uname}[$cstart],$$currlist{$uname}[$cend],$startdate,$enddate);
1.15 raeburn 240: if ($datechange) {
1.39 raeburn 241: my $modify_access_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$enddate,$startdate,'auto','',$cid,'',$context);
1.15 raeburn 242: $access = &showaccess($enddate,$startdate);
243: if ($modify_access_result =~ /^ok/) {
1.33 raeburn 244: $$logmsg .= &mt('Change in access dates for [_1].',$uname).$access.$linefeed;
1.15 raeburn 245: } else {
1.33 raeburn 246: $$logmsg .= &mt('Error when attempting to change start and/or end access dates for [_1] in section: [_2] -error [_3].',$uname,$stuinfo[$place{groupID}],$modify_access_result).$linefeed;
1.15 raeburn 247: }
248: }
249: }
250: } else {
1.5 raeburn 251: if ( ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) {
1.10 raeburn 252: # Delete from roles.db for current section
253: my $expiretime = time;
254: my $uurl='/'.$cid;
255: $uurl=~s/\_/\//g;
256: if ($$currlist{$uname}[$sec]) {
257: $uurl.='/'.$$currlist{$uname}[$sec];
258: }
1.38 raeburn 259: my $expire_role_result = &Apache::lonnet::assignrole($dom,$uname,$uurl,'st',$expiretime,'','','',$context);
1.10 raeburn 260: if ($expire_role_result eq 'ok') {
1.15 raeburn 261: my $modify_section_result;
262: if (grep/^$uname$/,@activestudents) {
1.39 raeburn 263: $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto','',$cid,'',$context);
1.15 raeburn 264: } else {
1.39 raeburn 265: $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$enddate,$startdate,'auto','',$cid,'',$context);
1.15 raeburn 266: $access = &showaccess($enddate,$startdate);
267: }
1.10 raeburn 268: if ($modify_section_result =~ /^ok/) {
1.33 raeburn 269: $switchresult .= &mt("Section for [_1] switched from old section: '[_2]' to new section: '[_3]'.",$uname,$$currlist{$uname}[$sec],$stuinfo[ $place{groupID} ]).$access.$linefeed;
1.21 raeburn 270: if ($context eq 'automated') {
1.33 raeburn 271: $$logmsg .= &mt('Section switch for [_1] from [_2] to [_3]',$uname,$$currlist{$uname}[$sec],$stuinfo[ $place{groupID} ]).$linefeed;
1.21 raeburn 272: }
273: $switchcount ++;
1.10 raeburn 274: } else {
1.33 raeburn 275: $$logmsg .= &mt("Error when attempting section change for [_1], from old section: '[_2]' to new section: '[_3]' -error: [_4]",$uname,$$currlist{$uname}[$sec],$stuinfo[ $place{groupID} ],$modify_section_result).$linefeed;
1.10 raeburn 276: }
1.5 raeburn 277: } else {
1.33 raeburn 278: $$logmsg .= &mt("Error when attempting to expire role for [_1] in old section: '[_2]' -error: '[_3]'.",$uname,$$currlist{$uname}[$sec],$expire_role_result).$linefeed;
1.5 raeburn 279: }
1.1 raeburn 280: }
281: }
1.5 raeburn 282: } else {
1.1 raeburn 283: # Check for changed usernames by checking studentIDs
1.5 raeburn 284: if ( ($stuinfo[ $place{studentID} ] ne '') && (grep/^$stuinfo[ $place{studentID} ]$/,@LCids) ) {
1.27 raeburn 285: foreach my $match ( @{ $unameFromLCid{ $stuinfo[ $place{studentID} ] } } ) {
1.40 weissno 286: $$logmsg .= &mt('A possible change in username has been detected for a student enrolled in this course.').' '.&mt('The existing LON-CAPA classlist contains user: [_1] and student/employee ID: [_2].',$match,$stuinfo[ $place{studentID} ]);
1.27 raeburn 287: if (grep/^$match$/,@okusers) {
1.40 weissno 288: $$logmsg .= &mt('The username [_1] remains in the institutional classlist, but the same student/employee ID is used for new user: [_2] now found in the institutional classlist.',$match,$uname).' '.&mt('You may need to contact your Domain Coordinator to determine how to resolve this issue and whether to move student data files for user: [_1] to [_2].',$match,$uname).' ';
1.27 raeburn 289: } else {
290: unless ($drops == 1) {
1.40 weissno 291: $$logmsg .= &mt('This username - [_1] - has been dropped from the institutional classlist, but the student/employee ID of this user is also used by [_2] who now appears in the institutional classlist.',$match,$uname).' '.&mt('You may need to contact your Domain Coordinator to request a move of the student data files for user: [_1] to [_2].',$match,$uname).' ';
1.5 raeburn 292: }
1.1 raeburn 293: }
1.40 weissno 294: $$logmsg .= &mt('Because of this student/employee ID conflict, the new username - [_1] - has not been added to the LON-CAPA classlist',$uname).$linefeed;
1.1 raeburn 295: }
1.5 raeburn 296: } elsif ($adds == 1) {
1.16 raeburn 297: my ($auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,$emailaddr,$pid,$emailenc);
298: &prepare_add($authtype,$autharg,$enddate,$startdate,\@stuinfo,\%place,\$dom,\$uname,\$auth,\$authparam,\$first,\$middle,\$last,\$gene,\$usec,\$end,\$start,\$emailaddr,\$pid,\$emailenc);
1.1 raeburn 299: # Check for existing account in this LON-CAPA domain for this username
1.5 raeburn 300: my $uhome=&Apache::lonnet::homeserver($uname,$dom);
301: if ($uhome eq 'no_host') { # User does not exist
1.19 raeburn 302: my $args = {'auth' => $auth,
303: 'authparam' => $authparam,
304: 'emailenc' => $emailenc,
305: 'udom' => $dom,
306: 'uname' => $uname,
307: 'pid' => $pid,
308: 'first' => $first,
309: 'middle' => $middle,
310: 'last' => $last,
311: 'gene' => $gene,
312: 'usec' => $usec,
313: 'end' => $end,
314: 'start' => $start,
315: 'emailaddr' => $emailaddr,
316: 'cid' => $cid,
317: 'crs' => $crs,
318: 'cdom' => $dom,
319: 'context' => $context,
320: 'linefeed' => $linefeed,
321: 'role' => 'st'
322: };
1.38 raeburn 323: my $outcome = &create_newuser($args,$logmsg,$newusermsg,\$enrollcount,\$addresult,\%longroles,\%courseinfo,$context);
1.5 raeburn 324: } else {
1.16 raeburn 325: &execute_add($context,'newstudent',$uname,$dom,$auth,$authparam,$first,$middle,$last,$gene,$pid,$usec,$end,$start,$emailenc,$cid,\$addresult,\$enrollcount,$linefeed,$logmsg);
1.3 raeburn 326: }
1.31 raeburn 327: if ($courseinfo{'showphoto'}) {
1.28 raeburn 328: my ($result,$resulttype) =
329: &Apache::lonnet::auto_checkphotos($uname,$dom,$pid);
330: if ($resulttype) {
331: push(@{$$phototypes{$resulttype}},$uname);
332: }
333: }
1.1 raeburn 334: }
335: }
336: }
337: }
1.31 raeburn 338: if ($courseinfo{'showphoto'}) {
1.28 raeburn 339: if (keys(%{$phototypes})>0) {
340: my %lt = &photo_response_types();
341: foreach my $type (sort(keys(%{$phototypes}))) {
342: my $numphoto = @{$$phototypes{$type}};
343: if ($numphoto > 0) {
344: if ($context eq 'updatenow') {
345: $photoresult .= '<br /><b>'.
1.29 albertel 346: &mt('For [_1] students, photos ',$numphoto).
347: $lt{$type}.'</b><ul><li>';
1.28 raeburn 348: } else {
1.33 raeburn 349: $photoresult .= "\n".&mt("For [quant,_1,student], photos ",$numphoto).
1.29 albertel 350: $lt{$type}."\n";
1.28 raeburn 351: }
352: foreach my $user (@{$$phototypes{$type}}) {
353: $photoresult .= $user.$linefeed;
354: }
355: if ($context eq 'updatenow') {
356: $photoresult = substr($photoresult,0,
1.29 albertel 357: rindex($photoresult,"<li>"));
1.28 raeburn 358: $photoresult .= '</ul><br />';
359: } else {
360: $photoresult .= "\n";
361: }
362: }
363: }
364: }
365: }
366:
1.1 raeburn 367: # Do drops
368: if ( ($drops == 1) && (@reg_students > 0) ) {
369: foreach my $uname (@localstudents) {
370: if ($$currlist{$uname}[$type] eq "auto") {
371: my @saved = ();
372: if (!grep/^$uname$/,@reg_students) {
373: # Check for changed usernames by checking studentIDs
374: if (grep/^$$currlist{$uname}[ $stuid ]$/,@allINids) {
375: foreach my $match (@{$unameFromINid{$$currlist{$uname}[ $stuid ]}} ) {
1.40 weissno 376: $$logmsg .= &mt('A possible change in username has been detected for a student enrolled in this course.').' '.&mt('The existing LON-CAPA classlist contains user: [_1] and student/employee ID: [_2].',$uname,$$currlist{$uname}[ $place{studentID} ]).' '.&mt('This username has been dropped from the institutional classlist, but the same student/employee ID is used for user: [_1] who still appears in the institutional classlist.',$match).' '.&mt('You may need to move the student data files for user: [_1] to [_2]',$uname,$match).' '.&mt('Because of this, user [_1] has not been dropped from the course.',$uname).$linefeed;
1.1 raeburn 377: push @saved,$uname;
378: }
379: } elsif (@saved == 0) {
1.38 raeburn 380: my $drop_reply = &Apache::lonnet::modifystudent($dom,$uname,'','','',undef,undef,undef,undef,$$currlist{$uname}[$sec],time,undef,undef,undef,undef,'auto','',$cid,'',$context);
1.1 raeburn 381: if ($drop_reply !~ /^ok/) {
1.33 raeburn 382: $$logmsg .= &mt('An error occured during the attempt to expire the [_1] from the old section [_2] - [_3].',$uname,$$currlist{$uname}[$sec],$drop_reply).$linefeed;
1.1 raeburn 383: } else {
384: $dropcount ++;
385: my %userenv = &Apache::lonnet::get('environment',['firstname','lastname','id'],$dom,$uname);
1.38 raeburn 386: $dropresult .= $userenv{'firstname'}." ".$userenv{'lastname'}." (".$userenv{'id'}.") - ".$uname.' '.&mt("dropped from section: '[_1]'.",$$currlist{$uname}[$sec]).$linefeed;
1.8 raeburn 387: if ($context eq 'automated') {
1.33 raeburn 388: $$logmsg .= &mt('User [_1] student role expired from course.',$uname).$linefeed;
1.8 raeburn 389: }
1.1 raeburn 390: }
391: }
392: }
393: }
394: }
395: }
1.5 raeburn 396:
397: # Terminated explictly allowed access to student creation/modification
398: if ($context eq 'automated') {
1.22 albertel 399: delete($env{'allowed.cst'});
1.5 raeburn 400: }
1.1 raeburn 401: if ($enrollcount > 0) {
402: if ($context eq "updatenow") {
1.6 raeburn 403: $addresult = substr($addresult,0,rindex($addresult,"<li>"));
1.33 raeburn 404: $addresult = &mt("The following [quant,_1,student was,students were] added to this LON-CAPA course:",$enrollcount).'<br/><ul><li>'.$addresult.'</ul><br/><br/>';
1.1 raeburn 405: } else {
1.33 raeburn 406: $addresult = &mt("The following [quant,_1,student was,students were] added to this LON-CAPA course:",$enrollcount)."\n\n".$addresult."\n\n";
1.21 raeburn 407: }
1.1 raeburn 408: }
409: if ($dropcount > 0) {
410: if ($context eq "updatenow") {
1.6 raeburn 411: $dropresult = substr($dropresult,0,rindex($dropresult,"<li>"));
1.33 raeburn 412: $dropresult = &mt("The following [quant,_1,student was,students were] expired from this LON-CAPA course:",$dropcount).'<br/><ul><li>'.$dropresult.'</ul><br/><br/>';
1.1 raeburn 413: } else {
1.33 raeburn 414: $dropresult = &mt("The following [quant,_1,student was,students were] expired from this LON-CAPA course:",$dropcount)."\n\n".$dropresult."\n\n";
1.1 raeburn 415: }
416: }
1.21 raeburn 417: if ($switchcount > 0) {
418: if ($context eq "updatenow") {
419: $switchresult = substr($switchresult,0,rindex($switchresult,"<li>"));
1.33 raeburn 420: $switchresult = &mt("The following [quant,_1,student] switched sections in this LON-CAPA course:",$switchcount).'<br/><ul><li>'.$switchresult.'</ul><br/><br/>';
1.21 raeburn 421: } else {
1.33 raeburn 422: $switchresult = &mt("The following [quant,_1,student] switched sections in this LON-CAPA course:",$switchcount)."\n\n".$switchresult."\n\n";
1.21 raeburn 423: }
424: }
1.1 raeburn 425: if ( ($adds) && ($enrollcount == 0) ) {
1.33 raeburn 426: $addresult = &mt('There were no new students to add to the course.');
1.1 raeburn 427: if ($context eq "updatenow") {
428: $addresult .="<br/><br/>";
429: } else {
430: $addresult .="\n";
431: }
432: }
433: if ( ($drops) && ($dropcount == 0) ) {
1.33 raeburn 434: $dropresult = &mt('There were no students with roles to expire because all active students previously added to the course from institutional classlist(s) are still officially registered.');
1.1 raeburn 435: if ($context eq "updatenow") {
436: $dropresult .="<br/>";
437: } else {
438: $dropresult .="\n";
439: }
440: }
1.21 raeburn 441: my $changecount = $enrollcount + $dropcount + $switchcount;
1.28 raeburn 442: return ($changecount,$addresult.$photoresult.$dropresult.$switchresult);
1.6 raeburn 443: }
1.1 raeburn 444:
1.19 raeburn 445: sub create_newuser {
1.36 albertel 446: my ($args,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,
447: $courseinfo,$called_context) = @_;
1.19 raeburn 448: my $auth = $args->{'auth'};
449: my $authparam = $args->{'authparam'};
450: my $emailenc = $args->{'emailenc'};
451: my $udom = $args->{'udom'};
452: my $uname = $args->{'uname'};
453: my $pid = $args->{'pid'};
454: my $first = $args->{'first'};
455: my $middle = $args->{'middle'};
456: my $last = $args->{'last'} ;
457: my $gene = $args->{'gene'};
458: my $usec = $args->{'usec'};
459: my $end = $args->{'end'};
460: my $start = $args->{'start'};
461: my $emailaddr = $args->{'emailaddr'};
462: my $cid = $args->{'cid'};
463: my $crs = $args->{'crs'};
464: my $cdom = $args->{'cdom'};
465: my $context = $args->{'context'};
466: my $linefeed = $args->{'linefeed'};
467: my $role = $args->{'role'};
468: my $create_passwd = 0;
469: my $authchk = '';
470: my $outcome;
471: unless ($authparam eq '') { $authchk = 'ok'; };
472: # If no account exists and passwords should be generated
473: if ($auth eq "internal") {
474: if ($authparam eq '') {
475: $authparam = &create_password();
476: if ($authparam eq '') {
477: $authchk = '';
478: } else {
479: $create_passwd = 1;
480: $authchk = 'ok';
481: }
482: }
483: } elsif ($auth eq "localauth") {
1.34 raeburn 484: ($authparam,$create_passwd,$authchk) = &Apache::lonnet::auto_create_password($crs,$cdom,$authparam,$udom);
1.19 raeburn 485: } elsif ($auth =~ m/^krb/) {
486: if ($authparam eq '') {
1.33 raeburn 487: $$logmsg .= &mt('No Kerberos domain was provided for the new user - [_1], so the new user was not enrolled in the course',$uname).$linefeed;
1.19 raeburn 488: $authchk = 'invalid';
489: }
490: } else {
491: $authchk = 'invalid';
1.33 raeburn 492: $$logmsg .= &mt('An invalid authentication type was provided for the new user - [_1], so the user was not enrolled in the course.',$uname).$linefeed;
1.34 raeburn 493: }
1.19 raeburn 494: if ($authchk eq 'ok') {
495: # Now create user.
496: my $type = 'auto';
497: my $userurl = '/'.$cdom.'/'.$crs;
498: if ($usec ne '') {
499: $userurl .= '/'.$usec;
500: }
501: if ($context eq 'createowner' || $context eq 'createcourse') {
502: my $result = &Apache::lonnet::modifyuser($udom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,'1',undef,$emailaddr);
503: if ($result eq 'ok' && $context eq 'createcourse') {
1.36 albertel 504: $outcome = &Apache::loncommon::commit_standardrole($udom,$uname,$userurl,$role,$start,$end,$cdom,$crs,$usec,$called_context);
1.19 raeburn 505: unless ($outcome =~ /^Error:/) {
506: $outcome = 'ok';
507: }
508: } else {
509: $outcome = $result;
510: }
511: } else {
1.38 raeburn 512: $outcome=&Apache::lonnet::modifystudent($udom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,'',undef,$emailaddr,'auto','',$cid,'',$called_context);
1.19 raeburn 513: }
514: if ($outcome eq 'ok') {
515: my $access = &showaccess($end,$start);
1.33 raeburn 516: my $showsec = $usec;
517: if ($usec eq '') {
518: $showsec = &mt('none');
519: }
1.38 raeburn 520: $$addresult .= "$first $last ($pid) - $uname ".&mt("enrolled in section: '[_1]'.",$showsec).$access.$linefeed;
1.19 raeburn 521: unless ($context eq 'createowner' || $context eq 'createcourse') {
522: $$enrollcount ++;
523: }
1.36 albertel 524: if ($called_context eq 'automated') {
1.33 raeburn 525: $$logmsg .= &mt('New [_1] user [_2] added successfully.',$udom,$uname);
1.19 raeburn 526: }
527: unless ($emailenc eq '' || $context eq 'createowner' || $context eq 'createcourse') {
528: my %emailHash;
529: $emailHash{'critnotification'} = $emailenc;
530: $emailHash{'notification'} = $emailenc;
1.23 raeburn 531: $emailHash{'permanentemail'} = $emailenc;
1.19 raeburn 532: my $putresult = &Apache::lonnet::put('environment',\%emailHash,$udom,$uname);
533: }
534: if ($create_passwd) {
535: # Send e-mail with initial password to new user at $emailaddr.
536: # If e-mail address is invalid, send password via message to courseowner i
537: # (if automated call) or to user if roster update.
538: if ($emailaddr eq '') {
1.33 raeburn 539: $$newusermsg .= &mt(' username: [_1], password: [_2]',$uname,$authparam).$linefeed."\n";
1.19 raeburn 540: } else {
1.33 raeburn 541: my $subject = &mt('New LON-CAPA account');
1.19 raeburn 542: my $body;
1.41 ! raeburn 543: my $portalurl = 'http://'.$ENV{'SERVER_NAME'};
! 544: my $protocol = 'http';
! 545: my $lonhost=&Apache::lonnet::domain($udom,'primary');
! 546: if ($lonhost ne '') {
! 547: my $ip = &Apache::lonnet::get_host_ip($lonhost);
! 548: if ($Apache::lonnet::protocol{$lonhost} eq 'https') {
! 549: $protocol = 'https';
! 550: }
! 551: if ($ip ne '') {
! 552: $portalurl = $protocol.'://'.$ip
! 553: }
! 554: }
1.19 raeburn 555: if ($context eq 'createowner') {
1.41 ! raeburn 556: $body = &mt('A user account has been created for you while creating your new course in the LON-CAPA course management and online homework system.')."\n\n".&mt('You should log-in to the system using the following credentials:')."\n".&mt('username: ').$uname."\n".&mt('password: ').$authparam."\n\n".&mt('The URL you should use to access the LON-CAPA system at your institution is: ').$portalurl."\n\n";
1.19 raeburn 557: } elsif ($context eq 'createcourse') {
1.41 ! raeburn 558: $body = &mt('You have been assigned the role of [_1] in a new course: [_2] - [_3] in the LON-CAPA course management and online homework system.',$$longroles{$role},$$courseinfo{'description'},$$courseinfo{'inst_code'}).' '.&mt('As you did not have an existing user account in the system, one has been created for you.')."\n\n".&mt("You should log-in to the system using the following credentials:\nusername: [_1]\npassword: [_2]",$uname,$authparam)."\n\n".&mt('The URL you should use to access the LON-CAPA system at your institution is: ').$portalurl."\n\n";
1.19 raeburn 559: } else {
560: my $access_start = 'immediately';
561: if ($start > 0) {
562: $access_start = localtime($start)
563: }
1.41 ! raeburn 564: $body = &mt('You have been enrolled in the LON-CAPA system at your institution, because you are a registered student in a class which is using the LON-CAPA couse management and online homework system.')."\n\n".&mt("You should log-in to the system using the following credentials:\nusername: [_1]\npassword: [_2]",$uname,$authparam)."\n\n".&mt('The URL you should use to access the LON-CAPA system at your institution is: ').$portalurl."\n\n".&mt('When you log-in you will be able to access the LON-CAPA course for [_1] - [_2] starting [_3].',$$courseinfo{'description'},$$courseinfo{'inst_code'},$access_start)."\n";
1.19 raeburn 565: }
566: &Apache::lonmsg::sendemail($emailaddr,$subject,$body);
567: }
1.36 albertel 568: if ($called_context eq 'automated') {
1.33 raeburn 569: $$logmsg .= &mt(' Initial password - sent to ').$emailaddr.$linefeed;
1.19 raeburn 570: }
571: } else {
1.36 albertel 572: if ($called_context eq 'automated') {
1.19 raeburn 573: $$logmsg .= $linefeed;
574: }
575: }
576: } else {
1.33 raeburn 577: $$logmsg .= &mt('An error occurred adding new user [_1] - [_2].',$uname,$outcome).$linefeed;
1.19 raeburn 578: }
1.34 raeburn 579: } else {
580: $$logmsg .= &mt('An error occurred adding the new user [_1] because the authcheck failed for authtype [_2] and parameter [_3].',$uname,$auth,$authparam).' '.&mt('The authcheck response was [_1].',$authchk).$linefeed;
1.19 raeburn 581: }
582: return $outcome;
583: }
584:
1.16 raeburn 585: sub prepare_add {
586: my ($authtype,$autharg,$enddate,$startdate,$stuinfo,$place,$dom,$uname,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,$emailaddr,$pid,$emailenc) = @_;
587: $$auth = $$stuinfo[ $$place{'authtype'} ];
588: $$authparam = $$stuinfo[ $$place{'autharg'} ];
589: $$first = $$stuinfo[ $$place{'firstname'} ];
590: $$middle = $$stuinfo[ $$place{'middlename'} ];
591: $$last = $$stuinfo[ $$place{'lastname'} ];
592: $$gene = $$stuinfo[ $$place{'generation'} ];
593: $$usec = $$stuinfo[ $$place{'groupID'} ];
594: $$end = $$stuinfo[ $$place{'enddate'} ];
595: $$start = $$stuinfo[ $$place{'startdate'} ];
596: $$emailaddr = $$stuinfo[ $$place{'email'} ];
597: $$pid = $$stuinfo[ $$place{'studentID'} ];
598:
599: # remove non alphanumeric values from section
600: $$usec =~ s/\W//g;
601:
602: unless ($$emailaddr =~/^[^\@]+\@[^\@]+$/) { $$emailaddr =''; }
603: $$emailenc = &HTML::Entities::encode($$emailaddr,'<>&"');
604:
605: # Use course defaults where entry is absent
606: if ( ($$auth eq '') || (!defined($$auth)) ) {
607: $$auth = $authtype;
608: }
609: if ( ($$authparam eq '') || (!defined($$authparam)) ) {
610: $$authparam = $autharg;
611: }
612: if ( ($$end eq '') || (!defined($$end)) ) {
613: $$end = $enddate;
614: }
615: if ( ($$start eq '') || (!defined($$start)) ) {
616: $$start = $startdate;
617: }
618: # Clean up whitespace
619: foreach ($dom,$uname,$pid,$first,$middle,$last,$gene,$usec) {
620: $$_ =~ s/(\s+$|^\s+)//g;
621: }
622: return;
623: }
624:
625: sub execute_add {
626: my ($context,$caller,$uname,$dom,$auth,$authparam,$first,$middle,$last,$gene,$pid,$usec,$end,$start,$emailenc,$cid,$addresult,$enrollcount,$linefeed,$logmsg) = @_;
627: # Get the user's information and authentication
1.23 raeburn 628: my %userenv = &Apache::lonnet::get('environment',['firstname','middlename','lastname','generation','id','critnotification','notification','permanentemail'],$dom,$uname);
1.16 raeburn 629: my ($tmp) = keys(%userenv);
630: if ($tmp =~ /^(con_lost|error)/i) {
631: %userenv = ();
632: }
633: # Get the user's e-mail address
634: if ($userenv{critnotification} =~ m/%40/) {
635: unless ($emailenc eq $userenv{critnotification}) {
1.41 ! raeburn 636: $$logmsg .= &mt('Current critical notification e-mail - [_1] for [_2] is different to e-mail address in institutional classlist - [_3].',
! 637: $userenv{critnotification},$uname,$emailenc).
! 638: $linefeed;
1.16 raeburn 639: }
640: }
641: if ($userenv{notification} =~ m/%40/) {
1.23 raeburn 642: unless ($emailenc eq $userenv{notification}) {
1.41 ! raeburn 643: $$logmsg .= &mt('Current standard notification e-mail - [_1] for [_2] is different to e-mail address in institutional classlist - [_3].',
! 644: $userenv{notification},$uname,$emailenc).
! 645: $linefeed;
1.16 raeburn 646: }
647: }
1.23 raeburn 648: if ($userenv{permanentemail} =~ m/%40/) {
649: unless ($emailenc eq $userenv{permanentemail}) {
1.33 raeburn 650: $$logmsg .= &mt('Current permanent e-mail
651: - [_1] for [_2] is different to e-mail address in institutional classlist - [_3]',$userenv{permanentemail},$uname,$emailenc).$linefeed;
1.23 raeburn 652: }
653: }
1.16 raeburn 654: my $krbdefdom = '';
655: my $currentauth=&Apache::lonnet::queryauthenticate($uname,$dom);
656: if ($currentauth=~/^(krb[45]):(.*)/) {
657: $currentauth = $1;
658: $krbdefdom = $2;
659: } elsif ($currentauth=~ /^(unix|internal|localauth):/) {
660: $currentauth = $1;
661: } else {
1.33 raeburn 662: $$logmsg .= &mt('Invalid authentication method [_1] for [_2].',$currentauth,$uname).$linefeed;
1.16 raeburn 663: }
664: # Report if authentication methods are different.
665: if ($currentauth ne $auth) {
1.33 raeburn 666: $$logmsg .= &mt("Authentication type mismatch for [_1] - '[_2]' in system, '[_3]' based on information in classlist or default for this course.",$uname,$currentauth,$auth).$linefeed;
1.16 raeburn 667: } elsif ($auth =~ m/^krb/) {
668: if ($krbdefdom ne $authparam) {
1.33 raeburn 669: $$logmsg .= &mt("Kerberos domain mismatch for [_1] - '[_2]' in system, '[_3]' based on information in classlist or default for this course.",$uname,$krbdefdom,$authparam).$linefeed;
1.16 raeburn 670: }
671: }
672:
673: # Check user data
674: if ($first ne $userenv{'firstname'} ||
675: $middle ne $userenv{'middlename'} ||
676: $last ne $userenv{'lastname'} ||
677: $gene ne $userenv{'generation'} ||
1.23 raeburn 678: $pid ne $userenv{'id'} ||
679: $emailenc ne $userenv{'permanentemail'} ) {
1.16 raeburn 680: # Make the change(s)
681: my %changeHash;
682: $changeHash{'firstname'} = $first;
683: $changeHash{'middlename'} = $middle;
684: $changeHash{'lastname'} = $last;
685: $changeHash{'generation'} = $gene;
686: $changeHash{'id'} = $pid;
1.23 raeburn 687: $changeHash{'permanentemail'} = $emailenc;
1.16 raeburn 688: my $putresult = &Apache::lonnet::put('environment',\%changeHash,$dom,$uname);
689: if ($putresult eq 'ok') {
1.37 raeburn 690: $$logmsg .= &mt('User information updated for user: [_1] prior to enrollment.',$uname).$linefeed;
1.16 raeburn 691: } else {
1.33 raeburn 692: $$logmsg .= &mt('There was a problem modifying user data for existing user - [_1] -error: [_2], enrollment will still be attempted.',$uname,$putresult).$linefeed;
1.16 raeburn 693: }
694: }
695:
696: # Assign the role of student in the course.
1.39 raeburn 697: my $classlist_reply = &Apache::lonnet::modify_student_enrollment($dom,$uname,$pid,$first,$middle,$last,$gene,$usec,$end,$start,'auto','',$cid,'',$context);
1.16 raeburn 698: if ($classlist_reply eq 'ok') {
699: my $access = &showaccess($end,$start);
1.33 raeburn 700: my $showsec = $usec;
701: if ($usec eq '') {
702: $showsec = &mt('none');
703: }
1.16 raeburn 704: if ($caller eq 'switchtype') {
1.38 raeburn 705: $$logmsg .= &mt("Existing user [_1] detected in institutional classlist - switched from 'manual' to 'auto' enrollment in section [_2].",$uname,$showsec).$access.$linefeed;
1.16 raeburn 706: } elsif ($caller eq 'newstudent') {
707: $$enrollcount ++;
1.38 raeburn 708: $$addresult .= "$first $last ($pid) - $uname ".&mt("enrolled in section '[_1]'.",$showsec).$access.$linefeed;
1.16 raeburn 709: }
710: if ($context eq 'automated') {
1.33 raeburn 711: $$logmsg .= &mt('Existing [_1] user [_2] enrolled successfully.',$dom,$uname).$linefeed;
1.16 raeburn 712: }
713: } else {
1.33 raeburn 714: $$logmsg .= &mt('There was a problem updating the classlist db file for user [_1] to show the new enrollment -error: [_2], so no enrollment occurred for this user.',$uname,$classlist_reply).$linefeed;
1.16 raeburn 715: }
716: return;
717: }
718:
719: sub datechange_check {
720: my ($oldstart,$oldend,$startdate,$enddate) = @_;
721: my $datechange = 0;
722: unless ($oldstart eq $startdate) {
723: $datechange = 1;
724: }
725: if (!$datechange) {
726: if (!$oldend) {
727: if ($enddate) {
728: $datechange = 1;
729: }
730: } elsif ($oldend ne $enddate) {
731: $datechange = 1;
732: }
733: }
734: return $datechange;
735: }
736:
1.15 raeburn 737: sub showaccess {
738: my ($end,$start) = @_;
739: my $showstart;
740: my $showend;
741: if ( (!$start) || ($start <= time) ) {
742: $showstart = 'immediately';
743: } else {
744: $showstart = &Apache::lonlocal::locallocaltime($start);
745: }
746: if (!$end) {
747: $showend = 'no end date';
748: } else {
749: $showend = &Apache::lonlocal::locallocaltime($end);
750: }
1.33 raeburn 751: my $access_msg = ' '.&mt('Access starts: [_1], ends: [_2].',$showstart,$showend);
1.15 raeburn 752: return $access_msg;
753: }
754:
1.1 raeburn 755: sub parse_classlist {
1.6 raeburn 756: my ($tmpdir,$dom,$crs,$class,$placeref,$groupID,$studentsref) = @_;
1.5 raeburn 757: my $xmlfile = $tmpdir."/tmp/".$dom."_".$crs."_".$class."_classlist.xml";
1.6 raeburn 758: my $uname = '';
759: my @state;
1.8 raeburn 760: my @items = ('autharg','authtype','email','firstname','generation','lastname','middlename','studentID');
1.6 raeburn 761: my $p = HTML::Parser->new
762: (
763: xml_mode => 1,
764: start_h =>
765: [sub {
766: my ($tagname, $attr) = @_;
767: push @state, $tagname;
768: if ("@state" eq "students student") {
769: $uname = $attr->{username};
770: }
771: }, "tagname, attr"],
772: text_h =>
773: [sub {
774: my ($text) = @_;
775: if ("@state" eq "students student groupID") {
776: $$studentsref{$uname}[ $$placeref{'groupID'} ] = $groupID;
1.8 raeburn 777: } elsif ("@state" eq "students student startdate") {
778: my $start = $text;
779: unless ($text eq '') {
780: $start = &process_date($text);
781: }
782: $$studentsref{$uname}[ $$placeref{'startdate'} ] = $start;
783: } elsif ("@state" eq "students student enddate") {
784: my $end = $text;
785: unless ($text eq '') {
786: $end = &process_date($text);
787: }
788: $$studentsref{$uname}[ $$placeref{'enddate'} ] = $end;
1.6 raeburn 789: } else {
790: foreach my $item (@items) {
791: if ("@state" eq "students student $item") {
792: $$studentsref{$uname}[ $$placeref{$item} ] = $text;
793: }
794: }
795: }
796: }, "dtext"],
797: end_h =>
798: [sub {
799: my ($tagname) = @_;
800: pop @state;
801: }, "tagname"],
802: );
803:
804: $p->parse_file($xmlfile);
805: $p->eof;
1.8 raeburn 806: if (-e "$xmlfile") {
807: unlink $xmlfile;
808: }
1.3 raeburn 809: return;
1.1 raeburn 810: }
811:
1.8 raeburn 812: sub process_date {
813: my $timestr = shift;
814: my $timestamp = '';
815: if ($timestr =~ m/^\d{4}:\d{2}:\d{2}/) {
816: my @entries = split/:/,$timestr;
817: for (my $j=0; $j<@entries; $j++) {
818: if ( length($entries[$j]) > 1 ) {
819: $entries[$j] =~ s/^0//;
820: }
821: }
822: $entries[1] = $entries[1] - 1;
823: $timestamp = timelocal($entries[5],$entries[4],$entries[3],$entries[2],$entries[1],$entries[0]);
824: }
825: return $timestamp;
826: }
827:
1.1 raeburn 828: sub create_password {
1.8 raeburn 829: my $passwd = '';
1.11 raeburn 830: my @letts = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
1.8 raeburn 831: for (my $i=0; $i<8; $i++) {
832: my $lettnum = int (rand 2);
833: my $item = '';
834: if ($lettnum) {
835: $item = $letts[int( rand(26) )];
836: my $uppercase = int(rand 2);
837: if ($uppercase) {
838: $item =~ tr/a-z/A-Z/;
839: }
840: } else {
841: $item = int( rand(10) );
842: }
843: $passwd .= $item;
844: }
845: return ($passwd);
1.9 raeburn 846: }
847:
1.19 raeburn 848: sub get_courseinfo {
849: my ($dom,$crs,$courseinfo) = @_;
850: my $owner;
851: if (defined($dom) && defined($crs)) {
1.31 raeburn 852: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.showphoto','description'],$dom,$crs);
1.19 raeburn 853: if ( defined($settings{'internal.coursecode'}) ) {
854: $$courseinfo{'inst_code'} = $settings{'internal.coursecode'};
855: }
856: if ( defined($settings{'description'}) ) {
857: $$courseinfo{'description'} = $settings{'description'};
858: }
1.31 raeburn 859: if ( defined($settings{'internal.showphoto'}) ) {
860: $$courseinfo{'showphoto'} = $settings{'internal.showphoto'};
1.28 raeburn 861: }
1.19 raeburn 862: }
863: return;
864: }
865:
1.38 raeburn 866: sub place_hash {
867: my %place = (
868: autharg => 0,
869: authtype => 1,
870: email => 2,
871: enddate => 3,
872: firstname => 4,
873: generation => 5,
874: groupID => 6,
875: lastname => 7,
876: middlename => 8,
877: startdate => 9,
878: studentID => 10,
879: );
880: return %place;
881: }
1.1 raeburn 882:
1.28 raeburn 883: sub photo_response_types {
1.29 albertel 884: my %lt = &Apache::lonlocal::texthash(
1.28 raeburn 885: 'same' => 'remained unchanged',
886: 'update' => 'were updated',
887: 'new' => 'were added',
888: 'missing' => 'were missing',
889: 'error' => 'were not imported because an error occurred',
890: 'nouser' => 'were for users without accounts',
1.40 weissno 891: 'noid' => 'were for users without student/employee IDs',
1.29 albertel 892: );
1.28 raeburn 893: return %lt;
894: }
895:
896:
1.1 raeburn 897: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>