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

1.5       albertel    1: # functions to glue school database system into Lon-CAPA for 
                      2: # automated enrollment
1.10    ! raeburn     3: # $Id: localenroll.pm,v 1.9 2004/06/17 18:31:25 raeburn Exp $
1.5       albertel    4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/html/adm/gpl.txt
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
1.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: 
1.9       raeburn    36: sub run() {
                     37:     my $dom = shift;
                     38:     return 0;
                     39: }
1.4       raeburn    40: 
                     41: ################################
                     42: # sub fetch_enrollment
1.3       albertel   43: #
1.4       raeburn    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 =
1.8       raeburn    56: # department name, 590 = course number, 001 = section number.)
1.4       raeburn    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
1.9       raeburn   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. 
1.4       raeburn   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
1.3       albertel  139: #
1.4       raeburn   140: # XML classlist files are temporary. They are deleted after the enrollment 
                    141: # update process in the calling module is complete.
1.3       albertel  142: #
1.4       raeburn   143: ################################
1.1       raeburn   144: 
                    145: sub fetch_enrollment {
1.7       matthew   146:     my ($dom,$affiliatesref,$replyref) = @_;
                    147:     foreach my $crs (sort keys %{$affiliatesref}) {
                    148:         $$replyref{$crs} = 0;
                    149:     }
                    150:     my $okflag = 0;
                    151:     return $okflag;
1.4       raeburn   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: #
1.8       raeburn   168: # get_sections requires one argument - the institutional coursecode
1.4       raeburn   169: # (in the MSU case this is a concatenation of semester code, department
                    170: # and course number). 
                    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: # 
1.10    ! raeburn   177: ###############################
1.4       raeburn   178: 
                    179: sub get_sections {
1.9       raeburn   180:     my ($coursecode,$dom) = @_;
1.4       raeburn   181:     my @secs = ();
                    182:     return @secs;
1.1       raeburn   183: }
                    184: 
1.4       raeburn   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
1.8       raeburn   192: # available to faculty who are officially assigned to a course.
1.4       raeburn   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 requires two arguments -
                    204: # 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: # the course owner. This is the LON-CAPA username of the course coordinator 
                    208: # assigned to the course when it is first created.
                    209: #
                    210: #################################
                    211: 
                    212: sub new_course  {
1.9       raeburn   213:     my ($course_id,$owner,$dom) = @_;
1.4       raeburn   214:     my $outcome = 'ok';
                    215:     return $outcome;
1.1       raeburn   216: }
                    217: 
1.4       raeburn   218: ###############################
                    219: # sub validate_courseID
                    220: #
                    221: # This is called whenever a new course section or crosslisted course
                    222: # is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
                    223: # and the Automated Enrollment Manager in lonpopulate.pm).
                    224: # A check is made that the courseID that the course coordinator wishes
                    225: # to affiliate with the course is valid according to the institutional
                    226: # schedule of official classes 
                    227: #
                    228: # A valid courseID is confirmed by returning 'ok'
                    229: #
                    230: # validate_courseID requires one argument -
                    231: # the institutional courseID (in the MSU case this is a concatenation of
                    232: # semester code, department code, course number, and section number
                    233: # e.g., fs03nop590001).
                    234: #
                    235: ###############################  
                    236: 
                    237: sub validate_courseID {
1.9       raeburn   238:     my ($course_id,$dom) = @_;
1.4       raeburn   239:     my $outcome = 'ok';
                    240:     return $outcome;   
                    241: }
1.1       raeburn   242: 
1.4       raeburn   243: ###############################
                    244: # sub create_password 
                    245: #
                    246: # This is called when the authentication method set for the automated 
1.8       raeburn   247: # enrollment process when enrolling new users in the domain is "localauth".
                    248: # This could be signalled for the specific user by the value of localauth
1.4       raeburn   249: # for the <authtype> tag from the classlist.xml files, or if this is blank,
                    250: # the default authtype, set by the domain coordinator when creating the course
                    251: # with loncreatecourse.pm.
                    252: # 
                    253: # create_password requires one argument -
                    254: # the value of <autharg> from the classlist.xml files, or if this is blank,
                    255: # the default autharg, set by the domain coordinator when creating the course
                    256: # with loncreatecourse.pm.  
                    257: #
                    258: # Three values are returned:
                    259: # (a) the value of $authparam - which might have been changed
                    260: # (b) a flag to indicate whether a password had been created
                    261: # 0 means no password created
                    262: # 1 means password created.  In this case the calling module - Enrollment.pm
1.8       raeburn   263: # will send the LON-CAPA username and password to the new user's e-mail
1.4       raeburn   264: # (if one was provided), or to the course owner (if one was not provided and
                    265: # the new user was created by the automated process), or to the active
                    266: # course coordinator (if the new user was created using the 'update roster
1.8       raeburn   267: # now' interface included in the Automated Enrollment Manager).  
1.4       raeburn   268: # (c) a flag to indicate that the authentication method is correct - 'ok'.
                    269: # If $authchk is not set to 'ok' then account creation and enrollment of the 
                    270: # new user will not occur.
                    271: #    
                    272: ###############################
                    273: 
                    274: sub create_password {
1.9       raeburn   275:     my ($authparam,$dom) = @_;
1.4       raeburn   276:     my $authchk = 'ok';
                    277:     my $create_passwd = 0;
                    278:     return ($authparam,$create_passwd,$authchk);
1.1       raeburn   279: }
                    280: 
1.10    ! raeburn   281: ###############################
        !           282: # sub instcode_format 
        !           283: #
        !           284: # Split coursecodes into constituent parts.   
        !           285: # e.g., INSTITUTIONALCODE = fs03nop590, LON-CAPA COURSEID: 43551dedcd43febmsul1
        !           286: # (MSU's course naming scheme - fs03 = Fall semester 2003, nop =
        !           287: # department name, 590 = course number)
        !           288: #
        !           289: # Incoming data:
        !           290: # $dom (domain)
        !           291: # $$courseIDs{'43551dedcd43febmsul1'} = 'Title of course' (hash of courseIDs)
        !           292: # 
        !           293: # fs03nop590 would be split as follows
        !           294: # @{$codetitles} = ("year","semester","department","number")
        !           295: # $$codes{{'year'} = '2003'
        !           296: # $$codes{'semester'} = 'Fall'
        !           297: # $$codes{'department'} = 'nop'
        !           298: # $$codes{'number'} = '590'
        !           299: #
        !           300: # requires five arguments:
        !           301: # domain ($dom)
        !           302: # reference to hash of institutional course IDs ($instcodes)  
        !           303: # reference to hash of codes ($codes)
        !           304: # reference to array of titles ($codetitles)
        !           305: # reference to hash of abbreviations used in categories
        !           306: # reference to hash of arrays specifying sort order used in category titles   
        !           307: #
        !           308: # e.g.,     %{$$cat_titles{'Semester'}} = (
        !           309: #                   fs => 'Fall',
        !           310: #                   ss => 'Spring',
        !           311: #                   us => 'Summer');
        !           312: #
        !           313: # e.g., @{$$cat_order{'Semester'}} = ('ss','us','fs'); 
        !           314: # returns 1 parameter: 'ok' if no processing errors.  
        !           315: ###############################
        !           316: 
        !           317: sub instcode_format () {
        !           318:     my ($dom,$instcodes,$codes,$codetitles,$cat_titles,$cat_order) = @_;
        !           319:     my $outcome = 'ok';
        !           320:     return $outcome;
        !           321: }
        !           322: 
1.1       raeburn   323: 1;

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