From 3432441fd90d759fe127ebe58b983fc15cd91e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 1 Mar 2024 10:32:25 -0300 Subject: [PATCH 1/4] Revert "feat: deserialize tag info from xml [FC-0049] (#2181)" This reverts commit 5329fea43b917a44c393afe5297494828b5d259f. --- openassessment/__init__.py | 2 +- openassessment/xblock/openassessmentblock.py | 11 +-- .../xblock/test/data/content_tags.xml | 93 ------------------- .../xblock/test/test_openassessment.py | 33 +------ 4 files changed, 3 insertions(+), 136 deletions(-) delete mode 100644 openassessment/xblock/test/data/content_tags.xml diff --git a/openassessment/__init__.py b/openassessment/__init__.py index 9f6b97a4d1..23ecb7c46a 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.2.0' +__version__ = '6.1.0' diff --git a/openassessment/xblock/openassessmentblock.py b/openassessment/xblock/openassessmentblock.py index 14dc24a52e..f59bda2bbb 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, @@ -937,12 +934,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 c4e3c52752..be43839ec9 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, @@ -757,12 +733,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. """ @@ -1190,8 +1160,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 def setup_dates(self, xblock, course_dates=None, subsection_dates=None): """ From 6d04ee3be03278bc19cb23a572eab677bb7ed7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 1 Mar 2024 10:35:58 -0300 Subject: [PATCH 2/4] Revert "feat: Serialize tag data in OpenAssessmentBlocks (#2171)" --- openassessment/__init__.py | 2 +- openassessment/xblock/test/test_xml.py | 34 -------------------------- openassessment/xblock/utils/xml.py | 5 ---- package-lock.json | 4 +-- package.json | 2 +- 5 files changed, 4 insertions(+), 43 deletions(-) diff --git a/openassessment/__init__.py b/openassessment/__init__.py index 23ecb7c46a..668f267fc3 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.1.0' +__version__ = '6.3.0' 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 0752ab483c..988c9bb401 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "edx-ora2", - "version": "6.0.34", + "version": "6.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "edx-ora2", - "version": "6.0.33", + "version": "6.3.0", "dependencies": { "@edx/frontend-build": "8.0.6", "@openedx/paragon": "^21.5.7", diff --git a/package.json b/package.json index 42dff5557b..3af2ec5e15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.1.0", + "version": "6.3.0", "repository": "https://github.com/openedx/edx-ora2.git", "dependencies": { "@edx/frontend-build": "8.0.6", From 70231e0b2bfb5841ff392e682080e5d79a88831b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Fri, 1 Mar 2024 15:57:28 -0300 Subject: [PATCH 3/4] test: improve coverage --- openassessment/xblock/test/test_openassessment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openassessment/xblock/test/test_openassessment.py b/openassessment/xblock/test/test_openassessment.py index be43839ec9..a9f44d1fc7 100644 --- a/openassessment/xblock/test/test_openassessment.py +++ b/openassessment/xblock/test/test_openassessment.py @@ -1160,7 +1160,7 @@ def defined_manual_dates(self, xblock, step): dt.datetime.fromisoformat(assessment.get('start')), dt.datetime.fromisoformat(assessment.get('due')) ) - return None + return None # pragma: no cover def setup_dates(self, xblock, course_dates=None, subsection_dates=None): """ From 8dffff17625754d1b2152fa680105c7bd23f0e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Wed, 6 Mar 2024 10:28:15 -0300 Subject: [PATCH 4/4] chore: bump version to 6.4.0 --- openassessment/__init__.py | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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/package-lock.json b/package-lock.json index 988c9bb401..934890c552 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "edx-ora2", - "version": "6.3.0", + "version": "6.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "edx-ora2", - "version": "6.3.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",