version 1.30, 2009/09/07 06:30:49
|
version 1.31, 2009/09/08 13:05:00
|
Line 527 sub form_elements {
|
Line 527 sub form_elements {
|
); |
); |
if ($env{'form.sectotal'} > 0) { |
if ($env{'form.sectotal'} > 0) { |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
$extras{'sec_'.$i} = 'checkbox', |
$extras{'sec_'.$i} = 'radio'; |
$extras{'secnum_'.$i} = 'text', |
$extras{'secnum_'.$i} = 'text'; |
$extras{'loncapasec_'.$i} = 'text', |
$extras{'loncapasec_'.$i} = 'text'; |
} |
} |
} |
} |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
my $crosslisttotal = $env{'form.crosslisttotal'}; |
Line 800 END
|
Line 800 END
|
} |
} |
if ($action eq 'new') { |
if ($action eq 'new') { |
my $jsextra; |
my $jsextra; |
unless (($state eq 'review') || ($state eq 'process')) { |
if ($state eq 'courseinfo') { |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
$jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); |
|
} elsif ($state eq 'enrollment') { |
|
if (($env{'form.crstype'} eq 'official') && |
|
(&Apache::lonnet::auto_run('',$dom))) { |
|
$js .= "\n".§ion_check_javascript()."\n".&enrollment_lcsec_js(); |
|
} |
|
} elsif ($state eq 'personnel') { |
|
$js .= "\n".§ion_check_javascript()."\n".&personnel_lcsec_js(); |
} |
} |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode, |
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode, |
Line 849 END
|
Line 856 END
|
other => 'Modify Request', |
other => 'Modify Request', |
next => 'Cancel Request', |
next => 'Cancel Request', |
); |
); |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'}, |
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, |
$state,$other,$navtxt{'other'}); |
$navtxt{'next'},$state,$other,$navtxt{'other'}); |
$r->print('</form>'); |
$r->print('</form>'); |
} elsif ($state eq 'cancel') { |
} elsif ($state eq 'cancel') { |
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'}); |
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'}); |
Line 863 END
|
Line 870 END
|
next => 'Confirm Cancellation', |
next => 'Confirm Cancellation', |
); |
); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next, |
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, |
$navtxt{'next'},$state); |
$navtxt{'next'},$state); |
} else { |
} else { |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},undef,'',$state); |
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},undef, |
|
'',$state); |
} |
} |
$r->print('</form>'); |
$r->print('</form>'); |
} elsif ($state eq 'removal') { |
} elsif ($state eq 'removal') { |
Line 929 END
|
Line 937 END
|
return; |
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<document.requestcrs.sec_".$i.".length; j++) { |
|
if (document.requestcrs.sec_".$i."[j].checked) { |
|
selSec = document.requestcrs.sec_".$i."[j].value; |
|
} |
|
if (selSec == 1) { |
|
secTest = validsection(document.requestcrs.loncapasec_".$i."); |
|
if (secTest == 'badsec') { |
|
badsectotal++; |
|
} |
|
if (secTest == 'reserved') { |
|
reservedtotal++; |
|
} |
|
} |
|
} |
|
"; |
|
} |
|
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { |
|
$output .= " |
|
if (document.requestcrs.crosslist_".$i.".checked) { |
|
secTest = validsection(document.requestcrs.crosslist_".$i."_lcsec); |
|
if (secTest == 'badsec') { |
|
badsectotal++; |
|
} |
|
if (secTest == 'reserved') { |
|
reservedtotal++; |
|
} |
|
} |
|
"; |
|
} |
|
$output .= " |
|
if (badsectotal>0) { |
|
alert('$secname'); |
|
return false; |
|
} |
|
if (reservedtotal>0) { |
|
alert('$secnone'); |
|
return false; |
|
} |
|
formname.state.value= nextstate; |
|
formname.submit(); |
|
return; |
|
} |
|
"; |
|
return $output; |
|
} |
|
|
|
sub personnel_lcsec_js { |
|
my %alerts = §ion_check_alerts(); |
|
my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'}; |
|
my $secnone = $alerts{'reserved'}; |
|
my $output = ' |
|
function validatePersonnelSections(formname,nextstate) { |
|
var badsectotal = 0; |
|
var reservedtotal = 0; |
|
var secTest = ""; |
|
'; |
|
for (my $i=0; $i<$env{'form.persontotal'}; $i++) { |
|
$output .= " |
|
if (document.requestcrs.person_".$i."_uname.value != '') { |
|
secTest = validsection(document.requestcrs.person_".$i."_newsec,'1'); |
|
if (secTest == 'badsec') { |
|
badsectotal++; |
|
} |
|
if (secTest == 'reserved') { |
|
reservedtotal++; |
|
} |
|
} |
|
"; |
|
} |
|
$output .= " |
|
if (badsectotal > 0) { |
|
alert('$secname'); |
|
return false; |
|
} else { |
|
if (reservedtotal > 0) { |
|
alert('$secnone'); |
|
return false; |
|
} |
|
} |
|
formname.state.value = nextstate; |
|
formname.submit(); |
|
return; |
|
} |
|
"; |
|
return $output; |
|
} |
|
|
|
sub section_check_alerts { |
|
my %lt = |
|
&Apache::lonlocal::texthash( |
|
reserved => "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<sections.length; i++) { |
|
if ((sections[i] != '') && (sections[i] != undefined) && (sections[i] != null)) { |
|
if (pattern.test(sections[i])) { |
|
badsecnum++; |
|
} else { |
|
if (sections[i] == 'none') { |
|
reservednum++; |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
if ((str != '') && (str != undefined) && (str != null)) { |
|
if (pattern.test(str)) { |
|
badsecnum++; |
|
} else { |
|
if (str == 'none') { |
|
reservednum++; |
|
} |
|
} |
|
} |
|
} |
|
if (badsecnum > 0) { |
|
return 'badsec'; |
|
} |
|
if (reservednum > 0) { |
|
return 'reserved'; |
|
} |
|
} |
|
return; |
|
} |
|
END |
|
} |
|
|
sub close_popup_form { |
sub close_popup_form { |
my $close= &mt('Close Window'); |
my $close= &mt('Close Window'); |
return << "END"; |
return << "END"; |
Line 1168 sub print_request_form {
|
Line 1336 sub print_request_form {
|
push(@excluded,'crosslisttotal'); |
push(@excluded,'crosslisttotal'); |
} |
} |
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>'); |
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state); |
&display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, |
|
$navtxt{'next'},$state); |
return; |
return; |
} |
} |
|
|
Line 1365 sub inst_section_selector {
|
Line 1534 sub inst_section_selector {
|
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
for (my $i=0; $i<@sections; $i++) { |
for (my $i=0; $i<@sections; $i++) { |
my $colflag = $i%2; |
my $colflag = $i%2; |
my $checked = ' checked="checked"'; |
my $secon = ' checked="checked"'; |
|
my $secoff = ''; |
if ($env{'form.origcnum'}) { |
if ($env{'form.origcnum'}) { |
$checked=''; |
$secoff = $secon; |
|
$secon=''; |
} |
} |
$output .= &Apache::loncommon::start_data_table_row(). |
$output .= &Apache::loncommon::start_data_table_row(). |
'<td><input type="checkbox" name="sec_'.$i. |
'<td><label><input type="radio" name="sec_'.$i. |
'"'.$checked.' value="1" /></td>'. |
'"'.$secon.' value="1" />'.&mt('Yes').'</label>'. |
'<td>'.$sections[$i]. |
(' 'x2).'<label><input type="radio" name="sec_'.$i. |
|
'"'.$secoff.' value="0" />'.&mt('No').'</label></td>'. |
|
'<td align="center">'.$sections[$i]. |
'<input type="hidden" name="secnum_'.$i.'" value="'. |
'<input type="hidden" name="secnum_'.$i.'" value="'. |
$sections[$i].'" /></td>'. |
$sections[$i].'" /></td>'. |
'<td><input type="text" size="10" name="loncapasec_'.$i. |
'<td><input type="text" size="10" name="loncapasec_'.$i. |
Line 1526 sub current_lc_sections {
|
Line 1699 sub current_lc_sections {
|
my @currsecs; |
my @currsecs; |
if ($env{'form.sectotal'}) { |
if ($env{'form.sectotal'}) { |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
for (my $i=0; $i<$env{'form.sectotal'}; $i++) { |
if (defined($env{'form.loncapasec_'.$i})) { |
if ($env{'form.sec_'.$i}) { |
my $lcsec = $env{'form.loncapasec_'.$i}; |
if (defined($env{'form.loncapasec_'.$i})) { |
unless (grep(/^\Q$lcsec\E$/,@currsecs)) { |
my $lcsec = $env{'form.loncapasec_'.$i}; |
push(@currsecs,$lcsec); |
unless (grep(/^\Q$lcsec\E$/,@currsecs)) { |
|
push(@currsecs,$lcsec); |
|
} |
} |
} |
} |
} |
} |
} |
Line 1933 sub print_review {
|
Line 2108 sub print_review {
|
if (ref($disallowed) eq 'ARRAY') { |
if (ref($disallowed) eq 'ARRAY') { |
next if (grep(/^$i$/,@{$disallowed})); |
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'}; |
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
$newsec =~ s/^\s+//; |
$newsec =~ s/^\s+//; |
$newsec =~s/\s+$//; |
$newsec =~s/\s+$//; |
my @newsecs = split(/[\s,;]+/,$newsec); |
my @newsecs = split(/\s*[\s,;:]\s*/,$newsec); |
foreach my $sec (@newsecs) { |
foreach my $sec (@newsecs) { |
|
next unless ($sec =~ /\w/); |
next if ($sec =~ /\W/); |
next if ($sec =~ /\W/); |
next if ($newsec eq 'none'); |
next if ($sec eq 'none'); |
if ($sec ne '') { |
if ($sec ne '') { |
unless (grep(/^\Q$sec\E$/,@allsecs)) { |
unless (grep(/^\Q$sec\E$/,@allsecs)) { |
push(@allsecs,$sec); |
push(@allsecs,$sec); |
Line 2242 sub get_course_dom {
|
Line 2425 sub get_course_dom {
|
} |
} |
|
|
sub display_navbuttons { |
sub display_navbuttons { |
my ($r,$formname,$prev,$prevtext,$next,$nexttext,$state,$other,$othertext) = @_; |
my ($r,$dom,$formname,$prev,$prevtext,$next,$nexttext,$state,$other,$othertext) = @_; |
$r->print('<div class="LC_navbuttons">'); |
$r->print('<div class="LC_navbuttons">'); |
if ($prev) { |
if ($prev) { |
$r->print('<input type="button" name="previous" value = "'.$prevtext.'" '. |
$r->print('<input type="button" name="previous" value = "'.$prevtext.'" '. |
'onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/>'. |
'onclick="javascript:backPage('."document.$formname,'$prev'".')"/>'. |
(' 'x3)); |
(' 'x3)); |
} elsif ($prevtext) { |
} elsif ($prevtext) { |
$r->print('<input type="button" name="previous" value = "'.$prevtext.'" '. |
$r->print('<input type="button" name="previous" value = "'.$prevtext.'" '. |
Line 2254 sub display_navbuttons {
|
Line 2437 sub display_navbuttons {
|
} |
} |
if ($state eq 'details') { |
if ($state eq 'details') { |
$r->print(' <input type="button" name="other" value="'.$othertext.'" '. |
$r->print(' <input type="button" name="other" value="'.$othertext.'" '. |
'onclick="javascript:nextPage(document.'.$formname.','."'".$other."'". |
'onclick="javascript:nextPage('."document.$formname,'$other'". |
')" />'); |
')" />'); |
} |
} |
|
my $gotnext; |
if ($state eq 'courseinfo') { |
if ($state eq 'courseinfo') { |
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
'onclick="javascript:validateForm();" />'); |
'onclick="javascript:validateForm();" />'); |
} elsif ($next) { |
$gotnext = 1; |
$r->print(' |
} elsif ($state eq 'enrollment') { |
<input type="button" name="next" value="'.$nexttext.'" '. |
if (($env{'form.crstype'} eq 'official') && |
'onclick="javascript:nextPage(document.'.$formname.','."'".$next."'".')" />'); |
(&Apache::lonnet::auto_run('',$dom))) { |
|
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:validateEnrollSections('."document.$formname,'$next'".');" />'); |
|
$gotnext = 1; |
|
} |
|
} elsif ($state eq 'personnel') { |
|
if ($env{'form.persontotal'} > 0) { |
|
$r->print('<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:validatePersonnelSections('."document.$formname,'$next'".');" />'); |
|
$gotnext = 1; |
|
} |
|
} |
|
unless ($gotnext) { |
|
if ($next) { |
|
$r->print(' |
|
<input type="button" name="next" value="'.$nexttext.'" '. |
|
'onclick="javascript:nextPage('."document.$formname,'$next'".')" />'); |
|
} |
} |
} |
$r->print('</div>'); |
$r->print('</div>'); |
} |
} |
Line 2353 sub print_request_outcome {
|
Line 2554 sub print_request_outcome {
|
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = (); |
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = (); |
} else { |
} else { |
my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec'); |
my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec'); |
|
my @allsecs; |
|
foreach my $sec (@currsec) { |
|
next unless ($sec =~ /\w/); |
|
next if ($sec =~ /\W/); |
|
next if ($sec eq 'none'); |
|
push(@allsecs,$sec); |
|
} |
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
my $newsec = $env{'form.person_'.$i.'_newsec'}; |
$newsec =~ s/^\s+//; |
$newsec =~ s/^\s+//; |
$newsec =~s/\s+$//; |
$newsec =~s/\s+$//; |
my @newsecs = split(/[\s,;]+/,$newsec); |
my @newsecs = split(/[\s,;]+/,$newsec); |
foreach my $sec (@newsecs) { |
foreach my $sec (@newsecs) { |
next if ($sec =~ /\W/); |
next if ($sec =~ /\W/); |
next if ($newsec eq 'none'); |
next if ($sec eq 'none'); |
if ($sec ne '') { |
if ($sec ne '') { |
unless (grep(/^\Q$sec\E$/,@currsec)) { |
unless (grep(/^\Q$sec\E$/,@allsecs)) { |
push(@currsec,$sec); |
push(@allsecs,$sec); |
} |
} |
} |
} |
} |
} |
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = @currsec; |
@{$personnel{$uname.':'.$udom}{$role}{'usec'}} = @allsecs; |
} |
} |
} |
} |
} else { |
} else { |