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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 04 Nov 2005 15:31:55 -0000


albertel		Fri Nov  4 10:31:55 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - enable 'show all foils'
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.75 loncom/homework/bridgetask.pm:1.76
--- loncom/homework/bridgetask.pm:1.75	Thu Nov  3 17:59:35 2005
+++ loncom/homework/bridgetask.pm	Fri Nov  4 10:31:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.75 2005/11/03 22:59:35 albertel Exp $
+# $Id: bridgetask.pm,v 1.76 2005/11/04 15:31:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1473,75 +1473,81 @@
 	if ($target eq 'web') {
 	    @Apache::scripttag::parser_env = @_;
 	    $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
-	    @Apache::scripttag::parser_env = @_;
-	    $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
-	    if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
-		$Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
-
-		my $dim_status=$Apache::lonhomework::history{"resource.$version.$dim.status"};
-		my $mandatory='Mandatory';
-		if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') {
-		    $mandatory='Optional';
-		}
-		my $dim_info="<div class='$dim_status'>\n";
-		if ($dim_status eq 'pass') {
-		    $dim_info.='<h3>Question : you passed this '.$mandatory.' question</h3>';
-		}
-		if ($dim_status eq 'fail') {
-		    $dim_info.='<h3>Question : you did not pass this '.$mandatory.' question</h3>';
-		}
-		my $man_count=0;
-		my $man_passed=0;
-		my $opt_count=0;
-		my $opt_passed=0;
-		foreach my $id (@{$dimension{$instance.'.criterias'}}) {
-		    if ($dimension{$instance.'.criteria.'.$id.'.mandatory'} 
-			eq 'N') {
-			$opt_count++;
-			if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
-			    $opt_passed++;
-			}
-		    } else {
-			$man_count++;
-			if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
-			    $man_passed++;
-			}
-		    }
-		}
-		if ($man_passed eq $man_count) { $man_passed='all'; }
-		my $opt_req=$dimension{$instance.'.optionalrequired'};
-		if ($opt_req !~ /\S/) { $opt_req='0'; }
-		$dim_info.="\n<p>".&mt('You passed [_1] of the [_2] mandatory components and [_3] of the [_4] optional components, of which you were required to pass [_5].',$man_passed,$man_count,$opt_passed,$opt_count,$opt_req)."</p>\n</div>";
-
-		my $internal_location=&internal_location($dim);
-		$result=~s/\Q$internal_location\E/$dim_info/;
-
-		foreach my $id (@{$dimension{$instance.'.criterias'}}) {
-		    my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
-		    my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
-		    my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
-		    if ($mandatory) {
-			$mandatory='Mandatory';
-		    } else {
+	    my @instances = $instance;
+	    if (&Apache::response::showallfoils()) {
+		@instances = @{$dimension{'instances'}};
+	    }
+	    foreach my $instance (@instances) {
+		@Apache::scripttag::parser_env = @_;
+		$result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+		if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
+		    $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
+
+		    my $dim_status=$Apache::lonhomework::history{"resource.$version.$dim.status"};
+		    my $mandatory='Mandatory';
+		    if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') {
 			$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 $dim_info="<div class='$dim_status'>\n";
+		    if ($dim_status eq 'pass') {
+			$dim_info.='<h3>Question : you passed this '.$mandatory.' question</h3>';
 		    }
-		    my $status_display=$status;
-		    $status_display=~s/^([a-z])/uc($1)/e;
-		    @Apache::scripttag::parser_env = @_;
-		    $result.='<div class="'.$status.'"><h4>'.$mandatory.
-			' Criteria</h4><p>';
-		    @Apache::scripttag::parser_env = @_;
-		    $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
-		    $result.='</p><p class="grade">'.$status_display.'</p>';
-		    if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
-			$result.='<p class="comment">'.$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'</p>';
+		    if ($dim_status eq 'fail') {
+			$dim_info.='<h3>Question : you did not pass this '.$mandatory.' question</h3>';
+		    }
+		    my $man_count=0;
+		    my $man_passed=0;
+		    my $opt_count=0;
+		    my $opt_passed=0;
+		    foreach my $id (@{$dimension{$instance.'.criterias'}}) {
+			if ($dimension{$instance.'.criteria.'.$id.'.mandatory'} 
+			    eq 'N') {
+			    $opt_count++;
+			    if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
+				$opt_passed++;
+			    }
+			} else {
+			    $man_count++;
+			    if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
+				$man_passed++;
+			    }
+			}
+		    }
+		    if ($man_passed eq $man_count) { $man_passed='all'; }
+		    my $opt_req=$dimension{$instance.'.optionalrequired'};
+		    if ($opt_req !~ /\S/) { $opt_req='0'; }
+		    $dim_info.="\n<p>".&mt('You passed [_1] of the [_2] mandatory components and [_3] of the [_4] optional components, of which you were required to pass [_5].',$man_passed,$man_count,$opt_passed,$opt_count,$opt_req)."</p>\n</div>";
+
+		    my $internal_location=&internal_location($dim);
+		    $result=~s/\Q$internal_location\E/$dim_info/;
+
+		    foreach my $id (@{$dimension{$instance.'.criterias'}}) {
+			my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
+			my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
+			my $mandatory=($dimension{$instance.'.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;
+			@Apache::scripttag::parser_env = @_;
+			$result.='<div class="'.$status.'"><h4>'.$mandatory.
+			    ' Criteria</h4><p>';
+			@Apache::scripttag::parser_env = @_;
+			$result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
+			$result.='</p><p class="grade">'.$status_display.'</p>';
+			if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
+			    $result.='<p class="comment">'.$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'</p>';
+			}
+			$result.='</div>';
 		    }
-		    $result.='</div>';
 		}
 	    }
 	} elsif ($target eq 'webgrade') {