Annotation of loncom/enrollment/localenroll.pm, revision 1.43

1.5       albertel    1: # functions to glue school database system into Lon-CAPA for 
                      2: # automated enrollment
1.43    ! raeburn     3: # $Id: localenroll.pm,v 1.42 2011/05/23 19:11:41 raeburn Exp $
1.5       albertel    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: #
1.32      jms        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: 
1.4       raeburn    46: package localenroll;
                     47: 
                     48: use strict;
1.6       albertel   49: 
1.32      jms        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
1.6       albertel   61: 
1.9       raeburn    62: sub run() {
                     63:     my $dom = shift;
                     64:     return 0;
                     65: }
1.4       raeburn    66: 
1.32      jms        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
1.1       raeburn   173: 
                    174: sub fetch_enrollment {
1.7       matthew   175:     my ($dom,$affiliatesref,$replyref) = @_;
                    176:     foreach my $crs (sort keys %{$affiliatesref}) {
                    177:         $$replyref{$crs} = 0;
                    178:     }
                    179:     my $okflag = 0;
                    180:     return $okflag;
1.4       raeburn   181: }
                    182: 
1.32      jms       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
1.4       raeburn   210: 
                    211: sub get_sections {
1.9       raeburn   212:     my ($coursecode,$dom) = @_;
1.4       raeburn   213:     my @secs = ();
                    214:     return @secs;
1.1       raeburn   215: }
                    216: 
1.32      jms       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: 
1.41      raeburn   236:  new_course takes three required arguments -
1.32      jms       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: 
1.41      raeburn   245:  new_course also takes a fourth (optional) argument -
                    246:  (d) the course co-owners, as a comma-separated list of username:domain for
                    247:  any co-owners. 
                    248: 
1.32      jms       249: =cut
1.4       raeburn   250: 
                    251: sub new_course  {
1.41      raeburn   252:     my ($course_id,$owner,$dom,$coowners) = @_;
1.4       raeburn   253:     my $outcome = 'ok';
                    254:     return $outcome;
1.1       raeburn   255: }
                    256: 
1.32      jms       257: =pod
                    258: 
                    259: =item validate_courseID()
                    260: 
                    261:  This is called whenever a new course section or crosslisted course
                    262:  is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
                    263:  and the Automated Enrollment Manager in lonpopulate.pm).
                    264:  A check is made that the courseID that the course coordinator wishes
                    265:  to affiliate with the course is valid according to the institutional
                    266:  schedule of official classes 
                    267: 
                    268:  A valid courseID is confirmed by returning 'ok'
                    269: 
                    270:  validate_courseID takes two arguments -
                    271:  (a) the institutional courseID (in the MSU case this is a concatenation of
                    272:  semester code, department code, course number, and section number
                    273:  e.g., fs03nop590001).
                    274:  (b) the LON-CAPA domain that contains the course
                    275: 
                    276: =cut  
1.4       raeburn   277: 
                    278: sub validate_courseID {
1.9       raeburn   279:     my ($course_id,$dom) = @_;
1.4       raeburn   280:     my $outcome = 'ok';
                    281:     return $outcome;   
                    282: }
1.1       raeburn   283: 
1.32      jms       284: =pod
                    285: 
1.36      raeburn   286: =item validate_instcode()
                    287: 
                    288: This is called when a request is being made for an official course.
                    289: A check is made that the institutional code for which a course is
                    290: is being requested is valid according to the institutional
                    291: schedule of official classes.
                    292: 
                    293: If the username of the course owner is provided, a more restrictive
                    294: test is used, namely that the requestor is listed as instructor of
                    295: record for the course in the institution's course schedule/database.
                    296: 
