version 1.1412, 2023/09/25 22:36:29
|
version 1.1431, 2024/05/21 02:57:15
|
Line 437 sub studentbrowser_javascript {
|
Line 437 sub studentbrowser_javascript {
|
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
// <![CDATA[ |
// <![CDATA[ |
var stdeditbrowser; |
var stdeditbrowser; |
function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadv) { |
function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadv,uident) { |
var url = '/adm/pickstudent?'; |
var url = '/adm/pickstudent?'; |
var filter; |
var filter; |
if (!ignorefilter) { |
if (!ignorefilter) { |
Line 458 sub studentbrowser_javascript {
|
Line 458 sub studentbrowser_javascript {
|
} |
} |
} |
} |
if ((courseadv == 'only') || (courseadv == 'none')) { url+="&courseadv="+courseadv; } |
if ((courseadv == 'only') || (courseadv == 'none')) { url+="&courseadv="+courseadv; } |
|
if (uident !== '') { url+="&identelement="+uident; } |
var title = 'Student_Browser'; |
var title = 'Student_Browser'; |
var options = 'scrollbars=1,resizable=1,menubar=0'; |
var options = 'scrollbars=1,resizable=1,menubar=0'; |
options += ',width=700,height=600'; |
options += ',width=700,height=600'; |
Line 489 ENDRESBRW
|
Line 490 ENDRESBRW
|
} |
} |
|
|
sub selectstudent_link { |
sub selectstudent_link { |
my ($form,$unameele,$udomele,$courseadv,$clickerid)=@_; |
my ($form,$unameele,$udomele,$courseadv,$clickerid,$identelem)=@_; |
my $callargs = "'".&Apache::lonhtmlcommon::entity_encode($form)."','". |
my $callargs = "'".&Apache::lonhtmlcommon::entity_encode($form)."','". |
&Apache::lonhtmlcommon::entity_encode($unameele)."','". |
&Apache::lonhtmlcommon::entity_encode($unameele)."','". |
&Apache::lonhtmlcommon::entity_encode($udomele)."'"; |
&Apache::lonhtmlcommon::entity_encode($udomele)."'"; |
Line 506 sub selectstudent_link {
|
Line 507 sub selectstudent_link {
|
$callargs .= ",'','','$courseadv'"; |
$callargs .= ",'','','$courseadv'"; |
} elsif ($courseadv eq 'condition') { |
} elsif ($courseadv eq 'condition') { |
$callargs .= ",'','','$courseadv'"; |
$callargs .= ",'','','$courseadv'"; |
|
} elsif ($identelem ne '') { |
|
$callargs .= ",'','',''"; |
|
} |
|
if ($identelem ne '') { |
|
$callargs .= ",'".&Apache::lonhtmlcommon::entity_encode($identelem)."'"; |
} |
} |
return '<span class="LC_nobreak">'. |
return '<span class="LC_nobreak">'. |
'<a href="javascript:openstdbrowser('.$callargs.');">'. |
'<a href="javascript:openstdbrowser('.$callargs.');">'. |
Line 1366 sub helpLatexCheatsheet {
|
Line 1372 sub helpLatexCheatsheet {
|
$out .= '<span>' |
$out .= '<span>' |
.&help_open_topic('Authoring_Output_Tags',&mt('Output Tags'),$stayOnPage,undef,600) |
.&help_open_topic('Authoring_Output_Tags',&mt('Output Tags'),$stayOnPage,undef,600) |
.'</span> <span>' |
.'</span> <span>' |
.&help_open_topic('Authoring_Multilingual_Problems',&mt('How to create problems in different languages'),$stayOnPage,undef,600) |
.&help_open_topic('Authoring_Multilingual_Problems',&mt('Languages'),$stayOnPage,undef,600) |
.'</span>'; |
.'</span>'; |
} |
} |
$out .= '</span>'; # End cheatsheet |
$out .= '</span>'; # End cheatsheet |
Line 1758 the id of the element to resize, second
|
Line 1764 the id of the element to resize, second
|
surrounds everything that comes after the textarea, this routine needs |
surrounds everything that comes after the textarea, this routine needs |
to be attached to the <body> for the onload and onresize events. |
to be attached to the <body> for the onload and onresize events. |
|
|
=back |
|
|
|
=cut |
=cut |
|
|
sub resize_textarea_js { |
sub resize_textarea_js { |
Line 2433 sub show_crsfiles_js {
|
Line 2437 sub show_crsfiles_js {
|
END |
END |
} |
} |
|
|
|
sub crsauthor_rights { |
|
my ($rightsfile,$path,$docroot,$cnum,$cdom) = @_; |
|
my $sourcerights = "$path/$rightsfile"; |
|
my $now = time; |
|
if (!-e $sourcerights) { |
|
my $cid = $cdom.'_'.$cnum; |
|
if (!-e "$docroot/priv/$cdom") { |
|
mkdir("$docroot/priv/$cdom",0755); |
|
} |
|
if (!-e "$docroot/priv/$cdom/$cnum") { |
|
mkdir("$docroot/priv/$cdom/$cnum",0755); |
|
} |
|
if (open(my $fh,">$sourcerights")) { |
|
print $fh <<END; |
|
<accessrule effect="deny" realm="" type="course" role="" /> |
|
<accessrule effect="allow" realm="$cid" type="course" role="" /> |
|
END |
|
close($fh); |
|
} |
|
} |
|
if (!-e "$sourcerights.meta") { |
|
if (open(my $fh,">$sourcerights.meta")) { |
|
my $author=$env{'environment.firstname'}.' '. |
|
$env{'environment.middlename'}.' '. |
|
$env{'environment.lastname'}.' '. |
|
$env{'environment.generation'}; |
|
$author =~ s/\s+$//; |
|
print $fh <<"END"; |
|
|
|
<abstract></abstract> |
|
<author>$author</author> |
|
<authorspace>$cnum:$cdom</authorspace> |
|
<copyright>private</copyright> |
|
<creationdate>$now</creationdate> |
|
<customdistributionfile></customdistributionfile> |
|
<dependencies></dependencies> |
|
<domain>$cdom</domain> |
|
<highestgradelevel>0</highestgradelevel> |
|
<keywords></keywords> |
|
<language>notset </language> |
|
<lastrevisiondate>$now</lastrevisiondate> |
|
<lowestgradelevel>0</lowestgradelevel> |
|
<mime>rights</mime> |
|
<modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser> |
|
<notes></notes> |
|
<obsolete></obsolete> |
|
<obsoletereplacement></obsoletereplacement> |
|
<owner>$cnum:$cdom</owner> |
|
<rule>deny:::course,allow:$cid::course</rule> |
|
<sourceavail></sourceavail> |
|
<standards></standards> |
|
<subject></subject> |
|
<title>Course Authoring Rights</title> |
|
END |
|
close($fh); |
|
} |
|
} |
|
return; |
|
} |
|
|
|
=pod |
|
|
|
=item * &iframe_wrapper_headjs() |
|
|
|
emits javascript containing two global vars to facilitate handling of resizing |
|
by code in iframe_wrapper_resizejs() used when an iframe is present in a page |
|
with standard LON-CAPA menus. |
|
|
|
=cut |
|
|
|
# |
|
# Where iframe is in use, if window.onload() executes before the custom resize function |
|
# has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef) |
|
# are used to ensure document.ready() triggers a call to resize, so the iframe contents |
|
# do not obscure the Functions menu. |
|
# |
|
|
|
sub iframe_wrapper_headjs { |
|
return <<"ENDJS"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
var LCnotready = 0; |
|
var LCresizedef = 0; |
|
// ]]> |
|
</script> |
|
|
|
ENDJS |
|
|
|
} |
|
|
|
=pod |
|
|
|
=item * &iframe_wrapper_resizejs() |
|
|
|
emits javascript used to handle resizing for a page containing |
|
an iframe, to ensure that the iframe does not obscure any |
|
standard LON-CAPA menu items. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
# |
|
# jQuery to use when iframe is in use and a page resize occurs. |
|
# This script will ensure that the iframe does not obscure any |
|
# standard LON-CAPA inline menus (primary, secondary, and/or |
|
# breadcrumbs and Functions menus. Expects javascript from |
|
# &iframe_wrapper_headjs() to be in head portion of the web page, |
|
# e.g., by inclusion in second arg passed to &start_page(). |
|
# |
|
|
|
sub iframe_wrapper_resizejs { |
|
my $offset = 5; |
|
&get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); |
|
if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) { |
|
$offset = 0; |
|
} |
|
return &Apache::lonhtmlcommon::scripttag(<<SCRIPT); |
|
\$(document).ready( function() { |
|
\$(window).unbind('resize').resize(function(){ |
|
var header = null; |
|
var offset = $offset; |
|
var height = 0; |
|
var hdrtop = 0; |
|
if (\$('div.LC_menus_content:first').length) { |
|
if (\$('div.LC_menus_content:first').hasClass ("shown")) { |
|
header = \$('div.LC_menus_content:first'); |
|
offset = 12; |
|
} |
|
} else if (\$('div.LC_head_subbox:first').length) { |
|
header = \$('div.LC_head_subbox:first'); |
|
offset = 9; |
|
} else { |
|
if (\$('#LC_breadcrumbs').length) { |
|
header = \$('#LC_breadcrumbs'); |
|
} |
|
} |
|
if (header != null && header.length) { |
|
height = header.height(); |
|
hdrtop = header.position().top; |
|
} |
|
var pos = height + hdrtop + offset; |
|
\$('.LC_iframecontainer').css('top', pos); |
|
}); |
|
LCresizedef = 1; |
|
if (LCnotready == 1) { |
|
LCnotready = 0; |
|
\$(window).trigger('resize'); |
|
} |
|
}); |
|
window.onload = function(){ |
|
if (LCresizedef) { |
|
LCnotready = 0; |
|
\$(window).trigger('resize'); |
|
} else { |
|
LCnotready = 1; |
|
} |
|
}; |
|
SCRIPT |
|
|
|
} |
|
|
=pod |
=pod |
|
|
=head1 Excel and CSV file utility routines |
=head1 Excel and CSV file utility routines |
Line 6455 sub CSTR_pageheader {
|
Line 6621 sub CSTR_pageheader {
|
return $output; |
return $output; |
} |
} |
|
|
|
############################################## |
|
=pod |
|
|
|
=item * &nocodemirror() |
|
|
|
Input: None |
|
|
|
Returns: 1 if CodeMirror is deactivated based on |
|
user's preference, or domain default, |
|
if user indicated use of default. |
|
|
|
=cut |
|
|
|
sub nocodemirror { |
|
my $nocodem = $env{'environment.nocodemirror'}; |
|
unless ($nocodem) { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
|
if ($domdefs{'nocodemirror'}) { |
|
$nocodem = 'yes'; |
|
} |
|
} |
|
if ($nocodem eq 'yes') { |
|
return 1; |
|
} |
|
return; |
|
} |
|
|
|
############################################## |
|
=pod |
|
|
|
=item * &permitted_editors() |
|
|
|
Input: $uri (optional) |
|
|
|
Returns: %editors hash in which keys are editors |
|
permitted in current Authoring Space, |
|
or in current course for web pages |
|
created in a course. |
|
|
|
Value for each key is 1. Possible keys |
|
are: edit, xml, and daxe. |
|
|
|
For a regular Authoring Space, if no specific |
|
set of editors has been set for the Author |
|
who owns the Authoring Space, then the |
|
domain default will be used. If no domain |
|
default has been set, then the keys will be |
|
edit and xml. |
|
|
|
For a course author, or for web pages created |
|
in a course, if no specific set of editors has |
|
been set for the course, then the domain |
|
course default will be used. If no domain |
|
course default has been set, then the keys |
|
will be edit and xml. |
|
|
|
=cut |
|
|
|
sub permitted_editors { |
|
my ($uri) = @_; |
|
my ($is_author,$is_coauthor,$is_course,$auname,$audom,%editors); |
|
if ($env{'request.role'} =~ m{^au\./}) { |
|
$is_author = 1; |
|
} elsif ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)}) { |
|
($audom,$auname) = ($1,$2); |
|
if (($audom ne '') && ($auname ne '')) { |
|
if (($env{'user.domain'} eq $audom) && |
|
($env{'user.name'} eq $auname)) { |
|
$is_author = 1; |
|
} else { |
|
$is_coauthor = 1; |
|
} |
|
} |
|
} elsif ($env{'request.course.id'}) { |
|
my ($cdom,$cnum); |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if (($env{'request.editurl'} =~ m{^/priv/\Q$cdom/$cnum\E/}) || |
|
($env{'request.editurl'} =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}) || |
|
($uri =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/})) { |
|
$is_course = 1; |
|
} elsif ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) { |
|
($audom,$auname) = ($1,$2); |
|
} elsif ($env{'request.uri'} =~ m{^/priv/($match_domain)/($match_username)/}) { |
|
($audom,$auname) = ($1,$2); |
|
} elsif (($uri eq '/daxesave') && |
|
(($env{'form.path'} =~ m{^/daxeopen/priv/\Q$cdom/$cnum\E/}) || |
|
($env{'form.path'} =~ m{^/daxeopen/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}))) { |
|
$is_course = 1; |
|
} elsif (($uri eq '/daxesave') && |
|
($env{'form.path'} =~ m{^/daxeopen/priv/($match_domain)/($match_username)/})) { |
|
($audom,$auname) = ($1,$2); |
|
} |
|
unless ($is_course) { |
|
if (($audom ne '') && ($auname ne '')) { |
|
if (($env{'user.domain'} eq $audom) && |
|
($env{'user.name'} eq $auname)) { |
|
$is_author = 1; |
|
} else { |
|
$is_coauthor = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($is_author) { |
|
if (exists($env{'environment.editors'})) { |
|
map { $editors{$_} = 1; } split(/,/,$env{'environment.editors'}); |
|
} else { |
|
%editors = ( edit => 1, |
|
xml => 1, |
|
); |
|
} |
|
} elsif ($is_coauthor) { |
|
if (exists($env{"environment.internal.editors./$audom/$auname"})) { |
|
map { $editors{$_} = 1; } split(/,/,$env{"environment.internal.editors./$audom/$auname"}); |
|
} else { |
|
%editors = ( edit => 1, |
|
xml => 1, |
|
); |
|
} |
|
} elsif ($is_course) { |
|
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.crseditors'})) { |
|
map { $editors{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.crseditors'}); |
|
} else { |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); |
|
if (exists($domdefaults{'crseditors'})) { |
|
map { $editors{$_} = 1; } split(/,/,$domdefaults{'crseditors'}); |
|
} else { |
|
%editors = ( edit => 1, |
|
xml => 1, |
|
); |
|
} |
|
} |
|
} else { |
|
%editors = ( edit => 1, |
|
xml => 1, |
|
); |
|
} |
|
return %editors; |
|
} |
|
|
############################################### |
############################################### |
############################################### |
############################################### |
|
|
Line 6681 sub bodytag {
|
Line 6988 sub bodytag {
|
$bodytag .= Apache::lonhtmlcommon::scripttag( |
$bodytag .= Apache::lonhtmlcommon::scripttag( |
Apache::lonmenu::utilityfunctions($httphost), 'start'); |
Apache::lonmenu::utilityfunctions($httphost), 'start'); |
|
|
|
my $collapsible; |
|
if ($args->{'collapsible_header'} ne '') { |
|
$collapsible = 1; |
|
my ($menustate,$tiptext,$divclass); |
|
if ($args->{'start_collapsed'}) { |
|
$menustate = 'collapsed'; |
|
$tiptext = 'display'; |
|
$divclass = 'hidden'; |
|
} else { |
|
$menustate = 'expanded'; |
|
$tiptext = 'hide'; |
|
$divclass = 'shown'; |
|
} |
|
my $alttext = &mt('menu state: '.$menustate); |
|
my $tooltip = &mt($tiptext.' standard menus'); |
|
$bodytag .= <<"END"; |
|
<div id="LC_expandingContainer" style="display:inline;"> |
|
<div id="LC_collapsible" class="LC_collapse_trigger" style="position: absolute;top: -5px;left: 0px; z-index:101; display:inline;"> |
|
<a href="#" style="text-decoration:none;"><img class="LC_collapsible_indicator" alt="$alttext" title="$tooltip" src="/res/adm/pages/$menustate.png" style="border:0;margin:0;padding:0;max-width:100%;height:auto" /></a></div> |
|
<div class="LC_menus_content $divclass"> |
|
END |
|
} |
unless ($args->{'no_primary_menu'}) { |
unless ($args->{'no_primary_menu'}) { |
my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref, |
my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref, |
$args->{'links_disabled'}, |
$args->{'links_disabled'}, |
$args->{'links_target'}); |
$args->{'links_target'}, |
|
$collapsible); |
|
|
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($dc_info) { |
if ($dc_info) { |
Line 6743 sub bodytag {
|
Line 7073 sub bodytag {
|
$bodytag .= '<hr style="clear:both" />'; |
$bodytag .= '<hr style="clear:both" />'; |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
} |
} |
|
if ($args->{'collapsible_header'} ne '') { |
|
$bodytag .= $args->{'collapsible_header'}. |
|
'<div id="LC_collapsible_separator"></div>'. |
|
'</div></div>'; |
|
} |
return $bodytag; |
return $bodytag; |
} |
} |
|
|
Line 6936 form, .inline {
|
Line 7270 form, .inline {
|
display: inline; |
display: inline; |
} |
} |
|
|
|
.LC_menus_content.shown{ |
|
display: block; |
|
} |
|
|
|
.LC_menus_content.hidden { |
|
display: none; |
|
} |
|
|
.LC_right { |
.LC_right { |
text-align:right; |
text-align:right; |
} |
} |
Line 6956 form, .inline {
|
Line 7298 form, .inline {
|
width:400px; |
width:400px; |
} |
} |
|
|
|
#LC_collapsible_separator { |
|
border: 1px solid black; |
|
width: 99.9%; |
|
height: 0px; |
|
} |
|
|
.LC_iframecontainer { |
.LC_iframecontainer { |
width: 98%; |
width: 98%; |
margin: 0; |
margin: 0; |
Line 17557 sub init_user_environment {
|
Line 17905 sub init_user_environment {
|
|
|
my $public=($username eq 'public' && $domain eq 'public'); |
my $public=($username eq 'public' && $domain eq 'public'); |
|
|
my ($filename,$cookie,$userroles,$firstaccenv,$timerintenv); |
my ($filename,$cookie,$userroles,$firstaccenv,$timerintenv, |
|
$coauthorenv); |
my $now=time; |
my $now=time; |
|
|
if ($public) { |
if ($public) { |
Line 17623 sub init_user_environment {
|
Line 17972 sub init_user_environment {
|
|
|
# Initialize roles |
# Initialize roles |
|
|
($userroles,$firstaccenv,$timerintenv) = |
($userroles,$firstaccenv,$timerintenv,$coauthorenv) = |
&Apache::lonnet::rolesinit($domain,$username,$authhost); |
&Apache::lonnet::rolesinit($domain,$username,$authhost); |
} |
} |
# ------------------------------------ Check browser type and MathML capability |
# ------------------------------------ Check browser type and MathML capability |
Line 17701 sub init_user_environment {
|
Line 18050 sub init_user_environment {
|
my %is_adv = ( is_adv => $env{'user.adv'} ); |
my %is_adv = ( is_adv => $env{'user.adv'} ); |
my %domdef = &Apache::lonnet::get_domain_defaults($domain); |
my %domdef = &Apache::lonnet::get_domain_defaults($domain); |
|
|
foreach my $tool ('aboutme','blog','webdav','portfolio','timezone') { |
foreach my $tool ('aboutme','blog','webdav','portfolio','portaccess','timezone') { |
$userenv{'availabletools.'.$tool} = |
$userenv{'availabletools.'.$tool} = |
&Apache::lonnet::usertools_access($username,$domain,$tool,'reload', |
&Apache::lonnet::usertools_access($username,$domain,$tool,'reload', |
undef,\%userenv,\%domdef,\%is_adv); |
undef,\%userenv,\%domdef,\%is_adv); |
} |
} |
Line 17714 sub init_user_environment {
|
Line 18063 sub init_user_environment {
|
\%userenv,\%domdef,\%is_adv); |
\%userenv,\%domdef,\%is_adv); |
} |
} |
|
|
|
if ((ref($userroles) eq 'HASH') && ($userroles->{'user.author'}) && |
|
(exists($userroles->{"user.role.au./$domain/"}))) { |
|
if ($userenv{'authoreditors'}) { |
|
$userenv{'editors'} = $userenv{'authoreditors'}; |
|
} elsif ($domdef{'editors'} ne '') { |
|
$userenv{'editors'} = $domdef{'editors'}; |
|
} else { |
|
$userenv{'editors'} = 'edit,xml'; |
|
} |
|
if ($userenv{'authorarchive'}) { |
|
$userenv{'canarchive'} = 1; |
|
} elsif (($userenv{'authorarchive'} eq '') && |
|
($domdef{'archive'})) { |
|
$userenv{'canarchive'} = 1; |
|
} |
|
} |
|
|
$userenv{'canrequest.author'} = |
$userenv{'canrequest.author'} = |
&Apache::lonnet::usertools_access($username,$domain,'requestauthor', |
&Apache::lonnet::usertools_access($username,$domain,'requestauthor', |
'reload','requestauthor', |
'reload','requestauthor', |
Line 17770 sub init_user_environment {
|
Line 18136 sub init_user_environment {
|
if (ref($timerintenv) eq 'HASH') { |
if (ref($timerintenv) eq 'HASH') { |
&_add_to_env(\%disk_env,$timerintenv); |
&_add_to_env(\%disk_env,$timerintenv); |
} |
} |
|
if (ref($coauthorenv) eq 'HASH') { |
|
if (keys(%{$coauthorenv})) { |
|
&_add_to_env(\%disk_env,$coauthorenv); |
|
} |
|
} |
if (ref($args->{'extra_env'})) { |
if (ref($args->{'extra_env'})) { |
&_add_to_env(\%disk_env,$args->{'extra_env'}); |
&_add_to_env(\%disk_env,$args->{'extra_env'}); |
} |
} |