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() {
var xml = val;
// replace headers
xml = xml.replace(/(^.*)\n(?=\=\=+)/g, '<h1>$1</h1>');
xml = xml.replace(/\=\=+/g, '');
xml = xml.replace(/(^.*?$)(?=\n\=\=+$)/gm, '<h1>$1</h1>');
xml = xml.replace(/\n^\=\=+$/gm, '');
// 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';
groupString += ' <choicegroup type="MultipleChoice">\n';
var options = match.split('\n');
for(var i = 0; i < options.length; i++) {
if(options[i].length > 0) {
var value = options[i].split(/\)\s*/)[1];
var correct = /\(x\)/i.test(options[i]);
var value = options[i].split(/^\s*\(.?\)\s*/)[1];
var correct = /^\s*\(x\)/i.test(options[i]);
groupString += ' <choice correct="' + correct + '">' + value + '</choice>\n';
}
}
......@@ -117,14 +117,14 @@ function updateXML() {
});
// group check answers
xml = xml.replace(/(\[.?\].*\n*)+/g, function(match, p) {
xml = xml.replace(/(^\s*\[.?\].*?$\n*)+/gm, function(match, p) {
var groupString = '<multiplechoiceresponse>\n';
groupString += ' <choicegroup type="MultipleChoiceChecks">\n';
var options = match.split('\n');
for(var i = 0; i < options.length; i++) {
if(options[i].length > 0) {
var value = options[i].split(/\]\s*/)[1];
var correct = /\[x\]/i.test(options[i]);
var value = options[i].split(/^\s*\[.?\]\s*/)[1];
var correct = /^\s*\[x\]/i.test(options[i]);
groupString += ' <choice correct="' + correct + '">' + value + '</choice>\n';
}
}
......@@ -134,12 +134,12 @@ function updateXML() {
});
// 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
xml = xml.replace(/(?:\n|^)\=\s*(.*)/g, function(match, p) {
xml = xml.replace(/^\=\s*(.*?$)/gm, function(match, p) {
var string;
var params = /(.*)\+\-\s*(.*)/.exec(p);
var params = /(.*?)\+\-\s*(.*?)/.exec(p);
if(parseFloat(p)) {
if(params) {
string = '<numericalresponse answer="' + params[1] + '">\n';
......@@ -156,22 +156,23 @@ function updateXML() {
});
// replace selects
xml = xml.replace(/\[\[(.+)\]\]/g, function(match, p) {
xml = xml.replace(/\[\[(.+?)\]\]/g, function(match, p) {
var selectString = '\n<optionresponse>\n';
selectString += ' <optioninput options="(';
var options = p.split(/\,\s*/g);
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 += p.split(/\(/)[1].split(/\)/)[0];
var correct = /\((.*?)\)/g.exec(p);
if (correct) selectString += correct[1];
selectString += '"></optioninput>\n';
selectString += '</optionresponse>\n\n';
return selectString;
});
// split scripts and wrap paragraphs
var splits = xml.split(/(\<\/?script.*\>)/g);
var splits = xml.split(/(\<\/?script.*?\>)/g);
var scriptFlag = false;
for(var i = 0; i < splits.length; i++) {
if(/\<script/.test(splits[i])) {
......
......@@ -10,11 +10,14 @@ metadata:
The answer is correct if it is within a specified numerical tolerance
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: |
<problem>
......
......@@ -3,6 +3,26 @@ metadata:
display_name: Option Response
rerandomize: never
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: |
<problem>
<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