File:
[LON-CAPA] /
loncom /
enrollment /
localenroll.pm
Revision
1.18:
download - view:
text,
annotated -
select for diffs
Mon Feb 26 20:52:55 2007 UTC (17 years, 4 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
Support automated update of instiutional users in a domain, based on domain preferences.
Autoupdate.pl --
- Institutional data now gathered for all users in a single call to localenroll.
- Correction to check to see if Autoupdate should run
- Accumulate updateable fields for all institutional types with which user is affiliated
- Use modifyuser() in lonnet to store updated user information
- affiliations_check() checks for changes in institutional status
localenroll.pm --
- correct documentation for instcodes hash reference
- allusers_info() - retrieve institutional user data for all users.
- get_userinfo() - retrieve institutional data for a single username or ID
- inst_usertypes() - provide institutional types (short and long titles).
1: # functions to glue school database system into Lon-CAPA for
2: # automated enrollment
3: # $Id: localenroll.pm,v 1.18 2007/02/26 20:52:55 raeburn Exp $
4: #
5: # Copyright Michigan State University Board of Trustees
6: #
7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8: #
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: package localenroll;
28:
29: use strict;
30:
31: ################################
32: # sub run
33: # set this to return 1 if you want the auto enrollment to run
34: ################################
35:
36: sub run() {
37: my $dom = shift;
38: return 0;
39: }
40:
41: ################################
42: # sub fetch_enrollment
43: #
44: # connects to the institutional classlist data source,
45: # reads classlist data and stores in an XML file
46: # in /home/httpd/perl/tmp/
47: #
48: # classlist files are named as follows:
49: #
50: # DOMAIN_COURSE_INSTITUTIONALCODE_classlist.xml
51: #
52: # e.g., msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
53: # where DOMAIN = msu COURSE = 43551dedcd43febmsul1
54: # INSTITUTIONALCODE = fs03nop590001
55: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
56: # department name, 590 = course number, 001 = section number.)
57: #
58: # fetch_enrollment requires three arguments -
59: # $dom - DOMAIN e.g., msu
60: # $affiliatesref - a reference to a hash of arrays that contains LON-CAPA
61: # courses that are to be updated as keys, and institutional coursecodes
62: # contributing enrollment to that LON-CAPA course as elements in each array.
63: # $replyref - a reference to a hash that contains LON-CAPA courses
64: # that are to be updated as keys, and the total enrollment count in all
65: # affiliated sections, as determined from institutional data as hash elements.
66: #
67: # As an example, if fetch_enrollment is called to retrieve institutional
68: # classlists for a single LON-CAPA course - 43551dedcd43febmsul1 which
69: # corresponds to fs03nop590, sections 001, 601 and 602 , and the course
70: # also accommodates enrollment from a crosslisted course in the ost
71: # department - fs03ost580002:
72: #
73: # the affiliatesref would be a reference to %affiliates which would be:
74: #
75: # @{$affiliates{'43551dedcd43febmsul1'}} =
76: # ("fs03nop590001","fs03nop590601","fs03nop590602","fs03ost580002");
77: #
78: # fetch_enrollment would create four files in /home/httpd/perl/tmp/.
79: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
80: # msu_43551dedcd43febmsul1_fs03nop590601_classlist.xml
81: # msu_43551dedcd43febmsul1_fs03nop590602_classlist.xml
82: # msu_43551dedcd43febmsul1_fs03ost580002_classlist.xml
83: #
84: # In each file, student data would be stored in the following format
85: #
86: # <student username="smith">
87: # <autharg>MSU.EDU</autharg>
88: # <authtype>krb4</authtype>
89: # <email>smith@msu.edu</email>
90: # <enddate></enddate>
91: # <firstname>John</firstname>
92: # <generation>II</generation>
93: # <groupID>fs03nop590001</groupID>
94: # <lastname>Smith</lastname>
95: # <middlename>D</middlename>
96: # <startdate></startdate>
97: # <studentID>A12345678</studentID>
98: # </student>
99: #
100: # with the following at the top of the file
101: #<?xml version="1.0" encoding="UTF-8"?>
102: #<!DOCTYPE text>
103: #<students>
104: #
105: # (all comment - #s removed)
106: #
107: # and a closing:
108: #</students>
109: #
110: # The <startdate> and the <enddate> are the activation date and expiration date
111: # for this student's role. If they are absent, then the default access start and
112: # default access end dates are used. The default access dates can be set when
113: # the course is created, and can be modified using the Automated Enrollment
114: # Manager, or via the 'Upload a class list','Enroll a single student' or
115: # 'Modify student data' utilities in the Enrollment Manager, by checking the
116: # 'make these dates the default for future enrollment' checkbox. If no default
117: # dates have been set, then the tudent role will be active immediately, and will
118: # remain active until the role is explicitly expired using ENRL -> Drop students.
119: # If dates are to included in the XML file, they should be in the format
120: # YYYY:MM:DD:HH:MM:SS (: separators required).
121: #
122: # If there were 10 students in fs03nop590001, 5 students in fs03nop59o601,
123: # 8 students in fs03nop590602, and 2 students in fs03ost580002,
124: # then $$reply{'43551dedcd43febmsul1'} = 25
125: #
126: # The purpose of the %reply hash is to detect cases where the institutional
127: # enrollment is 0 (most likely due to a problem with the data source).
128: # In such a case, the LON-CAPA course roster is left unchanged (i.e., no
129: # students are expired, even if automated drops is enabled.
130: #
131: # fetch_enrollment should return a 0 or 1, depending on whether a connection
132: # could be established to the institutional data source.
133: # 0 is returned if no connection could be made.
134: # 1 is returned if connection was successful
135: #
136: # A return of 1 is required for the calling modules to perform LON-CAPA
137: # roster changes based on the contents of the XML classlist file(s), e,g,,
138: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
139: #
140: # XML classlist files are temporary. They are deleted after the enrollment
141: # update process in the calling module is complete.
142: #
143: ################################
144:
145: sub fetch_enrollment {
146: my ($dom,$affiliatesref,$replyref) = @_;
147: foreach my $crs (sort keys %{$affiliatesref}) {
148: $$replyref{$crs} = 0;
149: }
150: my $okflag = 0;
151: return $okflag;
152: }
153:
154: ###############################
155: # sub get_sections
156: #
157: # This is called by the Automated Enrollment Manager interface
158: # (lonpopulate.pm) to create an array of valid sections for
159: # a specific institutional coursecode.
160: # e.g., for MSU coursecode: fs03nop590
161: # ("001","601","602") would be returned
162: #
163: # If the array returned contains at least one element, then
164: # the interface offerred to the course coordinator, lists
165: # official sections and provides a checkbox to use to
166: # select enrollment in the LON-CAPA course from each official section.
167: #
168: # get_sections takes two arguments - (a) the institutional coursecode
169: # (in the MSU case this is a concatenation of semester code, department
170: # and course number), and (b) the LON-CAPA domain that contains the course.
171: #
172: # If there is no access to official course sections at your institution,
173: # then an empty array is returned, and the Automated Enrollment Manager
174: # interface will allow the course coordinator to enter section numbers
175: # in text boxes.
176: #
177: ###############################
178:
179: sub get_sections {
180: my ($coursecode,$dom) = @_;
181: my @secs = ();
182: return @secs;
183: }
184:
185: ###############################
186: # sub new_course
187: #
188: # This is called by loncreatecourse.pm and
189: # lonpopulate.pm to record that fact that a new course section
190: # has been added to LON-CAPA that requires access to institutional data
191: # At MSU, this is required, as institutional classlists can only made
192: # available to faculty who are officially assigned to a course.
193: #
194: # The new_course subroutine is used to check that the course owner
195: # of the LON-CAPA course is permitted to access the institutional
196: # classlist for any course sections and crosslisted classes that
197: # the course coordinator wishes to have affiliated with the course.
198: #
199: # If access is permitted, then 'ok' is returned.
200: # The course section or crosslisted course will only be added to the list of
201: # affiliates if 'ok' is returned.
202: #
203: # new_course takes three arguments -
204: # (a) the institutional courseID (in the MSU case this is a concatenation of
205: # semester code, department code, course number, and section number
206: # e.g., fs03nop590001).
207: # (b) the course owner. This is the LON-CAPA username and domain of the course
208: # coordinator assigned to the course when it is first created, in the form
209: # username:domain
210: # (c) the LON-CAPA domain that contains the course
211: #
212: #################################
213:
214: sub new_course {
215: my ($course_id,$owner,$dom) = @_;
216: my $outcome = 'ok';
217: return $outcome;
218: }
219:
220: ###############################
221: # sub validate_courseID
222: #
223: # This is called whenever a new course section or crosslisted course
224: # is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
225: # and the Automated Enrollment Manager in lonpopulate.pm).
226: # A check is made that the courseID that the course coordinator wishes
227: # to affiliate with the course is valid according to the institutional
228: # schedule of official classes
229: #
230: # A valid courseID is confirmed by returning 'ok'
231: #
232: # validate_courseID takes two arguments -
233: # (a) the institutional courseID (in the MSU case this is a concatenation of
234: # semester code, department code, course number, and section number
235: # e.g., fs03nop590001).
236: # (b) the LON-CAPA domain that contains the course
237: #
238: ###############################
239:
240: sub validate_courseID {
241: my ($course_id,$dom) = @_;
242: my $outcome = 'ok';
243: return $outcome;
244: }
245:
246: ###############################
247: # sub create_password
248: #
249: # This is called when the authentication method set for the automated
250: # enrollment process when enrolling new users in the domain is "localauth".
251: # This could be signalled for the specific user by the value of localauth
252: # for the <authtype> tag from the classlist.xml files, or if this is blank,
253: # the default authtype, set by the domain coordinator when creating the course
254: # with loncreatecourse.pm.
255: #
256: # create_password takes three arguments -
257: # (a) $authparam - the value of <autharg> from the classlist.xml files,
258: # or if this blank, the default autharg, set by the domain coordinator when
259: # creating the course with loncreatecourse.pm
260: # (b) $dom - the domain of the new user.
261: # (c) $username - the username of the new user (currently not actually used)
262: #
263: # Four values are returned:
264: # (a) the value of $authparam - which might have been changed
265: # (b) a flag to indicate whether a password had been created
266: # 0 means no password created
267: # 1 means password created. In this case the calling module - Enrollment.pm
268: # will send the LON-CAPA username and password to the new user's e-mail
269: # (if one was provided), or to the course owner (if one was not provided and
270: # the new user was created by the automated process), or to the active
271: # course coordinator (if the new user was created using the 'update roster
272: # now' interface included in the Automated Enrollment Manager).
273: # (c) a flag to indicate that the authentication method is correct - 'ok'.
274: # If $authchk is not set to 'ok' then account creation and enrollment of the
275: # new user will not occur.
276: # (d) if a password was created it can be sent along. This is the password
277: # which will be included in the e-mail sent to the new user, or made available
278: # to the course owner/course coordinator if no e-mail address is provided. If
279: # you do not wish to send a password, but want to give instructions on obtaining
280: # one, you could set $newpasswd as those instructions. (e.g.,
281: # $newpasswd = '(Please visit room 212, ACNS Bldg. to obtain your password)';
282: # The value of $newpasswd is NOT written in the user's LON-CAPA passwd file in
283: # /home/httpd/lonUsers/$dom/a/b/c/abcuser/passwd, which in the case of a user
284: # employing localauth will contain 'localauth:$authparam'. If you need to include
285: # a parameter in the user's passwd file, you should return it as $authparam,
286: # i.e., the first of the variables returned by create_password().
287: ###############################
288:
289: sub create_password {
290: my ($authparam,$dom,$username) = @_;
291: my $authchk = 'ok';
292: my $newpasswd = '';
293: my $create_passwd = 0;
294: return ($authparam,$create_passwd,$authchk,$newpasswd);
295: }
296:
297: ###############################
298: # sub instcode_format
299: #
300: # Split coursecodes into constituent parts.
301: # e.g., INSTITUTIONALCODE = fs03nop590, LON-CAPA COURSEID: 43551dedcd43febmsul1
302: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
303: # department name, 590 = course number)
304: #
305: # Incoming data:
306: # $dom (domain)
307: # $$instcodes{'43551dedcd43febmsul1'} = 'fs03nop590' (hash of courseIDs)
308: #
309: # fs03nop590 would be split as follows
310: # @{$codetitles} = ("year","semester","department","number")
311: # $$codes{{'year'} = '2003'
312: # $$codes{'semester'} = 'Fall'
313: # $$codes{'department'} = 'nop'
314: # $$codes{'number'} = '590'
315: #
316: # requires six arguments:
317: # domain ($dom)
318: # reference to hash of institutional course IDs ($instcodes)
319: # reference to hash of codes ($codes)
320: # reference to array of titles ($codetitles)
321: # reference to hash of abbreviations used in categories
322: # reference to hash of arrays specifying sort order used in category titles
323: #
324: # e.g., %{$$cat_titles{'Semester'}} = (
325: # fs => 'Fall',
326: # ss => 'Spring',
327: # us => 'Summer');
328: #
329: # e.g., @{$$cat_order{'Semester'}} = ('ss','us','fs');
330: # returns 1 parameter: 'ok' if no processing errors.
331: ###############################
332:
333: sub instcode_format () {
334: my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
335: my $outcome = 'ok';
336: return $outcome;
337: }
338:
339: ###############################
340: # sub institutional_photos
341: #
342: # Called when automated enrollment manager is used to update student photos.
343: #
344: # Incoming data: six arguments
345: # (a) $dom (domain)
346: # (b) $crs (LONCAPA course number)
347: # (c) $affiliates: a reference to a hash with the keys set to the
348: # institutional course IDs for the course.
349: # (d) $result: a reference to a hash which will return usernames
350: # of students (& separated) in following categories (the keys):
351: # new, update, missing, same, deleted, noid, nouser. The list
352: # includes those students for whom the result of the modification
353: # process was either addition of a new photo. update of an
354: # existing photo, photo was found to be missing from institution's
355: # data store, photo used is same as before, or photo was
356: # deleted from storage on LON-CAPA server housing student's
357: # information, no student ID was available.
358:
359: # (e) $action: the type of action needed. (e.g., update, delete);
360: # (f) $students: a reference to a hash with the keys set to student
361: # usernames and domains in the form username:domain, and values set
362: # to the studentID, if action is required for specific students.
363: #
364: # returns 1 parameter: 'ok' if no processing errors.
365: # other course or student specific values can be stored as values
366: # in the appropriate referenced hashes.
367: ###############################
368:
369: sub institutional_photos {
370: my ($dom,$crs,$affiliates,$result,$action,$students) = @_;
371: my $outcome = 'ok';
372: return $outcome;
373: }
374:
375: ###############################
376: # sub photo_permission
377: #
378: # Incoming data: three arguments
379: # (a) $dom (domain)
380: # (b) $perm_reqd: a reference to a a scalar that is either 'yes'
381: # if a course owner must indicate acceptance of conditions of use,
382: # 'no' otherwise.
383: # (c) $conditions: the text of the conditions of use.
384: #
385: # returns 1 parameter: 'ok' if no processing errors.
386: # $$perm_reqd is set to 'yes' or 'no'
387: # $$agreement is set to conditions of use - plain text string
388: # which will be displayed in a textarea in a web form.
389: ###############################
390:
391: sub photo_permission {
392: my ($dom,$perm_reqd,$conditions) = @_;
393: $$perm_reqd = 'no';
394: $$conditions = '';
395: my $outcome = 'ok';
396: return $outcome;
397: }
398:
399:
400: ###############################
401: # sub manager_photo_update
402: #
403: # Incoming data: one argument
404: # (a) $dom (domain)
405: #
406: # returns 2 parameters: update (0 or 1), and comment.
407: # Called by automated enrollment manager, to determine
408: # whether "Update Student photos" button will be available,
409: # and if so, the message (plain text string) that will be displayed
410: # with the button.
411: ###############################
412:
413: sub manager_photo_update {
414: my ($dom) = @_;
415: my $update = 0;
416: my $comment = '';
417: return ($update,$comment);
418: }
419:
420: ###############################
421: # sub check_section
422: #
423: # Incoming data: three arguments (+ fourth optional argument)
424: # (a) $class - institutional class id (coursecode concatanated with section)
425: # (b) $owner - course owner (2.2 and later username:domain; pre-2.2 username)
426: # (c) $dom 0 domain of course
427: # (d) $dbh - optional database handle
428: #
429: # returns 1 parameter - $sectioncheck ('ok' or other value).
430: # Verifies that course owner has access to classlist for specific class
431: # according to institution's SIS. 'ok' if access available
432: ###############################
433:
434: sub check_section {
435: my ($class,$owner,$dom,$dbh) = @_;
436: my $sectioncheck = 'ok';
437: return $sectioncheck;
438: }
439:
440: ###############################
441: # sub instcode_defaults
442: #
443: # Incoming data: three arguments
444: # (a) $dom - domain
445: # (b) $defaults - reference to hash which will contain default regular
446: # expression matches for different components of an
447: # institutional course code
448: # (c) $code_order - reference to array which will contain order of
449: # component parts used in institutional code.
450: #
451: # returns 1 parameter - ('ok' or other value).
452: # Used to construct a regular expression to be used when searching for
453: # courses based on fragments of an institutional code.
454: # $defaults contains defaults to use for each component, and code_order
455: # contains keys of hash in order in which they are to be concatenated.
456: #
457: # e.g., INSTITUTIONALCODE = fs03nop590
458: # (MSU's course naming scheme - fs = semester, 03 = year, nop =
459: # department name, 590 = course number)
460: #
461: # %{$defaults} = (
462: # 'Year' => '\d{2}',
463: # 'Semester' => '^[sfu]s',
464: # 'Department' => '\w{2,3}',
465: # 'Number' => '\d{3,4}\w?',
466: # );
467: #
468: # @{$code_order} = ('Semester','Year','Department','Number');
469: #
470: ###############################
471:
472: sub instcode_defaults {
473: my ($dom,$defaults,$code_order) = @_;
474: return 'ok';
475: }
476:
477: ###############################
478: # sub allusers_info
479: #
480: # Incoming data: three arguments
481: # (a) $dom - domain
482: # (b) $instusers - reference to hash which will contain hashes,
483: # where keys will be usernames and value will be a
484: # hash of user information. Keys in the inner hash
485: # will be some or all of: lastname,firstname,
486: # middlename, generation, id, inststatus -
487: # institutional status (e.g., faculty,staff,student)
488: # Values are all scalars except inststatus,
489: # which is an array.
490: # (c) $instids - reference to hash which will contain ID numbers.
491: # keys will be unique IDs (student or faculty/staff ID)
492: # values will be either: scalar (username) or an array
493: # if a single ID matches multiple usernames.
494: # returns 1 parameter - ('ok' or other value).
495: # side effects - populates the $instusers and $instids refs to hashes.
496: # with information for all users from all available
497: # institutional datafeeds.
498: #
499: ###############################
500:
501: sub allusers_info {
502: my ($dom,$instusers,$instids) = @_;
503: my $outcome = 'ok';
504: return $outcome;
505: }
506:
507: ###############################
508: # sub get_userinfo
509: #
510: # Incoming data: four required arguments and two optional arguments
511: # Retrieves institutional data for a single user either by username
512: # if $uname is included as second argument, or by ID if $id is
513: # included as a third argument. Either (b) or (c) must be provided.
514: # (a) $dom - domain
515: # (b) $uname - username of user
516: # (c) $id - student/faculty ID of user
517: # (d) $instusers - reference to hash which will contain info for user
518: # as key = value; keys will be one or all of:
519: # lastname,firstname,middlename,generation,id,inststatus -
520: # institutional status (e.g., faculty,staff,student)
521: # Values are all scalars except inststatus,
522: # which is an array.
523: # (e) $instids - reference to hash which will contain ID numbers -
524: # keys will be unique IDs (student or faculty/staff ID)
525: # values will be either: scalar (username) or an array
526: # if a single ID matches multiple usernames.
527: # (f) $types - optional reference to array which contains
528: # institutional types to check.
529: #
530: # returns 1 parameter - ('ok' or other value).
531: # side effects - populates the $instusers and $instids refs to hashes.
532: # with information for specified username, or specified
533: # id, if fifth argument provided, from all available, or
534: # specified (e.g., faculty only) institutional datafeeds,
535: # if sixth argument provided.
536: ###############################
537:
538: sub get_userinfo {
539: my ($dom,$uname,$id,$instusers,$instids,$types) = @_;
540: my $outcome = 'ok';
541: return $outcome;
542: }
543:
544: ###############################
545: # sub inst_usertypes
546: #
547: # Incoming data: three arguments
548: # (a) $dom - domain
549: # (b) $usertypes - reference to hash which will contain
550: # key = value, where keys are institution
551: # affiliation types (e.g., Faculty, Student etc.)
552: # and values are titles (e.g., Faculty/Academic Staff)
553: # (c) $order - reference to array which will contain the order in
554: # which institutional types should be shown
555: # when displaying data tables (e.g., default quotas
556: # or updateable user fields (see domainprefs.pm)
557: # returns 1 parameter - ('ok' or other value).
558: #
559: ###############################
560:
561: sub inst_usertypes {
562: my ($dom,$usertypes,$order) = @_;
563: my $outcome = 'ok';
564: return $outcome;
565: }
566:
567: ###############################
568: # sub AUTOLOAD
569: #
570: # Incoming data: none
571: # Returns ''
572: #
573: # Prevents errors when undefined subroutines are called in this package
574: # Will allow new routines added in the future to be called from lond etc.
575: # without the need for customized versions of local*.pm packages to be
576: # modified to include the new subroutines immediately.
577: #
578: # See "Programming Perl" 3rd ed. pp 296-298.
579: ###############################
580:
581: sub AUTOLOAD {
582: our $AUTOLOAD;
583: return '';
584: }
585:
586: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>