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 -
- ${question_label} +
+ % for choice_id, choice_description in choices: