--- loncom/homework/structuretags.pm 2000/12/21 18:13:33 1.24 +++ loncom/homework/structuretags.pm 2001/01/11 16:11:16 1.30 @@ -6,7 +6,7 @@ use strict; use Apache::lonnet; sub BEGIN { - &Apache::lonxml::register('Apache::structuretags',('block','while','randomlist','problem','web','tex','part','pre_duedate','post_answerdate','solved','not_solved')); + &Apache::lonxml::register('Apache::structuretags',('block','while','randomlist','problem','web','tex','part','preduedate','postanswerdate','solved','notsolved')); } sub start_web { @@ -54,7 +54,7 @@ sub start_problem { if ( $status eq 'CLOSED' ) { my $bodytext=&Apache::lonxml::get_all_text("/problem",$$parser[$#$parser]); if ( $target eq "web" ) { - return "

Problem is not open to be viewed. The problem $datemsg

"; + return "

Problem is not open to be viewed. The problem $datemsg

"; } } } @@ -62,10 +62,15 @@ sub start_problem { my $args =''; if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } my $name = &Apache::run::run("{$args;".'return $name}',$safeeval); + if ($name eq '') { + $name=&Apache::lonnet::EXT('resource.title'); + if ($name eq 'con_lost') { $name = ''; } + } + $Apache::lonhomework::name=$name; if ($status eq 'CAN_ANSWER') { # create a page header and exit return "$name\n\n
"; - } elsif ($status eq 'SHOW_ANSWER') { + } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'CLOSED') { return "$name\n\n"; } } @@ -77,7 +82,8 @@ sub end_problem { my $result=''; my $status=$Apache::inputtags::status['-1']; unless ($target eq 'meta') { - if ( $target eq 'grade' && $Apache::inputtags::part eq '0') { + if ( $target eq 'grade' && $Apache::inputtags::part eq '0' && + $status eq 'CAN_ANSWER') { # if part is zero, no s existed, so we need to the grading &Apache::inputtags::grade; } elsif ($Apache::inputtags::part eq '0') { @@ -88,7 +94,7 @@ sub end_problem { if ($target eq 'web') { if ($status eq 'CAN_ANSWER') { $result.="\n"; - } elsif ($status eq 'SHOW_ANSWER') { + } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') { $result.="\n"; } } @@ -231,54 +237,58 @@ sub start_part { sub end_part { my ($target,$token,$parstack,$parser,$safeeval)=@_; &Apache::lonxml::debug("in end_part $target "); + my $status=$Apache::inputtags::status['-1']; pop @Apache::inputtags::status; if ( $target eq 'meta' ) { return ''; } - if ( $target eq 'grade' ) { return &Apache::inputtags::grade; } + if ( $target eq 'grade' && $status eq 'CAN_ANSWER') { + return &Apache::inputtags::grade; + } return &Apache::inputtags::gradestatus($Apache::inputtags::part); } -sub start_pre_duedate { +sub start_preduedate { my ($target,$token,$parstack,$parser,$safeeval)=@_; if ($target ne 'meta') { - if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER') { - &Apache::lonxml::get_all_text("/pre_duedate",$$parser[$#$parser]); + if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' && + $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER' ) { + &Apache::lonxml::get_all_text("/preduedate",$$parser[$#$parser]); } } return ''; } -sub end_pre_duedate { +sub end_preduedate { return ''; } -sub start_post_answerdate { +sub start_postanswerdate { my ($target,$token,$parstack,$parser,$safeeval)=@_; if ($target ne 'meta') { if ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') { - &Apache::lonxml::get_all_text("/post_answerdate",$$parser[$#$parser]); + &Apache::lonxml::get_all_text("/postanswerdate",$$parser[$#$parser]); } } return ''; } -sub end_post_answerdate { +sub end_postanswerdate { return ''; } -sub start_not_solved { +sub start_notsolved { my ($target,$token,$parstack,$parser,$safeeval)=@_; if ($target ne 'meta') { my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"}; &Apache::lonxml::debug("not solved has :$gradestatus:"); if ($gradestatus =~ /^correct/) { &Apache::lonxml::debug("skipping"); - &Apache::lonxml::get_all_text("/not_solved",$$parser[$#$parser]); + &Apache::lonxml::get_all_text("/notsolved",$$parser[$#$parser]); } } return ''; } -sub end_not_solved { +sub end_notsolved { return ''; }