Commit 37d3d4a8 by Waheed Ahmed

Merge pull request #3451 from edx/waheed/stud1524-accessibility-labels-missing-in-problems

Fixed accessibility labels are not always created in problems.
parents 2d7d3bf2 4f8dbc15
...@@ -538,7 +538,7 @@ describe 'MarkdownEditingDescriptor', -> ...@@ -538,7 +538,7 @@ describe 'MarkdownEditingDescriptor', ->
<p>What is the capital of Germany?</p> <p>What is the capital of Germany?</p>
<multiplechoiceresponse> <multiplechoiceresponse>
<choicegroup type="MultipleChoice"> <choicegroup label="What is the capital of Germany?" type="MultipleChoice">
<choice correct="false">Bonn</choice> <choice correct="false">Bonn</choice>
<choice correct="false">Hamburg</choice> <choice correct="false">Hamburg</choice>
<choice correct="true">Berlin</choice> <choice correct="true">Berlin</choice>
......
...@@ -359,7 +359,7 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor ...@@ -359,7 +359,7 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
// looks for >>arbitrary text<< and inserts it into the label attribute of the input type directly below the text. // looks for >>arbitrary text<< and inserts it into the label attribute of the input type directly below the text.
var split = xml.split('\n'); var split = xml.split('\n');
var new_xml = []; var new_xml = [];
var line, i, curlabel = ''; var line, i, curlabel, prevlabel = '';
var didinput = false; var didinput = false;
for (i = 0; i < split.length; i++) { for (i = 0; i < split.length; i++) {
line = split[i]; line = split[i];
...@@ -370,13 +370,14 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor ...@@ -370,13 +370,14 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
.replace(/"/g, '&quot;') .replace(/"/g, '&quot;')
.replace(/'/g, '&apos;'); .replace(/'/g, '&apos;');
line = line.replace(/>>|<</g, ''); line = line.replace(/>>|<</g, '');
} else if (line.match(/<\w+response/) && didinput) { } else if (line.match(/<\w+response/) && didinput && curlabel == prevlabel) {
// reset label to prevent gobbling up previous one (if multiple questions) // reset label to prevent gobbling up previous one (if multiple questions)
curlabel = ''; curlabel = '';
didinput = false; didinput = false;
} else if (line.match(/<(textline|optioninput|formulaequationinput|choicegroup|checkboxgroup)/) && curlabel != '') { } else if (line.match(/<(textline|optioninput|formulaequationinput|choicegroup|checkboxgroup)/) && curlabel != '' && curlabel != undefined) {
line = line.replace(/<(textline|optioninput|formulaequationinput|choicegroup|checkboxgroup)/, '<$1 label="' + curlabel + '"'); line = line.replace(/<(textline|optioninput|formulaequationinput|choicegroup|checkboxgroup)/, '<$1 label="' + curlabel + '"');
didinput = true; didinput = true;
prevlabel = curlabel;
} }
new_xml.push(line); new_xml.push(line);
} }
......
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