Skip to content

Commit

Permalink
chore: adds proble block
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Oct 27, 2024
1 parent 458272c commit 9820dd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cms/lib/xblock/tagging/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from xblock.fields import Dict, Scope

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

_ = lambda text: text
Expand Down Expand Up @@ -42,6 +41,7 @@ def student_view_aside(self, block, context): # pylint: disable=unused-argument
Display the tag selector with specific categories and allowed values,
depending on the context.
"""
from xmodule.capa_block import ProblemBlock
if isinstance(block, ProblemBlock):
tags = []
for tag in self.get_available_tags():
Expand Down
27 changes: 18 additions & 9 deletions xmodule/capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
from xblock.core import XBlock
from xblock.fields import Boolean, Dict, Float, Integer, Scope, String, XMLString, List
from xblock.scorable import ScorableXBlockMixin, Score
from xblocks_contrib.problem import ProblemBlock as _ExtractedProblemBlock

from common.djangoapps.xblock_django.constants import (
ATTR_KEY_DEPRECATED_ANONYMOUS_USER_ID,
ATTR_KEY_USER_IS_STAFF,
ATTR_KEY_USER_ID,
)
from openedx.core.djangolib.markup import HTML, Text
from xmodule.capa import responsetypes
from xmodule.capa.capa_problem import LoncapaProblem, LoncapaSystem
from xmodule.capa.inputtypes import Status
Expand All @@ -36,23 +43,17 @@
from xmodule.exceptions import NotFoundError, ProcessingError
from xmodule.graders import ShowCorrectness
from xmodule.raw_block import RawMixin
from xmodule.util.sandboxing import SandboxService
from xmodule.toggles import USE_EXTRACTED_PROBLEM_BLOCK
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment
from xmodule.util.sandboxing import SandboxService
from xmodule.x_module import (
ResourceTemplates,
XModuleMixin,
XModuleToXBlockMixin,
shim_xmodule_js
)
from xmodule.xml_block import XmlMixin
from common.djangoapps.xblock_django.constants import (
ATTR_KEY_DEPRECATED_ANONYMOUS_USER_ID,
ATTR_KEY_USER_IS_STAFF,
ATTR_KEY_USER_ID,
)
from openedx.core.djangolib.markup import HTML, Text
from .capa.xqueue_interface import XQueueService

from .fields import Date, ListScoreField, ScoreField, Timedelta
from .progress import Progress

Expand Down Expand Up @@ -134,7 +135,7 @@ def from_json(self, value):
@XBlock.needs('sandbox')
@XBlock.needs('replace_urls')
@XBlock.wants('call_to_action')
class ProblemBlock(
class _BuiltInProblemBlock(
ScorableXBlockMixin,
RawMixin,
XmlMixin,
Expand All @@ -161,6 +162,8 @@ class ProblemBlock(
"""
INDEX_CONTENT_TYPE = 'CAPA'

is_extracted = False

resources_dir = None

has_score = True
Expand Down Expand Up @@ -2509,3 +2512,9 @@ def randomization_bin(seed, problem_id):
r_hash.update(str(problem_id).encode())
# get the first few digits of the hash, convert to an int, then mod.
return int(r_hash.hexdigest()[:7], 16) % NUM_RANDOMIZATION_BINS


ProblemBlock = (
_ExtractedProblemBlock if USE_EXTRACTED_PROBLEM_BLOCK.is_enabled()
else _BuiltInProblemBlock
)

0 comments on commit 9820dd6

Please sign in to comment.