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

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


albertel		Mon Feb 16 15:01:26 2004 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  - BUG#1682, support settings in <part>ed problem
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.239 loncom/homework/structuretags.pm:1.240
--- loncom/homework/structuretags.pm:1.239	Mon Feb 16 14:50:10 2004
+++ loncom/homework/structuretags.pm	Mon Feb 16 15:01:26 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.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 @@
     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 @@
 	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 @@
 	    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') ||