--- loncom/interface/lonrequestcourse.pm 2014/05/19 15:59:55 1.84
+++ 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.84 2014/05/19 15:59:55 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);
@@ -172,7 +197,7 @@ sub handler {
if ($can_request{'textbook'}) {
&process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request);
} else {
- &textbook_request_disabled($r,$dom,\%can_request);
+ &textbook_request_disabled($r,$dom,$action,\%can_request);
}
} elsif ($action eq 'display') {
my ($uname,$udom,$result,$warning) = &domcoord_display($dom);
@@ -192,9 +217,10 @@ 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,\%can_request);
+ &textbook_request_disabled($r,$dom,$action,\%can_request);
}
}
return OK;
@@ -476,27 +502,29 @@ sub get_breadcrumbs {
}
}
}
- for (my $i=0; $i<@{$states->{$action}}; $i++) {
- if ($$state eq $states->{$action}[$i]) {
- &Apache::lonhtmlcommon::add_breadcrumb(
- {text=>"$trail->{$$state}"});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
- last;
- } else {
- if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) {
+ if (ref($states->{$action}) eq 'ARRAY') {
+ for (my $i=0; $i<@{$states->{$action}}; $i++) {
+ if ($$state eq $states->{$action}[$i]) {
&Apache::lonhtmlcommon::add_breadcrumb(
- { href => '/adm/requestcourse',
- text => "$trail->{$states->{$action}[$i]}",
- }
- );
+ {text=>"$trail->{$$state}"});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
+ last;
} else {
- &Apache::lonhtmlcommon::add_breadcrumb(
+ if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => "$trail->{$states->{$action}[$i]}",
+ }
+ );
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb(
{ href => "javascript:backPage(document.requestcrs,'$states->{$action}[$i]')",
text => "$trail->{$states->{$action}[$i]}", }
- );
- }
- }
- }
+ );
+ }
+ }
+ }
+ }
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
{text=>'Pick Action'});
@@ -549,6 +577,7 @@ sub form_elements {
clonedom => 'selectbox',
datemode => 'radio',
dateshift => 'text',
+ tinyurls => 'radio',
},
enrollment => {
accessstart_month => 'selectbox',
@@ -758,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})) {
@@ -766,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.');
@@ -937,7 +976,8 @@ END
if ($action eq 'new') {
my $jsextra;
if (($state eq 'courseinfo') || ($state eq 'codepick')) {
- $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
+ $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom,'','','','','',
+ $newinstcode);
} elsif ($state eq 'enrollment') {
if (($env{'form.crstype'} eq 'official') &&
(&Apache::lonnet::auto_run('',$dom))) {
@@ -988,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');
}
@@ -1172,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;
@@ -1229,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;
@@ -1566,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') {
@@ -1576,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(''.&mt('Make another request').'
');
+ unless ($customized) {
+ $r->print(''.&mt('Make another request').'
');
+ }
}
}
} elsif ($state eq 'reqauthor') {
@@ -2081,18 +2131,32 @@ 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?').' ';
}
- for (my $i=0; $i<$persontotal; $i++) {
+ 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;
+ }
+ }
+ }
+ my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$dom);
+ for (my $i=0; $i<$persontotal; $i++) {
my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
my $linkargstr = join("','",@linkargs);
my $uname_form = ' ';
my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
"'person_".$i."_hidedom','person_".$i."_uname'".');';
my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
- 1,$onchange).
+ 1,$onchange,undef,$trusted,$untrusted).
' ';
my %form_elems;
foreach my $item (@items) {
@@ -2109,9 +2173,14 @@ sub print_personnel_menu {
}
$sectionselector .= $newtitle.
' '."\n";
- my $usersrchlinktxt = &mt('Search for user');
- my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
- $usersrchlinktxt);
+ my $usersrchlink;
+ if ($cansearch) {
+ my $usersrchlinktxt = &mt('Search for user');
+ $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
+ $usersrchlinktxt);
+ } else {
+ $usersrchlink = ' ';
+ }
my $userchklinktxt = &mt('Check username');
my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
$userchklinktxt,'checkusername');
@@ -2358,7 +2427,7 @@ sub print_cancel_request {
&Apache::loncommon::start_data_table_row().
''.$history{details}{'cdescr'}.' '.
&Apache::lonlocal::locallocaltime($timestamp).' '.
- ''.$showtype.' '.
+ ''.&mt($showtype).' '.
&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table().
'';
@@ -2413,8 +2482,9 @@ ENDJS
}
sub viewcancel_javascript {
- my $alert = &mt('Are you sure you want to cancel this request?').'\\n'.
+ my $alert = &mt('Are you sure you want to cancel this request?')."\n".
&mt('Your request will be removed.');
+ &js_escape(\$alert);
return << "ENDJS";
function nextPage(formname,nextstate) {
if (confirm('$alert')) {
@@ -2491,7 +2561,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;
@@ -2659,7 +2729,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');
@@ -2711,7 +2781,7 @@ sub requestlog_display_filter {
$typename = $typenames->{$crstype};
}
}
- $output .= ''.$typename.' '."\n";
+ $output .= ''.&mt($typename).' '."\n";
}
$output .= '';
}
@@ -2786,6 +2856,7 @@ sub print_review {
my $enrollrow_title = &mt('Default Access Dates').' '.
'('.&Apache::lonnet::plaintext('st',$category).')';
+ my $instcode;
if ($env{'form.crstype'} eq 'official') {
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
foreach my $title (@{$codetitles}) {
@@ -2801,6 +2872,11 @@ sub print_review {
}
}
}
+ if (ref($code_order) eq 'ARRAY') {
+ foreach my $item (@{$code_order}) {
+ $instcode .= $env{'form.instcode_'.$item};
+ }
+ }
$inst_headers .= '
'.&mt('Credits').' ';
if ($instcredits) {
$inst_values .= ''.$instcredits.' ';
@@ -2881,19 +2957,20 @@ sub print_review {
$inst_values .= ''.$env{'form.coursecredits'}.' ';
}
- my %ctxt = &clone_text();
+ my %ctxt = &clone_text($env{'form.crstype'});
$inst_headers .= ''.&mt('Clone From').' ';
if (($env{'form.cloning'}) &&
($env{'form.clonecrs'} =~ /^$match_name$/) &&
($env{'form.clonedom'} =~ /^$match_domain$/)) {
my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,
$udom,$env{'form.clonecrs'},$env{'form.clonedom'},
- $env{'form.crstype'});
+ $env{'form.crstype'},$dom,$instcode);
if ($canclone) {
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
$env{'form.clonecrs'},('description','internal.coursecode'));
if (keys(%courseenv) > 0) {
- $inst_headers .= ''.$ctxt{'dsh'}.' ';
+ $inst_headers .= ''.$ctxt{'dsh'}.' '.
+ ''.$ctxt{'dpl'}.' ';
$inst_values .= ''.$courseenv{'description'}.' ';
my $cloneinst = $courseenv{'internal.coursecode'};
if ($cloneinst ne '') {
@@ -2909,6 +2986,14 @@ 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').' ';
@@ -3050,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";