[prev in list] [next in list] [prev in thread] [next in thread]
List: lon-capa-cvs
Subject: [LON-CAPA-cvs] cvs: loncom / lond /enrollment localenroll.pm /lonnet/perl lonnet.pm
From: raeburn <raeburn () source ! lon-capa ! org>
Date: 2009-07-25 15:25:19
Message-ID: cvsraeburn1248535519 () cvsserver
[Download RAW message or body]
This is a MIME encoded message
raeburn Sat Jul 25 15:25:19 2009 EDT
Modified files:
/loncom lond
/loncom/enrollment localenroll.pm
/loncom/lonnet/perl lonnet.pm
Log:
- &localenroll:possible_instcodes() takes an addition arg: $code_order which \
indicates the order in which components of the course code should be \
recombined.
- e.g., At MSU, select boxes in the course request form are in the order:
Year Semester Department
but the order used to create the institutional code is:
Semester Year Department
- &lonnet::auto_get_sections()
- $cnum arg is undefined when checking for institutional sections during the \
course request process. In the is case the homeserver used to retrieve the sections \
is the primary library server for the domain.
- &lonnet::auto_validate_instcode() - new routine used to validate an institutional \
course code during course requests.
- Note: this differs from the institutional courseID (which in the institutional \
code with appended institutional section).
["raeburn-20090725152519.txt" (text/plain)]
Index: loncom/lond
diff -u loncom/lond:1.416 loncom/lond:1.417
--- loncom/lond:1.416 Thu Jun 11 19:19:51 2009
+++ loncom/lond Sat Jul 25 15:25:10 2009
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.416 2009/06/11 19:19:51 raeburn Exp $
+# $Id: lond,v 1.417 2009/07/25 15:25:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.416 $'; #' stupid emacs
+my $VERSION='$Revision: 1.417 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -4641,6 +4641,33 @@
}
®ister_handler("autorun", \&enrollment_enabled_handler, 0, 1, 0);
+#
+# Validate an institutional code use for a LON-CAPA course.
+#
+# Formal Parameters:
+# $cmd - The command request that got us dispatched.
+# $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.
+# $client - Socket open on the client.
+# Returns:
+# 1 - Indicating processing should continue.
+#
+sub validate_instcode_handler {
+ my ($cmd, $tail, $client) = @_;
+ my $userinput = "$cmd:$tail";
+ my ($dom,$instcode,$owner) = split(/:/, $tail);
+ my $outcome=&localenroll::validate_instcode($dom,$instcode,$owner);
+ &Reply($client, \$outcome, $userinput);
+
+ return 1;
+}
+®ister_handler("autovalidateinstcode", \&validate_instcode_handler, 0, 1, 0);
+
# Get the official sections for which auto-enrollment is possible.
# Since the admin people won't know about 'unofficial sections'
# we cannot auto-enroll on them.
@@ -4934,13 +4961,15 @@
my $reply;
my $cdom = $tail;
- my (@codetitles,%cat_titles,%cat_order);
+ my (@codetitles,%cat_titles,%cat_order,@code_order);
my $formatreply = &localenroll::possible_instcodes($cdom,
\@codetitles,
\%cat_titles,
- \%cat_order);
+ \%cat_order,
+ \@code_order);
if ($formatreply eq 'ok') {
my $result = join('&',map {&escape($_);} (@codetitles)).':';
+ $result .= join('&',map {&escape($_);} (@code_order)).':';
foreach my $key (keys(%cat_titles)) {
$result .= &escape($key).'='.&Apache::lonnet::freeze_escape($cat_titles{$key}).'&';
}
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.35 loncom/enrollment/localenroll.pm:1.36
--- loncom/enrollment/localenroll.pm:1.35 Thu Jun 11 20:09:25 2009
+++ loncom/enrollment/localenroll.pm Sat Jul 25 15:25:14 2009
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.35 2009/06/11 20:09:25 raeburn Exp $
+# $Id: localenroll.pm,v 1.36 2009/07/25 15:25:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -279,6 +279,36 @@
=pod
+=item validate_instcode()
+
+This is called when a request is being made for an official course.
+A check is made that the institutional code for which a course is
+is being requested is valid according to the institutional
+schedule of official classes.
+
+If the username of the course owner is provided, a more restrictive
+test is used, namely that the requestor is listed as instructor of
+record for the course in the institution's course schedule/database.
+
+A valid instcode is confirmed by returning 'ok'.
+Otherwise a phrase can be returned explaining why the code was invalid.
+
+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.
+
+=cut
+
+sub validate_instcode {
+ my ($dom,$instcode,$owner) = @_;
+ my $outcome = '';
+ return $outcome;
+}
+
+=pod
+
=item create_password()
This is called when the authentication method set for the automated
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1006 loncom/lonnet/perl/lonnet.pm:1.1007
--- loncom/lonnet/perl/lonnet.pm:1.1006 Sat Jul 25 14:44:55 2009
+++ loncom/lonnet/perl/lonnet.pm Sat Jul 25 15:25:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1006 2009/07/25 14:44:55 raeburn Exp $
+# $Id: lonnet.pm,v 1.1007 2009/07/25 15:25:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5507,11 +5507,21 @@
sub auto_get_sections {
my ($cnum,$cdom,$inst_coursecode) = @_;
- my $homeserver = &homeserver($cnum,$cdom);
- my @secs = ();
- my $response=&unescape(&reply('autogetsections:'.$inst_coursecode.':'.$cdom,$homeserver));
- unless ($response eq 'refused') {
- @secs = split(/:/,$response);
+ my $homeserver;
+ if (($cdom =~ /^$match_domain$/) && ($cnum =~ /^$match_courseid$/)) {
+ $homeserver = &homeserver($cnum,$cdom);
+ }
+ if (!defined($homeserver)) {
+ if ($cdom =~ /^$match_domain$/) {
+ $homeserver = &domain($cdom,'primary');
+ }
+ }
+ my @secs;
+ if (defined($homeserver)) {
+ my $response=&unescape(&reply('autogetsections:'.$inst_coursecode.':'.$cdom,$homeserver));
+ unless ($response eq 'refused') {
+ @secs = split(/:/,$response);
+ }
}
return @secs;
}
@@ -5530,6 +5540,22 @@
return $response;
}
+sub auto_validate_instcode {
+ my ($cnum,$cdom,$instcode,$owner) = @_;
+ my ($homeserver,$response);
+ if (($cdom =~ /^$match_domain$/) && ($cnum =~ /^$match_courseid$/)) {
+ $homeserver = &homeserver($cnum,$cdom);
+ }
+ if (!defined($homeserver)) {
+ if ($cdom =~ /^$match_domain$/) {
+ $homeserver = &domain($cdom,'primary');
+ }
+ }
+ my $response=&unescape(&reply('autovalidateinstcode:'.$cdom.':'.
+ &escape($instcode).':'.&escape($owner),$homeserver));
+ return $response;
+}
+
sub auto_create_password {
my ($cnum,$cdom,$authparam,$udom) = @_;
my ($homeserver,$response);
@@ -5704,7 +5730,11 @@
}
sub auto_possible_instcodes {
- my ($domain,$codetitles,$cat_titles,$cat_orders) = @_;
+ my ($domain,$codetitles,$cat_titles,$cat_orders,$code_order) = @_;
+ unless ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') &&
+ (ref($cat_orders) eq 'HASH') && (ref($code_order) eq 'ARRAY')) {
+ return;
+ }
my (@homeservers,$uhome);
if (defined(&domain($domain,'primary'))) {
$uhome=&domain($domain,'primary');
@@ -5721,8 +5751,10 @@
foreach my $server (@homeservers) {
$response=&reply('autopossibleinstcodes:'.$domain,$server);
next if ($response =~ /(con_lost|error|no_such_host|refused)/);
- my ($codetitlestr,$cat_title,$cat_order) = split(':',$response);
- @{$codetitles} = map { &unescape($_); } (split('&',$codetitlestr));
+ my ($codetitlestr,$codeorderstr,$cat_title,$cat_order) =
+ split(':',$response);
+ @{$codetitles} = map { &unescape($_); } (split('&',$codetitlestr));
+ @{$code_order} = map { &unescape($_); } (split('&',$codeorderstr));
foreach my $item (split('&',$cat_title)) {
my ($name,$value)=split('=',$item);
$cat_titles->{&unescape($name)}=&thaw_unescape($value);
_______________________________________________
LON-CAPA-cvs mailing list
LON-CAPA-cvs@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic