--- loncom/homework/structuretags.pm 2004/02/16 19:50:10 1.239 +++ loncom/homework/structuretags.pm 2004/02/16 20:01:26 1.240 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.239 2004/02/16 19:50:10 albertel Exp $ +# $Id: structuretags.pm,v 1.240 2004/02/16 20:01:26 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -373,6 +373,14 @@ sub reset_problem_globals { undef($Apache::lonhomework::name); } +sub set_problem_status { + my ($part)=@_; + if ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct') { + $Apache::lonhomework::history{"resource.$part.solved"}= + 'correct_by_student'; + } +} + sub start_problem { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; @@ -395,17 +403,13 @@ sub start_problem { if ($target eq 'web') { &Apache::lonhomework::showhash(%Apache::lonhomework::history); } - if ($ENV{'request.state'} eq 'construct' && - $ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct' ) { - $Apache::lonhomework::history{'resource.0.solved'}= - 'correct_by_student'; - } + if ($ENV{'request.state'} eq 'construct') { &set_problem_status('0'); } $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type'); if (($ENV{'request.state'} eq 'construct') && defined($ENV{'form.problemtype'})) { $Apache::lonhomework::type=$ENV{'form.problemtype'}; } - &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:"); + &Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:"); } if ($Apache::lonhomework::type eq '' ) { my $uri=$ENV{'request.uri'}; @@ -1010,6 +1014,9 @@ sub start_part { my $expression='$external::datestatus="'.$status.'";'; $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";'; &Apache::run::run($expression,$safeeval); + if ($ENV{'request.state'} eq 'construct') { + &set_problem_status($Apache::inputtags::part); + } if (( $status eq 'CLOSED' ) || ( $status eq 'UNCHECKEDOUT') || ( $status eq 'BANNED') ||