[LON-CAPA-cvs] cvs: loncom / lond /enrollment localenroll.pm /interface loncreatecourse.pm lonmodifycourse.pm lonpickcourse.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Tue, 11 Jul 2006 02:28:28 -0000
This is a MIME encoded message
--raeburn1152584908
Content-Type: text/plain
raeburn Mon Jul 10 22:28:28 2006 EDT
Modified files:
/loncom lond
/loncom/interface loncreatecourse.pm lonmodifycourse.pm
lonpickcourse.pm
/loncom/enrollment localenroll.pm
Log:
Bug 4813. Retain backwards compatibility with legacy courses in which only a course owner's username is stored in environment.internal.courseowner, and in the course's record in nohist_courseids.db. New courses will include username:domain (escaped) in nohist_courseids.db. MCRS can be used to update legacy course owner information (just click "Modify Settings" button, it will be necessary to select the correct course owner where the course domain is different from the owner's domain.
--raeburn1152584908
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060710222828.txt"
Index: loncom/lond
diff -u loncom/lond:1.335 loncom/lond:1.336
--- loncom/lond:1.335 Tue Jun 27 15:01:19 2006
+++ loncom/lond Mon Jul 10 22:28:17 2006
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.335 2006/06/27 19:01:19 albertel Exp $
+# $Id: lond,v 1.336 2006/07/11 02:28:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.335 $'; #' stupid emacs
+my $VERSION='$Revision: 1.336 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -3336,12 +3336,11 @@
# institutional code - optional supplied code to filter
# the dump. Only courses with an institutional code
# that match the supplied code will be returned.
-# owner - optional supplied username of owner to filter
-# the dump. Only courses for which the course
-# owner matches the supplied username will be
-# returned. Implicit assumption that owner
-# is a user in the domain in which the
-# course database is defined.
+# owner - optional supplied username and domain of owner to
+# filter the dump. Only courses for which the course
+# owner matches the supplied username and/or domain
+# will be returned. Pre-2.2.0 legacy entries from
+# nohist_courseiddump will only contain usernames.
# $client - The socket open on the client.
# Returns:
# 1 - Continue processing.
@@ -3364,11 +3363,22 @@
} else {
$instcodefilter='.';
}
+ my ($ownerunamefilter,$ownerdomfilter);
if (defined($ownerfilter)) {
$ownerfilter=&unescape($ownerfilter);
+ if ($ownerfilter ne '.' && defined($ownerfilter)) {
+ if ($ownerfilter =~ /^([^:]*):([^:]*)$/) {
+ $ownerunamefilter = $1;
+ $ownerdomfilter = $2;
+ } else {
+ $ownerunamefilter = $ownerfilter;
+ $ownerdomfilter = '';
+ }
+ }
} else {
$ownerfilter='.';
}
+
if (defined($coursefilter)) {
$coursefilter=&unescape($coursefilter);
} else {
@@ -3405,8 +3415,37 @@
}
unless ($ownerfilter eq '.' || !defined($ownerfilter)) {
my $unescapeOwner = &unescape($owner);
- unless (eval('$unescapeOwner=~/\Q$ownerfilter\E/i')) {
- $match = 0;
+ if (($ownerunamefilter ne '') && ($ownerdomfilter ne '')) {
+ if ($unescapeOwner =~ /:/) {
+ if (eval('$unescapeOwner !~
+ /\Q$ownerunamefilter\E:\Q$ownerdomfilter\E$/i')) {
+ $match = 0;
+ }
+ } else {
+ if (eval('$unescapeOwner!~/\Q$ownerunamefilter\E/i')) {
+ $match = 0;
+ }
+ }
+ } elsif ($ownerunamefilter ne '') {
+ if ($unescapeOwner =~ /:/) {
+ if (eval('$unescapeOwner!~/\Q$ownerunamefilter\E:[^:]+$/i')) {
+ $match = 0;
+ }
+ } else {
+ if (eval('$unescapeOwner!~/\Q$ownerunamefilter\E/i')) {
+ $match = 0;
+ }
+ }
+ } elsif ($ownerdomfilter ne '') {
+ if ($unescapeOwner =~ /:/) {
+ if (eval('$unescapeOwner!~/^[^:]+:\Q$ownerdomfilter\E/')) {
+ $match = 0;
+ }
+ } else {
+ if ($ownerdomfilter ne $udom) {
+ $match = 0;
+ }
+ }
}
}
unless ($coursefilter eq '.' || !defined($coursefilter)) {
@@ -4100,6 +4139,7 @@
my $userinput = "$cmd:$tail";
my ($inst_course_id, $owner, $cdom) = split(/:/, $tail);
+ $owner = &unescape($owner);
my $outcome = &localenroll::new_course($inst_course_id,$owner,$cdom);
&Reply($client, "$outcome\n", $userinput);
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.93 loncom/interface/loncreatecourse.pm:1.94
--- loncom/interface/loncreatecourse.pm:1.93 Tue Jun 27 17:28:13 2006
+++ loncom/interface/loncreatecourse.pm Mon Jul 10 22:28:22 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.93 2006/06/27 21:28:13 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.94 2006/07/11 02:28:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -832,7 +832,7 @@
clonecourse => $env{'form.clonecourse'},
clonedomain => $env{'form.clonedomain'},
crsid => $env{'form.crsid'},
- curruser => $env{'user.name'},
+ curruser => $env{'user.name'}.':'.$env{'user.domain'},
crssections => $env{'form.crssections'},
crsxlist => $env{'form.crsxlist'},
autoadds => $env{'form.autoadds'},
@@ -917,13 +917,14 @@
my $crstype = lc($args->{'crstype'});
my %cenv=();
$$courseid=&Apache::lonnet::createcourse($args->{'course_domain'},
- $args->{'cdescr'},
- $args->{'curl'},
- $args->{'course_home'},
- $args->{'nonstandard'},
- $args->{'crscode'},
- $args->{'ccuname'},
- $args->{'crstype'});
+ $args->{'cdescr'},
+ $args->{'curl'},
+ $args->{'course_home'},
+ $args->{'nonstandard'},
+ $args->{'crscode'},
+ $args->{'ccuname'}.':'.
+ $args->{'ccdomain'},
+ $args->{'crstype'});
# Note: The testing routines depend on this being output; see
# Utils::Course. This needs to at least be output as a comment
@@ -987,7 +988,8 @@
$cenv{'internal.coursequota'}=$args->{'crsquota'} = 20;
}
if ($args->{'ccuname'}) {
- $cenv{'internal.courseowner'} = $args->{'ccuname'};
+ $cenv{'internal.courseowner'} = $args->{'ccuname'}.
+ ':'.$args->{'ccdomain'};
} else {
$cenv{'internal.courseowner'} = $args->{'curruser'};
}
@@ -1046,7 +1048,7 @@
my @notified = ();
if ($args->{'notify_owner'}) {
if ($args->{'ccuname'} ne '') {
- push(@notified,$args->{'ccuname'}.'@'.$args->{'ccdomain'});
+ push(@notified,$args->{'ccuname'}.':'.$args->{'ccdomain'});
}
}
if ($args->{'notify_dc'}) {
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.25 loncom/interface/lonmodifycourse.pm:1.26
--- loncom/interface/lonmodifycourse.pm:1.25 Tue May 30 08:46:09 2006
+++ loncom/interface/lonmodifycourse.pm Mon Jul 10 22:28:22 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# automated enrollment course setup handler
#
-# $Id: lonmodifycourse.pm,v 1.25 2006/05/30 12:46:09 www Exp $
+# $Id: lonmodifycourse.pm,v 1.26 2006/07/11 02:28:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,7 +51,7 @@
);
# Determine the courses
- my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.');
+ my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',undef,undef,'.');
&print_header($r,$tasklongref);
$r->print(<<ENDBLOCK);
<form action="/adm/modifycourse" method="post" name="cmod">
@@ -104,6 +104,9 @@
if ($courseIDs{$item} =~ /^([^:]*):([^:]*):([^:]*)/) {
$description = &unescape($1);
$owner = &unescape($3);
+ if (($owner ne '') && ($owner !~ /^([^:]+):([^:]+)$/)) {
+ $owner = $owner.':'.$dom;
+ }
} elsif ($courseIDs{$item} =~ /^([^:]*):([^:]*)$/) {
$description = &unescape($1);
} else {
@@ -117,7 +120,16 @@
}
}
unless ($owner eq '') {
- $ownername = &Apache::loncommon::plainname($owner,$dom);
+ my ($owneruname,$ownerdom);
+ if ($owner =~ /^([^:]+):([^:]+)$/) {
+ $owneruname = $1;
+ $ownerdom = $2;
+ } else {
+ $owneruname = $owner;
+ $ownerdom = $dom;
+ }
+ $ownername = &Apache::loncommon::plainname($owneruname,
+ $ownerdom);
}
$r->print("<option value=\"$crs\">$showcode -- $description ---------- $ownername");
}
@@ -166,7 +178,7 @@
'noen' => "No end date",
'ownr' => "Owner",
'name' => "Name",
- 'unme' => "Username",
+ 'unme' => "Username:Domain",
'stus' => "Status",
'aecs' => "Automated Enrollment Course Settings",
'cose' => "Course settings for LON-CAPA courses that control automated student enrollment based on classlist data available from your institution's student information system fall into two groups: (a) settings that can be modified by a Course Coordinator using the ",
@@ -214,10 +226,18 @@
} elsif ($type eq "sectionums") {
$enrollvar{$type} = $settings{$item};
$enrollvar{$type} =~ s/,/, /g;
- } elsif ($type eq "courseowner" || $type eq "authtype"
+ } elsif ($type eq "authtype"
|| $type eq "autharg" || $type eq "coursecode"
|| $type eq "crosslistings") {
$enrollvar{$type} = $settings{$item};
+ } elsif ($type eq 'courseowner') {
+ if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
+ $enrollvar{$type} = $settings{$item};
+ } else {
+ if ($settings{$item} ne '') {
+ $enrollvar{$type} = $settings{$item}.':'.$dom;
+ }
+ }
}
} elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
my $type = $1;
@@ -236,23 +256,31 @@
my %cc_status = ();
my %pname = ();
my $active_cc;
- foreach (@coursepersonnel) {
- my @roleinfo = split/:/,$_;
- if ( ($roleinfo[0] eq 'cc') && ($roleinfo[2] eq $dom) ) {
- unless (grep/^$roleinfo[1]$/,@local_ccs) {
- $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc');
+ foreach my $person (@coursepersonnel) {
+ my ($role,$user) = split(/:/,$person,2);
+ $user =~ s/:$//;
+ if (($role eq 'cc') && ($user ne '')) {
+ if (!grep(/^\Q$user\E$/,@local_ccs)) {
+ my ($ccname,$ccdom) = split(/:/,$user);
+ $active_cc =
+ &Apache::loncommon::check_user_status($ccdom,$ccname,$dom,
+ $course,'cc');
if ($active_cc eq 'active') {
- push @local_ccs, $roleinfo[1];
- $pname{$roleinfo[1]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
- $cc_status{$roleinfo[1]} = $lt{'actv'};
+ push(@local_ccs,$user);
+ $pname{$user} = &Apache::loncommon::plainname($ccname,$ccdom);
+ $cc_status{$user} = $lt{'actv'};
}
}
}
}
- unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') ) {
- push @local_ccs, $enrollvar{'courseowner'};
- $pname{$enrollvar{'courseowner'}} = &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);
- $active_cc = &Apache::loncommon::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');
+ if ( (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs)) &&
+ ($enrollvar{'courseowner'} ne '') ) {
+ my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
+ push(@local_ccs,$enrollvar{'courseowner'});
+ $pname{$enrollvar{'courseowner'}} =
+ &Apache::loncommon::plainname($owneruname,$ownerdom);
+ $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
+ $dom,$course,'cc');
if ($active_cc eq 'active') {
$cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
} else {
@@ -350,7 +378,7 @@
my $colflag = $i%2;
$ownertable .= "<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">";
if ($local_ccs[$i] eq $enrollvar{'courseowner'}) {
- $ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$local_ccs[$i]\" checked=\"true\"/></td>";
+ $ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$local_ccs[$i]\" checked=\"checked\" /></td>";
} else {
$ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$local_ccs[$i]\" /></td>";
}
@@ -705,7 +733,7 @@
sub check_course {
my ($dom,$course) = @_;
- my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.');
+ my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',undef,undef,'.');
foreach my $key (sort keys %courseIDs) {
if ($key =~ m/^($dom)_(\w+)$/) {
if ($2 eq $course) {
@@ -741,7 +769,7 @@
'default_enrollment_start_date' => 'Date of first student access',
'default_enrollment_end_date' => 'Date of last student access',
'coursecode' => 'Official course code',
- 'courseowner' => "Username of course owner (\@$dom)",
+ 'courseowner' => "Username:domain of course owner",
'notifylist' => 'Course Coordinators to be notified of enrollment changes',
'sectionnums' => 'Course section number(:groupID)',
'crosslistings' => 'Crosslisted class(:groupID)',
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.51 loncom/interface/lonpickcourse.pm:1.52
--- loncom/interface/lonpickcourse.pm:1.51 Mon Jul 3 00:00:34 2006
+++ loncom/interface/lonpickcourse.pm Mon Jul 10 22:28:22 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a course
#
-# $Id: lonpickcourse.pm,v 1.51 2006/07/03 04:00:34 albertel Exp $
+# $Id: lonpickcourse.pm,v 1.52 2006/07/11 02:28:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -53,7 +53,7 @@
'cdomelement','cnameelement','roleelement',
'pickedcourse','instcodefilter',
'ownerfilter','coursefilter','multiple',
- 'type']);
+ 'type','ownerdomfilter']);
# domain filter and selection
my $domainfilter=$env{'form.domainfilter'};
$domainfilter=~s/\W//g;
@@ -70,8 +70,13 @@
my $listinstcode=&HTML::Entities::encode($instcodefilter,'<>&"');
# course owner filter
my $ownerfilter=$env{'form.ownerfilter'};
- unless ($ownerfilter) { $ownerfilter=''; }
+ $ownerfilter=~s/\W//g;
my $listowner=&HTML::Entities::encode($ownerfilter,'<>&"');
+# course ownerdomain filter
+ my $ownerdomfilter=$env{'form.ownerdomfilter'};
+ $ownerdomfilter=~s/\W//g;
+ my $ownerdomselectform=
+ &Apache::loncommon::select_dom_form($ownerdomfilter,'ownerdomfilter',1);
# course ID filter for DCs only
my ($courseidtag,$coursefilter);
if ($env{'user.adv'} && $domainfilter && exists($env{'user.role.dc./'.
@@ -243,6 +248,7 @@
'cdo' => &mt('[_1] Domain',$type),
'cin' => &mt('Course Institutional Code'),
'cow' => &mt("[_1] Owner's Username",$type),
+ 'cod' => &mt("[_1] Owner's Domain", $type),
'cog' => &mt('Course or Group')
);
@@ -275,7 +281,6 @@
$instcodeform = $lt{'cin'}.': <input type="text" name="instcodefilter"
size="10" value="'.$listinstcode.'" /><br />';
}
-
my %elements = (
Course => {
name => 'coursepick',
@@ -403,6 +408,8 @@
$lt{'cow'}:
<input type="text" name="ownerfilter" size="10" value="$listowner" />
<br />
+$lt{'cod'}: $ownerdomselectform
+<br />
$courseidtag
$lt{'cde'}:
<input type="text" name="descriptfilter" size="40" value="$listdescript" />
@@ -416,13 +423,17 @@
$r->rflush();
unless ($descriptfilter) { $descriptfilter='.'; }
unless ($instcodefilter) { $instcodefilter='.'; }
- unless ($ownerfilter) { $ownerfilter='.'; }
- unless ($coursefilter) { $coursefilter='.'; }
- unless ($type) { $type = '.'; }
+ my $combownerfilter;
+ if (($ownerfilter ne '') || ($ownerdomfilter ne '')) {
+ $combownerfilter = $ownerfilter.':'.$ownerdomfilter;
+ }
+ if ($combownerfilter eq '') { $combownerfilter='.'; }
+ if ($coursefilter eq '') { $coursefilter='.'; }
+ if ($type eq '') { $type = '.'; }
my $timefilter=($sincefilter==-1?1:time-$sincefilter);
- my %courses=
- &Apache::lonnet::courseiddump
- ($domainfilter,$descriptfilter,$timefilter,$instcodefilter,$ownerfilter,$coursefilter,undef,undef,$type);
+ my %courses = &Apache::lonnet::courseiddump($domainfilter,$descriptfilter,
+ $timefilter,$instcodefilter,$combownerfilter,
+ $coursefilter,undef,undef,$type);
$r->print('<form name="courselist" method="post" action="/adm/pickcourse">');
my %by_descrip;
my $numcourses = keys(%courses);
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.14 loncom/enrollment/localenroll.pm:1.15
--- loncom/enrollment/localenroll.pm:1.14 Thu Feb 9 21:38:46 2006
+++ loncom/enrollment/localenroll.pm Mon Jul 10 22:28:27 2006
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.14 2006/02/10 02:38:46 raeburn Exp $
+# $Id: localenroll.pm,v 1.15 2006/07/11 02:28:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -204,8 +204,9 @@
# (a) the institutional courseID (in the MSU case this is a concatenation of
# semester code, department code, course number, and section number
# e.g., fs03nop590001).
-# (b) the course owner. This is the LON-CAPA username of the course coordinator
-# assigned to the course when it is first created.
+# (b) the course owner. This is the LON-CAPA username and domain of the course
+# coordinator assigned to the course when it is first created, in the form
+# username:domain
# (c) the LON-CAPA domain that contains the course
#
#################################
--raeburn1152584908--