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

1.5       albertel    1: # functions to glue school database system into Lon-CAPA for 
                      2: # automated enrollment
1.6     ! albertel    3: # $Id: localenroll.pm,v 1.5 2003/12/11 15:43:29 albertel 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 =
                     53: # department name, 590 = course number, 001 = section number.
                     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
                    108: # for this student's role. If they are absent, then the date set for
                    109: # first automated enrollment is used as the default activation date, and the
                    110: # date set for last automated enrollment is used as the default expiration date.
                    111: # If dates are to included in the XML file, they should be in the format
                    112: # YYYY:MM:DD:HH:MM:SS (: separators required).
                    113: #
                    114: # If there were 10 students in fs03nop590001, 5 students in fs03nop59o601, 
                    115: # 8 students in fs03nop590602, and 2 students in fs03ost580002,
                    116: # then $$reply{'43551dedcd43febmsul1'} = 25
                    117: #
                    118: # The purpose of the %reply hash is to detect cases where the institutional 
                    119: # enrollment is 0 (most likely due to a problem with the data source).
                    120: # In such a case, the LON-CAPA course roster is left unchanged (i.e., no
                    121: # students are expired, even if automated drops is enabled.
                    122: # 
                    123: # fetch_enrollment should return a 0 or 1, depending on whether a connection
                    124: # could be established to the institutional data source.
                    125: # 0 is returned if no connection could be made.
                    126: # 1 is returned if connection was successful
                    127: #
                    128: # A return of 1 is required for the calling modules to perform LON-CAPA
                    129: # roster changes based on the contents of the XML classlist file(s), e,g,,
                    130: # msu_43551dedcd43febmsul1_fs03nop590001_classlist.xml
1.3       albertel  131: #
1.4       raeburn   132: # XML classlist files are temporary. They are deleted after the enrollment 
                    133: # update process in the calling module is complete.
1.3       albertel  134: #
1.4       raeburn   135: ################################
1.1       raeburn   136: 
                    137: sub fetch_enrollment {
                    138:   my ($dom,$affiliatesref,$replyref) = @_;
                    139:      foreach my $crs (sort keys %{$affiliatesref}) {
1.4       raeburn   140:          $$replyref{$crs} = 0;
1.1       raeburn   141:      }
                    142:   }
1.4       raeburn   143:   my $okflag = 0;
                    144:   return $okflag;
                    145: }
                    146: 
                    147: ###############################
                    148: # sub get_sections
                    149: #
                    150: # This is called by the Automated Enrollment Manager interface
                    151: # (lonpopulate.pm) to create an array of valid sections for 
                    152: # a specific institutional coursecode.
                    153: # e.g., for MSU coursecode: fs03nop590
                    154: # ("001","601","602") would be returned
                    155: #
                    156: # If the array returned contains at least one element, then 
                    157: # the interface offerred to the course coordinator, lists
                    158: # official sections and provides a checkbox to use to
                    159: # select enrollment in the LON-CAPA course from each official section.  
                    160: #
                    161: # get_sections requires one argument - the instituional coursecode
                    162: # (in the MSU case this is a concatenation of semester code, department
                    163: # and course number). 
                    164: # 
                    165: # If there is no access to official course sections at your institution,
                    166: # then an empty array is returned, and the Automated Enrollment Manager
                    167: # interface will allow the course coordinator to enter section numbers
                    168: # in text boxes.
                    169: # 
                    170: ################################ 
                    171: 
                    172: sub get_sections {
                    173:     my $coursecode = shift;
                    174:     my @secs = ();
                    175:     return @secs;
1.1       raeburn   176: }
                    177: 
