[LON-CAPA-cvs] cvs: doc /homework xml.html loncom/homework lonhomework.pm loncom/interface londocs.pm loncom/xml lonxml.pm scripttag.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 21 Oct 2002 20:31:06 -0000
albertel Mon Oct 21 16:31:06 2002 EDT
Modified files:
/loncom/interface londocs.pm
/loncom/homework lonhomework.pm
/loncom/xml scripttag.pm lonxml.pm
/doc/homework xml.html
Log:
- default_homework is now lazy loaded by the <script> tag
- fixes BUG#842 (can't use <script> in .html)
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.34 loncom/interface/londocs.pm:1.35
--- loncom/interface/londocs.pm:1.34 Sun Oct 20 14:42:53 2002
+++ loncom/interface/londocs.pm Mon Oct 21 16:31:06 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.34 2002/10/20 18:42:53 www Exp $
+# $Id: londocs.pm,v 1.35 2002/10/21 20:31:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -265,18 +265,13 @@
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
$r->print('<br />');
$r->rflush();
- my $default='';
- if ($1=~/(problem|exam|quiz|assess|survey|form|library)/) {
- $default=&Apache::lonnet::getfile(
- '/home/httpd/html/res/adm/includes/default_homework.lcpm');
- }
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
$r->print('- Rendering: ');
&Apache::lonxml::xmlparse($r,'web',
&Apache::lonnet::getfile(
- &Apache::lonnet::filelocation('',$url)),$default);
+ &Apache::lonnet::filelocation('',$url)));
if (($Apache::lonxml::errorcount) ||
($Apache::lonxml::warningcount)) {
if ($Apache::lonxml::errorcount) {
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.97 loncom/homework/lonhomework.pm:1.98
--- loncom/homework/lonhomework.pm:1.97 Wed Oct 16 15:29:44 2002
+++ loncom/homework/lonhomework.pm Mon Oct 21 16:31:06 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.97 2002/10/16 19:29:44 albertel Exp $
+# $Id: lonhomework.pm,v 1.98 2002/10/21 20:31:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -396,14 +396,9 @@
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); }
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%ENV,'^form');}
- my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
- if ($default == -1) {
- &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");
- $default='';
- }
&Apache::lonxml::debug("Should be parsing now");
$result = &Apache::lonxml::xmlparse($request, $target, $problem,
- $default.&setup_vars($target),%mystyle);
+ &setup_vars($target),%mystyle);
#$request->print("Result follows:");
if ($target eq 'modified') {
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.78 loncom/xml/scripttag.pm:1.79
--- loncom/xml/scripttag.pm:1.78 Mon Oct 14 16:47:11 2002
+++ loncom/xml/scripttag.pm Mon Oct 21 16:31:06 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.78 2002/10/14 20:47:11 albertel Exp $
+# $Id: scripttag.pm,v 1.79 2002/10/21 20:31:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,15 +59,18 @@
} elsif ( $target eq 'web' || $target eq 'tex' ||
$target eq 'grade' || $target eq 'answer' ||
$target eq 'analyze' ) {
- &Apache::run::run($bodytext,$safeeval);
- if (($target eq 'answer') && ($Apache::lonhomework::viewgrades == 'F')) {
- $Apache::lonxml::evaluate--;
- $result.="<a href=\"javascript:newWindow=open(\'\',\'new_W\',\'width=500,height=200,scrollbars=1\');newWindow.document.open(\'text/html\',\'replace\');newWindow.document.writeln(\'<html><head><title>newwindow</title></head><body bgcolor="#FFFFFF"><pre>";
- my $listing= &HTML::Entities::encode(&Apache::run::dump($target,$safeeval));
-
- $result.=$listing;
- $result.= "</pre></body></html>\');newWindow.document.close();void(0);\">Script Vars</a><br />";
- }
+ if (!$Apache::lonxml::default_homework_loaded) {
+ &Apache::lonxml::default_homework_load($safeeval);
+ }
+ &Apache::run::run($bodytext,$safeeval);
+ if (($target eq 'answer') && ($Apache::lonhomework::viewgrades == 'F')) {
+ $Apache::lonxml::evaluate--;
+ $result.="<a href=\"javascript:newWindow=open(\'\',\'new_W\',\'width=500,height=200,scrollbars=1\');newWindow.document.open(\'text/html\',\'replace\');newWindow.document.writeln(\'<html><head><title>newwindow</title></head><body bgcolor="#FFFFFF"><pre>";
+ my $listing= &HTML::Entities::encode(&Apache::run::dump($target,$safeeval));
+
+ $result.=$listing;
+ $result.= "</pre></body></html>\');newWindow.document.close();void(0);\">Script Vars</a><br />";
+ }
} elsif ($target eq "edit" ) {
#&Apache::run::run($bodytext,$safeeval);
#$result="<br /> <$token->[1]> output: <br />$bodytext<br />Source:<br />";
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.206 loncom/xml/lonxml.pm:1.207
--- loncom/xml/lonxml.pm:1.206 Mon Oct 21 13:10:35 2002
+++ loncom/xml/lonxml.pm Mon Oct 21 16:31:06 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.206 2002/10/21 17:10:35 albertel Exp $
+# $Id: lonxml.pm,v 1.207 2002/10/21 20:31:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -858,6 +858,7 @@
$Apache::lonxml::registered = 0;
$errorcount=0;
$warningcount=0;
+ $Apache::lonxml::default_homework_loaded=0;
&init_counter();
@Apache::lonxml::pwd=();
@Apache::lonxml::extlinks=();
@@ -957,6 +958,18 @@
$rndseed=&Apache::lonnet::rndseed($symb,$courseid,$domain,$name);
$safeinit .= ';$external::randomseed='.$rndseed.';';
&Apache::run::run($safeinit,$safeeval);
+}
+
+sub default_homework_load {
+ my ($safeeval)=@_;
+ &Apache::lonxml::debug('Loading default_homework');
+ my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
+ if ($default == -1) {
+ &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");
+ } else {
+ &Apache::run::run($default,$safeeval);
+ $Apache::lonxml::default_homework_loaded=1;
+ }
}
sub startredirection {
Index: doc/homework/xml.html
diff -u doc/homework/xml.html:1.6 doc/homework/xml.html:1.7
--- doc/homework/xml.html:1.6 Mon Oct 21 13:10:35 2002
+++ doc/homework/xml.html Mon Oct 21 16:31:06 2002
@@ -100,6 +100,12 @@
true, should use the &increment_counter() function to
increment this value.
</li>
+ <li>
+ <i>$Apache::lonxml::default_homework_loaded</i> - a boolean on
+ wherethe the default_homework.lcpm file has been loaded into
+ the Safe Space, the function
+ &Apache::lonxml::default_homework_load()
+ </li>
</ul>
<p>
@@ -319,7 +325,7 @@
<address><a href="mailto:albertel@marvin.lite.msu.edu">Guy Albertelli</a></address>
<!-- Created: Sun May 20 15:47:08 EDT 2001 -->
<!-- hhmts start -->
-Last modified: Mon Oct 21 13:23:28 EDT 2002
+Last modified: Mon Oct 21 16:41:56 EDT 2002
<!-- hhmts end -->
</body>
</html>