--- loncom/interface/lonrequestcourse.pm 2015/06/08 22:06:52 1.88
+++ loncom/interface/lonrequestcourse.pm 2021/03/06 13:44:51 1.110
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.88 2015/06/08 22:06:52 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.110 2021/03/06 13:44:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -119,6 +119,10 @@ 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');
@@ -127,6 +131,10 @@ 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();
@@ -155,6 +163,23 @@ sub handler {
}
if ($canreq) {
+ if (($env{'form.crstype'} eq 'lti') && ($env{'request.lti.login'}) &&
+ ($env{'form.lti.reqrole'} eq 'cc') && ($env{'form.lti.reqcrs'}) &&
+ ($env{'form.lti.sourcecrs'} ne '')) {
+ if ($action eq 'process') {
+ if ($can_request{'lti'}) {
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
+ &process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request,'lti');
+ } else {
+ $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
+ '
'.
+ '
'.&mt('You do not have privileges to request creation of LTI courses.').'
'.
+ '
'.
+ &Apache::loncommon::end_page());
+ }
+ }
+ return OK;
+ }
if (($env{'form.crstype'} eq 'textbook') ||
(scalar(keys(%can_request)) == 1) && ($can_request{'textbook'})) {
my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
@@ -192,7 +217,8 @@ sub handler {
}
} else {
if ($can_request{'textbook'}) {
- &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request);
+ &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},
+ \%can_request,'textbook');
} else {
&textbook_request_disabled($r,$dom,$action,\%can_request);
}
@@ -551,6 +577,7 @@ sub form_elements {
clonedom => 'selectbox',
datemode => 'radio',
dateshift => 'text',
+ tinyurls => 'radio',
},
enrollment => {
accessstart_month => 'selectbox',
@@ -760,6 +787,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})) {
@@ -768,42 +796,51 @@ END
";
}
}
- my %lt = &Apache::lonlocal::texthash(
+ my %js_lt = &Apache::lonlocal::texthash(
official => 'You are not permitted to request creation of an official course in this domain.',
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.',
);
+ &js_escape(\%js_lt);
$js .= <{'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.');
@@ -991,6 +1028,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');
}
@@ -1175,6 +1214,8 @@ sub enrollment_lcsec_js {
my %alerts = §ion_check_alerts();
my $secname = $alerts{'badsec'};
my $secnone = $alerts{'reserved'};
+ &js_escape(\$secname);
+ &js_escape(\$secnone);
my $output = '
function validateEnrollSections(formname,nextstate) {
var badsectotal = 0;
@@ -1232,8 +1273,10 @@ function validateEnrollSections(formname
sub personnel_lcsec_js {
my %alerts = §ion_check_alerts();
- my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'};
+ my $secname = $alerts{'badsec'}."\n".$alerts{'separate'};
my $secnone = $alerts{'reserved'};
+ &js_escape(\$secname);
+ &js_escape(\$secnone);
my $output = '
function validatePersonnelSections(formname,nextstate) {
var badsectotal = 0;
@@ -1569,8 +1612,8 @@ sub print_request_form {
\%cat_order,\@code_order);
}
my $lonhost = $r->dir_config('lonHostID');
- my ($storeresult,$result) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
- \@code_order,$instcredits);
+ my ($storeresult,$result,$customized) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
+ \@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
if ($storeresult eq 'ok') {
@@ -1579,10 +1622,14 @@ sub print_request_form {
''.&mt('Make another request').'');
}
if (&Apache::loncoursequeueadmin::author_prompt()) {
- &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'},
- $env{'form.crstype'},$storeresult);
+ unless ($customized) {
+ &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'},
+ $env{'form.crstype'},$storeresult);
+ }
} elsif ($storeresult eq 'created') {
- $r->print('
';
@@ -3059,19 +3135,21 @@ sub dates_from_form {
sub courseinfo_form {
my ($dom,$formname,$crstype,$next,$description) = @_;
- my %lt = &Apache::lonlocal::texthash(
+ my %js_lt = &Apache::lonlocal::texthash(
official => 'You must provide a (brief) course description.',
community => 'You must provide a (brief) community description.'
);
- $lt{'unofficial'} = $lt{'official'};
- $lt{'textbook'} = $lt{'official'};
+ &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";