'.
@@ -338,6 +353,8 @@ 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 '') {
$Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};
@@ -352,6 +369,8 @@ sub finalize_storage {
&store_aggregates($symb,$courseid);
}
}
+ } else {
+ &Apache::lonxml::debug('Nothing to store');
}
return $result;
}
@@ -502,10 +521,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 +534,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 '';
}
@@ -599,19 +620,25 @@ sub start_problem {
}
$form_tag_start.=' ';
}
- ($status,$accessmsg) = &Apache::lonhomework::check_access('0');
+
+ ($status,$accessmsg,my $slot_name,my $slot) =
+ &Apache::lonhomework::check_slot_access('0','problem');
push (@Apache::inputtags::status,$status);
+
my $expression='$external::datestatus="'.$status.'";';
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
&Apache::run::run($expression,$safeeval);
&Apache::lonxml::debug("Got $status");
+
if (( $status eq 'CLOSED' ) ||
( $status eq 'UNCHECKEDOUT') ||
( $status eq 'NOT_YET_VIEWED') ||
( $status eq 'BANNED') ||
( $status eq 'UNAVAILABLE') ||
+ ( $status eq 'NOT_IN_A_SLOT') ||
( $status eq 'INVALID_ACCESS')) {
- my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
+ my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
+ $style);
if ( $target eq "web" ) {
$result.= $head_tag_start.'';
my $msg=$body_tag_start;
@@ -626,6 +653,8 @@ sub start_problem {
$msg.=&checkout_msg;
} elsif ($status eq 'NOT_YET_VIEWED') {
$msg.=&firstaccess_msg($accessmsg,$symb);
+ } elsif ($status eq 'NOT_IN_A_SLOT') {
+ $msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work.");
}
$result.=$msg.' ';
} elsif ($target eq 'tex') {
@@ -636,6 +665,17 @@ sub start_problem {
$result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
}
}
+ } elsif ($status eq 'NEEDS_CHECKIN') {
+ 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
@@ -653,74 +693,8 @@ sub start_problem {
}
}
} elsif ($target eq 'tex') {
- my $startminipage = '';
- if (not $env{'form.problem_split'}=~/yes/) {
- $startminipage = '\begin{minipage}{\textwidth}';
- }
- my $id = $Apache::inputtags::part;
- my $weight = &Apache::lonnet::EXT("resource.$id.weight");
- my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');
- my @packages = split /,/,$packages;
- my $allow_print_points = 0;
- foreach my $partial_key (@packages) {
- if ($partial_key=~m/^part_0$/) {
- $allow_print_points=1;
- }
- }
- my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
- if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }
- if (lc($env{'course.'.$env{'request.course.id'}.
- '.disableexampointprint'}) eq 'yes') {
- $allow_print_points=0;
- }
- my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
- my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource "'.$name_of_resourse.'" located in '.$env{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent ';
- my $toc_line='\vskip 1 mm\noindent '.$startminipage.
- '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
-
- # Figure out what the due date is and if we need to print
- # it in the problem header. We have been logging the
- # last due date written to file.
-
- my $duetime = &Apache::lonnet::EXT("resource.$id.duedate");
- my $duedate = POSIX::strftime("%c",localtime($duetime));
- my $temp_file;
- my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
-
- # Figure out what the last printed due date is or set it
- # to the epoch if no duedates have been printed.
-
- my $due_file_content = 0; # If the file does not yet exist, time is the epoch.
- if (-e $filename) {
- $temp_file = Apache::File->new($filename);
- my @due_file = <$temp_file>;
- $due_file_content = $due_file[$#due_file];
- chomp $due_file_content;
- }
-
- # comparisons of the absolute times
- if ($due_file_content != $duetime) {
- $temp_file = Apache::File->new('>'.$filename);
- print $temp_file "$duetime\n";
- if (not $env{'request.symb'} =~ m/\.page_/) {
- if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
- $result .= $begin_doc.
- '\textit{Due date: '.$duedate.'} '.$toc_line;
- } else {
- $result .= $begin_doc.$toc_line;
- if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
- }
- } else {
- $result .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';
- }
- } else {
- if (not $env{'request.symb'} =~ m/\.page_/) {
- $result .= $begin_doc.$toc_line;
- if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
- } else {
- $result .= '\vskip 1mm \\\\\\\\';
- }
- }
+ $result .= 'INSERTTEXFRONTMATTERHERE';
+
}
} elsif ($target eq 'edit') {
$result.=$head_tag_start."".$body_tag_start.$form_tag_start.
@@ -741,7 +715,102 @@ sub start_problem {
sub end_problem {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- my $result= &Apache::lonxml::endredirection(); # started in &start_problem
+ my $result;
+
+ if (!$Apache::lonxml::metamode) {
+ $result = &Apache::lonxml::endredirection(); #started in &start_problem
+ $Apache::lonxml::post_evaluate=0;
+ }
+
+ 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
+ # dates depends on whether due dates have already been
+ # displayed in the problem parts.
+
+ my $frontmatter = '';
+ my $startminipage = '';
+ if (not $env{'form.problem_split'}=~/yes/) {
+ $startminipage = '\begin{minipage}{\textwidth}';
+ }
+ my $id = $Apache::inputtags::part;
+ my $weight = &Apache::lonnet::EXT("resource.$id.weight");
+ my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');
+ my @packages = split /,/,$packages;
+ my $allow_print_points = 0;
+ foreach my $partial_key (@packages) {
+ if ($partial_key=~m/^part_0$/) {
+ $allow_print_points=1;
+ }
+ }
+ my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
+ if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }
+ if (lc($env{'course.'.$env{'request.course.id'}.
+ '.disableexampointprint'}) eq 'yes') {
+ $allow_print_points=0;
+ }
+ my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
+ my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource "'.$name_of_resourse.'" located in '.$env{'request.uri'}.' STAMPOFPASSEDRESOURCEEND} \noindent ';
+ my $toc_line='\vskip 1 mm\noindent '.$startminipage.
+ '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
+
+ # Figure out what the due date is and if we need to print
+ # it in the problem header. We have been logging the
+ # last due date written to file.
+
+ my $duetime = &Apache::lonnet::EXT("resource.$id.duedate");
+ my $duedate = POSIX::strftime("%c",localtime($duetime));
+ my $temp_file;
+ my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
+
+ # Figure out what the last printed due date is or set it
+ # to the epoch if no duedates have been printed.
+
+ my $due_file_content = 0; # If the file does not yet exist, time is the epoch.
+ if (-e $filename) {
+ $temp_file = Apache::File->new($filename);
+ my @due_file = <$temp_file>;
+ $due_file_content = $due_file[$#due_file];
+ chomp $due_file_content;
+ }
+
+ # We display the due date iff it is not the same as the last
+ # duedate in problem header ($due_file_content), and
+ # none of our parts displayed a duedate.
+ #
+ my $parts_with_displayduedate;
+ if (defined $Apache::outputtags::showonce{'displayduedate'}) {
+ $parts_with_displayduedate =
+ scalar(@{$Apache::outputtags::showonce{'displayduedate'}});
+ } else {
+ $parts_with_displayduedate = 0;
+ }
+ if (($due_file_content != $duetime) && ($parts_with_displayduedate == 0) ) {
+ $temp_file = Apache::File->new('>'.$filename);
+ print $temp_file "$duetime\n";
+ if (not $env{'request.symb'} =~ m/\.page_/) {
+ if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
+ $frontmatter .= $begin_doc.
+ '\textit{Due date: '.$duedate.'} '.$toc_line;
+ } else {
+ $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\textit{Due date: '.$duedate.'} \\\\\\\\';
+ }
+ } 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 \\\\\\\\';
+ }
+ }
+ $result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/;
+ }
my $status=$Apache::inputtags::status['-1'];
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
@@ -750,6 +819,8 @@ sub end_problem {
# if part is zero, no s existed, so we need to the grading
if ($status eq 'CAN_ANSWER' ||$Apache::lonhomework::scantronmode) {
&Apache::inputtags::grade;
+ } elsif ($status eq 'NEEDS_CHECKIN') {
+ # no need to grade, and don't want to hide data
} else {
# move any submission data to .hidden
&Apache::inputtags::hidealldata($Apache::inputtags::part);
@@ -811,6 +882,9 @@ sub end_problem {
} elsif ($target eq 'edit') {
&Apache::lonxml::debug("in end_problem with $target, edit");
$result .= &problem_edit_footer();
+ } elsif ($target eq 'modified') {
+ $result .= $token->[2];
+ $result.=&Apache::edit::handle_insertafter($token->[1]);
}
if ($env{'request.state'} eq 'construct' && $target eq 'web') {
@@ -869,12 +943,12 @@ sub end_library {
}
sub start_definetag {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
my $name = $token->[2]->{'name'};
- my $skip=&Apache::lonxml::get_all_text("/definetag",$parser);
+ my $skip=&Apache::lonxml::get_all_text("/definetag",$parser,$style);
if ($name=~/^\//) {
$result=
'
END '.$name.' | ';
@@ -1020,7 +1094,7 @@ sub end_instructorcomment {
}
sub start_while {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
@@ -1032,7 +1106,7 @@ sub start_while {
&Apache::lonxml::default_homework_load($safeeval);
}
my $result = &Apache::run::run($code,$safeeval);
- my $bodytext=&Apache::lonxml::get_all_text("/while",$parser);
+ my $bodytext=&Apache::lonxml::get_all_text("/while",$parser,$style);
push( @Apache::structuretags::whilebody, $bodytext);
push( @Apache::structuretags::whileline, $token->[5]);
&Apache::lonxml::debug("s code $code got -$result-");
@@ -1088,11 +1162,11 @@ sub end_while {
# ...
#
sub start_randomlist {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
if ($target eq 'answer' || $target eq 'grade' || $target eq 'web' ||
$target eq 'tex' || $target eq 'analyze') {
- my $body= &Apache::lonxml::get_all_text("/randomlist",$parser);
+ my $body= &Apache::lonxml::get_all_text("/randomlist",$parser,$style);
my $b_parser= HTML::LCParser->new(\$body);
$b_parser->xml_mode(1);
$b_parser->marked_sections(1);
@@ -1181,9 +1255,11 @@ sub ordered_show_check {
}
sub start_part {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- &Apache::lonxml::startredirection(); # we'll use redirection to fix up
- # duedates.
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ if (!$Apache::lonxml::metamode) {
+ &Apache::lonxml::startredirection(); # we'll use redirection to fix up
+ # duedates.
+ }
my $result='';
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
@@ -1208,7 +1284,7 @@ sub start_part {
} elsif ($target eq 'web' || $target eq 'grade' ||
$target eq 'answer' || $target eq 'tex') {
if ($hidden || !$in_order_show) {
- my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
+ my $bodytext=&Apache::lonxml::get_all_text("/part",$parser,$style);
} else {
my ($status,$accessmsg) = &Apache::lonhomework::check_access($id);
push (@Apache::inputtags::status,$status);
@@ -1224,7 +1300,8 @@ sub start_part {
( $status eq 'BANNED') ||
( $status eq 'UNAVAILABLE') ||
( $status eq 'INVALID_ACCESS')) {
- my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
+ my $bodytext=&Apache::lonxml::get_all_text("/part",$parser,
+ $style);
if ( $target eq "web" ) {
$result=" ".&mt('Part is not open to be viewed. It')." $accessmsg ";
} elsif ( $target eq 'tex' ) {
@@ -1292,7 +1369,11 @@ sub end_part {
my $status=$Apache::inputtags::status['-1'];
my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
my $in_order_show=&ordered_show_check();
- my $result= &Apache::lonxml::endredirection(); # started in &start_part
+ my $result;
+ if (!$Apache::lonxml::metamode) {
+ $result = &Apache::lonxml::endredirection(); # started in &start_part
+ $Apache::lonxml::post_evaluate=0;
+ }
if ($target eq 'grade') {
if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&
!$hidden && $in_order_show) {
@@ -1312,6 +1393,9 @@ sub end_part {
if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';}
} elsif ($target eq 'edit') {
$result.=&Apache::edit::end_table();
+ } elsif ($target eq 'modified') {
+ $result .= $token->[2];
+ $result.=&Apache::edit::handle_insertafter($token->[1]);
}
pop @Apache::inputtags::status;
$Apache::inputtags::part='';
@@ -1320,14 +1404,14 @@ sub end_part {
}
sub start_preduedate {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
&Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']);
if (!$Apache::lonhomework::scantronmode &&
$Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
&Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER'));
- &Apache::lonxml::get_all_text("/preduedate",$parser);
+ &Apache::lonxml::get_all_text("/preduedate",$parser,$style);
}
}
return '';
@@ -1338,14 +1422,14 @@ sub end_preduedate {
}
sub start_postanswerdate {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target eq 'web' || $target eq 'grade') {
if ($Apache::lonhomework::scantronmode ||
$Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
- &Apache::lonxml::get_all_text("/postanswerdate",$parser);
+ &Apache::lonxml::get_all_text("/postanswerdate",$parser,$style);
}
} elsif ($target eq 'tex') {
- &Apache::lonxml::get_all_text("/postanswerdate",$parser);
+ &Apache::lonxml::get_all_text("/postanswerdate",$parser,$style);
}
return '';
}
@@ -1355,7 +1439,7 @@ sub end_postanswerdate {
}
sub start_notsolved {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex') {
my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
@@ -1363,7 +1447,7 @@ sub start_notsolved {
if ($gradestatus =~ /^correct/ &&
&Apache::response::show_answer()) {
&Apache::lonxml::debug("skipping");
- &Apache::lonxml::get_all_text("/notsolved",$parser);
+ &Apache::lonxml::get_all_text("/notsolved",$parser,$style);
}
}
return '';
@@ -1374,13 +1458,13 @@ sub end_notsolved {
}
sub start_solved {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex') {
my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
if ($gradestatus !~ /^correct/ ||
!&Apache::response::show_answer()) {
- &Apache::lonxml::get_all_text("/solved",$parser);
+ &Apache::lonxml::get_all_text("/solved",$parser,$style);
}
}
return '';
@@ -1391,7 +1475,7 @@ sub end_solved {
}
sub start_problemtype {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
$target eq 'tex' || $target eq 'analyze') {
@@ -1403,10 +1487,10 @@ sub start_problemtype {
if ($Apache::lonhomework::type eq lc($type)) { $found=1; }
}
if ($mode eq 'show' && !$found) {
- &Apache::lonxml::get_all_text("/problemtype",$parser);
+ &Apache::lonxml::get_all_text("/problemtype",$parser,$style);
}
if ($mode eq 'hide' && $found) {
- &Apache::lonxml::get_all_text("/problemtype",$parser);
+ &Apache::lonxml::get_all_text("/problemtype",$parser,$style);
}
} elsif ($target eq 'edit') {
$result .=&Apache::edit::tag_start($target,$token);
@@ -1440,12 +1524,12 @@ sub start_startouttext {
}
sub end_startouttext {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result='';
my $text='';
if ($target eq 'edit') {
- $text=&Apache::lonxml::get_all_text("endouttext",$parser);
+ $text=&Apache::lonxml::get_all_text("endouttext",$parser,$style);
$result.=&Apache::edit::start_table($token)."".&mt('Text Block')." |
".&mt('Delete:').
&Apache::edit::deletelist($target,$token)
@@ -1484,8 +1568,8 @@ sub end_endouttext {
}
sub delete_startouttext {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- # my $text=&Apache::lonxml::get_all_text("endouttext",$parser);
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ # my $text=&Apache::lonxml::get_all_text("endouttext",$parser,$style);
my $text=$$parser['-1']->get_text("/endouttext");
my $ntoken=$$parser['-1']->get_token();
&Apache::lonxml::debug("Deleting :$text: and :$ntoken->[0]:$ntoken->[1]:$ntoken->[2]: for startouttext");
|
|