1.4       raeburn   178: ###############################
                    179: # sub new_course
                    180: #
                    181: # This is called by loncreatecourse.pm and 
                    182: # lonpopulate.pm to record that fact that a new course section
                    183: # has been added to LON-CAPA that requires access to institutional data
                    184: # At MSU, this is required, as institutional classlists can only made
                    185: # available to faculty who are officially assigned to a course
                    186: # 
                    187: # The new_course subroutine is used to check that the course owner
                    188: # of the LON-CAPA course is permitted to access the institutional
                    189: # classlist for any course sections and crosslisted classes that
                    190: # the course coordinator wishes to have affiliated with the course.
                    191: # 
                    192: # If access is permitted, then 'ok' is returned.
                    193: # The course section or crosslisted course will only be added to the list of
                    194: # affiliates if 'ok' is returned.
                    195: #
                    196: # new_course requires two arguments -
                    197: # the institutional courseID (in the MSU case this is a concatenation of 
                    198: # semester code, department code, course number, and section number
                    199: # e.g., fs03nop590001).
                    200: # the course owner. This is the LON-CAPA username of the course coordinator 
                    201: # assigned to the course when it is first created.
                    202: #
                    203: #################################
                    204: 
                    205: sub new_course  {
                    206:     my ($course_id,$owner) = @_;
                    207:     my $outcome = 'ok';
                    208:     return $outcome;
1.1       raeburn   209: }
                    210: 
1.4       raeburn   211: ###############################
                    212: # sub validate_courseID
                    213: #
                    214: # This is called whenever a new course section or crosslisted course
                    215: # is being affiliated with a LON-CAPA course (i.e., by loncreatecourse.pm
                    216: # and the Automated Enrollment Manager in lonpopulate.pm).
                    217: # A check is made that the courseID that the course coordinator wishes
                    218: # to affiliate with the course is valid according to the institutional
                    219: # schedule of official classes 
                    220: #
                    221: # A valid courseID is confirmed by returning 'ok'
                    222: #
                    223: # validate_courseID requires one argument -
                    224: # the institutional courseID (in the MSU case this is a concatenation of
                    225: # semester code, department code, course number, and section number
                    226: # e.g., fs03nop590001).
                    227: #
                    228: ###############################  
                    229: 
                    230: sub validate_courseID {
                    231:     my $course_id = shift;
                    232:     my $outcome = 'ok';
                    233:     return $outcome;   
                    234: }
1.1       raeburn   235: 
1.4       raeburn   236: ###############################
                    237: # sub create_password 
                    238: #
                    239: # This is called when the authentication method set for the automated 
                    240: # enrollment process when enrolling new users in the domain is "local".
                    241: # This could be signalled for the specific user by the value of local
                    242: # for the <authtype> tag from the classlist.xml files, or if this is blank,
                    243: # the default authtype, set by the domain coordinator when creating the course
                    244: # with loncreatecourse.pm.
                    245: # 
                    246: # create_password requires one argument -
                    247: # the value of <autharg> from the classlist.xml files, or if this is blank,
                    248: # the default autharg, set by the domain coordinator when creating the course
                    249: # with loncreatecourse.pm.  
                    250: #
                    251: # Three values are returned:
                    252: # (a) the value of $authparam - which might have been changed
                    253: # (b) a flag to indicate whether a password had been created
                    254: # 0 means no password created
                    255: # 1 means password created.  In this case the calling module - Enrollment.pm
                    256: # will send the LON-CAPA username and passwod to the new user's e-mail
                    257: # (if one was provided), or to the course owner (if one was not provided and
                    258: # the new user was created by the automated process), or to the active
                    259: # course coordinator (if the new user was created using the 'update roster
                    260: # now' interface included in the Automated Enrollment Manager.  
                    261: # (c) a flag to indicate that the authentication method is correct - 'ok'.
                    262: # If $authchk is not set to 'ok' then account creation and enrollment of the 
                    263: # new user will not occur.
                    264: #    
                    265: ###############################
                    266: 
                    267: sub create_password {
                    268:     my $authparam = shift;
                    269:     my $authchk = 'ok';
                    270:     my $create_passwd = 0;
                    271:     return ($authparam,$create_passwd,$authchk);
1.1       raeburn   272: }
                    273: 
                    274: 1;

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