--- loncom/interface/lonrequestcourse.pm 2023/03/11 04:54:24 1.95.2.7.2.3 +++ loncom/interface/lonrequestcourse.pm 2016/04/02 04:30:21 1.96 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.95.2.7.2.3 2023/03/11 04:54:24 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.96 2016/04/02 04:30:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -119,10 +119,6 @@ use Apache::loncoursequeueadmin; use Apache::lonuserutils; use LONCAPA qw(:DEFAULT :match); -my $registered_flush; -my $registered_instcats; -my $modified_dom; - sub handler { my ($r) = @_; &Apache::loncommon::content_type($r,'text/html'); @@ -131,10 +127,6 @@ sub handler { return OK; } - $registered_flush = 0; - $registered_instcats = 0; - $modified_dom = ''; - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','showdom','cnum','state','crstype','queue','tabs']); &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -319,6 +311,8 @@ sub handler { $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored); if ($state eq 'courseinfo') { $jscript .= &cloning_javascript(); + } elsif ($state eq 'process') { + $jscript .= &processing_javascript(); } } } @@ -430,6 +424,17 @@ function setCloneDisplay(courseForm) { END } +sub processing_javascript { + return <<"END"; +function hideProcessing() { + if (document.getElementById('processing')) { + document.getElementById('processing').style.display="none"; + } +} + +END +} + sub get_breadcrumbs { my ($dom,$action,$state,$states,$trail) = @_; my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description); @@ -546,7 +551,6 @@ sub form_elements { clonedom => 'selectbox', datemode => 'radio', dateshift => 'text', - tinyurls => 'radio', }, enrollment => { accessstart_month => 'selectbox', @@ -708,6 +712,9 @@ sub onload_action { if ($state eq 'courseinfo') { $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);'; } + if ($state eq 'process') { + $loaditems{'onload'} .= 'javascript:hideProcessing();'; + } } return \%loaditems; } @@ -753,6 +760,7 @@ function check_can_request(crschoice,act var unofficial = ''; var community = ''; var textbook = ''; + var placement = ''; END if (ref($can_request) eq 'HASH') { foreach my $item (keys(%{$can_request})) { @@ -766,6 +774,7 @@ END unofficial => 'You are not permitted to request creation of an unofficial course in this domain.', community => 'You are not permitted to request creation of a community in this domain.', textbook => 'You are not permitted to request creation of a textbook course in this domain', + placement => 'You are not permitted to request creation of a placement test in this domain', all => 'You must choose a specific course type when making a new course request.', allt => '"All types" is not allowed.', ); @@ -795,9 +804,16 @@ END return false; } } else { - if (actionchoice == 'new') { - alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); - return false; + if (crschoice == 'placement') { + if (placement != 1) { + alert("$js_lt{'placement'}"); + return false; + } + } else { + if (actionchoice == 'new') { + alert('$js_lt{'all'}'+'\\n'+'$js_lt{'allt'}'); + return false; + } } } } @@ -808,7 +824,7 @@ END END my ($pagetitle,$pageinfo,$domaintitle,$earlyout); if (ref($can_request) eq 'HASH') { - if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || $can_request->{'textbook'}) { + if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || ($can_request->{'textbook'}) || ($can_request->{'placement'})) { if ($can_request->{'community'}) { $pagetitle = 'Course/Community Requests'; $pageinfo = &mt('Request creation of a new course or community, or review your pending requests.'); @@ -985,6 +1001,8 @@ END $title = &mt('Pending requests for unofficial courses'); } elsif ($env{'form.crstype'} eq 'textbook') { $title = &mt('Pending requests for textbook courses'); + } elsif ($env{'form.crstype'} eq 'textbook') { + $title = &mt('Pending requests for placement tests'); } else { $title = &mt('Pending course/community requests'); } @@ -2086,22 +2104,11 @@ sub print_personnel_menu { official => 'Requestor is automatically assigned Course Coordinator role.', ); $lt{'unofficial'} = $lt{'official'}; - $lt{'textbook'} = $lt{'textbook'}; + $lt{'textbook'} = $lt{'official'}; + $lt{'placement'} = $lt{'official'}; $output .= &Apache::lonhtmlcommon::row_headline(). '

'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'

'; } - my $cansearch = 1; - my @alldoms = &Apache::lonnet::all_domains(); - if (@alldoms == 1) { - my %domsrch = &Apache::lonnet::get_dom('configuration', - ['directorysrch'],$alldoms[0]); - if (ref($domsrch{'directorysrch'}) eq 'HASH') { - if ((!$domsrch{'directorysrch'}{'available'}) && - ($domsrch{'directorysrch'}{'lcavailable'} eq '0')) { - $cansearch = 0; - } - } - } for (my $i=0; $i<$persontotal; $i++) { my @linkargs = map { 'person_'.$i.'_'.$_ } (@items); my $linkargstr = join("','",@linkargs); @@ -2126,14 +2133,9 @@ sub print_personnel_menu { } $sectionselector .= $newtitle. ''."\n"; - my $usersrchlink; - if ($cansearch) { - my $usersrchlinktxt = &mt('Search for user'); - $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, - $usersrchlinktxt); - } else { - $usersrchlink = ' '; - } + my $usersrchlinktxt = &mt('Search for user'); + my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, + $usersrchlinktxt); my $userchklinktxt = &mt('Check username'); my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom, $userchklinktxt,'checkusername'); @@ -2380,7 +2382,7 @@ sub print_cancel_request { &Apache::loncommon::start_data_table_row(). ''.$history{details}{'cdescr'}.''. &Apache::lonlocal::locallocaltime($timestamp).''. - ''.&mt($showtype).''. + ''.$showtype.''. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). '
'; @@ -2514,7 +2516,7 @@ sub print_request_logs { if (ref($domconfig{'requestcourses'}) eq 'HASH') { if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') { if ($curr{'crstype'} eq 'any') { - my @types = qw(official unofficial community textbook); + my @types = qw(official unofficial community textbook placement); foreach my $type (@types) { if ($domconfig{'requestcourses'}{'uniquecode'}{$type}) { $showuniquecode = 1; @@ -2682,7 +2684,7 @@ sub reqstatus_names { rejected => 'Request rejected', cancelled => 'Request cancelled', ); - if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) { + if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook') || ($crstype eq 'placement')) { $statusnames{'created'} = &mt('Course created'); } elsif ($crstype eq 'community') { $statusnames{'created'} = &mt('Community created'); @@ -2734,7 +2736,7 @@ sub requestlog_display_filter { $typename = $typenames->{$crstype}; } } - $output .= ''."\n"; + $output .= ''."\n"; } $output .= ''; } @@ -2910,7 +2912,7 @@ sub print_review { $inst_values .= ''.$env{'form.coursecredits'}.''; } - my %ctxt = &clone_text($env{'form.crstype'}); + my %ctxt = &clone_text(); $inst_headers .= ''.&mt('Clone From').''; if (($env{'form.cloning'}) && ($env{'form.clonecrs'} =~ /^$match_name$/) && @@ -2922,8 +2924,7 @@ sub print_review { my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'}, $env{'form.clonecrs'},('description','internal.coursecode')); if (keys(%courseenv) > 0) { - $inst_headers .= ''.$ctxt{'dsh'}.''. - ''.$ctxt{'dpl'}.''; + $inst_headers .= ''.$ctxt{'dsh'}.''; $inst_values .= ''.$courseenv{'description'}.' '; my $cloneinst = $courseenv{'internal.coursecode'}; if ($cloneinst ne '') { @@ -2939,14 +2940,6 @@ sub print_review { } else { $inst_values .= $ctxt{'ncd'}; } - $inst_values .= ''; - if ($env{'form.tinyurls'} eq 'delete') { - $inst_values .= $ctxt{'nsl'}; - } elsif ($env{'form.tinyurls'} eq 'transfer') { - $inst_values .= $ctxt{'tsl'}; - } else { - $inst_values .= $ctxt{'csl'}; - } $inst_values .= ''; } else { $inst_values .= ''.&mt('Unknown').''; @@ -3095,6 +3088,7 @@ sub courseinfo_form { &js_escape(\%js_lt); $js_lt{'unofficial'} = $js_lt{'official'}; $js_lt{'textbook'} = $js_lt{'official'}; + $js_lt{'placement'} = $js_lt{'official'}; my $js_validate = <<"ENDJS"; -ENDCLOSE - my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble); - &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Processing ...')); + $r->print('
'."\n". + &mt('Your request is being processed; this page will update when processing is complete.'). + '
'); $r->rflush(); if (ref($details) eq 'HASH') { if ($details->{'clonecrs'}) { @@ -3856,12 +3807,9 @@ ENDCLOSE $customitems{'_LC_coursestartdate'} = $accessstart; $customitems{'_LC_courseenddate'} = $accessend; my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum, - 'autocreate',$details,\$logmsg,$clonemsg,\$newusermsg, - \$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs, - \%longroles,\$code,\%customitems); - &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Finished!')); - &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); - $r->print($closure); + 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult, + \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles, + \$code,\%customitems); if (ref($postprocess) eq 'HASH') { $customized = $postprocess->{'createdcustomized'}; } @@ -3895,39 +3843,7 @@ ENDCLOSE $output .= '
'.$role_result; } $output .= '

