'."\n".$form."\n".
- &print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order,
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
\@code_order)."\n".
''."\n");
my @excluded = &get_excluded_elements($dom,$states,'new','review');
@@ -737,6 +781,18 @@ END
}
$r->print('');
}
+ } elsif ($action eq 'display') {
+ my $formname = 'requestcrs';
+ my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
+ if ($env{'form.crstype'} eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ }
+ $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
+ $crumb."\n".'
'.&mt('Course Request Details').'
'.
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
+ \@code_order,$uname,$udom)."\n".''.
+ &close_popup_form());
} elsif ($action eq 'log') {
$r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
}
@@ -744,6 +800,15 @@ END
return;
}
+sub close_popup_form {
+ my $close= &mt('Close Window');
+ return << "END";
+'.
&mt('No course was found matching your choice of institutional course category.');
}
- unless ($code_chk eq 'ok') {
+ unless ($code_chk eq 'valid') {
$prev = 'crstype';
}
$r->print($message);
@@ -811,12 +876,19 @@ sub print_request_form {
$r->print('
'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
&Apache::lonhtmlcommon::end_pick_box().'
');
} else {
+ $next = $states->{$action}[$page+2];
$r->print(&courseinfo_form($dom,$formname,$crstype,$next));
}
} else {
+ if ($crstype eq 'official') {
+ $next = $states->{$action}[$page+2];
+ }
$r->print(&courseinfo_form($dom,$formname,$crstype,$next));
}
} elsif ($prev eq 'codepick') {
+ if ($env{'form.instcode'} eq '') {
+ $prev = $states->{$action}[$page-2];
+ }
$r->print(&courseinfo_form($dom,$formname,$crstype,$next));
} elsif ($state eq 'enrollment') {
if ($crstype eq 'official') {
@@ -837,8 +909,7 @@ sub print_request_form {
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
$r->print('
'.&mt('Review the details of the course request before submission.').'
'.
- &print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order).
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order).
'
');
$navtxt{'next'} = &mt('Submit course request');
} elsif ($state eq 'process') {
@@ -850,6 +921,9 @@ sub print_request_form {
$r->print($result);
}
my @excluded = &get_excluded_elements($dom,$states,$action,$state);
+ if ($state eq 'personnel') {
+ push(@excluded,'persontotal');
+ }
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'');
&display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state);
return;
@@ -902,7 +976,7 @@ sub print_enrollment_menu {
my ($section_form,$crosslist_form,$autoenroll_form);
$section_form = &inst_section_selector($dom,$instcode);
my $crosslisttotal = $env{'form.crosslisttotal'};
- if (!defined($crosslisttotal)) {
+ if (!$crosslisttotal) {
$crosslisttotal = 1;
}
if ($env{'form.addcrosslist'}) {
@@ -968,15 +1042,19 @@ sub inst_section_selector {
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_row().
'
'.&mt('Include?').''.
+ 'value="'.$sectotal.'" /> | '.
'
'.&mt('Institutional Section').' | '.
'
'.&mt('LON-CAPA section').' | '.
&Apache::loncommon::end_data_table_row();
for (my $i=0; $i<@sections; $i++) {
my $colflag = $i%2;
+ my $checked = ' checked="checked"';
+ if ($env{'form.origcnum'}) {
+ $checked='';
+ }
$output .= &Apache::loncommon::start_data_table_row().
'
| '.
+ '"'.$checked.' value="1" />'.
'
'.$sections[$i].
' | '.
@@ -1339,13 +1417,16 @@ sub print_request_logs {
}
sub print_review {
- my ($formname,$dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_;
+ my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom) = @_;
my ($types,$typename) = &course_types();
my ($owner,$ownername,$owneremail);
- $owner = $env{'user.name'}.':'.$env{'user.domain'};
- $ownername = &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'},'first');
- my %emails = &Apache::loncommon::getemails();
+ if ($uname eq '' || $udom eq '') {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ }
+ $owner = $uname.':'.$udom;
+ $ownername = &Apache::loncommon::plainname($uname,$udom,'first');
+ my %emails = &Apache::loncommon::getemails($uname,$udom);
foreach my $email ('permanentemail','critnotification','notification') {
$owneremail = $emails{$email};
last if ($owneremail ne '');
@@ -1424,32 +1505,35 @@ sub print_review {
&mt('Institutional course/section').''.
'
'.&mt('LON-CAPA section').' | ';
my $xlistinfo;
- if ($env{'form.crosslisttotal'}) {
- for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
- if ($env{'form.crosslist_'.$i}) {
- $xlistinfo .= '
';
- if (ref($code_order) eq 'ARRAY') {
- if (@{$code_order} > 0) {
- foreach my $item (@{$code_order}) {
- $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
- }
+ my $crosslisttotal = $env{'form.crosslisttotal'};
+ if (!$crosslisttotal) {
+ $crosslisttotal = 1;
+ }
+ for (my $i=0; $i<$crosslisttotal; $i++) {
+ if ($env{'form.crosslist_'.$i}) {
+ $xlistinfo .= ' |
';
+ if (ref($code_order) eq 'ARRAY') {
+ if (@{$code_order} > 0) {
+ foreach my $item (@{$code_order}) {
+ $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
}
}
- $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.' | ';
- if ($env{'form.crosslist_'.$i.'_lcsec'}) {
- $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
- } else {
- $xlistinfo .= &mt('None');
- }
- $xlistinfo .= ' |
';
}
+ $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'
';
+ if ($env{'form.crosslist_'.$i.'_lcsec'}) {
+ $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
+ } else {
+ $xlistinfo .= &mt('None');
+ }
+ $xlistinfo .= ' | ';
}
}
if ($xlistinfo eq '') {
$xlistinfo = '
'.&mt('None').' |
';
}
- $section_values .= $xlistinfo.'';
+ $section_values .= $xlistinfo;
}
+ $section_values .= '';
}
my %ctxt = &clone_text();
@@ -1525,10 +1609,16 @@ sub print_review {
}
}
}
- my $showsec = 'None';
+ my $showsec;
if (@allsecs) {
$showsec = join(', ',@allsecs);
}
+ if ($showsec eq '') {
+ $showsec = &mt('None');
+ }
+ if ($env{'form.person_'.$i.'_role'} eq 'cc') {
+ $showsec = &mt('None');
+ }
$personnel_values .=
'
'.$env{'form.person_'.$i.'_firstname'}.' '.
$env{'form.person_'.$i.'_lastname'}.' | '.
@@ -1569,7 +1659,7 @@ sub print_review {
''.$personnel_headers.'
'."\n".
$personnel_values.'
'."\n".
&Apache::lonhtmlcommon::row_closure(1).
- &Apache::lonhtmlcommon::end_pick_box();
+ &Apache::lonhtmlcommon::end_pick_box().'';
return $output;
}
@@ -1826,6 +1916,8 @@ sub print_request_outcome {
my ($dom,$codetitles,$code_order) = @_;
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
%sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);
+ my $sectotal = $env{'form.sectotal'};
+ my $crosslisttotal = 0;
$cnum = $env{'form.cnum'};
unless ($cnum =~ /^$match_courseid$/) {
$output = &mt('Invalid LON-CAPA course number for the new course')."\n";
@@ -1867,8 +1959,11 @@ sub print_request_outcome {
}
}
}
- $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'};
- $crosslistings{$i}{'inst'} = $xlistinfo;
+ $crosslistings{$i}{'instcode'} = $xlistinfo;
+ if ($xlistinfo ne '') {
+ $crosslisttotal ++;
+ }
+ $crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'};
$crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'};
}
}
@@ -1934,17 +2029,9 @@ sub print_request_outcome {
if ($env{'form.autoadds'}) {
$autodrops = $env{'form.autoadds'};
}
- my $sectotal = 0;
- if ($env{'form.sectotal'}) {
- $sectotal = $env{'form.sectotal'};
- }
if ($env{'form.autoadds'}) {
$autodrops = $env{'form.autoadds'};
}
- my $crosslisttotal = 0;
- if ($env{'form.crosslisttotal'}) {
- $crosslisttotal = $env{'form.crosslisttotal'};
- }
my $instcode = '';
if (exists($env{'form.instcode'})) {
$instcode = $env{'form.instcode'};
@@ -2018,7 +2105,7 @@ sub print_request_outcome {
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},
$dom,$crstype,$limit,\$message);
} elsif ($val eq 'validate') {
- my $inststatuslist;
+ my ($inststatuslist,$validationchk,$validation);
if (@inststatuses > 0) {
$inststatuslist = join(',',@inststatuses);
}
@@ -2026,23 +2113,20 @@ sub print_request_outcome {
if (@instsections > 0) {
$instseclist = join(',',@instsections);
}
- my $validation =
- &Apache::lonnet::auto_validate_instcode('',$dom,$instcode,
- $env{'user.name'}.':'.$env{'user.domain'},$inststatuslist,
- $instseclist);
- if ($validation eq 'valid') {
- $disposition = 'process';
- } elsif ($validation eq 'rejected') {
- $disposition = 'rejected';
- } elsif ($validation eq 'pending') {
- $disposition = 'pending';
- } elsif ($disposition eq 'approval') {
- $disposition = 'approval';
- } elsif ($disposition =~ /^error(.*)$/) {
+ $validationchk =
+ &Apache::lonnet::auto_courserequest_validation($dom,
+ $env{'user.name'}.':'.$env{'user.domain'},$crstype,
+ $inststatuslist,$instcode,$instseclist);
+ if ($validationchk =~ /:/) {
+ ($validation,$message) = split(':',$validationchk);
+ } else {
+ $validation = $validationchk;
+ }
+ if ($validation =~ /^error(.*)$/) {
$disposition = 'approval';
$validationerror = $1;
} else {
- $disposition = 'approval';
+ $disposition = $validation;
}
} else {
$disposition = 'approval';
@@ -2098,9 +2182,10 @@ sub print_request_outcome {
$env{'user.domain'},$env{'user.name'});
if ($userreqhash{$statuskey} ne '') {
$modified = 1;
- my %queuehash = &Apache::lonnet::get_dom('courserequestqueue',
- [$cnum.'_approval',
- $cnum.'_pending'],$dom);
+ my $uname = &Apache::lonnet::get_domainconfiguser($dom);
+ my %queuehash = &Apache::lonnet::get('courserequestqueue',
+ [$cnum.'_approval',
+ $cnum.'_pending'],$dom,$uname);
if (($queuehash{$cnum.'_approval'} ne '') ||
($queuehash{$cnum.'_pending'} ne '')) {
$queued = 1;
@@ -2206,7 +2291,7 @@ sub get_processtype {
if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
%settings = %{$domconfig->{'requestcourses'}};
if (ref($settings{$crstype}) eq 'HASH') {
- if (($env{'user.adv'}) && (exists($settings{$crstype}{'_LC_adv'}))) {
+ if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) {
$val = $settings{$crstype}{'_LC_adv'};
@{$inststatuses} = ('_LC_adv_');
} else {
@@ -2312,11 +2397,14 @@ sub check_autolimit {
}
sub retrieve_settings {
- my ($dom,$cnum) = @_;
- my ($result,%reqinfo) = &get_request_settings($dom,$cnum);
+ my ($dom,$cnum,$udom,$uname) = @_;
+ if ($udom eq '' || $uname eq '') {
+ $udom = $env{'user.domain'};
+ $uname = $env{'user.name'};
+ }
+ my ($result,%reqinfo) = &get_request_settings($dom,$cnum,$udom,$uname);
if ($result eq 'ok') {
- if (($env{'user.name'} eq $reqinfo{'owner'}) &&
- ($env{'user.domain'} eq $reqinfo{'domain'})) {
+ if (($udom eq $reqinfo{'domain'}) && ($uname eq $reqinfo{'owner'})) {
$env{'form.chome'} = $reqinfo{'coursehome'};
$env{'form.cdescr'} = $reqinfo{'cdescr'};
$env{'form.crstype'} = $reqinfo{'crstype'};
@@ -2339,17 +2427,18 @@ sub retrieve_settings {
$env{'form.autoadds'} = $reqinfo{'autoadds'};
$env{'form.autdrops'} = $reqinfo{'autodrops'};
$env{'form.instcode'} = $reqinfo{'instcode'};
- my %crscode = (
- instcode => $reqinfo{'instcode'},
- );
- &extract_instcode($dom,'instcode',\%crscode);
+ my $crscode = {
+ $cnum => $reqinfo{'instcode'},
+ };
+ &extract_instcode($dom,'instcode',$crscode,$cnum);
}
my @currsec;
if (ref($reqinfo{'sections'}) eq 'HASH') {
foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) {
if (ref($reqinfo{'sections'}{$i}) eq 'HASH') {
- my $sec = $reqinfo{'sections'}{$i}{'inst'};;
+ my $sec = $reqinfo{'sections'}{$i}{'inst'};
$env{'form.secnum_'.$i} = $sec;
+ $env{'form.sec_'.$i} = '1';
if (!grep(/^\Q$sec\E$/,@currsec)) {
push(@currsec,$sec);
}
@@ -2357,15 +2446,19 @@ sub retrieve_settings {
}
}
}
- if (ref($reqinfo{'crosslistings'}) eq 'HASH') {
- foreach my $i (sort(keys(%{$reqinfo{'crosslistings'}}))) {
- if (ref($reqinfo{'crosslistings'}{$i}) eq 'HASH') {
- $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslistings'}{$i}{'loncapa'};
- my $xlistsec = $reqinfo{'crosslistings'}{$i}{'instsec'};
- my %crscode = (
- $i => $reqinfo{'crosslistings'}{$i}{'instcode'},
- );
- &extract_instcode($dom,'crosslist',\%crscode,$1,$xlistsec);
+ if (ref($reqinfo{'crosslists'}) eq 'HASH') {
+ foreach my $i (sort(keys(%{$reqinfo{'crosslists'}}))) {
+ if (ref($reqinfo{'crosslists'}{$i}) eq 'HASH') {
+ $env{'form.crosslist_'.$i} = '1';
+ $env{'form.crosslist_'.$i.'_instsec'} = $reqinfo{'crosslists'}{$i}{'instsec'};
+ $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslists'}{$i}{'loncapa'};
+ if ($reqinfo{'crosslists'}{$i}{'instcode'} ne '') {
+ my $key = $cnum.$i;
+ my $crscode = {
+ $key => $reqinfo{'crosslists'}{$i}{'instcode'},
+ };
+ &extract_instcode($dom,'crosslist',$crscode,$key,$i);
+ }
}
}
}
@@ -2391,7 +2484,7 @@ sub retrieve_settings {
if (grep(/^\Q$sec\E/,@currsec)) {
$env{'form.person_'.$i.'_sec'} = $sec;
} else {
- push (@newsecs,$sec);
+ push(@newsecs,$sec);
}
}
}
@@ -2413,12 +2506,11 @@ sub retrieve_settings {
}
sub get_request_settings {
- my ($dom,$cnum) = @_;
+ my ($dom,$cnum,$udom,$uname) = @_;
my $requestkey = $dom.'_'.$cnum;
my ($result,%reqinfo);
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
- my %history = &Apache::lonnet::restore($requestkey,'courserequests',
- $env{'user.domain'},$env{'user.name'});
+ my %history = &Apache::lonnet::restore($requestkey,'courserequests',$udom,$uname);
my $disposition = $history{'disposition'};
if (($disposition eq 'approval') || ($disposition eq 'pending')) {
if (ref($history{'details'}) eq 'HASH') {
@@ -2437,26 +2529,19 @@ sub get_request_settings {
}
sub extract_instcode {
- my ($cdom,$element,$crscodehashref,$counter,$xlistsec) = @_;
+ my ($cdom,$element,$crscode,$crskey,$counter) = @_;
my (%codes,@codetitles,%cat_titles,%cat_order);
- if (ref($crscodehashref) eq 'HASH') {
- if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscodehashref,
- \%codes,\@codetitles,\%cat_titles,\%cat_order) eq 'ok') {
+ if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscode,\%codes,
+ \@codetitles,\%cat_titles,
+ \%cat_order) eq 'ok') {
+ if (ref($codes{$crskey}) eq 'HASH') {
if (@codetitles > 0) {
my $sel = $element;
if ($element eq 'crosslist') {
$sel .= '_'.$counter;
}
- my $lastitem = pop(@codetitles);
foreach my $title (@codetitles) {
- if (ref($cat_order{$title}) eq 'ARRAY') {
- if (@{$cat_order{$title}} > 0) {
- $env{'form.'.$sel.'_'.$title} = $cat_order{$title}[0];
- }
- }
- }
- if ($element eq 'crosslist') {
- $env{'form.'.$sel.'_'.$lastitem} = $xlistsec;
+ $env{'form.'.$sel.'_'.$title} = $codes{$crskey}{$title};
}
}
}