'.
@@ -1741,7 +1790,7 @@ sub do_paste_from_buffer {
%msgs = &Apache::lonlocal::texthash (
notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
- notindom => 'Paste failed: Item is an external tool from a course in a different donain.',
+ notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
);
@@ -1770,14 +1819,7 @@ sub do_paste_from_buffer {
# Retrieve information about all course maps in main content area
my $allmaps = {};
- if ($folder =~ /^default/) {
- $allmaps =
- &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
- $env{"course.$env{'request.course.id'}.home"},
- $env{'request.course.id'});
- }
-
- my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
+ my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk);
# Loop over the items to paste
foreach my $suffix (@dopaste) {
@@ -1795,6 +1837,13 @@ sub do_paste_from_buffer {
if ($is_map{$suffix}) {
# If pasting a map, check if map contains other maps
my (%hierarchy,%titles);
+ if (($folder =~ /^default/) && (!$donechk)) {
+ $allmaps =
+ &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
+ $env{"course.$env{'request.course.id'}.home"},
+ $env{'request.course.id'});
+ $donechk = 1;
+ }
&contained_map_check($url,$folder,$coursenum,$coursedom,
\%removefrommap,\%removeparam,\%addedmaps,
\%hierarchy,\%titles,$allmaps);
@@ -1852,13 +1901,18 @@ sub do_paste_from_buffer {
}
if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
my $prefix = $1;
- my $fromothercrs;
+ my $fromothercrs;
#need to copy the db contents to a new one, unless this is a move.
my %info = (
src => $url,
cdom => $coursedom,
cnum => $coursenum,
);
+ if ($prefix eq 'ext.tool') {
+ if ($prefixchg{$suffix} eq 'docstosupp') {
+ $info{'delgradable'} = 1;
+ }
+ }
if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
$fromothercrs = 1;
@@ -1950,6 +2004,18 @@ sub do_paste_from_buffer {
©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
$coursedom,$coursenum,$template,$newidx,"$folder.$container");
}
+ } elsif ($url =~ /ext\.tool$/) {
+ if (($newidx) && ($folder=~/^default/)) {
+ my $marker = (split(m{/},$url))[4];
+ my %toolsettings = &Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
+ my $val = 'no';
+ if ($toolsettings{'gradable'}) {
+ $val = 'yes';
+ }
+ &LONCAPA::map::storeparameter($newidx,'parameter_0_gradable',$val,
+ 'string_yesno');
+ &remember_parms($newidx,'gradable','set',$val);
+ }
}
$LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
':'.$ext.':normal:res';
@@ -2198,6 +2264,9 @@ sub dbcopy {
}
}
$db_name =~ s{_\d*$ }{_$suffix}x;
+ if (($prefix eq 'exttool') && ($dbref->{'delgradable'}) && ($contents{'gradable'})) {
+ delete($contents{'gradable'});
+ }
$result=&Apache::lonnet::put($db_name,\%contents,
$coursedom,$coursenum);
if ($result eq 'ok') {
@@ -2482,16 +2551,38 @@ sub url_paste_fixups {
$changed = 1;
}
}
- } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
+ } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
next if ($skip);
my $srcdom = $1;
my $srcnum = $2;
+ my $rem = $3;
+ my ($is_exttool,$exttoolchg);
+ if ($rem =~ m{\d+/ext\.tool$}) {
+ $is_exttool = 1;
+ }
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
$rewrites->{$oldurl}{$id} = $ressrc;
$dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
$dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
$dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
$changed = 1;
+ if ($is_exttool) {
+ $exttoolchg = 1;
+ }
+ } elsif (($rem =~ m{\d+/ext\.tool$}) &&
+ ($env{'form.docs.markedcopy_options'} ne 'move')) {
+ $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
+ $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
+ $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
+ $changed = 1;
+ $exttoolchg = 1;
+ }
+ if (($is_exttool) && ($prefixchg)) {
+ if ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/default}) {
+ if ($exttoolchg) {
+ $dbcopies->{$oldurl}{$id}{'delgradable'} = 1;
+ }
+ }
}
} elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
@@ -2712,9 +2803,7 @@ sub apply_fixups {
}
}
if (ref($resdatacopy{$key}) eq 'HASH') {
- if ($newsubdir{$key}) {
-
- }
+ my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer);
foreach my $idx (keys(%{$resdatacopy{$key}})) {
if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
my $srcurl = $resdatacopy{$key}{$idx}{'src'};
@@ -2724,15 +2813,18 @@ sub apply_fixups {
($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
- my ($newmapname) = ($key =~ m{/([^/]+)$});
- my ($srcfolder,$srccontainer) = split(/\./,$newmapname);
+ unless ($gotnewmapname) {
+ ($newmapname) = ($key =~ m{/([^/]+)$});
+ ($srcfolder,$srccontainer) = split(/\./,$newmapname);
+ if ($newsubdir{$key}) {
+ $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
+ }
+ $gotnewmapname = 1;
+ }
my $srcmapinfo = $srcfolder.':'.$idx;
if ($srccontainer eq 'page') {
$srcmapinfo .= ':1';
}
- if ($newsubdir{$key}) {
- $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
- }
©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
$cnum,$template,$idx,$newmapname);
}
@@ -2755,7 +2847,8 @@ sub apply_fixups {
}
}
}
- for (my $i=0; $i<@LONCAPA::map::order; $i++) {
+ my $total = scalar(@LONCAPA::map::order) - 1;
+ for (my $i=$total; $i>=0; $i--) {
my $idx = $LONCAPA::map::order[$i];
if (defined($LONCAPA::map::resources[$idx])) {
my $changed;
@@ -2765,7 +2858,7 @@ sub apply_fixups {
splice(@LONCAPA::map::order,$i,1);
if (ref($currparam{$idx}) eq 'ARRAY') {
foreach my $name (@{$currparam{$idx}}) {
- &LONCAPA::map::delparameter($idx,'parameter_'.$name);
+ &LONCAPA::map::delparameter($idx,$name);
}
}
next;
@@ -2807,7 +2900,7 @@ sub apply_fixups {
foreach my $idx (keys(%remparam)) {
if (ref($remparam{$idx}) eq 'ARRAY') {
foreach my $name (@{$remparam{$idx}}) {
- &LONCAPA::map::delparameter($idx,'parameter_'.$name);
+ &LONCAPA::map::delparameter($idx,$name);
}
}
}
@@ -4079,7 +4172,9 @@ END
} elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
if (($ENV{'SERVER_PORT'} == 443) &&
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- $url .= '?usehttp=1';
+ unless (&Apache::lonnet::uses_sts()) {
+ $url .= '?usehttp=1';
+ }
$nomodal = 1;
}
}
@@ -4089,9 +4184,8 @@ END
if ($url =~ /^([^#]+)#([^#]+)$/) {
$url = $1;
$anchor = $2;
- if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
- $shownsymb = $1.&escape('#').$anchor;
- }
+ my $escan = &escape('#');
+ $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;
}
}
unless ($env{'request.role.adv'}) {
@@ -4104,7 +4198,7 @@ END
}
}
if ($url ne '') {
- $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
}
} elsif (!$env{'request.role.adv'}) {
my $checkencrypt;
@@ -4125,7 +4219,7 @@ END
my $shownsymb = &Apache::lonenc::encrypted($symb);
my $shownurl = &Apache::lonenc::encrypted($url);
if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
- $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
+ $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
if ($env{'request.enc'} ne '') {
delete($env{'request.enc'});
}
@@ -4145,8 +4239,11 @@ END
$url = $1;
$anchor = $2;
if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
- if ($hostname ne '') {
- $url = 'http://'.$hostname.$url;
+ unless (&Apache::lonnet::uses_sts()) {
+ if ($hostname ne '') {
+ $url = 'http://'.$hostname.$url;
+ }
+ $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
}
$nomodal = 1;
}
@@ -4154,10 +4251,12 @@ END
} elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
if (($ENV{'SERVER_PORT'} == 443) &&
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- if ($hostname ne '') {
- $url = 'http://'.$hostname.$url;
+ unless (&Apache::lonnet::uses_sts()) {
+ if ($hostname ne '') {
+ $url = 'http://'.$hostname.$url;
+ }
+ $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
}
- $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
$nomodal = 1;
}
}
@@ -4311,7 +4410,7 @@ $form_end;
$reinit = &mt('(re-initialize course to access)');
}
$line.=''.$editlink.$renamelink;
- if ($url =~ /$LONCAPA::assess_re/) {
+ if ($orig_url =~ /$LONCAPA::assess_re/) {
$line.= ' ';
if ($curralias ne '') {
$line.=''.
@@ -4338,8 +4437,7 @@ $form_end;
} else {
$link = $url;
}
- $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
- (($anchor ne '')?$anchor:''));
+ $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor);
if ($nomodal) {
$line.=''.
'';
@@ -4721,6 +4819,48 @@ sub list_symbs {
$r->print(&endContentScreen());
}
+sub short_urls {
+ my ($r,$canedit) = @_;
+ my $crstype = &Apache::loncommon::course_type();
+ my $formname = 'shortenurl';
+ $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
+ $r->print(&startContentScreen('tools'));
+ my ($navmap,$errormsg) =
+ &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my (%maps,%resources,%titles);
+ if (!ref($navmap)) {
+ $r->print($errormsg.
+ &endContentScreen());
+ return '';
+ } else {
+ $r->print(''.&mt('Tiny URLs for deep-linking into course').''."\n");
+ $r->rflush();
+ my $readonly;
+ if ($canedit) {
+ my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap);
+ if ($numnew) {
+ $r->print(''.&mt('Created [quant,_1,URL]',$numnew).' ');
+ }
+ if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
+ $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'
');
+ foreach my $error (@{$errors}) {
+ $r->print('- '.$error.'
');
+ }
+ $r->print(' ');
+ }
+ } else {
+ $readonly = 1;
+ }
+ my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
+ $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
+ undef,undef,undef,undef,undef,\%currtiny,$readonly));
+ }
+ $r->print(&endContentScreen());
+}
+
sub contentverifyform {
my ($r) = @_;
my $crstype = &Apache::loncommon::course_type();
@@ -5091,13 +5231,17 @@ sub changewarning {
if (!defined($message)) {
$message='Changes will become active for your current session after [_1], or the next time you log in.';
}
+ my $windowname = 'loncapaclient';
+ if ($env{'request.lti.login'}) {
+ $windowname .= 'lti';
+ }
$r->print("\n\n".
''."\n".
-' |