'; - if ($logmsg) { - $output .= '

'.$logmsg.'

'; - } - if ((ref($clonemsg) eq 'ARRAY') && (@{$clonemsg})) { - $output .= '

'; - my $user_lh = &Apache::loncommon::user_lang($env{'user.name'},$env{'user.domain'}); - foreach my $item (@{$clonemsg}) { - if (ref($item) eq 'HASH') { - $output .= &mt_user($user_lh,$item->{mt}, - @{$item->{args}}).'
'."\n"; - } - } - $output .= '

'."\n"; - } $creationresult = 'created'; - # Flush the course logs so reverse user roles immediately updated - unless ($registered_flush) { - my $handlers = $r->get_handlers('PerlCleanupHandler'); - $r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]); - $registered_flush=1; - } - if ($instcode ne '') { - &Apache::lonnet::devalidate_cache_new('instcats',$dom); - # Update cache of self-cataloging courses on institution's server(s). - if (&Apache::lonnet::shared_institution($dom)) { - unless ($registered_instcats) { - my $handlers = $r->get_handlers('PerlCleanupHandler'); - $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]); - $registered_instcats=1; - $modified_dom = $dom; - } - } - } } else { $output = ''; if ($crstype eq 'community') { @@ -4036,7 +3952,7 @@ ENDCLOSE } elsif ($disposition eq 'pending') { my $pendingform; if ($crstype ne 'official') { - $pendingform = &pending_validation_form($r,$dom,$cnum,$crstype,$now,$token, + $pendingform = &pending_validation_form($dom,$cnum,$crstype,$now,$token, $lonhost,$env{'form.cdescr'}); } if ($pendingform) { @@ -4063,22 +3979,6 @@ ENDCLOSE } } -sub devalidate_remote_instcats { - if ($modified_dom ne '') { - my %servers = &Apache::lonnet::internet_dom_servers($modified_dom); - my %thismachine; - map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); - if (keys(%servers)) { - foreach my $server (keys(%servers)) { - next if ($thismachine{$server}); - &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]); - } - } - $modified_dom = ''; - } - return; -} - sub custom_formitems { my ($preprocess,$customhash) = @_; return unless ((ref($preprocess) eq 'HASH') && (ref($customhash) eq 'HASH')); @@ -4354,7 +4254,7 @@ sub notification_information { } sub pending_validation_form { - my ($r,$cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_; + my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_; my $output; my %postvalues = ( 'owner' => $env{'user.name'}.':'.$env{'user.domain'}, @@ -4387,12 +4287,9 @@ sub pending_validation_form { $buttontext = &mt('Create course'); } } - my $hostname = &Apache::lonnet::hostname($lonhost); my $protocol = $Apache::lonnet::protocol{$lonhost}; $protocol = 'http' if ($protocol ne 'https'); - my $alias = &Apache::lonnet::use_proxy_alias($r,$lonhost); - $hostname = $alias if ($alias ne ''); - my $crscreator = $protocol.'://'.$hostname.'/cgi-bin/createpending.pl'; + my $crscreator = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/createpending.pl'; $output .= ''."\n". ''."\n". ''."\n". @@ -4417,7 +4314,7 @@ sub check_autolimit { if (($crstype eq 'community') && (exists($crsroles{$cnum.':'.$cdom.':co'}))) { $count ++; - } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) && + } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook') || ($crstype eq 'placement')) && (exists($crsroles{$cnum.':'.$cdom.':cc'}))) { $count ++; } @@ -4468,7 +4365,6 @@ sub retrieve_settings { } $env{'form.datemode'} = $reqinfo{'datemode'}; $env{'form.dateshift'} = $reqinfo{'dateshift'}; - $env{'form.tinyurls'} = $reqinfo{'tinyurls'}; if ($reqinfo{'crstype'} eq 'official') { $env{'form.autoadds'} = $reqinfo{'autoadds'}; $env{'form.autodrops'} = $reqinfo{'autodrops'}; @@ -4871,26 +4767,17 @@ sub print_textbook_form { # # Table of user's current courses (owner and/or course coordinator) # - my %lt = &clone_text('Course'); + my %lt = &clone_text(); if (keys(%cloneable)) { $r->print(''); } # @@ -4899,20 +4786,13 @@ sub print_textbook_form { if (keys(%domcloneable)) { $r->print(''); } @@ -5097,7 +4977,11 @@ sub process_textbook_request { undef($clonedom); } } - $r->print(&header('Course Creation')); + my $js = &processing_javascript(); + my $loaditems = { + onload => 'javascript:hideProcessing();', + }; + $r->print(&header('Course Creation',$js,$loaditems)); if (ref($can_request) eq 'HASH') { unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) { @@ -5139,7 +5023,6 @@ sub process_textbook_request { } else { $details->{dateshift} = ''; } - $details->{tinyurls} = $env{'form.owntinyurls'}; } elsif ($reqtype eq 'colleague') { $details->{datemode} = $env{'form.colldatemode'}; if ($details->{datemode} eq 'shift') { @@ -5147,11 +5030,6 @@ sub process_textbook_request { } else { $details->{dateshift} = ''; } - $details->{tinyurls} = $env{'form.colltinyurls'}; - } elsif (($reqtype eq 'textbook') || ($reqtype eq 'template')) { - $details->{datemode} = 'delete'; - $details->{dateshift} = ''; - $details->{tinyurls} = ''; } if ($details->{dateshift} ne '') { $details->{dateshift} =~ s/[^\d\.]+//g; @@ -5159,7 +5037,6 @@ sub process_textbook_request { } else { $details->{datemode} = ''; $details->{dateshift} = ''; - $details->{tinyurls} = ''; } my $lonhost = $r->dir_config('lonHostID'); $r->rflush();