'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'
';
@@ -3698,9 +4098,50 @@ sub process_request {
}
}
if ($creationresult ne '') {
- return ($creationresult,$output);
+ return ($creationresult,$output,$customized);
} else {
- return ($storeresult,$output);
+ return ($storeresult,$output,$customized);
+ }
+}
+
+sub devalidate_remote_instcats {
+ if ($modified_dom ne '') {
+ my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
+ my %thismachine;
+ map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
+ if (keys(%servers)) {
+ foreach my $server (keys(%servers)) {
+ next if ($thismachine{$server});
+ &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
+ }
+ }
+ $modified_dom = '';
+ }
+ return;
+}
+
+sub custom_formitems {
+ my ($preprocess,$customhash) = @_;
+ return unless ((ref($preprocess) eq 'HASH') && (ref($customhash) eq 'HASH'));
+ if (ref($preprocess->{'formitems'}) eq 'HASH') {
+ foreach my $key (keys(%{$preprocess->{'formitems'}})) {
+ if ($preprocess->{'formitems'}->{$key} eq 'multiple') {
+ if (exists($env{'form.'.$key})) {
+ my @items = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
+ foreach my $item (@items) {
+ $item =~ s/(`)/'/g;
+ $item =~ s/\$/\(\$\)/g;
+ push(@{$customhash->{$key}},$item);
+ }
+ }
+ } else {
+ if (exists($env{'form.'.$key})) {
+ $customhash->{$key} = $env{'form.'.$key};
+ $customhash->{$key} =~ s/(`)/'/g;
+ $customhash->{$key} =~ s/\$/\(\$\)/g;
+ }
+ }
+ }
}
}
@@ -3840,7 +4281,7 @@ sub update_requestors_roles {
}
sub notification_information {
- my ($disposition,$req_notifylist,$cnum,$now,$code) = @_;
+ my ($disposition,$req_notifylist,$dom,$cnum,$now,$code,$postprocess,$crstype) = @_;
my %emails = &Apache::loncommon::getemails();
my $address;
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
@@ -3856,35 +4297,128 @@ sub notification_information {
if ($address ne '') {
$output.= &mt('An e-mail will also be sent to: [_1] when this occurs.',$address).''.
+ &mt('Students can automatically select your course by entering this code: [_1].',''.$code.'').
+ '
'.
+ &mt('A message has been sent to your LON-CAPA account with this information.');
+ if ($address ne '') {
+ $output.= '
'.&mt('An e-mail has also been sent to: [_1] with this code.',$address);
+ }
+ $output .= '
';
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
+ foreach my $item (@{$postprocess->{'createdmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$addmsg},$item);
+ }
+ }
+ }
+ }
+ if ($postprocess->{'createdweb'}) {
+ $output .= $postprocess->{'createdweb'}
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ my $type = 'createdcrsreq';
+ if ($code) {
+ $type = 'uniquecode';
+ }
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,$dom.'_'.$cnum,$env{'form.cdescr'},
+ $now,$type,$sender,'','',$crstype);
+ }
}
} else {
$output .= ''.
@@ -3894,6 +4428,102 @@ sub notification_information {
return $output;
}
+sub notify_admin {
+ my ($dom,$crstype,$contextdesc,$textstr,$timestamp,$emailsref) = @_;
+ if ((ref($emailsref) eq 'HASH') && (keys(%{$emailsref}))) {
+ my $emailto = join(',',sort(keys(%{$emailsref})));
+ my (@rawmsg,$rawsubj,$msgtxt);
+ if ($crstype eq 'community') {
+ $rawsubj = 'Community request to review';
+ $msgtxt = 'Creation of the following community: [_1]was requested by [_2] on [_3].';
+ } else {
+ $rawsubj = 'Course request to review';
+ $msgtxt = 'Creation of the following course: [_1]was requested by [_2] on [_3].';
+ }
+ $timestamp =&Apache::lonlocal::locallocaltime($timestamp);
+ push(@rawmsg,{
+ mt => $msgtxt,
+ args => ["\n $contextdesc\n",$textstr,$timestamp],
+ },
+ {
+ mt =>'[_1]A Domain Coordinator will use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which can either be approved or rejected.',
+ args => ["\n","\n\n","\n\n"],
+ });
+
+ my $sender_lh = &Apache::loncommon::user_lang($env{'user.name'},$env{'user.domain'});
+ my $subject = &mt_user($sender_lh,$rawsubj);
+ my $message = '';
+ foreach my $item (@rawmsg) {
+ if (ref($item) eq 'HASH') {
+ if (ref($item->{args}) eq 'ARRAY') {
+ $message .= &mt_user($sender_lh,$item->{mt},@{$item->{args}})."\n";
+ } else {
+ $message .= &mt_user($sender_lh,$item->{mt})."\n";
+ }
+ }
+ }
+ my $chgmail = "To: $emailto\n".
+ "Subject: $subject\n".
+ "Content-type: text/plain\; charset=UTF-8\n".
+ "MIME-Version: 1.0\n\n".
+ "$message\n\n";
+ if (open(my $mailh, "|/usr/lib/sendmail -oi -t -odb")) {
+ print $mailh $chgmail;
+ close($mailh);
+ }
+ }
+}
+
+sub pending_validation_form {
+ my ($r,$cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
+ my $output;
+ my %postvalues = (
+ 'owner' => $env{'user.name'}.':'.$env{'user.domain'},
+ 'course' => $cdom.'_'.$cnum,
+ 'coursetype' => $crstype,
+ );
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
+
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ my ($url,$buttontext,$code,@fields);
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ $postvalues{'description'} = $cdesc;
+ $url = $domconfig{'requestcourses'}{'validation'}{'url'};
+ if (ref($domconfig{'requestcourses'}{'validation'}{'fields'}) eq 'ARRAY') {
+ @fields = @{$domconfig{'requestcourses'}{'validation'}{'fields'}};
+ }
+ $buttontext = $domconfig{'requestcourses'}{'validation'}{'button'};
+ $output .= $domconfig{'requestcourses'}{'validation'}{'markup'};
+ if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
+ $output .= '
'."\n";
+ }
+ }
+ }
+ return $output;
+}
+
sub check_autolimit {
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
@@ -3908,7 +4538,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 ++;
}
@@ -3959,6 +4589,7 @@ sub retrieve_settings {
}
$env{'form.datemode'} = $reqinfo{'datemode'};
$env{'form.dateshift'} = $reqinfo{'dateshift'};
+ $env{'form.tinyurls'} = $reqinfo{'tinyurls'};
if ($reqinfo{'crstype'} eq 'official') {
$env{'form.autoadds'} = $reqinfo{'autoadds'};
$env{'form.autodrops'} = $reqinfo{'autodrops'};
@@ -4110,26 +4741,29 @@ sub generate_date_items {
}
sub print_textbook_form {
- my ($r,$dom,$incdoms,$domdefs,$settings) = @_;
- my ($bookshash,%ordered);
- my $crstype = 'textbook';
-#
-# Retrieve list of textbook courses cloneable by user
-#
- my $numbook;
- if (ref($settings) eq 'HASH') {
- $bookshash = $settings->{'textbooks'};
- if (ref($bookshash) eq 'HASH') {
- foreach my $item (keys(%{$bookshash})) {
- my ($clonedom,$clonecrs) = split(/_/,$item);
- if (ref($bookshash->{$item}) eq 'HASH') {
+ my ($r,$dom,$incdoms,$domdefs,$settings,$can_request,$crstype,$formhash) = @_;
+ my (%prefab,%ordered,%numprefab);
+ if ($crstype eq '') {
+ $crstype = 'textbook';
+ }
+#
+# Retrieve list of prefabricated courses (textbook courses and templates) cloneable by user
+#
+ foreach my $type ('textbooks','templates') {
+ $numprefab{$type} = 0;
+ if (ref($settings) eq 'HASH') {
+ $prefab{$type} = $settings->{$type};
+ if (ref($prefab{$type}) eq 'HASH') {
+ foreach my $item (keys(%{$prefab{$type}})) {
my ($clonedom,$clonecrs) = split(/_/,$item);
- if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
- $env{'user.domain'},$clonecrs,$clonedom,$crstype)) {
-
- my $num = $bookshash->{$item}{'order'};
- $ordered{$num} = $item;
- $numbook ++;
+ if (ref($prefab{$type}{$item}) eq 'HASH') {
+ if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
+ $env{'user.domain'},$clonecrs,$clonedom,$crstype,$dom)) {
+
+ my $num = $prefab{$type}{$item}{'order'};
+ $ordered{$type}{$num} = $item;
+ $numprefab{$type} ++;
+ }
}
}
}
@@ -4147,41 +4781,118 @@ sub print_textbook_form {
}
#
-# Retrieve information about courses owned by user, or in which user has an active or future
-# Course Coordinator role
+# Retrieve information about courses owned by user, or in which user has an active
+# Course Coordinator role
#
my $numcurrent;
my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'},
- undef,undef,undef,'Course');
+ '.',undef,undef,'Course');
my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
- ['active','future'],['cc']);
+ ['active'],['cc']);
+
+ my $cc_clone = '';
foreach my $role (keys(%ccroles)) {
my ($cnum,$cdom,$rest) = split(/:/,$role,3);
+ $cc_clone .= $cdom.':'.$cnum.'&';
unless (exists($cloneable{$cdom.'_'.$cnum})) {
my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1});
- $cloneable{$cdom.'_'.$cnum} = \%courseinfo;
+ $cloneable{$cdom.'_'.$cnum} = {
+ context => $courseinfo{'internal.creationcontext'},
+ created => $courseinfo{'internal.created'},
+ creator => $courseinfo{'internal.creator'},
+ description => $courseinfo{'description'},
+ inst_code => $courseinfo{'coursecode'},
+ owner => $courseinfo{'internal.courseowner'},
+ releaserequired => $courseinfo{'internal.releaserequired'},
+ type => $courseinfo{'type'},
+ };
}
}
my $numcurrent = scalar(keys(%cloneable));
- my $jscript = &textbook_request_javascript($numbook,$numcurrent);
- my %loaditems;
- $loaditems{'onload'} = 'javascript:uncheckAllRadio();';
- $r->print(&header('Course Request',$jscript,\%loaditems));
+#
+# Retrieve information about courses from user's domain which user can clone, but which not owned
+# or cloneable based on Course Coordinator role.
+#
+ my ($numdomcourses,%domcloneable);
+ my %allcloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',undef,undef,'Course',
+ undef,undef,undef,undef,undef,
+ $env{'user.name'}.':'.$env{'user.domain'},
+ $cc_clone,1);
+ foreach my $cid (keys(%allcloneable)) {
+ unless (exists($cloneable{$cid})) {
+ $domcloneable{$cid} = $allcloneable{$cid};
+ }
+ }
+ $numdomcourses = scalar(keys(%domcloneable));
- &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+ my $fullname = &Apache::loncommon::plainname($env{'user.name'},
+ $env{'user.domain'});
+
+#
+# Retrieve any custom form information prior to rendering page
+#
+
+ my $initprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'initializereview',$env{'user.name'},
+ $env{'user.domain'},$fullname);
+ my %custominit;
+ if (ref($initprocess) eq 'HASH') {
+ &custom_formitems($initprocess,\%custominit);
+ }
+
+#
+# Retrieve any custom onload actions or javascript used for page before rendering
+#
+
+ my ($customonload,$customjs,$customvalidationjs);
+ my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'prereview',$env{'user.name'},
+ $env{'user.domain'},$fullname,undef,undef,
+ undef,undef,\%custominit);
+ if (ref($inprocess) eq 'HASH') {
+ $customonload = $inprocess->{'onload'};
+ $customjs = $inprocess->{'javascript'};
+ $customvalidationjs = $inprocess->{'validationjs'};
+ }
+
+ my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'review',
+ $env{'user.name'},
+ $env{'user.domain'},$fullname,undef,undef,
+ undef,undef,\%custominit);
+
+ my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent,$numdomcourses,$customvalidationjs);
+ $jscript .= $customjs;
+ my (%loaditems,$args);
+ $loaditems{'onload'} = 'javascript:uncheckAllRadio();'.$customonload;
+ 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'})) ||
+ ($crstype eq 'lti')) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => 'Pick action',
+ });
+ }
+ }
+ unless ($crstype eq 'lti') {
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+ &startContentScreen($r,'textbookrequests');
#
# Show domain selector form, if required.
#
- if (@{$incdoms} > 1) {
- my $onchange = 'this.form.submit()';
- $r->print('
'.
- &Apache::loncommon::end_page());
+
+ if (($crstype eq 'lti') && (ref($formhash) eq 'HASH')) {
+ foreach my $item (keys(%{$formhash})) {
+ $r->print('
'."\n");
+ }
+ }
+
+ $r->print('');
+ 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) = @_;
+ 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') {
@@ -4396,7 +5207,6 @@ sub process_textbook_request {
}
}
}
- my $crstype = 'textbook';
my $now = time;
my $reqtype = $env{'form.cloning'};
my (@inststatuses,$storeresult,$creationresult);
@@ -4404,8 +5214,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) {
@@ -4413,7 +5227,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);
@@ -4423,15 +5237,30 @@ sub process_textbook_request {
undef($clonedom);
}
}
- $r->print(&header('Course Creation'));
-
- &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'));
+ 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');
+ }
my $details = {
owner => $env{'user.name'},
@@ -4448,36 +5277,90 @@ sub process_textbook_request {
accessend => $accessend,
personnel => {},
};
- if ($reqtype eq 'existing') {
- $details->{datemode} = $env{'form.datemode'};
- $details->{dateshift} = $env{'form.dateshift'};
- }
- my ($result,$output) = &process_request($dom,$cnum,$crstype,$now,$details,'',$req_notifylist,[],$domconfig);
+ 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');
+ $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);
}
$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';
@@ -4489,7 +5372,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;
}
@@ -4541,7 +5438,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;
@@ -4554,17 +5451,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;
@@ -4582,24 +5487,74 @@ 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;
}
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".''."\n");
+ $r->print('- '.&mt('Request a Course').'
'."\n");
+ $r->print('- '.&mt('Course Request History').'
'."\n");
+ $r->print("\n".'
'."\n");
+ $r->print('');
+}
+
+sub endContentScreen {
+ my ($r)=@_;
+ $r->print('
');
+}
1;