--- loncom/xml/lonxml.pm 2007/10/24 10:06:22 1.467 +++ loncom/xml/lonxml.pm 2008/05/28 01:32:59 1.478 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.467 2007/10/24 10:06:22 foxr Exp $ +# $Id: lonxml.pm,v 1.478 2008/05/28 01:32:59 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -377,8 +377,12 @@ sub xmlparse { $finaloutput .= join('',@script_var_displays); undef(@script_var_displays); } - + &init_state(); if ($env{'form.return_only_error_and_warning_counts'}) { + if ($env{'request.filename'}=~/\.(html|htm|xml)$/i) { + my $error=&verify_html($content_file_string); + if ($error) { $errorcount++; } + } return "$errorcount:$warningcount"; } return $finaloutput; @@ -659,6 +663,7 @@ sub setup_globals { &init_counter(); &clear_bubble_lines_for_part(); &init_state(); + &set_state('target',$target); @Apache::lonxml::pwd=(); @Apache::lonxml::extlinks=(); @script_var_displays=(); @@ -722,6 +727,7 @@ sub init_safespace { $safehole->wrap(\&Apache::chemresponse::chem_standard_order,$safeeval, '&chem_standard_order'); $safehole->wrap(\&Apache::response::check_status,$safeeval,'&check_status'); + $safehole->wrap(\&Apache::response::implicit_multiplication,$safeeval,'&implicit_multiplication'); $safehole->wrap(\&Apache::lonmaxima::maxima_eval,$safeeval,'&maxima_eval'); $safehole->wrap(\&Apache::lonmaxima::maxima_check,$safeeval,'&maxima_check'); @@ -1074,6 +1080,7 @@ Optional Arguments: sub increment_counter { my ($increment, $part_response) = @_; + if ($env{'form.grade_target'} eq 'analyze') { return; } if (!defined($increment) || $increment le 0) { $increment = 1; } @@ -1082,7 +1089,7 @@ sub increment_counter { # If the caller supplied the response_id parameter, # Maintain its counter.. creating if necessary. - if(defined($part_response)) { + if (defined($part_response)) { if (!defined($Apache::lonxml::counters_per_part{$part_response})) { $Apache::lonxml::counters_per_part{$part_response} = 0; } @@ -1115,7 +1122,7 @@ sub init_counter { } sub store_counter { - &Apache::lonnet::appenv(('form.counter' => $Apache::lonxml::counter)); + &Apache::lonnet::appenv({'form.counter' => $Apache::lonxml::counter}); $Apache::lonxml::counter_changed=0; return ''; } @@ -1136,7 +1143,7 @@ sub store_counter { sub restore_problem_counter { if (defined($state)) { - &Apache::lonnet::appenv(('form.counter' => $state)); + &Apache::lonnet::appenv({'form.counter' => $state}); } } sub get_problem_counter { @@ -1148,7 +1155,7 @@ sub store_counter { =pod -=item bubble_lines_for_part(response_id) +=item bubble_lines_for_part(part_response) Returns the number of lines required to get a response for $part_response (this is just $Apache::lonxml::counters_per_part{$part_response} @@ -1163,7 +1170,6 @@ sub bubble_lines_for_part { } else { return $Apache::lonxml::counters_per_part{$part_response}; } - } =pod @@ -1182,7 +1188,7 @@ sub clear_bubble_lines_for_part { =pod -=item set_bubble_lines(response_id, value) +=item set_bubble_lines(part_response, value) If there is a problem part, that for whatever reason requires bubble lines that are not @@ -1374,7 +1380,7 @@ sub writeallows { &Apache::lonnet::hreflocation($thisdir,&unescape($_))}=$thisurl; } @extlinks=(); - &Apache::lonnet::appenv(%httpref); + &Apache::lonnet::appenv(\%httpref); } sub register_ssi { @@ -1474,11 +1480,50 @@ SIMPLECONTENT return $filecontents; } +sub verify_html { + my ($filecontents)=@_; + if ($filecontents!~/(?:\<|\<\;)(?:html|xml)[^\<]*(?:\>|\>\;)/is) { + return &mt('File does not have [_1] or [_2] starting tag','<html>','<xml>'); + } + if ($filecontents!~/(?:\<|\<\;)\/(?:html|xml)(?:\>|\>\;)/is) { + return &mt('File does not have [_1] or [_2] ending tag','<html>','<xml>'); + } + if ($filecontents!~/(?:\<|\<\;)(?:body|frameset)[^\<]*(?:\>|\>\;)/is) { + return &mt('File does not have [_1] or [_2] starting tag','<body>','<frameset>'); + } + if ($filecontents!~/(?:\<|\<\;)\/(?:body|frameset)[^\<]*(?:\>|\>\;)/is) { + return &mt('File does not have [_1] or [_2] ending tag','<body>','<frameset>'); + } + return ''; +} + +sub renderingoptions { + my %langchoices=('' => ''); + foreach (&Apache::loncommon::languageids()) { + if (&Apache::loncommon::supportedlanguagecode($_)) { + $langchoices{&Apache::loncommon::supportedlanguagecode($_)} + = &Apache::loncommon::plainlanguagedescription($_); + } + } + return + ''. + &mt('Language: '). + &Apache::loncommon::select_form($env{'form.languages'},'languages', + %langchoices).' + + '. + &mt('Math Rendering: '). + &Apache::loncommon::select_form($env{'form.texengine'},'texengine', + ('' => '', + 'tth' => 'tth', + 'jsMath' => 'jsMath', + 'mimetex' => 'mimetex')).' + '; +} sub inserteditinfo { - my ($filecontents,$filetype)=@_; + my ($filecontents, $filetype, $filename)=@_; $filecontents = &HTML::Entities::encode($filecontents,'<>&"'); -# my $editheader='Edit below