1.38      raeburn   297: validate_instcode takes three arguments -
1.36      raeburn   298:  (a) the LON-CAPA domain that will contain the course
                    299:  (b) the institutional code (in the MSU case this is a concatenation of
                    300:  semester code, department code, and course number, e.g., fs03nop590.
                    301:  (c) an optional institutional username for the course owner.
                    302: 
1.39      raeburn   303: An array is returned containing (a) the result of the check for a valid 
                    304: instcode, and (b) an (optional) course description.   
                    305: A valid instcode is confirmed by returning 'valid'.
                    306: If no course description is available, '' should be set as
                    307: the value of the second item in the returned array.
                    308: 
1.36      raeburn   309: =cut
                    310: 
                    311: sub validate_instcode {
1.38      raeburn   312:     my ($dom,$instcode,$owner) = @_;
1.36      raeburn   313:     my $outcome = '';
1.39      raeburn   314:     my $description = '';
                    315:     return ($outcome,$description);
1.36      raeburn   316: }
                    317: 
                    318: =pod
                    319: 
1.38      raeburn   320: =item validate_crsreq()
                    321: 
                    322: This is used to check whether a course request should be processed
                    323: automatically, or held in a queue pending administrative action at
                    324: the institution.
                    325: 
                    326: Course requests will trigger this check if the process type has been set 
                    327: to 'validate' for the course type (official, unofficial or community) and
                    328: the requestor's affiliation.  Whether "validate" is an available option
                    329: in the Domain Configuration menu is controlled by auto_courserequest_checks(). 
                    330: One scenario is where the request is for an official course, in which case
                    331: a check could be made that the requestor is listed as instructor of 
                    332: record for the course in the institution's course schedule/database.
                    333: 
                    334: Other scenarios are possible, and the routine can be customized according
                    335: to whatever rules a domain wishes to implement to run validations against
                    336: given the data passed in to the routine.
                    337: 
                    338: validate_crsreq takes six arguments -
                    339:  (a) the LON-CAPA domain that will contain the course.
                    340:  (b) the username:domain for the course owner.
                    341:  (c) the course type (official, unofficial or community)
                    342:  (d) a comma-separated list of institutional affiliations of 
                    343:      the course owner.
                    344:  (e) the institutional code (in the MSU case this is a concatenation of
                    345:  semester code, department code, and course number, e.g., fs03nop590.
                    346:  (f) a comma-separated list of institutional sections included in
                    347:      the course request (only applicable to official courses).
                    348: 
                    349: A valid courserequest is confirmed by returning 'process'.
                    350: The following can be returned: process, rejected, pending, approval or error (with error condition - no :), followed by a : and then an optional message. 
                    351: 
                    352: (a) process  - the requestor is the recorded instructor - create the course
1.40      raeburn   353: (b) rejected - the requestor should never be requesting this course, reject the
1.38      raeburn   354:     request permanently
                    355: (c) pending - the requestor is not the recorded instructor, but could
                    356:     become so after administrative action at the institution. Put the
                    357:     request in a queue and check localenroll:validate_instcode()
                    358:     periodically until the status changes to "valid".
                    359: (d) approval - the request will be held pending review by a Domain Coordinator.
                    360: (e) error (followed by the error condition).
                    361: 
                    362: =cut
                    363: 
                    364: sub validate_crsreq {
                    365:     my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist) = @_;
                    366:     my $outcome = 'approval';
                    367:     return $outcome;
                    368: }
                    369: 
                    370: =pod 
                    371: 
                    372: =item crsreq_checks()
                    373: 
                    374: This is used to determine whether the "validate" option should appear in the
                    375: possible choices for course request processing in the Domain Configuration 
                    376: menu for Course Requests. Ultimately it is called by domainprefs.pm (via: 
                    377: lonnet -> lond -> localenroll.pm) The domain configuration menu includes 
                    378: a table where columns are course type (official, unofficial or community) 
                    379: and rows are institutional affiliations (e.g., Faculty, Staff, Student etc.).
                    380: 
1.42      raeburn   381: crsreq_checks() takes three arguments: $dom, $reqtypes, $validations.
1.38      raeburn   382: $dom - the domain for which validation options are needed.
                    383: $reqtypes - ref to an ARRAY of course types (i.e., official, unofficial and community.
                    384: $validations - ref to a hash of a hash which will determine whether "validate"
                    385: will be one of the possible choices for each course type (outer hash key),
                    386: and institutional type (inner hash key).
                    387: 
                    388: For example to allow validate to be a choice for official classes for Faculty,
                    389: req_checks would include:
                    390: 
                    391: $validations{'official'}{'Faculty'} = 1;
                    392: 
                    393: This routine is closely tied to validate_crsreq(). "Validate" should not be
                    394: a possible choice in the domain configuration menu for a particular course
                    395: type/institutional affiliation, unless a corresponding validation code has
                    396: been implemented in validate_crsreq().
                    397: 
                    398: For example at MSU, official courses requested by Faculty will be validated
                    399: against the official schedule of classes to check that the requestor is one
                    400: of the instructors of record for the course.  In this case validate_crsreq()
                    401: includes a call to validate_instcode().
                    402: 
                    403: =cut
                    404: 
                    405: sub crsreq_checks {
                    406:     my ($dom,$reqtypes,$validations) = @_;
                    407:     if ((ref($reqtypes) eq 'ARRAY') && (ref($validations) eq 'HASH')) {
                    408:         my (%usertypes,@order);
                    409:         if (&inst_usertypes($dom,\%usertypes,\@order) eq 'ok') {
                    410:             foreach my $type (@{$reqtypes}) {
                    411:                 foreach my $inst_type (@order) {
                    412:                     $validations->{$type}{$inst_type} = 0;
                    413:                 }
                    414:             }
                    415:         }
                    416:     }
                    417:     return 'ok';
                    418: }
                    419: 
                    420: =pod
                    421: 
1.32      jms       422: =item create_password()
                    423: 
                    424:  This is called when the authentication method set for the automated 
                    425:  enrollment process when enrolling new users in the domain is "localauth".
                    426:  This could be signalled for the specific user by the value of localauth
                    427:  for the <authtype> tag from the classlist.xml files, or if this is blank,
                    428:  the default authtype, set by the domain coordinator when creating the course
                    429:  with loncreatecourse.pm.
                    430:   
                    431:  create_password takes three arguments -
                    432:  (a) $authparam - the value of <autharg> from the classlist.xml files,
                    433:  or if this blank, the default autharg, set by the domain coordinator when 
                    434:  creating the course with loncreatecourse.pm
                    435:  (b) $dom - the domain of the new user.
                    436:  (c) $username - the username of the new user (currently not actually used)
                    437: 
                    438:  Four values are returned:
                    439:  (a) the value of $authparam - which might have been changed
                    440:  (b) a flag to indicate whether a password had been created
                    441:  0 means no password created
                    442:  1 means password created.  In this case the calling module - Enrollment.pm
                    443:  will send the LON-CAPA username and password to the new user's e-mail
                    444:  (if one was provided), or to the course owner (if one was not provided and
                    445:  the new user was created by the automated process), or to the active
                    446:  course coordinator (if the new user was created using the 'update roster
                    447:  now' interface included in the Automated Enrollment Manager).  
                    448:  (c) a flag to indicate that the authentication method is correct - 'ok'.
                    449:  If $authchk is not set to 'ok' then account creation and enrollment of the 
                    450:  new user will not occur.
                    451:  (d) if a password was created it can be sent along.  This is the password 
                    452:  which will be included in the e-mail sent to the new user, or made available    
                    453:  to the course owner/course coordinator if no e-mail address is provided. If
                    454:  you do not wish to send a password, but want to give instructions on obtaining
                    455:  one, you could set $newpasswd as those instructions. (e.g.,
                    456:  $newpasswd = '(Please visit room 212, ACNS Bldg. to obtain your password)';
                    457:  The value of $newpasswd is NOT written in the user's LON-CAPA passwd file in
                    458:  /home/httpd/lonUsers/$dom/a/b/c/abcuser/passwd, which in the case of a user
                    459:  employing localauth will contain 'localauth:$authparam'.  If you need to include
                    460:  a parameter in the user's passwd file, you should return it as $authparam,
                    461:  i.e., the first of the variables returned by create_password().             
                    462: 
                    463: 
                    464: =cut 
1.4       raeburn   465: 
                    466: sub create_password {
1.13      albertel  467:     my ($authparam,$dom,$username) = @_;
1.4       raeburn   468:     my $authchk = 'ok';
1.11      raeburn   469:     my $newpasswd = '';
1.4       raeburn   470:     my $create_passwd = 0;
1.11      raeburn   471:     return ($authparam,$create_passwd,$authchk,$newpasswd);
1.1       raeburn   472: }
                    473: 
1.32      jms       474: =pod
                    475: 
                    476: =item instcode_format()
                    477: 
                    478:  Split coursecodes into constituent parts.   
                    479:  e.g., INSTITUTIONALCODE = fs03nop590, LON-CAPA COURSEID: 43551dedcd43febmsul1
                    480:  (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
                    481:  department name, 590 = course number)
                    482: 
                    483:  Incoming data:
                    484:  $dom (domain)
                    485:  $$instcodes{'43551dedcd43febmsul1'} = 'fs03nop590' (hash of courseIDs)
                    486:  
                    487:  fs03nop590 would be split as follows
                    488:  @{$codetitles} = ("year","semester","department","number")
1.33      bisitz    489:  $$codes{'year'} = '2003'
1.32      jms       490:  $$codes{'semester'} = 'Fall'
                    491:  $$codes{'department'} = 'nop'
                    492:  $$codes{'number'} = '590'
                    493: 
                    494:  requires six arguments:
                    495:  domain ($dom)
                    496:  reference to hash of institutional course IDs ($instcodes)  
                    497:  reference to hash of codes ($codes)
                    498:  reference to array of titles ($codetitles)
                    499:  reference to hash of abbreviations used in categories
                    500:  reference to hash of arrays specifying sort order used in category titles   
                    501: 
                    502:  e.g.,     %{$$cat_titles{'Semester'}} = (
                    503:                    fs => 'Fall',
                    504:                    ss => 'Spring',
                    505:                    us => 'Summer');
                    506: 
                    507:  e.g., @{$$cat_order{'Semester'}} = ('ss','us','fs'); 
                    508:  returns 1 parameter: 'ok' if no processing errors. 
1.33      bisitz    509: 
                    510:  Detailed help:
                    511:  http://yourloncapaserver/adm/help/Institutional_Integration_Course_Codes.hlp
                    512: 
1.32      jms       513: =cut
                    514: 
1.10      raeburn   515: 
                    516: sub instcode_format () {
                    517:     my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
                    518:     my $outcome = 'ok';
                    519:     return $outcome;
                    520: }
                    521: 
1.35      raeburn   522: =pod
                    523: 
                    524: =item possible_instcodes()
                    525: 
                    526: Gather acceptable values for institutional categories to use in course creation request form for official courses.
                    527: 
1.40      raeburn   528:  requires five arguments:
                    529: 
1.35      raeburn   530:  domain ($dom)
                    531:  reference to array of titles ($codetitles)
                    532:  reference to hash of abbreviations used in categories ($cat_titles).
1.40      raeburn   533:  reference to hash of arrays specifying sort order used in 
                    534:            category titles ($cat_order).
                    535:  reference to array which will contain order of component parts used 
                    536:            in institutional code ($code_order).
1.35      raeburn   537: 
                    538:  e.g., 
1.40      raeburn   539:  @{$codetitles} = ('Year','Semester',"Department','Number');
1.35      raeburn   540: 
                    541:  %{$$cat_titles{'Semester'}} = (
                    542:                    fs => 'Fall',
                    543:                    ss => 'Spring',
                    544:                    us => 'Summer');
                    545: 
                    546:  @{$$cat_order{'Semester'}} = ('ss','us','fs');
1.40      raeburn   547:  @{$code_order} = ('Semester','Year','Department','Number');
1.35      raeburn   548: 
                    549:  returns 1 parameter: 'ok' if no processing errors.
                    550: 
                    551: =cut
                    552: 
                    553: sub possible_instcodes {
1.40      raeburn   554:     my ($dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_;
1.35      raeburn   555:     @{$codetitles} = ();
                    556:     %{$$cat_titles{'Semester'}} = ();
                    557:     @{$$cat_order{'Semester'}} = ('ss','us','fs');
1.40      raeburn   558:     @{$code_order} = ();
1.35      raeburn   559:     return 'ok';
                    560: }
                    561: 
                    562: 
1.32      jms       563: =pod
                    564: 
                    565: =item institutional_photos()
                    566: 
                    567:  Called when automated enrollment manager is used to update student photos.
                    568: 
                    569:  Incoming data: six arguments
                    570:  (a) $dom (domain)
                    571:  (b) $crs (LONCAPA course number)
                    572:  (c) $affiliates: a reference to a hash with the keys set to the 
                    573:  institutional course IDs for the course.
                    574:  (d) $result: a reference to a hash which will return usernames  
                    575:      of students (& separated) in following categories (the keys):
                    576:      new, update, missing, same, deleted, noid, nouser. The list 
                    577:      includes those students for whom the result of the modification 
                    578:      process was either addition of a new photo. update of an
                    579:      existing photo, photo was found to be missing from institution's
                    580:      data store, photo used is same as before, or photo was 
                    581:      deleted from storage on LON-CAPA server housing student's
1.34      weissno   582:      information, no student/employee ID was available. 
1.12      raeburn   583:                
1.32      jms       584:  (e) $action: the type of action needed. (e.g., update, delete);
                    585:  (f) $students: a reference to a hash with the keys set to student 
                    586:  usernames and domains in the form username:domain, and values set
                    587:  to the studentID, if action is required for specific students.  
                    588: 
                    589:  returns 1 parameter: 'ok' if no processing errors.
                    590:  other course or student specific values can be stored as values
                    591:  in the appropriate referenced hashes. 
                    592: 
                    593: =cut
1.12      raeburn   594: 
                    595: sub institutional_photos {
                    596:     my ($dom,$crs,$affiliates,$result,$action,$students) = @_;
                    597:     my $outcome = 'ok';
                    598:     return $outcome;
                    599: }
                    600: 
1.32      jms       601: =pod
                    602: 
                    603: =item photo_permission()
                    604: 
                    605:  Incoming data: three arguments
                    606:  (a) $dom (domain)
                    607:  (b) $perm_reqd: a reference to a a scalar that is either 'yes'
                    608:  if a course owner must indicate acceptance of conditions of use,
                    609:  'no' otherwise.
                    610:  (c) $conditions: the text of the conditions of use.
                    611:     
                    612:  returns 1 parameter: 'ok' if no processing errors.
                    613:  $$perm_reqd is set to 'yes' or 'no'
                    614:  $$agreement is set to conditions of use - plain text string
                    615:              which will be displayed in a textarea in a web form.
                    616: 
                    617: 
                    618: =cut
                    619: 
1.12      raeburn   620: sub photo_permission {
                    621:    my ($dom,$perm_reqd,$conditions) = @_;
                    622:    $$perm_reqd = 'no';
                    623:    $$conditions = '';
                    624:    my $outcome = 'ok';
                    625:    return $outcome;
                    626: }
                    627: 
1.32      jms       628: =pod
                    629: 
                    630: =item manager_photo_update()
                    631: 
                    632:  Incoming data: one argument
                    633:  (a) $dom (domain)
                    634: 
                    635:  returns 2 parameters: update (0 or 1), and comment.
                    636:  Called by automated enrollment manager, to determine 
                    637:  whether "Update Student photos" button will be available,
                    638:  and if so, the message (plain text string) that will be displayed
                    639:  with the button. 
1.12      raeburn   640: 
1.32      jms       641: 
                    642: =cut
1.12      raeburn   643:                                                                                         
                    644: sub manager_photo_update {
                    645:     my ($dom) = @_;
                    646:     my $update = 0;
                    647:     my $comment = '';
                    648:     return ($update,$comment);
                    649: }
                    650: 
1.32      jms       651: =pod
                    652: 
                    653: 
                    654: =item check_section()
                    655: 
                    656:  Incoming data: three arguments (+ fourth optional argument)
                    657:  (a) $class - institutional class id (coursecode concatanated with section) 
                    658:  (b) $owner - course owner (2.2 and later username:domain; pre-2.2 username;
                    659:                             2.6 and later - comma-separated list of 
                    660:                             username:domain for course owner and co-owners.)
                    661:  (c) $dom - domain of course
                    662:  (d) $dbh - optional database handle
                    663: 
                    664:  returns 1 parameter - $sectioncheck ('ok' or other value). 
                    665:  Verifies that at least one of the course owner (or co-owners) have access 
                    666:  to classlist for specific class according to institution's SIS
                    667:  'ok' if access available  
                    668: 
                    669: 
                    670: =cut
1.16      raeburn   671: 
                    672: sub check_section {
                    673:     my ($class,$owner,$dom,$dbh) = @_;
                    674:     my $sectioncheck = 'ok';
                    675:     return $sectioncheck;
                    676: }
                    677: 
1.32      jms       678: =pod
                    679: 
                    680: =item instcode_defaults()
                    681: 
                    682:  Incoming data: three arguments
                    683:  (a) $dom - domain
                    684:  (b) $defaults - reference to hash which will contain default regular
                    685:                  expression matches for different components of an 
                    686:                  institutional course code 
                    687:  (c) $code_order - reference to array which will contain order of 
                    688:                    component parts used in institutional code.  
                    689: 
                    690:  returns 1 parameter - ('ok' or other value).
                    691:  Used to construct a regular expression to be used when searching for
                    692:  courses based on fragments of an institutional code.
                    693:  $defaults contains defaults to use for each component, and code_order
                    694:  contains keys of hash in order in which they are to be concatenated.
                    695: 
                    696:  e.g., INSTITUTIONALCODE = fs03nop590
                    697:  (MSU's course naming scheme - fs  = semester, 03 = year, nop =
                    698:  department name, 590 = course number)
                    699: 
                    700:      %{$defaults} = (
                    701:         'Year' => '\d{2}',
                    702:         'Semester' => '^[sfu]s', 
                    703:         'Department' => '\w{2,3}',
                    704:         'Number' => '\d{3,4}\w?',
                    705:      );
                    706: 
                    707:      @{$code_order} = ('Semester','Year','Department','Number');
                    708: 
1.33      bisitz    709:  Detailed help:
                    710:  http://yourloncapaserver/adm/help/Institutional_Integration_Course_Codes.hlp
                    711: 
1.32      jms       712: =cut
1.17      raeburn   713: 
                    714: sub instcode_defaults {
                    715:     my ($dom,$defaults,$code_order) = @_;
                    716:     return 'ok';
                    717: }
                    718: 
1.32      jms       719: 
                    720: =pod
                    721: 
                    722: =item allusers_info()
                    723: 
                    724:  Incoming data: three arguments
                    725:  (a) $dom - domain
                    726:  (b) $instusers - reference to hash which will contain hashes, 
                    727:                  where keys will be usernames and value will be a 
                    728:                  hash of user information. Keys in the inner hash 
                    729:                  will be some or all of: lastname,firstname,
                    730:                  middlename, generation, id, inststatus - 
                    731:                  institutional status (e.g., faculty,staff,student)
                    732:                  Values are all scalars except inststatus,
                    733:                  which is an array.
                    734:  (c) $instids - reference to hash which will contain ID numbers. 
                    735:                 keys will be unique IDs (student or faculty/staff ID)
                    736:                 values will be either: scalar (username) or an array 
                    737:                 if a single ID matches multiple usernames.
1.43    ! raeburn   738:  (d) $lc_users - reference to hash containing LON-CAPA usernames in 
        !           739:                  in domain $dom, as keys. Needed if institutional
        !           740:                  data source only allows query by username.
1.32      jms       741:  returns 1 parameter - 'ok' if no processing error, or other value 
                    742:                        if an error occurred.
                    743:  side effects - populates the $instusers and $instids refs to hashes.
                    744:                 with information for all users from all available 
                    745:                 institutional datafeeds.
                    746: 
                    747: 
                    748: =cut
1.18      raeburn   749: 
                    750: sub allusers_info {
1.43    ! raeburn   751:     my ($dom,$instusers,$instids,$lc_users) = @_;
1.18      raeburn   752:     my $outcome = 'ok';
                    753:     return $outcome; 
                    754: }
                    755: 
1.32      jms       756: =pod
                    757: 
                    758: =item get_userinfo()
                    759: 
                    760:  Incoming data: four required arguments and additional optional arguments
                    761:  Two modes of operation:
                    762:  (1) Retrieves institutional data for a single user either by username
                    763:      if $uname is included as second argument, or by ID if $id is 
                    764:      included as a third argument.  Either (b) or (c) must be provided.
                    765:      (g), (h) and (i) will be undefined.
                    766:  (2) Retrieves institutional user data from search of an institutional
                    767:      directory based on a search. (g) and (h) are required.
                    768:      (i) is optional. (b) and (c) will be undefined. 
                    769: 
                    770:  (a) $dom - domain
                    771:  (b) $uname - username of user
                    772:  (c) $id - student/faculty ID of user
                    773:  (d) $instusers - reference to hash which will contain info for user
                    774:                  as key = value; keys will be one or all of:
                    775:                  lastname,firstname,middlename,generation,id,inststatus -
                    776:                  institutional status (e.g., faculty,staff,student)
                    777:                  Values are all scalars except inststatus,
                    778:                  which is an array.
                    779:  (e) $instids - reference to hash which will contain ID numbers - 
                    780:                  keys will be unique IDs (student or faculty/staff ID)  
                    781:                  values will be either: scalar (username) or an array
                    782:                  if a single ID matches multiple usernames.
                    783:  (f) $types - optional reference to array which contains 
                    784:               institutional types to check.
                    785:  (g) $srchby - optional if $uname or $id defined, otherwise required.
                    786:                Allowed values include: 1. lastfirst, 2. last, 3. uname
                    787:                corresponding to searches by 1. lastname,firstname;
                    788:                2. lastname; 3. username
                    789:  (h) $srchterm - optional if $uname or $id defined, otherwise required
                    790:                 String to search for.
                    791:  (i) $srchtype - optional. Allowed values: contains, begins (defaults
                    792:                 to exact match otherwise).
                    793: 
                    794:  returns 1 parameter - 'ok' if no processing error, or other value 
                    795:                        if an error occurred.
                    796:  side effects - populates the $instusers and $instids refs to hashes.
                    797:                 with information for specified username, or specified
                    798:                 id, if fifth argument provided, from all available, or 
                    799:                 specified (e.g., faculty only) institutional datafeeds,
                    800:                 if sixth argument provided.
                    801: 
                    802:  WARNING: You need to set $outcome to 'ok' once you have customized
                    803:           this routine to communicate with an instititional 
                    804:           directory data source, otherwise institutional directory 
                    805:           searches will always be reported as being unavailable
                    806:           in domain $dom.
                    807: 
                    808: =cut
1.18      raeburn   809: 
                    810: sub get_userinfo {
1.21      raeburn   811:     my ($dom,$uname,$id,$instusers,$instids,$types,
                    812:         $srchby,$srchterm,$srchtype) = @_;
1.24      raeburn   813:     my $outcome = 'unavailable';
1.18      raeburn   814:     return $outcome;
                    815: }
                    816: 
1.32      jms       817: =pod
                    818: 
                    819: =item inst_usertypes() 
                    820: 
                    821:  Incoming data: three arguments
                    822:  (a) $dom - domain
                    823:  (b) $usertypes - reference to hash which will contain 
                    824:                  key = value, where keys are institution 
                    825:                  affiliation types (e.g., Faculty, Student etc.)
                    826:                  and values are titles (e.g., Faculty/Academic Staff)
                    827:  (c) $order - reference to array which will contain the order in
                    828:               which institutional types should be shown
                    829:               when displaying data tables (e.g., default quotas    
                    830:               or updateable user fields (see domainprefs.pm) 
                    831:  returns 1 parameter - 'ok' if no processing error, or other value 
                    832:                         if an error occurred.
                    833: 
                    834: 
                    835: =cut
1.18      raeburn   836: 
                    837: sub inst_usertypes {
                    838:     my ($dom,$usertypes,$order) = @_;
1.20      raeburn   839:     @{$order} = ();
                    840:     %{$usertypes} = ();
1.18      raeburn   841:     my $outcome = 'ok';
                    842:     return $outcome;
                    843: }
1.17      raeburn   844: 
1.32      jms       845: =pod
                    846: 
                    847: =item username_rules()
                    848: 
                    849:  Incoming data: three arguments 
                    850:  (a) $dom - domain
                    851:  (b) $ruleshash - reference to hash containing rules
                    852:                   (a hash of a hash)
                    853:                   keys of top level hash are short names  
                    854:                    (e.g., netid, noncredit) 
                    855:                   for each key, value is a hash
                    856:                       desc => long name for rule  
                    857:                       rule => description of rule
                    858:                       authtype => (krb5,krb4,int, or loc)
                    859:                                  authentication type for rule 
                    860:                       authparm => authentication parameter for rule
                    861:                       authparmfixed => 1 if authparm used when
                    862:                           creating user for rule must be authparm  
                    863:                       authmsg => Message to display describing 
                    864:                                  authentication to use for this rule
                    865: 
                    866:  (c) $rulesorder - reference to array containing rule names 
                    867:                    in order to be displayed
                    868: 
                    869: 
                    870:   returns 'ok' if no processing error.
1.25      raeburn   871: 
1.32      jms       872: =cut
1.25      raeburn   873: 
                    874: sub username_rules {
                    875:     my ($dom,$ruleshash,$rulesorder) = @_;
                    876:     my $outcome;
                    877:     return $outcome;
                    878: }
                    879: 
1.32      jms       880: =pod
                    881: 
                    882: =item id_rules()
                    883: 
                    884:  Incoming data: three arguments
                    885:  (a) $dom - domain
                    886:  (b) $ruleshash - reference to hash containing rules
                    887:                   (a hash of a hash)
                    888:                   keys of top level hash are short names
                    889:                    (e.g., netid, noncredit)
                    890:                   for each key, value is a hash
                    891:                       desc => long name for rule
                    892:                       rule => description of rule
                    893: 
                    894:  (c) $rulesorder - reference to array containing rule names
                    895:                    in order to be displayed
                    896: 
                    897:   returns 'ok' if no processing error.
                    898: 
                    899: =cut
1.27      raeburn   900: 
1.30      raeburn   901: sub id_rules {
                    902:     my ($dom,$ruleshash,$rulesorder) = @_;
                    903:     my $outcome;
                    904:     return $outcome;
                    905: }
                    906: 
1.32      jms       907: =pod
                    908: 
                    909: =item selfcreate_rules()
                    910: 
                    911:  Incoming data: three arguments
                    912:  (a) $dom - domain
                    913:  (b) $ruleshash - reference to hash containing rules
                    914:                   (a hash of a hash)
                    915:                   keys of top level hash are short names
                    916:                    (e.g., netid)
                    917:                   for each key, value is a hash
                    918:                       desc => long name for rule
                    919:                       rule => description of rule
                    920: 
                    921:  (c) $rulesorder - reference to array containing rule names
                    922:                    in order to be displayed
                    923: 
                    924:   returns 'ok' if no processing error.
                    925: 
1.27      raeburn   926: 
1.32      jms       927: =cut
1.30      raeburn   928: 
1.31      raeburn   929: sub selfcreate_rules {
1.27      raeburn   930:     my ($dom,$ruleshash,$rulesorder) = @_;
                    931:     my $outcome;
                    932:     return $outcome;
                    933: }
                    934: 
1.32      jms       935: =pod
                    936: 
                    937: =item username_check() 
                    938: 
                    939:  Incoming data: four arguments
                    940:  (a) $dom - domain (scalar) 
                    941:  (b) $uname - username to compare against rules (scalar)
                    942:  (c) $to_check (reference to array of rule names to check)
                    943:  (d) $resultshash (reference to hash of results)
                    944:                     hash of results for rule checked
                    945:                    - keys are rule names
                    946:                    - values are: 1 or 0 (for matched or unmatched) 
                    947: 
                    948:  returns 'ok' if no processing error.
                    949: 
                    950: 
                    951: =cut
1.25      raeburn   952: 
                    953: sub username_check {
                    954:     my ($dom,$uname,$to_check,$resultshash) = @_;
                    955:     my $outcome;
                    956:     return $outcome; 
                    957: }
                    958: 
1.32      jms       959: =pod
                    960: 
                    961: =item id_check()
                    962: 
                    963:  Incoming data: four arguments
                    964:  (a) $dom - domain (scalar)
                    965:  (b) $id - ID to compare against rules (scalar)
                    966:  (c) $to_check (reference to array of rule names to check)
                    967:  (d) $resultshash (reference to hash of results)
                    968:                     hash of results for rule checked
                    969:                    - keys are rule names
                    970:                    - values are: 1 or 0 (for matched or unmatched)
                    971: 
                    972:  returns 'ok' if no processing error.
                    973: 
                    974: 
                    975: =cut
1.27      raeburn   976: 
                    977: sub id_check {
                    978:     my ($dom,$id,$to_check,$resultshash) = @_;
                    979:     my $outcome;
                    980:     return $outcome;
                    981: }
                    982: 
1.32      jms       983: =pod
                    984: 
                    985: =item selfcreate_check()
                    986: 
                    987:  Incoming data: four arguments
                    988:  (a) $dom - domain (scalar)
                    989:  (b) $selfcreatename - e-mail proposed as username (compare against rules - scalar)
                    990:  (c) $to_check (reference to array of rule names to check)
                    991:  (d) $resultshash (reference to hash of results)
                    992:                    hash of results for rule checked
                    993:                    - keys are rule names
                    994:                    - values are: 1 or 0 (for matched or unmatched)
                    995: 
                    996:  returns 'ok' if no processing error.
                    997: 
                    998: 
                    999: =cut
1.30      raeburn  1000: 
1.31      raeburn  1001: sub selfcreate_check {
                   1002:     my ($dom,$selfcreatename,$to_check,$resultshash) = @_;
1.30      raeburn  1003:     my $outcome;
                   1004:     return $outcome;
                   1005: }
                   1006: 
1.32      jms      1007: =pod
                   1008: 
                   1009: =item AUTOLOAD()
                   1010: 
                   1011:  Incoming data: none
                   1012:  Returns ''
                   1013: 
                   1014:  Prevents errors when undefined subroutines are called in this package
                   1015:  Will allow new routines added in the future to be called from lond etc.
                   1016:  without the need for customized versions of local*.pm packages to be
                   1017:  modified to include the new subroutines immediately.
                   1018: 
                   1019:  See "Programming Perl" 3rd ed. pp 296-298.   
                   1020: 
                   1021: =back
                   1022: 
                   1023: =cut
1.14      raeburn  1024: 
                   1025: sub AUTOLOAD {
                   1026:     our $AUTOLOAD;
                   1027:     return '';
                   1028: }
                   1029: 
1.1       raeburn  1030: 1;

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