--- loncom/interface/lonrequestcourse.pm 2014/01/03 18:39:51 1.73
+++ loncom/interface/lonrequestcourse.pm 2023/03/11 04:44:51 1.116
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.73 2014/01/03 18:39:51 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.116 2023/03/11 04: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,13 +197,30 @@ 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);
+ if ($warning ne '') {
+ my $args = { only_body => 1 };
+ $r->print(&header('Course/Community Requests','','' ,'',$args).
+ '
'.&mt('Course/Community Request Details').'
'.
+ '
'.$warning.'
'.
+ &close_popup_form());
+ } else {
+ $states{'display'} = ['details'];
+ my $loaditems = &onload_action($action,$state);
+ my $page = 0;
+ &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
+ $loaditems,'','','','','',$showcredits,'','',
+ $uname,$udom);
}
} 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;
@@ -232,46 +274,7 @@ sub handler {
my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
if ($action eq 'display') {
- if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
- if ($env{'form.cnum'} ne '') {
- my $cnum = $env{'form.cnum'};
- my $queue = $env{'form.queue'};
- my $reqkey = $cnum.'_'.$queue;
- my $namespace = 'courserequestqueue';
- my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
- my %queued =
- &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
- if (ref($queued{$reqkey}) eq 'HASH') {
- $uname = $queued{$reqkey}{'ownername'};
- $udom = $queued{$reqkey}{'ownerdom'};
- if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
- $result = &retrieve_settings($dom,$cnum,$udom,$uname);
- } else {
- if ($env{'form.crstype'} eq 'community') {
- $warning = &mt('Invalid username or domain for community requestor');
- } else {
- $warning = &mt('Invalid username or domain for course requestor');
- }
- }
- } else {
- if ($env{'form.crstype'} eq 'community') {
- $warning = &mt('No information was found for this community request.');
- } else {
- $warning = &mt('No information was found for this course request.');
- }
- }
- } else {
- $warning = &mt('No course request ID provided.');
- }
- } else {
- if ($env{'form.crstype'} eq 'any') {
- $warning = &mt('You do not have rights to view course or community request information.');
- } elsif ($env{'form.crstype'} eq 'community') {
- $warning = &mt('You do not have rights to view community request information.');
- } else {
- $warning = &mt('You do not have rights to view course request information.');
- }
- }
+ ($uname,$udom,$result,$warning) = &domcoord_display($dom);
} elsif ((defined($state)) && (defined($action))) {
if (($action eq 'view') && ($state eq 'details')) {
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
@@ -436,7 +439,7 @@ function setCloneDisplay(courseForm) {
for (var i=0; i{$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'});
@@ -559,6 +564,7 @@ sub form_elements {
clonedom => 'selectbox',
datemode => 'radio',
dateshift => 'text',
+ tinyurls => 'radio',
},
enrollment => {
accessstart_month => 'selectbox',
@@ -765,6 +771,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})) {
@@ -773,42 +780,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.');
@@ -833,15 +849,24 @@ END
$pagetitle = 'Community Requests';
$pageinfo = &mt('Request creation of a new course, or review your pending requests.');
$domaintitle = &mt('Community Domain');
- } else {
+ } elsif ((ref($incdoms) eq 'ARRAY') && ((@{$incdoms} > 1) ||
+ ((@{$incdoms} == 1) && ($incdoms->[0] ne $dom)))) {
$pagetitle = 'Course/Community Requests';
$pageinfo = &mt('You do not have rights to request creation of courses in this domain; please choose a different domain.');
$domaintitle = &mt('Course/Community Domain');
+ } else {
+ $pagetitle = 'Course/Community Requests';
+ $pageinfo = &mt('You do not have rights to request creation of courses or communities.');
+ $earlyout = 1;
}
}
$r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb.
- '