--- loncom/xml/lonxml.pm 2002/10/17 17:13:44 1.204 +++ loncom/xml/lonxml.pm 2002/10/25 18:58:19 1.208 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.204 2002/10/17 17:13:44 albertel Exp $ +# $Id: lonxml.pm,v 1.208 2002/10/25 18:58:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,7 +60,7 @@ package Apache::lonxml; use vars -qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode); +qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode $errorcount $warningcount); use strict; use HTML::LCParser(); use HTML::TreeBuilder(); @@ -106,6 +106,10 @@ use Apache::lonmsg(); #debugging control, to turn on debugging modify the correct handler $Apache::lonxml::debug=0; +# keeps count of the number of warnings and errors generated in a parse +$warningcount=0; +$errorcount=0; + #path to the directory containing the file currently being processed @pwd=(); @@ -524,7 +528,7 @@ sub xmlparse { # do we have a course style file? # - if ($ENV{'request.course.id'}) { + if ($ENV{'request.course.id'} && $ENV{'request.state'} ne 'construct') { my $bodytext= $ENV{'course.'.$ENV{'request.course.id'}.'.default_xml_style'}; if ($bodytext) { @@ -852,6 +856,9 @@ sub setup_globals { my ($request,$target)=@_; $Apache::lonxml::request=$request; $Apache::lonxml::registered = 0; + $errorcount=0; + $warningcount=0; + $Apache::lonxml::default_homework_loaded=0; &init_counter(); @Apache::lonxml::pwd=(); @Apache::lonxml::extlinks=(); @@ -953,6 +960,18 @@ sub init_safespace { &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("Unable to find default_homework.lcpm"); + } else { + &Apache::run::run($default,$safeeval); + $Apache::lonxml::default_homework_loaded=1; + } +} + sub startredirection { $Apache::lonxml::redirection++; push (@Apache::lonxml::outputstack, ''); @@ -1352,6 +1371,7 @@ sub debug { } sub error { + $errorcount++; if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) { # If printing in construction space, put the error inside

     print "ERROR:".join("\n",@_)."\n";
@@ -1377,6 +1397,7 @@ sub error {
 }
 
 sub warning {
+  $warningcount++;
   if ($ENV{'request.state'} eq 'construct') {
     print "WARNING:".join('
',@_)."
\n"; }