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

1.5       albertel    1: # functions to glue school database system into Lon-CAPA for 
                      2: # automated enrollment
1.8     ! raeburn     3: # $Id: localenroll.pm,v 1.7 2003/12/11 19:01:33 matthew Exp $
1.5       albertel    4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/html/adm/gpl.txt
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
1.4       raeburn    27: package localenroll;
                     28: 
                     29: use strict;
1.6       albertel   30: 
                     31: ################################
                     32: # sub run
                     33: # set this to return 1 if you want the auto enrollment to run
                     34: ################################
                     35: 
                     36: sub run { return 0; }
1.4       raeburn    37: 
                     38: ################################
                     39: # sub fetch_enrollment
1.3       albertel   40: #
1.4       raeburn    41: # connects to the institutional classlist data source,
                     42: # reads classlist data and stores in an XML file
                     43: # in /home/httpd/perl/tmp/
                     44: #
                     45: # classlist files are named as follows:
                     46: #
                     47: # DOMAIN_COURSE_INSTITUTIONALCODE_classlist.xml
                     48: #
                     49: # e.g., msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
                     50: # where DOMAIN = msu  COURSE = 43551dedcd43febmsul1 
                     51: # INSTITUTIONALCODE = fs03nop590001 
                     52: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
1.8     ! raeburn    53: # department name, 590 = course number, 001 = section number.)
1.4       raeburn    54: #
                     55: # fetch_enrollment requires three arguments -
                     56: # $dom - DOMAIN e.g., msu
                     57: # $affiliatesref - a reference to a hash of arrays that contains LON-CAPA 
                     58: # courses that are to be updated as keys, and institutional coursecodes 
                     59: # contributing enrollment to that LON-CAPA course as elements in each array.
                     60: # $replyref - a reference to a hash that contains LON-CAPA courses
                     61: # that are to be updated as keys, and the total enrollment count in all 
                     62: # affiliated sections, as determined from institutional data as hash elements. 
                     63: #
                     64: # As an example, if fetch_enrollment is called to retrieve institutional
                     65: # classlists for a single LON-CAPA course - 43551dedcd43febmsul1 which 
                     66: # corresponds to fs03nop590, sections 001, 601 and 602 , and the course
                     67: # also accommodates enrollment from a crosslisted course in the ost
                     68: # department - fs03ost580002:
                     69: #
                     70: # the affiliatesref would be a reference to %affiliates which would be:
                     71: #
                     72: # @{$affiliates{'43551dedcd43febmsul1'}} =
                     73: #   ("fs03nop590001","fs03nop590601","fs03nop590602","fs03ost580002");
                     74: #
                     75: # fetch_enrollment would create four files in /home/httpd/perl/tmp/.
                     76: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
                     77: # msu_43551dedcd43febmsul1_fs03nop590601_classlist.xml
                     78: # msu_43551dedcd43febmsul1_fs03nop590602_classlist.xml
                     79: # msu_43551dedcd43febmsul1_fs03ost580002_classlist.xml
                     80: #
                     81: # In each file, student data would be stored in the following format
                     82: # 
                     83: # <student username="smith">
                     84: #  <autharg>MSU.EDU</autharg>
                     85: #  <authtype>krb4</authtype>
                     86: #  <email>smith@msu.edu</email>
                     87: #  <enddate></enddate>
                     88: #  <firstname>John</firstname>
                     89: #  <generation>II</generation>
                     90: #  <groupID>fs03nop590001</groupID>
                     91: #  <lastname>Smith</lastname>
                     92: #  <middlename>D</middlename>
                     93: #  <startdate></startdate>
                     94: #  <studentID>A12345678</studentID>
                     95: # </student>
                     96: # 
                     97: # with the following at the top of the file
                     98: #<?xml version="1.0" encoding="UTF-8"?>
                     99: #<!DOCTYPE text>
                    100: #<students>
                    101: #
                    102: # (all comment - #s removed)
                    103: #
                    104: # and a closing:
                    105: #</students>
                    106: #
                    107: # The <startdate> and the <enddate> are the activation date and expiration date
1.8     ! raeburn   108: # for this student's role. If they are absent, then neither a start date nor an end
        !           109: # date will be set, and the student role will remain active until the role is 
        !           110: # explicitly expired using ENRL -> Drop students.    
        !           111: # An option to set a default activation date, and a default expiration date will
        !           112: # be added to loncreatecourse.pm, and lonpopulate.pm in a future release.
        !           113: # Once these default parameters are available, they will be used as the start date and
        !           114: # the end date in cases where the <startdate> and <enddate> fields are blank.
1.4       raeburn   115: # If dates are to included in the XML file, they should be in the format
                    116: # YYYY:MM:DD:HH:MM:SS (: separators required).
                    117: #
                    118: # If there were 10 students in fs03nop590001, 5 students in fs03nop59o601, 
                    119: # 8 students in fs03nop590602, and 2 students in fs03ost580002,
                    120: # then $$reply{'43551dedcd43febmsul1'} = 25
                    121: #
                    122: # The purpose of the %reply hash is to detect cases where the institutional 
                    123: # enrollment is 0 (most likely due to a problem with the data source).
                    124: # In such a case, the LON-CAPA course roster is left unchanged (i.e., no
                    125: # students are expired, even if automated drops is enabled.
                    126: # 
                    127: # fetch_enrollment should return a 0 or 1, depending on whether a connection
                    128: # could be established to the institutional data source.
                    129: # 0 is returned if no connection could be made.
                    130: # 1 is returned if connection was successful
                    131: #
                    132: # A return of 1 is required for the calling modules to perform LON-CAPA
                    133: # roster changes based on the contents of the XML classlist file(s), e,g,,
                    134: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
1.3       albertel  135: #
1.4       raeburn   136: # XML classlist files are temporary. They are deleted after the enrollment 
                    137: # update process in the calling module is complete.
1.3       albertel  138: #
1.4       raeburn   139: ################################
1.1       raeburn   140: 
                    141: sub fetch_enrollment {
1.7       matthew   142:     my ($dom,$affiliatesref,$replyref) = @_;
                    143:     foreach my $crs (sort keys %{$affiliatesref}) {
                    144:         $$replyref{$crs} = 0;
                    145:     }
                    146:     my $okflag = 0;
                    147:     return $okflag;
1.4       raeburn   148: }
                    149: 
                    150: ###############################
                    151: # sub get_sections
                    152: #
                    153: # This is called by the Automated Enrollment Manager interface
                    154: # (lonpopulate.pm) to create an array of valid sections for 
                    155: # a specific institutional coursecode.
                    156: # e.g., for MSU coursecode: fs03nop590
                    157: # ("001","601","602") would be returned
                    158: #
                    159: # If the array returned contains at least one element, then 
                    160: # the interface offerred to the course coordinator, lists
                    161: # official sections and provides a checkbox to use to
                    162: # select enrollment in the LON-CAPA course from each official section.  
                    163: #
1.8     ! raeburn   164: # get_sections requires one argument - the institutional coursecode
1.4       raeburn   165: # (in the MSU case this is a concatenation of semester code, department
                    166: # and course number). 
                    167: # 
                    168: # If there is no access to official course sections at your institution,
                    169: # then an empty array is returned, and the Automated Enrollment Manager
                    170: # interface will allow the course coordinator to enter section numbers
                    171: # in text boxes.
                    172: # 
                    173: ################################ 
                    174: 
                    175: sub get_sections {
                    176:     my $coursecode = shift;
                    177:     my @secs = ();
                    178:     return @secs;
1.1       raeburn   179: }
                    180: 
1.4       raeburn   181: ###############################
                    182: # sub new_course
                    183: #
                    184: # This is called by loncreatecourse.pm and 
                    185: # lonpopulate.pm to record that fact that a new course section
                    186: # has been added to LON-CAPA that requires access to institutional data
                    187: # At MSU, this is required, as institutional classlists can only made
1.8     ! raeburn   188: # available to faculty who are officially assigned to a course.
1.4       raeburn   189: # 
                    190: # The new_course subroutine is used to check that the course owner
                    191: # of the LON-CAPA course is permitted to access the institutional
                    192: # classlist for any course sections and crosslisted classes that
                    193: # the course coordinator wishes to have affiliated with the course.
                    194: # 
                    195: # If access is permitted, then 'ok' is returned.
                    196: # The course section or crosslisted course will only be added to the list of
                    197: # affiliates if 'ok' is returned.
                    198: #
                    199: # new_course requires two arguments -
                    200: # the institutional courseID (in the MSU case this is a concatenation of 
                    201: # semester code, department code, course number, and section number
                    202: # e.g., fs03nop590001).
                    203: # the course owner. This is the LON-CAPA username of the course coordinator 
                    204: # assigned to the course when it is first created.
                    205: #
                    206: #################################
                    207: 
                    208: sub new_course  {
                    209:     my ($course_id,$owner) = @_;
                    210:     my $outcome = 'ok';
                    211:     return $outcome;
1.1       raeburn   212: }
                    213: 
1.4       raeburn   214: ###############################
                    215: # sub validate_courseID
                    216: #
                    217: # This is called whenever a new course section or crosslisted course
                    218: # is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
                    219: # and the Automated Enrollment Manager in lonpopulate.pm).
                    220: # A check is made that the courseID that the course coordinator wishes
                    221: # to affiliate with the course is valid according to the institutional
                    222: # schedule of official classes 
                    223: #
                    224: # A valid courseID is confirmed by returning 'ok'
                    225: #
                    226: # validate_courseID requires one argument -
                    227: # the institutional courseID (in the MSU case this is a concatenation of
                    228: # semester code, department code, course number, and section number
                    229: # e.g., fs03nop590001).
                    230: #
                    231: ###############################  
                    232: 
                    233: sub validate_courseID {
                    234:     my $course_id = shift;
                    235:     my $outcome = 'ok';
                    236:     return $outcome;   
                    237: }
1.1       raeburn   238: 
1.4       raeburn   239: ###############################
                    240: # sub create_password 
                    241: #
                    242: # This is called when the authentication method set for the automated 
1.8     ! raeburn   243: # enrollment process when enrolling new users in the domain is "localauth".
        !           244: # This could be signalled for the specific user by the value of localauth
1.4       raeburn   245: # for the <authtype> tag from the classlist.xml files, or if this is blank,
                    246: # the default authtype, set by the domain coordinator when creating the course
                    247: # with loncreatecourse.pm.
                    248: # 
                    249: # create_password requires one argument -
                    250: # the value of <autharg> from the classlist.xml files, or if this is blank,
                    251: # the default autharg, set by the domain coordinator when creating the course
                    252: # with loncreatecourse.pm.  
                    253: #
                    254: # Three values are returned:
                    255: # (a) the value of $authparam - which might have been changed
                    256: # (b) a flag to indicate whether a password had been created
                    257: # 0 means no password created
                    258: # 1 means password created.  In this case the calling module - Enrollment.pm
1.8     ! raeburn   259: # will send the LON-CAPA username and password to the new user's e-mail
1.4       raeburn   260: # (if one was provided), or to the course owner (if one was not provided and
                    261: # the new user was created by the automated process), or to the active
                    262: # course coordinator (if the new user was created using the 'update roster
1.8     ! raeburn   263: # now' interface included in the Automated Enrollment Manager).  
1.4       raeburn   264: # (c) a flag to indicate that the authentication method is correct - 'ok'.
                    265: # If $authchk is not set to 'ok' then account creation and enrollment of the 
                    266: # new user will not occur.
                    267: #    
                    268: ###############################
                    269: 
                    270: sub create_password {
                    271:     my $authparam = shift;
                    272:     my $authchk = 'ok';
                    273:     my $create_passwd = 0;
                    274:     return ($authparam,$create_passwd,$authchk);
1.1       raeburn   275: }
                    276: 
                    277: 1;

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