From 509f27f02cf4cd748e147af6a8aa75a6acc1e941 Mon Sep 17 00:00:00 2001
From: Adam Palay
Date: Fri, 29 May 2015 18:50:23 -0400
Subject: [PATCH 1/3] Revert "changes for failing label test"
This reverts commit c75526ea5e57b102d4d3b16aa423d16155940b66.
---
common/lib/capa/capa/tests/test_input_templates.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/common/lib/capa/capa/tests/test_input_templates.py b/common/lib/capa/capa/tests/test_input_templates.py
index f51244879e..510a45ba74 100644
--- a/common/lib/capa/capa/tests/test_input_templates.py
+++ b/common/lib/capa/capa/tests/test_input_templates.py
@@ -126,7 +126,7 @@ class ChoiceGroupTemplateTest(TemplateTestCase):
self.context = {'id': '1',
'choices': choices,
'status': Status('correct'),
- 'question_label': 'test',
+ 'question_label': '',
'label': 'test',
'input_type': 'checkbox',
'name_array_suffix': '1',
@@ -343,8 +343,8 @@ class ChoiceGroupTemplateTest(TemplateTestCase):
def test_label(self):
xml = self.render_to_xml(self.context)
- xpath = "//fieldset/legend"
- self.assert_has_text(xml, xpath, self.context['question_label'])
+ xpath = "//fieldset[@aria-label='%s']" % self.context['label']
+ self.assert_has_xpath(xml, xpath, self.context)
class TextlineTemplateTest(TemplateTestCase):
From 0aba5874e6e61f713dbca032ac2a0385de79c2e3 Mon Sep 17 00:00:00 2001
From: Adam Palay
Date: Fri, 29 May 2015 18:50:34 -0400
Subject: [PATCH 2/3] Revert "Fieldset and legend solution is lost when edit
Problem"
This reverts commit 16a248b997d4ca9f4ac6b30d5e69df6f1dd384a2.
---
common/lib/capa/capa/capa_problem.py | 23 +-----------
common/lib/capa/capa/inputtypes.py | 2 --
.../lib/capa/capa/templates/choicegroup.html | 4 +--
.../lib/capa/capa/tests/test_html_render.py | 1 -
.../capa/capa/tests/test_input_templates.py | 36 +++++++++----------
common/lib/capa/capa/tests/test_inputtypes.py | 31 +---------------
.../xmodule/js/spec/problem/edit_spec.coffee | 23 ++++++------
.../xmodule/js/src/problem/edit.coffee | 4 +--
.../problem/checkboxes_response.yaml | 23 ++++++------
.../templates/problem/multiplechoice.yaml | 3 +-
.../templates/problem/numericalresponse.yaml | 5 ++-
.../templates/problem/optionresponse.yaml | 1 -
.../templates/problem/string_response.yaml | 2 +-
13 files changed, 50 insertions(+), 108 deletions(-)
diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py
index 551aa2a68a..48b07bd876 100644
--- a/common/lib/capa/capa/capa_problem.py
+++ b/common/lib/capa/capa/capa_problem.py
@@ -139,7 +139,6 @@ class LoncapaProblem(object):
self.do_reset()
self.problem_id = id
self.capa_system = capa_system
- self.question_label = ""
state = state or {}
@@ -733,7 +732,6 @@ class LoncapaProblem(object):
'status': status,
'id': input_id,
'input_state': self.input_state[input_id],
- 'question_label': self.question_label if self.question_label else None,
'answervariable': answervariable,
'feedback': {
'message': msg,
@@ -764,12 +762,8 @@ class LoncapaProblem(object):
tree = etree.Element(problemtree.tag)
for item in problemtree:
item_xhtml = self._extract_html(item)
- item_sibling = self.sibling_for_item(problemtree, item)
if item_xhtml is not None:
- if item_xhtml.tag == "legend" and item_sibling is not None and item_sibling in self.responders:
- self.question_label = item_xhtml.text
- else:
- tree.append(item_xhtml)
+ tree.append(item_xhtml)
if tree.tag in html_transforms:
tree.tag = html_transforms[problemtree.tag]['tag']
@@ -840,18 +834,3 @@ class LoncapaProblem(object):
for solution in tree.findall('.//solution'):
solution.attrib['id'] = "%s_solution_%i" % (self.problem_id, solution_id)
solution_id += 1
-
- def sibling_for_item(self, tree, node):
- """
- Check if node exist in problem tree and return next sibling if exist
- else return None
- """
- problem_tree = tree.xpath('//problem/*')
- if node in problem_tree:
- node_index = problem_tree.index(node)
- try:
- return problem_tree[node_index + 1]
- except IndexError:
- return None
- else:
- return None
diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py
index 3a4430e45d..9125451352 100644
--- a/common/lib/capa/capa/inputtypes.py
+++ b/common/lib/capa/capa/inputtypes.py
@@ -214,7 +214,6 @@ class InputTypeBase(object):
self.hintmode = feedback.get('hintmode', None)
self.input_state = state.get('input_state', {})
self.answervariable = state.get("answervariable", None)
- self.question_label = state.get("question_label", None)
# put hint above msg if it should be displayed
if self.hintmode == 'always':
@@ -314,7 +313,6 @@ class InputTypeBase(object):
context.update(self._extra_context())
if self.answervariable:
context.update({'answervariable': self.answervariable})
- context.update({'question_label': self.question_label if self.question_label is not None else ""})
return context
def _extra_context(self):
diff --git a/common/lib/capa/capa/templates/choicegroup.html b/common/lib/capa/capa/templates/choicegroup.html
index 880b7f8bf5..814fae6594 100644
--- a/common/lib/capa/capa/templates/choicegroup.html
+++ b/common/lib/capa/capa/templates/choicegroup.html
@@ -17,8 +17,8 @@
% endif
-
You can use the following example problem as a model.
-
-
-
- Urdu
- Finnish
- Marathi
- French
- Hungarian
-
-
+
+
+
+
+ Urdu
+ Finnish
+ Marathi
+ French
+ Hungarian
+
+
+
Note: Make sure you select all of the correct options—there may be more than one!
diff --git a/common/lib/xmodule/xmodule/templates/problem/multiplechoice.yaml b/common/lib/xmodule/xmodule/templates/problem/multiplechoice.yaml
index 72763ad060..2aab5d17f9 100644
--- a/common/lib/xmodule/xmodule/templates/problem/multiplechoice.yaml
+++ b/common/lib/xmodule/xmodule/templates/problem/multiplechoice.yaml
@@ -15,7 +15,6 @@ metadata:
(x) Indonesia
( ) Russia
-
[explanation]
According to September 2014 estimates:
The population of Indonesia is approximately 250 million.
@@ -31,6 +30,7 @@ data: |
When you add the problem, be sure to select Settings
to specify a Display Name and other values that apply.
You can use the following example problem as a model.
+
@@ -40,6 +40,7 @@ data: |
Russia
+
Explanation
diff --git a/common/lib/xmodule/xmodule/templates/problem/numericalresponse.yaml b/common/lib/xmodule/xmodule/templates/problem/numericalresponse.yaml
index 3ed2c2ae8c..8d886d3b30 100644
--- a/common/lib/xmodule/xmodule/templates/problem/numericalresponse.yaml
+++ b/common/lib/xmodule/xmodule/templates/problem/numericalresponse.yaml
@@ -14,12 +14,11 @@ metadata:
>>How many miles away from Earth is the sun? Use scientific notation to answer.<<
= 9.3*10^6
- or= 9.296*10^6
-
+ or= 9.296*10^6
>>The square of what number is -100?<<
- = 10*i
+ = 10*i
[explanation]
The sun is 93,000,000, or 9.3*10^6, miles away from Earth.
diff --git a/common/lib/xmodule/xmodule/templates/problem/optionresponse.yaml b/common/lib/xmodule/xmodule/templates/problem/optionresponse.yaml
index f9f1964a75..25de5fa3fc 100644
--- a/common/lib/xmodule/xmodule/templates/problem/optionresponse.yaml
+++ b/common/lib/xmodule/xmodule/templates/problem/optionresponse.yaml
@@ -14,7 +14,6 @@ metadata:
[[(India), Spain, China, Bermuda]]
-
[explanation]
India became an independent nation on August 15, 1947.
[explanation]
diff --git a/common/lib/xmodule/xmodule/templates/problem/string_response.yaml b/common/lib/xmodule/xmodule/templates/problem/string_response.yaml
index 2913dbca8c..701934f40e 100644
--- a/common/lib/xmodule/xmodule/templates/problem/string_response.yaml
+++ b/common/lib/xmodule/xmodule/templates/problem/string_response.yaml
@@ -14,7 +14,7 @@ metadata:
= Nanjing Higher Normal Institute
or= National Central University
or= Nanjing University
-
+
[explanation]
Nanjing Higher Normal Institute first admitted female students in 1920.
[explanation]
From 683d2b3dbe31ac617b342b32a3c5c3499a224025 Mon Sep 17 00:00:00 2001
From: Adam Palay
Date: Fri, 29 May 2015 19:50:00 -0400
Subject: [PATCH 3/3] fix quality violation
---
common/lib/capa/capa/tests/test_inputtypes.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py
index b1f42b659e..6946bbed97 100644
--- a/common/lib/capa/capa/tests/test_inputtypes.py
+++ b/common/lib/capa/capa/tests/test_inputtypes.py
@@ -648,7 +648,17 @@ class MatlabTest(unittest.TestCase):
output = self.the_input.get_html()
self.assertEqual(
etree.tostring(output),
- """
{\'status\': Status(\'queued\'), \'button_enabled\': True, \'rows\': \'10\', \'queue_len\': \'3\', \'mode\': \'\', \'cols\': \'80\', \'STATIC_URL\': \'/dummy-static/\', \'linenumbers\': \'true\', \'queue_msg\': \'\', \'value\': \'print "good evening"\', \'msg\': u\'Submitted. As soon as a response is returned, this message will be replaced by that feedback.\', \'matlab_editor_js\': \'/dummy-static/js/vendor/CodeMirror/octave.js\', \'hidden\': \'\', \'id\': \'prob_1_2\', \'tabsize\': 4}
"""
+ textwrap.dedent("""
+
{\'status\': Status(\'queued\'), \'button_enabled\': True,
+ \'rows\': \'10\', \'queue_len\': \'3\', \'mode\': \'\',
+ \'cols\': \'80\', \'STATIC_URL\': \'/dummy-static/\',
+ \'linenumbers\': \'true\', \'queue_msg\': \'\',
+ \'value\': \'print "good evening"\',
+ \'msg\': u\'Submitted. As soon as a response is returned,
+ this message will be replaced by that feedback.\',
+ \'matlab_editor_js\': \'/dummy-static/js/vendor/CodeMirror/octave.js\',
+ \'hidden\': \'\', \'id\': \'prob_1_2\', \'tabsize\': 4}
+ """).replace('\n', ' ').strip()
)
# test html, that is correct HTML5 html, but is not parsable by XML parser.