[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 16 Feb 2004 20:20:01 -0000


albertel		Mon Feb 16 15:20:01 2004 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  - Ahh, BUG#1682 should be done now, <part>ed problems now respect show/noshow feedback
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.240 loncom/homework/structuretags.pm:1.241
--- loncom/homework/structuretags.pm:1.240	Mon Feb 16 15:01:26 2004
+++ loncom/homework/structuretags.pm	Mon Feb 16 15:20:01 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.240 2004/02/16 20:01:26 albertel Exp $
+# $Id: structuretags.pm,v 1.241 2004/02/16 20:20:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -336,14 +336,8 @@
     if ($type eq 'problem') {
 	$Apache::inputtags::part='0';
 	@Apache::inputtags::partlist=('0');
-	$Apache::lonhomework::problemstatus=
-	    &Apache::lonnet::EXT('resource.0.problemstatus');
-	&Apache::lonxml::debug("problem status is  $Apache::lonhomework::problemstatus");
-	&Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});
-	if ($ENV{'request.state'} eq 'construct' &&
-	    defined($ENV{'form.problemstatus'})) {
-	    $Apache::lonhomework::problemstatus=$ENV{'form.problemstatus'};
-	}
+
+	$Apache::lonhomework::problemstatus=&get_problem_status('0')
     } else {
 	$Apache::inputtags::part='';
 	@Apache::inputtags::partlist=();
@@ -373,7 +367,7 @@
     undef($Apache::lonhomework::name);
 }
 
-sub set_problem_status {
+sub set_problem_state {
     my ($part)=@_;
     if ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct') {
 	$Apache::lonhomework::history{"resource.$part.solved"}=
@@ -381,6 +375,18 @@
     }
 }
 
+sub get_problem_status {
+    my ($part)=@_;
+    my $problem_status=&Apache::lonnet::EXT("resource.$part.problemstatus");
+    &Apache::lonxml::debug("problem status for $part is $problem_status");
+    &Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});
+    if ($ENV{'request.state'} eq 'construct' &&
+	defined($ENV{'form.problemstatus'})) {
+	$problem_status=$ENV{'form.problemstatus'};
+    }
+    return $problem_status;
+}
+
 sub start_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 
@@ -403,7 +409,7 @@
 	if ($target eq 'web') {
 	    &Apache::lonhomework::showhash(%Apache::lonhomework::history);
 	}
-       	if ($ENV{'request.state'} eq 'construct') { &set_problem_status('0'); }
+       	if ($ENV{'request.state'} eq 'construct') { &set_problem_state('0'); }
 	$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
 	if (($ENV{'request.state'} eq 'construct') &&
 	    defined($ENV{'form.problemtype'})) {
@@ -994,8 +1000,7 @@
     @Apache::inputtags::response=();
     @Apache::inputtags::previous=();
     @Apache::inputtags::previous_version=();
-    $Apache::lonhomework::problemstatus=
-	&Apache::lonnet::EXT("resource.$id.problemstatus");
+    $Apache::lonhomework::problemstatus=&get_problem_status($id);
     my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
     my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
     &Apache::run::run($expression,$safeeval);
@@ -1015,7 +1020,7 @@
 	    $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); 
+		&set_problem_state($Apache::inputtags::part); 
 	    }
 	    if (( $status eq 'CLOSED' ) ||
 		( $status eq 'UNCHECKEDOUT') ||