[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm /xml lonxml.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 11 Sep 2007 23:53:13 -0000
albertel Tue Sep 11 19:53:13 2007 EDT
Modified files:
/loncom/homework structuretags.pm
/loncom/xml lonxml.pm
Log:
- BUG#4816, implementing the <translated> idea
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.396 loncom/homework/structuretags.pm:1.397
--- loncom/homework/structuretags.pm:1.396 Tue Sep 11 19:36:39 2007
+++ loncom/homework/structuretags.pm Tue Sep 11 19:53:05 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.396 2007/09/11 23:36:39 albertel Exp $
+# $Id: structuretags.pm,v 1.397 2007/09/11 23:53:05 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,7 @@
use LONCAPA;
BEGIN {
- &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
+ &Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
}
sub start_web {
@@ -1195,6 +1195,56 @@
return $result;
}
+{
+ my %available_texts;
+ sub start_translated {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ &Apache::lonxml::register('Apache::structuretags',('lang'));
+ undef(%available_texts);
+ }
+
+ sub end_translated {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result;
+ #show the translation on viewable targets
+ if ($target eq 'web' || $target eq 'tex' || $target eq 'webgrade'||
+ # or non-viewable targets, if it's embedded in something that
+ # wants the output
+ (($target eq 'answer' || $target eq 'analyze'|| $target eq 'grade')
+ && &Apache::lonxml::in_redirection() ) ) {
+ my @possibilities = keys(%available_texts);
+ my $which =
+ &Apache::loncommon::languages(\@possibilities) || 'default';
+ $result = $available_texts{$which};
+ }
+ undef(%available_texts);
+ &Apache::lonxml::deregister('Apache::structuretags',('lang'));
+ return $result;
+ }
+
+
+ sub start_lang {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
+ &Apache::lonxml::startredirection();
+ }
+ return '';
+ }
+
+ sub end_lang {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
+ my $result = &Apache::lonxml::endredirection();
+ my $which = &Apache::lonxml::get_param('which',$parstack,
+ $safeeval);
+ $available_texts{$which} = $result;
+ }
+ return '';
+ }
+}
+
sub start_instructorcomment {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.458 loncom/xml/lonxml.pm:1.459
--- loncom/xml/lonxml.pm:1.458 Tue Sep 11 16:36:18 2007
+++ loncom/xml/lonxml.pm Tue Sep 11 19:53:13 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.458 2007/09/11 20:36:18 albertel Exp $
+# $Id: lonxml.pm,v 1.459 2007/09/11 23:53:13 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -909,6 +909,9 @@
}
pop @Apache::lonxml::outputstack;
}
+sub in_redirection {
+ return ($Apache::lonxml::redirection > 0)
+}
sub end_tag {
my ($tagstack,$parstack,$token)=@_;