--- loncom/homework/structuretags.pm 2001/08/22 19:21:36 1.66
+++ loncom/homework/structuretags.pm 2001/10/13 05:59:18 1.70
@@ -66,8 +66,15 @@ sub page_start {
sub initialize_storage {
%Apache::lonhomework::results=();
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
- %Apache::lonhomework::history=
- &Apache::lonnet::restore($symb,$courseid,$domain,$name);
+ if ($ENV{'request.state'} eq 'construct') {
+ %Apache::lonhomework::history=
+ &Apache::lonnet::restore($ENV{'request.uri'},'nohist_construct',$domain,$name);
+ my ($temp)=keys %Apache::lonhomework::history ;
+ &Apache::lonxml::debug("Return message of $temp");
+ } else {
+ %Apache::lonhomework::history=
+ &Apache::lonnet::restore($symb,$courseid,$domain,$name);
+ }
#ignore error conditions
my ($temp)=keys %Apache::lonhomework::history ;
if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); }
@@ -82,9 +89,16 @@ sub finalize_storage {
my ($temp) = keys %Apache::lonhomework::results;
if ( $temp ne '' ) {
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
- $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
- $symb,$courseid,$domain,$name);
- &Apache::lonxml::debug("Store return message:".$result);
+ if ($ENV{'request.state'} eq 'construct') {
+ $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
+ $ENV{'request.uri'},'nohist_construct',
+ $domain,$name);
+ &Apache::lonxml::debug('Construct Store return message:'.$result);
+ } else {
+ $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
+ $symb,$courseid,$domain,$name);
+ &Apache::lonxml::debug('Store return message:'.$result);
+ }
}
return $result;
}
@@ -127,7 +141,7 @@ sub start_problem {
}
}
-#added vars to the scripting enviroment
+ #added vars to the scripting enviroment
my $expression='$external::part='.$Apache::inputtags::part.';';
&Apache::run::run($expression,$safeeval);
my $status;
@@ -137,17 +151,28 @@ sub start_problem {
my ($result,$head_tag_start,$body_tag_start)=
&page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
- if ($Apache::lonhomework::type eq 'exam') {
- if ($target eq 'web') {
- my $token=$Apache::lonhomework::history{"resource.0.outtoken"};
- if (($ENV{'form.doescheckout'}) && (!$token)) {
- $token=&Apache::lonxml::maketoken();
- $Apache::lonhomework::history{"resource.0.outtoken"}=$token;
- }
- $body_tag_start.=&Apache::lonxml::printtokenheader($target,$token);
+
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer') {
+ #handle exam checkout
+ if ($Apache::lonhomework::type eq 'exam') {
+ my $token=$Apache::lonhomework::history{"resource.0.outtoken"};
+ if (($ENV{'form.doescheckout'}) && (!$token)) {
+ $token=&Apache::lonxml::maketoken();
+ $Apache::lonhomework::history{"resource.0.outtoken"}=$token;
}
- }
- if ($target eq 'web' || $target eq 'grade') {
+ $body_tag_start.=&Apache::lonxml::printtokenheader($target,$token);
+ }
+
+ #handle rand seed in construction space
+ my $rndseed;
+ if ($ENV{'request.state'} eq "construct") {
+ $rndseed=$ENV{'form.rndseed'};
+ if (!$rndseed) {
+ $rndseed=time;
+ $ENV{'form.rndseed'}=$rndseed;
+ }
+ &Apache::run::run('$external::randomseed='.$rndseed.';',$safeeval);
+ }
($status,$accessmsg) = &Apache::lonhomework::check_access('0');
push (@Apache::inputtags::status,$status);
my $expression='$external::datestatus="'.$status.'";';
@@ -166,42 +191,45 @@ sub start_problem {
} elsif ($status eq 'UNCHECKEDOUT') {
$msg.=&checkout_msg;
}
- return $result.$msg.'
';
+ $result.=$msg.'
';
}
- }
- }
- if ($target eq 'web') {
- my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
- if ($name eq '') {
- $name=&Apache::lonnet::EXT('resource.title');
- if ($name eq 'con_lost') { $name = ''; }
- }
- $Apache::lonhomework::name=$name;
- if ($status eq 'CAN_ANSWER') {
- # create a page header and exit
- $result.="$head_tag_start