version 1.15, 2005/02/17 08:29:43
|
version 1.22, 2006/02/10 23:38:15
|
Line 1
|
Line 1
|
|
# The LearningOnline Network with CAPA |
|
# automated enrollment course setup handler |
|
# |
|
# $Id$ |
|
# |
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees |
# |
# |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
Line 33 use lib '/home/httpd/lib/perl';
|
Line 38 use lib '/home/httpd/lib/perl';
|
|
|
sub print_course_selection_page { |
sub print_course_selection_page { |
my ($r,$tasklongref) = @_; |
my ($r,$tasklongref) = @_; |
my $dom = $ENV{'request.role.domain'}; |
my $dom = $env{'request.role.domain'}; |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'csae' => "Course settings for automated enrollment", |
'csae' => "Course settings for automated enrollment", |
'unst' => "Unlike standard LON-CAPA course parameters, such as course description, feedback addresses, and top level map, which are displayed and/or modified using the 'Course Environment Parameters' screen, settings that control automated enrollment based on classlist data available from your institution's student information system are handled differently. Automated enrollment settings fall into two groups: (a) settings that can be modified by a Course Coordinator using the Automated Enrollment Manager and (b) settings that may only be modified by a Domain Coordinator via the 'View/Modify Course settings' menu accessed from this page.", |
'unst' => "Unlike standard LON-CAPA course parameters, such as course description, feedback addresses, and top level map, which are displayed and/or modified using the 'Course Environment Parameters' screen, settings that control automated enrollment based on classlist data available from your institution's student information system are handled differently. Automated enrollment settings fall into two groups: (a) settings that can be modified by a Course Coordinator using the Automated Enrollment Manager and (b) settings that may only be modified by a Domain Coordinator via the 'View/Modify Course settings' menu accessed from this page.", |
Line 45 sub print_course_selection_page {
|
Line 50 sub print_course_selection_page {
|
); |
); |
|
|
# Determine the courses |
# Determine the courses |
my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.'); |
my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.'); |
&print_header($r,$tasklongref); |
&print_header($r,$tasklongref); |
$r->print(<<ENDBLOCK); |
$r->print(<<ENDBLOCK); |
<form action="/adm/modifycourse" method="post" name="cmod"> |
<form action="/adm/modifycourse" method="post" name="cmod"> |
Line 132 sub print_course_modification_page {
|
Line 137 sub print_course_modification_page {
|
my %enrollvar = (); |
my %enrollvar = (); |
my $javascript_validations; |
my $javascript_validations; |
my $course = ''; |
my $course = ''; |
my $dom = $ENV{'request.role.domain'}; |
my $dom = $env{'request.role.domain'}; |
if ( defined($ENV{'form.course'}) ) { |
if ( defined($env{'form.course'}) ) { |
$course = $ENV{'form.course'}; |
$course = $env{'form.course'}; |
} |
} |
my $ok_course = 'ok'; |
my $ok_course = 'ok'; |
if ( ($course == -1) || ($course == '-2') || ($course eq '') ) { |
if ( ($course == -1) || ($course == '-2') || ($course eq '') ) { |
Line 142 sub print_course_modification_page {
|
Line 147 sub print_course_modification_page {
|
} else { |
} else { |
$ok_course = &check_course($dom,$course); |
$ok_course = &check_course($dom,$course); |
} |
} |
print STDERR "Response was $ok_course for $dom,$course\n"; |
|
|
|
unless ($ok_course eq 'ok') { |
unless ($ok_course eq 'ok') { |
&print_header($r,$tasklongref,'',\$javascript_validations); |
&print_header($r,$tasklongref,'',\$javascript_validations); |
Line 191 all settings except course code, course
|
Line 195 all settings except course code, course
|
$enrollvar{'autharg'} = ''; |
$enrollvar{'autharg'} = ''; |
$enrollvar{'authtype'} = ''; |
$enrollvar{'authtype'} = ''; |
foreach my $item (keys %settings) { |
foreach my $item (keys %settings) { |
if ($item =~ m/^internal\.(.+)$/) { |
if ($item =~ m/^internal\.(.+)$/) { |
if ( ($1 eq "autoadds") || ($1 eq "autodrops") ) { |
my $type = $1; |
|
|
|
if ( ($type eq "autoadds") || ($type eq "autodrops") ) { |
if ($settings{$item} == 1) { |
if ($settings{$item} == 1) { |
$enrollvar{$1} = "ON"; |
$enrollvar{$type} = "ON"; |
} else { |
} else { |
$enrollvar{$1} = "OFF"; |
$enrollvar{$type} = "OFF"; |
} |
} |
} elsif ( ($1 eq "autostart") || ($1 eq "autoend") ) { |
} elsif ( ($type eq "autostart") || ($type eq "autoend") ) { |
if ( ($1 eq "autoend") && ($settings{$item} == 0) ) { |
if ( ($type eq "autoend") && ($settings{$item} == 0) ) { |
$enrollvar{$1} = $lt{'noen'}; |
$enrollvar{$type} = $lt{'noen'}; |
} else { |
} else { |
$enrollvar{$1} = localtime($settings{$item}); |
$enrollvar{$type} = localtime($settings{$item}); |
} |
} |
} elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode" || $1 eq "crosslistings") { |
} elsif ($type eq "sectionums") { |
$enrollvar{$1} = $settings{$item}; |
$enrollvar{$type} = $settings{$item}; |
|
$enrollvar{$type} =~ s/,/, /g; |
|
} elsif ($type eq "courseowner" || $type eq "authtype" |
|
|| $type eq "autharg" || $type eq "coursecode" |
|
|| $type eq "crosslistings") { |
|
$enrollvar{$type} = $settings{$item}; |
} |
} |
} elsif ($item =~ m/^default_enrollment_(start|end)_date$/) { |
} elsif ($item =~ m/^default_enrollment_(start|end)_date$/) { |
if ( ($1 eq 'end') && ($settings{$item} == 0) ) { |
my $type = $1; |
|
if ( ($type eq 'end') && ($settings{$item} == 0) ) { |
$enrollvar{$item} = $lt{'noen'}; |
$enrollvar{$item} = $lt{'noen'}; |
} elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) { |
} elsif ( ($type eq 'start') && ($settings{$item} eq '') ) { |
$enrollvar{$item} = 'When enrolled'; |
$enrollvar{$item} = 'When enrolled'; |
} else { |
} else { |
$enrollvar{$item} = localtime($settings{$item}); |
$enrollvar{$item} = localtime($settings{$item}); |
Line 227 all settings except course code, course
|
Line 239 all settings except course code, course
|
my @roleinfo = split/:/,$_; |
my @roleinfo = split/:/,$_; |
if ( ($roleinfo[0] eq 'cc') && ($roleinfo[2] eq $dom) ) { |
if ( ($roleinfo[0] eq 'cc') && ($roleinfo[2] eq $dom) ) { |
unless (grep/^$roleinfo[1]$/,@local_ccs) { |
unless (grep/^$roleinfo[1]$/,@local_ccs) { |
$active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc'); |
$active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc'); |
if ($active_cc eq 'ok') { |
if ($active_cc eq 'active') { |
push @local_ccs, $roleinfo[1]; |
push @local_ccs, $roleinfo[1]; |
$pname{$roleinfo[1]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]); |
$pname{$roleinfo[1]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]); |
$cc_status{$roleinfo[1]} = $lt{'actv'}; |
$cc_status{$roleinfo[1]} = $lt{'actv'}; |
Line 239 all settings except course code, course
|
Line 251 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{'courseowner'}; |
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 = &Apache::loncommon::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc'); |
if ($active_cc eq 'ok') { |
if ($active_cc eq 'active') { |
$cc_status{$enrollvar{'courseowner'}} = $lt{'actv'}; |
$cc_status{$enrollvar{'courseowner'}} = $lt{'actv'}; |
} else { |
} else { |
$cc_status{$enrollvar{'courseowner'}} = $lt{'inac'}; |
$cc_status{$enrollvar{'courseowner'}} = $lt{'inac'}; |
Line 437 ENDDOCUMENT
|
Line 449 ENDDOCUMENT
|
|
|
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 486 sub modify_course {
|
Line 498 sub modify_course {
|
my $description = $settings{'description'}; |
my $description = $settings{'description'}; |
my %cenv = (); |
my %cenv = (); |
|
|
if ($ENV{'form.login'} eq 'krb') { |
if ($env{'form.login'} eq 'krb') { |
$newattr{'authtype'} = $ENV{'form.login'}; |
$newattr{'authtype'} = $env{'form.login'}; |
$newattr{'authtype'} .= $ENV{'form.krbver'}; |
$newattr{'authtype'} .= $env{'form.krbver'}; |
$newattr{'autharg'} = $ENV{'form.krbarg'}; |
$newattr{'autharg'} = $env{'form.krbarg'}; |
} elsif ($ENV{'form.login'} eq 'int') { |
} elsif ($env{'form.login'} eq 'int') { |
$newattr{'authtype'} ='internal'; |
$newattr{'authtype'} ='internal'; |
if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) { |
if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) { |
$newattr{'autharg'} = $ENV{'form.intarg'}; |
$newattr{'autharg'} = $env{'form.intarg'}; |
} |
} |
} elsif ($ENV{'form.login'} eq 'loc') { |
} elsif ($env{'form.login'} eq 'loc') { |
$newattr{'authtype'} = 'localauth'; |
$newattr{'authtype'} = 'localauth'; |
if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) { |
if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { |
$newattr{'autharg'} = $ENV{'form.locarg'}; |
$newattr{'autharg'} = $env{'form.locarg'}; |
} |
} |
} |
} |
if ( $newattr{'authtype'}=~ /^krb/) { |
if ( $newattr{'authtype'}=~ /^krb/) { |
Line 508 sub modify_course {
|
Line 520 sub modify_course {
|
} |
} |
} |
} |
|
|
if ( exists($ENV{'form.courseowner'}) ) { |
if ( exists($env{'form.courseowner'}) ) { |
$newattr{'courseowner'}=$ENV{'form.courseowner'}; |
$newattr{'courseowner'}=$env{'form.courseowner'}; |
unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) { |
unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) { |
$changeowner = 1; |
$changeowner = 1; |
} |
} |
} |
} |
|
|
if ( exists($ENV{'form.coursecode'}) ) { |
if ( exists($env{'form.coursecode'}) ) { |
$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; |
} |
} |
} |
} |
if ($changeowner == 1 || $changecode == 1) { |
if ($changeowner == 1 || $changecode == 1) { |
my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).':'.&Apache::lonnet::escape($ENV{'form.coursecode'}).':'.&Apache::lonnet::escape($ENV{'form.courseowner'}); |
my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).':'.&Apache::lonnet::escape($env{'form.coursecode'}).':'.&Apache::lonnet::escape($env{'form.courseowner'}); |
&Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom)); |
&Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom)); |
} |
} |
|
|
Line 642 sub print_header {
|
Line 654 sub print_header {
|
'comg' => 'Course Manager', |
'comg' => 'Course Manager', |
); |
); |
my $action = "start"; |
my $action = "start"; |
if ( exists($ENV{'form.action'}) ) { |
if ( exists($env{'form.action'}) ) { |
$action = $ENV{'form.action'}; |
$action = $env{'form.action'}; |
} |
} |
if ( ($description eq '') || (!defined($description)) ) { |
if ( ($description eq '') || (!defined($description)) ) { |
$description = $lt{'comg'}; |
$description = $lt{'comg'}; |
Line 655 sub print_header {
|
Line 667 sub print_header {
|
} else { |
} else { |
$page = '<a href="/adm/modifycourse">'.$lt{'chco'}.'</a>'; |
$page = '<a href="/adm/modifycourse">'.$lt{'chco'}.'</a>'; |
if ( $action eq 'process' ) { |
if ( $action eq 'process' ) { |
my $course = $ENV{'form.course'}; |
my $course = $env{'form.course'}; |
$page .= "-> <a href=\"/adm/modifycourse?action=display&course=$course\">".$$tasklongref{'display'}."</a> -> <b>$$tasklongref{$action}</b> "; |
$page .= "-> <a href=\"/adm/modifycourse?action=display&course=$course\">".$$tasklongref{'display'}."</a> -> <b>$$tasklongref{$action}</b> "; |
} else { |
} else { |
$page .= " -> <b>".$$tasklongref{$action}."</b>"; |
$page .= " -> <b>".$$tasklongref{$action}."</b>"; |
Line 702 ENDBASE
|
Line 714 ENDBASE
|
|
|
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,'.','.','.'); |
foreach my $key (sort keys %courseIDs) { |
foreach my $key (sort keys %courseIDs) { |
if ($key =~ m/^($dom)_(\w+)$/) { |
if ($key =~ m/^($dom)_(\w+)$/) { |
if ($2 eq $course) { |
if ($2 eq $course) { |
Line 722 sub handler {
|
Line 734 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','course']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','course']); |
my $dom = $ENV{'user.domain'}; |
my $dom = $env{'user.domain'}; |
my %longtype=&Apache::lonlocal::texthash( |
my %longtype=&Apache::lonlocal::texthash( |
'authtype' => 'Default authentication method', |
'authtype' => 'Default authentication method', |
'autharg' => 'Default authentication parameter', |
'autharg' => 'Default authentication parameter', |
Line 749 sub handler {
|
Line 761 sub handler {
|
'process' => 'Results of changes', |
'process' => 'Results of changes', |
); |
); |
|
|
if ($ENV{'form.action'} eq 'process') { |
if ($env{'form.action'} eq 'process') { |
&modify_course($r,\%tasklong,\%longtype); |
&modify_course($r,\%tasklong,\%longtype); |
} elsif ($ENV{'form.action'} eq 'display') { |
} elsif ($env{'form.action'} eq 'display') { |
&print_course_modification_page($r,\%tasklong,\%longtype); |
&print_course_modification_page($r,\%tasklong,\%longtype); |
} else { |
} else { |
&print_course_selection_page($r,\%tasklong); |
&print_course_selection_page($r,\%tasklong); |
} |
} |
} else { |
} else { |
$ENV{'user.error.msg'}= |
$env{'user.error.msg'}= |
"/adm/modifycourse:ccc:0:0:Cannot modify course settings"; |
"/adm/modifycourse:ccc:0:0:Cannot modify course settings"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |