Commit 2e527a6a by Don Mitchell

Fixed all regex's in toXml (I hope) and added 2 markdown templates

parent ecfc96c7
...@@ -96,18 +96,18 @@ function updateXML() { ...@@ -96,18 +96,18 @@ function updateXML() {
var xml = val; var xml = val;
// replace headers // replace headers
xml = xml.replace(/(^.*)\n(?=\=\=+)/g, '<h1>$1</h1>'); xml = xml.replace(/(^.*?$)(?=\n\=\=+$)/gm, '<h1>$1</h1>');
xml = xml.replace(/\=\=+/g, ''); xml = xml.replace(/\n^\=\=+$/gm, '');
// group multiple choice answers // group multiple choice answers
xml = xml.replace(/(\(.?\).*\n*)+/g, function(match, p) { xml = xml.replace(/(^\s*\(.?\).*?$\n*)+/gm, function(match, p) {
var groupString = '<multiplechoiceresponse>\n'; var groupString = '<multiplechoiceresponse>\n';
groupString += ' <choicegroup type="MultipleChoice">\n'; groupString += ' <choicegroup type="MultipleChoice">\n';
var options = match.split('\n'); var options = match.split('\n');
for(var i = 0; i < options.length; i++) { for(var i = 0; i < options.length; i++) {
if(options[i].length > 0) { if(options[i].length > 0) {
var value = options[i].split(/\)\s*/)[1]; var value = options[i].split(/^\s*\(.?\)\s*/)[1];
var correct = /\(x\)/i.test(options[i]); var correct = /^\s*\(x\)/i.test(options[i]);
groupString += ' <choice correct="' + correct + '">' + value + '</choice>\n'; groupString += ' <choice correct="' + correct + '">' + value + '</choice>\n';
} }
} }
...@@ -117,14 +117,14 @@ function updateXML() { ...@@ -117,14 +117,14 @@ function updateXML() {
}); });
// group check answers // group check answers
xml = xml.replace(/(\[.?\].*\n*)+/g, function(match, p) { xml = xml.replace(/(^\s*\[.?\].*?$\n*)+/gm, function(match, p) {
var groupString = '<multiplechoiceresponse>\n'; var groupString = '<multiplechoiceresponse>\n';
groupString += ' <choicegroup type="MultipleChoiceChecks">\n'; groupString += ' <choicegroup type="MultipleChoiceChecks">\n';
var options = match.split('\n'); var options = match.split('\n');
for(var i = 0; i < options.length; i++) { for(var i = 0; i < options.length; i++) {
if(options[i].length > 0) { if(options[i].length > 0) {
var value = options[i].split(/\]\s*/)[1]; var value = options[i].split(/^\s*\[.?\]\s*/)[1];
var correct = /\[x\]/i.test(options[i]); var correct = /^\s*\[x\]/i.test(options[i]);
groupString += ' <choice correct="' + correct + '">' + value + '</choice>\n'; groupString += ' <choice correct="' + correct + '">' + value + '</choice>\n';
} }
} }
...@@ -134,12 +134,12 @@ function updateXML() { ...@@ -134,12 +134,12 @@ function updateXML() {
}); });
// replace videos // replace videos
xml = xml.replace(/\{\{video\s(.*)\}\}/g, '<video youtube="1.0:$1" />\n\n'); xml = xml.replace(/\{\{video\s(.*?)\}\}/g, '<video youtube="1.0:$1" />\n\n');
// replace string and numerical // replace string and numerical
xml = xml.replace(/(?:\n|^)\=\s*(.*)/g, function(match, p) { xml = xml.replace(/^\=\s*(.*?$)/gm, function(match, p) {
var string; var string;
var params = /(.*)\+\-\s*(.*)/.exec(p); var params = /(.*?)\+\-\s*(.*?)/.exec(p);
if(parseFloat(p)) { if(parseFloat(p)) {
if(params) { if(params) {
string = '<numericalresponse answer="' + params[1] + '">\n'; string = '<numericalresponse answer="' + params[1] + '">\n';
...@@ -156,22 +156,23 @@ function updateXML() { ...@@ -156,22 +156,23 @@ function updateXML() {
}); });
// replace selects // replace selects
xml = xml.replace(/\[\[(.+)\]\]/g, function(match, p) { xml = xml.replace(/\[\[(.+?)\]\]/g, function(match, p) {
var selectString = '\n<optionresponse>\n'; var selectString = '\n<optionresponse>\n';
selectString += ' <optioninput options="('; selectString += ' <optioninput options="(';
var options = p.split(/\,\s*/g); var options = p.split(/\,\s*/g);
for(var i = 0; i < options.length; i++) { for(var i = 0; i < options.length; i++) {
selectString += "'" + options[i].replace(/\((.*)\)/g, '$1') + "'" + (i < options.length -1 ? ',' : ''); selectString += "'" + options[i].replace(/\((.*?)\)/g, '$1') + "'" + (i < options.length -1 ? ',' : '');
} }
selectString += ')" correct="'; selectString += ')" correct="';
selectString += p.split(/\(/)[1].split(/\)/)[0]; var correct = /\((.*?)\)/g.exec(p);
if (correct) selectString += correct[1];
selectString += '"></optioninput>\n'; selectString += '"></optioninput>\n';
selectString += '</optionresponse>\n\n'; selectString += '</optionresponse>\n\n';
return selectString; return selectString;
}); });
// split scripts and wrap paragraphs // split scripts and wrap paragraphs
var splits = xml.split(/(\<\/?script.*\>)/g); var splits = xml.split(/(\<\/?script.*?\>)/g);
var scriptFlag = false; var scriptFlag = false;
for(var i = 0; i < splits.length; i++) { for(var i = 0; i < splits.length; i++) {
if(/\<script/.test(splits[i])) { if(/\<script/.test(splits[i])) {
......
...@@ -10,11 +10,14 @@ metadata: ...@@ -10,11 +10,14 @@ metadata:
The answer is correct if it is within a specified numerical tolerance The answer is correct if it is within a specified numerical tolerance
of the expected answer. of the expected answer.
Enter the numerical value of Pi: = 3.14159 +- .02 Enter the numerical value of Pi:
= 3.14159 +- .02
Enter the approximate value of 502*9: = 4518 +- 15% Enter the approximate value of 502*9:
= 4518 +- 15%
Enter the number of fingers on a human hand: = 5 +- 0 Enter the number of fingers on a human hand:
= 5
" "
data: | data: |
<problem> <problem>
......
...@@ -3,6 +3,26 @@ metadata: ...@@ -3,6 +3,26 @@ metadata:
display_name: Option Response display_name: Option Response
rerandomize: never rerandomize: never
showanswer: always showanswer: always
markdown: "
<p>OptionResponse gives a limited set of options for students to respond with, and presents those options
in a format that encourages them to search for a specific answer rather than being immediately presented with options from which to recognize the correct answer.</p>
<p>
The answer options and the identification of the correct answer is defined in the <b>optioninput</b> tag.
</p>
<p>Translation between Option Response and __________ is extremely straightforward:
<optionresponse>
<optioninput options="('Multiple Choice','String Response','Numerical Response','External Response','Image Response')" correct="Multiple Choice"></optioninput>
</optionresponse>
</p>
<solution>
<div class="detailed-solution">
<p>Explanation</p>
<p>Multiple Choice also allows students to select from a variety of pre-written responses, although the format makes it easier for students to read very long response options. Optionresponse also differs slightly because students are more likely to think of an answer and then search for it rather than relying purely on recognition to answer the question.</p>
</div>
</solution>
"
data: | data: |
<problem> <problem>
<p>OptionResponse gives a limited set of options for students to respond with, and presents those options <p>OptionResponse gives a limited set of options for students to respond with, and presents those options
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment