Annotation of modules/gci/localenroll.pm, revision 1.2

1.1       gci         1: # functions to glue school database system into Lon-CAPA for 
                      2: # automated enrollment
1.2     ! gci         3: # $Id: localenroll.pm,v 1.1 2010/11/16 03:12:39 gci Exp $
1.1       gci         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: 
                     28: =pod
                     29: 
                     30: =head1 NAME
                     31: 
                     32: localenroll
                     33: 
                     34: =head1 SYNOPSIS
                     35: 
                     36: This is part of the LearningOnline Network with CAPA project
                     37: described at http://www.lon-capa.org.
                     38: 
                     39: 
                     40: =head1 NOTABLE SUBROUTINES
                     41: 
                     42: =over
                     43: 
                     44: =cut
                     45: 
                     46: package localenroll;
                     47: 
                     48: use strict;
                     49: 
                     50: =pod
                     51:  
                     52: =item run()
                     53:  set this to return 1 if you want the auto enrollment to run
                     54: 
                     55:  Beginning with LON-CAPA version 2.4, use of this routine is
                     56:  deprecated.  Whether or not Autoenroll.pl should run is set
                     57:  by the Domain Coordinator via "Set domain configuration",
                     58:  provided in the Domain Management section of the Main menu. 
                     59: 
                     60: =cut
                     61: 
                     62: sub run() {
                     63:     my $dom = shift;
                     64:     return 0;
                     65: }
                     66: 
                     67: 
                     68: =pod
                     69: 
                     70: =item fetch_enrollment()
                     71: 
                     72:  connects to the institutional classlist data source,
                     73:  reads classlist data and stores in an XML file
                     74:  in /home/httpd/perl/tmp/
                     75: 
                     76:  classlist files are named as follows:
                     77: 
                     78:  DOMAIN_COURSE_INSTITUTIONALCODE_classlist.xml
                     79: 
                     80:  e.g., msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
                     81:  where DOMAIN = msu  COURSE = 43551dedcd43febmsul1 
                     82:  INSTITUTIONALCODE = fs03nop590001 
                     83:  (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
                     84:  department name, 590 = course number, 001 = section number.)
                     85: 
                     86:  fetch_enrollment requires three arguments -
                     87:  $dom - DOMAIN e.g., msu
                     88:  $affiliatesref - a reference to a hash of arrays that contains LON-CAPA 
                     89:  courses that are to be updated as keys, and institutional coursecodes 
                     90:  contributing enrollment to that LON-CAPA course as elements in each array.
                     91:  $replyref - a reference to a hash that contains LON-CAPA courses
                     92:  that are to be updated as keys, and the total enrollment count in all 
                     93:  affiliated sections, as determined from institutional data as hash elements. 
                     94: 
                     95:  As an example, if fetch_enrollment is called to retrieve institutional
                     96:  classlists for a single LON-CAPA course - 43551dedcd43febmsul1 which 
                     97:  corresponds to fs03nop590, sections 001, 601 and 602 , and the course
                     98:  also accommodates enrollment from a crosslisted course in the ost
                     99:  department - fs03ost580002:
                    100: 
                    101:  the affiliatesref would be a reference to %affiliates which would be:
                    102: 
                    103:  @{$affiliates{'43551dedcd43febmsul1'}} =
                    104:    ("fs03nop590001","fs03nop590601","fs03nop590602","fs03ost580002");
                    105: 
                    106:  fetch_enrollment would create four files in /home/httpd/perl/tmp/.
                    107:  msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
                    108:  msu_43551dedcd43febmsul1_fs03nop590601_classlist.xml
                    109:  msu_43551dedcd43febmsul1_fs03nop590602_classlist.xml
                    110:  msu_43551dedcd43febmsul1_fs03ost580002_classlist.xml
                    111: 
                    112:  In each file, student data would be stored in the following format
                    113:  
                    114:  <student username="smith">
                    115:   <autharg>MSU.EDU</autharg>
                    116:   <authtype>krb4</authtype>
                    117:   <email>smith@msu.edu</email>
                    118:   <enddate></enddate>
                    119:   <firstname>John</firstname>
                    120:   <generation>II</generation>
                    121:   <groupID>fs03nop590001</groupID>
                    122:   <lastname>Smith</lastname>
                    123:   <middlename>D</middlename>
                    124:   <startdate></startdate>
                    125:   <studentID>A12345678</studentID>
                    126:  </student>
                    127:  
                    128:  with the following at the top of the file
                    129: <?xml version="1.0" encoding="UTF-8"?>
                    130: <!DOCTYPE text>
                    131: <students>
                    132: 
                    133:  (all comment - s removed)
                    134: 
                    135:  and a closing:
                    136: </students>
                    137: 
                    138:  The <startdate> and the <enddate> are the activation date and expiration date
                    139:  for this student's role. If they are absent, then the default access start and
                    140:  default access end dates are used. The default access dates can be set when 
                    141:  the course is created, and can be modified using the Automated Enrollment
                    142:  Manager, or via the 'Upload a class list','Enroll a single student' or 
                    143:  'Modify student data' utilities in the Enrollment Manager, by checking the 
                    144:  'make these dates the default for future enrollment' checkbox. If no default 
                    145:  dates have been set, then the tudent role will be active immediately, and will 
                    146:  remain active until the role is explicitly expired using ENRL -> Drop students. 
                    147:  If dates are to included in the XML file, they should be in the format
                    148:  YYYY:MM:DD:HH:MM:SS (: separators required).
                    149: 
                    150:  If there were 10 students in fs03nop590001, 5 students in fs03nop59o601, 
                    151:  8 students in fs03nop590602, and 2 students in fs03ost580002,
                    152:  then $$reply{'43551dedcd43febmsul1'} = 25
                    153: 
                    154:  The purpose of the %reply hash is to detect cases where the institutional 
                    155:  enrollment is 0 (most likely due to a problem with the data source).
                    156:  In such a case, the LON-CAPA course roster is left unchanged (i.e., no
                    157:  students are expired, even if automated drops is enabled.
                    158:  
                    159:  fetch_enrollment should return a 0 or 1, depending on whether a connection
                    160:  could be established to the institutional data source.
                    161:  0 is returned if no connection could be made.
                    162:  1 is returned if connection was successful
                    163: 
                    164:  A return of 1 is required for the calling modules to perform LON-CAPA
                    165:  roster changes based on the contents of the XML classlist file(s), e,g,,
                    166:  msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
                    167: 
                    168:  XML classlist files are temporary. They are deleted after the enrollment 
                    169:  update process in the calling module is complete.
                    170: 
                    171: 
                    172: =cut
                    173: 
                    174: sub fetch_enrollment {
                    175:     my ($dom,$affiliatesref,$replyref) = @_;
                    176:     foreach my $crs (sort keys %{$affiliatesref}) {
                    177:         $$replyref{$crs} = 0;
                    178:     }
                    179:     my $okflag = 0;
                    180:     return $okflag;
                    181: }
                    182: 
                    183: =pod
                    184: 
                    185: =item get_sections()
                    186: 
                    187:  This is called by the Automated Enrollment Manager interface
                    188:  (lonpopulate.pm) to create an array of valid sections for 
                    189:  a specific institutional coursecode.
                    190:  e.g., for MSU coursecode: fs03nop590
                    191:  ("001","601","602") would be returned
                    192: 
                    193:  If the array returned contains at least one element, then 
                    194:  the interface offerred to the course coordinator, lists
                    195:  official sections and provides a checkbox to use to
                    196:  select enrollment in the LON-CAPA course from each official section.  
                    197: 
                    198:  get_sections takes two arguments - (a) the institutional coursecode
                    199:  (in the MSU case this is a concatenation of semester code, department
                    200:  and course number), and (b) the LON-CAPA domain that contains the course. 
                    201:  
                    202:  If there is no access to official course sections at your institution,
                    203:  then an empty array is returned, and the Automated Enrollment Manager
                    204:  interface will allow the course coordinator to enter section numbers
                    205:  in text boxes.
                    206:  
                    207: 
                    208: 
                    209: =cut
                    210: 
                    211: sub get_sections {
                    212:     my ($coursecode,$dom) = @_;
                    213:     my @secs = ();
                    214:     return @secs;
                    215: }
                    216: 
                    217: =pod
                    218: 
                    219: =item new_course()
                    220: 
                    221:  This is called by loncreatecourse.pm and 
                    222:  lonpopulate.pm to record that fact that a new course section
                    223:  has been added to LON-CAPA that requires access to institutional data
                    224:  At MSU, this is required, as institutional classlists can only made
                    225:  available to faculty who are officially assigned to a course.
                    226:  
                    227:  The new_course subroutine is used to check that the course owner
                    228:  of the LON-CAPA course is permitted to access the institutional
                    229:  classlist for any course sections and crosslisted classes that
                    230:  the course coordinator wishes to have affiliated with the course.
                    231:  
                    232:  If access is permitted, then 'ok' is returned.
                    233:  The course section or crosslisted course will only be added to the list of
                    234:  affiliates if 'ok' is returned.
                    235: 
                    236:  new_course takes three arguments -
                    237:  (a) the institutional courseID (in the MSU case this is a concatenation of 
                    238:  semester code, department code, course number, and section number
                    239:  e.g., fs03nop590001).
                    240:  (b) the course owner. This is the LON-CAPA username and domain of the course 
                    241:  coordinator assigned to the course when it is first created, in the form
                    242:  username:domain
                    243:  (c) the LON-CAPA domain that contains the course
                    244: 
                    245: =cut
                    246: 
                    247: sub new_course  {
                    248:     my ($course_id,$owner,$dom) = @_;
                    249:     my $outcome = 'ok';
                    250:     return $outcome;
                    251: }
                    252: 
                    253: =pod
                    254: 
                    255: =item validate_courseID()
                    256: 
                    257:  This is called whenever a new course section or crosslisted course
                    258:  is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
                    259:  and the Automated Enrollment Manager in lonpopulate.pm).
                    260:  A check is made that the courseID that the course coordinator wishes
                    261:  to affiliate with the course is valid according to the institutional
                    262:  schedule of official classes 
                    263: 
                    264:  A valid courseID is confirmed by returning 'ok'
                    265: 
                    266:  validate_courseID takes two arguments -
                    267:  (a) the institutional courseID (in the MSU case this is a concatenation of
                    268:  semester code, department code, course number, and section number
                    269:  e.g., fs03nop590001).
                    270:  (b) the LON-CAPA domain that contains the course
                    271: 
                    272: =cut  
                    273: 
                    274: sub validate_courseID {
                    275:     my ($course_id,$dom) = @_;
                    276:     my $outcome = 'ok';
                    277:     return $outcome;   
                    278: }
                    279: 
                    280: =pod
                    281: 
                    282: =item validate_instcode()
                    283: 
                    284: This is called when a request is being made for an official course.
                    285: A check is made that the institutional code for which a course is
                    286: is being requested is valid according to the institutional
                    287: schedule of official classes.
                    288: 
                    289: If the username of the course owner is provided, a more restrictive
                    290: test is used, namely that the requestor is listed as instructor of
                    291: record for the course in the institution's course schedule/database.
                    292: 
                    293: validate_instcode takes three arguments -
                    294:  (a) the LON-CAPA domain that will contain the course
                    295:  (b) the institutional code (in the MSU case this is a concatenation of
                    296:  semester code, department code, and course number, e.g., fs03nop590.
                    297:  (c) an optional institutional username for the course owner.
                    298: 
                    299: An array is returned containing (a) the result of the check for a valid 
                    300: instcode, and (b) an (optional) course description.   
                    301: A valid instcode is confirmed by returning 'valid'.
                    302: If no course description is available, '' should be set as
                    303: the value of the second item in the returned array.
                    304: 
                    305: =cut
                    306: 
                    307: sub validate_instcode {
                    308:     my ($dom,$instcode,$owner) = @_;
                    309:     my $outcome = '';
                    310:     my $description = '';
                    311:     return ($outcome,$description);
                    312: }
                    313: 
                    314: =pod
                    315: 
                    316: =item validate_crsreq()
                    317: 
                    318: This is used to check whether a course request should be processed
                    319: automatically, or held in a queue pending administrative action at
                    320: the institution.
                    321: 
                    322: Course requests will trigger this check if the process type has been set 
                    323: to 'validate' for the course type (official, unofficial or community) and
                    324: the requestor's affiliation.  Whether "validate" is an available option
                    325: in the Domain Configuration menu is controlled by auto_courserequest_checks(). 
                    326: One scenario is where the request is for an official course, in which case
                    327: a check could be made that the requestor is listed as instructor of 
                    328: record for the course in the institution's course schedule/database.
                    329: 
                    330: Other scenarios are possible, and the routine can be customized according
                    331: to whatever rules a domain wishes to implement to run validations against
                    332: given the data passed in to the routine.
                    333: 
                    334: validate_crsreq takes six arguments -
                    335:  (a) the LON-CAPA domain that will contain the course.
                    336:  (b) the username:domain for the course owner.
                    337:  (c) the course type (official, unofficial or community)
                    338:  (d) a comma-separated list of institutional affiliations of 
                    339:      the course owner.
                    340:  (e) the institutional code (in the MSU case this is a concatenation of
                    341:  semester code, department code, and course number, e.g., fs03nop590.
                    342:  (f) a comma-separated list of institutional sections included in
                    343:      the course request (only applicable to official courses).
                    344: 
                    345: A valid courserequest is confirmed by returning 'process'.
                    346: The following can be returned: process, rejected, pending, approval or error (with error condition - no :), followed by a : and then an optional message. 
                    347: 
                    348: (a) process  - the requestor is the recorded instructor - create the course
                    349: (b) rejected - the requestor should never be requesting this course, reject the
                    350:     request permanently
                    351: (c) pending - the requestor is not the recorded instructor, but could
                    352:     become so after administrative action at the institution. Put the
                    353:     request in a queue and check localenroll:validate_instcode()
                    354:     periodically until the status changes to "valid".
                    355: (d) approval - the request will be held pending review by a Domain Coordinator.
                    356: (e) error (followed by the error condition).
                    357: 
                    358: =cut
                    359: 
                    360: sub validate_crsreq {
                    361:     my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist) = @_;
                    362:     my $outcome = 'approval';
                    363:     return $outcome;
                    364: }
                    365: 
                    366: =pod 
                    367: 
                    368: =item crsreq_checks()
                    369: 
                    370: This is used to determine whether the "validate" option should appear in the
                    371: possible choices for course request processing in the Domain Configuration 
                    372: menu for Course Requests. Ultimately it is called by domainprefs.pm (via: 
                    373: lonnet -> lond -> localenroll.pm) The domain configuration menu includes 
                    374: a table where columns are course type (official, unofficial or community) 
                    375: and rows are institutional affiliations (e.g., Faculty, Staff, Student etc.).
                    376: 
                    377: crsreq_checks() takes three arguments: $dom, $reqtyes, $validations.
                    378: $dom - the domain for which validation options are needed.
                    379: $reqtypes - ref to an ARRAY of course types (i.e., official, unofficial and community.
                    380: $validations - ref to a hash of a hash which will determine whether "validate"
                    381: will be one of the possible choices for each course type (outer hash key),
                    382: and institutional type (inner hash key).
                    383: 
                    384: For example to allow validate to be a choice for official classes for Faculty,
                    385: req_checks would include:
                    386: 
                    387: $validations{'official'}{'Faculty'} = 1;
                    388: 
                    389: This routine is closely tied to validate_crsreq(). "Validate" should not be
                    390: a possible choice in the domain configuration menu for a particular course
                    391: type/institutional affiliation, unless a corresponding validation code has
                    392: been implemented in validate_crsreq().
                    393: 
                    394: For example at MSU, official courses requested by Faculty will be validated
                    395: against the official schedule of classes to check that the requestor is one
                    396: of the instructors of record for the course.  In this case validate_crsreq()
                    397: includes a call to validate_instcode().
                    398: 
                    399: =cut
                    400: 
                    401: sub crsreq_checks {
                    402:     my ($dom,$reqtypes,$validations) = @_;
                    403:     if ((ref($reqtypes) eq 'ARRAY') && (ref($validations) eq 'HASH')) {
                    404:         my (%usertypes,@order);
                    405:         if (&inst_usertypes($dom,\%usertypes,\@order) eq 'ok') {
                    406:             foreach my $type (@{$reqtypes}) {
                    407:                 foreach my $inst_type (@order) {
                    408:                     $validations->{$type}{$inst_type} = 0;
                    409:                 }
                    410:             }
                    411:         }
                    412:     }
                    413:     return 'ok';
                    414: }
                    415: 
                    416: =pod
                    417: 
                    418: =item create_password()
                    419: 
                    420:  This is called when the authentication method set for the automated 
                    421:  enrollment process when enrolling new users in the domain is "localauth".
                    422:  This could be signalled for the specific user by the value of localauth
                    423:  for the <authtype> tag from the classlist.xml files, or if this is blank,
                    424:  the default authtype, set by the domain coordinator when creating the course
                    425:  with loncreatecourse.pm.
                    426:   
                    427:  create_password takes three arguments -
                    428:  (a) $authparam - the value of <autharg> from the classlist.xml files,
                    429:  or if this blank, the default autharg, set by the domain coordinator when 
                    430:  creating the course with loncreatecourse.pm
                    431:  (b) $dom - the domain of the new user.
                    432:  (c) $username - the username of the new user (currently not actually used)
                    433: 
                    434:  Four values are returned:
                    435:  (a) the value of $authparam - which might have been changed
                    436:  (b) a flag to indicate whether a password had been created
                    437:  0 means no password created
                    438:  1 means password created.  In this case the calling module - Enrollment.pm
                    439:  will send the LON-CAPA username and password to the new user's e-mail
                    440:  (if one was provided), or to the course owner (if one was not provided and
                    441:  the new user was created by the automated process), or to the active
                    442:  course coordinator (if the new user was created using the 'update roster
                    443:  now' interface included in the Automated Enrollment Manager).  
                    444:  (c) a flag to indicate that the authentication method is correct - 'ok'.
                    445:  If $authchk is not set to 'ok' then account creation and enrollment of the 
                    446:  new user will not occur.
                    447:  (d) if a password was created it can be sent along.  This is the password 
                    448:  which will be included in the e-mail sent to the new user, or made available    
                    449:  to the course owner/course coordinator if no e-mail address is provided. If
                    450:  you do not wish to send a password, but want to give instructions on obtaining
                    451:  one, you could set $newpasswd as those instructions. (e.g.,
                    452:  $newpasswd = '(Please visit room 212, ACNS Bldg. to obtain your password)';
                    453:  The value of $newpasswd is NOT written in the user's LON-CAPA passwd file in
                    454:  /home/httpd/lonUsers/$dom/a/b/c/abcuser/passwd, which in the case of a user
                    455:  employing localauth will contain 'localauth:$authparam'.  If you need to include
                    456:  a parameter in the user's passwd file, you should return it as $authparam,
                    457:  i.e., the first of the variables returned by create_password().             
                    458: 
                    459: 
                    460: =cut 
                    461: 
                    462: sub create_password {
                    463:     my ($authparam,$dom,$username) = @_;
                    464:     my $authchk = 'ok';
                    465:     my $newpasswd = '';
                    466:     my $create_passwd = 0;
                    467:     return ($authparam,$create_passwd,$authchk,$newpasswd);
                    468: }
                    469: 
                    470: =pod
                    471: 
                    472: =item instcode_format()
                    473: 
                    474:  Split coursecodes into constituent parts.   
                    475:  e.g., INSTITUTIONALCODE = fs03nop590, LON-CAPA COURSEID: 43551dedcd43febmsul1
                    476:  (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
                    477:  department name, 590 = course number)
                    478: 
                    479:  Incoming data:
                    480:  $dom (domain)
                    481:  $$instcodes{'43551dedcd43febmsul1'} = 'fs03nop590' (hash of courseIDs)
                    482:  
                    483:  fs03nop590 would be split as follows
                    484:  @{$codetitles} = ("year","semester","department","number")
                    485:  $$codes{'year'} = '2003'
                    486:  $$codes{'semester'} = 'Fall'
                    487:  $$codes{'department'} = 'nop'
                    488:  $$codes{'number'} = '590'
                    489: 
                    490:  requires six arguments:
                    491:  domain ($dom)
                    492:  reference to hash of institutional course IDs ($instcodes)  
                    493:  reference to hash of codes ($codes)
                    494:  reference to array of titles ($codetitles)
                    495:  reference to hash of abbreviations used in categories
                    496:  reference to hash of arrays specifying sort order used in category titles   
                    497: 
                    498:  e.g.,     %{$$cat_titles{'Semester'}} = (
                    499:                    fs => 'Fall',
                    500:                    ss => 'Spring',
                    501:                    us => 'Summer');
                    502: 
                    503:  e.g., @{$$cat_order{'Semester'}} = ('ss','us','fs'); 
                    504:  returns 1 parameter: 'ok' if no processing errors. 
                    505: 
                    506:  Detailed help:
                    507:  http://yourloncapaserver/adm/help/Institutional_Integration_Course_Codes.hlp
                    508: 
                    509: =cut
                    510: 
                    511: 
                    512: sub instcode_format () {
                    513:     my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
                    514:     my $outcome = 'ok';
                    515:     return $outcome;
                    516: }
                    517: 
                    518: =pod
                    519: 
                    520: =item possible_instcodes()
                    521: 
                    522: Gather acceptable values for institutional categories to use in course creation request form for official courses.
                    523: 
                    524:  requires five arguments:
                    525: 
                    526:  domain ($dom)
                    527:  reference to array of titles ($codetitles)
                    528:  reference to hash of abbreviations used in categories ($cat_titles).
                    529:  reference to hash of arrays specifying sort order used in 
                    530:            category titles ($cat_order).
                    531:  reference to array which will contain order of component parts used 
                    532:            in institutional code ($code_order).
                    533: 
                    534:  e.g., 
                    535:  @{$codetitles} = ('Year','Semester',"Department','Number');
                    536: 
                    537:  %{$$cat_titles{'Semester'}} = (
                    538:                    fs => 'Fall',
                    539:                    ss => 'Spring',
                    540:                    us => 'Summer');
                    541: 
                    542:  @{$$cat_order{'Semester'}} = ('ss','us','fs');
                    543:  @{$code_order} = ('Semester','Year','Department','Number');
                    544: 
                    545:  returns 1 parameter: 'ok' if no processing errors.
                    546: 
                    547: =cut
                    548: 
                    549: sub possible_instcodes {
                    550:     my ($dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_;
                    551:     @{$codetitles} = ();
                    552:     %{$$cat_titles{'Semester'}} = ();
                    553:     @{$$cat_order{'Semester'}} = ('ss','us','fs');
                    554:     @{$code_order} = ();
                    555:     return 'ok';
                    556: }
                    557: 
                    558: 
                    559: =pod
                    560: 
                    561: =item institutional_photos()
                    562: 
                    563:  Called when automated enrollment manager is used to update student photos.
                    564: 
                    565:  Incoming data: six arguments
                    566:  (a) $dom (domain)
                    567:  (b) $crs (LONCAPA course number)
                    568:  (c) $affiliates: a reference to a hash with the keys set to the 
                    569:  institutional course IDs for the course.
                    570:  (d) $result: a reference to a hash which will return usernames  
                    571:      of students (& separated) in following categories (the keys):
                    572:      new, update, missing, same, deleted, noid, nouser. The list 
                    573:      includes those students for whom the result of the modification 
                    574:      process was either addition of a new photo. update of an
                    575:      existing photo, photo was found to be missing from institution's
                    576:      data store, photo used is same as before, or photo was 
                    577:      deleted from storage on LON-CAPA server housing student's
                    578:      information, no student/employee ID was available. 
                    579:                
                    580:  (e) $action: the type of action needed. (e.g., update, delete);
                    581:  (f) $students: a reference to a hash with the keys set to student 
                    582:  usernames and domains in the form username:domain, and values set
                    583:  to the studentID, if action is required for specific students.  
                    584: 
                    585:  returns 1 parameter: 'ok' if no processing errors.
                    586:  other course or student specific values can be stored as values
                    587:  in the appropriate referenced hashes. 
                    588: 
                    589: =cut
                    590: 
                    591: sub institutional_photos {
                    592:     my ($dom,$crs,$affiliates,$result,$action,$students) = @_;
                    593:     my $outcome = 'ok';
                    594:     return $outcome;
                    595: }
                    596: 
                    597: =pod
                    598: 
                    599: =item photo_permission()
                    600: 
                    601:  Incoming data: three arguments
                    602:  (a) $dom (domain)
                    603:  (b) $perm_reqd: a reference to a a scalar that is either 'yes'
                    604:  if a course owner must indicate acceptance of conditions of use,
                    605:  'no' otherwise.
                    606:  (c) $conditions: the text of the conditions of use.
                    607:     
                    608:  returns 1 parameter: 'ok' if no processing errors.
                    609:  $$perm_reqd is set to 'yes' or 'no'
                    610:  $$agreement is set to conditions of use - plain text string
                    611:              which will be displayed in a textarea in a web form.
                    612: 
                    613: 
                    614: =cut
                    615: 
                    616: sub photo_permission {
                    617:    my ($dom,$perm_reqd,$conditions) = @_;
                    618:    $$perm_reqd = 'no';
                    619:    $$conditions = '';
                    620:    my $outcome = 'ok';
                    621:    return $outcome;
                    622: }
                    623: 
                    624: =pod
                    625: 
                    626: =item manager_photo_update()
                    627: 
                    628:  Incoming data: one argument
                    629:  (a) $dom (domain)
                    630: 
                    631:  returns 2 parameters: update (0 or 1), and comment.
                    632:  Called by automated enrollment manager, to determine 
                    633:  whether "Update Student photos" button will be available,
                    634:  and if so, the message (plain text string) that will be displayed
                    635:  with the button. 
                    636: 
                    637: 
                    638: =cut
                    639:                                                                                         
                    640: sub manager_photo_update {
                    641:     my ($dom) = @_;
                    642:     my $update = 0;
                    643:     my $comment = '';
                    644:     return ($update,$comment);
                    645: }
                    646: 
                    647: =pod
                    648: 
                    649: 
                    650: =item check_section()
                    651: 
                    652:  Incoming data: three arguments (+ fourth optional argument)
                    653:  (a) $class - institutional class id (coursecode concatanated with section) 
                    654:  (b) $owner - course owner (2.2 and later username:domain; pre-2.2 username;
                    655:                             2.6 and later - comma-separated list of 
                    656:                             username:domain for course owner and co-owners.)
                    657:  (c) $dom - domain of course
                    658:  (d) $dbh - optional database handle
                    659: 
                    660:  returns 1 parameter - $sectioncheck ('ok' or other value). 
                    661:  Verifies that at least one of the course owner (or co-owners) have access 
                    662:  to classlist for specific class according to institution's SIS
                    663:  'ok' if access available  
                    664: 
                    665: 
                    666: =cut
                    667: 
                    668: sub check_section {
                    669:     my ($class,$owner,$dom,$dbh) = @_;
                    670:     my $sectioncheck = 'ok';
                    671:     return $sectioncheck;
                    672: }
                    673: 
                    674: =pod
                    675: 
                    676: =item instcode_defaults()
                    677: 
                    678:  Incoming data: three arguments
                    679:  (a) $dom - domain
                    680:  (b) $defaults - reference to hash which will contain default regular
                    681:                  expression matches for different components of an 
                    682:                  institutional course code 
                    683:  (c) $code_order - reference to array which will contain order of 
                    684:                    component parts used in institutional code.  
                    685: 
                    686:  returns 1 parameter - ('ok' or other value).
                    687:  Used to construct a regular expression to be used when searching for
                    688:  courses based on fragments of an institutional code.
                    689:  $defaults contains defaults to use for each component, and code_order
                    690:  contains keys of hash in order in which they are to be concatenated.
                    691: 
                    692:  e.g., INSTITUTIONALCODE = fs03nop590
                    693:  (MSU's course naming scheme - fs  = semester, 03 = year, nop =
                    694:  department name, 590 = course number)
                    695: 
                    696:      %{$defaults} = (
                    697:         'Year' => '\d{2}',
                    698:         'Semester' => '^[sfu]s', 
                    699:         'Department' => '\w{2,3}',
                    700:         'Number' => '\d{3,4}\w?',
                    701:      );
                    702: 
                    703:      @{$code_order} = ('Semester','Year','Department','Number');
                    704: 
                    705:  Detailed help:
                    706:  http://yourloncapaserver/adm/help/Institutional_Integration_Course_Codes.hlp
                    707: 
                    708: =cut
                    709: 
                    710: sub instcode_defaults {
                    711:     my ($dom,$defaults,$code_order) = @_;
                    712:     return 'ok';
                    713: }
                    714: 
                    715: 
                    716: =pod
                    717: 
                    718: =item allusers_info()
                    719: 
                    720:  Incoming data: three arguments
                    721:  (a) $dom - domain
                    722:  (b) $instusers - reference to hash which will contain hashes, 
                    723:                  where keys will be usernames and value will be a 
                    724:                  hash of user information. Keys in the inner hash 
                    725:                  will be some or all of: lastname,firstname,
                    726:                  middlename, generation, id, inststatus - 
                    727:                  institutional status (e.g., faculty,staff,student)
                    728:                  Values are all scalars except inststatus,
                    729:                  which is an array.
                    730:  (c) $instids - reference to hash which will contain ID numbers. 
                    731:                 keys will be unique IDs (student or faculty/staff ID)
                    732:                 values will be either: scalar (username) or an array 
                    733:                 if a single ID matches multiple usernames.
                    734:  returns 1 parameter - 'ok' if no processing error, or other value 
                    735:                        if an error occurred.
                    736:  side effects - populates the $instusers and $instids refs to hashes.
                    737:                 with information for all users from all available 
                    738:                 institutional datafeeds.
                    739: 
                    740: 
                    741: =cut
                    742: 
                    743: sub allusers_info {
                    744:     my ($dom,$instusers,$instids) = @_;
                    745:     my $outcome = 'ok';
                    746:     return $outcome; 
                    747: }
                    748: 
                    749: =pod
                    750: 
                    751: =item get_userinfo()
                    752: 
                    753:  Incoming data: four required arguments and additional optional arguments
                    754:  Two modes of operation:
                    755:  (1) Retrieves institutional data for a single user either by username
                    756:      if $uname is included as second argument, or by ID if $id is 
                    757:      included as a third argument.  Either (b) or (c) must be provided.
                    758:      (g), (h) and (i) will be undefined.
                    759:  (2) Retrieves institutional user data from search of an institutional
                    760:      directory based on a search. (g) and (h) are required.
                    761:      (i) is optional. (b) and (c) will be undefined. 
                    762: 
                    763:  (a) $dom - domain
                    764:  (b) $uname - username of user
                    765:  (c) $id - student/faculty ID of user
                    766:  (d) $instusers - reference to hash which will contain info for user
                    767:                  as key = value; keys will be one or all of:
                    768:                  lastname,firstname,middlename,generation,id,inststatus -
                    769:                  institutional status (e.g., faculty,staff,student)
                    770:                  Values are all scalars except inststatus,
                    771:                  which is an array.
                    772:  (e) $instids - reference to hash which will contain ID numbers - 
                    773:                  keys will be unique IDs (student or faculty/staff ID)  
                    774:                  values will be either: scalar (username) or an array
                    775:                  if a single ID matches multiple usernames.
                    776:  (f) $types - optional reference to array which contains 
                    777:               institutional types to check.
                    778:  (g) $srchby - optional if $uname or $id defined, otherwise required.
                    779:                Allowed values include: 1. lastfirst, 2. last, 3. uname
                    780:                corresponding to searches by 1. lastname,firstname;
                    781:                2. lastname; 3. username
                    782:  (h) $srchterm - optional if $uname or $id defined, otherwise required
                    783:                 String to search for.
                    784:  (i) $srchtype - optional. Allowed values: contains, begins (defaults
                    785:                 to exact match otherwise).
                    786: 
                    787:  returns 1 parameter - 'ok' if no processing error, or other value 
                    788:                        if an error occurred.
                    789:  side effects - populates the $instusers and $instids refs to hashes.
                    790:                 with information for specified username, or specified
                    791:                 id, if fifth argument provided, from all available, or 
                    792:                 specified (e.g., faculty only) institutional datafeeds,
                    793:                 if sixth argument provided.
                    794: 
                    795:  WARNING: You need to set $outcome to 'ok' once you have customized
                    796:           this routine to communicate with an instititional 
                    797:           directory data source, otherwise institutional directory 
                    798:           searches will always be reported as being unavailable
                    799:           in domain $dom.
                    800: 
                    801: =cut
                    802: 
                    803: sub get_userinfo {
                    804:     my ($dom,$uname,$id,$instusers,$instids,$types,
                    805:         $srchby,$srchterm,$srchtype) = @_;
                    806:     my $outcome = 'unavailable';
                    807:     return $outcome;
                    808: }
                    809: 
                    810: =pod
                    811: 
                    812: =item inst_usertypes() 
                    813: 
                    814:  Incoming data: three arguments
                    815:  (a) $dom - domain
                    816:  (b) $usertypes - reference to hash which will contain 
                    817:                  key = value, where keys are institution 
                    818:                  affiliation types (e.g., Faculty, Student etc.)
                    819:                  and values are titles (e.g., Faculty/Academic Staff)
                    820:  (c) $order - reference to array which will contain the order in
                    821:               which institutional types should be shown
                    822:               when displaying data tables (e.g., default quotas    
                    823:               or updateable user fields (see domainprefs.pm) 
                    824:  returns 1 parameter - 'ok' if no processing error, or other value 
                    825:                         if an error occurred.
                    826: 
                    827: 
                    828: =cut
                    829: 
                    830: sub inst_usertypes {
                    831:     my ($dom,$usertypes,$order) = @_;
1.2     ! gci       832:     if ($dom =~ /^\w+ci$/) {
1.1       gci       833:         %{$usertypes} = (
                    834:                       Faculty => 'Faculty',
                    835:                       Postdoc => 'Postdoctoral Researcher',
                    836:                       Graduate => 'Graduate Student',
                    837:                       Undergraduate => 'Undergraduate',
                    838:                      );
                    839:         @{$order}=('Faculty','Postdoc','Graduate','Undergraduate');
1.2     ! gci       840:     } elsif ($dom =~ /^\w+citest$/) {
1.1       gci       841:         %{$usertypes} = (
                    842:                       Student => 'Student',
                    843:                         );
                    844:         @{$order}=('Student');
                    845:     }
                    846:     my $outcome = 'ok';
                    847:     return $outcome;
                    848: }
                    849: 
                    850: =pod
                    851: 
                    852: =item username_rules()
                    853: 
                    854:  Incoming data: three arguments 
                    855:  (a) $dom - domain
                    856:  (b) $ruleshash - reference to hash containing rules
                    857:                   (a hash of a hash)
                    858:                   keys of top level hash are short names  
                    859:                    (e.g., netid, noncredit) 
                    860:                   for each key, value is a hash
                    861:                       desc => long name for rule  
                    862:                       rule => description of rule
                    863:                       authtype => (krb5,krb4,int, or loc)
                    864:                                  authentication type for rule 
                    865:                       authparm => authentication parameter for rule
                    866:                       authparmfixed => 1 if authparm used when
                    867:                           creating user for rule must be authparm  
                    868:                       authmsg => Message to display describing 
                    869:                                  authentication to use for this rule
                    870: 
                    871:  (c) $rulesorder - reference to array containing rule names 
                    872:                    in order to be displayed
                    873: 
                    874: 
                    875:   returns 'ok' if no processing error.
                    876: 
                    877: =cut
                    878: 
                    879: sub username_rules {
                    880:     my ($dom,$ruleshash,$rulesorder) = @_;
                    881:     %{$ruleshash} = (
                    882:                   email => {
                    883:                               name     => 'E-mail address',
                    884:                               desc     => 'Valid e-mail address',
                    885:                               authtype => 'int',
                    886:                               authparm => '',
                    887:                               authparmfixed => '',
                    888:                               authmsg       => 'A new user with a username which is a valid e-mail address will log-in using the e-mail address as username, and the password they have chosen.',
                    889:                            },
                    890:                  );
                    891:     @{$rulesorder} = ('email');
                    892:     return 'ok';
                    893: }
                    894: 
                    895: =pod
                    896: 
                    897: =item id_rules()
                    898: 
                    899:  Incoming data: three arguments
                    900:  (a) $dom - domain
                    901:  (b) $ruleshash - reference to hash containing rules
                    902:                   (a hash of a hash)
                    903:                   keys of top level hash are short names
                    904:                    (e.g., netid, noncredit)
                    905:                   for each key, value is a hash
                    906:                       desc => long name for rule
                    907:                       rule => description of rule
                    908: 
                    909:  (c) $rulesorder - reference to array containing rule names
                    910:                    in order to be displayed
                    911: 
                    912:   returns 'ok' if no processing error.
                    913: 
                    914: =cut
                    915: 
                    916: sub id_rules {
                    917:     my ($dom,$ruleshash,$rulesorder) = @_;
                    918:     my $outcome;
                    919:     return $outcome;
                    920: }
                    921: 
                    922: =pod
                    923: 
                    924: =item selfcreate_rules()
                    925: 
                    926:  Incoming data: three arguments
                    927:  (a) $dom - domain
                    928:  (b) $ruleshash - reference to hash containing rules
                    929:                   (a hash of a hash)
                    930:                   keys of top level hash are short names
                    931:                    (e.g., netid)
                    932:                   for each key, value is a hash
                    933:                       desc => long name for rule
                    934:                       rule => description of rule
                    935: 
                    936:  (c) $rulesorder - reference to array containing rule names
                    937:                    in order to be displayed
                    938: 
                    939:   returns 'ok' if no processing error.
                    940: 
                    941: 
                    942: =cut
                    943: 
                    944: sub selfcreate_rules {
                    945:     my ($dom,$ruleshash,$rulesorder) = @_;
                    946:     my $outcome;
                    947:     return $outcome;
                    948: }
                    949: 
                    950: =pod
                    951: 
                    952: =item username_check() 
                    953: 
                    954:  Incoming data: four arguments
                    955:  (a) $dom - domain (scalar) 
                    956:  (b) $uname - username to compare against rules (scalar)
                    957:  (c) $to_check (reference to array of rule names to check)
                    958:  (d) $resultshash (reference to hash of results)
                    959:                     hash of results for rule checked
                    960:                    - keys are rule names
                    961:                    - values are: 1 or 0 (for matched or unmatched) 
                    962: 
                    963:  returns 'ok' if no processing error.
                    964: 
                    965: 
                    966: =cut
                    967: 
                    968: sub username_check {
                    969:     my ($dom,$uname,$to_check,$resultshash) = @_;
                    970:     my $outcome;
                    971:     if (ref($to_check) eq 'ARRAY') {
                    972:         foreach my $item (@{$to_check}) {
                    973:             if ($item eq 'email') {
                    974:                 if ($uname =~ /^[^\@]+\@[^\@]+$/) {
                    975:                     $resultshash->{$item} = 1;
                    976:                 } else {
                    977:                     $resultshash->{$item} = 0;
                    978:                 }
                    979:             }
                    980:         }
                    981:         $outcome = 'ok';
                    982:     }
                    983:     return $outcome;
                    984: }
                    985: 
                    986: =pod
                    987: 
                    988: =item id_check()
                    989: 
                    990:  Incoming data: four arguments
                    991:  (a) $dom - domain (scalar)
                    992:  (b) $id - ID to compare against rules (scalar)
                    993:  (c) $to_check (reference to array of rule names to check)
                    994:  (d) $resultshash (reference to hash of results)
                    995:                     hash of results for rule checked
                    996:                    - keys are rule names
                    997:                    - values are: 1 or 0 (for matched or unmatched)
                    998: 
                    999:  returns 'ok' if no processing error.
                   1000: 
                   1001: 
                   1002: =cut
                   1003: 
                   1004: sub id_check {
                   1005:     my ($dom,$id,$to_check,$resultshash) = @_;
                   1006:     my $outcome;
                   1007:     return $outcome;
                   1008: }
                   1009: 
                   1010: =pod
                   1011: 
                   1012: =item selfcreate_check()
                   1013: 
                   1014:  Incoming data: four arguments
                   1015:  (a) $dom - domain (scalar)
                   1016:  (b) $selfcreatename - e-mail proposed as username (compare against rules - scalar)
                   1017:  (c) $to_check (reference to array of rule names to check)
                   1018:  (d) $resultshash (reference to hash of results)
                   1019:                    hash of results for rule checked
                   1020:                    - keys are rule names
                   1021:                    - values are: 1 or 0 (for matched or unmatched)
                   1022: 
                   1023:  returns 'ok' if no processing error.
                   1024: 
                   1025: 
                   1026: =cut
                   1027: 
                   1028: sub selfcreate_check {
                   1029:     my ($dom,$selfcreatename,$to_check,$resultshash) = @_;
                   1030:     my $outcome;
                   1031:     return $outcome;
                   1032: }
                   1033: 
                   1034: =pod
                   1035: 
                   1036: =item AUTOLOAD()
                   1037: 
                   1038:  Incoming data: none
                   1039:  Returns ''
                   1040: 
                   1041:  Prevents errors when undefined subroutines are called in this package
                   1042:  Will allow new routines added in the future to be called from lond etc.
                   1043:  without the need for customized versions of local*.pm packages to be
                   1044:  modified to include the new subroutines immediately.
                   1045: 
                   1046:  See "Programming Perl" 3rd ed. pp 296-298.   
                   1047: 
                   1048: =back
                   1049: 
                   1050: =cut
                   1051: 
                   1052: sub AUTOLOAD {
                   1053:     our $AUTOLOAD;
                   1054:     return '';
                   1055: }
                   1056: 
                   1057: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>