[LON-CAPA-cvs] cvs: rat(version_2_11_X) / lonuserstate.pm loncom/interface londocs.pm
raeburn
raeburn at source.lon-capa.org
Sat May 2 17:28:09 EDT 2020
raeburn Sat May 2 21:28:09 2020 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface londocs.pm
/rat lonuserstate.pm
Log:
- For 2.11
Backport 1.159, 1.160
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.484.2.72.2.5 loncom/interface/londocs.pm:1.484.2.72.2.6
--- loncom/interface/londocs.pm:1.484.2.72.2.5 Sun Apr 29 17:33:52 2018
+++ loncom/interface/londocs.pm Wed Feb 6 16:41:42 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.72.2.5 2018/04/29 17:33:52 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.72.2.6 2019/02/06 16:41:42 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,6 +43,7 @@
use Apache::lonextresedit();
use Apache::lontemplate();
use Apache::lonsimplepage();
+use Apache::loncourserespicker();
use HTML::Entities;
use HTML::TokeParser;
use GDBM_File;
@@ -4496,6 +4497,47 @@
$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('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
+ $r->rflush();
+ my $readonly;
+ if ($canedit) {
+ my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap);
+ if ($numnew) {
+ $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
+ }
+ if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
+ $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
+ foreach my $error (@{$errors}) {
+ $r->print('<li>'.$error.'</li>');
+ }
+ $r->print('</ul><br />');
+ }
+ } 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 verifycontent {
my ($r) = @_;
@@ -4997,6 +5039,9 @@
} elsif ($allowed && $env{'form.listsymbs'}) {
&init_breadcrumbs('listsymbs','List Content IDs');
&list_symbs($r);
+ } elsif ($allowed && $env{'form.shorturls'}) {
+ &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
+ &short_urls($r,$canedit);
} elsif ($allowed && $env{'form.docslog'}) {
&init_breadcrumbs('docslog','Show Log');
my $folder = $env{'form.folder'};
@@ -6262,6 +6307,7 @@
'vc' => 'Verify Content',
'cv' => 'Check/Set Resource Versions',
'ls' => 'List Resource Identifiers',
+ 'ct' => 'Display/Set Shortened URLs for Deep-linking',
'imse' => 'Export contents to IMS Archive',
'dcd' => "Copy $crstype Content to Authoring Space",
);
@@ -6312,6 +6358,13 @@
icon => 'symbs.png',
linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
},
+ { linktext => $lt{'ct'},
+ url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
+ permission => 'F',
+ help => 'Docs_Short_URLs',
+ icon => 'shorturls.png',
+ linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
+ },
]
});
if ($canedit) {
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.149.2.3 rat/lonuserstate.pm:1.149.2.4
--- rat/lonuserstate.pm:1.149.2.3 Thu Mar 5 22:39:57 2020
+++ rat/lonuserstate.pm Sat May 2 21:28:08 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construct and maintain state and binary representation of course for user
#
-# $Id: lonuserstate.pm,v 1.149.2.3 2020/03/05 22:39:57 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.149.2.4 2020/05/02 21:28:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -292,15 +292,7 @@
# Handle randomization and random selection
if ($randomize) {
- my $advanced;
- if ($env{'request.course.id'}) {
- $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
- } else {
- $env{'request.course.id'} = $courseid;
- $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
- $env{'request.course.id'} = '';
- }
- unless ($advanced) {
+ unless (&is_advanced($courseid)) {
# Order of resources is not randomized if user has and advanced role in the course.
my $seed;
@@ -383,6 +375,18 @@
}
}
+sub is_advanced {
+ my ($courseid) = @_;
+ my $advanced;
+ if ($env{'request.course.id'}) {
+ $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
+ } else {
+ $env{'request.course.id'} = $courseid;
+ $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
+ $env{'request.course.id'} = '';
+ }
+ return $advanced;
+}
# -------------------------------------------------------------------- Resource
#
@@ -563,7 +567,9 @@
if (($turi=~/\.sequence$/) ||
($turi=~/\.page$/)) {
$hash{'is_map_'.$rid}=1;
- &loadmap($turi,$rid,$courseid);
+ if ((!$hiddenurl{$rid}) || (&is_advanced($courseid))) {
+ &loadmap($turi,$rid,$courseid);
+ }
}
return $token->[2]->{'id'};
}
More information about the LON-CAPA-cvs
mailing list