[LON-CAPA-cvs] cvs: loncom /interface lonrequestcourse.pm
raeburn
raeburn at source.lon-capa.org
Sat Jun 13 20:02:43 EDT 2015
raeburn Sun Jun 14 00:02:43 2015 EDT
Modified files:
/loncom/interface lonrequestcourse.pm
Log:
- Textbook/Template course requests
- Additional content option -- select from colleagues' courses for which
requester has rights to clone.
- Existing single-use code moved to new routines: clone_selection_table()
and custom_formitems() to facilitate re-use.
- Prompts to request author role or create another course, on page
displayed after course request is processed can be suppressed, if
custom output is planned from localenroll::crsreq_updates().
- Additional items can be sent to localenroll::crsreq_updates():
(_LC_coursedomainname, _LC_ownerfullname, _LC_owneremail).
- Additional calls to lonnet::auto_crsreq_update() for new actions:
(a) initializereview and (b) prereview used to support custom
javascript in textbook request page, and custom onload action.
-------------- next part --------------
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.89 loncom/interface/lonrequestcourse.pm:1.90
--- loncom/interface/lonrequestcourse.pm:1.89 Tue Jun 9 21:22:57 2015
+++ loncom/interface/lonrequestcourse.pm Sun Jun 14 00:02:43 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.89 2015/06/09 21:22:57 damieng Exp $
+# $Id: lonrequestcourse.pm,v 1.90 2015/06/14 00:02:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1574,8 +1574,8 @@
\%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') {
@@ -1584,10 +1584,14 @@
'<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
}
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('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
+ unless ($customized) {
+ $r->print('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
+ }
}
}
} elsif ($state eq 'reqauthor') {
@@ -3636,15 +3640,15 @@
accessend => $accessend,
personnel => \%personnel,
};
- my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,
- $req_notifylist,\@instsections,\%domconfig);
- return ($result,$output);
+ my ($result,$output,$customized) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,
+ $instcode,$req_notifylist,\@instsections,\%domconfig);
+ return ($result,$output,$customized);
}
sub process_request {
my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,
$domconfig) = @_;
- my (@inststatuses,$storeresult,$creationresult,$output);
+ my (@inststatuses,$storeresult,$creationresult,$output,$customized);
my $val =
&Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'},
$env{'user.domain'},$env{'user.adv'},
@@ -3663,7 +3667,7 @@
}
$storeresult = 'notpermitted';
} else {
- my ($disposition,$message,$reqstatus,$coursedesc);
+ my ($disposition,$message,$reqstatus,$coursedesc,%customvalidation);
my %reqhash = (
reqtime => $now,
crstype => $crstype,
@@ -3683,10 +3687,10 @@
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},
$dom,$crstype,$limit,\$message);
} elsif ($val eq 'validate') {
- my ($inststatuslist,$validationchk,$validation,%custominfo);
+ my ($inststatuslist,$validationchk,$validation);
if (ref($details) eq 'HASH') {
if ($details->{'clonecrs'}) {
- $custominfo{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'};
+ $customvalidation{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'};
}
}
if (@inststatuses > 0) {
@@ -3698,27 +3702,18 @@
$instseclist = join(',',@{$instsections});
}
}
+#
+# Retrieve any custom form information used for validation
+#
my $preprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'prevalidate',$env{'user.name'},
$env{'user.domain'},$fullname,$coursedesc);
if (ref($preprocess) 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})) {
- @{$custominfo{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
- }
- } else {
- if (exists($env{'form.'.$key})) {
- $custominfo{$key} = $env{'form.'.$key};
- }
- }
- }
- }
+ &custom_formitems($preprocess,\%customvalidation);
}
$validationchk =
&Apache::lonnet::auto_courserequest_validation($dom,
$env{'user.name'}.':'.$env{'user.domain'},$crstype,
- $inststatuslist,$instcode,$instseclist,\%custominfo);
+ $inststatuslist,$instcode,$instseclist,\%customvalidation);
if ($validationchk =~ /:/) {
($validation,$message) = split(':',$validationchk);
} else {
@@ -3738,21 +3733,15 @@
my ($modified,$queued,$coursedesc,$token,%customitems);
unless ($disposition eq 'rejected') {
my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'},
- $env{'user.domain'},$fullname,$coursedesc);
+ $env{'user.domain'},$fullname,$coursedesc,undef,
+ undef,undef,\%customvalidation);
+#
+# Retrieve any custom form information submitted with review page and include in request details.
+#
if (ref($inprocess) eq 'HASH') {
- if (ref($inprocess->{'formitems'}) eq 'HASH') {
- foreach my $key (keys(%{$inprocess->{'formitems'}})) {
- if ($inprocess->{'formitems'}->{$key} eq 'multiple') {
- if (exists($env{'form.'.$key})) {
- @{$customitems{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
- }
- } else {
- if (exists($env{'form.'.$key})) {
- $customitems{$key} = $env{'form.'.$key};
- $reqhash{'custom'}{$key} = $customitems{$key};
- }
- }
- }
+ &custom_formitems($inprocess,\%customitems);
+ foreach my $key (keys(%customitems)) {
+ $reqhash{'custom'}{$key} = $customitems{$key};
}
}
}
@@ -3786,10 +3775,24 @@
$customitems{'_LC_clonefrom'} = $details->{'clonedom'}.'_'.$details->{'clonecrs'};
}
}
+ $customitems{'_LC_ownerfullname'} = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'},'first');
+ my $owneremail;
+ my %emails = &Apache::loncommon::getemails();
+ foreach my $email ('permanentemail','critnotification','notification') {
+ $owneremail = $emails{$email};
+ last if ($owneremail ne '');
+ }
+ if ($owneremail ne '') {
+ $customitems{'_LC_owneremail'} = $owneremail;
+ }
+ $customitems{'_LC_coursedomainname'} = &Apache::lonnet::domain($dom,'description');
my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
\$code,\%customitems);
+ if (ref($postprocess) eq 'HASH') {
+ $customized = $postprocess->{'createdcustomized'};
+ }
if ($result eq 'created') {
$disposition = 'created';
$reqstatus = 'created';
@@ -3816,7 +3819,10 @@
}
}
}
- $output .= '<br />'.$role_result.'</p>';
+ unless ($customized) {
+ $output .= '<br />'.$role_result;
+ }
+ $output .= '</p>';
$creationresult = 'created';
} else {
$output = '<span class="LC_error">';
@@ -3921,6 +3927,7 @@
if ((ref($postprocess) eq 'HASH') &&
((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) {
¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess);
+ $customized = $postprocess->{'createdcustomized'};
}
} elsif ($disposition eq 'pending') {
my $pendingform;
@@ -3933,6 +3940,9 @@
} else {
$output .= ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess);
}
+ if (ref($postprocess) eq 'HASH') {
+ $customized = $postprocess->{'createdcustomized'};
+ }
}
}
if ($validationerror ne '') {
@@ -3943,9 +3953,34 @@
}
}
if ($creationresult ne '') {
- return ($creationresult,$output);
+ return ($creationresult,$output,$customized);
} else {
- return ($storeresult,$output);
+ return ($storeresult,$output,$customized);
+ }
+}
+
+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;
+ }
+ }
+ }
}
}
@@ -4499,16 +4534,19 @@
}
#
-# 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;
@@ -4517,9 +4555,59 @@
my $numcurrent = scalar(keys(%cloneable));
- my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent);
+#
+# 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));
+
+ 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;
- $loaditems{'onload'} = 'javascript:uncheckAllRadio();';
+ $loaditems{'onload'} = 'javascript:uncheckAllRadio();'.$customonload;
$r->print(&header('Course Request',$jscript,\%loaditems));
if (ref($can_request) eq 'HASH') {
@@ -4564,7 +4652,7 @@
#
# Content source selection, if more than one available
#
- if (keys(%cloneable) || keys(%ordered)) {
+ if (keys(%cloneable) || keys(%ordered) || keys(%domcloneable)) {
$r->print('<div>'.
'<fieldset><legend>'.&mt('Course Content').'</legend>');
if (keys(%ordered)) {
@@ -4584,6 +4672,11 @@
'<input type="radio" name="cloning" value="existing" onclick="javascript:cloneChoice();" />'.
&mt('Copy one of your courses').'</label></span>'.(' 'x2).' ');
}
+ if (keys(%domcloneable)) {
+ $r->print('<span class="LC_nobreak"><label>'.
+ '<input type="radio" name="cloning" value="colleague" onclick="javascript:cloneChoice();" />'.
+ &mt("Copy a colleague's course").'</label></span>'.(' 'x2).' ');
+ }
$r->print('<span class="LC_nobreak"><label>'.
'<input type="radio" name="cloning" value="none" checked="checked" onclick="javascript:cloneChoice();" />'.
&mt('Empty course shell').'</label></span>');
@@ -4645,90 +4738,39 @@
#
# Table of user's current courses (owner and/or course coordinator)
#
+ my %lt = &clone_text();
if (keys(%cloneable)) {
- my %lt = &clone_text();
$r->print('<div id="showexisting" style="display:none">'.
- &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row().
- '<th>'.&mt('Title').'</th>'.
- '<th>'.&mt('Owner/co-owner(s)').'</th>'.
- &Apache::loncommon::end_data_table_header_row());
- my %allownernames;
- my %sortbytitle;
- foreach my $cid (sort(keys(%cloneable))) {
- if (ref($cloneable{$cid}) eq 'HASH') {
- my $cdesc = $cloneable{$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, at owners,%ownernames);
- my $singleowner = $cloneable{$cid}{'internal.courseowner'};
- push(@owners,$singleowner);
- if ($cloneable{$cid}{'co-owners'} ne '') {
- foreach my $item (split(/,/,$cloneable{$cid}{'internal.co-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));
- }
- $r->print(&Apache::loncommon::start_data_table_row().
- '<td><label><input type="radio" name="owned" value="'.$cid.'" />'.
- ' '.$cleantitle.'</label></td>'.
- '<td>'.$namestr.'</td>'.
- &Apache::loncommon::end_data_table_row());
- }
- }
- }
- $r->print(&Apache::loncommon::end_data_table().
- '<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
- '</label><br /><label>'.
- '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
- '</label><br /><label>'.
- '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
- $lt{'shd'}.'</label>'.
- '<input type="text" size="5" name="dateshift" value="365" />'.
- '</div>');
+ &clone_selection_table($dom,'owned',\%cloneable).
+ '<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
+ '</label><br /><label>'.
+ '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
+ '</label><br /><label>'.
+ '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
+ $lt{'shd'}.'</label>'.
+ '<input type="text" size="5" name="dateshift" value="365" />'.
+ '</div>');
}
#
+# Table of other cloneable courses from user's domain (exclude own courses)
+#
+ if (keys(%domcloneable)) {
+ $r->print('<div id="showcolleague" style="display:none">'.
+ &clone_selection_table($dom,'colleague',\%domcloneable).
+ '<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
+ '</label><br /><label>'.
+ '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
+ '</label><br /><label>'.
+ '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
+ $lt{'shd'}.'</label>'.
+ '<input type="text" size="5" name="dateshift" value="365" />'.
+ '</div>');
+ }
+
+#
# End of content selector
#
- if (keys(%cloneable) || keys(%ordered)) {
+ if (keys(%cloneable) || keys(%domcloneable) || keys(%ordered)) {
$r->print('</fieldset></div>');
}
@@ -4759,11 +4801,6 @@
#
# Display any custom fields for this course type
#
- my $fullname = &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'});
- my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'review',
- $env{'user.name'},
- $env{'user.domain'},$fullname);
if (ref($postprocess) eq 'HASH') {
if ($postprocess->{'reviewweb'}) {
$r->print($postprocess->{'reviewweb'});
@@ -4786,6 +4823,84 @@
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, at owners,%ownernames);
+ my $singleowner = $cloneableref->{$cid}{'internal.courseowner'};
+ push(@owners,$singleowner);
+ if ($cloneableref->{$cid}{'co-owners'} ne '') {
+ foreach my $item (split(/,/,$cloneableref->{$cid}{'internal.co-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().
+ '<td><label><input type="radio" name="'.$name.'" value="'.$cid.'" />'.
+ ' '.$cleantitle.'</label></td>'.
+ '<td>'.$namestr.'</td>'.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ }
+ if ($output) {
+ return &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt('Title').'</th>'.
+ '<th>'.&mt('Owner/co-owner(s)').'</th>'.
+ &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 ($uniquecode,$req_notifylist);
@@ -4811,6 +4926,8 @@
$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) {
@@ -4872,28 +4989,33 @@
}
my $lonhost = $r->dir_config('lonHostID');
$r->rflush();
- my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,'',
- $req_notifylist,[],$domconfig);
+ 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);
+ unless ($customized) {
+ &print_author_prompt($r,$action,$cnum,$dom,$crstype,$result);
+ }
} elsif ($result eq 'created') {
- $r->print('<p><a href="/adm/requestcourse">'.&mt('Create another course').'</a></p>');
+ unless ($customized) {
+ $r->print('<p><a href="/adm/requestcourse">'.&mt('Create another course').'</a></p>');
+ }
}
&endContentScreen($r);
$r->print(&Apache::loncommon::end_page());
}
sub textbook_request_javascript {
- my ($numprefab,$numcurrent) = @_;
+ my ($numprefab,$numcurrent,$numcolleague,$customvalidationjs) = @_;
return unless (ref($numprefab) eq 'HASH');
- return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent);
+ 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.',
- title => 'Please enter a course title.',
+ 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.',
);
&js_escape(\%js_lt);
return <<"ENDSCRIPT";
@@ -4902,7 +5024,7 @@
var radioLength = document.requestcourse.cloning.length;
if (radioLength == undefined) {
var val = document.requestcourse.cloning.value;
- if ((val == 'textbook') || (val == 'template') || (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';
@@ -4914,7 +5036,7 @@
} else {
for (var i=0; i<radioLength; i++) {
var val = document.requestcourse.cloning[i].value;
- if ((val == 'textbook') || (val == 'template') || (val == 'existing')) {
+ if ((val == 'textbook') || (val == 'template') || (val == 'existing') || (val == 'colleague')) {
var elem = document.getElementById('show'+val);
if (document.requestcourse.cloning[i].checked) {
elem.style.display = 'block';
@@ -4928,6 +5050,9 @@
if (val == 'existing') {
uncheckRadio('owned');
}
+ if (val == 'colleague') {
+ uncheckRadio('colleague');
+ }
elem.style.display = 'none';
}
}
@@ -4955,6 +5080,7 @@
var numbook = $numprefab->{'textbooks'};
var numtemplate = $numprefab->{'templates'};
var numcurrent = $numcurrent;
+ var numcolleague = $numcolleague;
if (numbook > 0) {
uncheckRadio('textbook');
}
@@ -4964,6 +5090,9 @@
if (numcurrent > 0) {
uncheckRadio('existing');
}
+ if (numcolleague > 0) {
+ uncheckRadio('colleague');
+ }
return;
}
@@ -4991,7 +5120,7 @@
}
}
var group;
- if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing')) {
+ if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing') || (cloneChoice == 'colleague')) {
var group;
if (cloneChoice == 'textbook') {
group = document.getElementsByName('book');
@@ -4999,7 +5128,11 @@
if (cloneChoice == 'template') {
group = document.getElementsByName('template');
} else {
- group = document.getElementsByName('owned');
+ if (cloneChoice == 'existing') {
+ group = document.getElementsByName('owned');
+ } else {
+ group = document.getElementsByName('colleague');
+ }
}
}
var groupLength = group.length;
@@ -5023,7 +5156,11 @@
if (cloneChoice == 'template') {
alert("$js_lt{'template'}");
} else {
- alert("$js_lt{'existing'}");
+ if (cloneChoice == 'existing') {
+ alert("$js_lt{'existing'}");
+ } else {
+ alert("js_$lt{'colleague'}");
+ }
}
}
return false;
@@ -5034,6 +5171,7 @@
alert("$js_lt{'title'}");
return false;
}
+ $customvalidationjs
return true;
}
More information about the LON-CAPA-cvs
mailing list