version 1.565, 2023/11/28 01:33:14
|
version 1.577, 2025/02/19 23:39:38
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# XML Parser Module |
# XML Parser Module |
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# Copyright for TtHfunc and TtMfunc by Ian Hutchinson. |
# Copyright for TtHfunc and TtMfunc by Ian Hutchinson. |
# TtHfunc and TtMfunc (the "Code") may be compiled and linked into |
# TtHfunc and TtMfunc (the "Code") may be compiled and linked into |
# binary executable programs or libraries distributed by the |
# binary executable programs or libraries distributed by the |
# Michigan State University (the "Licensee"), but any binaries so |
# Michigan State University (the "Licensee"), but any binaries so |
# distributed are hereby licensed only for use in the context |
# distributed are hereby licensed only for use in the context |
# of a program or computational system for which the Licensee is the |
# of a program or computational system for which the Licensee is the |
# primary author or distributor, and which performs substantial |
# primary author or distributor, and which performs substantial |
# additional tasks beyond the translation of (La)TeX into HTML. |
# additional tasks beyond the translation of (La)TeX into HTML. |
# The C source of the Code may not be distributed by the Licensee |
# The C source of the Code may not be distributed by the Licensee |
# to any other parties under any circumstances. |
# to any other parties under any circumstances. |
Line 57 described at http://www.lon-capa.org.
|
Line 57 described at http://www.lon-capa.org.
|
|
|
|
|
|
|
package Apache::lonxml; |
package Apache::lonxml; |
use vars |
use vars |
qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $errorcount $warningcount); |
qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $errorcount $warningcount); |
use strict; |
use strict; |
Line 117 use Apache::lonhtmlcommon();
|
Line 117 use Apache::lonhtmlcommon();
|
use Apache::functionplotresponse(); |
use Apache::functionplotresponse(); |
use Apache::lonnavmaps(); |
use Apache::lonnavmaps(); |
|
|
#==================================== Main subroutine: xmlparse |
#==================================== Main subroutine: xmlparse |
|
|
#debugging control, to turn on debugging modify the correct handler |
#debugging control, to turn on debugging modify the correct handler |
|
|
Line 208 sub xmlend {
|
Line 208 sub xmlend {
|
if ($Apache::lonhomework::parsing_a_problem || |
if ($Apache::lonhomework::parsing_a_problem || |
$Apache::lonhomework::parsing_a_task ) { |
$Apache::lonhomework::parsing_a_task ) { |
$mode='problem'; |
$mode='problem'; |
$status=$Apache::inputtags::status[-1]; |
$status=$Apache::inputtags::status[-1]; |
} |
} |
my $discussion; |
my $discussion; |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
Line 317 sub xmlparse {
|
Line 317 sub xmlparse {
|
} |
} |
&init_state(); |
&init_state(); |
if ($env{'form.return_only_error_and_warning_counts'}) { |
if ($env{'form.return_only_error_and_warning_counts'}) { |
if ($env{'request.filename'}=~/\.(html|htm|xml)$/i) { |
if ($env{'request.filename'}=~/\.(html|htm|xml)$/i) { |
my $error=&verify_html($content_file_string); |
my $error=&verify_html($content_file_string); |
if ($error) { $errorcount++; } |
if ($error) { $errorcount++; } |
} |
} |
Line 343 sub latex_special_symbols {
|
Line 343 sub latex_special_symbols {
|
$string=~s/([^\\])\&/$1\\\&/g; |
$string=~s/([^\\])\&/$1\\\&/g; |
$string=~s/([^\\])\#/$1\\\#/g; |
$string=~s/([^\\])\#/$1\\\#/g; |
$string =~ s/_/\\_/g; # _ -> \_ |
$string =~ s/_/\\_/g; # _ -> \_ |
$string =~ s/\^/\\\^{}/g; # ^ -> \^{} |
$string =~ s/\^/\\\^{}/g; # ^ -> \^{} |
} else { |
} else { |
$string=~s/\\/\\ensuremath{\\backslash}/g; |
$string=~s/\\/\\ensuremath{\\backslash}/g; |
$string=~s/\\\%|\%/\\\%/g; |
$string=~s/\\\%|\%/\\\%/g; |
Line 469 sub inner_xmlparse {
|
Line 469 sub inner_xmlparse {
|
|
|
if ($token->[0] eq 'E') { |
if ($token->[0] eq 'E') { |
if ($dontpop) { |
if ($dontpop) { |
$lastdontpop = $token; |
$lastdontpop = $token; |
} else { |
} else { |
$lastendtag = $token->[1]; |
$lastendtag = $token->[1]; |
&end_tag($stack,$parstack,$token); |
&end_tag($stack,$parstack,$token); |
Line 483 sub inner_xmlparse {
|
Line 483 sub inner_xmlparse {
|
} |
} |
} |
} |
|
|
if (($#$stack == 0) && ($stack->[0] eq 'physnet') && ($target eq 'web') && |
if (($#$stack == 0) && ($stack->[0] eq 'physnet') && ($target eq 'web') && |
($lastendtag eq 'LONCAPA_INTERNAL_TURN_STYLE_ON')) { |
($lastendtag eq 'LONCAPA_INTERNAL_TURN_STYLE_ON')) { |
if ((ref($lastdontpop) eq 'ARRAY') && ($lastdontpop->[1] eq 'physnet')) { |
if ((ref($lastdontpop) eq 'ARRAY') && ($lastdontpop->[1] eq 'physnet')) { |
&end_tag($stack,$parstack,$lastdontpop); |
&end_tag($stack,$parstack,$lastdontpop); |
Line 506 sub inner_xmlparse {
|
Line 506 sub inner_xmlparse {
|
if ($target eq 'modified') { |
if ($target eq 'modified') { |
# if modfied, handle startpart and endpart |
# if modfied, handle startpart and endpart |
$finaloutput=~s/\<startpartmarker[^\>]*\>(.*)\<endpartmarker[^\>]*\>/<part>$1<\/part>/gs; |
$finaloutput=~s/\<startpartmarker[^\>]*\>(.*)\<endpartmarker[^\>]*\>/<part>$1<\/part>/gs; |
} |
} |
return $finaloutput; |
return $finaloutput; |
} |
} |
|
|
## |
## |
## Looks to see if there is a subroutine defined for this tag. If so, call it, |
## Looks to see if there is a subroutine defined for this tag. If so, call it, |
## otherwise do not call it as we do not know what it is. |
## otherwise do not call it as we do not know what it is. |
## |
## |
Line 597 sub callsub {
|
Line 597 sub callsub {
|
sub init_state { |
sub init_state { |
undef(%state); |
undef(%state); |
} |
} |
|
|
sub set_state { |
sub set_state { |
my ($key,$value) = @_; |
my ($key,$value) = @_; |
$state{$key} = $value; |
$state{$key} = $value; |
Line 673 sub init_safespace {
|
Line 673 sub init_safespace {
|
$safeeval->reval('use LONCAPA::LCMathComplex;'); |
$safeeval->reval('use LONCAPA::LCMathComplex;'); |
$safeeval->permit_only(":default"); |
$safeeval->permit_only(":default"); |
$safeeval->permit("entereval"); |
$safeeval->permit("entereval"); |
|
$safeeval->permit("hintseval"); |
$safeeval->permit(":base_math"); |
$safeeval->permit(":base_math"); |
$safeeval->permit("sort"); |
$safeeval->permit("sort"); |
$safeeval->permit("time"); |
$safeeval->permit("time"); |
Line 699 sub init_safespace {
|
Line 700 sub init_safespace {
|
$safehole->wrap(\&Apache::lonr::r_check,$safeeval,'&r_check'); |
$safehole->wrap(\&Apache::lonr::r_check,$safeeval,'&r_check'); |
$safehole->wrap(\&Apache::lonr::r_cas_formula_fix,$safeeval, |
$safehole->wrap(\&Apache::lonr::r_cas_formula_fix,$safeeval, |
'&r_cas_formula_fix'); |
'&r_cas_formula_fix'); |
|
|
$safehole->wrap(\&Apache::caparesponse::capa_formula_fix,$safeeval, |
$safehole->wrap(\&Apache::caparesponse::capa_formula_fix,$safeeval, |
'&capa_formula_fix'); |
'&capa_formula_fix'); |
|
|
Line 725 sub init_safespace {
|
Line 726 sub init_safespace {
|
$safehole->wrap(\&Math::Cephes::y1,$safeeval,'&y1'); |
$safehole->wrap(\&Math::Cephes::y1,$safeeval,'&y1'); |
$safehole->wrap(\&Math::Cephes::yn,$safeeval,'&yn'); |
$safehole->wrap(\&Math::Cephes::yn,$safeeval,'&yn'); |
$safehole->wrap(\&Math::Cephes::yv,$safeeval,'&yv'); |
$safehole->wrap(\&Math::Cephes::yv,$safeeval,'&yv'); |
|
|
$safehole->wrap(\&Math::Cephes::bdtr ,$safeeval,'&bdtr' ); |
$safehole->wrap(\&Math::Cephes::bdtr ,$safeeval,'&bdtr' ); |
$safehole->wrap(\&Math::Cephes::bdtrc ,$safeeval,'&bdtrc' ); |
$safehole->wrap(\&Math::Cephes::bdtrc ,$safeeval,'&bdtrc' ); |
$safehole->wrap(\&Math::Cephes::bdtri ,$safeeval,'&bdtri' ); |
$safehole->wrap(\&Math::Cephes::bdtri ,$safeeval,'&bdtri' ); |
Line 1072 sub increment_counter {
|
Line 1073 sub increment_counter {
|
} |
} |
$Apache::lonxml::counter += $increment; |
$Apache::lonxml::counter += $increment; |
|
|
# If the caller supplied the response_id parameter, |
# If the caller supplied the response_id parameter, |
# Maintain its counter.. creating if necessary. |
# Maintain its counter.. creating if necessary. |
|
|
if (defined($part_response)) { |
if (defined($part_response)) { |
Line 1193 sub set_bubble_lines {
|
Line 1194 sub set_bubble_lines {
|
|
|
=item get_bubble_line_hash |
=item get_bubble_line_hash |
|
|
Returns the current bubble line hash. This is assumed to |
Returns the current bubble line hash. This is assumed to |
be small so we return a copy |
be small so we return a copy |
|
|
|
|
Line 1219 sub get_all_text {
|
Line 1220 sub get_all_text {
|
my $depth=0; |
my $depth=0; |
my $token; |
my $token; |
my $result=''; |
my $result=''; |
if ( $tag =~ m:^/: ) { |
if ( $tag =~ m:^/: ) { |
my $tag=substr($tag,1); |
my $tag=substr($tag,1); |
#&Apache::lonxml::debug("have:$tag:"); |
#&Apache::lonxml::debug("have:$tag:"); |
my $top_empty=0; |
my $top_empty=0; |
while (($depth >=0) && ($#$pars > -1) && (!$top_empty)) { |
while (($depth >=0) && ($#$pars > -1) && (!$top_empty)) { |
Line 1321 sub newparser {
|
Line 1322 sub newparser {
|
push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]); |
push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]); |
} else { |
} else { |
push (@Apache::lonxml::pwd, $dir); |
push (@Apache::lonxml::pwd, $dir); |
} |
} |
} |
} |
|
|
sub parstring { |
sub parstring { |
Line 1338 sub parstring {
|
Line 1339 sub parstring {
|
push(@values,"\"$val\""); |
push(@values,"\"$val\""); |
} |
} |
} |
} |
my $var_init = |
my $var_init = |
(@vars) ? 'my ('.join(',',@vars).') = ('.join(',',@values).');' |
(@vars) ? 'my ('.join(',',@vars).') = ('.join(',',@values).');' |
: ''; |
: ''; |
return $var_init; |
return $var_init; |
Line 1591 FULLPAGE
|
Line 1592 FULLPAGE
|
} |
} |
} elsif ($symb || $folderpath) { |
} elsif ($symb || $folderpath) { |
$deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; |
$deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; |
$initialize .= |
$initialize .= |
&Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle, |
&Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle, |
undef,$folderpath,$uri)."\n"; |
undef,$folderpath,$uri)."\n"; |
} |
} |
Line 1613 FULLPAGE
|
Line 1614 FULLPAGE
|
my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit', |
my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit', |
'vi' => 'Save and View', |
'vi' => 'Save and View', |
'dv' => 'Discard Edits and View', |
'dv' => 'Discard Edits and View', |
'un' => 'undo', |
'un' => 'Undo', |
'ed' => 'Edit'); |
'ed' => 'Edit', |
|
'ew' => 'Edit with Daxe', |
|
'er' => 'Editor'); |
my $spelllink = &Apache::lonhtmlcommon::spelllink('xmledit','filecont'); |
my $spelllink = &Apache::lonhtmlcommon::spelllink('xmledit','filecont'); |
my $textarea_events = &Apache::edit::element_change_detection(); |
my $textarea_events = &Apache::edit::element_change_detection(); |
my $form_events = &Apache::edit::form_change_detection(); |
my $form_events = &Apache::edit::form_change_detection(); |
Line 1622 FULLPAGE
|
Line 1625 FULLPAGE
|
if ($filetype eq 'html') { |
if ($filetype eq 'html') { |
$htmlerror=&verify_html($filecontents); |
$htmlerror=&verify_html($filecontents); |
if ($htmlerror) { |
if ($htmlerror) { |
$htmlerror='<span class="LC_error">'.$htmlerror.'</span>'; |
$htmlerror=(' 'x3).' <span class="LC_error">'.$htmlerror.'</span>'; |
} |
} |
if (&Apache::lonhtmlcommon::htmlareabrowser()) { |
if (&Apache::lonhtmlcommon::htmlareabrowser()) { |
unless ($textareaclass) { |
unless ($textareaclass) { |
Line 1630 FULLPAGE
|
Line 1633 FULLPAGE
|
} |
} |
} |
} |
} |
} |
my $undo; |
my ($undo,$daxebutton,%onclick); |
|
foreach my $item ('discard','undo','daxe') { |
|
$onclick{$item} = 'onclick="still_ask=true;setmode(this.form,'."'$item'".')"'; |
|
} |
|
foreach my $item ('saveedit','saveview') { |
|
$onclick{$item} = 'onclick="is_submit=true;setmode(this.form,'."'$item'".')"'; |
|
} |
unless ($uri =~ m{^/uploaded/}) { |
unless ($uri =~ m{^/uploaded/}) { |
$undo = '<input type="submit" name="Undo" accesskey="u" value="'.$lt{'un'}.'" />'."\n"; |
$undo = '<input type="button" name="undo" accesskey="u" value="'.$lt{'un'}.'" '. |
|
$onclick{'undo'}.' />'."\n"; |
|
} |
|
$initialize .= &setmode_javascript(); |
|
if ($filetype eq 'html') { |
|
my %editors = &Apache::loncommon::permitted_editors($uri); |
|
if ($editors{'daxe'}) { |
|
$daxebutton = '<input type="button" name="editwithdaxe" accesskey="w" value="'.$lt{'ew'}.'" '. |
|
$onclick{'daxe'}.' />'."\n"; |
|
} |
} |
} |
my $editfooter=(<<ENDFOOTER); |
my $editfooter=(<<ENDFOOTER); |
$initialize |
$initialize |
<a name="editsection" /> |
<a name="editsection" /> |
<form $form_events method="post" name="xmledit" action="$action"> |
<form $form_events method="post" name="xmledit" action="$action"> |
|
<input type="hidden" name="problemmode" value="edit" /> |
<div class="LC_edit_problem_editxml_header"> |
<div class="LC_edit_problem_editxml_header"> |
<table class="LC_edit_problem_header_title"><tr><td> |
<table class="LC_edit_problem_header_title"><tr><td> |
$filename |
$filename |
Line 1646 $initialize
|
Line 1665 $initialize
|
</td></tr> |
</td></tr> |
</table> |
</table> |
<div style="float:right"> |
<div style="float:right"> |
<input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" /> |
<input type="button" name="savethisfile" accesskey="s" value="$lt{'st'}" $onclick{'saveedit'} /> |
<input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" /> |
<input type="button" name="viewmode" accesskey="v" value="$lt{'vi'}" $onclick{'saveview'} /> |
</div> |
</div> |
<div> |
<div> |
<input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" /> |
<input type="button" name="discardview" accesskey="d" value="$lt{'dv'}" $onclick{'discard'} /> |
$undo $htmlerror $deps_button $dragmath_button |
$undo $deps_button $daxebutton $dragmath_button $htmlerror |
</div> |
</div> |
</div> |
</div> |
<textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea><br />$spelllink |
<textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea><br /><label for="filecont" class="LC_visually_hidden">$lt{'er'}</label>$spelllink |
<div id="LC_aftertextarea"> |
<div id="LC_aftertextarea"> |
<br /> |
<br /> |
$titledisplay |
$titledisplay |
</div> |
</div> |
</form> |
</form> |
ENDFOOTER |
ENDFOOTER |
return ($editfooter,$add_to_onload,$add_to_onresize);; |
return ($editfooter,$add_to_onload,$add_to_onresize); |
} |
} |
|
|
sub setmode_javascript { |
sub setmode_javascript { |
Line 1685 ENDSCRIPT
|
Line 1704 ENDSCRIPT
|
} |
} |
|
|
sub seteditor_javascript { |
sub seteditor_javascript { |
|
my ($is_course_doc,$is_supp,$supp_path,$supp_title) = @_; |
|
my $symb; |
|
if ($is_course_doc) { |
|
if (!$is_supp) { |
|
($symb) = &Apache::lonnet::whichuser(); |
|
if ($symb) { |
|
$symb = &escape($symb); |
|
} |
|
} |
|
} |
return <<"ENDSCRIPT"; |
return <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
function seteditmode(form,editor) { |
function seteditmode(form,editor) { |
|
var querystr = ''; |
|
var supplemental = '$is_supp'; |
|
var coursedoc = '$is_course_doc'; |
|
if (coursedoc) { |
|
if (supplemental) { |
|
var supppath = '$supp_path'; |
|
var supptitle = '$supp_title'; |
|
if (supppath) { |
|
querystr = 'folderpath='+supppath; |
|
} |
|
if (supptitle) { |
|
if (querystr) { |
|
querystr += '&'; |
|
} |
|
querystr += 'title='+supptitle; |
|
} |
|
} |
|
} |
if (editor == 'daxe') { |
if (editor == 'daxe') { |
var url = new URL(document.location.href); |
var url = new URL(document.location.href); |
window.location = url.protocol+'//'+url.hostname+'/daxepage'+url.pathname; |
var newloc = url.protocol+'//'+url.hostname+'/daxepage'+url.pathname; |
|
if (querystr) { |
|
if (/\\?/.test(url.pathname)) { |
|
newloc += '&'; |
|
} else { |
|
newloc += '?'; |
|
} |
|
newloc += querystr; |
|
} |
|
window.location = newloc; |
} else { |
} else { |
form.editmode.value = editor; |
if (coursedoc) { |
|
var curraction = form.action; |
|
var idx = curraction.indexOf('?'); |
|
if (idx !== -1) { |
|
form.action = curraction.substring(0,idx); |
|
} |
|
form.action += '?forceedit=1®ister=1'; |
|
if (querystr) { |
|
form.action += '&'+querystr; |
|
} |
|
} |
|
if (editor == 'edit') { |
|
form.editmode.value = editor; |
|
} else { |
|
form.editmode.value = ''; |
|
} |
form.submit(); |
form.submit(); |
} |
} |
} |
} |
Line 1734 sub handler {
|
Line 1805 sub handler {
|
|
|
my $target=&get_target(); |
my $target=&get_target(); |
$Apache::lonxml::debug=$env{'user.debug'}; |
$Apache::lonxml::debug=$env{'user.debug'}; |
|
|
&Apache::loncommon::content_type($request,'text/html'); |
&Apache::loncommon::content_type($request,'text/html'); |
&Apache::loncommon::no_cache($request); |
&Apache::loncommon::no_cache($request); |
if ($env{'request.state'} eq 'published') { |
if ($env{'request.state'} eq 'published') { |
Line 1742 sub handler {
|
Line 1813 sub handler {
|
'lastrevisiondate')); |
'lastrevisiondate')); |
} |
} |
# Embedded Flash movies from Camtasia served from https will not display in IE |
# Embedded Flash movies from Camtasia served from https will not display in IE |
# if XML config file has expired from cache. |
# if XML config file has expired from cache. |
if ($ENV{'SERVER_PORT'} == 443) { |
if ($ENV{'SERVER_PORT'} == 443) { |
if ($request->uri =~ /\.xml$/) { |
if ($request->uri =~ /\.xml$/) { |
my ($httpbrowser,$clientbrowser) = |
my ($httpbrowser,$clientbrowser) = |
Line 1757 sub handler {
|
Line 1828 sub handler {
|
} |
} |
} |
} |
$request->send_http_header; |
$request->send_http_header; |
|
|
return OK if $request->header_only; |
return OK if $request->header_only; |
|
|
|
|
Line 1804 sub handler {
|
Line 1875 sub handler {
|
# Edit action? Save file. |
# Edit action? Save file. |
# |
# |
if (!($env{'request.state'} eq 'published')) { |
if (!($env{'request.state'} eq 'published')) { |
if ($env{'form.savethisfile'} || $env{'form.viewmode'} || $env{'form.Undo'}) { |
if (($env{'form.problemmode'} eq 'saveedit') || |
|
($env{'form.problemmode'} eq 'saveview') || |
|
($env{'form.problemmode'} eq 'undo')) { |
my $html_file=&Apache::lonnet::getfile($file); |
my $html_file=&Apache::lonnet::getfile($file); |
my $error = &Apache::lonhomework::handle_save_or_undo($request, \$html_file, \$env{'form.filecont'}); |
my $error = &Apache::lonhomework::handle_save_or_undo($request, \$html_file, \$env{'form.filecont'}); |
if ($env{'form.savethisfile'}) { |
if ($env{'form.problemmode'} eq 'saveedit') { |
$env{'form.editmode'}='Edit'; #force edit mode |
$env{'form.editmode'}='edit'; #force edit mode |
} |
} |
} |
} |
} |
} |
Line 1817 sub handler {
|
Line 1890 sub handler {
|
my $result = ''; |
my $result = ''; |
my $filecontents=&Apache::lonnet::getfile($file); |
my $filecontents=&Apache::lonnet::getfile($file); |
if ($filecontents eq -1) { |
if ($filecontents eq -1) { |
my $start_page=&Apache::loncommon::start_page('File Error'); |
my ($start_page,$end_page,$errormsg); |
my $end_page=&Apache::loncommon::end_page(); |
$start_page=&Apache::loncommon::start_page('File Error'); |
my $errormsg='<p class="LC_error">' |
if ($target eq 'web') { |
.&mt('File not found: [_1]' |
$start_page .= '<div class="LC_landmark" style="clear:both" role="menu">'. |
,'<span class="LC_filename">'.$file.'</span>') |
'<h1 class="LC_visually_hidden">'. |
.'</p>'; |
&mt('File not found').'</h1>'; |
|
$end_page = '</div>'; |
|
} |
|
$end_page .= &Apache::loncommon::end_page(); |
|
$errormsg='<p class="LC_error">' |
|
.&mt('File not found: [_1]' |
|
,'<span class="LC_filename">'.$file.'</span>') |
|
.'</p>'; |
$result=(<<ENDNOTFOUND); |
$result=(<<ENDNOTFOUND); |
$start_page |
$start_page |
$errormsg |
$errormsg |
Line 1837 ENDNOTFOUND
|
Line 1917 ENDNOTFOUND
|
} elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') { |
} elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') { |
$filecontents=&createnewhtml(); |
$filecontents=&createnewhtml(); |
} |
} |
$env{'form.editmode'}='Edit'; #force edit mode |
$env{'form.editmode'}='edit'; #force edit mode |
} |
} |
} else { |
} else { |
unless ($env{'request.state'} eq 'published') { |
unless ($env{'request.state'} eq 'published') { |
Line 1849 ENDNOTFOUND
|
Line 1929 ENDNOTFOUND
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['editmode']); |
['editmode']); |
} |
} |
if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) { |
if ((!$env{'form.editmode'}) || |
|
($env{'form.problemmode'} eq 'saveview') || |
|
($env{'form.problemmode'} eq 'discard')) { |
if ($filetype eq 'html' || $filetype eq 'sty') { |
if ($filetype eq 'html' || $filetype eq 'sty') { |
&Apache::structuretags::reset_problem_globals(); |
&Apache::structuretags::reset_problem_globals(); |
$result = &Apache::lonxml::xmlparse($request,$target, |
$result = &Apache::lonxml::xmlparse($request,$target, |
Line 1876 ENDNOTFOUND
|
Line 1958 ENDNOTFOUND
|
$inhibit_menu = 1; |
$inhibit_menu = 1; |
} |
} |
} |
} |
if (($filetype ne 'html') && |
if (($filetype ne 'html') && |
(!$env{'form.return_only_error_and_warning_counts'}) && |
(!$env{'form.return_only_error_and_warning_counts'}) && |
(!$inhibit_menu)) { |
(!$inhibit_menu)) { |
my $nochgview = 1; |
my $nochgview = 1; |
Line 1926 ENDNOTFOUND
|
Line 2008 ENDNOTFOUND
|
# Edit action? Insert editing commands |
# Edit action? Insert editing commands |
# |
# |
unless (($env{'request.state'} eq 'published') || ($inhibit_menu)) { |
unless (($env{'request.state'} eq 'published') || ($inhibit_menu)) { |
if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'}))) |
if (($env{'form.editmode'}) && |
{ |
(!($env{'form.problemmode'} eq 'saveview')) && |
|
(!($env{'form.problemmode'} eq 'discard'))) { |
my ($displayfile,$url,$symb,$itemtitle,$action); |
my ($displayfile,$url,$symb,$itemtitle,$action); |
$displayfile=$request->uri; |
$displayfile=$request->uri; |
if ($request->uri =~ m{^/uploaded/}) { |
if ($request->uri =~ m{^/uploaded/}) { |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/supplemental/\E}) { |
if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/\E(docs|supplemental)/}) { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
if ($1 eq 'supplemental') { |
['folderpath','title']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['folderpath','title']); |
|
} |
|
if (($env{'request.state'} eq 'edit') && ($env{'form.editmode'} eq 'edit') && |
|
($filetype eq 'html')) { |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
} |
} elsif ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) { |
} elsif ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) { |
my $filename = $1; |
my $filename = $1; |
if ($1 eq 'loncapa.html') { |
if ($1 eq 'loncapa.html') { |
Line 1947 ENDNOTFOUND
|
Line 2036 ENDNOTFOUND
|
} |
} |
} |
} |
unless ($itemtitle) { |
unless ($itemtitle) { |
($symb,$itemtitle,$displayfile) = |
($symb,$itemtitle,$displayfile) = |
&get_courseupload_hierarchy($request->uri, |
&get_courseupload_hierarchy($request->uri, |
$env{'form.folderpath'}, |
$env{'form.folderpath'}, |
$env{'form.title'}); |
$env{'form.title'}); |
Line 1960 ENDNOTFOUND
|
Line 2049 ENDNOTFOUND
|
&inserteditinfo($filecontents,$filetype,$displayfile,$symb, |
&inserteditinfo($filecontents,$filetype,$displayfile,$symb, |
$itemtitle,$env{'form.folderpath'},$request->uri,$action); |
$itemtitle,$env{'form.folderpath'},$request->uri,$action); |
|
|
my %options = |
my %options = |
('add_entries' => |
('add_entries' => |
{'onresize' => $add_to_onresize, |
{'onresize' => $add_to_onresize, |
'onload' => $add_to_onload, }); |
'onload' => $add_to_onload, }); |
Line 1999 ENDNOTFOUND
|
Line 2088 ENDNOTFOUND
|
|
|
&Apache::lonxml::add_messages(\$result); |
&Apache::lonxml::add_messages(\$result); |
$request->print($result); |
$request->print($result); |
|
|
return OK; |
return OK; |
} |
} |
|
|
Line 2032 sub get_courseupload_hierarchy {
|
Line 2121 sub get_courseupload_hierarchy {
|
} |
} |
if ($title) { |
if ($title) { |
push(@pathitems,&unescape($title)); |
push(@pathitems,&unescape($title)); |
|
$itemtitle = $title; |
} |
} |
$displaypath = join(' » ',@pathitems); |
$displaypath = join(' » ',@pathitems); |
} else { |
} else { |
Line 2069 sub debug {
|
Line 2159 sub debug {
|
} |
} |
|
|
sub show_error_warn_msg { |
sub show_error_warn_msg { |
if (($env{'request.filename'} eq |
if (($env{'request.filename'} eq |
$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/lib/templates/simpleproblem.problem') && |
$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/lib/templates/simpleproblem.problem') && |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
return 1; |
return 1; |
Line 2164 sub error {
|
Line 2254 sub error {
|
|
|
sub warning { |
sub warning { |
$warningcount++; |
$warningcount++; |
|
|
if ($env{'form.grade_target'} ne 'tex') { |
if ($env{'form.grade_target'} ne 'tex') { |
if ( &show_error_warn_msg() ) { |
if ( &show_error_warn_msg() ) { |
push(@Apache::lonxml::warning_messages, |
push(@Apache::lonxml::warning_messages, |
Line 2179 sub warning {
|
Line 2269 sub warning {
|
} |
} |
|
|
sub info { |
sub info { |
if ($env{'form.grade_target'} ne 'tex' |
if ($env{'form.grade_target'} ne 'tex' |
&& $env{'request.state'} eq 'construct') { |
&& $env{'request.state'} eq 'construct') { |
push(@Apache::lonxml::info_messages,join('<br />',@_)."<br />\n"); |
push(@Apache::lonxml::info_messages,join('<br />',@_)."<br />\n"); |
} |
} |
Line 2229 sub get_param {
|
Line 2319 sub get_param {
|
} |
} |
} else { |
} else { |
if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) { |
if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) { |
|
|
return &Apache::run::run("{$args;".'return $'.$param.'}', |
return &Apache::run::run("{$args;".'return $'.$param.'}', |
$safeeval); #' |
$safeeval); #' |
} else { |
} else { |
Line 2311 sub register_insert_xml {
|
Line 2401 sub register_insert_xml {
|
} |
} |
} |
} |
} |
} |
|
|
# parse the allows and ignore tags set to <show>no</show> |
# parse the allows and ignore tags set to <show>no</show> |
foreach my $tag (@alltags) { |
foreach my $tag (@alltags) { |
next if (!exists($insertlist{$tag.'.allow'})); |
next if (!exists($insertlist{$tag.'.allow'})); |
Line 2417 sub get_tag {
|
Line 2507 sub get_tag {
|
=item &print_pdf_radiobutton(fieldname, value) |
=item &print_pdf_radiobutton(fieldname, value) |
|
|
Returns a latexline to generate a PDF-Form-Radiobutton. |
Returns a latexline to generate a PDF-Form-Radiobutton. |
Note: Radiobuttons with equal names are automaticly grouped |
Note: Radiobuttons with equal names are automaticly grouped |
in a selection-group. |
in a selection-group. |
|
|
$fieldname: PDF internalname of the radiobutton(group) |
$fieldname: PDF internalname of the radiobutton(group) |
Line 2444 sub print_pdf_start_combobox {
|
Line 2534 sub print_pdf_start_combobox {
|
my $result; |
my $result; |
my ($fieldName) = @_; |
my ($fieldName) = @_; |
$result .= '\begin{tabularx}{\textwidth}{p{2.5cm}X}'."\n"; |
$result .= '\begin{tabularx}{\textwidth}{p{2.5cm}X}'."\n"; |
$result .= '\comboBox[]{'.$fieldName.'}{2.3cm}{14bp}{'; # |
$result .= '\comboBox[]{'.$fieldName.'}{2.3cm}{14bp}{'; # |
|
|
return $result; |
return $result; |
} |
} |
Line 2462 $option: PDF internal name of the Combob
|
Line 2552 $option: PDF internal name of the Combob
|
sub print_pdf_add_combobox_option { |
sub print_pdf_add_combobox_option { |
|
|
my $result; |
my $result; |
my ($option) = @_; |
my ($option) = @_; |
|
|
$result .= '('.$option.')'; |
$result .= '('.$option.')'; |
|
|
return $result; |
return $result; |
} |
} |
|
|