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

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

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