--- loncom/interface/lonmodifycourse.pm 2004/06/17 18:31:24 1.9 +++ loncom/interface/lonmodifycourse.pm 2006/07/18 21:52:01 1.27 @@ -1,3 +1,8 @@ +# The LearningOnline Network with CAPA +# automated enrollment course setup handler +# +# $Id: lonmodifycourse.pm,v 1.27 2006/07/18 21:52:01 albertel Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -30,11 +35,11 @@ use Apache::lonlocal; use Apache::londropadd; use LONCAPA::Enrollment; use lib '/home/httpd/lib/perl'; -use localenroll; +use LONCAPA; sub print_course_selection_page { my ($r,$tasklongref) = @_; - my $dom = $ENV{'user.domain'}; + my $dom = $env{'request.role.domain'}; my %lt=&Apache::lonlocal::texthash( '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.", @@ -46,7 +51,7 @@ sub print_course_selection_page { ); # 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(< @@ -57,8 +62,8 @@ sub print_course_selection_page {

$lt{'ccrs'}: "; + $ownertable .= ""; } else { - $ownertable .= ""; + $ownertable .= ""; } $ownertable .= " $pname{$local_ccs[$i]} - $local_ccs[$i] + $local_ccs[$i] $cc_status{$local_ccs[$i]} $lt{'ccor'}"; } $ownertable .= " @@ -431,8 +478,8 @@ ENDDOCUMENT sub modify_course { my ($r,$tasklongref,$typeref) = @_; - my $dom = $ENV{'user.domain'}; - my $crs = $ENV{'form.course'}; + my $dom = $env{'user.domain'}; + my $crs = $env{'form.course'}; unless ( &check_course($dom,$crs) eq 'ok' ) { &print_header($r,$tasklongref); my $reply = "
".&mt("The LON-CAPA course selected was not a valid course for this domain"); @@ -480,20 +527,19 @@ sub modify_course { my $description = $settings{'description'}; my %cenv = (); - if ($ENV{'form.login'} eq 'krb') { - $newattr{'authtype'} = $ENV{'form.login'}; - $newattr{'authtype'} .= $ENV{'form.krbver'}; - $newattr{'autharg'} = $ENV{'form.krbarg'}; - $newattr{'autharg'} =~ tr/a-z/A-Z/; - } elsif ($ENV{'form.login'} eq 'int') { + if ($env{'form.login'} eq 'krb') { + $newattr{'authtype'} = $env{'form.login'}; + $newattr{'authtype'} .= $env{'form.krbver'}; + $newattr{'autharg'} = $env{'form.krbarg'}; + } elsif ($env{'form.login'} eq 'int') { $newattr{'authtype'} ='internal'; - if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) { - $newattr{'autharg'} = $ENV{'form.intarg'}; + if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) { + $newattr{'autharg'} = $env{'form.intarg'}; } - } elsif ($ENV{'form.login'} eq 'loc') { + } elsif ($env{'form.login'} eq 'loc') { $newattr{'authtype'} = 'localauth'; - if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) { - $newattr{'autharg'} = $ENV{'form.locarg'}; + if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { + $newattr{'autharg'} = $env{'form.locarg'}; } } if ( $newattr{'authtype'}=~ /^krb/) { @@ -503,22 +549,23 @@ sub modify_course { } } - if ( exists($ENV{'form.courseowner'}) ) { - my $ownerparam = 'username_'.$ENV{'form.courseowner'}; - if ( exists($ENV{"form.$ownerparam"}) ) { - $newattr{'courseowner'}=$ENV{"form.$ownerparam"}; - unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) { - $changeowner = 1; - } + if ( exists($env{'form.courseowner'}) ) { + $newattr{'courseowner'}=$env{'form.courseowner'}; + unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) { + $changeowner = 1; } } - if ( exists($ENV{'form.coursecode'}) ) { - $newattr{'coursecode'}=$ENV{'form.coursecode'}; + if ( exists($env{'form.coursecode'}) ) { + $newattr{'coursecode'}=$env{'form.coursecode'}; unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) { $changecode = 1; } } + if ($changeowner == 1 || $changecode == 1) { + my $courseid_entry = &escape($dom.'_'.$crs).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'}); + &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom)); + } foreach (@params) { if ($currattr{$_} eq $newattr{$_}) { @@ -630,44 +677,40 @@ sub modify_course { sub print_header { my ($r,$tasklongref,$description,$javascriptref) = @_; my %lt =&Apache::lonlocal::texthash( - 'vmcs' => 'View/Modify Course Settings', 'chco' => 'Choose a course', 'main' => 'Main Menu', 'comg' => 'Course Manager', ); my $action = "start"; - if ( exists($ENV{'form.action'}) ) { - $action = $ENV{'form.action'}; + if ( exists($env{'form.action'}) ) { + $action = $env{'form.action'}; } if ( ($description eq '') || (!defined($description)) ) { $description = $lt{'comg'}; } my $page = ''; - my $bodytag=&Apache::loncommon::bodytag($lt{'vmcs'}); + if ($action eq 'start') { $page = "$lt{'chco'}"; } else { $page = ''.$lt{'chco'}.''; if ( $action eq 'process' ) { - my $course = $ENV{'form.course'}; + my $course = $env{'form.course'}; $page .= "-> ".$$tasklongref{'display'}." -> $$tasklongref{$action} "; } else { $page .= " -> ".$$tasklongref{$action}.""; } } - $r->print(" - -"); + + my $js; if ($action eq 'display') { - $r->print(" -"); + $js = ''; } + $r->print(&Apache::loncommon::start_page('View/Modify Course Settings', + $js)); $r->print(<The LearningOnline Network with CAPA - -$bodytag
@@ -683,18 +726,14 @@ ENDTHIS } sub print_footer { - my $r = shift; - $r->print(< - - -ENDBASE + my ($r) = @_; + $r->print('
'.&Apache::loncommon::end_page()); return; } 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) { @@ -714,12 +753,12 @@ sub handler { 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'); $r->send_http_header; &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( 'authtype' => 'Default authentication method', 'autharg' => 'Default authentication parameter', @@ -730,7 +769,7 @@ sub handler { '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)', @@ -741,15 +780,15 @@ sub handler { 'process' => 'Results of changes', ); - if ($ENV{'form.action'} eq 'process') { + if ($env{'form.action'} eq 'process') { &modify_course($r,\%tasklong,\%longtype); - } elsif ($ENV{'form.action'} eq 'display') { + } elsif ($env{'form.action'} eq 'display') { &print_course_modification_page($r,\%tasklong,\%longtype); } else { &print_course_selection_page($r,\%tasklong); } } else { - $ENV{'user.error.msg'}= + $env{'user.error.msg'}= "/adm/modifycourse:ccc:0:0:Cannot modify course settings"; return HTTP_NOT_ACCEPTABLE; }