version 1.2, 2003/12/28 01:37:02
|
version 1.6, 2003/12/31 18:32:23
|
Line 1
|
Line 1
|
|
# Copyright Michigan State University Board of Trustees |
|
# |
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
|
# |
|
# LON-CAPA is free software; you can redistribute it and/or modify |
|
# it under the terms of the GNU General Public License as published by |
|
# the Free Software Foundation; either version 2 of the License, or |
|
# (at your option) any later version. |
|
# |
|
# LON-CAPA is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU General Public License |
|
# along with LON-CAPA; if not, write to the Free Software |
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
# |
|
# /home/httpd/html/adm/gpl.txt |
|
# |
|
# http://www.lon-capa.org/ |
|
# |
package Apache::lonmodifycourse; |
package Apache::lonmodifycourse; |
|
|
use strict; |
use strict; |
Line 28 sub print_course_selection_page {
|
Line 50 sub print_course_selection_page {
|
&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"> |
<h2>$lt{'csae'}</h2> |
<h3>$lt{'csae'}</h3> |
<p>$lt{'unst'} |
<p>$lt{'unst'} |
</p><p>$lt{'chcs'} |
</p><p>$lt{'chcs'} |
<br/>$lt{'eaen'} |
<br/>$lt{'eaen'} |
Line 102 ENDBLOCK
|
Line 124 ENDBLOCK
|
sub print_course_modification_page { |
sub print_course_modification_page { |
my ($r,$tasklongref,$typeref) = @_; |
my ($r,$tasklongref,$typeref) = @_; |
my %enrollvar = (); |
my %enrollvar = (); |
my @bgcolors=("#eeeeee","#cccccc"); |
my $javascript_validations; |
my $course = $ENV{'form.course'}; |
my $course = ''; |
my $dom = $ENV{'user.domain'}; |
my $dom = $ENV{'user.domain'}; |
|
if ( defined($ENV{'form.course'}) ) { |
|
$course = $ENV{'form.course'}; |
|
} |
|
my $ok_course = 'ok'; |
|
if ( ($course == -1) || ($course == '-2') || ($course eq '') ) { |
|
$ok_course = 'invalid'; |
|
} else { |
|
$ok_course = &check_course($dom,$course); |
|
} |
|
|
|
unless ($ok_course eq 'ok') { |
|
&print_header($r,$tasklongref,'',\$javascript_validations); |
|
my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain"); |
|
$r->print($reply); |
|
&print_footer($r); |
|
return; |
|
} |
|
|
|
my @bgcolors=("#eeeeee","#cccccc"); |
my $ownertable; |
my $ownertable; |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'actv' => "Active", |
'actv' => "Active", |
Line 181 all settings except course code, course
|
Line 222 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 207 all settings except course code, course
|
Line 248 all settings except course code, course
|
unless ($curr_authtype eq '') { |
unless ($curr_authtype eq '') { |
$curr_authfield = $curr_authtype.'arg'; |
$curr_authfield = $curr_authtype.'arg'; |
} |
} |
my $javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield); |
$javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield); |
my %param = ( formname => 'document.cmod', |
my %param = ( formname => 'document.cmod', |
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
kerb_def_auth => $krbdef, |
kerb_def_auth => $krbdef, |
Line 238 all settings except course code, course
|
Line 279 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 305 all settings except course code, course
|
Line 346 all settings except course code, course
|
&print_header($r,$tasklongref,$settings{'description'},\$javascript_validations); |
&print_header($r,$tasklongref,$settings{'description'},\$javascript_validations); |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<form action="/adm/modifycourse" method="post" name="cmod"> |
<form action="/adm/modifycourse" method="post" name="cmod"> |
<h2>$lt{'aecs'}</h2> |
<h3>$lt{'aecs'}</h3> |
$lt{'cose'}<a href="/adm/populate">$lt{'aenm'}</a>$lt{'andb'} |
$lt{'cose'}<a href="/adm/populate">$lt{'aenm'}</a>$lt{'andb'} |
<p> |
<p> |
<table width="100%" cellspacing="0" cellpadding="0"> |
<table width="100%" cellspacing="0" cellpadding="0"> |
Line 377 $disp_table
|
Line 418 $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' ) { |
|
&print_header($r,$tasklongref); |
|
my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain"); |
|
$r->print($reply); |
|
&print_footer($r); |
|
return; |
|
} |
|
|
my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$dom,$crs); |
my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$dom,$crs); |
my %currattr = (); |
my %currattr = (); |
my %newattr = (); |
my %newattr = (); |
Line 499 sub modify_course {
|
Line 550 sub modify_course {
|
foreach my $sec (@sections) { |
foreach my $sec (@sections) { |
if ($sec =~ m/^(.+):/) { |
if ($sec =~ m/^(.+):/) { |
my $course_id = $newattr{'coursecode'}.$1; |
my $course_id = $newattr{'coursecode'}.$1; |
# my $course_check = &localenroll::validate_courseID($course_id); |
my $course_check = &localenroll::validate_courseID($course_id); |
my $course_check = 'ok'; |
|
if ($course_check eq 'ok') { |
if ($course_check eq 'ok') { |
# my $outcome = &localenroll::new_course($course_id,$newattr{'courseowner'}); |
my $outcome = &localenroll::new_course($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 514 sub modify_course {
|
Line 563 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 $course_id = $newattr{'coursecode'}.$1; |
|
my $outcome = &localenroll::new_course($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 = &localenroll::new_course($1,$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 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 554 sub modify_course {
|
Line 614 sub modify_course {
|
$reply = $response; |
$reply = $response; |
} |
} |
&print_header($r,$tasklongref,$description); |
&print_header($r,$tasklongref,$description); |
$r->print("<table><tr><td>$reply</td></tr></table"); |
$reply = "<h3>".&mt("Automated Enrollment Course Settings")."</h3><table><tr><td>".$reply."</td></tr></table>"; |
|
$r->print($reply); |
&print_footer($r); |
&print_footer($r); |
return; |
return; |
} |
} |
Line 611 $bodytag
|
Line 672 $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 { |
|
my ($dom,$course) = @_; |
|
my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1); |
|
foreach my $key (sort keys %courseIDs) { |
|
if ($key =~ m/^($dom)_(\w+)$/) { |
|
if ($2 eq $course) { |
|
return 'ok'; |
|
} |
|
} |
|
} |
|
return 'invalid course'; |
} |
} |
|
|
|
|