From 3c73666161016088225840eeccf36b184f59b9fd Mon Sep 17 00:00:00 2001 From: farhan <25842457+farhan@users.noreply.github.com> Date: Tue, 24 Nov 2026 15:21:11 +0000 Subject: [PATCH 1/2] feat: Upgrade Python dependency xblocks-core Commit generated by workflow `openedx/openedx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master` --- requirements/edx/base.txt | 2 +- requirements/edx/development.txt | 2 +- uv.lock | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index e948b85fdac5..2ecc2327eb2e 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -1322,7 +1322,7 @@ xblock==6.3.5 xblock-drag-and-drop-v2==5.1.2 xblock-google-drive==0.8.2 xblock-poll==1.16.1 -xblocks-core==3.0.0 +xblocks-core==4.0.0 xmlsec==1.3.14 # via python3-saml xss-utils==1.1.0 diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 3ffe864ea7cc..19bfdb0bfe37 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -1604,7 +1604,7 @@ xblock==6.3.5 xblock-drag-and-drop-v2==5.1.2 xblock-google-drive==0.8.2 xblock-poll==1.16.1 -xblocks-core==3.0.0 +xblocks-core==4.0.0 xmlsec==1.3.14 # via python3-saml xss-utils==1.1.0 diff --git a/uv.lock b/uv.lock index 25575e27c389..55cb7b1c9bd4 100644 --- a/uv.lock +++ b/uv.lock @@ -8248,7 +8248,7 @@ wheels = [ [[package]] name = "xblocks-core" -version = "3.0.0" +version = "4.0.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "beautifulsoup4" }, @@ -8280,9 +8280,9 @@ dependencies = [ { name = "wrapt" }, { name = "xblock" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/5c/6c/ff9e81dd4d0b448eed086f677553fde801ac68e6961bee95852a81e361af/xblocks_core-3.0.0.tar.gz", hash = "sha256:bf0d17ae9b251001c9f1c56e6583f7664707f7e8e7c8576796d7b9b399ec05fc", size = 3967738, upload-time = "2026-11-18T15:53:42.119Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f7/f9/9aebe07dd9d0b716840e9bdaecd5b5c685e1e590f74abd8741f3ee1beb2d/xblocks_core-4.0.0.tar.gz", hash = "sha256:13ca82047b2d48517ea9b36c4407a9a927988f35bd5e445fc276d36327a2e121", size = 3956202, upload-time = "2026-11-24T13:52:48.111Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/21/17/6d1c4d51b930e4d02344633e7cf87300a7e329b7dd0769c41c47aab74f92/xblocks_core-3.0.0-py3-none-any.whl", hash = "sha256:c9b0a8f60084fcb0899d962eb558a6117ffb934c0d97ed61622f7c6ee89b3361", size = 3754524, upload-time = "2026-11-18T15:53:40.55Z" }, + { url = "https://files.pythonhosted.org/packages/b2/2c/2a56a4580db7fede53c52adb3aaf113e33557b2cea73ce31114e1afa09c9/xblocks_core-4.0.0-py3-none-any.whl", hash = "sha256:8a1ac3a128ce7e6ef9af75e69d2c31b05f246cf6efd5b7031faf3086d4eca984", size = 3749437, upload-time = "2026-11-24T13:52:46.47Z" }, ] [[package]] From 96734b686e7ed944e0b7d6db642960d5e6c7e688 Mon Sep 17 00:00:00 2001 From: farhan Date: Wed, 25 Nov 2026 11:33:53 +0500 Subject: [PATCH 2/2] fix: adapt to the xblocks-core 4.0.0 problem block API xblocks-core 4.0.0 changed XQueueInterface to take only the block and removed matlab_api_key from LoncapaSystem and ProblemBlock, so the platform's XQueue service and built-in ProblemBlock raised TypeError. Tests now patch the edx-submissions hand-off instead of the removed XQueue HTTP client and no longer use matlab_api_key. Co-Authored-By: Claude Opus 5.5 --- .../tests/test_downstream_sync_integration.py | 1 - cms/lib/xblock/test/test_upstream_sync.py | 5 --- .../tests/test_submitting_problems.py | 10 +++--- xmodule/capa_block.py | 3 -- xmodule/services.py | 15 +------- xmodule/tests/test_capa_block.py | 36 ++++++------------- xmodule/tests/test_services.py | 7 +--- 7 files changed, 16 insertions(+), 61 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v2/views/tests/test_downstream_sync_integration.py b/cms/djangoapps/contentstore/rest_api/v2/views/tests/test_downstream_sync_integration.py index ffa8b0fa7089..984d9d87c5eb 100644 --- a/cms/djangoapps/contentstore/rest_api/v2/views/tests/test_downstream_sync_integration.py +++ b/cms/djangoapps/contentstore/rest_api/v2/views/tests/test_downstream_sync_integration.py @@ -168,7 +168,6 @@ def assertXmlEqual(self, xml_str_a: str, xml_str_b: str) -> None: # OLX attributes that will appear on capa problems when saved/exported. Excludes "markdown" standard_capa_attributes = """ markdown_edited="false" - matlab_api_key="null" name="null" rerandomize="never" source_code="null" diff --git a/cms/lib/xblock/test/test_upstream_sync.py b/cms/lib/xblock/test/test_upstream_sync.py index d32f2fb5809a..d8af302da9e8 100644 --- a/cms/lib/xblock/test/test_upstream_sync.py +++ b/cms/lib/xblock/test/test_upstream_sync.py @@ -63,7 +63,6 @@ def setUp(self): ' force_save_button="false"' ' graceperiod="1d"' ' grading_method="last_attempt"' - ' matlab_api_key="abc"' ' max_attempts="10"' ' rerandomize=""always""' ' show_correctness="never"' @@ -250,7 +249,6 @@ def test_sync_updates_to_downstream_only_fields(self): assert downstream.upstream_display_name == "Upstream Problem Title V2" assert downstream.display_name == "Upstream Problem Title V2" assert downstream.rerandomize == '"always"' - assert downstream.matlab_api_key == 'abc' assert not downstream.use_latex_compiler # These fields are "downstream only", so field defaults are preserved, and values are NOT copied from upstream @@ -275,7 +273,6 @@ def test_sync_updates_to_downstream_only_fields(self): ' force_save_button="false"' ' graceperiod=""' ' grading_method="final_attempt"' - ' matlab_api_key="def"' ' max_attempts="11"' ' rerandomize=""per_student""' ' show_correctness="past_due"' @@ -304,7 +301,6 @@ def test_sync_updates_to_downstream_only_fields(self): # Modifying synchronized fields are "unsafe" customizations downstream.rerandomize = '"onreset"' - downstream.matlab_api_key = 'hij' save_xblock_with_callback(downstream, self.user) # Follow-up sync. @@ -313,7 +309,6 @@ def test_sync_updates_to_downstream_only_fields(self): # "unsafe" customizations are overridden by upstream assert downstream.upstream_display_name == "Upstream Problem Title V3" assert downstream.rerandomize == '"per_student"' - assert downstream.matlab_api_key == 'def' assert downstream.use_latex_compiler # but "safe" customizations survive diff --git a/lms/djangoapps/courseware/tests/test_submitting_problems.py b/lms/djangoapps/courseware/tests/test_submitting_problems.py index 828c97609c39..7eefa20491a8 100644 --- a/lms/djangoapps/courseware/tests/test_submitting_problems.py +++ b/lms/djangoapps/courseware/tests/test_submitting_problems.py @@ -27,7 +27,7 @@ OptionResponseXMLFactory, SchematicResponseXMLFactory, ) -from xblock_problem.capa.xqueue_interface import XQueueInterface +from xblock_problem.capa.xqueue_submission import XQueueInterfaceSubmission from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.student.models import CourseEnrollment, anonymous_id_for_user @@ -788,7 +788,7 @@ def problem_setup(self, name, files): # re-fetch the course from the database so the object is up to date self.refresh_course() - @patch.object(XQueueInterface, '_http_post') + @patch.object(XQueueInterfaceSubmission, 'send_to_submission') def test_three_files(self, mock_xqueue_post): # Open the test files, and arrange to close them later. filenames = "prog1.py prog2.py prog3.py" @@ -809,10 +809,8 @@ def test_three_files(self, mock_xqueue_post): # See how post got called. assert mock_xqueue_post.call_count == 1 - args, kwargs = mock_xqueue_post.call_args - assert len(args) == 2 - assert args[0].endswith('/submit/') - self.assertEqual(list(kwargs['files'].keys()), filenames.split()) # noqa: PT009 + args, _ = mock_xqueue_post.call_args + self.assertEqual(list(args[3].keys()), filenames.split()) # noqa: PT009 class TestPythonGradedResponse(TestSubmittingProblems): diff --git a/xmodule/capa_block.py b/xmodule/capa_block.py index 770053f04161..d8bad04bc2e5 100644 --- a/xmodule/capa_block.py +++ b/xmodule/capa_block.py @@ -640,7 +640,6 @@ def max_score(self): resources_fs=self.runtime.resources_fs, seed=None, xqueue=None, - matlab_api_key=None, ) try: lcp = LoncapaProblem( @@ -700,7 +699,6 @@ def generate_report_data(self, user_state_iterator, limit_responses=None): resources_fs=self.runtime.resources_fs, seed=1, xqueue=None, - matlab_api_key=None, ) _ = capa_system.i18n.gettext @@ -864,7 +862,6 @@ def new_lcp(self, state, text=None): resources_fs=self.runtime.resources_fs, seed=seed, # Why do we do this if we have self.seed? xqueue=None if is_studio else xqueue_service, - matlab_api_key=self.matlab_api_key, ) return LoncapaProblem( diff --git a/xmodule/services.py b/xmodule/services.py index 068cf2c9f39c..fe0c185fad26 100644 --- a/xmodule/services.py +++ b/xmodule/services.py @@ -13,7 +13,6 @@ from django.urls import reverse from edx_when.field_data import DateLookupFieldData from eventtracking import tracker -from requests.auth import HTTPBasicAuth from xblock.reference.plugins import Service from xblock.runtime import KvsFieldData from xblock_problem.capa.xqueue_interface import XQueueInterface @@ -339,19 +338,7 @@ class XQueueService: def __init__(self, block: "ProblemBlock"): self._block = block - - basic_auth = settings.XQUEUE_INTERFACE.get("basic_auth") - requests_auth = HTTPBasicAuth(*basic_auth) if basic_auth else None - - use_submission = self.use_edx_submissions_for_xqueue() - - self._interface = XQueueInterface( - settings.XQUEUE_INTERFACE["url"], - settings.XQUEUE_INTERFACE["django_auth"], - requests_auth, - block=block, - use_submission_service=use_submission, - ) + self._interface = XQueueInterface(block) @property def interface(self): diff --git a/xmodule/tests/test_capa_block.py b/xmodule/tests/test_capa_block.py index f5a26e800a93..5d5dcd278875 100644 --- a/xmodule/tests/test_capa_block.py +++ b/xmodule/tests/test_capa_block.py @@ -14,7 +14,6 @@ import ddt import pytest -import requests import webob from codejail.safe_exec import SafeExecException from django.test import override_settings @@ -29,7 +28,7 @@ from xblock_problem.capa import responsetypes from xblock_problem.capa.correctmap import CorrectMap from xblock_problem.capa.responsetypes import LoncapaProblemError, ResponseError, StudentInputError -from xblock_problem.capa.xqueue_interface import XQueueInterface +from xblock_problem.capa.xqueue_submission import XQueueInterfaceSubmission from lms.djangoapps.courseware.user_state_client import XBlockUserState from openedx.core.djangolib.testing.utils import skip_unless_lms @@ -266,21 +265,6 @@ def test_showanswer_default(self): problem = CapaFactory.create() assert not problem.answer_available() - @ddt.data( - (requests.exceptions.ReadTimeout, (1, "failed to read from the server")), - (requests.exceptions.ConnectionError, (1, "cannot connect to server")), - ) - @ddt.unpack - def test_xqueue_request_exception(self, exception, result): - """ - Makes sure that platform will raise appropriate exception in case of - connect/read timeout(s) to request to xqueue - """ - xqueue_interface = XQueueInterface("http://example.com/xqueue", Mock()) - with patch.object(xqueue_interface.session, "post", side_effect=exception): - response = xqueue_interface._http_post("http://some/fake/url", {}) # pylint: disable=protected-access - assert response == result - def test_showanswer_attempted(self): """Check answer availability changes after attempting the problem.""" problem = CapaFactory.create(showanswer="attempted") @@ -1238,7 +1222,7 @@ def test_submit_problem_queued(self): assert block.attempts == 1 @pytest.mark.django_db - @patch.object(XQueueInterface, "_http_post") + @patch.object(XQueueInterfaceSubmission, "send_to_submission") def test_submit_problem_with_files(self, mock_xqueue_post): """Verify file-upload submissions are sent correctly to XQueue via submit_problem.""" # Check a problem with uploaded files, using the submit_problem API. @@ -1301,13 +1285,13 @@ def test_submit_problem_with_files(self, mock_xqueue_post): # ) assert mock_xqueue_post.call_count == 1 - _, kwargs = mock_xqueue_post.call_args - self.assertCountEqual(fpaths, list(kwargs["files"].keys())) # noqa: PT009 - for fpath, fileobj in kwargs["files"].items(): + files = mock_xqueue_post.call_args.args[3] + self.assertCountEqual(fpaths, list(files.keys())) # noqa: PT009 + for fpath, fileobj in files.items(): assert fpath == fileobj.name @pytest.mark.django_db - @patch.object(XQueueInterface, "_http_post") + @patch.object(XQueueInterfaceSubmission, "send_to_submission") def test_submit_problem_with_files_as_xblock(self, mock_xqueue_post): """Verify file-upload submissions work correctly via the XBlock handler API.""" # Check a problem with uploaded files, using the XBlock API. @@ -1335,9 +1319,9 @@ def test_submit_problem_with_files_as_xblock(self, mock_xqueue_post): block.handle("xmodule_handler", request, "problem_check") assert mock_xqueue_post.call_count == 1 - _, kwargs = mock_xqueue_post.call_args - self.assertCountEqual(fnames, list(kwargs["files"].keys())) # noqa: PT009 - for fpath, fileobj in kwargs["files"].items(): + files = mock_xqueue_post.call_args.args[3] + self.assertCountEqual(fnames, list(files.keys())) # noqa: PT009 + for fpath, fileobj in files.items(): assert fpath == fileobj.name def test_submit_problem_error(self): @@ -3976,7 +3960,7 @@ def test_rerandomized_inputs(self): } @pytest.mark.django_db - @patch.object(XQueueInterface, "_http_post") + @patch.object(XQueueInterfaceSubmission, "send_to_submission") def test_file_inputs(self, mock_xqueue_post): """Verify tracking data for file submission and custom response inputs.""" fnames = ["prog1.py", "prog2.py", "prog3.py"] diff --git a/xmodule/tests/test_services.py b/xmodule/tests/test_services.py index 4015cbd45b4d..36c02bf7db22 100644 --- a/xmodule/tests/test_services.py +++ b/xmodule/tests/test_services.py @@ -184,13 +184,8 @@ def setUp(self): self.service = XQueueService(self.block) def test_interface(self): - """Test that the `XQUEUE_INTERFACE` settings are passed from the service to the interface.""" + """The service wraps an XQueueInterface for the block.""" assert isinstance(self.service.interface, XQueueInterface) - assert self.service.interface.url == "http://sandbox-xqueue.edx.org" - assert self.service.interface.auth["username"] == "lms" - assert self.service.interface.auth["password"] == "***REMOVED***" - assert self.service.interface.session.auth.username == "anant" - assert self.service.interface.session.auth.password == "agarwal" @patch("xmodule.services.XQueueService.use_edx_submissions_for_xqueue", return_value=True) def test_construct_callback_with_flag_enabled(self, mock_flag): # pylint: disable=unused-argument