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

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

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