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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 06 Jun 2006 21:05:56 -0000


albertel		Tue Jun  6 17:05:56 2006 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - adding <Setup> section, in functionality a <Criteria>less dimension basically a way of getting <instance> selection while not causing anything to be created that needs grading
  
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.161 loncom/homework/bridgetask.pm:1.162
--- loncom/homework/bridgetask.pm:1.161	Thu Jun  1 15:31:12 2006
+++ loncom/homework/bridgetask.pm	Tue Jun  6 17:05:56 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.161 2006/06/01 19:31:12 albertel Exp $
+# $Id: bridgetask.pm,v 1.162 2006/06/06 21:05:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -43,7 +43,7 @@
  
 
 BEGIN {
-    &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Instance','InstanceText','Criteria','ClosingParagraph'));
+    &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','ClosingParagraph'));
 }
 
 sub initialize_bridgetask {
@@ -1791,6 +1791,15 @@
 }
 
 my %dimension;
+sub start_Setup {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+    undef(%dimension);
+    my $dim_id=&get_id($parstack,$safeeval);
+    $Apache::bridgetask::dimension=$dim_id;
+    undef(@Apache::bridgetask::instance);
+    &Apache::lonxml::startredirection();
+    return &internal_location($dim_id);
+}
 sub start_Question { return &start_Dimension(@_); }
 sub start_Dimension {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
@@ -2060,6 +2069,41 @@
 	}
 	return $result;
     }
+
+    sub end_Setup {
+	my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+	my $result=&Apache::lonxml::endredirection();
+	my $dim=&get_id($parstack,$safeeval);
+	my $instance=&get_instance($dim);
+	my $version=&get_version();
+	if ($target eq 'web') {
+	    @Apache::scripttag::parser_env = @_;
+	    $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
+	    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'});
+		@Apache::scripttag::parser_env = @_;
+		$result.=&Apache::scripttag::xmlparse($dimension{'questiontext'});
+	    }
+	} elsif ($target eq 'webgrade' 
+		 || $target eq 'grade' && $env{'form.webgrade'}) {
+	    # in case of any side effects that we need
+	    @Apache::scripttag::parser_env = @_;
+	    &Apache::scripttag::xmlparse($dimension{'intro'});
+	    @Apache::scripttag::parser_env = @_;
+	    &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+	    @Apache::scripttag::parser_env = @_;
+	    &Apache::scripttag::xmlparse($dimension{'questiontext'});
+	} else {
+	    # any other targets no output
+	    undef($result);
+	}
+	return $result;
+    }
 }
 
 sub grading_history {