--- loncom/homework/structuretags.pm 2006/03/28 18:31:37 1.332.2.1 +++ loncom/homework/structuretags.pm 2006/04/13 18:35:06 1.342 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.332.2.1 2006/03/28 18:31:37 albertel Exp $ +# $Id: structuretags.pm,v 1.342 2006/04/13 18:35:06 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::File(); use Apache::lonmenu; use Apache::lonlocal; use Apache::lonxml; +use Apache::lonenc(); use Time::HiRes qw( gettimeofday tv_interval ); BEGIN { &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag')); @@ -44,7 +45,7 @@ BEGIN { sub start_web { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style); - if ($target eq 'web') { + if ($target eq 'web' || $target eq 'webgrade') { return $bodytext; } return ''; @@ -88,10 +89,8 @@ sub body_tag_start { } $body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1); - &Apache::lontexconvert::jsMath_reset(); - if ($env{'environment.texengine'} eq 'jsMath') { - $body_tag_start.=&Apache::lontexconvert::jsMath_header(); - } + $body_tag_start.=&Apache::lontexconvert::init_math_support(); + return $body_tag_start; } @@ -156,9 +155,8 @@ sub page_start { } my $form_tag_start; if (!defined($found{'form'})) { - $form_tag_start='

'. &Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields). - "\n
\n".&Apache::loncommon::endbodytag()."\n"; + "\n\n".&Apache::loncommon::end_page(); } sub option { @@ -336,9 +336,19 @@ sub initialize_storage { %Apache::lonhomework::results=(); %Apache::lonhomework::history=(); my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); - if ($env{'request.state'} eq 'construct' || $symb eq '') { + if ($env{'request.state'} eq 'construct' + || $symb eq '' + || $Apache::lonhomework::type eq 'practice') { + + my $namespace = $symb || $env{'request.uri'}; + if ($env{'form.resetdata'} eq &mt('Reset Submissions') || + $env{'form.resetdata'} eq &mt('New Problem Variation') || + $env{'form.newrandomization'} eq &mt('New Randomization')) { + &Apache::lonnet::tmpreset($namespace,'',$domain,$name); + &Apache::lonxml::debug("Attempt reset"); + } %Apache::lonhomework::history= - &Apache::lonnet::tmprestore($env{'request.uri'},'',$domain,$name); + &Apache::lonnet::tmprestore($namespace,'',$domain,$name); my ($temp)=keys %Apache::lonhomework::history ; &Apache::lonxml::debug("Return message of $temp"); } else { @@ -362,10 +372,13 @@ sub finalize_storage { my @remove = grep(/^INTERNAL_/,keys(%Apache::lonhomework::results)); delete(@Apache::lonhomework::results{@remove}); my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); - if ($env{'request.state'} eq 'construct' || $symb eq '') { + if ($env{'request.state'} eq 'construct' + || $symb eq '' + || $Apache::lonhomework::type eq 'practice') { + my $namespace = $symb || $env{'request.uri'}; $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'}; $result=&Apache::lonnet::tmpstore(\%Apache::lonhomework::results, - $env{'request.uri'},'',$domain,$name); + $namespace,'',$domain,$name); &Apache::lonxml::debug('Construct Store return message:'.$result); } else { $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results, @@ -608,14 +621,18 @@ sub start_problem { #handle rand seed in construction space my $rndseed=&setup_rndseed($safeeval); my ($symb)=&Apache::lonxml::whichuser(); - if ($env{'request.state'} ne "construct" && $symb eq '') { + if ($env{'request.state'} ne "construct" && + ($symb eq '' || $Apache::lonhomework::type eq 'practice')) { $form_tag_start.=''. ''. + value="'.&mt('New Problem Variation').'" />'; + if (exists($env{'form.username'})) { + $form_tag_start.= ''; - if ($env{'user.adv'}) { + } + if ($env{'request.role.adv'}) { $form_tag_start.= '