--- loncom/interface/lonrequestcourse.pm 2009/07/27 22:58:24 1.1 +++ loncom/interface/lonrequestcourse.pm 2009/08/04 20:15:50 1.2 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.1 2009/07/27 22:58:24 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.2 2009/08/04 20:15:50 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,35 +67,240 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + &Apache::lonhtmlcommon::clear_breadcrumbs(); + my $dom = &get_course_dom(); my $action = $env{'form.action'}; my $state = $env{'form.state'}; - my $dom = &get_course_dom(); + + my %stored; + my $jscript; + if ((defined($state)) && (defined($action))) { + my %elements = &form_elements($dom); + if (($action eq 'view') && ($state ne 'crstype')) { + if (defined($env{'form.request_id'})) { + %stored = &retrieve_settings($dom,$env{'form.request_id'}); + } + } + my $elementsref = {}; + if (ref($elements{$action}) eq 'HASH') { + if (ref($elements{$action}{$state}) eq 'HASH') { + $elementsref = $elements{$action}{$state}; + } + } + $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); + } + + if ($state eq 'personnel') { + $jscript .= "\n".&Apache::loncommon::userbrowser_javascript(); + } + + my $loaditems = &onload_action($action,$state); + + my %states; + $states{'view'} = ['pick_request','details','review','process']; + $states{'log'} = ['filter','display']; + $states{'new'} = ['courseinfo','enrollment','personnel','review','process']; + if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) { + unless ($env{'form.state'} eq 'crstype') { + unshift (@{$states{'new'}},'codepick'); + } + } + + foreach my $key (keys(%states)) { + if (ref($states{$key}) eq 'ARRAY') { + unshift (@{$states{$key}},'crstype'); + } + } + + my $page = 0; + if (defined($action)) { + my $done = 0; + my $i=0; + if (ref($states{$action}) eq 'ARRAY') { + while ($i<@{$states{$action}} && !$done) { + if ($states{$action}[$i] eq $state) { + $page = $i; + $done = 1; + } + $i++; + } + } + } + my %can_request; my $canreq = &check_can_request($dom,\%can_request); if ($action eq 'new') { if ($canreq) { if ($state eq 'crstype') { - &print_main_menu($r,\%can_request,$dom); + &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems); } else { - &request_administration($r,$action,$state,$dom); + &request_administration($r,$action,$state,$page,\%states,$dom,$jscript, + $loaditems); } } else { - $r->print(&Apache::loncommon::start_page('Course Requests'). + $r->print(&header('Course Requests'). '
'. &mt('You do not have privileges to request creation of courses.'). - '
'. - &Apache::loncommon::end_page()); + ''.&Apache::loncommon::end_page()); } } elsif ($action eq 'view') { - &print_request_status(); + &print_request_status($jscript,$loaditems); } elsif ($action eq 'log') { - &print_request_logs(); + &print_request_logs($jscript,$loaditems); } else { - &print_main_menu($r,\%can_request,$dom); + &print_main_menu($r,\%can_request,\%states,$dom,$jscript); } return OK; } +sub header { + my ($bodytitle,$jscript,$loaditems,$jsextra) = @_; + if ($jscript) { + $jscript = ''."\n"; + } + if ($loaditems) { + $loaditems = {'add_entries' => $loaditems,}; + } + return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$loaditems); +} + +sub form_elements { + my ($dom) = @_; + my %elements = + ( + new => { + crstype => { + crstype => 'selectbox', + action => 'selectbox', + }, + courseinfo => { + cdescr => 'text', + clonecourse => 'text', + clonedomain => 'selectbox', + datemode => 'radio', + dateshift => 'text', + }, + enrollment => { + startaccess_month => 'selectbox', + startaccess_hour => 'selectbox', + endaccess_month => 'selectbox', + endaccess_hour => 'selectbox', + startaccess_day => 'text', + startaccess_year => 'text', + startaccess_minute => 'text', + startaccess_second => 'text', + endaccess_day => 'text', + endaccess_year => 'text', + endaccess_minute => 'text', + endaccess_second => 'text', + no_end_date => 'checkbox', + }, + personnel => { + persontotal => 'hidden', + addperson => 'checkbox', + }, + }, + view => { + crstype => { + crstype => 'selectbox', + action => 'selectbox', + }, + }, + ); + my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem); + &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, + \%cat_order,\@code_order); + my $numtitles = scalar(@codetitles); + if ($numtitles) { + my %extras; + $lastitem = pop(@codetitles); + $extras{'instcode_'.$lastitem} = 'text'; + foreach my $item (@codetitles) { + $extras{'instcode_'.$item} = 'selectbox'; + } + $elements{'new'}{'codepick'} = \%extras; + } + if (&Apache::lonnet::auto_run('',$dom)) { + my %extras = ( + sectotal => 'hidden', + startenroll_month => 'selectbox', + startenroll_hour => 'selectbox', + endenroll_month => 'selectbox', + endenroll_hour => 'selectbox', + startenroll_day => 'text', + startenroll_year => 'text', + startenroll_minute => 'text', + startenroll_second => 'text', + endenroll_day => 'text', + endenroll_year => 'text', + endenroll_minute => 'text', + endenroll_second => 'text', + crosslisttotal => 'hidden', + addcrosslist => 'checkbox', + autoadds => 'radio', + autodrops => 'radio', + ); + if ($env{'form.sectotal'} > 0) { + for (my $i=0; $i<$env{'form.sectotal'}; $i++) { + $extras{'sec_'.$i} = 'checkbox', + $extras{'secnum_'.$i} = 'text', + $extras{'loncapasec_'.$i} = 'checkbox', + } + } + my $crosslisttotal = $env{'form.crosslisttotal'}; + if (!defined($crosslisttotal)) { + $crosslisttotal = 1; + } + if ($crosslisttotal > 0) { + for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) { + if ($numtitles) { + $extras{'crosslist_'.$i.'_'.$lastitem} = 'text'; + } + if (@codetitles > 0) { + foreach my $item (@codetitles) { + $extras{'crosslist_'.$i.'_'.$item} = 'selectbox'; + } + } + $extras{'crosslist_'.$i} = 'checkbox'; + $extras{'crosslist_'.$i.'_instsec'} = 'text', + $extras{'crosslist_'.$i.'_lcsec'} = 'text', + } + } + my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras); + %{$elements{'new'}{'enrollment'}} = %mergedhash; + } + my %people; + my $persontotal = $env{'form.persontotal'}; + if (!defined($persontotal)) { + $persontotal = 1; + } + for (my $i=0; $i<$persontotal; $i++) { + $people{'person_'.$i.'_uname'} = 'text', + $people{'person_'.$i.'_dom'} = 'selectbox', + $people{'person_'.$i.'_hidedom'} = 'hidden', + $people{'person_'.$i.'_first'} = 'text', + $people{'person_'.$i.'_last'} = 'text', + $people{'person_'.$i.'_email'} = 'text', + $people{'person_'.$i.'_role'} = 'selectbox', + $people{'person_'.$i.'_sec'} = 'selectbox', + $people{'person_'.$i.'_newsec'} = 'text', + $people{'person_'.$i.'_sections'} = 'hidden', + } + my %personnelhash = (%{$elements{'new'}{'personnel'}},%people); + %{$elements{'new'}{'personnel'}} = %personnelhash; + return %elements; +} + +sub onload_action { + my ($action,$state) = @_; + my %loaditems; + if (($action eq 'new') || ($action eq 'view')) { + $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)'; + } + return \%loaditems; +} + sub check_can_request { my ($dom,$can_request) = @_; my $canreq = 0; @@ -126,31 +331,43 @@ sub check_can_request { } sub print_main_menu { - my ($r,$can_request,$dom) = @_; + my ($r,$can_request,$states,$dom,$jscript,$loaditems) = @_; my $onchange; unless ($env{'form.interface'} eq 'textual') { $onchange = 1; } - &Apache::lonhtmlcommon::clear_breadcrumbs(); + my $nextstate_setter = "\n"; + if (ref($states) eq 'HASH') { + foreach my $key (keys(%{$states})) { + if (ref($states->{$key}) eq 'ARRAY') { + $nextstate_setter .= +" if (actionchoice == '$key') { + nextstate = '".$states->{$key}[1]."'; + } +"; + } + } + } - my $js = < + my $js = <<"END"; -function nextPage(formname,nextstate) { - if (check_can_request() == true) { +function nextPage(formname) { + var crschoice = document.requestcrs.crstype.value; + var actionchoice = document.requestcrs.action.value; + if (check_can_request(crschoice,actionchoice) == true) { + if ((actionchoice == 'new') && (crschoice == 'official')) { + nextstate = 'codepick'; + } else { +$nextstate_setter + } formname.state.value= nextstate; formname.submit(); } return; } -function backPage(formname,prevstate) { - formname.state.value = prevstate; - formname.submit(); -} - -function check_can_request() { +function check_can_request(crschoice,actionchoice) { var official = ''; var unofficial = ''; var community = ''; @@ -168,7 +385,6 @@ END all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.', ); $js .= < END - my $formname = 'requestform'; - $r->print(&Apache::loncommon::start_page('Course Requests',$js). + $r->print(&header('Course Requests',$js.$jscript,$loaditems). '

'. '
'. &Apache::lonhtmlcommon::start_pick_box(). @@ -215,15 +428,14 @@ END $r->print(&Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::end_pick_box().'
'); - my $formname = 'requestform'; - my $next = 'codepick'; + my $formname = 'requestcrs'; my $nexttext = &mt('Next'); $r->print('
'. &Apache::lonhtmlcommon::start_pick_box(). &Apache::lonhtmlcommon::row_title('Action').' '. @@ -231,24 +443,24 @@ END &Apache::lonhtmlcommon::row_title('Course Type').' '. &Apache::lonhtmlcommon::row_closure(1). &Apache::lonhtmlcommon::end_pick_box().'
- +
'); $r->print(&Apache::loncommon::end_page()); return; } sub request_administration { - my ($r,$action,$state,$dom) = @_; - if ($action eq 'new') { - my $js = < + my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems) = @_; + my $js; + if (($action eq 'new') || ($action eq 'view')) { + $js = < - END - + } + if ($action eq 'new') { + my $jsextra; unless (($state eq 'review') || ($state eq 'process')) { - $js .= "\n".&Apache::loncommon::coursebrowser_javascript($dom); + $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom); } - my $start_page = - &Apache::loncommon::start_page('Request a course',$js); - $r->print($start_page); + $r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra)); if ($state eq 'review') { &print_review($r,$state,$dom); } elsif ($state eq 'process') { &print_request_outcome($r,$state,$dom); } else { - &print_request_form($r,$state,$dom); + &print_request_form($r,$action,$state,$page,$states,$dom); } - $r->print(&Apache::loncommon::end_page()); + } elsif ($action eq 'view') { + $r->print(&header('Manage course requests',$js.$jscript,$loaditems)); } elsif ($action eq 'log') { - $r->print(&coursereq_log()); + $r->print(&coursereq_log('View request log',$jscript,$loaditems)); } + $r->print(&Apache::loncommon::end_page()); return; } sub print_request_form { - my ($r,$state,$dom) = @_; + my ($r,$action,$state,$page,$states,$dom) = @_; my $formname = 'requestcrs'; - my ($next,$prev,$message,$output,$codepicker); - my $prev = 'crstype'; + my ($next,$prev,$message,$output,$codepicker,$crstype); + $prev = $states->{$action}[$page-1]; + $next = $states->{$action}[$page+1]; + $crstype = $env{'form.crstype'}; $r->print('
'); - my $crstype = $env{'form.crstype'}; - my $xlist = 0; + my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk); if ($crstype eq 'official') { - my (@codetitles,%cat_titles,%cat_order,@code_order); &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, \%cat_order,\@code_order); - if ($state eq 'courseinfo') { - my $instcode; - if (@code_order > 0) { + if ($env{'form.instcode'} ne '') { + $instcode = $env{'form.instcode'}; + } + } + if ($prev eq 'codepick') { + if (@code_order > 0) { + my $message; + if ($instcode eq '') { foreach my $item (@code_order) { - $instcode .= $env{'form.instcode_'.$item}; + $instcode .= $env{'form.instcode_'.$item}; } + $r->print(''."\n"); } if ($instcode ne '') { - my $code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode); + $code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode); if ($code_chk eq 'ok') { $message = '
'. &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. + ''). + ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''.&mt('Section(s)').'
'.$sectionselector.''."\n". + '
'.&mt('Username').'
'.$uname_form.'
'.&mt('Domain').'
'.$udom_form.'
'.&mt('First Name').'
'.$form_elems{'first'}.'
'.&mt('Last Name').'
'.$form_elems{'last'}.'
'.&mt('E-mail').'
'.$form_elems{email}.'
'.&mt('Role').'
'.$roleselector.'
'.&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}). ''; + if ($context eq 'crosslist') { + $output .= ''; + } foreach my $title (@{$codetitles}) { if (ref($cat_order->{$title}) eq 'ARRAY') { if (@{$cat_order->{$title}} > 0) { @@ -483,7 +944,8 @@ sub coursecode_form { } if ($context eq 'crosslist') { $output .= '
'.&mt('Include?').'
'. + '
'.$lastitem.'
'."\n". - $lastinput.'
'; + $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}). + '
'. + ''.&mt('Include?'). + ''. + ''.&mt('Institutional ID').'
'. + ''. + '
'.$lcsec.'
'. + &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;