File:  [LON-CAPA] / loncom / enrollment / localenroll.pm
Revision 1.47: download - view: text, annotated - select for diffs
Wed Apr 30 17:17:25 2014 UTC (10 years, 2 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Pass default start access date and default end access dates to
  localenroll::crsreq_updates() so they are available to course request
  validator.

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

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