[LON-CAPA-cvs] cvs: modules /msu localenroll.pm loncom lond loncom/enrollment localenroll.pm loncom/interface lonrequestcourse.pm loncom/lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Sun, 13 Sep 2009 03:14:30 -0000
This is a MIME encoded message
--raeburn1252811670
Content-Type: text/plain
raeburn Sun Sep 13 03:14:30 2009 EDT
Modified files:
/loncom lond
/loncom/lonnet/perl lonnet.pm
/loncom/interface lonrequestcourse.pm
/loncom/enrollment localenroll.pm
/modules/msu localenroll.pm
Log:
- &Apache::lonnet::auto_validate_instcode() now returns an array containing:
- the outcome ('valid' - or some other message) and
- an (optional) brief description for the course retrieved from
localenroll::validate_instcode() which likewise returns an array of 2 items.
- Used to set cdescr form element in the course request form for official courses when the instcode has been validated.
--raeburn1252811670
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090913031430.txt"
Index: loncom/lond
diff -u loncom/lond:1.425 loncom/lond:1.426
--- loncom/lond:1.425 Mon Aug 24 20:08:31 2009
+++ loncom/lond Sun Sep 13 03:13:21 2009
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.425 2009/08/24 20:08:31 raeburn Exp $
+# $Id: lond,v 1.426 2009/09/13 03:13:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.425 $'; #' stupid emacs
+my $VERSION='$Revision: 1.426 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -4745,8 +4745,10 @@
my ($dom,$instcode,$owner) = split(/:/, $tail);
$instcode = &unescape($instcode);
$owner = &unescape($owner);
- my $outcome=&localenroll::validate_instcode($dom,$instcode,$owner);
- &Reply($client, \$outcome, $userinput);
+ my ($outcome,$description) =
+ &localenroll::validate_instcode($dom,$instcode,$owner);
+ my $result = &escape($outcome).'&'.&escape($description);
+ &Reply($client, \$result, $userinput);
return 1;
}
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1026 loncom/lonnet/perl/lonnet.pm:1.1027
--- loncom/lonnet/perl/lonnet.pm:1.1026 Sat Sep 5 20:44:01 2009
+++ loncom/lonnet/perl/lonnet.pm Sun Sep 13 03:13:38 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1026 2009/09/05 20:44:01 raeburn Exp $
+# $Id: lonnet.pm,v 1.1027 2009/09/13 03:13:38 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5613,7 +5613,8 @@
}
my $response=&unescape(&reply('autovalidateinstcode:'.$cdom.':'.
&escape($instcode).':'.&escape($owner),$homeserver));
- return $response;
+ my ($outcome,$description) = map { &unescape($_); } split('&',$response,2);
+ return ($outcome,$description);
}
sub auto_create_password {
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.35 loncom/interface/lonrequestcourse.pm:1.36
--- loncom/interface/lonrequestcourse.pm:1.35 Fri Sep 11 12:53:10 2009
+++ loncom/interface/lonrequestcourse.pm Sun Sep 13 03:13:55 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.35 2009/09/11 12:53:10 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.36 2009/09/13 03:13:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -178,7 +178,7 @@
$trail{'enrollment'} = 'Enrollment';
}
- my ($page,$crumb,$newinstcode,$codechk,$checkedcode) =
+ my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
if ($action eq 'display') {
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
@@ -239,7 +239,7 @@
$crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};
}
if ($crosslistcode ne '') {
- $codechk{$i} =
+ ($codechk{$i}, my $rest) =
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
}
unless ($codechk{$i} eq 'valid') {
@@ -286,7 +286,8 @@
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,
$jscript,$loaditems,$crumb,$newinstcode,
- $codechk,$checkedcode,\@invalidcrosslist);
+ $codechk,$checkedcode,$description,
+ \@invalidcrosslist);
}
} else {
$r->print(&header('Course Requests').$crumb.
@@ -310,7 +311,7 @@
&close_popup_form());
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb,'','','','',$uname,$udom);
+ $loaditems,$crumb,'','','','','',$uname,$udom);
}
} elsif ($action eq 'log') {
&print_request_logs($jscript,$loaditems,$crumb);
@@ -346,7 +347,7 @@
sub get_breadcrumbs {
my ($dom,$action,$state,$states,$trail) = @_;
- my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles);
+ my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
my $page = 0;
if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) {
if (defined($action)) {
@@ -371,7 +372,7 @@
$$state = 'codepick';
$page --;
} else {
- $codechk =
+ ($codechk,$description) =
&Apache::lonnet::auto_validate_instcode('',
$dom,$newinstcode);
if ($codechk ne 'valid') {
@@ -416,7 +417,7 @@
{text=>'Pick Action'});
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
}
- return ($page,$crumb,$newinstcode,$codechk,$checkedcode);
+ return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
}
sub header {
@@ -778,7 +779,8 @@
sub request_administration {
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
- $newinstcode,$codechk,$checkedcode,$invalidcrosslist,$uname,$udom) = @_;
+ $newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist,
+ $uname,$udom) = @_;
my $js;
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
$js = <<END;
@@ -814,7 +816,7 @@
}
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb);
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,
- $codechk,$checkedcode,$invalidcrosslist);
+ $codechk,$checkedcode,$description,$invalidcrosslist);
} elsif ($action eq 'view') {
my $jsextra;
my $formname = 'requestcrs';
@@ -1126,7 +1128,7 @@
sub print_request_form {
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
- $invalidcrosslist) = @_;
+ $description,$invalidcrosslist) = @_;
my $formname = 'requestcrs';
my ($next,$prev,$message,$output,$codepicker,$crstype);
$prev = $states->{$action}[$page-1];
@@ -1191,7 +1193,7 @@
if ($instcode eq '') {
$prev = $states->{$action}[$page-2];
}
- $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
+ $r->print(&courseinfo_form($dom,$formname,$crstype,$next,$description));
} elsif ($state eq 'enrollment') {
if ($crstype eq 'official') {
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
@@ -2238,7 +2240,7 @@
}
sub courseinfo_form {
- my ($dom,$formname,$crstype,$next) = @_;
+ my ($dom,$formname,$crstype,$next,$description) = @_;
my %lt = &Apache::lonlocal::texthash(
official => 'You must provide a (brief) course description.',
community => 'You must provide a (brief) community description.'
@@ -2268,7 +2270,7 @@
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'</h3>'.
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::row_title(&mt('Description')).
- '<input type="text" size="40" name="cdescr" />';
+ '<input type="text" size="60" name="cdescr" value="'.$description.'" />';
my ($home_server_pick,$numlib) =
&Apache::loncommon::home_server_form_item($dom,'chome',
'default','hide');
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.38 loncom/enrollment/localenroll.pm:1.39
--- loncom/enrollment/localenroll.pm:1.38 Sat Aug 22 19:52:13 2009
+++ loncom/enrollment/localenroll.pm Sun Sep 13 03:14:12 2009
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.38 2009/08/22 19:52:13 raeburn Exp $
+# $Id: localenroll.pm,v 1.39 2009/09/13 03:14:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -290,20 +290,25 @@
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 'valid'.
-
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.
+An array is returned containing (a) the result of the check for a valid
+instcode, and (b) an (optional) course description.
+A valid instcode is confirmed by returning 'valid'.
+If no course description is available, '' should be set as
+the value of the second item in the returned array.
+
=cut
sub validate_instcode {
my ($dom,$instcode,$owner) = @_;
my $outcome = '';
- return $outcome;
+ my $description = '';
+ return ($outcome,$description);
}
=pod
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.44 modules/msu/localenroll.pm:1.45
--- modules/msu/localenroll.pm:1.44 Fri Sep 4 00:11:13 2009
+++ modules/msu/localenroll.pm Sun Sep 13 03:14:30 2009
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.44 2009/09/04 00:11:13 raeburn Exp $
+# $Id: localenroll.pm,v 1.45 2009/09/13 03:14:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -299,6 +299,12 @@
sub validate_instcode {
my ($dom,$instcode,$owner) = @_;
my $outcome = '';
+ my $description = '';
+ my %longsem = (
+ fs => 'Fall',
+ ss => 'Spring',
+ us => 'Summer',
+ );
if ($instcode =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)$/) {
my $term = $1;
my $subj = $2;
@@ -337,6 +343,7 @@
$database = 'SIS';
($dbh,$dbflag) = &connect_DB('SIS');
if ($dbflag) {
+ my ($quotedsubj,$quotedcrse,$quotedterm);
eval {
my $quotedsubj = $dbh->quote($subj);
my $quotedcrse = $dbh->quote($crse);
@@ -344,6 +351,17 @@
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 = 'valid';
+ eval {
+ $description = $dbh->selectrow_array( "SELECT DISTINCT(Crse_Title) FROM SISCRSD WHERE (Subj_Code = $quotedsubj AND Crse_Code= $quotedcrse)");
+ if ($description ne '') {
+ my ($sem,$year) = ($term =~ /^([suf]s)(\d{2})$/);
+ $year =~ s/^0//;
+ my $longyr = 2000 + int($year);
+ if (defined($longsem{$sem}) && ($year)) {
+ $description = $longsem{$sem}.', '.$longyr.' - '.$description;
+ }
+ }
+ }
} else {
$outcome = "There was no match in the MSU $database database to the combination of semester ($term), subject ($subj), course number ($crse) you entered.";
}
@@ -361,7 +379,7 @@
} else {
$outcome = "One or more of the combination of semester, year, subject and course number you provided do not conform to the format used at MSU.";
}
- return $outcome;
+ return ($outcome,$description);
}
sub crsreq_checks {
--raeburn1252811670--