';
}
@@ -250,8 +259,8 @@ sub problem_edit_header {
sub problem_edit_footer {
return '
'.
- &Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields).
- "\n\n".&Apache::loncommon::endbodytag()."\n";
+ &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields()).
+ "\n\n".&Apache::loncommon::end_page();
}
sub option {
@@ -333,9 +342,18 @@ Feedback Mode:
}
sub initialize_storage {
- %Apache::lonhomework::results=();
- %Apache::lonhomework::history=();
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ my ($given_symb) = @_;
+ undef(%Apache::lonhomework::results);
+ undef(%Apache::lonhomework::history);
+ my ($symb,$courseid,$domain,$name) =
+ &Apache::lonxml::whichuser($given_symb);
+
+ # anonymous users (CODEd exams) have no data
+ if ($name eq 'anonymous'
+ && !defined($domain)) {
+ return;
+ }
+
if ($env{'request.state'} eq 'construct'
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice') {
@@ -355,6 +373,7 @@ sub initialize_storage {
%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=(); }
@@ -367,11 +386,13 @@ sub initialize_storage {
# Will increment totals for attempts, students, and corrects
# if running user has student role.
sub finalize_storage {
+ my ($given_symb) = @_;
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();
+ my ($symb,$courseid,$domain,$name) =
+ &Apache::lonxml::whichuser($given_symb);
if ($env{'request.state'} eq 'construct'
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice') {
@@ -442,13 +463,14 @@ sub checkout_msg {
'warning'=>'Checking out resources is subject to course policies, and may exclude future credit even if done erroneously.',
'checkout'=>'Check out Exam for Viewing',
'checkout?'=>'Check out Exam?');
+ my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});
return (<$lt{'resource'}
$lt{'id_expln'}
$lt{'warning'}
-
@@ -460,9 +482,10 @@ sub firstaccess_msg {
my ($map)=&Apache::lonnet::decode_symb($symb);
my $foldertitle=&Apache::lonnet::gettitle($map);
&Apache::lonxml::debug("map is $map title is $foldertitle");
+ my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'});
return (<The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".
-
@@ -503,7 +526,9 @@ sub init_problem_globals {
@Apache::structuretags::whileline=();
$Apache::lonhomework::scantronmode=0;
undef($Apache::lonhomework::name);
-
+ undef($Apache::lonhomework::default_type);
+ undef($Apache::lonhomework::type);
+ undef($Apache::lonhomework::problemstatus);
}
sub reset_problem_globals {
@@ -515,6 +540,11 @@ sub reset_problem_globals {
#detect if we try to do 2 problems in one file
# undef($Apache::lonhomework::parsing_a_problem);
undef($Apache::lonhomework::name);
+ undef($Apache::lonhomework::default_type);
+ undef($Apache::lonhomework::type);
+ undef($Apache::lonhomework::scantronmode);
+ undef($Apache::lonhomework::problemstatus);
+ undef($Apache::lonhomework::ignore_response_errors);
}
sub set_problem_state {
@@ -596,9 +626,15 @@ sub start_problem {
my $status;
my $accessmsg;
- #should get back a or the neccesary stuff to start XML/MathML
- my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
- &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
+ my $name= &get_resource_name($parstack,$safeeval);
+ my ($result,$form_tag_start);
+ if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex'
+ || $target eq 'edit') {
+ ($result,$form_tag_start) =
+ &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval,
+ $name);
+ }
+
if ($target eq 'tex' and $env{'request.symb'} =~ m/\.page_/) {$result='';}
if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
@@ -613,7 +649,7 @@ sub start_problem {
$Apache::lonhomework::history{"resource.0.outtoken"}=
$token;
}
- $body_tag_start.=&Apache::lonxml::printtokenheader($target,$token);
+ $result.=&Apache::lonxml::printtokenheader($target,$token);
}
if ($env{'form.markaccess'}) {
&Apache::lonnet::set_first_access('map');
@@ -663,8 +699,7 @@ sub start_problem {
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
$style);
if ( $target eq "web" ) {
- $result.= $head_tag_start.'';
- my $msg=$body_tag_start;
+ my $msg;
if ($status eq 'UNAVAILABLE') {
$msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
';
} elsif ($status ne 'NOT_YET_VIEWED') {
@@ -673,7 +708,7 @@ sub start_problem {
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
$msg.='The problem '.$accessmsg;
} elsif ($status eq 'UNCHECKEDOUT') {
- $msg.=&checkout_msg;
+ $msg.=&checkout_msg();
} elsif ($status eq 'NOT_YET_VIEWED') {
$msg.=&firstaccess_msg($accessmsg,$symb);
} elsif ($status eq 'NOT_IN_A_SLOT') {
@@ -695,17 +730,13 @@ sub start_problem {
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
$style);
if ($target eq 'web') {
- $result .= $head_tag_start.'';
- $result .= $body_tag_start;
$result .= &Apache::bridgetask::proctor_validation_screen();
} elsif ($target eq 'grade') {
&Apache::bridgetask::proctor_check_auth($slot_name,$slot,
'problem');
}
} elsif ($target eq 'web') {
- my $name= &get_resource_name($parstack,$safeeval);
- $result.="$head_tag_start$name
- $body_tag_start \n $form_tag_start".
+ $result.="\n $form_tag_start".
'';
# create a page header and exit
if ($env{'request.state'} eq "construct") {
@@ -723,8 +754,7 @@ sub start_problem {
}
} elsif ($target eq 'edit') {
- $result.=$head_tag_start."".$body_tag_start.$form_tag_start.
- &problem_edit_header();
+ $result .= $form_tag_start.&problem_edit_header();
$Apache::lonxml::warnings_error_header=
&mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")." ";
my $temp=&Apache::edit::insertlist($target,$token);
@@ -866,10 +896,10 @@ sub end_problem {
if ($target ne 'tex' &&
$env{'form.answer_output_mode'} ne 'tex') {
$result.="";
- $result.=&Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields);
+ $result.= &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields());
}
if ($target eq 'web') {
- $result.=&Apache::lonxml::xmlend().'