File:
[LON-CAPA] /
loncom /
enrollment /
localenroll.pm
Revision
1.12:
download - view:
text,
annotated -
select for diffs
Tue Feb 7 05:08:21 2006 UTC (18 years, 7 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
Add support for student photo import from an institutional repository. Availability of photos of registered students in a course controlled by course environment parameter: 'internal.studentphoto'. This may be configured to require initial acceptance of conditions of use by course owner. View classlist in ENRL, and Automated Enrollment Manager now includes option to display thumbnails of student photos. Nightly enrollment update can import student photos for students added to a course. Student photos can be updated via the Automated Enrollment Manager.
1: # functions to glue school database system into Lon-CAPA for
2: # automated enrollment
3: # $Id: localenroll.pm,v 1.12 2006/02/07 05:08:21 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 of the course coordinator
208: # assigned to the course when it is first created.
209: # (c) the LON-CAPA domain that contains the course
210: #
211: #################################
212:
213: sub new_course {
214: my ($course_id,$owner,$dom) = @_;
215: my $outcome = 'ok';
216: return $outcome;
217: }
218:
219: ###############################
220: # sub validate_courseID
221: #
222: # This is called whenever a new course section or crosslisted course
223: # is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
224: # and the Automated Enrollment Manager in lonpopulate.pm).
225: # A check is made that the courseID that the course coordinator wishes
226: # to affiliate with the course is valid according to the institutional
227: # schedule of official classes
228: #
229: # A valid courseID is confirmed by returning 'ok'
230: #
231: # validate_courseID takes two arguments -
232: # (a) the institutional courseID (in the MSU case this is a concatenation of
233: # semester code, department code, course number, and section number
234: # e.g., fs03nop590001).
235: # (b) the LON-CAPA domain that contains the course
236: #
237: ###############################
238:
239: sub validate_courseID {
240: my ($course_id,$dom) = @_;
241: my $outcome = 'ok';
242: return $outcome;
243: }
244:
245: ###############################
246: # sub create_password
247: #
248: # This is called when the authentication method set for the automated
249: # enrollment process when enrolling new users in the domain is "localauth".
250: # This could be signalled for the specific user by the value of localauth
251: # for the <authtype> tag from the classlist.xml files, or if this is blank,
252: # the default authtype, set by the domain coordinator when creating the course
253: # with loncreatecourse.pm.
254: #
255: # create_password takes three arguments -
256: # (a) $authparam - the value of <autharg> from the classlist.xml files,
257: # or if this blank, the default autharg, set by the domain coordinator when
258: # creating the course with loncreatecourse.pm
259: # (b) $username - the username of the new user
260: # (b) $dom - the domain of the new user.
261: #
262: # Four values are returned:
263: # (a) the value of $authparam - which might have been changed
264: # (b) a flag to indicate whether a password had been created
265: # 0 means no password created
266: # 1 means password created. In this case the calling module - Enrollment.pm
267: # will send the LON-CAPA username and password to the new user's e-mail
268: # (if one was provided), or to the course owner (if one was not provided and
269: # the new user was created by the automated process), or to the active
270: # course coordinator (if the new user was created using the 'update roster
271: # now' interface included in the Automated Enrollment Manager).
272: # (c) a flag to indicate that the authentication method is correct - 'ok'.
273: # If $authchk is not set to 'ok' then account creation and enrollment of the
274: # new user will not occur.
275: # (d) if a password was created it can be sent along. This is the password
276: # which will be included in the e-mail sent to the new user, or made available
277: # to the course owner/course coordinator if no e-mail address is provided. If
278: # you do not wish to send a password, but want to give instructions on obtaining
279: # one, you could set $newpasswd as those instructions. (e.g.,
280: # $newpasswd = '(Please visit room 212, ACNS Bldg. to obtain your password)';
281: # The value of $newpasswd is NOT written in the user's LON-CAPA passwd file in
282: # /home/httpd/lonUsers/$dom/a/b/c/abcuser/passwd, which in the case of a user
283: # employing localauth will contain 'localauth:$authparam'. If you need to include
284: # a parameter in the user's passwd file, you should return it as $authparam,
285: # i.e., the first of the variables returned by create_password().
286: ###############################
287:
288: sub create_password {
289: my ($authparam,$username,$dom) = @_;
290: my $authchk = 'ok';
291: my $newpasswd = '';
292: my $create_passwd = 0;
293: return ($authparam,$create_passwd,$authchk,$newpasswd);
294: }
295:
296: ###############################
297: # sub instcode_format
298: #
299: # Split coursecodes into constituent parts.
300: # e.g., INSTITUTIONALCODE = fs03nop590, LON-CAPA COURSEID: 43551dedcd43febmsul1
301: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
302: # department name, 590 = course number)
303: #
304: # Incoming data:
305: # $dom (domain)
306: # $$instcodes{'43551dedcd43febmsul1'} = 'Title of course' (hash of courseIDs)
307: #
308: # fs03nop590 would be split as follows
309: # @{$codetitles} = ("year","semester","department","number")
310: # $$codes{{'year'} = '2003'
311: # $$codes{'semester'} = 'Fall'
312: # $$codes{'department'} = 'nop'
313: # $$codes{'number'} = '590'
314: #
315: # requires six arguments:
316: # domain ($dom)
317: # reference to hash of institutional course IDs ($instcodes)
318: # reference to hash of codes ($codes)
319: # reference to array of titles ($codetitles)
320: # reference to hash of abbreviations used in categories
321: # reference to hash of arrays specifying sort order used in category titles
322: #
323: # e.g., %{$$cat_titles{'Semester'}} = (
324: # fs => 'Fall',
325: # ss => 'Spring',
326: # us => 'Summer');
327: #
328: # e.g., @{$$cat_order{'Semester'}} = ('ss','us','fs');
329: # returns 1 parameter: 'ok' if no processing errors.
330: ###############################
331:
332: sub instcode_format () {
333: my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
334: my $outcome = 'ok';
335: return $outcome;
336: }
337:
338: ###############################
339: # sub institutional_photos
340: #
341: # Called when automated enrollment manager is used to update student photos.
342: #
343: # Incoming data: six arguments
344: # (a) $dom (domain)
345: # (b) $crs (LONCAPA course number)
346: # (c) $affiliates: a reference to a hash with the keys set to the
347: # institutional course IDs for the course.
348: # (d) $result: a reference to a hash which will return usernames
349: # of students (& separated) in following categories (the keys):
350: # new, update, missing, same, deleted, noid, nouser. The list
351: # includes those students for whom the result of the modification
352: # process was either addition of a new photo. update of an
353: # existing photo, photo was found to be missing from institution's
354: # data store, photo used is same as before, or photo was
355: # deleted from storage on LON-CAPA server housing student's
356: # information, no student ID was available.
357:
358: # (e) $action: the type of action needed. (e.g., update, delete);
359: # (f) $students: a reference to a hash with the keys set to student
360: # usernames and domains in the form username:domain, and values set
361: # to the studentID, if action is required for specific students.
362: #
363: # returns 1 parameter: 'ok' if no processing errors.
364: # other course or student specific values can be stored as values
365: # in the appropriate referenced hashes.
366: ###############################
367:
368: sub institutional_photos {
369: my ($dom,$crs,$affiliates,$result,$action,$students) = @_;
370: my $outcome = 'ok';
371: return $outcome;
372: }
373:
374: ###############################
375: # sub photo_permission
376: #
377: # Incoming data: three arguments
378: # (a) $dom (domain)
379: # (b) $perm_reqd: a reference to a a scalar that is either 'yes'
380: # if a course owner must indicate acceptance of conditions of use,
381: # 'no' otherwise.
382: # (c) $conditions: the text of the conditions of use.
383: #
384: # returns 1 parameter: 'ok' if no processing errors.
385: # $$perm_reqd is set to 'yes' or 'no'
386: # $$agreement is set to conditions of use - plain text string
387: # which will be displayed in a textarea in a web form.
388: ###############################
389:
390: sub photo_permission {
391: my ($dom,$perm_reqd,$conditions) = @_;
392: $$perm_reqd = 'no';
393: $$conditions = '';
394: my $outcome = 'ok';
395: return $outcome;
396: }
397:
398:
399: ###############################
400: # sub manager_photo_update
401: #
402: # Incoming data: one argument
403: # (a) $dom (domain)
404: #
405: # returns 2 parameters: update (0 or 1), and comment.
406: # Called by automated enrollment manager, to determine
407: # whether "Update Student photos" button will be available,
408: # and if so, the message (plain text string) that will be displayed
409: # with the button.
410: ###############################
411:
412: sub manager_photo_update {
413: my ($dom) = @_;
414: my $update = 0;
415: my $comment = '';
416: return ($update,$comment);
417: }
418:
419: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>