--- loncom/interface/lonrequestcourse.pm 2023/03/11 04:54:24 1.95.2.7.2.3
+++ loncom/interface/lonrequestcourse.pm 2020/07/01 20:08:54 1.109
@@ -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.109 2020/07/01 20:08:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -163,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}).
+ '
';
@@ -2514,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;
@@ -2682,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');
@@ -2734,7 +2781,7 @@ sub requestlog_display_filter {
$typename = $typenames->{$crstype};
}
}
- $output .= '
'."\n";
+ $output .= '
'."\n";
}
$output .= '';
}
@@ -3095,6 +3142,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'}) {
@@ -3859,9 +3892,6 @@ ENDCLOSE
'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);
if (ref($postprocess) eq 'HASH') {
$customized = $postprocess->{'createdcustomized'};
}
@@ -4036,7 +4066,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) {
@@ -4354,7 +4384,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'},
@@ -4390,8 +4420,6 @@ sub pending_validation_form {
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';
$output .= '
'."\n".
'
'."\n".
@@ -4417,7 +4445,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 ++;
}
@@ -4620,9 +4648,11 @@ sub generate_date_items {
}
sub print_textbook_form {
- my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_;
+ my ($r,$dom,$incdoms,$domdefs,$settings,$can_request,$crstype,$formhash) = @_;
my (%prefab,%ordered,%numprefab);
- my $crstype = 'textbook';
+ if ($crstype eq '') {
+ $crstype = 'textbook';
+ }
#
# Retrieve list of prefabricated courses (textbook courses and templates) cloneable by user
#
@@ -4682,7 +4712,7 @@ sub print_textbook_form {
owner => $courseinfo{'internal.courseowner'},
releaserequired => $courseinfo{'internal.releaserequired'},
type => $courseinfo{'type'},
- };
+ };
}
}
@@ -4739,31 +4769,37 @@ sub print_textbook_form {
my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent,$numdomcourses,$customvalidationjs);
$jscript .= $customjs;
- my %loaditems;
+ my (%loaditems,$args);
$loaditems{'onload'} = 'javascript:uncheckAllRadio();'.$customonload;
- $r->print(&header('Course Request',$jscript,\%loaditems));
+ if ($crstype eq 'lti') {
+ $args = { 'only_body' => 1};
+ }
+ $r->print(&header('Course Request',$jscript,\%loaditems,undef,$args));
if (ref($can_request) eq 'HASH') {
- unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
+ unless (((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) ||
+ ($crstype eq 'lti')) {
&Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/requestcourse',
text => 'Pick action',
});
}
}
- &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+ unless ($crstype eq 'lti') {
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
- &startContentScreen($r,'textbookrequests');
+ &startContentScreen($r,'textbookrequests');
#
# Show domain selector form, if required.
#
- if (@{$incdoms} > 1) {
- my $onchange = 'this.form.submit()';
- $r->print('