');
} elsif ($state eq 'cancel') {
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
@@ -863,10 +859,11 @@ END
next => 'Confirm Cancellation',
);
if ($result eq 'ok') {
- &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,
+ &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
$navtxt{'next'},$state);
} else {
- &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},undef,'',$state);
+ &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},undef,
+ '',$state);
}
$r->print('');
} elsif ($state eq 'removal') {
@@ -929,6 +926,166 @@ END
return;
}
+sub enrollment_lcsec_js {
+ my %alerts = §ion_check_alerts();
+ my $secname = $alerts{'badsec'};
+ my $secnone = $alerts{'reserved'};
+ my $output = '
+function validateEnrollSections(formname,nextstate) {
+ var badsectotal = 0;
+ var reservedtotal = 0;
+ var secTest = "";
+';
+ for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
+ $output .= "
+ var selSec = 0;
+ for (var j=0; j "You need to change one or more LON-CAPA section names - none is a reserved word in the system, and may not be used.",
+ badsec => 'You need to change one or more LON-CAPA section names - names may only contain letters or numbers.',
+ separate => 'Separate multiple sections with a comma.'
+ );
+ return %lt;
+}
+
+sub section_check_javascript {
+ return <<"END";
+function validsection(field,mult) {
+ var str = field.value;
+ var badsec=0;
+ var reserved=0;
+ if (window.RegExp) {
+ var badsecnum=0;
+ var reservednum=0;
+ var pattern=/[^a-zA-Z0-9]/;
+ str = str.replace(/(^\\s*)|(\\s*\$)/gi,"");
+ str = str.replace(/[ ]{2,}/gi," ");
+ if (mult == '1') {
+ var sections = new Array();
+ sections = str.split(/\\s*[\\s,;:]\\s*/);
+ var i;
+ for (i=0; i 0) {
+ return 'badsec';
+ }
+ if (reservednum > 0) {
+ return 'reserved';
+ }
+ }
+ return;
+}
+END
+}
+
sub close_popup_form {
my $close= &mt('Close Window');
return << "END";
@@ -956,7 +1113,7 @@ sub get_instcode {
sub print_request_form {
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
- $invalidcrosslist) = @_;
+ $description,$invalidcrosslist) = @_;
my $formname = 'requestcrs';
my ($next,$prev,$message,$output,$codepicker,$crstype);
$prev = $states->{$action}[$page-1];
@@ -966,7 +1123,7 @@ sub print_request_form {
next => 'Next',
);
$crstype = $env{'form.crstype'};
- $r->print('
'.
+ '
'.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'
';
return $output;
}
@@ -1526,10 +1718,12 @@ sub current_lc_sections {
my @currsecs;
if ($env{'form.sectotal'}) {
for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
- if (defined($env{'form.loncapasec_'.$i})) {
- my $lcsec = $env{'form.loncapasec_'.$i};
- unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
- push(@currsecs,$lcsec);
+ if ($env{'form.sec_'.$i}) {
+ if (defined($env{'form.loncapasec_'.$i})) {
+ my $lcsec = $env{'form.loncapasec_'.$i};
+ unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
+ push(@currsecs,$lcsec);
+ }
}
}
}
@@ -1541,14 +1735,8 @@ sub print_request_status {
my ($dom) = @_;
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
$env{'user.name'},'^status:'.$dom);
- my ($output,$formname,%queue_by_date,%typenames);
- if ($env{'form.crstype'} eq 'any') {
- %typenames = &Apache::lonlocal::texthash (
- official => 'Official course',
- unofficial => 'Unofficial course',
- community => 'Community',
- );
- }
+ my ($output,$formname,%queue_by_date);
+ my ($types,$typenames) = &course_types();
foreach my $key (keys(%statusinfo)) {
if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) {
(undef,my($cdom,$cnum)) = split(':',$key);
@@ -1619,7 +1807,10 @@ sub print_request_status {
'
'.&unescape($desc).'
'.
'
'.$cdom.'
';
if ($env{'form.crstype'} eq 'any') {
- my $typename = $typenames{$type};
+ my $typename;
+ if (ref($typenames) eq 'HASH') {
+ $typename = &mt($typenames->{$type});
+ }
if ($typename eq '') {
$typename = &mt('Unknown type');
}
@@ -1772,7 +1963,7 @@ sub print_review {
$crstypename = $env{'form.crstype'};
if (ref($typename) eq 'HASH') {
unless ($typename->{$env{'form.crstype'}} eq '') {
- $crstypename = $typename->{$env{'form.crstype'}};
+ $crstypename = &mt($typename->{$env{'form.crstype'}});
}
}
my $category = 'Course';
@@ -1933,14 +2124,22 @@ sub print_review {
if (ref($disallowed) eq 'ARRAY') {
next if (grep(/^$i$/,@{$disallowed}));
}
- my @allsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
+ my @officialsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
+ my @allsecs;
+ foreach my $sec (@officialsecs) {
+ next unless ($sec =~ /\w/);
+ next if ($sec =~ /\W/);
+ next if ($sec eq 'none');
+ push(@allsecs,$sec);
+ }
my $newsec = $env{'form.person_'.$i.'_newsec'};
$newsec =~ s/^\s+//;
$newsec =~s/\s+$//;
- my @newsecs = split(/[\s,;]+/,$newsec);
+ my @newsecs = split(/\s*[\s,;:]\s*/,$newsec);
foreach my $sec (@newsecs) {
+ next unless ($sec =~ /\w/);
next if ($sec =~ /\W/);
- next if ($newsec eq 'none');
+ next if ($sec eq 'none');
if ($sec ne '') {
unless (grep(/^\Q$sec\E$/,@allsecs)) {
push(@allsecs,$sec);
@@ -2026,15 +2225,19 @@ sub dates_from_form {
}
sub courseinfo_form {
- my ($dom,$formname,$crstype,$next) = @_;
- my $nodescr = &mt('You must provide a (brief) course description.');
+ my ($dom,$formname,$crstype,$next,$description) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ official => 'You must provide a (brief) course description.',
+ community => 'You must provide a (brief) community description.'
+ );
+ $lt{'unofficial'} = $lt{'official'};
my $js_validate = <<"ENDJS";