Skip to content
Draft
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
7 changes: 6 additions & 1 deletion lms/djangoapps/courseware/tests/test_submitting_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
SchematicResponseXMLFactory
)
from xmodule.capa.tests.test_util import use_unsafe_codejail
from xmodule.capa.xqueue_interface import XQueueInterface
from common.djangoapps.course_modes.models import CourseMode
from lms.djangoapps.courseware.models import BaseStudentModuleHistory, StudentModule
from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase
Expand All @@ -44,6 +43,12 @@
from xmodule.partitions.partitions import Group, UserPartition # lint-amnesty, pylint: disable=wrong-import-order


if settings.USE_EXTRACTED_PROBLEM_BLOCK:
from xblocks_contrib.problem.capa.xqueue_interface import XQueueInterface
else:
from xmodule.capa.xqueue_interface import XQueueInterface


class ProblemSubmissionTestMixin(TestCase):
"""
TestCase mixin that provides functions to submit answers to problems.
Expand Down
7 changes: 5 additions & 2 deletions lms/djangoapps/instructor_task/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.test.utils import override_settings
from django.urls import reverse
from django.conf import settings

from xmodule.capa.responsetypes import StudentInputError
from xmodule.capa.tests.response_xml_factory import CodeResponseXMLFactory, CustomResponseXMLFactory
Expand All @@ -45,6 +46,8 @@
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import BlockFactory # lint-amnesty, pylint: disable=wrong-import-order

PREFIX_CAPA = "xblocks_contrib.problem" if settings.USE_EXTRACTED_PROBLEM_BLOCK else "xmodule"

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -275,7 +278,7 @@ def test_rescoring_failure(self):
self.submit_student_answer('u1', problem_url_name, [OPTION_1, OPTION_1])

expected_message = "bad things happened"
with patch('xmodule.capa.capa_problem.LoncapaProblem.get_grade_from_current_answers') as mock_rescore:
with patch(f'{PREFIX_CAPA}.capa.capa_problem.LoncapaProblem.get_grade_from_current_answers') as mock_rescore:
mock_rescore.side_effect = ZeroDivisionError(expected_message)
instructor_task = self.submit_rescore_all_student_answers('instructor', problem_url_name)
self._assert_task_failure(
Expand All @@ -295,7 +298,7 @@ def test_rescoring_bad_unicode_input(self):

# return an input error as if it were a numerical response, with an embedded unicode character:
expected_message = "Could not interpret '2/3\u03a9' as a number"
with patch('xmodule.capa.capa_problem.LoncapaProblem.get_grade_from_current_answers') as mock_rescore:
with patch(f'{PREFIX_CAPA}.capa.capa_problem.LoncapaProblem.get_grade_from_current_answers') as mock_rescore:
mock_rescore.side_effect = StudentInputError(expected_message)
instructor_task = self.submit_rescore_all_student_answers('instructor', problem_url_name)

Expand Down
6 changes: 5 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@
# Import after sys.path fixup
from xmodule.modulestore.edit_info import EditInfoMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
from xmodule.modulestore.inheritance import InheritanceMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
from xmodule.x_module import XModuleMixin # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
from xmodule.x_module import XModuleMixin, ResourceTemplates # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position

# These are the Mixins that will be added to every Blocklike upon instantiation.
# DO NOT EXPAND THIS LIST!! We want it eventually to be EMPTY. Why? Because dynamically adding functions/behaviors to
Expand All @@ -1597,6 +1597,7 @@
# (b) refactor their functionality out of the Blocklike objects and into the edx-platform block runtimes.
LmsBlockMixin,
InheritanceMixin,
ResourceTemplates,
XModuleMixin,
EditInfoMixin,
)
Expand Down Expand Up @@ -3164,6 +3165,9 @@
"openedx_learning.apps.authoring.units",
"openedx_learning.apps.authoring.subsections",
"openedx_learning.apps.authoring.sections",

# Extracted problem xblock
"xblocks_contrib.problem.capa"
]

######################### CSRF #########################################
Expand Down
2 changes: 1 addition & 1 deletion openedx/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def _make_locale_paths(settings):
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_creation_date: 2024-11-10
# .. toggle_target_removal_date: 2025-06-01
USE_EXTRACTED_PROBLEM_BLOCK = False
USE_EXTRACTED_PROBLEM_BLOCK = True

# .. toggle_name: USE_EXTRACTED_VIDEO_BLOCK
# .. toggle_default: False
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ xblock-utils==4.0.0
# via
# edx-sga
# xblock-poll
xblocks-contrib==0.6.0
git+https://github.com/openedx/xblocks-contrib.git@problemblock
# via -r requirements/edx/bundled.in
xmlsec==1.3.14
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ xblock-utils==4.0.0
# -r requirements/edx/testing.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.6.0
git+https://github.com/openedx/xblocks-contrib.git@problemblock
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ xblock-utils==4.0.0
# -r requirements/edx/base.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.6.0
git+https://github.com/openedx/xblocks-contrib.git@problemblock
# via -r requirements/edx/base.txt
xmlsec==1.3.14
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ xblock-utils==4.0.0
# -r requirements/edx/base.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.6.0
git+https://github.com/openedx/xblocks-contrib.git@problemblock
# via -r requirements/edx/base.txt
xmlsec==1.3.14
# via
Expand Down
3 changes: 2 additions & 1 deletion xmodule/modulestore/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ def _create(cls, target_class, **kwargs): # lint-amnesty, pylint: disable=argum
if 'boilerplate' in kwargs:
template_id = kwargs.pop('boilerplate')
clz = XBlock.load_class(category)
template = clz.get_template(template_id)
dynamic_clz = parent.runtime.mixologist.mix(clz)
template = dynamic_clz.get_template(template_id)
assert template is not None
metadata.update(template.get('metadata', {}))
if not isinstance(data, str):
Expand Down
1 change: 1 addition & 0 deletions xmodule/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def get_block(block):

descriptor_system.get_block_for_descriptor = get_block # lint-amnesty, pylint: disable=attribute-defined-outside-init
descriptor_system._services.update(services) # lint-amnesty, pylint: disable=protected-access
descriptor_system.render_template = Mock(side_effect=render_template)

return descriptor_system

Expand Down
Loading
Loading