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

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

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