[LON-CAPA-cvs] cvs: loncom /homework/cleanxml xml_to_loncapa.pm
damieng
damieng at source.lon-capa.org
Wed Jan 20 16:24:23 EST 2016
damieng Wed Jan 20 21:24:23 2016 EDT
Modified files:
/loncom/homework/cleanxml xml_to_loncapa.pm
Log:
add startouttext and endouttext inside empty hintgroup; put translated and lang within startouttext/endouttext
Index: loncom/homework/cleanxml/xml_to_loncapa.pm
diff -u loncom/homework/cleanxml/xml_to_loncapa.pm:1.7 loncom/homework/cleanxml/xml_to_loncapa.pm:1.8
--- loncom/homework/cleanxml/xml_to_loncapa.pm:1.7 Wed Jan 20 00:41:31 2016
+++ loncom/homework/cleanxml/xml_to_loncapa.pm Wed Jan 20 21:24:22 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network
# convert_file takes a well-formed XML file content and converts it to LON-CAPA syntax.
#
-# $Id: xml_to_loncapa.pm,v 1.7 2016/01/20 00:41:31 damieng Exp $
+# $Id: xml_to_loncapa.pm,v 1.8 2016/01/20 21:24:22 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,9 +38,11 @@
use XML::LibXML;
-my @loncapa_block = ('parameter','location','answer','foil','image','polygon','rectangle','text','conceptgroup','itemgroup','item','label','data','function','array','unit','answergroup','functionplotresponse','functionplotruleset','functionplotelements','functionplotcustomrule','essayresponse','hintpart','formulahint','numericalhint','reactionhint','organichint','optionhint','radiobuttonhint','stringhint','customhint','mathhint','formulahintcondition','numericalhintcondition','reactionhintcondition','organichintcondition','optionhintcondition','radiobuttonhintcondition','stringhintcondition','customhintcondition','mathhintcondition','imageresponse','foilgroup','datasubmission','textfield','hiddensubmission','radiobuttonresponse','rankresponse','matchresponse','import','style','script','window','block','library','notsolved','part','postanswerdate','preduedate','problem','problemtype','randomlabel','bgimg','labelgroup','randomlist','solved','while','tex','print','web','gnuplo!
t','curve','Task','IntroParagraph','ClosingParagraph','Question','QuestionText','Setup','Instance','InstanceText','Criteria','CriteriaText','GraderNote','languageblock','translated','lang','instructorcomment','dataresponse','togglebox','standalone','comment','drawimage','allow','displayduedate','displaytitle','responseparam','organicstructure','scriptlib','parserlib','drawoptionlist','spline','backgroundplot','plotobject','plotvector','drawvectorsum','functionplotrule','functionplotvectorrule','functionplotvectorsumrule','axis','key','xtics','ytics','title','xlabel','ylabel','hiddenline','dtm','stringresponse','optionresponse','numericalresponse','formularesponse','mathresponse','organicresponse','reactionresponse','customresponse','externalresponse', 'hint', 'hintgroup');
+# LON-CAPA block elements that cannot be found within startouttext/endouttext
+my @loncapa_block = ('parameter','location','answer','foil','image','polygon','rectangle','text','conceptgroup','itemgroup','item','label','data','function','array','unit','answergroup','functionplotresponse','functionplotruleset','functionplotelements','functionplotcustomrule','essayresponse','hintpart','formulahint','numericalhint','reactionhint','organichint','optionhint','radiobuttonhint','stringhint','customhint','mathhint','formulahintcondition','numericalhintcondition','reactionhintcondition','organichintcondition','optionhintcondition','radiobuttonhintcondition','stringhintcondition','customhintcondition','mathhintcondition','imageresponse','foilgroup','datasubmission','textfield','hiddensubmission','radiobuttonresponse','rankresponse','matchresponse','import','style','script','window','block','library','notsolved','part','postanswerdate','preduedate','problem','problemtype','randomlabel','bgimg','labelgroup','randomlist','solved','while','tex','print','web','gnuplo!
t','curve','Task','IntroParagraph','ClosingParagraph','Question','QuestionText','Setup','Instance','InstanceText','Criteria','CriteriaText','GraderNote','languageblock','instructorcomment','dataresponse','togglebox','standalone','comment','drawimage','allow','displayduedate','displaytitle','responseparam','organicstructure','scriptlib','parserlib','drawoptionlist','spline','backgroundplot','plotobject','plotvector','drawvectorsum','functionplotrule','functionplotvectorrule','functionplotvectorsumrule','axis','key','xtics','ytics','title','xlabel','ylabel','hiddenline','dtm','stringresponse','optionresponse','numericalresponse','formularesponse','mathresponse','organicresponse','reactionresponse','customresponse','externalresponse', 'hint', 'hintgroup');
-my @loncapa_inline = ('display','m','lm','chem','num','parse','algebra','displayweight','displaystudentphoto'); # not textline
+# LON-CAPA elements that can be found within startouttext/endouttext:
+my @loncapa_in_text = ('display','m','lm','chem','num','parse','algebra','displayweight','displaystudentphoto','translated','lang'); # not textline
# HTML elements that trigger the addition of startouttext/endouttext
my @html_trigger = ('header','footer','aside','h1','h2','h3','h4','h5','h6','li','dd','dt','tbody','tr','caption','thead','tfoot','td','th','span','a','em','strong','b','i','sup','sub','pre','code','kbd','samp','cite','q','tt','ins','del','var','small','big','br','hr','address','blockquote','img','figure','figcaption','object','param','embed','applet','video','source','audio','map','area','canvas','form','input','select','optgroup','option','textarea','fieldset','legend','button','iframe','section','div','p','ul','ol','dl','table');
@@ -145,6 +147,11 @@
return;
}
convert_paragraphs($node);
+ if ($node->nodeName eq 'hintgroup' && !defined $node->firstChild) {
+ # empty hintgroup: colorful editor needs start/end outtext
+ add_endouttext($node, undef);
+ add_startouttext($node, $node->firstChild);
+ }
my $next;
my $in_outtext = 0;
for (my $child=$node->firstChild; defined $child; $child=$next) {
@@ -178,7 +185,7 @@
return 1;
}
}
- if ($node->nodeType == XML_ELEMENT_NODE && string_in_array(\@loncapa_inline, $node->nodeName)) {
+ if ($node->nodeType == XML_ELEMENT_NODE && string_in_array(\@loncapa_in_text, $node->nodeName)) {
return 1;
}
return 0;
More information about the LON-CAPA-cvs
mailing list