Annotation of loncom/automation/batchcreatecourse.pm, revision 1.2
1.1 raeburn 1: package LONCAPA::batchcreatecourse;
2: use LONCAPA::Configuration;
3: use LONCAPA::Enrollment;
4: use HTML::Parser;
5: use Time::Local;
6: use Apache::Constants;
7: use Apache::lonnet;
1.2 ! raeburn 8: use Apache::loncommon;
1.1 raeburn 9: use Apache::loncreatecourse;
1.2 ! raeburn 10: use Apache::loncreateuser;
1.1 raeburn 11: use Apache::lonlocal;
12:
13: # Collection of routines used for batch creation of courses and users.
14: # &create_courses() should be called by an Autocreate.pl
15: # script via a cron entry, or alternatively from a web page, after upload
16: # of a file containing an XML description of a course request (lonbatchccrs.pm).
17: #
18: # XML file(s) describing courses that are to be created in domain $dom are stored in
19: # /home/httpd/perl/tmp/addcourse/$dom. Each XML file is deleted after it has been
20: # parsed.
21: #
22: # &create_courses() will create an account for the course owner
23: # (if one does not currently exist), will create the course (cloning if necessary),
24: # and will add additional instructional staff (creating accounts if necessary).
25: #
26: # Example of XML file (which could contain more than one class to be created):
27: #
28: #<?xml version="1.0" encoding="UTF-8"?>
29: #<!DOCTYPE text>
30: #<class id="ss05ubw101">
31: # <title>Underwater Basket Weaving</title>
32: # <coursecode>ss05ubw101</coursecode>
33: # <coursehome>msul1</coursehome>
34: # <coursedomain>msu</coursedomain>
35: # <reshome>/res/msu/</reshome>
36: # <optional_id></optional_id>
37: # <adds>1</adds>
38: # <drops>1</drops>
39: # <enrollstart>2005:01:04:10:30</enrollstart>
40: # <enrollend>2005:07:04:20:30</enrollend>
41: # <accessstart>2005:01:10:10:30</accessstart>
42: # <accessend>2005:05:31:10:30</accessend>
43: # <authentication>
44: # <method>krb4</method>
45: # <param>MSU.EDU</param>
46: # </authentication>
47: # <nonstandard></nonstandard>
48: # <topmap></topmap>
49: # <firstres>nav</firstres>
50: # <clonecrs>466011437c34194msul1</clonecrs>
51: # <clonedom>msu</clonedom>
52: # <showphotos></showphotos>
53: # <setpolicy>1</setpolicy>
54: # <setcontent>1</setcontent>
55: # <setkeys>0</setkeys>
56: # <keyauth>keyadmin@msu</keyauth>
57: # <disresdis>1</disresdis>
58: # <disablechat>1</disablechat>
59: # <openall></openall>
60: # <notify_dc>1</notify_dc>
61: # <notify_owner>1</notify_owner>
62: # <owner>
63: # <username>sparty</username>
64: # <domain>msu</domain>
65: # <authtype>krb4</authtype>
66: # <autharg>MSU.EDU</autharg>
67: # </owner>
68: # <sections>
69: # <section>
70: # <inst>001</inst>
71: # <loncapa>1</loncapa>
72: # </section>
73: # <section>
74: # <inst>002</inst>
75: # <loncapa>2</loncapa>
76: # </section>
77: # </sections>
78: # <crosslists>
79: # <xlist>
80: # <inst>ss05zzz101001</inst>
81: # <loncapa>1</loncapa>
82: # </xlist>
83: # </crosslists>
84: # <users>
85: # <user>
86: # <username>sparty</username>
87: # <domain>msu</domain>
88: # <email>sparty@msu.edu</email>
89: # <authtype>krb4</authtype>
90: # <autharg></autharg>
91: # <firstname>MSU</firstname>
92: # <generation></generation>
93: # <lastname>Spartan</lastname>x
94: # <middlename></middlename>
95: # <studentID></studentID>
96: # <roles></roles>
97: # </user>
98: # <user>
99: # <username>itds0001</username>
100: # <domain>northwood5</domain>
101: # <email>itds0001@msu.edu</email>
102: # <authtype>int</authtype>
103: # <autharg></autharg>
104: # <firstname>Info</firstname>
105: # <generation></generation>
106: # <lastname>Techc</lastname>x
107: # <middlename></middlename>
108: # <studentID></studentID>
109: # <roles>
110: # <role id='in'>
111: # <start>2005:01:01:12:10</start>
112: # <end>2005:12:01:12:10</end>
113: # <usec>1</usec>
114: # <usec>2</usec>
115: # </role>
116: # </roles>
117: # </user>
118: # </users>
119: #</class>
120: #
121: # Many of these are binary options (corresponding to either checkboxes or
122: # radio buttons in the interactive CCRS page). Examples include:
123: # setpolicy, setcontent, setkeys, disableresdis, disablechat, openall
124: #
125: # A value of 1 between opening and closing tags is equivalent to a
126: # checked checkbox or 'Yes' response in the original CCRS web page.
127: # A value of 0 or blank is equivalent to an unchecked box or 'No'
128: # response. Dates are in format YYYY:MM:DD:HH:MM:SS (:separators required)
129: #
130: # firstres can be nav, syl , or blank for "Navigate Contents", Syllabus, or
131: # no entry respectively.
132: # For format of other parameters, refer to the interactive CCRS page
133: # and view how the equivalent parameter is displayed in the web form.
134: #
135: ##############################################################
136: # create_courses() - creates courses described in @$requests,
137: # files listed in @$requests are deleted
138: # after the files have been parsed.
139: #
140: # Directory searched for files listed in @$requests
141: # is /home/httpd/perl/tmp/addcourse/$dom/auto if $context is auto
142: # and /home/httpd/perl/tmp/addcourse/$dom/web/$uname if $context is web
143: #
144: # inputs (five) - requests - ref to array of filename(s) containing course requests
145: # courseids - ref to hash to store LON-CAPA course ids of new courses
146: # context - auto if called from command line, web if called from browser
147: # dom - domain for which the course is being created
148: # uname - username of DC who is requesting course creation from browser
149: #
150: # outputs (three) - output - text recording user roles added etc.
151: # logmsg - text to be logged
152: # keysmsg - text containing link(s) to manage keys page(s)
153: #############################################################
154:
155: sub create_courses {
156: my ($requests,$courseids,$context,$dom,$uname) = @_;
157: my $output;
158: my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf');
159: # Get role names
160: my %longroles = ();
161: open(FILE,"<$perlvarref{'lonTabDir'}.'/rolesplain.tab");
162: my @rolesplain = <FILE>;
163: close(FILE);
164: foreach (@rolesplain) {
165: if ($_ =~ /^(st|ta|ex|ad|in|cc):([\w\s]+)$/) {
166: $longroles{$1} = $2;
167: }
168: }
169: my ($logmsg,$keysmsg,$newusermsg,$addresult);
170: my %enrollcount = ();
171: my $newcoursedir = $$perlvarref{'lonDaemons'}.'/tmp/addcourse/'.$dom.'/'.$context;
172: if ($uname) {
173: unless ($context eq 'auto') {
174: $newcoursedir .= '/'.$uname;
175: }
176: }
177: if (@{$requests} > 0) {
178: foreach my $request (@{$requests}) {
179: my %details = ();
180: if (-e $newcoursedir.'/'.$request) {
181: &parse_coursereqs($newcoursedir.'/'.$request, \%details);
182: foreach my $num (sort keys %details) {
183: my $courseid = &build_course($dom,$num,$context,\%details,\%longroles,\$logmsg,\$newusermsg,\$addresult,\%enrollcount,\$output,\$keysmsg);
184: $$courseids{$courseid} = $enrollcount;
185: }
186: }
187: }
188: }
189: return ($output,$logmsg,$keysmsg);
190: }
191:
192: #############################################################
193: #
194: # parse_coursereqs()
195: # inputs (two) - coursefile - path to XML file containing course(s) to be created.
196: # - details - reference to hash containing extracted information.
197: # outputs (none)
198: #
199: ############################################################
200:
201: sub parse_coursereqs {
202: my ($coursefile,$details) = @_;
203: # Note all start and end dates should be in this format:
204: # YYYY:MM:DD:HH:MM:SS (:separators required).
205: my $uname = '';
206: my @state = ();
207: my $num = 0;
208: my $secid = 0;
209: my $xlist = 0;
210: my $userkey = '';
211: my $role = '';
212: my @items = ('title','optional_id','coursecode','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','showphotos','setpolicy','setcontent','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc');
213: my @dateitems = ('enrollstart','enrollend','accessstart','accessend');
214: my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID');
215: my $p = HTML::Parser->new
216: (
217: xml_mode => 1,
218: start_h =>
219: [sub {
220: my ($tagname, $attr) = @_;
221: push(@state, $tagname);
222: if ("@state" eq "class") {
223: %{$$details{$num}} = ();
224: $$details{$num}{'class'} = $attr->{id};
225: %{$$details{$num}{'users'}} = ();
226: %{$$details{$num}{'sections'}} = ();
227: $secid = 0;
228: $xlist = 0;
229: }
230: if ("@state" eq "class users user roles role") {
231: $role = $attr->{id};
232: if ($role =~ /^(st|ad|ep|ta|in|cc)$/) {
233: push(@{$$details{$num}{'users'}{$userkey}{'roles'}}, $role);
234: %{$$details{$num}{'users'}{$userkey}{$role}} = ();
235: @{$$details{$num}{'users'}{$userkey}{$role}{'usec'}} = ();
236: }
237: }
238: if ("@state" eq "class sections section") {
239: $secid ++;
240: %{$$details{$num}{'sections'}{$secid}} = ();
241: }
242: if ("@state" eq "class crosslists xlist") {
243: $xlist ++;
244: %{$$details{$num}{'crosslists'}{$xlist}} = ();
245: }
246: }, "tagname, attr"],
247: text_h =>
248: [sub {
249: my ($text) = @_;
250: if ("@state" eq "class owner username") {
251: $$details{$num}{'owner'} = $text;
252: } elsif ("@state" eq "class owner domain") {
253: $$details{$num}{'domain'} = $text;
254: } elsif ("@state" eq "class sections section inst") {
255: $$details{$num}{'sections'}{$secid}{'inst'} = $text;
256: } elsif ("@state" eq "class sections section loncapa") {
257: $$details{$num}{'sections'}{$secid}{'loncapa'} = $text;
258: } elsif ("@state" eq "class crosslists xlist inst") {
259: $$details{$num}{'crosslists'}{$xlist}{'inst'} = $text;
260: } elsif ("@state" eq "class crosslists xlist loncapa") {
261: $$details{$num}{'crosslists'}{$xlist}{'loncapa'} = $text;
262: } elsif ("@state" eq "class owner authtype") {
263: $$details{$num}{'ownerauthtype'} = $text;
264: } elsif ("@state" eq "class owner autharg") {
265: $$details{$num}{'ownerautharg'} = $text;
266: } elsif ("@state" eq "class authentication method") {
267: $$details{$num}{'authtype'} = $text;
268: } elsif ("@state" eq "class authentication param") {
269: $$details{$num}{'authparam'} = $text;
270: } elsif ("@state" eq "class users user username") {
271: $userkey = $text;
272: } elsif ("@state" eq "class users user domain") {
273: $userkey .= ':'.$text;
274: %{$$details{$num}{'users'}{$userkey}} = ();
275: @{$$details{$num}{'users'}{$userkey}{'roles'}} = ();
276: } elsif ("@state" eq "class users user email") {
277: $$details{$num}{'users'}{$userkey}{'emailaddr'} = $text;
278: $$details{$num}{'users'}{$userkey}{'emailenc'} = &Apache::lonnet::escape($text);
279: } elsif ("@state" eq "class users user roles role start") {
280: if ($role =~ /^(st|ad|ep|ta|in|cc)$/) {
281: $$details{$num}{'users'}{$userkey}{$role}{'start'} = &process_date($text);
282: }
283: } elsif ("@state" eq "class users user roles role end") {
284: if ($role =~ /^(st|ad|ep|ta|in|cc)$/) {
285: $$details{$num}{'users'}{$userkey}{$role}{'end'} = &process_date($text);
286: }
287: } elsif ("@state" eq "class users user roles role usec") {
288: if ($role =~ /^(st|ad|ep|ta|in|cc)$/) {
289: unless ($text eq '') {
290: push(@{$$details{$num}{'users'}{$userkey}{$role}{'usec'}},$text);
291: }
292: }
293: } else {
294: foreach my $item (@items) {
295: if ("@state" eq "class $item") {
296: $$details{$num}{$item} = $text;
297: }
298: }
299: foreach my $item (@dateitems) {
300: if ("@state" eq "class $item") {
301: $$details{$num}{$item} = &process_date($text);
302: }
303: }
304: foreach my $item (@useritems) {
305: if ("@state" eq "class users user $item") {
306: $$details{$num}{'users'}{$userkey}{$item} = $text;
307: }
308: }
309: }
310: }, "dtext"],
311: end_h =>
312: [sub {
313: my ($tagname) = @_;
314: if ("@state" eq "class") {
315: $num ++;
316: }
317: pop @state;
318: }, "tagname"],
319: );
320:
321: $p->parse_file($coursefile);
322: $p->eof;
323: if (-e "$coursefile") {
324: # unlink $coursefile;
325: }
326: return;
327: }
328:
329: #########################################################
330: #
331: # build_course()
332: #
333: # inputs
334: # domain
335: # course request number
336: # context - auto if called from command line, web if called from DC web interface
337: # ref to hash of course creation information
338: # ref to hash of role descriptions
339: # ref to scalar used to accumulate log messages
340: # ref to scalar used to accumulate messages sent to new users
341: # ref to scalar used to accumulate results of new user additions
342: # ref to hash of enrollment counts for different roles
343: # ref to scalar used to accumulate iformation about added roles
344: # ref to scalar used to accumulate
345: #
346: # outputs
347: # LON-CAPA courseID for new (created) course
348: #
349: #########################################################
350:
351: sub build_course {
352: my ($cdom,$num,$context,$details,$longoles,$logmsg,$newusermsg,$addresult,$enrollcount,$output,$keysmsg) = @_;
353: my $owner_uname = $$details{$num}{'owner'};
354: my $owner_domain = $$details{$num}{'domain'};
355: my $owner = $owner_uname.':'.$owner_domain;
356: my $sectionstr = '';
357: my $xliststr = '';
358: my $noenddate = '';
359: my $outcome;
360: my ($courseid,$crsudom,$crsunum);
361: my $linefeed;
362: if ($context eq 'auto') {
363: $linefeed = "\n";
364: } else {
365: $linefeed = "<br />\n";
366: }
367: if ($$details{$num}{'accessend'} eq '') {
368: $noenddate = 1;
369: }
370: my $reshome = $$details{$num}{'reshome'};
371: if ($reshome eq '') {
372: $reshome = '/res/'.$cdom;
373: }
374: my $firstres = $$details{$num}{'firstres'};
375: if ($firstres eq '') {
376: $firstres = 'syl';
377: }
378: foreach my $secid (sort keys %{$$details{$num}{'sections'}}) {
379: $sectionstr .= $$details{$num}{'sections'}{$secid}{'inst'}.':'.$$details{$num}{'sections'}{$secid}{'loncapa'};
380: }
381:
382: foreach my $xlist (sort keys %{$$details{$num}{'crosslists'}}) {
383: $xliststr .= $$details{$num}{'crosslists'}{$xlist}{'inst'}.':'.$$details{$num}{'crosslists'}{$xlist}{'loncapa'};
384: }
385:
386: my %courseinfo = (
387: inst_code => $$details{$num}{'coursecode'},
388: description => $$details{$num}{'title'}
389: );
390: if (&Apache::lonnet::homeserver($$details{$num}{'owner'},$$details{$num}{'domain'}) eq 'no_host') { # Add user if no account
391: my $ownerargs = ('auth' => $$details{$num}{'ownerauthtype'},
392: 'authparam' => $$details{$num}{'ownerauthparam'},
393: 'emailenc' => $$details{$num}{'emailenc'},
394: 'dom' => $$details{$num}{'domain'},
395: 'uname' => $$details{$num}{'owner'},
396: 'pid' => '',
397: 'first' => $$details{$num}{'users'}{$owner}{'first'},
398: 'middle' => $$details{$num}{'users'}{$owner}{'middle'},
399: 'last' => $$details{$num}{'users'}{$owner}{'last'},
400: 'gene' => $$details{$num}{'users'}{$owner}{'gene'},
401: 'usec' => '',
402: 'end' => '',
403: 'start' => '',
404: 'emailaddr' => $$details{$num}{'users'}{$owner}{'email'},
405: 'cid' => '',
406: 'context' => 'createowner',
407: 'linefeed' => $linefeed,
408: 'role' => 'cc'
409: );
410: $outcome = &LONCAPA::Enrollment::create_newuser($ownerargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,$courseinfo);
411: } else {
412: $outcome = 'ok';
413: }
414:
415: my $courseargs = {
416: ccuname => $$details{$num}{'owner'},
417: ccdomain => $$details{$num}{'domain'},
418: cdescr => $$details{$num}{'title'},
419: curl => $$details{$num}{'topmap'},
420: course_domain => $cdom,
421: course_home => $$details{$num}{'coursehome'},
422: nonstandard => $$details{$num}{'nonstandard'},
423: crscode => $$details{$num}{'coursecode'},
424: clonecourse => $$details{$num}{'clonecrs'},
425: clonedomain => $$details{$num}{'clonedom'},
426: crsid => $$details{$num}{'optional_id'},
427: curruser => $$details{$num}{'owner'},
428: crssections => $sectionstr,
429: crsxlist => $xliststr,
430: autoadds => $$details{$num}{'adds'},
431: autodrops => $$details{$num}{'drops'},
432: notify => $$details{$num}{'notify_owner'},
433: notify_dc => $$details{$num}{'notify_dc'},
434: no_end_date => $noenddate,
435: showphotos => $$details{$num}{'showphotos'},
436: authtype => $$details{$num}{'authtype'},
437: autharg => $$details{$num}{'authparam'},
438: enrollstart => $$details{$num}{'enrollstart'},
439: enrollend => $$details{$num}{'enrollend'},
440: startaccess => $$details{$num}{'accessstart'},
441: endaccess => $$details{$num}{'accessend'},
442: setpolicy => $Sdetails{$num}{'setpolicy'},
443: setcontent => $$details{$num}{'setcontent'},
444: reshome => $reshome,
445: setkeys => $$details{$num}{'setkeys'},
446: keyauth => $$details{$num}{'keyauth'},
447: disresdis => $$details{$num}{'disresdis'},
448: disablechat => $$details{$num}{'disablechat'},
449: openall => $$details{$num}{'openall'},
450: firstres => $firstres
451: };
452:
453: if ($outcome eq 'ok') {
454: my %host_servers = &Apache::loncommon::get_library_servers($cdom);
455: if (! exists($host_servers{$$details{$num}{'coursehome'}})) {
456: $$logmsg .= &mt('Invalid home server for course').': '.$$details{$num}{'coursehome'};
457: return;
458: }
459:
460: &Apache::loncreatecourse::construct_course($courseargs,$logmsg,\$courseid,\$crsudom,\$crsunum);
461: } else {
462: return;
463: }
464:
465: #
466: # Make owner a course coordinator
467: #
468: if (($owner_domain) && ($owner_uname)) {
469: &Apache::lonnet::assignrole($owner_domain,$owner_uname,$courseid,'cc');
470: }
471:
472: #
473: # Process other reqested users
474: #
475: my $stulogmsg = '';
476: foreach my $userkey (sort keys %{$$details{$num}{'users'}}) {
477: my $url = '/'.$crsudom.'/'.$crsunum;
478: if (@{$$details{$num}{'users'}{$userkey}{'roles'}} > 0) {
479: my ($username,$userdom) = split/:/,$userkey;
480: if (&Apache::lonnet::homeserver($username,$userdom) eq 'no_host') { # Add user if no account
481: my $firstrole = $$details{$num}{'users'}{$userkey}{'roles'}[0];
482: my $firssec = $$details{$num}{'users'}{$userkey}{$firstrole}{'usec'}[0];
483: my $userargs = ('auth' => $$details{$num}{'users'}{$userkey}{'authtype'},
484: 'authparam' => $$details{$num}{'users'}{$userkey}{'authparam'},
485: 'emailenc' => $$details{$num}{'users'}{$userkey}{'emailenc'},
486: 'dom' => $userdom,
487: 'uname' => $username,
488: 'pid' => $$details{$num}{'users'}{$userkey}{'studentID'},
489: 'first' => $$details{$num}{'users'}{$userkey}{'first'},
490: 'middle' => $$details{$num}{'users'}{$userkey}{'middle'},
491: 'last' => $$details{$num}{'users'}{$userkey}{'last'},
492: 'gene' => $$details{$num}{'users'}{$userkey}{'gene'},
493: 'usec' => $firstsec,
494: 'end' => $$details{$num}{'users'}{$userkey}{'end'},
495: 'start' => $$details{$num}{'users'}{$userkey}{'start'},
496: 'emailaddr' => $$details{$num}{'users'}{$userkey}{'email'},
497: 'cid' => $courseid,
498: 'context' => 'createcourse',
499: 'linefeed' => $linefeed,
500: 'role' => $$details{$num}{'users'}{$userkey}{'roles'}[0],
501: );
502: $outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,$courseinfo);
503: # now add other roles and other sections.
504: if ($outcome eq 'ok') {
505: if (($firstrole ne 'st') && (@{$$details{$num}{'users'}{$userkey}{$firstrole}{'usec'}} > 1)) {
506: for (my $i=1; $i<@{$$details{$num}{'users'}{$userkey}{$firstrole}{'usec'}}; $i++) {
507: my $curr_role = $firstrole;
508: my $start = $$details{$num}{'users'}{$userkey}{$curr_role}{'start'};
509: my $end = $$details{$num}{'users'}{$userkey}{$curr_role}{'end'};
510: my $usec = $$details{$num}{'users'}{$userkey}{$firstrole}{'usec'}[$i];
511: $url = '/'.$crsudom.'/'.$crsunum;
512: if ($usec ne '') {
513: $url .= '/'.$usec;
514: }
515: $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
516: }
517: }
518: if (@{$$details{$num}{'users'}{$userkey}{'roles'}} > 1) {
519: for (my $j=1; $j<@{$$details{$num}{'users'}{$userkey}{'roles'}}; $j++) {
520: my $curr_role = $$details{$num}{'users'}{$userkey}{'roles'}[$j];
521: my $start = $$details{$num}{'users'}{$userkey}{$curr_role}{'start'};
522: my $end = $$details{$num}{'users'}{$userkey}{$curr_role}{'end'};
523: if ($curr_role eq 'st') {
524: my $usec = $$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}[0];
525: $url = '/'.$crsudom.'/'.$crsunum;
526: if ($usec ne '') {
527: $url .= '/'.$usec;
528: }
529: $$output .= &Apache::loncreateuser::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
530: } else {
531: foreach my $usec (@{$$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}}) {
532: $url = '/'.$crsudom.'/'.$crsunum;
533: if ($usec ne '') {
534: $url .= '/'.$usec;
535: }
536: $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
537: }
538: }
539: }
540: }
541: }
542: } else {
543: foreach my $curr_role (@{$$details{$num}{'users'}{$userkey}{'roles'}}) {
544: my $start = $$details{$num}{'users'}{$userkey}{$curr_role}{'start'};
545: my $end = $$details{$num}{'users'}{$userkey}{$curr_role}{'end'};
546: if ($curr_role eq 'st') {
547: my $usec = $$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}[0];
548: $url = '/'.$crsudom.'/'.$crsunum;
549: if ($usec ne '') {
550: $url .= '/'.$usec;
551: }
552: $$output .= &Apache::loncreateuser::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
553: } else {
554: if (@{$$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}} > 0) {
555: foreach my $usec (@{$$details{$num}{'users'}{$userkey}{$curr_role}{'usec'}}) {
556: $url = '/'.$crsudom.'/'.$crsunum;
557: if ($usec ne '') {
558: $url .= '/'.$usec;
559: }
560: $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec);
561: $url = '/'.$crsudom.'/'.$crsunum;
562: if ($usec ne '') {
563: $url .= '/'.$usec;
564: }
565: }
566: } else {
567: $$output .= &Apache::loncreateuser::commit_standardrole($userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,'');
568: }
569: }
570: }
571: }
572: }
573: }
574:
575: # Information about keys.
576: if ($$details{$num}{'setkeys'}) {
577: $$keysmsg .=
578: '<a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a> for '.$$details{$num}{'title'}.$linefeed;
579: }
580: # Flush the course logs so reverse user roles immediately updated
581: &Apache::lonnet::flushcourselogs();
582: return $courseid;
583: }
584:
585: #########################################################
586: #
587: # process_date()
588: #
589: # input - date/time string in format YYYY:MM:DD:HH:MM:SS (:separators required).
590: # output - corresponding UNIX time (seconds since epoch).
591: #
592: #########################################################
593:
594: sub process_date {
595: my $timestr = shift;
596: my $timestamp = '';
597: if ($timestr eq "No end date") {
598: $timestamp = '';
599: } else {
600: my @entries = split/:/,$timestr;
601: for (my $j=0; $j<@entries; $j++) {
602: if ( length($entries[$j]) > 1 ) {
603: $entries[$j] =~ s/^0//;
604: }
605: }
606: $entries[1] = $entries[1] - 1;
607: $timestamp = timelocal($entries[5],$entries[4],$entries[3],$entries[2],$entries[1],$entries[0]);
608: }
609: return $timestamp;
610: }
611:
612: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>