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

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

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