--- loncom/homework/bridgetask.pm	2005/05/06 20:26:35	1.18
+++ loncom/homework/bridgetask.pm	2005/05/09 21:55:01	1.19
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.18 2005/05/06 20:26:35 albertel Exp $
+# $Id: bridgetask.pm,v 1.19 2005/05/09 21:55:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -469,11 +469,18 @@ sub end_ClosingParagraph {
     return $result;
 }
 
+sub get_id {
+    my ($parstack,$safeeval)=@_;
+    my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval);
+    if (!$id) { $id=$Apache::lonxml::curdepth; }
+    return $id;
+}
+
 my %dimension;
 sub start_Dimension {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     undef(%dimension);
-    my $dim_id=$Apache::lonxml::curdepth;
+    my $dim_id=&get_id($parstack,$safeeval);
     $Apache::bridgetask::dimension=$dim_id;
     push(@Apache::bridgetask::dimensionlist,$dim_id);
     undef(@Apache::bridgetask::instance);
@@ -494,24 +501,23 @@ sub get_instance {
     sub end_Dimension {
 	my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 	my $result;
+	my $instance=&get_instance();
 	if ($target eq 'web') {
-	    my $instance=&get_instance();
 	    $result=$dimension{'intro'}.$dimension{$instance.'.text'};
 	} elsif ($target eq 'webgrade') {
-	    my $instance=&get_instance();
 	    foreach my $id (@{$dimension{$instance.'.criterias'}}) {
 		my $link='criteria_'.$instance.'_'.$id;
-		$result.='<tr><td valign="top">'.
+		$result.='<tr><td width="100%" valign="top">'.
 		    '<a name="'.$link.'" />'.
 		    '<a name="next_'.$last_link.'" />'.
 		    '<br /><textarea enabled="false" style="width:100%" rows="8" width="25" wrap="hard">'.$dimension{$instance.'.criteria.'.$id}.'</textarea>'.
 		    #$dimension{$instance.'.criteria.'.$id}.
 		    '</td>'.
-		    '<td>Additional Comment for Student <br />'.
+		    '<td><nobr>Additional Comment for Student</nobr> <br />'.
 		    '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'"></textarea>'.
 		    '</td>'.
 		    '<td>'.
-		    '<label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" />Ungraded</label><br />'.
+		    '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" />Ungraded</label></nobr><br />'.
 		    '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" />Pass</label><br />'.
 		    '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" />Fail</label><br />'.
 		    '<label><input type="radio" name="HWVAL_'.$link.'" value="review" />Review</label><br />'.
@@ -522,6 +528,15 @@ sub get_instance {
 		    '</td></tr>';
 		$last_link=$link;
 	    }
+	} elsif ($target eq 'grade') {
+	    my $optional_passed=0;
+	    foreach my $id (@{$dimension{$instance.'.criterias'}}) {
+		if ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'pass') {
+		} elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'fail') {
+		} elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'ungraded') {
+		} elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'review') {
+		}
+	    }
 	}
 	return $result;
     }
@@ -551,9 +566,12 @@ sub end_IntroParagraph {
 
 sub start_Instance {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
-    push(@{$dimension{'instances'}},$Apache::lonxml::curdepth);
-    push(@Apache::bridgetask::instance,$Apache::lonxml::curdepth);
-    push(@Apache::bridgetask::instancelist,$Apache::lonxml::curdepth);
+    my $id=&get_id($parstack,$safeeval);
+    push(@{$dimension{'instances'}},$id);
+    push(@Apache::bridgetask::instance,$id);
+    push(@Apache::bridgetask::instancelist,$id);
+    $dimension{$instance_id.'.optionalrequired'}=
+	&Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
     return '';
 }
 
@@ -592,8 +610,10 @@ sub end_Criteria {
     my $instance_id=$Apache::bridgetask::instance[-1];
     if ($target eq 'web' || $target eq 'webgrade') {
 	my $criteria=&Apache::lonxml::endredirection();
-	my $id=$Apache::lonxml::curdepth;
+	my $id=&get_id($parstack,$safeeval);
 	$dimension{$instance_id.'.criteria.'.$id}=$criteria;
+	$dimension{$instance_id.'.criteria.'.$id.'.mandatory'}=
+	    &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
 	push(@{$dimension{$instance_id.'.criterias'}},$id);
     }
     return '';