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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 01 Jun 2006 19:22:30 -0000


albertel		Thu Jun  1 15:22:30 2006 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - adding a <QuestionText> to <Question>/<Dimension>
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.159 loncom/homework/bridgetask.pm:1.160
--- loncom/homework/bridgetask.pm:1.159	Thu Jun  1 15:20:56 2006
+++ loncom/homework/bridgetask.pm	Thu Jun  1 15:22:29 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.159 2006/06/01 19:20:56 albertel Exp $
+# $Id: bridgetask.pm,v 1.160 2006/06/01 19:22:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -43,7 +43,7 @@
  
 
 BEGIN {
-    &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','Instance','InstanceText','Criteria','ClosingParagraph'));
+    &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Instance','InstanceText','Criteria','ClosingParagraph'));
 }
 
 sub initialize_bridgetask {
@@ -1805,6 +1805,20 @@
     return &internal_location($dim_id);
 }
 
+sub start_QuestionText {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    my $dim_id=$Apache::bridgetask::dimension;
+    my $text=&Apache::lonxml::get_all_text('/questiontext',$parser,$style);
+    if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+	$dimension{'questiontext'}=$text;
+    }
+    return '';
+}
+
+sub end_QuestionText {
+    return '';
+}
+
 sub get_instance {
     my ($dim)=@_;
     my $rand_alg=&Apache::lonnet::get_rand_alg();
@@ -1865,9 +1879,12 @@
 	    if (&Apache::response::showallfoils()) {
 		@instances = @{$dimension{'instances'}};
 	    }
+	    my $shown_question_text;
 	    foreach my $instance (@instances) {
 		@Apache::scripttag::parser_env = @_;
 		$result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+		@Apache::scripttag::parser_env = @_;
+		$result.=&Apache::scripttag::xmlparse($dimension{'questiontext'});
 		if ($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass' ||
 		    $Apache::lonhomework::history{"resource.$version.0.status"} eq 'fail') {
 
@@ -1952,6 +1969,8 @@
 	    &Apache::scripttag::xmlparse($dimension{'intro'});
 	    @Apache::scripttag::parser_env = @_;
 	    &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+	    @Apache::scripttag::parser_env = @_;
+	    &Apache::scripttag::xmlparse($dimension{'questiontext'});
 	    foreach my $id (@{$dimension{$instance.'.criterias'}},
 			    @{$dimension{'criterias'}} ) {
 		my $link=&link($id);
@@ -1987,11 +2006,14 @@
 
 	    @Apache::scripttag::parser_env = @_;
 	    $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
+	    @Apache::scripttag::parser_env = @_;
+	    $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+	    @Apache::scripttag::parser_env = @_;
+	    &Apache::scripttag::xmlparse($dimension{'questiontext'});
+
 	    foreach my $id (@{$dimension{$instance.'.criterias'}},
 			    @{$dimension{'criterias'}}) {
 		my $link=&link($id);
-		@Apache::scripttag::parser_env = @_;
-		$result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
 		my $status=$Apache::lonhomework::results{"resource.$version.0.$dim.$id.status"}=$env{'form.HWVAL_'.$link};
 		$Apache::lonhomework::results{"resource.$version.0.$dim.$id.comment"}=$env{'form.HWVAL_comment_'.$link};
 		my $mandatory=($dimension{'criteria.'.$id.'.mandatory'} ne 'N');