'.
@@ -315,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 {
@@ -338,11 +369,16 @@ sub initialize_storage {
sub finalize_storage {
my $result;
if (%Apache::lonhomework::results) {
+ 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,
@@ -352,6 +388,8 @@ sub finalize_storage {
&store_aggregates($symb,$courseid);
}
}
+ } else {
+ &Apache::lonxml::debug('Nothing to store');
}
return $result;
}
@@ -502,10 +540,12 @@ sub get_problem_status {
}
sub start_problem {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
# We'll use the redirection to fix up printing of duedates.
- &Apache::lonxml::startredirection();
+ if (!$Apache::lonxml::metamode) {
+ &Apache::lonxml::startredirection();
+ }
# Problems don't nest and we don't allow more than one in
# a .problem file.
@@ -513,7 +553,7 @@ sub start_problem {
if ( $Apache::inputtags::part ne '' ||
$Apache::lonhomework::parsing_a_problem) {
&Apache::lonxml::error('Only one <problem> allowed in a .problem file');
- #my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
+ #my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,$style);
return '';
}
@@ -535,7 +575,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'};
@@ -581,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.=
' |