--- loncom/interface/loncommon.pm 2023/03/11 21:58:18 1.1401
+++ loncom/interface/loncommon.pm 2023/09/10 18:12:54 1.1411
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1401 2023/03/11 21:58:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.1411 2023/09/10 18:12:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -71,6 +71,7 @@ use Apache::lonuserutils();
use Apache::lonuserstate();
use Apache::courseclassifier();
use LONCAPA qw(:DEFAULT :match);
+use LONCAPA::ltiutils;
use LONCAPA::LWPReq;
use LONCAPA::map();
use HTTP::Request;
@@ -1851,7 +1852,7 @@ sub colorfuleditor_js {
if (document.getElementById('crsres_include_'+element)) {
include = document.getElementById('crsres_include_'+element).value;
}
- populateCrsSelects(form,dirsel,filesel,1,include,1,0,1,1);
+ populateCrsSelects(form,dirsel,filesel,1,include,1,0,1,1,0);
}
}
if (document.getElementById('chooser_'+element+'_upload')) {
@@ -1859,7 +1860,7 @@ sub colorfuleditor_js {
if (currcrsupload == 'none') {
dirsel = 'crsauthorpath_'+element;
filesel = '';
- populateCrsSelects(form,dirsel,filesel,0,'',1,0,1,0);
+ populateCrsSelects(form,dirsel,filesel,0,'',1,0,1,0,1);
}
}
}
@@ -1874,6 +1875,16 @@ sub colorfuleditor_js {
if (document.getElementById('coursepath_'+element).length) {
numdirs = document.getElementById('coursepath_'+element).length;
}
+ if ((document.getElementById('hascrsres_'+element)) &&
+ (document.getElementById('nocrsres_'+element))) {
+ if (numdirs) {
+ document.getElementById('hascrsres_'+element).style.display='inline-block';
+ document.getElementById('nocrsres_'+element).style.display='none';
+ } else {
+ document.getElementById('hascrsres_'+element).style.display='none';
+ document.getElementById('nocrsres_'+element).style.display='inline-block';
+ }
+ }
form.elements['coursepath_'+element].selectedIndex = 0;
if (numdirs > 1) {
var selelem = form.elements['coursefile_'+element];
@@ -2266,7 +2277,7 @@ sub import_crsauthor_form {
return (0) unless (($cnum ne '') && ($cdom ne ''));
my @ids=&Apache::lonnet::current_machine_ids();
my ($output,$is_home,$toppath,%subdirs,%files,%selimport_menus,$include,$exclude);
-
+
if (grep(/^\Q$crshome\E$/,@ids)) {
$is_home = 1;
}
@@ -2278,25 +2289,29 @@ sub import_crsauthor_form {
$js_only = join(',',map { &js_escape($_); } sort(keys(%{$include})));
}
$exclude = &Apache::lonnet::priv_exclude();
- &Apache::lonnet::recursedirs($is_home,1,$include,$exclude,1,$toppath,'',\%subdirs,\%files);
+ &Apache::lonnet::recursedirs($is_home,1,$include,$exclude,1,0,$toppath,'',\%subdirs,\%files);
my $numdirs = scalar(keys(%files));
my %lt = &Apache::lonlocal::texthash (
fnam => 'Filename',
dire => 'Directory',
se => 'Select',
);
- $output = $lt{'dire'}.
+ $output = $lt{'dire'}.': '.
'
'."\n".
- $lt{'fnam'}.''."\n".
+ '';
return ($numdirs,$output);
}
@@ -2310,7 +2325,7 @@ sub show_crsfiles_js {
my $js = <<"END";
- function populateCrsSelects (form,dirsel,filesel,exc,include,setdir,setfile,recurse,nonemptydir) {
+ function populateCrsSelects (form,dirsel,filesel,exc,include,setdir,setfile,recurse,nonemptydir,addtopdir) {
var relpath = '';
if ((setfile) && (dirsel != null) && (dirsel != 'undefined') && (dirsel != '')) {
var currdir = form.elements[dirsel].options[form.elements[dirsel].selectedIndex].value;
@@ -2340,7 +2355,7 @@ sub show_crsfiles_js {
if (exc) {
exclude = '$exclude';
}
- var params = "role=course&files=1&rec="+recurse+"&nonempty="+nonemptydir+"&exc="+exclude+"&inc="+include+"&path="+relpath;
+ var params = "role=course&files=1&rec="+recurse+"&nonempty="+nonemptydir+"&exc="+exclude+"&inc="+include+"&addtop="+addtopdir+"&path="+relpath;
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
@@ -2358,11 +2373,7 @@ sub show_crsfiles_js {
}
var len = data.dirs.length;
if (len) {
- if (len > 1) {
- selelem.options[selelem.options.length] = new Option('$se','');
- }
- }
- if (len) {
+ selelem.options[selelem.options.length] = new Option('$se','');
var j;
for (j = 0; j < len; j++) {
selelem.options[selelem.options.length] = new Option(data.dirs[j],data.dirs[j]);
@@ -2771,7 +2782,7 @@ sub display_filter {
my $onchange = "javascript:toggleHistoryOptions(this,'containingphrase','$context',
'$secondid','$thirdid')";
return ' '.
&mt('Filter: [_1]',
@@ -6359,6 +6370,8 @@ Input: (optional) filename from which br
If page header is being requested for use in a frameset, then
the second (option) argument -- frameset will be true, and
the target attribute set for links should be target="_parent".
+ If $title is supplied as the thitd arg, that will be used to
+ the left of the breadcrumbs tail for the current path.
Returns: HTML div with CSTR path and recent box
To be included on Authoring Space pages
@@ -6366,7 +6379,7 @@ Returns: HTML div with CSTR path and rec
=cut
sub CSTR_pageheader {
- my ($trailfile,$frameset) = @_;
+ my ($trailfile,$frameset,$title) = @_;
if ($trailfile eq '') {
$trailfile = $env{'request.filename'};
}
@@ -6389,13 +6402,15 @@ sub CSTR_pageheader {
$lastitem = $thisdisfn;
}
- my ($crsauthor,$title);
+ my $crsauthor;
if (($env{'request.course.id'}) &&
($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
$crsauthor = 1;
- $title = &mt('Course Authoring Space');
- } else {
+ if ($title eq '') {
+ $title = &mt('Course Authoring Space');
+ }
+ } elsif ($title eq '') {
$title = &mt('Authoring Space');
}
@@ -6834,6 +6849,9 @@ ENDJS
$endbodytag;
}
}
+ if ((ref($args) eq 'HASH') && ($args->{'dashjs'})) {
+ $endbodytag = &Apache::lonhtmlcommon::dash_to_minus_js().$endbodytag;
+ }
return $endbodytag;
}
@@ -8150,6 +8168,11 @@ fieldset {
/* overflow: hidden; */
}
+fieldset#LC_selectuser {
+ margin: 0;
+ padding: 0;
+}
+
article.geogebraweb div {
margin: 0;
}
@@ -9749,6 +9772,50 @@ sub symb_from_tinyurl {
}
}
+sub usable_exttools {
+ my %tooltypes;
+ if ($env{'request.course.id'}) {
+ if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'}) {
+ if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'both') {
+ %tooltypes = (
+ crs => 1,
+ dom => 1,
+ );
+ } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'crs') {
+ $tooltypes{'crs'} = 1;
+ } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'dom') {
+ $tooltypes{'dom'} = 1;
+ }
+ } else {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $crstype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
+ if ($crstype eq '') {
+ $crstype = 'course';
+ }
+ if ($crstype eq 'course') {
+ if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'}) {
+ $crstype = 'official';
+ } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.textbook'}) {
+ $crstype = 'textbook';
+ } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.lti'}) {
+ $crstype = 'lti';
+ } else {
+ $crstype = 'unofficial';
+ }
+ }
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
+ if ($domdefaults{$crstype.'domexttool'}) {
+ $tooltypes{'dom'} = 1;
+ }
+ if ($domdefaults{$crstype.'exttool'}) {
+ $tooltypes{'crs'} = 1;
+ }
+ }
+ }
+ return %tooltypes;
+}
+
sub wishlist_window {
return(<<'ENDWISHLIST');