Skip to content

Commit 9820dd6

Browse files
committed
chore: adds proble block
1 parent 458272c commit 9820dd6

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

cms/lib/xblock/tagging/tagging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from xblock.fields import Dict, Scope
99

1010
from common.djangoapps.edxmako.shortcuts import render_to_string
11-
from xmodule.capa_block import ProblemBlock # lint-amnesty, pylint: disable=wrong-import-order
1211
from xmodule.x_module import AUTHOR_VIEW # lint-amnesty, pylint: disable=wrong-import-order
1312

1413
_ = lambda text: text
@@ -42,6 +41,7 @@ def student_view_aside(self, block, context): # pylint: disable=unused-argument
4241
Display the tag selector with specific categories and allowed values,
4342
depending on the context.
4443
"""
44+
from xmodule.capa_block import ProblemBlock
4545
if isinstance(block, ProblemBlock):
4646
tags = []
4747
for tag in self.get_available_tags():

xmodule/capa_block.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
from xblock.core import XBlock
2626
from xblock.fields import Boolean, Dict, Float, Integer, Scope, String, XMLString, List
2727
from xblock.scorable import ScorableXBlockMixin, Score
28+
from xblocks_contrib.problem import ProblemBlock as _ExtractedProblemBlock
2829

30+
from common.djangoapps.xblock_django.constants import (
31+
ATTR_KEY_DEPRECATED_ANONYMOUS_USER_ID,
32+
ATTR_KEY_USER_IS_STAFF,
33+
ATTR_KEY_USER_ID,
34+
)
35+
from openedx.core.djangolib.markup import HTML, Text
2936
from xmodule.capa import responsetypes
3037
from xmodule.capa.capa_problem import LoncapaProblem, LoncapaSystem
3138
from xmodule.capa.inputtypes import Status
@@ -36,23 +43,17 @@
3643
from xmodule.exceptions import NotFoundError, ProcessingError
3744
from xmodule.graders import ShowCorrectness
3845
from xmodule.raw_block import RawMixin
39-
from xmodule.util.sandboxing import SandboxService
46+
from xmodule.toggles import USE_EXTRACTED_PROBLEM_BLOCK
4047
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment
48+
from xmodule.util.sandboxing import SandboxService
4149
from xmodule.x_module import (
4250
ResourceTemplates,
4351
XModuleMixin,
4452
XModuleToXBlockMixin,
4553
shim_xmodule_js
4654
)
4755
from xmodule.xml_block import XmlMixin
48-
from common.djangoapps.xblock_django.constants import (
49-
ATTR_KEY_DEPRECATED_ANONYMOUS_USER_ID,
50-
ATTR_KEY_USER_IS_STAFF,
51-
ATTR_KEY_USER_ID,
52-
)
53-
from openedx.core.djangolib.markup import HTML, Text
5456
from .capa.xqueue_interface import XQueueService
55-
5657
from .fields import Date, ListScoreField, ScoreField, Timedelta
5758
from .progress import Progress
5859

@@ -134,7 +135,7 @@ def from_json(self, value):
134135
@XBlock.needs('sandbox')
135136
@XBlock.needs('replace_urls')
136137
@XBlock.wants('call_to_action')
137-
class ProblemBlock(
138+
class _BuiltInProblemBlock(
138139
ScorableXBlockMixin,
139140
RawMixin,
140141
XmlMixin,
@@ -161,6 +162,8 @@ class ProblemBlock(
161162
"""
162163
INDEX_CONTENT_TYPE = 'CAPA'
163164

165+
is_extracted = False
166+
164167
resources_dir = None
165168

166169
has_score = True
@@ -2509,3 +2512,9 @@ def randomization_bin(seed, problem_id):
25092512
r_hash.update(str(problem_id).encode())
25102513
# get the first few digits of the hash, convert to an int, then mod.
25112514
return int(r_hash.hexdigest()[:7], 16) % NUM_RANDOMIZATION_BINS
2515+
2516+
2517+
ProblemBlock = (
2518+
_ExtractedProblemBlock if USE_EXTRACTED_PROBLEM_BLOCK.is_enabled()
2519+
else _BuiltInProblemBlock
2520+
)

0 commit comments

Comments
 (0)