[LON-CAPA-cvs] cvs: modules /msu localenroll.pm loncom lond loncom/enrollment localenroll.pm
raeburn
raeburn@source.lon-capa.org
Sat, 22 Aug 2009 19:52:17 -0000
This is a MIME encoded message
--raeburn1250970737
Content-Type: text/plain
raeburn Sat Aug 22 19:52:17 2009 EDT
Modified files:
/loncom lond
/loncom/enrollment localenroll.pm
/modules/msu localenroll.pm
Log:
- lond
- update documentation in lond for validate_instcode_handler().
- &crsreq_checks_handler()
- include ref to reqtypes array
- official, unofficial, community
as arg in call to &localenroll::crsreq_checks_handler().
- enrollment::localenroll.pm
- update &validate_instcode() to accept three args, and modify documentation.
- add &crsreq_checks() to determine which types/affiliations should have 'validate'
choice for processing course requests.
- add validate_crsreq() to determine next action for a course request for which
process type is 'validate'.
- msu::localenroll.pm
- Add &crsreq_checks() and &validate_crsreq().
- Update &validate_instcode()
- owner is $username:$domain
- outcome for valid course is 'valid' instead of 'ok'.
- correct text of a couple of $outcome messages were course was not validated.
--raeburn1250970737
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090822195217.txt"
Index: loncom/lond
diff -u loncom/lond:1.423 loncom/lond:1.424
--- loncom/lond:1.423 Sat Aug 22 19:10:01 2009
+++ loncom/lond Sat Aug 22 19:52:08 2009
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.423 2009/08/22 19:10:01 raeburn Exp $
+# $Id: lond,v 1.424 2009/08/22 19:52:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.423 $'; #' stupid emacs
+my $VERSION='$Revision: 1.424 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -4877,10 +4877,16 @@
# $tail - The tail of the command. In this case,
# this is a colon separated set of words that will be split
# into:
-# $inst_course_id - The institutional cod3 from the
-# institutions point of view.
-# $cdom - The domain from the institutions
-# point of view.
+# $dom - The domain for which the check of
+# institutional course code will occur.
+#
+# $instcode - The institutional code for the course
+# being requested, or validated for rights
+# to request.
+#
+# $owner - The course requestor (who will be the
+# course owner, in the form username:domain
+#
# $client - Socket open on the client.
# Returns:
# 1 - Indicating processing should continue.
@@ -5106,10 +5112,12 @@
my $userinput = "$cmd:$tail";
my $dom = $tail;
my $result;
+ my @reqtypes = ('official','unofficial','community');
eval {
local($SIG{__DIE__})='DEFAULT';
my %validations;
- my $response = &localenroll::crsreq_checks($dom,\%validations);
+ my $response = &localenroll::crsreq_checks($dom,\@reqtypes,
+ \%validations);
if ($response eq 'ok') {
foreach my $key (keys(%validations)) {
$result .= &escape($key).'='.&Apache::lonnet::freeze_escape($validations{$key}).'&';
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.37 loncom/enrollment/localenroll.pm:1.38
--- loncom/enrollment/localenroll.pm:1.37 Tue Aug 18 20:08:38 2009
+++ loncom/enrollment/localenroll.pm Sat Aug 22 19:52:13 2009
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.37 2009/08/18 20:08:38 raeburn Exp $
+# $Id: localenroll.pm,v 1.38 2009/08/22 19:52:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -291,38 +291,125 @@
record for the course in the institution's course schedule/database.
A valid instcode is confirmed by returning 'valid'.
-In the case of a check for the instructor of record, the following can
-be returned:
-(a) valid - the requestor is the recorded instructor - create the course
-(b) reject - the requestor should never be requesting this course, reject the
- request permanently
-(c) pending - the requestor is not the recorded instructor, but could
- become so after administrative action at the institution. Put the
- request ina queue and check localenroll:validate_instcode()
- periodically until the status changes to "valid".
-(d) approval - the request will be held pending review by a Domain Coordinator.
-(e) error (followed by the error condition);
-validate_instcode takes five arguments -
+validate_instcode takes three arguments -
(a) the LON-CAPA domain that will contain the course
(b) the institutional code (in the MSU case this is a concatenation of
semester code, department code, and course number, e.g., fs03nop590.
(c) an optional institutional username for the course owner.
- (d) an optional comma-separated list of institutional affiliations of
- the course owner.
- (e) an optional comma-separated list of institutional sections included in
- the course request
=cut
sub validate_instcode {
- my ($dom,$instcode,$owner,$inststatuslist,$instseclist) = @_;
+ my ($dom,$instcode,$owner) = @_;
my $outcome = '';
return $outcome;
}
=pod
+=item validate_crsreq()
+
+This is used to check whether a course request should be processed
+automatically, or held in a queue pending administrative action at
+the institution.
+
+Course requests will trigger this check if the process type has been set
+to 'validate' for the course type (official, unofficial or community) and
+the requestor's affiliation. Whether "validate" is an available option
+in the Domain Configuration menu is controlled by auto_courserequest_checks().
+One scenario is where the request is for an official course, in which case
+a check could be made that the requestor is listed as instructor of
+record for the course in the institution's course schedule/database.
+
+Other scenarios are possible, and the routine can be customized according
+to whatever rules a domain wishes to implement to run validations against
+given the data passed in to the routine.
+
+validate_crsreq takes six arguments -
+ (a) the LON-CAPA domain that will contain the course.
+ (b) the username:domain for the course owner.
+ (c) the course type (official, unofficial or community)
+ (d) a comma-separated list of institutional affiliations of
+ the course owner.
+ (e) the institutional code (in the MSU case this is a concatenation of
+ semester code, department code, and course number, e.g., fs03nop590.
+ (f) a comma-separated list of institutional sections included in
+ the course request (only applicable to official courses).
+
+A valid courserequest is confirmed by returning 'process'.
+The following can be returned: process, rejected, pending, approval or error (with error condition - no :), followed by a : and then an optional message.
+
+(a) process - the requestor is the recorded instructor - create the course
+(b) reject - the requestor should never be requesting this course, reject the
+ request permanently
+(c) pending - the requestor is not the recorded instructor, but could
+ become so after administrative action at the institution. Put the
+ request in a queue and check localenroll:validate_instcode()
+ periodically until the status changes to "valid".
+(d) approval - the request will be held pending review by a Domain Coordinator.
+(e) error (followed by the error condition).
+
+=cut
+
+sub validate_crsreq {
+ my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist) = @_;
+ my $outcome = 'approval';
+ return $outcome;
+}
+
+=pod
+
+=item crsreq_checks()
+
+This is used to determine whether the "validate" option should appear in the
+possible choices for course request processing in the Domain Configuration
+menu for Course Requests. Ultimately it is called by domainprefs.pm (via:
+lonnet -> lond -> localenroll.pm) The domain configuration menu includes
+a table where columns are course type (official, unofficial or community)
+and rows are institutional affiliations (e.g., Faculty, Staff, Student etc.).
+
+crsreq_checks() takes three arguments: $dom, $reqtyes, $validations.
+$dom - the domain for which validation options are needed.
+$reqtypes - ref to an ARRAY of course types (i.e., official, unofficial and community.
+$validations - ref to a hash of a hash which will determine whether "validate"
+will be one of the possible choices for each course type (outer hash key),
+and institutional type (inner hash key).
+
+For example to allow validate to be a choice for official classes for Faculty,
+req_checks would include:
+
+$validations{'official'}{'Faculty'} = 1;
+
+This routine is closely tied to validate_crsreq(). "Validate" should not be
+a possible choice in the domain configuration menu for a particular course
+type/institutional affiliation, unless a corresponding validation code has
+been implemented in validate_crsreq().
+
+For example at MSU, official courses requested by Faculty will be validated
+against the official schedule of classes to check that the requestor is one
+of the instructors of record for the course. In this case validate_crsreq()
+includes a call to validate_instcode().
+
+=cut
+
+sub crsreq_checks {
+ my ($dom,$reqtypes,$validations) = @_;
+ if ((ref($reqtypes) eq 'ARRAY') && (ref($validations) eq 'HASH')) {
+ my (%usertypes,@order);
+ if (&inst_usertypes($dom,\%usertypes,\@order) eq 'ok') {
+ foreach my $type (@{$reqtypes}) {
+ foreach my $inst_type (@order) {
+ $validations->{$type}{$inst_type} = 0;
+ }
+ }
+ }
+ }
+ return 'ok';
+}
+
+=pod
+
=item create_password()
This is called when the authentication method set for the automated
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.42 modules/msu/localenroll.pm:1.43
--- modules/msu/localenroll.pm:1.42 Fri Jul 31 23:48:10 2009
+++ modules/msu/localenroll.pm Sat Aug 22 19:52:17 2009
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.42 2009/07/31 23:48:10 raeburn Exp $
+# $Id: localenroll.pm,v 1.43 2009/08/22 19:52:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -207,7 +207,7 @@
return @secs;
}
-sub new_course {
+sub new_course {
my ($course_id,$owner,$dom) = @_;
my $outcome = '';
if ($owner eq '') {
@@ -308,25 +308,30 @@
$term =~tr/a-z/A-Z/;
my ($dbh,$dbflag,$database);
if (defined($owner)) {
- if ($owner =~ /^\w{2,8}$/) {
- $database = 'RO';
- ($dbh,$dbflag) = &connect_DB($database);
- if ($dbflag) {
+ my ($ownername,$ownerdom) = split(':',$owner);
+ if ($ownerdom eq 'msu') {
+ if ($owner =~ /^\w{2,8}$/) {
+ $database = 'RO';
+ ($dbh,$dbflag) = &connect_DB($database);
+ if ($dbflag) {
# Check if instructor is in CLIFMS for this course
- eval {
- my $clifmscount = $dbh->selectrow_array("SELECT count(*) FROM RO_CLIFMS_VIEW WHERE Term_Code='$term' AND Subj_Code='$subj' AND Crse_Code='$crse' AND MSUNetID='$owner' AND (Record_Type='1' OR Record_Type='2' OR Record_Type ='3' OR Record_Type = '9')");
- if ($clifmscount > 0) {
- $outcome = 'ok';
- } else {
- $outcome = "There was no match in the MSU $database database to the combination of semester ($term), subject ($subj), course number ($crse) for the specified owner ($owner).";
+ eval {
+ my $clifmscount = $dbh->selectrow_array("SELECT count(*) FROM RO_CLIFMS_VIEW WHERE Term_Code='$term' AND Subj_Code='$subj' AND Crse_Code='$crse' AND MSUNetID='$owner' AND (Record_Type='1' OR Record_Type='2' OR Record_Type ='3' OR Record_Type = '9')");
+ if ($clifmscount > 0) {
+ $outcome = 'valid';
+ } else {
+ $outcome = "There was no match in the MSU $database database to the combination of semester ($term), subject ($subj), course number ($crse) for the specified owner ($owner).";
+ }
+ };
+ if ($@) {
+ $outcome = "There was a problem connecting to the CLIFMS database, so the course number could not be validated.";
}
- };
- if ($@) {
- $outcome = "There was a problem connecting to the SIS database, so the course number could not be validated.";
}
+ } else {
+ $outcome = "The username provided for the course owner did not conform to the format used for MSU NetIDs.";
}
} else {
- $outcome = "The username provided for the course owner did conform to the format used for MSU NetIDs.";
+ $outcome = "The course owner is not from the msu domain so can not be validated.";
}
} else {
$database = 'SIS';
@@ -338,7 +343,7 @@
my $quotedterm = $dbh->quote($term);
my $count = $dbh->selectrow_array( "SELECT count(*) FROM SISCRSS WHERE Subj_Code = $quotedsubj AND Crse_Code= $quotedcrse AND Sctn_Term_Code =$quotedterm ");
if ($count > 0) {
- $outcome = 'ok';
+ $outcome = 'valid';
} else {
$outcome = "There was no match in the MSU $database database to the combination of semester ($term), subject ($subj), course number ($crse) you entered.";
}
@@ -359,6 +364,38 @@
return $outcome;
}
+sub crsreq_checks {
+ my ($dom,$reqtypes,$validations) = @_;
+ if ((ref($reqtypes) eq 'ARRAY') && (ref($validations) eq 'HASH')) {
+ my (%usertypes,@order);
+ if (&inst_usertypes($dom,\%usertypes,\@order) eq 'ok') {
+ foreach my $type (@{$reqtypes}) {
+ foreach my $inst_type (@order) {
+ if (($type eq 'official') && ($inst_type eq 'Faculty')) {
+ $validations->{$type}{$inst_type} = 1;
+ } else {
+ $validations->{$type}{$inst_type} = '';
+ }
+ }
+ }
+ }
+ }
+ return 'ok';
+}
+
+sub validate_crsreq {
+ my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist) = @_;
+ my ($outcome,$message);
+ my $result = &validate_instcode($dom,$instcode,$owner);
+ if ($result eq 'valid') {
+ $outcome = 'process';
+ } else {
+ $outcome = 'pending';
+ $message = $result;
+ }
+ return $outcome.':'.$message;
+}
+
sub create_password {
my ($authparam,$dom) = @_;
my $authchk = 'ok';
--raeburn1250970737--