'.
&mt('The chosen course category [_1] is valid.',''.
- $instcode.'').'
';
- my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,
- $instcode);
- if (@sections) {
- $output .= &inst_section_selector(\@sections);
- }
- $output .= &coursecode_form($dom,'crosslist',\@codetitles,
- \%cat_titles,\%cat_order,$xlist);
- $prev = 'codepick';
+ $instcode.'').'';
} else {
$message = ''.
&mt('No course was found matching your choice of institutional course category.');
@@ -324,64 +534,304 @@ sub print_request_form {
}
$message .= '
';
}
+ } else {
+ $message = ''.
+ &mt('No course was found matching your choice of institutional course category.');
}
+ unless ($code_chk eq 'ok') {
+ $prev = 'crstype';
+ }
+ $r->print($message);
}
- unless ($prev eq 'codepick') {
+ }
+ if ($prev eq 'crstype') {
+ if (@code_order > 0) {
$codepicker = &coursecode_form($dom,'instcode',\@codetitles,
\%cat_titles,\%cat_order);
+ if ($codepicker) {
+ $r->print('
'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
+ &Apache::lonhtmlcommon::end_pick_box().'
');
+ } else {
+ $r->print(&courseinfo_form($dom,$formname,$crstype));
+ }
+ } else {
+ $r->print(&courseinfo_form($dom,$formname,$crstype));
}
+ } elsif ($prev eq 'codepick') {
+ $r->print(&courseinfo_form($dom,$formname,$crstype));
+ } elsif ($state eq 'enrollment') {
+ $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
+ \%cat_titles,\%cat_order,\@code_order));
+ } elsif ($state eq 'personnel') {
+ $r->print(&print_personnel_menu($dom,$formname));
}
- $r->print($message.'
'.&Apache::lonhtmlcommon::start_pick_box());
- if ($output ne '') {
- $r->print($output);
- }
- if ($codepicker) {
- $r->print($codepicker);
- $state = 'codepick';
- $next = 'courseinfo';
- } else {
- $r->print(&courseinfo_form());
- $state = 'courseinfo';
- $next = 'review';
- }
- $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'."\n");
- unless ($codepicker) {
- $r->print('
'.&clone_form($dom,$formname,$crstype).'
'."\n");
+ my @excluded = ('counter');
+ my %elements = &form_elements($dom);
+ if (ref($states) eq 'HASH') {
+ if (ref($states->{$action}) eq 'ARRAY') {
+ my @items = @{$states->{$action}};
+ my $numitems = scalar(@items);
+ if ($numitems) {
+ for (my $i=$numitems-1; $i>=0; $i--) {
+ if (ref($elements{$action}) eq 'HASH') {
+ if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
+ foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
+ push(@excluded,$key);
+ }
+ }
+ }
+ last if ($items[$i] eq $state);
+ }
+ }
+ }
}
- $r->print('
'.
- &Apache::lonhtmlcommon::echo_form_input(['state']).'');
+ if (grep(/^instcode_/,@excluded)) {
+ push(@excluded,'instcode');
+ }
+ $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'');
&display_navbuttons($r,$formname,$prev,'Previous',$next,'Next');
return;
}
+sub print_enrollment_menu {
+ my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order) =@_;
+ my ($sections,$autoenroll,$access_dates);
+ my $starttime = time;
+ my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
+
+ my %accesstitles = (
+ 'start' => 'Default start access',
+ 'end' => 'Default end accss',
+ );
+ my %enrolltitles = (
+ 'start' => 'Start auto-enrollment',
+ 'end' => 'End auto-enrollment',
+ );
+ if ($env{'form.crstype'} eq 'official') {
+ if (&Apache::lonnet::auto_run('',$dom)) {
+ my ($section_form,$crosslist_form,$autoenroll_form);
+ $section_form = &inst_section_selector($dom,$instcode);
+ my $crosslisttotal = $env{'form.crosslisttotal'};
+ if (!defined($crosslisttotal)) {
+ $crosslisttotal = 1;
+ }
+ if ($env{'form.addcrosslist'}) {
+ $crosslisttotal ++;
+ }
+ for (my $i=0; $i<$crosslisttotal; $i++) {
+ $crosslist_form .= &coursecode_form($dom,'crosslist',$codetitles,
+ $cat_titles,$cat_order,$i);
+ }
+ if ($crosslist_form) {
+ $crosslist_form .=
+ &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
+ '
'.
+ '
'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1);
+ }
+ if ($section_form || $crosslist_form) {
+ $sections = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ $section_form.$crosslist_form.
+ &Apache::lonhtmlcommon::end_pick_box().'
'."\n";
+ }
+ $autoenroll_form =
+ &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')).
+ '
'.(' 'x3).''.
+ &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')).
+ '
'.(' 'x3).''.
+ &Apache::lonhtmlcommon::row_closure().
+ &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles);
+ if ($autoenroll_form) {
+ $autoenroll = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ $autoenroll_form.
+ &Apache::lonhtmlcommon::end_pick_box().'
'."\n";
+ }
+ }
+ }
+ my $access_dates_form =
+ &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles);
+ if ($access_dates_form) {
+ $access_dates = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ $access_dates_form.
+ &Apache::lonhtmlcommon::end_pick_box().'
'."\n";
+ }
+ return $sections.$autoenroll.$access_dates;
+}
+
sub inst_section_selector {
- my ($sections,$selected) = @_;
+ my ($dom,$instcode) = @_;
+ my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
+ my $sectotal = scalar(@sections);
my $output;
- if (ref($sections) eq 'ARRAY') {
- $output = &Apache::lonhtmlcommon::row_title('Sections').
- &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_row().
- '
'.&mt('Institutional Section').' | '.
- '
'.&mt('LON-CAPA section ID').' | '.
- '
'.&mt('Include in course?').' | '.
- &Apache::loncommon::end_data_table_row();
- for (my $i=0; $i<@{$sections}; $i++) {
+ if ($sectotal) {
+ $output .= &Apache::lonhtmlcommon::row_title('Sections').
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_row().
+ '
'.&mt('Include?').''.
+ ' | '.&mt('Institutional Section').' | '.
+ '
'.&mt('LON-CAPA section').' | '.
+ &Apache::loncommon::end_data_table_row();
+ for (my $i=0; $i<@sections; $i++) {
my $colflag = $i%2;
$output .= &Apache::loncommon::start_data_table_row().
- '
'.$sections->[$i].
+ ' | | '.
+ '
'.$sections[$i].
' | '.
+ $sections[$i].'" />'.
'
| '.
- '
| '.
+ '" value="'.$sections[$i].'" />'.
&Apache::loncommon::end_data_table_row();
}
- $output .= &Apache::loncommon::end_data_table();
+ $output .= &Apache::loncommon::end_data_table().
+ &Apache::lonhtmlcommon::row_closure();
}
return $output;
}
+sub date_setting_table {
+ my ($starttime,$endtime,$formname,$suffix,%datetitles) = @_;
+ my ($perpetual,$table);
+ my $startform = &Apache::lonhtmlcommon::date_setter($formname,'start'.$suffix,
+ $starttime,'','','',1,'','','',1);
+ my $endform = &Apache::lonhtmlcommon::date_setter($formname,'end'.$suffix,
+ $endtime,'','','',1,'','','',1);
+ if ($suffix eq 'access') {
+ $perpetual = '
';
+ }
+ $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}).
+ $startform.
+ &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title($datetitles{'end'}).
+ $endform.$perpetual.
+ &Apache::lonhtmlcommon::row_closure(1);
+ return $table;
+}
+
+sub print_personnel_menu {
+ my ($dom,$formname) = @_;
+ my $output = '
'.&Apache::lonhtmlcommon::start_pick_box();
+ my $persontotal = $env{'form.persontotal'};
+ if (!defined($persontotal)) {
+ $persontotal = 1;
+ }
+ if ($env{'form.addperson'}) {
+ $persontotal ++;
+ }
+ my $userlinktxt = &mt('Set User');
+ my @items = ('uname','dom','last','first','email','hidedom');
+
+ my $roleoptions;
+ my @roles = &Apache::lonuserutils::roles_by_context('course');
+ foreach my $role (@roles) {
+ my $plrole=&Apache::lonnet::plaintext($role);
+ $roleoptions .= '
'."\n";
+ }
+ my %customroles=&Apache::lonuserutils::my_custom_roles();
+ if (keys(%customroles) > 0) {
+ foreach my $cust (sort(keys(%customroles))) {
+ my $custrole='cr_cr_'.$env{'user.domain'}.
+ '_'.$env{'user.name'}.'_'.$cust;
+ $roleoptions .= '
'."\n";
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+ }
+
+ my ($existtitle,$existops,$existmult,$newtitle,$seccolspan);
+ if (@currsecs) {
+ my $existsize = scalar(@currsecs);
+ if ($existsize > 3) {
+ $existsize = 3;
+ }
+ if ($existsize > 1) {
+ $existmult = ' multiple="multiple" size="'.$existsize.'" ';
+ }
+ @currsecs = sort { $a <=> $b } (@currsecs);
+ $existtitle = &mt('Official').': ';
+ $existops = '
';
+ foreach my $sec (@currsecs) {
+ $existops .= '
'."\n";
+ }
+ $seccolspan = ' colspan="2"';
+ $newtitle = &mt('Other').': ';
+ }
+
+ for (my $i=0; $i<$persontotal; $i++) {
+ my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
+ my $linkargstr = join("','",@linkargs);
+ my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$userlinktxt);
+ my $uname_form = '
';
+ my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
+ "'person_".$i."_hidedom'".');'.
+ 'openuserbrowser('."'$formname','$linkargstr'".');';
+ my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
+ 1,$onchange).
+ '
';
+ my %form_elems;
+ foreach my $item (@items) {
+ next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom'));
+ $form_elems{$item} = '
';
+ }
+ my $roleselector = '
';
+ my $sectionselector;
+ if (@currsecs) {
+ $sectionselector = $existtitle.'
'.(' ' x3);
+ }
+ $sectionselector .= $newtitle.
+ '
'.
+ '
'."\n";
+
+ $output .=
+ &Apache::lonhtmlcommon::row_title(&mt('Additional Personnel').'
'.
+ '
'.$userlink.
+ '').
+ '
'.&mt('Username').' '.$uname_form.' | '."\n".
+ ''.&mt('Domain').' '.$udom_form.' |
'."\n".
+ ''.&mt('First Name').' '.$form_elems{'first'}.' | '."\n".
+ ''.&mt('Last Name').' '.$form_elems{'last'}.' | '."\n".
+ ''.&mt('E-mail').' '.$form_elems{email}.' |
'."\n".
+ ''.&mt('Role').' '.$roleselector.' | '."\n".
+ ''.&mt('Section(s)').' '.$sectionselector.' | '."\n".
+ '
'.&Apache::lonhtmlcommon::row_closure();
+ }
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
+ '
'.
+ '
'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box().'
';
+ return $output;
+}
+
sub print_request_status {
return;
}
@@ -396,8 +846,13 @@ sub print_review {
}
sub courseinfo_form {
- my $output = &Apache::lonhtmlcommon::row_title('Course Description').
- '
';
+ my ($dom,$formname,$crstype) = @_;
+ my $output = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ &Apache::lonhtmlcommon::row_title('Course Description').
+ ''.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box().'
'.
+ '
'.&clone_form($dom,$formname,$crstype).'
'."\n";
return $output;
}
@@ -408,8 +863,7 @@ sub clone_form {
$type = 'Community';
}
my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedomain').
- &Apache::loncommon::selectcourse_link($formname,'clonecourse',
- 'clonedomain','','','',$type);
+ &Apache::loncommon::selectcourse_link($formname,'clonecourse','clonedomain','','','',$type);
my %lt = &Apache::lonlocal::texthash(
'cid' => 'Course ID',
'dmn' => 'Domain',
@@ -418,48 +872,55 @@ sub clone_form {
'prd' => 'Clone date parameters as-is',
'shd' => 'Shift date parameters by number of days',
);
- my $output .= &Apache::lonhtmlcommon::start_pick_box().
- &Apache::lonhtmlcommon::row_title($lt{'cid'}).
- '
'.&Apache::lonhtmlcommon::row_closure(1).'
'.
- $cloneform.''.&Apache::lonhtmlcommon::row_closure().
- &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'
'.
- '
'.
- &Apache::lonhtmlcommon::row_closure(1).
- &Apache::lonhtmlcommon::end_pick_box();
+ my $output .=
+ &Apache::lonhtmlcommon::start_pick_box().
+ &Apache::lonhtmlcommon::row_title($lt{'cid'}).'
'.&Apache::lonhtmlcommon::row_closure(1).'
'.
+ $cloneform.''.&Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'
'.
+ '
'.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box();
return $output;
}
sub coursecode_form {
- my ($dom,$context,$codetitles,$cat_titles,$cat_order,$count) = @_;
+ my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_;
my $output;
+ my %rowtitle = (
+ instcode => 'Course Category',
+ crosslist => 'Cross Listed Course',
+ );
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') &&
(ref($cat_order))) {
+ my ($sel,$instsec,$lcsec);
+ $sel = $context;
+ if ($context eq 'crosslist') {
+ $sel .= '_'.$num;
+ $instsec = &mt('Institutional section').'
'.
+ '
';
+ $lcsec = &mt('LON-CAPA section').'
'.
+ '
';
+ }
if (@{$codetitles} > 0) {
my $lastitem = pop(@{$codetitles});
- my $sel = $context;
- if ($context eq 'crosslist') {
- $sel .= '_'.$count;
- }
- my $lastinput = '
';
- my %rowtitle = (
- instcode => 'Course Category',
- crosslist => 'Cross Listed Course',
- );
+ my $lastinput = '
';
if (@{$codetitles} > 0) {
- my $sel = $context;
- if ($context eq 'crosslist') {
- $sel .= '_'.$count;
- }
$output = &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
'
';
+ $lastinput.'
'.$instsec.' | '.
+ '
'.$lcsec.' | ';
} else {
$output .= ''.
&Apache::lonhtmlcommon::row_closure().
@@ -493,13 +955,26 @@ sub coursecode_form {
} else {
if ($context eq 'crosslist') {
$output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
- $lastitem.'
';
+ '
'.
+ ''.$lastitem.' '.$lastinput.' | '.
+ ''.$instsec.' | '.$lcsec.' | '.
+ '
';
} else {
$output .= &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
$lastinput;
}
- $output .= $lastinput.&Apache::lonhtmlcommon::row_closure(1);
}
+ $output .= &Apache::lonhtmlcommon::row_closure(1);
+ push(@$codetitles,$lastitem);
+ } elsif ($context eq 'crosslist') {
+ $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
+ '
'.
+ &Apache::lonhtmlcommon::row_closure(1);
}
}
return $output;
@@ -547,5 +1022,30 @@ sub print_request_outcome {
return;
}
+sub retrieve_settings {
+ my ($dom,$request_id) = @_;
+ my %reqinfo = &get_request_settings($request_id,$dom);
+ my %stored;
+ $stored{'cdescr'} = &unescape($reqinfo{'description'});
+ $stored{'startaccess'} = $reqinfo{'startaccess'};
+ $stored{'endaccess'} = $reqinfo{'endaccess'};
+ if ($stored{'endaccess'} == 0) {
+ $stored{'no_end_date'} = 1;
+ }
+ $stored{'startenroll'} = $reqinfo{'startenroll'};
+ $stored{'endenroll'} = $reqinfo{'endenroll'};
+ $stored{'crosslist'} = $reqinfo{'crosslist'};
+ $stored{'clonecourse'} = $reqinfo{'clonecourse'};
+ $stored{'clonedomain'} = $reqinfo{'clonedomain'};
+ $stored{'sections'} = $reqinfo{'sections'};
+ $stored{'personnel'} = $reqinfo{'personnel'};
+
+ return %stored;
+}
+
+sub get_request_settings {
+ my ($request_id,$dom);
+}
+
1;