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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 02 Nov 2006 23:25:41 -0000


albertel		Thu Nov  2 18:25:41 2006 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - move display of <Criteria> Form the end of the <Dimension> to be at the location of the <Criteria>
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.189 loncom/homework/bridgetask.pm:1.190
--- loncom/homework/bridgetask.pm:1.189	Thu Nov  2 17:23:06 2006
+++ loncom/homework/bridgetask.pm	Thu Nov  2 18:25:40 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.189 2006/11/02 22:23:06 albertel Exp $
+# $Id: bridgetask.pm,v 1.190 2006/11/02 23:25:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2211,33 +2211,6 @@
 			    $result.=$dimension{$id}{'result'};
 			    next;
 			}
-			my $status= &get_criteria('status', $version,$dim,$id);
-			my $comment=&get_criteria('comment',$version,$dim,$id);
-			my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N');
-			if ($mandatory) {
-			    $mandatory='Mandatory';
-			} else {
-			    $mandatory='Optional';
-			}
-			if ($status eq 'fail') {
-			} elsif ($status eq 'pass') {
-			} else {
-			    &Apache::lonxml::error("Student viewing a graded bridgetask was shown a status of $status");
-			}
-			my $status_display=$status;
-			$status_display=~s/^([a-z])/uc($1)/e;
-			$result.=
-			    '<div class="LC_'.$status.' LC_criteria"><h4>'
-			    .$mandatory.' Criteria</h4><p>';
-			$result.=
-			    &nested_parse(\$dimension{$dim}{'criteria.'.$id},
-					  [@_],{'set_dim_id' => $id});
-			$result.='</p><p class="LC_grade">'.$status_display.'</p>';
-			if ($comment) {
-			    $result.='<p class="LC_comment">'.
-				&mt('Comment: [_1]',$comment).'</p>';
-			}
-			$result.='</div>';
 		    }
 		}
 	    }
@@ -2495,6 +2468,7 @@
 sub start_Criteria {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style);
+    my $result = '';
     if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
 	my $dim = &get_dim_id();
 	my $id=&get_id($parstack,$safeeval);
@@ -2512,9 +2486,37 @@
 	    $dimension{$dim}{'criteria.'.$id.'.mandatory'}=
 		&Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
 	    push(@{$dimension{$dim}{'criterias'}},$id);
+
+	    my $version=&get_version();
+	    my $task_status = 
+		$Apache::lonhomework::history{"resource.$version.0.status"};
+	    if ($target eq 'web' 
+		&& ($task_status eq 'pass' || $task_status eq 'fail')) {
+		my $status= &get_criteria('status', $version,$dim,$id);
+		my $comment=&get_criteria('comment',$version,$dim,$id);
+		my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N');
+		if ($mandatory) {
+		    $mandatory='Mandatory';
+		} else {
+		    $mandatory='Optional';
+		}
+		my $status_display=$status;
+		$status_display=~s/^([a-z])/uc($1)/e;
+		$result.=
+		    '<div class="LC_'.$status.' LC_criteria"><h4>'
+		    .$mandatory.' Criteria</h4><p>';
+		$result.=
+		    &nested_parse(\$dimension{$dim}{'criteria.'.$id},[@_]);
+		$result.='</p><p class="LC_grade">'.$status_display.'</p>';
+		if ($comment) {
+		    $result.='<p class="LC_comment">'.
+			&mt('Comment: [_1]',$comment).'</p>';
+		}
+		$result.='</div>';
+	    }
 	}
     }
-    return '';
+    return $result;
 }
 
 sub end_Criteria {