--- loncom/interface/lonrequestcourse.pm 2019/07/25 20:23:52 1.107
+++ loncom/interface/lonrequestcourse.pm 2021/03/06 13:44:51 1.110
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.107 2019/07/25 20:23:52 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.110 2021/03/06 13:44:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -577,6 +577,7 @@ sub form_elements {
clonedom => 'selectbox',
datemode => 'radio',
dateshift => 'text',
+ tinyurls => 'radio',
},
enrollment => {
accessstart_month => 'selectbox',
@@ -2426,7 +2427,7 @@ sub print_cancel_request {
&Apache::loncommon::start_data_table_row().
'
';
@@ -2780,7 +2781,7 @@ sub requestlog_display_filter {
$typename = $typenames->{$crstype};
}
}
- $output .= '
'."\n";
+ $output .= '
'."\n";
}
$output .= '';
}
@@ -2956,7 +2957,7 @@ sub print_review {
$inst_values .= '
'.$env{'form.coursecredits'}.' | ';
}
- my %ctxt = &clone_text();
+ my %ctxt = &clone_text($env{'form.crstype'});
$inst_headers .= '
'.&mt('Clone From').' | ';
if (($env{'form.cloning'}) &&
($env{'form.clonecrs'} =~ /^$match_name$/) &&
@@ -2968,7 +2969,8 @@ sub print_review {
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
$env{'form.clonecrs'},('description','internal.coursecode'));
if (keys(%courseenv) > 0) {
- $inst_headers .= '
'.$ctxt{'dsh'}.' | ';
+ $inst_headers .= '
'.$ctxt{'dsh'}.' | '.
+ '
'.$ctxt{'dpl'}.' | ';
$inst_values .= '
'.$courseenv{'description'}.' ';
my $cloneinst = $courseenv{'internal.coursecode'};
if ($cloneinst ne '') {
@@ -2984,6 +2986,14 @@ sub print_review {
} else {
$inst_values .= $ctxt{'ncd'};
}
+ $inst_values .= ' | ';
+ if ($env{'form.tinyurls'} eq 'delete') {
+ $inst_values .= $ctxt{'nsl'};
+ } elsif ($env{'form.tinyurls'} eq 'transfer') {
+ $inst_values .= $ctxt{'tsl'};
+ } else {
+ $inst_values .= $ctxt{'csl'};
+ }
$inst_values .= ' | ';
} else {
$inst_values .= '
'.&mt('Unknown').' | ';
@@ -3215,7 +3225,7 @@ sub clone_form {
} elsif ($crstype eq 'placement') {
$type = 'Placement';
}
- my %lt = &clone_text();
+ my %lt = &clone_text($crstype);
my $output .=
&Apache::lonhtmlcommon::row_title($lt{'dmn'}).'
'.
@@ -3233,19 +3243,37 @@ sub clone_form {
'
'.
$lt{'shd'}.''.
'
'.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::row_title($lt{'dpl'}).'
'.
&Apache::lonhtmlcommon::row_closure(1);
return $output;
}
sub clone_text {
- return &Apache::lonlocal::texthash(
+ my ($crstype) = @_;
+ my %lt = &Apache::lonlocal::texthash(
'cid' => 'Course ID',
'dmn' => 'Domain',
'dsh' => 'Date Shift',
'ncd' => 'Do not clone date parameters',
'prd' => 'Clone date parameters as-is',
'shd' => 'Shift date parameters by number of days',
- );
+ 'dpl' => 'URL shortcuts (for deep linking)',
+ 'nsl' => 'Do not clone URL shortcuts',
+ 'tsl' => 'Transfer URL shortcuts from existing course to new course',
+ 'csl' => 'Create new URL shortcuts in new course',
+ );
+ if ($crstype eq 'Community') {
+ $lt{'tsl'} = &mt('Transfer URL shortcuts from existing course to new community');
+ $lt{'csl'} = &mt('Create new URL shortcuts in new course');
+ }
+ return %lt;
}
sub coursecode_form {
@@ -3271,7 +3299,7 @@ sub coursecode_form {
}
if (@{$codetitles} > 0) {
my $lastitem = pop(@{$codetitles});
- my $lastinput = '
';
+ my $lastinput = '
';
if (@{$codetitles} > 0) {
my $helplink;
if (defined($helpitem{$context})) {
@@ -3692,6 +3720,7 @@ sub print_request_outcome {
clonecrs => $clonecrs,
datemode => $env{'form.datemode'},
dateshift => $env{'form.dateshift'},
+ tinyurls => $env{'form.tinyurls'},
sectotal => $sectotal,
sections => \%sections,
crosslisttotal => $crosslisttotal,
@@ -3825,7 +3854,9 @@ sub process_request {
$storeresult = 'rejected';
} elsif ($disposition eq 'process') {
my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
- my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles,$code);
+ my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,
+ $keysmsg,%longroles,$code);
+ my $clonemsg = [];
my $type = 'Course';
if ($crstype eq 'community') {
$type = 'Community';
@@ -3858,9 +3889,9 @@ sub process_request {
$customitems{'_LC_coursestartdate'} = $accessstart;
$customitems{'_LC_courseenddate'} = $accessend;
my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
- 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
- \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
- \$code,\%customitems);
+ 'autocreate',$details,\$logmsg,$clonemsg,\$newusermsg,
+ \$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs,
+ \%longroles,\$code,\%customitems);
if (ref($postprocess) eq 'HASH') {
$customized = $postprocess->{'createdcustomized'};
}
@@ -3894,6 +3925,20 @@ sub process_request {
$output .= '
'.$role_result;
}
$output .= '';
+ if ($logmsg) {
+ $output .= '
'.$logmsg.'
';
+ }
+ if ((ref($clonemsg) eq 'ARRAY') && (@{$clonemsg})) {
+ $output .= '
';
+ my $user_lh = &Apache::loncommon::user_lang($env{'user.name'},$env{'user.domain'});
+ foreach my $item (@{$clonemsg}) {
+ if (ref($item) eq 'HASH') {
+ $output .= &mt_user($user_lh,$item->{mt},
+ @{$item->{args}}).'
'."\n";
+ }
+ }
+ $output .= '
'."\n";
+ }
$creationresult = 'created';
# Flush the course logs so reverse user roles immediately updated
unless ($registered_flush) {
@@ -4451,6 +4496,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'};
@@ -4861,17 +4907,26 @@ sub print_textbook_form {
#
# Table of user's current courses (owner and/or course coordinator)
#
- my %lt = &clone_text();
+ my %lt = &clone_text('Course');
if (keys(%cloneable)) {
$r->print('
');
}
#
@@ -4880,13 +4935,20 @@ sub print_textbook_form {
if (keys(%domcloneable)) {
$r->print('
');
}
@@ -5134,6 +5196,7 @@ sub process_textbook_request {
} else {
$details->{dateshift} = '';
}
+ $details->{tinyurls} = $env{'form.owntinyurls'};
} elsif ($reqtype eq 'colleague') {
$details->{datemode} = $env{'form.colldatemode'};
if ($details->{datemode} eq 'shift') {
@@ -5141,9 +5204,11 @@ sub process_textbook_request {
} 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;
@@ -5151,6 +5216,7 @@ sub process_textbook_request {
} else {
$details->{datemode} = '';
$details->{dateshift} = '';
+ $details->{tinyurls} = '';
}
my $lonhost = $r->dir_config('lonHostID');
$r->rflush();