';
}
@@ -252,8 +316,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 {
@@ -269,9 +333,7 @@ sub option {
sub problem_web_to_edit_header {
my ($rndseed)=@_;
my $result.='';
- if (!$Apache::lonhomework::parsing_a_task) {
- $result .= '';
- }
+ $result .= '';
$result .= '
@@ -279,16 +341,22 @@ sub problem_web_to_edit_header {
- ';
+ '';
+ $result.=&mt('Apply style file: ').'
+&').'" />
+ '.&mt('Select').'
+
+ ';
+
if (!$Apache::lonhomework::parsing_a_task) {
$result.="
@@ -330,21 +398,45 @@ Feedback Mode:
'.'.&Apache::loncommon::help_open_topic("Analyze_Problem",
'',undef,undef,300).
'';
+ } elsif ($Apache::lonhomework::parsing_a_task) {
+ $result.="
+
+Problem Status:
+
+
+
+";
}
return $result;
}
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::lonnet::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') {
my $namespace = $symb || $env{'request.uri'};
if ($env{'form.resetdata'} eq &mt('Reset Submissions') ||
- $env{'form.resetdata'} eq &mt('New Problem Variation') ||
+ ($env{'form.resetdata'} eq &mt('New Problem Variation')
+ && $env{'form.submitted'} eq 'yes') ||
$env{'form.newrandomization'} eq &mt('New Randomization')) {
&Apache::lonnet::tmpreset($namespace,'',$domain,$name);
&Apache::lonxml::debug("Attempt reset");
@@ -357,6 +449,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=(); }
@@ -369,11 +462,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::lonnet::whichuser($given_symb);
if ($env{'request.state'} eq 'construct'
|| $symb eq ''
|| $Apache::lonhomework::type eq 'practice') {
@@ -395,7 +490,6 @@ sub finalize_storage {
}
return $result;
}
-use Data::Dumper;
# -------------------------------------------------------------store_aggregates
# Sends hash of values to be incremented in nohist_resourcetracker.db
@@ -444,13 +538,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'}
-
@@ -462,9 +557,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".
-
@@ -505,7 +601,8 @@ sub init_problem_globals {
@Apache::structuretags::whileline=();
$Apache::lonhomework::scantronmode=0;
undef($Apache::lonhomework::name);
-
+ undef($Apache::lonhomework::default_type);
+ undef($Apache::lonhomework::type);
}
sub reset_problem_globals {
@@ -517,6 +614,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 {
@@ -566,12 +668,7 @@ sub start_problem {
$Apache::lonhomework::scantronmode=1;
}
- &initialize_storage();
if ($target ne 'analyze') {
- if ($target eq 'web') {
- &Apache::lonhomework::showhash(%Apache::lonhomework::history);
- }
- if ($env{'request.state'} eq 'construct') { &set_problem_state('0'); }
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
if (($env{'request.state'} eq 'construct') &&
defined($env{'form.problemtype'})) {
@@ -591,6 +688,17 @@ sub start_problem {
}
$Apache::lonhomework::default_type = $Apache::lonhomework::type;
+ &initialize_storage();
+ if ($target ne 'analyze'
+ && $env{'request.state'} eq 'construct') {
+ &set_problem_state('0');
+ }
+
+ if ($target eq 'web') {
+ &Apache::lonxml::debug(" grading history ");
+ &Apache::lonhomework::showhash(%Apache::lonhomework::history);
+ }
+
#added vars to the scripting enviroment
my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
$expression.='$external::type=\''.$Apache::lonhomework::type.'\';';
@@ -598,9 +706,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); }
@@ -615,14 +729,14 @@ 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');
}
#handle rand seed in construction space
my $rndseed=&setup_rndseed($safeeval);
- my ($symb)=&Apache::lonxml::whichuser();
+ my ($symb)=&Apache::lonnet::whichuser();
if ($env{'request.state'} ne "construct" &&
($symb eq '' || $Apache::lonhomework::type eq 'practice')) {
$form_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') {
$msg.='
'.&mt('Not open to be viewed').'
';
}
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
- $msg.='The problem '.$accessmsg;
+ $msg.=&mt('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') {
@@ -697,17 +810,21 @@ 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();
+ $result .=
+ &Apache::bridgetask::proctor_validation_screen($slot);
} 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".
+ if ($status eq 'CAN_ANSWER'
+ && $slot_name ne ''
+ && $Apache::lonhomework::history{'resource.0.checkedin'} eq '') {
+ # unproctored slot access, self checkin
+ &Apache::bridgetask::check_in('problem',undef,undef,
+ $slot_name);
+ }
+ $result.="\n $form_tag_start \t".
'';
# create a page header and exit
if ($env{'request.state'} eq "construct") {
@@ -725,15 +842,13 @@ 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);
$result.=$temp;
} elsif ($target eq 'modified') {
$result=$token->[4];
- $result.=&Apache::edit::handle_insert();
} else {
# page_start returned a starting result, delete it if we don't need it
$result = '';
@@ -751,7 +866,6 @@ sub end_problem {
}
if ($target eq 'tex') {
-
# Figure out the front matter and replace the
# INSERTTEXFRONTMATTERHERE in result with it. note that we do
# this in end_problem because whether or not we display due
@@ -827,14 +941,14 @@ sub end_problem {
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
}
} else {
- $frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';
+ $frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\'.$startminipage;
}
} else {
if (not $env{'request.symb'} =~ m/\.page_/) {
$frontmatter .= $begin_doc.$toc_line;
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
} else {
- $frontmatter .= '\vskip 1mm \\\\\\\\';
+ $frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage;
}
}
$result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/;
@@ -868,10 +982,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().'