--- loncom/interface/lonmodifycourse.pm 2005/04/27 19:09:30 1.18 +++ loncom/interface/lonmodifycourse.pm 2006/05/30 12:46:09 1.25 @@ -1,3 +1,8 @@ +# The LearningOnline Network with CAPA +# automated enrollment course setup handler +# +# $Id: lonmodifycourse.pm,v 1.25 2006/05/30 12:46:09 www Exp $ +# # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -30,6 +35,7 @@ use Apache::lonlocal; use Apache::londropadd; use LONCAPA::Enrollment; use lib '/home/httpd/lib/perl'; +use LONCAPA; sub print_course_selection_page { my ($r,$tasklongref) = @_; @@ -96,12 +102,12 @@ ENDBLOCK if ($item =~ m/^($dom)_(\w+)$/) { $crs = $2; if ($courseIDs{$item} =~ /^([^:]*):([^:]*):([^:]*)/) { - $description = &Apache::lonnet::unescape($1); - $owner = &Apache::lonnet::unescape($3); + $description = &unescape($1); + $owner = &unescape($3); } elsif ($courseIDs{$item} =~ /^([^:]*):([^:]*)$/) { - $description = &Apache::lonnet::unescape($1); + $description = &unescape($1); } else { - $description = &Apache::lonnet::unescape($courseIDs{$item}); + $description = &unescape($courseIDs{$item}); } # Get course owner if ($owner eq '') { @@ -190,26 +196,34 @@ all settings except course code, course $enrollvar{'autharg'} = ''; $enrollvar{'authtype'} = ''; foreach my $item (keys %settings) { - if ($item =~ m/^internal\.(.+)$/) { - if ( ($1 eq "autoadds") || ($1 eq "autodrops") ) { + if ($item =~ m/^internal\.(.+)$/) { + my $type = $1; + + if ( ($type eq "autoadds") || ($type eq "autodrops") ) { if ($settings{$item} == 1) { - $enrollvar{$1} = "ON"; + $enrollvar{$type} = "ON"; } else { - $enrollvar{$1} = "OFF"; + $enrollvar{$type} = "OFF"; } - } elsif ( ($1 eq "autostart") || ($1 eq "autoend") ) { - if ( ($1 eq "autoend") && ($settings{$item} == 0) ) { - $enrollvar{$1} = $lt{'noen'}; + } elsif ( ($type eq "autostart") || ($type eq "autoend") ) { + if ( ($type eq "autoend") && ($settings{$item} == 0) ) { + $enrollvar{$type} = $lt{'noen'}; } 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") { - $enrollvar{$1} = $settings{$item}; + } elsif ($type eq "sectionums") { + $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$/) { - if ( ($1 eq 'end') && ($settings{$item} == 0) ) { + my $type = $1; + if ( ($type eq 'end') && ($settings{$item} == 0) ) { $enrollvar{$item} = $lt{'noen'}; - } elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) { + } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) { $enrollvar{$item} = 'When enrolled'; } else { $enrollvar{$item} = localtime($settings{$item}); @@ -226,8 +240,8 @@ all settings except course code, course my @roleinfo = split/:/,$_; if ( ($roleinfo[0] eq 'cc') && ($roleinfo[2] eq $dom) ) { unless (grep/^$roleinfo[1]$/,@local_ccs) { - $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc'); - if ($active_cc eq 'ok') { + $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$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'}; @@ -238,15 +252,15 @@ all settings except course code, course 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 = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc'); - if ($active_cc eq 'ok') { + $active_cc = &Apache::loncommon::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc'); + if ($active_cc eq 'active') { $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'}; } else { $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'}; } } my $numlocalcc = @local_ccs; - my $bodytag=&Apache::loncommon::bodytag(&mt("Modify Course Settings")); + my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses")); my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($dom); my $curr_authtype = ''; @@ -521,7 +535,7 @@ sub modify_course { } } 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 = &escape($dom.'_'.$crs).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'}); &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom)); } @@ -635,7 +649,6 @@ 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', @@ -648,7 +661,7 @@ sub print_header { $description = $lt{'comg'}; } my $page = ''; - my $bodytag=&Apache::loncommon::bodytag($lt{'vmcs'}); + if ($action eq 'start') { $page = "$lt{'chco'}"; } else { @@ -660,21 +673,16 @@ sub print_header { $page .= " -> ".$$tasklongref{$action}.""; } } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(" -$html - -"); + + 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
@@ -690,12 +698,8 @@ ENDTHIS } sub print_footer { - my $r = shift; - $r->print(< - - -ENDBASE + my ($r) = @_; + $r->print('
'.&Apache::loncommon::end_page()); return; }