--- loncom/homework/structuretags.pm 2005/11/09 12:04:23 1.319 +++ loncom/homework/structuretags.pm 2005/11/21 21:51:29 1.324 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.319 2005/11/09 12:04:23 foxr Exp $ +# $Id: structuretags.pm,v 1.324 2005/11/21 21:51:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -346,6 +346,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'}; @@ -360,6 +362,8 @@ sub finalize_storage { &store_aggregates($symb,$courseid); } } + } else { + &Apache::lonxml::debug('Nothing to store'); } return $result; } @@ -513,7 +517,9 @@ sub start_problem { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; # 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. @@ -607,17 +613,22 @@ 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); if ( $target eq "web" ) { @@ -644,6 +655,16 @@ 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); + 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 @@ -683,14 +704,20 @@ sub start_problem { sub end_problem { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; - my $result= &Apache::lonxml::endredirection(); # started in &start_problem + my $result; - # Figure out the front matter which was too deeply coupled for me to easily - # unravel 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. + if (!$Apache::lonxml::metamode) { + $result = &Apache::lonxml::endredirection(); #started in &start_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 + # 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/) { @@ -780,6 +807,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); @@ -841,6 +870,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') { @@ -1212,8 +1244,10 @@ 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. + 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; } @@ -1322,7 +1356,10 @@ 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 + } if ($target eq 'grade') { if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) && !$hidden && $in_order_show) { @@ -1342,6 +1379,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='';