[LON-CAPA-cvs] cvs: loncom /enrollment Autoenroll.pl /interface loncreatecourse.pm lonmodifycourse.pm lonpopulate.pm /lonnet/perl lonnet.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 09 Jun 2004 17:01:56 -0000
This is a MIME encoded message
--raeburn1086800516
Content-Type: text/plain
raeburn Wed Jun 9 13:01:56 2004 EDT
Modified files:
/loncom/interface loncreatecourse.pm lonmodifycourse.pm
lonpopulate.pm
/loncom/enrollment Autoenroll.pl
/loncom/lonnet/perl lonnet.pm
Log:
Fix bug #3062
--raeburn1086800516
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040609130156.txt"
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.58 loncom/interface/loncreatecourse.pm:1.59
--- loncom/interface/loncreatecourse.pm:1.58 Tue Jun 8 18:09:44 2004
+++ loncom/interface/loncreatecourse.pm Wed Jun 9 13:01:55 2004
@@ -1,7 +1,7 @@
#meserver The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.58 2004/06/08 22:09:44 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.59 2004/06/09 17:01:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -628,7 +628,7 @@
if (@affiliates > 0) {
my @badclasses = ();
foreach my $class (@affiliates) {
- my $addcheck = &Apache::lonnet::auto_new_course($crsuhome,$class,$cenv{'internal.courseowner'});
+ my $addcheck = &Apache::lonnet::auto_new_course($crsunum,$crsudom,$class,$cenv{'internal.courseowner'});
unless ($addcheck eq 'ok') {
push @badclasses, $class;
}
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.7 loncom/interface/lonmodifycourse.pm:1.8
--- loncom/interface/lonmodifycourse.pm:1.7 Tue Jun 8 18:09:44 2004
+++ loncom/interface/lonmodifycourse.pm Wed Jun 9 13:01:55 2004
@@ -425,9 +425,6 @@
my ($r,$tasklongref,$typeref) = @_;
my $dom = $ENV{'user.domain'};
my $crs = $ENV{'form.course'};
- my $homeserver = &Apache::lonnet::homeserver($crs,$dom);
- my $server = $Apache::lonnet::perlvar{'lonHostID'};
-
unless ( &check_course($dom,$crs) eq 'ok' ) {
&print_header($r,$tasklongref);
my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain");
@@ -551,10 +548,10 @@
if ($changecode) {
foreach my $sec (@sections) {
if ($sec =~ m/^(.+):/) {
- my $course_id = $newattr{'coursecode'}.$1;
- my $course_check = &Apache::lonnet::auto_validate_courseID($homeserver,$course_id);
+ my $inst_course_id = $newattr{'coursecode'}.$1;
+ my $course_check = &Apache::lonnet::auto_validate_courseID($crs,$dom,$inst_course_id);
if ($course_check eq 'ok') {
- my $outcome = &Apache::lonnet::auto_new_course($homeserver,$course_id,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");
}
@@ -568,8 +565,8 @@
} elsif ($changeowner) {
foreach my $sec (@sections) {
if ($sec =~ m/^(.+):/) {
- my $course_id = $newattr{'coursecode'}.$1;
- my $outcome = &Apache::lonnet::auto_new_course($homeserver,$course_id,$newattr{'courseowner'});
+ my $inst_course_id = $newattr{'coursecode'}.$1;
+ my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");
}
@@ -584,7 +581,7 @@
if ( (@xlists > 0) && ($changeowner) ) {
foreach my $xlist (@xlists) {
if ($xlist =~ m/^(.+):/) {
- my $outcome = &Apache::lonnet::auto_new_course($homeserver,$1,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$1,$newattr{'courseowner'});
unless ($outcome eq 'ok') {
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for crosslisted class: ").$1.&mt(" for the following reason: $outcome.<br/>");
}
@@ -596,7 +593,7 @@
}
} else {
foreach my $attr (@params) {
- $nochgresponse .= "<li>$$typeref{$attr} ".&mt("still set to \"").$currattr{$attr}."\".</li>";
+ $nochgresponse .= "<li>$$typeref{$attr} ".&mt("still set to")." \"".$currattr{$attr}."\".</li>";
}
}
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.12 loncom/interface/lonpopulate.pm:1.13
--- loncom/interface/lonpopulate.pm:1.12 Tue Jun 8 18:09:44 2004
+++ loncom/interface/lonpopulate.pm Wed Jun 9 13:01:56 2004
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.12 2004/06/08 22:09:44 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.13 2004/06/09 17:01:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -207,7 +207,7 @@
###############################################################
sub print_main_frame {
- my ($r,$realm,$dom,$crs,$tasktitleref,$homeserver,$server) = @_;
+ my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
my $action = "information";
if (exists($ENV{'form.action'}) ) {
$action = $ENV{'form.action'};
@@ -642,7 +642,7 @@
");
} elsif ($action eq "sections") {
my @sections = ();
- @sections = &Apache::lonnet::auto_get_sections($homeserver,$enrollvar{coursecode});
+ @sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
my @storedsections = ();
my @currsections = ();
my %sec_id = ();
@@ -1157,7 +1157,7 @@
}
sub print_crosslistings_menu () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref,$homeserver,$server) = @_;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
my @currxlists = ();
my @xlists = ();
@@ -1260,7 +1260,7 @@
}
sub print_crosslistings_response () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref,$homeserver,$server) = @_;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
my @currxlists = ();
my @xlists = ();
@@ -1291,18 +1291,10 @@
my $gp = "newgroupid_".$i;
if ( exists($ENV{"form.$xl"}) ) {
my $coursecheck = '';
-# if ($homeserver eq $server) {
-# $coursecheck = &localenroll::validate_courseID($ENV{"form.$xl"});
-# } else {
- $coursecheck = &Apache::lonnet::auto_validate_courseID($homeserver,$ENV{"form.$xl"});
-# }
+ $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$ENV{"form.$xl"});
if ($coursecheck eq 'ok') {
my $addcheck = '';
-# if ($homeserver eq $server) {
-# $addcheck = &localenroll::new_course($ENV{"form.$xl"},$owner);
-# } else {
- $addcheck = &Apache::lonnet::auto_new_course($homeserver,$ENV{"form.$xl"},$owner);
-# }
+ $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$ENV{"form.$xl"},$owner);
if ($addcheck eq 'ok') {
push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
} else {
@@ -1382,7 +1374,7 @@
}
sub print_sections_menu () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref,$homeserver,$server) = @_;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
my @currsections = ();
my @sections = ();
@@ -1421,19 +1413,9 @@
$seccount ++;
} else {
my $newsec = $coursecode.$ENV{"form.$secnum"};
- my $coursecheck = '';
-# if ($homeserver eq $server) {
-# $coursecheck = &localenroll::validate_courseID($newsec);
-# } else {
- $coursecheck = &Apache::lonnet::auto_validate_courseID($homeserver,$newsec);
-# }
+ my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
if ($coursecheck eq 'ok') {
- my $addcheck = '';
-# if ($homeserver eq $server) {
-# $addcheck = &localenroll::new_course($newsec,$owner);
-# } else {
- $addcheck = &Apache::lonnet::auto_new_course($homeserver,$newsec,$owner);
-# }
+ my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
if ($addcheck eq 'ok') {
push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
$seccount ++;
@@ -1576,7 +1558,7 @@
}
sub print_sections_response () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref,$homeserver,$server) = @_;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
my @currsections = ();
my @sections = ();
@@ -1608,19 +1590,9 @@
if ( exists($ENV{"form.$sec"}) ) {
unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
my $newsec = $coursecode.$ENV{"form.$sec"};
- my $coursecheck = '';
-# if ($homeserver eq $server) {
-# $coursecheck = &localenroll::validate_courseID($newsec);
-# } else {
- $coursecheck = &Apache::lonnet::auto_validate_courseID($homeserver,$newsec);
-# }
+ my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
if ($coursecheck eq 'ok') {
- my $addcheck = '';
-# if ($homeserver eq $server) {
-# $addcheck = &localenroll::new_course($newsec,$owner);
-# } else {
- $addcheck = &Apache::lonnet::auto_new_course($homeserver,$newsec,$owner);
-# }
+ my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
if ($addcheck eq 'ok') {
push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
} else {
@@ -1722,7 +1694,7 @@
}
sub print_update_result () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref,$homeserver,$server) = @_;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
my $response = '';
my $updateadds = 0;
my $updatedrops = 0;
@@ -1794,11 +1766,7 @@
if (@allcourses > 0) {
@{$affiliates{$crs}} = @allcourses;
-# if ($homeserver eq $server) {
-# &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);
-# } else {
- &Apache::lonnet::fetch_enrollment_query($homeserver,$dom,\%affiliates,\%reply);
-# }
+ my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$crs,$dom);
if ($reply{$crs} > 0) {
($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
} else {
@@ -2040,10 +2008,6 @@
}
}
-# Determine course home server and current server
- my $homeserver = &Apache::lonnet::homeserver($crs,$dom);
- my $server = $Apache::lonnet::perlvar{'lonHostID'};
-
my $reply = 0;
unless ($state eq "choose") { $reply = 1; }
@@ -2051,7 +2015,7 @@
&print_navmenu($r,\@tasks,\%tasklong);
if (($state eq "choose") || ($action eq "information")) {
- &print_main_frame($r,$realm,$dom,$crs,\%tasktitle,$homeserver,$server);
+ &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
} elsif ($action eq "chgsettings") {
&print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "setdates") {
@@ -2059,17 +2023,17 @@
} elsif ($action eq "notify") {
&print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "sections") {
- &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle,$homeserver,$server);
+ &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "crosslist") {
- &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle,$homeserver,$server);
+ &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "updatenow") {
- &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle,$homeserver,$server);
+ &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "photos") {
&print_photos_response($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "newcross") {
- &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle,$homeserver,$server);
+ &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
} elsif ($action eq "newsections") {
- &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle,$homeserver,$server);
+ &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
}
&print_doc_base($r);
return OK;
Index: loncom/enrollment/Autoenroll.pl
diff -u loncom/enrollment/Autoenroll.pl:1.9 loncom/enrollment/Autoenroll.pl:1.10
--- loncom/enrollment/Autoenroll.pl:1.9 Tue Jun 8 18:09:44 2004
+++ loncom/enrollment/Autoenroll.pl Wed Jun 9 13:01:56 2004
@@ -1,7 +1,7 @@
#!/usr/bin/perl
#
#Automated Enrollment script
-# $Id: Autoenroll.pl,v 1.9 2004/06/08 22:09:44 raeburn Exp $
+# $Id: Autoenroll.pl,v 1.10 2004/06/09 17:01:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -113,7 +113,7 @@
}
}
}
- my $outcome = &Apache::lonnet::fetch_enrollment_query($hostid,$dom,\%affiliates,\%reply);
+ my $outcome = &Apache::lonnet::fetch_enrollment_query('automated',$dom,\%affiliates,\%reply);
# Now go through classes and perform required enrollment changes.
open (my $fh,">>$logfile");
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.507 loncom/lonnet/perl/lonnet.pm:1.508
--- loncom/lonnet/perl/lonnet.pm:1.507 Wed Jun 9 10:57:30 2004
+++ loncom/lonnet/perl/lonnet.pm Wed Jun 9 13:01:56 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.507 2004/06/09 14:57:30 www Exp $
+# $Id: lonnet.pm,v 1.508 2004/06/09 17:01:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3054,14 +3054,20 @@
return get_query_reply($queryid);
}
-# ------- Request retrieval of institutional classlists from course homerserver
+# ------- Request retrieval of institutional classlists for course(s)
sub fetch_enrollment_query {
- my ($homeserver,$dom,$affiliatesref,$replyref) = @_;
+ my ($context,$affiliatesref,$replyref,$cnum,$dom) = @_;
+ my $homeserver;
+ if ($context eq 'automated') {
+ $homeserver = $perlvar{'lonHostID'};
+ } else {
+ $homeserver = &homeserver($cnum,$dom);
+ }
my $host=$hostname{$homeserver};
my $cmd = '';
foreach (keys %{$affiliatesref}) {
- $cmd .= $_.'='.join(",",@{$$affiliatesref{$_}}).'%%';
+ $cmd .= $_.'='.join(",",@{$$affiliatesref{$_}}).'%%';
}
$cmd =~ s/%%$//;
$cmd = &escape($cmd);
@@ -3143,15 +3149,17 @@
#--------- Call auto-enrollment subs in localenroll.pm for homeserver for course
sub auto_run {
- my $homeserver = shift;
+ my ($cnum,$cdom) = @_;
+ my $homeserver = &homeserver($cnum,$cdom);
my $response = &reply('autorun',$homeserver);
return $response;
}
sub auto_get_sections {
- my ($homeserver,$coursecode) = @_;
+ my ($cnum,$cdom,$inst_coursecode) = @_;
+ my $homeserver = &homeserver($cnum,$cdom);
my @secs = ();
- my $response=&unescape(&reply('autogetsections:'.$coursecode,$homeserver));
+ my $response=&unescape(&reply('autogetsections:'.$inst_coursecode,$homeserver));
unless ($response eq 'refused') {
@secs = split/:/,$response;
}
@@ -3159,19 +3167,22 @@
}
sub auto_new_course {
- my ($homeserver,$course_id,$owner) = @_;
- my $response=&unescape(&reply('autonewcourse:'.$course_id.':'.$owner,$homeserver));
+ my ($cnum,$cdom,$inst_course_id,$owner) = @_;
+ my $homeserver = &homeserver($cnum,$cdom);
+ my $response=&unescape(&reply('autonewcourse:'.$inst_course_id.':'.$owner,$homeserver));
return $response;
}
sub auto_validate_courseID {
- my ($homeserver,$course_id) = @_;
- my $response=&unescape(&reply('autovalidatecourse:'.$course_id,$homeserver));
+ my ($cnum,$cdom,$inst_course_id) = @_;
+ my $homeserver = &homeserver($cnum,$cdom);
+ my $response=&unescape(&reply('autovalidatecourse:'.$inst_course_id,$homeserver));
return $response;
}
sub auto_create_password {
- my ($homeserver,$authparam) = @_;
+ my ($cnum,$cdom,$authparam) = @_;
+ my $homeserver = &homeserver($cnum,$cdom);
my $create_passwd = 0;
my $authchk = '';
my $response=&unescape(&reply('autocreatepassword:'.$authparam,$homeserver));
--raeburn1086800516--