From 8de0eaf76a5359e13987c3d7007f2a275a5a993f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Wed, 6 Mar 2024 21:28:40 -0300 Subject: [PATCH] revert: rollback changes from #2171 and #2181 (#2184) * Revert "feat: deserialize tag info from xml [FC-0049] (#2181)" This reverts commit 5329fea43b917a44c393afe5297494828b5d259f. * Revert "feat: Serialize tag data in OpenAssessmentBlocks (#2171)" * test: improve coverage * chore: bump version to 6.4.0 --- openassessment/__init__.py | 2 +- openassessment/xblock/openassessmentblock.py | 11 +-- .../xblock/test/data/content_tags.xml | 93 ------------------- .../xblock/test/test_openassessment.py | 33 +------ openassessment/xblock/test/test_xml.py | 34 ------- openassessment/xblock/utils/xml.py | 5 - package-lock.json | 4 +- package.json | 2 +- 8 files changed, 6 insertions(+), 178 deletions(-) delete mode 100644 openassessment/xblock/test/data/content_tags.xml diff --git a/openassessment/__init__.py b/openassessment/__init__.py index 668f267fc3..4bb84382bc 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.3.0' +__version__ = '6.4.0' diff --git a/openassessment/xblock/openassessmentblock.py b/openassessment/xblock/openassessmentblock.py index 2f2f3d4977..0d4d33b730 100644 --- a/openassessment/xblock/openassessmentblock.py +++ b/openassessment/xblock/openassessmentblock.py @@ -18,7 +18,7 @@ from webob import Response from xblock.core import XBlock from xblock.exceptions import NoSuchServiceError -from xblock.fields import Boolean, Dict, Integer, List, Scope, String +from xblock.fields import Boolean, Integer, List, Scope, String from openassessment.staffgrader.staff_grader_mixin import StaffGraderMixin from openassessment.workflow.errors import AssessmentWorkflowError @@ -283,9 +283,6 @@ class OpenAssessmentBlock( help="A title to display to a student (plain text)." ) - xml_attributes = Dict(help="Map of unhandled xml attributes, used only for storage between import and export", - default={}, scope=Scope.settings) - white_listed_file_types = List( default=[], scope=Scope.content, @@ -938,12 +935,6 @@ def parse_xml(cls, node, runtime, keys, id_generator): block.text_response_editor = config['text_response_editor'] block.title = config['title'] block.white_listed_file_types_string = config['white_listed_file_types'] - - # Deserialize and add tag data info to block if any - if hasattr(block, 'read_tags_from_node') and callable(block.read_tags_from_node): # pylint: disable=no-member - # This comes from TaggedBlockMixin - block.read_tags_from_node(node) # pylint: disable=no-member - return block @property diff --git a/openassessment/xblock/test/data/content_tags.xml b/openassessment/xblock/test/data/content_tags.xml deleted file mode 100644 index 3a1d9aaf44..0000000000 --- a/openassessment/xblock/test/data/content_tags.xml +++ /dev/null @@ -1,93 +0,0 @@ - - Open Assessment Test - - - Given the state of the world today, what do you think should be done to combat poverty? Please answer in a short essay of 200-300 words. - - - Given the state of the world today, what do you think should be done to combat pollution? - - - - - Concise - How concise is it? - - - - - - - - Clear-headed - How clear is the thinking? - - - - - - - - Form - Lastly, how is its form? Punctuation, grammar, and spelling all count. - - - - - - - - - - - - - diff --git a/openassessment/xblock/test/test_openassessment.py b/openassessment/xblock/test/test_openassessment.py index 565ddf0a94..dcaf544a82 100644 --- a/openassessment/xblock/test/test_openassessment.py +++ b/openassessment/xblock/test/test_openassessment.py @@ -8,7 +8,6 @@ from unittest import mock from unittest.mock import MagicMock, Mock, PropertyMock, patch from django.test.utils import override_settings -from workbench.runtime import WorkbenchRuntime import ddt import pytz @@ -25,29 +24,6 @@ from .base import XBlockHandlerTestCase, scenario -original_construct_xblock_from_class = WorkbenchRuntime.construct_xblock_from_class - - -def _read_tags_from_node(self, node): - """ - This method is originally defined in the XmlMixin in edx-platform. - """ - assert 'tags-v1' in node.attrib - self.xml_attributes['tags-v1'] = str(node.attrib['tags-v1']) - - -def _construct_xblock_from_class(*args, **kwargs): - """ - Mock the original construct_xblock_from_class method to add the read_tags_from_node method and xml_attributes - property to the xblock. - - In edx-platform, these members are part of the XmlMixin. - """ - xblock = original_construct_xblock_from_class(*args, **kwargs) - xblock.read_tags_from_node = lambda node: _read_tags_from_node(xblock, node) - return xblock - - def assert_is_closed( xblock, now, @@ -782,12 +758,6 @@ def test_mfe_views_supported__rearranged_steps(self, xblock): # Given this ORA has rearranged our assessment steps self.assertTrue(xblock.mfe_views_supported) - @patch.object(WorkbenchRuntime, 'construct_xblock_from_class', new=_construct_xblock_from_class) - @scenario('data/content_tags.xml') - def test_content_tags(self, xblock): - # Check if content tags are set properly - self.assertEqual(xblock.xml_attributes["tags-v1"], "test content tags") - class TestDates(XBlockHandlerTestCase): """ Test Assessment Dates. """ @@ -1215,8 +1185,7 @@ def defined_manual_dates(self, xblock, step): dt.datetime.fromisoformat(assessment.get('start')), dt.datetime.fromisoformat(assessment.get('due')) ) - - assert False, f"Assessment {step} not found" # pragma: no cover + return None # pragma: no cover def setup_dates(self, xblock, course_dates=None, subsection_dates=None): """ diff --git a/openassessment/xblock/test/test_xml.py b/openassessment/xblock/test/test_xml.py index 0013b6bbf8..1d258e273f 100644 --- a/openassessment/xblock/test/test_xml.py +++ b/openassessment/xblock/test/test_xml.py @@ -216,40 +216,6 @@ def test_serialize_assessments(self, data): xml_str = serialize_assessments_to_xml_str(self.oa_block) self.assertIn(data['assessments'][0]['name'], xml_str) - @ddt.file_data('data/serialize.json') - def test_serialize_with_tags(self, data): - self._configure_xblock(data) - - # Create a mocked serialize tag data method that returns no data - def add_tags_to_node_no_tags(node): # pylint: disable=unused-argument - return - - # Manually add the mocked method to the OpenAssessment block instance - # This method will be added in the edx-platform repo through applying XBLOCK_MIXINS - self.oa_block.add_tags_to_node = add_tags_to_node_no_tags - - xml = serialize_content(self.oa_block) - - # Confirm that no tags appear in the xml - self.assertNotIn("tags-v1", xml) - - # Create a mocked serialize tag data method that returns data - def add_tags_to_node_with_tags(node): - # return "lightcast-skills:Typing,Microsoft Office" - node.set('tags-v1', 'lightcast-skills:Typing,Microsoft Office') - - # Manually add the mocked method to the OpenAssessment block instance - # This method will be added in the edx-platform repo through applying XBLOCK_MIXINS - self.oa_block.add_tags_to_node = add_tags_to_node_with_tags - - xml = serialize_content(self.oa_block) - - # Confirm that tags appear in the xml - self.assertIn("tags-v1=\"lightcast-skills:Typing,Microsoft Office\"", xml) - - # Clear the mocked serialize tag data method - del self.oa_block.add_tags_to_node - def test_mutated_criteria_dict(self): self._configure_xblock({}) diff --git a/openassessment/xblock/utils/xml.py b/openassessment/xblock/utils/xml.py index 7c3dbef788..dea0279b41 100644 --- a/openassessment/xblock/utils/xml.py +++ b/openassessment/xblock/utils/xml.py @@ -772,11 +772,6 @@ def serialize_content_to_xml(oa_block, root): if oa_block.show_rubric_during_response is not None: root.set('show_rubric_during_response', str(oa_block.show_rubric_during_response)) - # Serialize and add tag data if any - if hasattr(oa_block, 'add_tags_to_node') and callable(oa_block.add_tags_to_node): # pylint: disable=no-member - # This comes from TaggedBlockMixin - oa_block.add_tags_to_node(root) # pylint: disable=no-member - def serialize_content(oa_block): """ diff --git a/package-lock.json b/package-lock.json index 7e2baafffd..934890c552 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "edx-ora2", - "version": "6.2.0", + "version": "6.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "edx-ora2", - "version": "6.2.0", + "version": "6.4.0", "dependencies": { "@edx/frontend-build": "8.0.6", "@openedx/paragon": "^21.5.7", diff --git a/package.json b/package.json index 3af2ec5e15..1d36602f37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.3.0", + "version": "6.4.0", "repository": "https://github.com/openedx/edx-ora2.git", "dependencies": { "@edx/frontend-build": "8.0.6",