version 1.3, 2003/12/28 18:27:49
|
version 1.10, 2004/06/29 14:56:32
|
Line 100 ENDBLOCK
|
Line 100 ENDBLOCK
|
unless ($code =~m/^___\d+$/) { $showcode = $code; } |
unless ($code =~m/^___\d+$/) { $showcode = $code; } |
if ($item =~ m/^($dom)_(\w+)$/) { |
if ($item =~ m/^($dom)_(\w+)$/) { |
$crs = $2; |
$crs = $2; |
$description = $courseIDs{$item}; |
if ($courseIDs{$item} =~ /^([^:]*):/) { |
|
$description = &Apache::lonnet::unescape($1); |
|
} else { |
|
$description = &Apache::lonnet::unescape($courseIDs{$item}); |
|
} |
# Get course owner |
# Get course owner |
my %settings = &Apache::lonnet::get('environment',['internal.courseowner'],$dom,$crs); |
my %settings = &Apache::lonnet::get('environment',['internal.courseowner'],$dom,$crs); |
if ( defined($settings{'internal.courseowner'}) ) { |
if ( defined($settings{'internal.courseowner'}) ) { |
Line 197 all settings except course code, course
|
Line 201 all settings except course code, course
|
} else { |
} else { |
$enrollvar{$1} = localtime($settings{$item}); |
$enrollvar{$1} = localtime($settings{$item}); |
} |
} |
} else { |
} elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode" || $1 eq "crosslistings") { |
$enrollvar{$1} = $settings{$item}; |
$enrollvar{$1} = $settings{$item}; |
} |
} |
|
} elsif ($item =~ m/^default_enrollment_(start|end)_date$/) { |
|
if ( ($1 eq 'end') && ($settings{$item} == 0) ) { |
|
$enrollvar{$item} = $lt{'noen'}; |
|
} elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) { |
|
$enrollvar{$item} = 'When enrolled'; |
|
} else { |
|
$enrollvar{$item} = localtime($settings{$item}); |
|
} |
} |
} |
} |
} |
|
|
Line 222 all settings except course code, course
|
Line 234 all settings except course code, course
|
} |
} |
} |
} |
unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') ) { |
unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') ) { |
push @local_ccs, $enrollvar{'coursecode'}; |
push @local_ccs, $enrollvar{'courseowner'}; |
$pname{$enrollvar{'courseowner'}} = &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom); |
$pname{$enrollvar{'courseowner'}} = &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom); |
$active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc'); |
$active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc'); |
if ($active_cc eq 'ok') { |
if ($active_cc eq 'ok') { |
Line 279 all settings except course code, course
|
Line 291 all settings except course code, course
|
<td>$$typeref{$key}</td> |
<td>$$typeref{$key}</td> |
<td>$enrollvar{$key}</td> |
<td>$enrollvar{$key}</td> |
</tr>"; |
</tr>"; |
$iter ++; |
$iter ++; |
} |
} |
$disp_table .= "</table> |
$disp_table .= "</table> |
</td> |
</td> |
Line 418 $disp_table
|
Line 430 $disp_table
|
<br/> |
<br/> |
ENDDOCUMENT |
ENDDOCUMENT |
&print_footer($r); |
&print_footer($r); |
|
return; |
} |
} |
|
|
sub modify_course { |
sub modify_course { |
my ($r,$tasklongref,$typeref) = @_; |
my ($r,$tasklongref,$typeref) = @_; |
my $dom = $ENV{'user.domain'}; |
my $dom = $ENV{'user.domain'}; |
my $crs = $ENV{'form.course'}; |
my $crs = $ENV{'form.course'}; |
|
|
unless ( &check_course($dom,$crs) eq 'ok' ) { |
unless ( &check_course($dom,$crs) eq 'ok' ) { |
&print_header($r,$tasklongref); |
&print_header($r,$tasklongref); |
my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain"); |
my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain"); |
Line 509 sub modify_course {
|
Line 521 sub modify_course {
|
$newattr{'coursecode'}=$ENV{'form.coursecode'}; |
$newattr{'coursecode'}=$ENV{'form.coursecode'}; |
unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) { |
unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) { |
$changecode = 1; |
$changecode = 1; |
|
my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).'='.&Apache::lonnet::escape($ENV{'form.coursecode'}); |
|
&Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom)); |
} |
} |
} |
} |
|
|
Line 548 sub modify_course {
|
Line 562 sub modify_course {
|
if ($changecode) { |
if ($changecode) { |
foreach my $sec (@sections) { |
foreach my $sec (@sections) { |
if ($sec =~ m/^(.+):/) { |
if ($sec =~ m/^(.+):/) { |
my $course_id = $newattr{'coursecode'}.$1; |
my $inst_course_id = $newattr{'coursecode'}.$1; |
my $course_check = &localenroll::validate_courseID($course_id); |
my $course_check = &Apache::lonnet::auto_validate_courseID($crs,$dom,$inst_course_id); |
if ($course_check eq 'ok') { |
if ($course_check eq 'ok') { |
my $outcome = &localenroll::new_course($course_id,$newattr{'courseowner'}); |
my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'}); |
my $outcome = 'ok'; |
|
unless ($outcome eq 'ok') { |
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/>"); |
$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/>"); |
} |
} |
Line 563 sub modify_course {
|
Line 576 sub modify_course {
|
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>"); |
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>"); |
} |
} |
} |
} |
} |
} elsif ($changeowner) { |
|
foreach my $sec (@sections) { |
|
if ($sec =~ m/^(.+):/) { |
|
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/>"); |
|
} |
|
} else { |
|
$warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>"); |
|
} |
|
} |
|
} |
} else { |
} else { |
$warning .= &mt("As no section numbers are currently listed for LON-CAPA course: ").$description.&mt(", automated enrollment will not occur for any sections of coursecode: ").$newattr{'coursecode'}."<br/>"; |
$warning .= &mt("As no section numbers are currently listed for LON-CAPA course: ").$description.&mt(", automated enrollment will not occur for any sections of coursecode: ").$newattr{'coursecode'}."<br/>"; |
} |
} |
if ( (@xlists > 0) && ($changeowner) ) { |
if ( (@xlists > 0) && ($changeowner) ) { |
foreach my $xlist (@xlists) { |
foreach my $xlist (@xlists) { |
if ($xlist =~ m/^(.+):/) { |
if ($xlist =~ m/^(.+):/) { |
my $outcome = &localenroll::new_course($1,$newattr{'courseowner'}); |
my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$1,$newattr{'courseowner'}); |
unless ($outcome eq 'ok') { |
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/>"); |
$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/>"); |
} |
} |
Line 582 sub modify_course {
|
Line 607 sub modify_course {
|
} |
} |
} else { |
} else { |
foreach my $attr (@params) { |
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>"; |
} |
} |
} |
} |
|
|
Line 660 $bodytag
|
Line 685 $bodytag
|
</tr> |
</tr> |
</table> |
</table> |
ENDTHIS |
ENDTHIS |
|
return; |
} |
} |
|
|
sub print_footer { |
sub print_footer { |
my $r = shift; |
my $r = shift; |
$r->print(<<ENDBASE); |
$r->print(<<ENDBASE); |
<br/> |
<br/> |
</body> |
</body> |
</html> |
</html> |
ENDBASE |
ENDBASE |
|
return; |
} |
} |
|
|
sub check_course { |
sub check_course { |
my ($dom,$course) = @_; |
my ($dom,$course) = @_; |
my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1); |
my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1); |
my @courses = (); |
|
foreach my $key (sort keys %courseIDs) { |
foreach my $key (sort keys %courseIDs) { |
if ($key =~ m/^($dom)_(\w+)$/) { |
if ($key =~ m/^($dom)_(\w+)$/) { |
push @courses, $2; |
if ($2 eq $course) { |
|
return 'ok'; |
|
} |
} |
} |
} |
} |
if (grep/^$course$/,@courses) { |
return 'invalid course'; |
return 'ok'; |
|
} |
|
else { |
|
return 'invalid course'; |
|
} |
|
} |
} |
|
|
|
|
Line 708 sub handler {
|
Line 731 sub handler {
|
'autharg' => 'Default authentication parameter', |
'autharg' => 'Default authentication parameter', |
'autoadds' => 'Automated adds', |
'autoadds' => 'Automated adds', |
'autodrops' => 'Automated drops', |
'autodrops' => 'Automated drops', |
'autostart' => 'Date of first enrollment', |
'autostart' => 'Date of first automated enrollment', |
'autoend' => 'Date of last enrollment', |
'autoend' => 'Date of last automated enrollment', |
|
'default_enrollment_start_date' => 'Date of first student access', |
|
'default_enrollment_end_date' => 'Date of last student access', |
'coursecode' => 'Official course code', |
'coursecode' => 'Official course code', |
'courseowner' => "Username of course owner (\@$dom)", |
'courseowner' => "Username of course owner (\@$dom)", |
'notifylist' => 'Course Coordinators to be notified of enrollment changes', |
'notifylist' => 'Course Coordinators to be notified of enrollment changes', |