--- loncom/homework/structuretags.pm 2006/01/18 20:16:43 1.331 +++ loncom/homework/structuretags.pm 2006/02/16 02:03:25 1.336 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.331 2006/01/18 20:16:43 albertel Exp $ +# $Id: structuretags.pm,v 1.336 2006/02/16 02:03:25 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -113,6 +113,12 @@ sub page_start { &Apache::lonhtmlcommon::htmlareaheaders(). &Apache::lonhtmlcommon::spellheader(). &Apache::lonxml::fontsettings(); + my $css_href = &Apache::lonnet::EXT('resource.0.cssfile'); + if ($css_href =~ /\S/) { + &Apache::lonxml::extlink($css_href); + $head_tag_start = + ''; + } if ($target eq 'edit') { $head_tag_start.=&Apache::edit::js_change_detection(); } @@ -186,8 +192,10 @@ sub setup_rndseed { my ($safeeval)=@_; my $rndseed; my ($symb)=&Apache::lonxml::whichuser(); - if ($env{'request.state'} eq "construct" || $symb eq '' || - $Apache::lonhomework::history{'resource.CODE'}) { + if ($env{'request.state'} eq "construct" + || $symb eq '' + || $Apache::lonhomework::type eq 'practice' + || $Apache::lonhomework::history{'resource.CODE'}) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['rndseed']); $rndseed=$env{'form.rndseed'}; @@ -330,9 +338,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 { @@ -356,10 +374,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, @@ -556,7 +577,7 @@ sub start_problem { defined($env{'form.problemtype'})) { $Apache::lonhomework::type=$env{'form.problemtype'}; } - &Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:"); + &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:"); } if ($Apache::lonhomework::type eq '' ) { my $uri=$env{'request.uri'}; @@ -602,14 +623,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.= '