File:  [LON-CAPA] / loncom / enrollment / localenroll.pm
Revision 1.49: download - view: text, annotated - select for diffs
Wed Jun 25 23:55:31 2014 UTC (9 years, 11 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Update documentation for deprecated inst_usertypes() routine (DC domain
  configuration web GUI used instead in 2.11.0).

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

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