Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions cms/lib/xblock/test/test_upstream_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down Expand Up @@ -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
Expand All @@ -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"'
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
10 changes: 4 additions & 6 deletions lms/djangoapps/courseware/tests/test_submitting_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions xmodule/capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
15 changes: 1 addition & 14 deletions xmodule/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
36 changes: 10 additions & 26 deletions xmodule/tests/test_capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import ddt
import pytest
import requests
import webob
from codejail.safe_exec import SafeExecException
from django.test import override_settings
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]
Expand Down
7 changes: 1 addition & 6 deletions xmodule/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down