File:  [LON-CAPA] / loncom / enrollment / localenroll.pm
Revision 1.16: download - view: text, annotated - select for diffs
Tue Aug 29 05:58:06 2006 UTC (17 years, 9 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
&check_section used to validate that a course owner has rights to access classlist data for a specific institutional class ID (including section).  Used to verify individual sections of the requested class, or crosslisted classes (and sections).

    1: # functions to glue school database system into Lon-CAPA for 
    2: # automated enrollment
    3: # $Id: localenroll.pm,v 1.16 2006/08/29 05:58:06 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: package localenroll;
   28: 
   29: use strict;
   30: 
   31: ################################
   32: # sub run
   33: # set this to return 1 if you want the auto enrollment to run
   34: ################################
   35: 
   36: sub run() {
   37:     my $dom = shift;
   38:     return 0;
   39: }
   40: 
   41: ################################
   42: # sub fetch_enrollment
   43: #
   44: # connects to the institutional classlist data source,
   45: # reads classlist data and stores in an XML file
   46: # in /home/httpd/perl/tmp/
   47: #
   48: # classlist files are named as follows:
   49: #
   50: # DOMAIN_COURSE_INSTITUTIONALCODE_classlist.xml
   51: #
   52: # e.g., msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
   53: # where DOMAIN = msu  COURSE = 43551dedcd43febmsul1 
   54: # INSTITUTIONALCODE = fs03nop590001 
   55: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
   56: # department name, 590 = course number, 001 = section number.)
   57: #
   58: # fetch_enrollment requires three arguments -
   59: # $dom - DOMAIN e.g., msu
   60: # $affiliatesref - a reference to a hash of arrays that contains LON-CAPA 
   61: # courses that are to be updated as keys, and institutional coursecodes 
   62: # contributing enrollment to that LON-CAPA course as elements in each array.
   63: # $replyref - a reference to a hash that contains LON-CAPA courses
   64: # that are to be updated as keys, and the total enrollment count in all 
   65: # affiliated sections, as determined from institutional data as hash elements. 
   66: #
   67: # As an example, if fetch_enrollment is called to retrieve institutional
   68: # classlists for a single LON-CAPA course - 43551dedcd43febmsul1 which 
   69: # corresponds to fs03nop590, sections 001, 601 and 602 , and the course
   70: # also accommodates enrollment from a crosslisted course in the ost
   71: # department - fs03ost580002:
   72: #
   73: # the affiliatesref would be a reference to %affiliates which would be:
   74: #
   75: # @{$affiliates{'43551dedcd43febmsul1'}} =
   76: #   ("fs03nop590001","fs03nop590601","fs03nop590602","fs03ost580002");
   77: #
   78: # fetch_enrollment would create four files in /home/httpd/perl/tmp/.
   79: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
   80: # msu_43551dedcd43febmsul1_fs03nop590601_classlist.xml
   81: # msu_43551dedcd43febmsul1_fs03nop590602_classlist.xml
   82: # msu_43551dedcd43febmsul1_fs03ost580002_classlist.xml
   83: #
   84: # In each file, student data would be stored in the following format
   85: # 
   86: # <student username="smith">
   87: #  <autharg>MSU.EDU</autharg>
   88: #  <authtype>krb4</authtype>
   89: #  <email>smith@msu.edu</email>
   90: #  <enddate></enddate>
   91: #  <firstname>John</firstname>
   92: #  <generation>II</generation>
   93: #  <groupID>fs03nop590001</groupID>
   94: #  <lastname>Smith</lastname>
   95: #  <middlename>D</middlename>
   96: #  <startdate></startdate>
   97: #  <studentID>A12345678</studentID>
   98: # </student>
   99: # 
  100: # with the following at the top of the file
  101: #<?xml version="1.0" encoding="UTF-8"?>
  102: #<!DOCTYPE text>
  103: #<students>
  104: #
  105: # (all comment - #s removed)
  106: #
  107: # and a closing:
  108: #</students>
  109: #
  110: # The <startdate> and the <enddate> are the activation date and expiration date
  111: # for this student's role. If they are absent, then the default access start and
  112: # default access end dates are used. The default access dates can be set when 
  113: # the course is created, and can be modified using the Automated Enrollment
  114: # Manager, or via the 'Upload a class list','Enroll a single student' or 
  115: # 'Modify student data' utilities in the Enrollment Manager, by checking the 
  116: # 'make these dates the default for future enrollment' checkbox. If no default 
  117: # dates have been set, then the tudent role will be active immediately, and will 
  118: # remain active until the role is explicitly expired using ENRL -> Drop students. 
  119: # If dates are to included in the XML file, they should be in the format
  120: # YYYY:MM:DD:HH:MM:SS (: separators required).
  121: #
  122: # If there were 10 students in fs03nop590001, 5 students in fs03nop59o601, 
  123: # 8 students in fs03nop590602, and 2 students in fs03ost580002,
  124: # then $$reply{'43551dedcd43febmsul1'} = 25
  125: #
  126: # The purpose of the %reply hash is to detect cases where the institutional 
  127: # enrollment is 0 (most likely due to a problem with the data source).
  128: # In such a case, the LON-CAPA course roster is left unchanged (i.e., no
  129: # students are expired, even if automated drops is enabled.
  130: # 
  131: # fetch_enrollment should return a 0 or 1, depending on whether a connection
  132: # could be established to the institutional data source.
  133: # 0 is returned if no connection could be made.
  134: # 1 is returned if connection was successful
  135: #
  136: # A return of 1 is required for the calling modules to perform LON-CAPA
  137: # roster changes based on the contents of the XML classlist file(s), e,g,,
  138: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
  139: #
  140: # XML classlist files are temporary. They are deleted after the enrollment 
  141: # update process in the calling module is complete.
  142: #
  143: ################################
  144: 
  145: sub fetch_enrollment {
  146:     my ($dom,$affiliatesref,$replyref) = @_;
  147:     foreach my $crs (sort keys %{$affiliatesref}) {
  148:         $$replyref{$crs} = 0;
  149:     }
  150:     my $okflag = 0;
  151:     return $okflag;
  152: }
  153: 
  154: ###############################
  155: # sub get_sections
  156: #
  157: # This is called by the Automated Enrollment Manager interface
  158: # (lonpopulate.pm) to create an array of valid sections for 
  159: # a specific institutional coursecode.
  160: # e.g., for MSU coursecode: fs03nop590
  161: # ("001","601","602") would be returned
  162: #
  163: # If the array returned contains at least one element, then 
  164: # the interface offerred to the course coordinator, lists
  165: # official sections and provides a checkbox to use to
  166: # select enrollment in the LON-CAPA course from each official section.  
  167: #
  168: # get_sections takes two arguments - (a) the institutional coursecode
  169: # (in the MSU case this is a concatenation of semester code, department
  170: # and course number), and (b) the LON-CAPA domain that contains the course. 
  171: # 
  172: # If there is no access to official course sections at your institution,
  173: # then an empty array is returned, and the Automated Enrollment Manager
  174: # interface will allow the course coordinator to enter section numbers
  175: # in text boxes.
  176: # 
  177: ###############################
  178: 
  179: sub get_sections {
  180:     my ($coursecode,$dom) = @_;
  181:     my @secs = ();
  182:     return @secs;
  183: }
  184: 
  185: ###############################
  186: # sub new_course
  187: #
  188: # This is called by loncreatecourse.pm and 
  189: # lonpopulate.pm to record that fact that a new course section
  190: # has been added to LON-CAPA that requires access to institutional data
  191: # At MSU, this is required, as institutional classlists can only made
  192: # available to faculty who are officially assigned to a course.
  193: # 
  194: # The new_course subroutine is used to check that the course owner
  195: # of the LON-CAPA course is permitted to access the institutional
  196: # classlist for any course sections and crosslisted classes that
  197: # the course coordinator wishes to have affiliated with the course.
  198: # 
  199: # If access is permitted, then 'ok' is returned.
  200: # The course section or crosslisted course will only be added to the list of
  201: # affiliates if 'ok' is returned.
  202: #
  203: # new_course takes three arguments -
  204: # (a) the institutional courseID (in the MSU case this is a concatenation of 
  205: # semester code, department code, course number, and section number
  206: # e.g., fs03nop590001).
  207: # (b) the course owner. This is the LON-CAPA username and domain of the course 
  208: # coordinator assigned to the course when it is first created, in the form
  209: # username:domain
  210: # (c) the LON-CAPA domain that contains the course
  211: #
  212: #################################
  213: 
  214: sub new_course  {
  215:     my ($course_id,$owner,$dom) = @_;
  216:     my $outcome = 'ok';
  217:     return $outcome;
  218: }
  219: 
  220: ###############################
  221: # sub validate_courseID
  222: #
  223: # This is called whenever a new course section or crosslisted course
  224: # is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
  225: # and the Automated Enrollment Manager in lonpopulate.pm).
  226: # A check is made that the courseID that the course coordinator wishes
  227: # to affiliate with the course is valid according to the institutional
  228: # schedule of official classes 
  229: #
  230: # A valid courseID is confirmed by returning 'ok'
  231: #
  232: # validate_courseID takes two arguments -
  233: # (a) the institutional courseID (in the MSU case this is a concatenation of
  234: # semester code, department code, course number, and section number
  235: # e.g., fs03nop590001).
  236: # (b) the LON-CAPA domain that contains the course
  237: #
  238: ###############################  
  239: 
  240: sub validate_courseID {
  241:     my ($course_id,$dom) = @_;
  242:     my $outcome = 'ok';
  243:     return $outcome;   
  244: }
  245: 
  246: ###############################
  247: # sub create_password 
  248: #
  249: # This is called when the authentication method set for the automated 
  250: # enrollment process when enrolling new users in the domain is "localauth".
  251: # This could be signalled for the specific user by the value of localauth
  252: # for the <authtype> tag from the classlist.xml files, or if this is blank,
  253: # the default authtype, set by the domain coordinator when creating the course
  254: # with loncreatecourse.pm.
  255: #  
  256: # create_password takes three arguments -
  257: # (a) $authparam - the value of <autharg> from the classlist.xml files,
  258: # or if this blank, the default autharg, set by the domain coordinator when 
  259: # creating the course with loncreatecourse.pm
  260: # (b) $dom - the domain of the new user.
  261: # (c) $username - the username of the new user (currently not actually used)
  262: #
  263: # Four values are returned:
  264: # (a) the value of $authparam - which might have been changed
  265: # (b) a flag to indicate whether a password had been created
  266: # 0 means no password created
  267: # 1 means password created.  In this case the calling module - Enrollment.pm
  268: # will send the LON-CAPA username and password to the new user's e-mail
  269: # (if one was provided), or to the course owner (if one was not provided and
  270: # the new user was created by the automated process), or to the active
  271: # course coordinator (if the new user was created using the 'update roster
  272: # now' interface included in the Automated Enrollment Manager).  
  273: # (c) a flag to indicate that the authentication method is correct - 'ok'.
  274: # If $authchk is not set to 'ok' then account creation and enrollment of the 
  275: # new user will not occur.
  276: # (d) if a password was created it can be sent along.  This is the password 
  277: # which will be included in the e-mail sent to the new user, or made available    
  278: # to the course owner/course coordinator if no e-mail address is provided. If
  279: # you do not wish to send a password, but want to give instructions on obtaining
  280: # one, you could set $newpasswd as those instructions. (e.g.,
  281: # $newpasswd = '(Please visit room 212, ACNS Bldg. to obtain your password)';
  282: # The value of $newpasswd is NOT written in the user's LON-CAPA passwd file in
  283: # /home/httpd/lonUsers/$dom/a/b/c/abcuser/passwd, which in the case of a user
  284: # employing localauth will contain 'localauth:$authparam'.  If you need to include
  285: # a parameter in the user's passwd file, you should return it as $authparam,
  286: # i.e., the first of the variables returned by create_password().             
  287: ###############################
  288: 
  289: sub create_password {
  290:     my ($authparam,$dom,$username) = @_;
  291:     my $authchk = 'ok';
  292:     my $newpasswd = '';
  293:     my $create_passwd = 0;
  294:     return ($authparam,$create_passwd,$authchk,$newpasswd);
  295: }
  296: 
  297: ###############################
  298: # sub instcode_format 
  299: #
  300: # Split coursecodes into constituent parts.   
  301: # e.g., INSTITUTIONALCODE = fs03nop590, LON-CAPA COURSEID: 43551dedcd43febmsul1
  302: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
  303: # department name, 590 = course number)
  304: #
  305: # Incoming data:
  306: # $dom (domain)
  307: # $$instcodes{'43551dedcd43febmsul1'} = 'Title of course' (hash of courseIDs)
  308: # 
  309: # fs03nop590 would be split as follows
  310: # @{$codetitles} = ("year","semester","department","number")
  311: # $$codes{{'year'} = '2003'
  312: # $$codes{'semester'} = 'Fall'
  313: # $$codes{'department'} = 'nop'
  314: # $$codes{'number'} = '590'
  315: #
  316: # requires six arguments:
  317: # domain ($dom)
  318: # reference to hash of institutional course IDs ($instcodes)  
  319: # reference to hash of codes ($codes)
  320: # reference to array of titles ($codetitles)
  321: # reference to hash of abbreviations used in categories
  322: # reference to hash of arrays specifying sort order used in category titles   
  323: #
  324: # e.g.,     %{$$cat_titles{'Semester'}} = (
  325: #                   fs => 'Fall',
  326: #                   ss => 'Spring',
  327: #                   us => 'Summer');
  328: #
  329: # e.g., @{$$cat_order{'Semester'}} = ('ss','us','fs'); 
  330: # returns 1 parameter: 'ok' if no processing errors.  
  331: ###############################
  332: 
  333: sub instcode_format () {
  334:     my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
  335:     my $outcome = 'ok';
  336:     return $outcome;
  337: }
  338: 
  339: ###############################
  340: # sub institutional_photos
  341: #
  342: # Called when automated enrollment manager is used to update student photos.
  343: #
  344: # Incoming data: six arguments
  345: # (a) $dom (domain)
  346: # (b) $crs (LONCAPA course number)
  347: # (c) $affiliates: a reference to a hash with the keys set to the 
  348: # institutional course IDs for the course.
  349: # (d) $result: a reference to a hash which will return usernames  
  350: #     of students (& separated) in following categories (the keys):
  351: #     new, update, missing, same, deleted, noid, nouser. The list 
  352: #     includes those students for whom the result of the modification 
  353: #     process was either addition of a new photo. update of an
  354: #     existing photo, photo was found to be missing from institution's
  355: #     data store, photo used is same as before, or photo was 
  356: #     deleted from storage on LON-CAPA server housing student's
  357: #     information, no student ID was available. 
  358:                
  359: # (e) $action: the type of action needed. (e.g., update, delete);
  360: # (f) $students: a reference to a hash with the keys set to student 
  361: # usernames and domains in the form username:domain, and values set
  362: # to the studentID, if action is required for specific students.  
  363: #
  364: # returns 1 parameter: 'ok' if no processing errors.
  365: # other course or student specific values can be stored as values
  366: # in the appropriate referenced hashes. 
  367: ###############################
  368: 
  369: sub institutional_photos {
  370:     my ($dom,$crs,$affiliates,$result,$action,$students) = @_;
  371:     my $outcome = 'ok';
  372:     return $outcome;
  373: }
  374: 
  375: ###############################
  376: # sub photo_permission
  377: #
  378: # Incoming data: three arguments
  379: # (a) $dom (domain)
  380: # (b) $perm_reqd: a reference to a a scalar that is either 'yes'
  381: # if a course owner must indicate acceptance of conditions of use,
  382: # 'no' otherwise.
  383: # (c) $conditions: the text of the conditions of use.
  384: #    
  385: # returns 1 parameter: 'ok' if no processing errors.
  386: # $$perm_reqd is set to 'yes' or 'no'
  387: # $$agreement is set to conditions of use - plain text string
  388: #             which will be displayed in a textarea in a web form.
  389: ###############################
  390:  
  391: sub photo_permission {
  392:    my ($dom,$perm_reqd,$conditions) = @_;
  393:    $$perm_reqd = 'no';
  394:    $$conditions = '';
  395:    my $outcome = 'ok';
  396:    return $outcome;
  397: }
  398: 
  399: 
  400: ###############################
  401: # sub manager_photo_update
  402: #
  403: # Incoming data: one argument
  404: # (a) $dom (domain)
  405: #
  406: # returns 2 parameters: update (0 or 1), and comment.
  407: # Called by automated enrollment manager, to determine 
  408: # whether "Update Student photos" button will be available,
  409: # and if so, the message (plain text string) that will be displayed
  410: # with the button. 
  411: ###############################
  412:                                                                                         
  413: sub manager_photo_update {
  414:     my ($dom) = @_;
  415:     my $update = 0;
  416:     my $comment = '';
  417:     return ($update,$comment);
  418: }
  419: 
  420: ###############################
  421: # sub check_section
  422: #
  423: # Incoming data: three arguments (+ fourth optional argument)
  424: # (a) $class - institutional class id (coursecode concatanated with section) 
  425: # (b) $owner - course owner (2.2 and later username:domain; pre-2.2 username)
  426: # (c) $dom 0 domain of course
  427: # (d) $dbh - optional database handle  
  428: #
  429: # returns 1 parameter - $sectioncheck ('ok' or other value). 
  430: # Verifies that course owner has access to classlist for specific class
  431: # according to institution's SIS. 'ok' if access available  
  432: ###############################
  433: 
  434: sub check_section {
  435:     my ($class,$owner,$dom,$dbh) = @_;
  436:     my $sectioncheck = 'ok';
  437:     return $sectioncheck;
  438: }
  439: 
  440: ###############################
  441: # sub AUTOLOAD
  442: #
  443: # Incoming data: none
  444: # Returns ''
  445: #
  446: # Prevents errors when undefined subroutines are called in this package
  447: # Will allow new routines added in the future to be called from lond etc.
  448: # without the need for customized versions of local*.pm packages to be
  449: # modified to include the new subroutines immediately.
  450: #
  451: # See "Programming Perl" 3rd ed. pp 296-298.   
  452: ###############################
  453: 
  454: sub AUTOLOAD {
  455:     our $AUTOLOAD;
  456:     return '';
  457: }
  458: 
  459: 1;

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