--- loncom/homework/structuretags.pm 2003/05/03 20:35:43 1.167 +++ loncom/homework/structuretags.pm 2003/05/13 20:38:55 1.171 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.167 2003/05/03 20:35:43 www Exp $ +# $Id: structuretags.pm,v 1.171 2003/05/13 20:38:55 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,7 +38,7 @@ use Apache::File(); use Apache::lonmenu; BEGIN { - &Apache::lonxml::register('Apache::structuretags',('block','languageblock','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','startouttext','endouttext')); + &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','startouttext','endouttext')); } sub start_web { @@ -272,6 +272,8 @@ sub start_problem { @Apache::structuretags::whilebody=(); @Apache::structuretags::whileline=(); $Apache::lonhomework::scantronmode=0; + $Apache::lonhomework::problemstatus= + &Apache::lonnet::EXT('resource.0.problemstatus'); if (defined($ENV{'scantron.maxquest'})) { $Apache::lonhomework::scantronmode=1; @@ -479,7 +481,7 @@ sub end_problem { ) { if ($status eq 'CAN_ANSWER') { if ($target ne 'tex') { - $result.="\n"; + if ($ENV{'form.print_answer'} ne 'yes') {$result.="\n";} } } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'UNCHECKEDOUT' ) { @@ -503,8 +505,10 @@ sub end_problem { &finalize_storage(); } if ($target eq 'answer' && ($ENV{'request.state'} eq 'construct') ) { - $result.=''; #normally we get it from xmlend, but in CSTR - # we always show answer mode too. + if ($ENV{'form.print_answer'} ne 'yes') { + $result.=''; #normally we get it from xmlend, but in CSTR + # we always show answer mode too. + } } } elsif ($target eq 'meta') { if ($Apache::inputtags::part eq '0') { @@ -644,9 +648,8 @@ sub start_languageblock { $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack, - $safeeval,'include') - .&Apache::edit::get_new_args($token,$parstack, - $safeeval,'exclude'); + $safeeval,'include', + 'exclude'); if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } } return $result; @@ -661,6 +664,35 @@ sub end_languageblock { return $result; } +sub start_instructorcomment { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + + my $result; + + if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || + $target eq 'tex' || $target eq 'analyze') { + $result=($ENV{'request.role'}=~/^(in|cc|au|ca|li)/); + if ( ! $result ) { + my $skip=&Apache::lonxml::get_all_text("/instructorcomment",$parser); + &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]"); + } + $result=''; + } elsif ($target eq 'edit') { + $result .=&Apache::edit::tag_start($target,$token); + $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); + } + return $result; +} + +sub end_instructorcomment { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + my $result; + if ($target eq "edit") { + $result.= &Apache::edit::tag_end($target,$token,''); + } + return $result; +} + sub start_while { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; @@ -815,6 +847,8 @@ sub start_part { @Apache::inputtags::responselist = (); @Apache::inputtags::previous=(); @Apache::inputtags::previous_version=(); + $Apache::lonhomework::problemstatus= + &Apache::lonnet::EXT("resource.$id.problemstatus"); my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part); if ($target eq 'meta') {