');
+ if (@{$incdoms} > 1) {
+ my $onchange = 'this.form.submit()';
+ $r->print('
');
- &endContentScreen($r).
+ unless ($crstype eq 'lti') {
+ &endContentScreen($r);
+ }
$r->print(&Apache::loncommon::end_page());
return;
}
+sub clone_selection_table {
+ my ($dom,$name,$cloneableref) = @_;
+ return unless ((ref($cloneableref) eq 'HASH') && (($name eq 'owned') || ($name eq 'colleague')));
+ my %allownernames;
+ my %sortbytitle;
+ my $output;
+ foreach my $cid (sort(keys(%{$cloneableref}))) {
+ if (ref($cloneableref->{$cid}) eq 'HASH') {
+ my $cdesc = $cloneableref->{$cid}{'description'};
+ $cdesc =~ s/`/'/g;
+ if ($cdesc ne '') {
+ push(@{$sortbytitle{$cdesc}},$cid);
+ }
+ }
+ }
+ foreach my $title (sort(keys(%sortbytitle))) {
+ if (ref($sortbytitle{$title}) eq 'ARRAY') {
+ foreach my $cid (sort(@{$sortbytitle{$title}})) {
+ my $cleantitle=&HTML::Entities::encode($title,'<>&"');
+ $cleantitle=~s/'/\\'/g;
+ $cleantitle =~ s/^\s+//;
+ my ($namestr,@owners,%ownernames);
+ if ($cloneableref->{$cid}{'owner'} ne '') {
+ push(@owners,$cloneableref->{$cid}{'owner'});
+ }
+ if ($cloneableref->{$cid}{'co-owners'} ne '') {
+ foreach my $item (split(/,/,$cloneableref->{$cid}{'co-owners'})) {
+ if (($item ne '') && (!grep(/^\Q$item\E$/,@owners))) {
+ push(@owners,$item);
+ }
+ }
+ }
+ foreach my $owner (@owners) {
+ my ($ownername,$ownerdom);
+ if ($owner =~ /:/) {
+ ($ownername,$ownerdom) = split(/:/,$owner);
+ } else {
+ $ownername = $owner;
+ if ($owner ne '') {
+ $ownerdom = $dom;
+ }
+ }
+ if ($ownername ne '' && $ownerdom ne '') {
+ if (exists($allownernames{$ownername.':'.$ownerdom})) {
+ $ownernames{$ownername.':'.$ownerdom} = $allownernames{$ownername.':'.$ownerdom};
+ } else {
+ my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
+ $ownernames{$ownername.':'.$ownerdom} = \%namehash;
+ $allownernames{$ownername.':'.$ownerdom} = $ownernames{$ownername.':'.$ownerdom};
+ }
+ }
+ }
+ my @lastnames;
+ foreach my $owner (keys(%ownernames)) {
+ if (ref($ownernames{$owner}) eq 'HASH') {
+ push(@lastnames,$ownernames{$owner}{'lastname'});
+ }
+ }
+ if (@lastnames) {
+ $namestr = join(', ',sort(@lastnames));
+ }
+ $output .= &Apache::loncommon::start_data_table_row().
+ '
| '.
+ '
'.$namestr.' | '.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ }
+ if ($output) {
+ return &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '
'.&mt('Title').' | '.
+ '
'.&mt('Owner/co-owner(s)').' | '.
+ &Apache::loncommon::end_data_table_header_row().
+ $output.
+ &Apache::loncommon::end_data_table();
+ }
+ return;
+}
+
sub process_textbook_request {
- my ($r,$dom,$action,$domdefs,$domconfig,$can_request) = @_;
+ my ($r,$dom,$action,$domdefs,$domconfig,$can_request,$crstype) = @_;
my ($uniquecode,$req_notifylist);
- my $crstype = 'textbook';
+ if ($crstype eq '') {
+ $crstype = 'textbook';
+ }
if (ref($domconfig) eq 'HASH') {
if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
if (ref($domconfig->{'requestcourses'}{'notify'}) eq 'HASH') {
@@ -4702,8 +5134,12 @@ sub process_textbook_request {
my ($clonefrom,$clonedom,$clonecrs);
if ($reqtype eq 'textbook') {
$clonefrom = $env{'form.book'};
+ } elsif ($reqtype eq 'template') {
+ $clonefrom = $env{'form.template'};
} elsif ($reqtype eq 'existing') {
$clonefrom = $env{'form.owned'};
+ } elsif ($reqtype eq 'colleague') {
+ $clonefrom = $env{'form.colleague'};
}
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
if ($clonefrom) {
@@ -4711,7 +5147,7 @@ sub process_textbook_request {
if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') {
my $canclone =
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
- $env{'user.domain'},$clonecrs,$clonedom,$crstype);
+ $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom);
unless ($canclone) {
undef($clonecrs);
undef($clonedom);
@@ -4721,24 +5157,30 @@ sub process_textbook_request {
undef($clonedom);
}
}
- $r->print(&header('Course Creation'));
-
- if (ref($can_request) eq 'HASH') {
- unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
- &Apache::lonhtmlcommon::add_breadcrumb(
- { href => '/adm/requestcourse',
- text => 'Pick action',
- });
+ my $args;
+ if ($crstype eq 'lti') {
+ $args = { 'only_body' => 1};
+ }
+ $r->print(&header('Course Creation','','',undef,$args));
+
+ unless ($crstype eq 'lti') {
+ if (ref($can_request) eq 'HASH') {
+ unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => 'Pick action',
+ });
+ }
}
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => "Create Course",
+ }
+ );
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Request Processed'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+ &startContentScreen($r,'textbookrequests');
}
- &Apache::lonhtmlcommon::add_breadcrumb(
- { href => '/adm/requestcourse',
- text => "Create Course",
- }
- );
- &Apache::lonhtmlcommon::add_breadcrumb({text=>'Request Processed'});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
- &startContentScreen($r,'textbookrequests');
my $details = {
owner => $env{'user.name'},
@@ -4755,39 +5197,90 @@ sub process_textbook_request {
accessend => $accessend,
personnel => {},
};
- if ($reqtype eq 'existing') {
- $details->{datemode} = $env{'form.datemode'};
- $details->{dateshift} = $env{'form.dateshift'};
+ if (($clonecrs ne '') && ($clonedom ne '')) {
+ if ($reqtype eq 'existing') {
+ $details->{datemode} = $env{'form.owndatemode'};
+ if ($details->{datemode} eq 'shift') {
+ $details->{dateshift} = $env{'form.owndateshift'};
+ } else {
+ $details->{dateshift} = '';
+ }
+ $details->{tinyurls} = $env{'form.owntinyurls'};
+ } elsif ($reqtype eq 'colleague') {
+ $details->{datemode} = $env{'form.colldatemode'};
+ if ($details->{datemode} eq 'shift') {
+ $details->{dateshift} = $env{'form.colldateshift'};
+ } 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;
+ }
+ } else {
+ $details->{datemode} = '';
+ $details->{dateshift} = '';
+ $details->{tinyurls} = '';
}
my $lonhost = $r->dir_config('lonHostID');
- my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,'',
- $req_notifylist,[],$domconfig);
+ $r->rflush();
+ my ($result,$output,$customized) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,
+ '',$req_notifylist,[],$domconfig);
$r->print($output);
- if (&Apache::loncoursequeueadmin::author_prompt()) {
- &print_author_prompt($r,$action,$cnum,$dom,$crstype,$result);
+ if ($crstype eq 'lti') {
+ my $storecrs;
+ if ($env{'request.lti.login'}) {
+ my %lti = &Apache::lonnet::get_domain_lti($dom,'provider');
+ if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
+ $storecrs = $lti{$env{'request.lti.login'}}{'storecrs'};
+ }
+ if ($storecrs) {
+ my %consumers = &Apache::lonnet::get_dom('lticonsumers',[$env{'form.sourcecrs'}],$dom);
+ if (($env{'form.lti.sourcecrs'} ne '') && ($consumers{$env{'form.lti.sourcecrs'}} eq '') && ($cnum ne '')) {
+ &Apache::lonnet::put_dom('lticonsumers',{ $env{'form.lti.sourcecrs'} => $env{'request.lti.login'}.':'.$cnum },$dom);
+ }
+ }
+ }
+ } elsif (&Apache::loncoursequeueadmin::author_prompt()) {
+ unless ($customized) {
+ &print_author_prompt($r,$action,$cnum,$dom,$crstype,$result);
+ }
} elsif ($result eq 'created') {
- $r->print('
'.&mt('Create another course').'
');
+ unless ($customized) {
+ $r->print('
'.&mt('Create another course').'
');
+ }
+ }
+ unless ($crstype eq 'lti') {
+ &endContentScreen($r);
}
- &endContentScreen($r);
$r->print(&Apache::loncommon::end_page());
}
sub textbook_request_javascript {
- my ($numbook,$numcurrent) = @_;
- my %lt = &Apache::lonlocal::texthash(
- choose => 'Please select a content option.',
- textbook => 'Please select a textbook, or choose a different option.',
- existing => 'Please select one of your existing courses to copy, or choose a different option.',
- title => 'Please enter a course title.',
+ my ($numprefab,$numcurrent,$numcolleague,$customvalidationjs) = @_;
+ return unless (ref($numprefab) eq 'HASH');
+ return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent && !$numcolleague);
+ my %js_lt = &Apache::lonlocal::texthash(
+ choose => 'Please select a content option.',
+ textbook => 'Please select a textbook, or choose a different option.',
+ template => 'Please select a template, or choose a different option.',
+ existing => 'Please select one of your existing courses to copy, or choose a different option.',
+ colleague => "Please select a colleague's course to copy, or choose a different option.",
+ title => 'Please enter a course title.',
);
- return if (!$numbook && !$numcurrent);
+ &js_escape(\%js_lt);
return <<"ENDSCRIPT";
function cloneChoice() {
if (document.requestcourse.cloning) {
var radioLength = document.requestcourse.cloning.length;
if (radioLength == undefined) {
var val = document.requestcourse.cloning.value;
- if ((val == 'textbook') || (val == 'existing')) {
+ if ((val == 'textbook') || (val == 'template') || (val == 'existing') || (val == 'colleague')) {
var elem = document.getElementById('show'+val);
if (document.requestcourse.cloning.checked) {
elem.style.display = 'block';
@@ -4799,7 +5292,7 @@ function cloneChoice() {
} else {
for (var i=0; i
{'textbooks'};
+ var numtemplate = $numprefab->{'templates'};
var numcurrent = $numcurrent;
+ var numcolleague = $numcolleague;
if (numbook > 0) {
uncheckRadio('textbook');
}
+ if (numtemplate > 0) {
+ uncheckRadio('template');
+ }
if (numcurrent > 0) {
uncheckRadio('existing');
}
+ if (numcolleague > 0) {
+ uncheckRadio('colleague');
+ }
return;
}
@@ -4851,7 +5358,7 @@ function validTextbookReq() {
var radioLength = document.requestcourse.cloning.length;
if (radioLength == undefined) {
if (document.requestcourse.cloning.checked == false) {
- alert("$lt{'choose'}");
+ alert("$js_lt{'choose'}");
return false;
} else {
cloneChoice = document.requestcourse.cloning.value;
@@ -4864,17 +5371,25 @@ function validTextbookReq() {
}
}
if (cloneChoice == 0) {
- alert("$lt{'choose'}");
+ alert("$js_lt{'choose'}");
return false;
}
}
var group;
- if ((cloneChoice == 'textbook') || (cloneChoice == 'existing')) {
+ if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing') || (cloneChoice == 'colleague')) {
var group;
if (cloneChoice == 'textbook') {
group = document.getElementsByName('book');
} else {
- group = document.getElementsByName('owned');
+ if (cloneChoice == 'template') {
+ group = document.getElementsByName('template');
+ } else {
+ if (cloneChoice == 'existing') {
+ group = document.getElementsByName('owned');
+ } else {
+ group = document.getElementsByName('colleague');
+ }
+ }
}
var groupLength = group.length;
var chosen = 0;
@@ -4892,18 +5407,27 @@ function validTextbookReq() {
}
if (chosen == 0) {
if (cloneChoice == 'textbook') {
- alert("$lt{'textbook'}");
+ alert("$js_lt{'textbook'}");
} else {
- alert("$lt{'existing'}");
+ if (cloneChoice == 'template') {
+ alert("$js_lt{'template'}");
+ } else {
+ if (cloneChoice == 'existing') {
+ alert("$js_lt{'existing'}");
+ } else {
+ alert("$js_lt{'colleague'}");
+ }
+ }
}
return false;
}
}
}
if (document.requestcourse.cdescr.value == '') {
- alert("$lt{'title'}");
+ alert("$js_lt{'title'}");
return false;
}
+ $customvalidationjs
return true;
}
@@ -4911,6 +5435,33 @@ ENDSCRIPT
}
+sub textbook_request_disabled {
+ my ($r,$dom,$action,$can_request) = @_;
+ if (ref($can_request) eq 'HASH') {
+ if ($action eq 'process') {
+ unless ((scalar(keys(%{$can_request})) == 1)) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => 'Pick action',
+ });
+ }
+ }
+ }
+ $r->print(&header('Course Request'));
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests').
+ ''.
+ '
'.&mt('You do not have privileges to request creation of textbook courses.').'
');
+ if (ref($can_request) eq 'HASH') {
+ if (scalar(keys(%{$can_request})) > 1) {
+ $r->print('
'.&mt('Go back').'');
+ }
+ }
+ $r->print('
'.
+ &Apache::loncommon::end_page());
+ return;
+}
+
sub startContentScreen {
my ($r,$mode)=@_;
$r->print("\n".'