Revert "refactor: move common/lib/capa/capa to xmodule/capa" (#30762)
This commit is contained in:
committed by
GitHub
parent
06064b237b
commit
4463ee751d
@@ -4,6 +4,7 @@ data_file = reports/${TEST_SUITE}.coverage
|
||||
source =
|
||||
cms
|
||||
common/djangoapps
|
||||
common/lib/capa
|
||||
lms
|
||||
openedx
|
||||
pavelib
|
||||
|
||||
@@ -4,6 +4,7 @@ data_file = reports/.coverage
|
||||
source =
|
||||
cms
|
||||
common/djangoapps
|
||||
common/lib/capa
|
||||
common/lib/xmodule
|
||||
lms
|
||||
openedx
|
||||
|
||||
@@ -46,10 +46,10 @@ cms/static/js/spec/views/course_info_spec.js
|
||||
cms/static/js/spec/views/metadata_edit_spec.js
|
||||
cms/static/js/spec/views/textbook_spec.js
|
||||
cms/static/js/spec/views/upload_spec.js
|
||||
xmodule/capa/tests/test_files/js/test_problem_display.js
|
||||
xmodule/capa/tests/test_files/js/test_problem_generator.js
|
||||
xmodule/capa/tests/test_files/js/test_problem_grader.js
|
||||
xmodule/capa/tests/test_files/js/xproblem.js
|
||||
common/lib/capa/capa/tests/test_files/js/test_problem_display.js
|
||||
common/lib/capa/capa/tests/test_files/js/test_problem_generator.js
|
||||
common/lib/capa/capa/tests/test_files/js/test_problem_grader.js
|
||||
common/lib/capa/capa/tests/test_files/js/xproblem.js
|
||||
lms/static/js/spec/calculator_spec.js
|
||||
lms/static/js/spec/courseware_spec.js
|
||||
lms/static/js/spec/feedback_form_spec.js
|
||||
|
||||
6
.github/workflows/unit-test-shards.json
vendored
6
.github/workflows/unit-test-shards.json
vendored
@@ -261,6 +261,12 @@
|
||||
]
|
||||
},
|
||||
"common-2": {
|
||||
"settings": "lms.envs.test",
|
||||
"paths": [
|
||||
"common/lib/"
|
||||
]
|
||||
},
|
||||
"common-3": {
|
||||
"settings": "cms.envs.test",
|
||||
"paths": [
|
||||
"common/djangoapps/"
|
||||
|
||||
3
.github/workflows/unit-tests.yml
vendored
3
.github/workflows/unit-tests.yml
vendored
@@ -31,6 +31,7 @@ jobs:
|
||||
"cms-2",
|
||||
"common-1",
|
||||
"common-2",
|
||||
"common-3",
|
||||
"xmodule-1"
|
||||
]
|
||||
|
||||
@@ -61,7 +62,7 @@ jobs:
|
||||
- name: install requirements
|
||||
run: |
|
||||
sudo pip install -r requirements/pip.txt
|
||||
sudo pip install --exists-action='w' -r requirements/edx/testing.txt
|
||||
sudo pip install -r requirements/edx/testing.txt
|
||||
if [[ "${{ matrix.django-version }}" == "pinned" ]]; then
|
||||
sudo pip install -r requirements/edx/django.txt
|
||||
else
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
- name: install requirements
|
||||
run: |
|
||||
sudo pip install -r requirements/pip.txt
|
||||
sudo pip install --exists-action='w' -r requirements/edx/testing.txt
|
||||
sudo pip install -r requirements/edx/testing.txt
|
||||
|
||||
- name: verify unit tests count
|
||||
uses: ./.github/actions/verify-tests-count
|
||||
|
||||
@@ -1112,10 +1112,10 @@ COURSES_WITH_UNSAFE_CODE = []
|
||||
# Cojail REST service
|
||||
ENABLE_CODEJAIL_REST_SERVICE = False
|
||||
# .. setting_name: CODE_JAIL_REST_SERVICE_REMOTE_EXEC
|
||||
# .. setting_default: 'xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
# .. setting_default: 'capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
# .. setting_description: Set the python package.module.function that is reponsible of
|
||||
# calling the remote service in charge of jailed code execution
|
||||
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = 'xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = 'capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
# .. setting_name: CODE_JAIL_REST_SERVICE_HOST
|
||||
# .. setting_default: 'http://127.0.0.1:8550'
|
||||
# .. setting_description: Set the codejail remote service host
|
||||
|
||||
@@ -27,13 +27,13 @@ import six
|
||||
from lxml import etree
|
||||
from pytz import UTC
|
||||
|
||||
import xmodule.capa.customrender as customrender
|
||||
import xmodule.capa.inputtypes as inputtypes
|
||||
import xmodule.capa.responsetypes as responsetypes
|
||||
import xmodule.capa.xqueue_interface as xqueue_interface
|
||||
from xmodule.capa.correctmap import CorrectMap
|
||||
from xmodule.capa.safe_exec import safe_exec
|
||||
from xmodule.capa.util import contextualize_text, convert_files_to_filenames, get_course_id_from_capa_module
|
||||
import capa.customrender as customrender
|
||||
import capa.inputtypes as inputtypes
|
||||
import capa.responsetypes as responsetypes
|
||||
import capa.xqueue_interface as xqueue_interface
|
||||
from capa.correctmap import CorrectMap
|
||||
from capa.safe_exec import safe_exec
|
||||
from capa.util import contextualize_text, convert_files_to_filenames, get_course_id_from_capa_module
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib.edx_six import get_gettext
|
||||
from xmodule.stringify import stringify_children
|
||||
@@ -13,7 +13,7 @@ from calc import UndefinedVariable
|
||||
from mako.lookup import TemplateLookup
|
||||
from path import Path as path
|
||||
|
||||
from xmodule.capa.capa_problem import LoncapaProblem
|
||||
from capa.capa_problem import LoncapaProblem
|
||||
|
||||
logging.basicConfig(format="%(levelname)s %(message)s")
|
||||
log = logging.getLogger('capa.checker')
|
||||
@@ -57,7 +57,7 @@ from chem import chemcalc
|
||||
from lxml import etree
|
||||
from six import text_type
|
||||
|
||||
from xmodule.capa.xqueue_interface import XQUEUE_TIMEOUT
|
||||
from capa.xqueue_interface import XQUEUE_TIMEOUT
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib import edx_six
|
||||
from xmodule.stringify import stringify_children
|
||||
@@ -43,8 +43,8 @@ from shapely.geometry import MultiPoint, Point
|
||||
from six import text_type
|
||||
from six.moves import map, range, zip
|
||||
|
||||
import xmodule.capa.safe_exec as safe_exec
|
||||
import xmodule.capa.xqueue_interface as xqueue_interface
|
||||
import capa.safe_exec as safe_exec
|
||||
import capa.xqueue_interface as xqueue_interface
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib import edx_six
|
||||
from openedx.core.lib.grade_utils import round_away_from_zero
|
||||
@@ -2,19 +2,19 @@
|
||||
Helper methods related to safe exec.
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
import logging
|
||||
from importlib import import_module
|
||||
import requests
|
||||
|
||||
from codejail.safe_exec import SafeExecException
|
||||
from django.conf import settings
|
||||
from edx_toggles.toggles import SettingToggle
|
||||
from importlib import import_module
|
||||
from requests.exceptions import RequestException, HTTPError
|
||||
from simplejson import JSONDecodeError
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
from .exceptions import CodejailServiceParseError, CodejailServiceStatusError, CodejailServiceUnavailable
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from xmodule.capa.safe_exec.lazymod import LazyModule
|
||||
from capa.safe_exec.lazymod import LazyModule
|
||||
|
||||
|
||||
class ModuleIsolation(object):
|
||||
@@ -19,7 +19,7 @@ from django.test import override_settings
|
||||
from six import text_type, unichr
|
||||
from six.moves import range
|
||||
|
||||
from xmodule.capa.safe_exec import safe_exec, update_hash
|
||||
from capa.safe_exec import safe_exec, update_hash
|
||||
|
||||
|
||||
class TestSafeExec(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from xmodule.capa.util import remove_markup %>
|
||||
<%! from capa.util import remove_markup %>
|
||||
<div id="chemicalequationinput_${id}" class="chemicalequationinput">
|
||||
<div class="script_placeholder" data-src="${previewer}"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from xmodule.capa.util import remove_markup
|
||||
<%! from capa.util import remove_markup
|
||||
from django.utils.translation import ugettext as _
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
%>
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from xmodule.capa.util import remove_markup %>
|
||||
<%! from capa.util import remove_markup %>
|
||||
<div>
|
||||
<div class="script_placeholder" data-src="${setup_script}"/>
|
||||
<input type="hidden"
|
||||
@@ -13,8 +13,8 @@ from mako.lookup import TemplateLookup
|
||||
from mock import MagicMock, Mock
|
||||
from path import Path
|
||||
|
||||
from xmodule.capa.capa_problem import LoncapaProblem, LoncapaSystem
|
||||
from xmodule.capa.inputtypes import Status
|
||||
from capa.capa_problem import LoncapaProblem, LoncapaSystem
|
||||
from capa.inputtypes import Status
|
||||
|
||||
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -7,8 +7,8 @@ Tests the logic of the "answer-pool" attribute, e.g.
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
from xmodule.capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
from capa.responsetypes import LoncapaProblemError
|
||||
from capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
|
||||
|
||||
class CapaAnswerPoolTest(unittest.TestCase):
|
||||
@@ -12,8 +12,8 @@ from lxml import etree
|
||||
from markupsafe import Markup
|
||||
from mock import patch
|
||||
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
from xmodule.capa.tests.helpers import new_loncapa_problem
|
||||
from capa.responsetypes import LoncapaProblemError
|
||||
from capa.tests.helpers import new_loncapa_problem
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Tests to verify that CorrectMap behaves correctly
|
||||
import datetime
|
||||
import unittest
|
||||
import pytest
|
||||
from xmodule.capa.correctmap import CorrectMap
|
||||
from capa.correctmap import CorrectMap
|
||||
|
||||
|
||||
class CorrectMapTest(unittest.TestCase):
|
||||
@@ -220,4 +220,4 @@ class CorrectMapTest(unittest.TestCase):
|
||||
invalid_list = [None, "", False, 0]
|
||||
for invalid in invalid_list:
|
||||
self.cmap.set_dict(invalid)
|
||||
assert not self.cmap.get_dict()
|
||||
assert self.cmap.get_dict() == {}
|
||||
@@ -5,8 +5,8 @@ import xml.sax.saxutils as saxutils
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from xmodule.capa import customrender
|
||||
from xmodule.capa.tests.helpers import test_capa_system
|
||||
from capa import customrender
|
||||
from capa.tests.helpers import test_capa_system
|
||||
|
||||
# just a handy shortcut
|
||||
lookup_tag = customrender.registry.get_class_for_tag
|
||||
@@ -8,7 +8,7 @@ import unittest
|
||||
import pytest
|
||||
from ddt import data, ddt, unpack
|
||||
|
||||
from xmodule.capa.tests.helpers import load_fixture, new_loncapa_problem
|
||||
from capa.tests.helpers import load_fixture, new_loncapa_problem
|
||||
|
||||
# With the use of ddt, some of the data expected_string cases below are naturally long stretches
|
||||
# of text text without whitespace. I think it's best to leave such lines intact
|
||||
@@ -10,7 +10,7 @@ import unittest
|
||||
import ddt
|
||||
import mock
|
||||
from lxml import etree
|
||||
from xmodule.capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
from capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
from .response_xml_factory import CustomResponseXMLFactory, StringResponseXMLFactory
|
||||
@@ -11,8 +11,8 @@ from lxml import etree
|
||||
from mako import exceptions
|
||||
from six.moves import range
|
||||
|
||||
from xmodule.capa.inputtypes import Status
|
||||
from xmodule.capa.tests.helpers import capa_render_template
|
||||
from capa.inputtypes import Status
|
||||
from capa.tests.helpers import capa_render_template
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
from xmodule.stringify import stringify_children
|
||||
|
||||
@@ -32,10 +32,10 @@ from mock import ANY, patch
|
||||
from pyparsing import ParseException
|
||||
from six.moves import zip
|
||||
|
||||
from xmodule.capa import inputtypes
|
||||
from xmodule.capa.checker import DemoSystem
|
||||
from xmodule.capa.tests.helpers import test_capa_system
|
||||
from xmodule.capa.xqueue_interface import XQUEUE_TIMEOUT
|
||||
from capa import inputtypes
|
||||
from capa.checker import DemoSystem
|
||||
from capa.tests.helpers import test_capa_system
|
||||
from capa.xqueue_interface import XQUEUE_TIMEOUT
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
# just a handy shortcut
|
||||
@@ -606,7 +606,7 @@ class MatlabTest(unittest.TestCase):
|
||||
|
||||
assert context == expected
|
||||
|
||||
@patch('xmodule.capa.inputtypes.time.time', return_value=10)
|
||||
@patch('capa.inputtypes.time.time', return_value=10)
|
||||
def test_rendering_while_queued(self, time): # lint-amnesty, pylint: disable=unused-argument
|
||||
state = {
|
||||
'value': 'print "good evening"',
|
||||
@@ -658,7 +658,7 @@ class MatlabTest(unittest.TestCase):
|
||||
assert 'queuekey' not in self.the_input.input_state
|
||||
assert 'queuestate' not in self.the_input.input_state
|
||||
|
||||
@patch('xmodule.capa.inputtypes.time.time', return_value=10)
|
||||
@patch('capa.inputtypes.time.time', return_value=10)
|
||||
def test_ungraded_response_success(self, time): # lint-amnesty, pylint: disable=unused-argument
|
||||
queuekey = 'abcd'
|
||||
input_state = {'queuekey': queuekey, 'queuestate': 'queued', 'queuetime': 5}
|
||||
@@ -677,7 +677,7 @@ class MatlabTest(unittest.TestCase):
|
||||
assert input_state['queuestate'] is None
|
||||
assert input_state['queue_msg'] == inner_msg
|
||||
|
||||
@patch('xmodule.capa.inputtypes.time.time', return_value=10)
|
||||
@patch('capa.inputtypes.time.time', return_value=10)
|
||||
def test_ungraded_response_key_mismatch(self, time): # lint-amnesty, pylint: disable=unused-argument
|
||||
queuekey = 'abcd'
|
||||
input_state = {'queuekey': queuekey, 'queuestate': 'queued', 'queuetime': 5}
|
||||
@@ -696,7 +696,7 @@ class MatlabTest(unittest.TestCase):
|
||||
assert input_state['queuestate'] == 'queued'
|
||||
assert 'queue_msg' not in input_state
|
||||
|
||||
@patch('xmodule.capa.inputtypes.time.time', return_value=20)
|
||||
@patch('capa.inputtypes.time.time', return_value=20)
|
||||
def test_matlab_response_timeout_not_exceeded(self, time): # lint-amnesty, pylint: disable=unused-argument
|
||||
|
||||
state = {'input_state': {'queuestate': 'queued', 'queuetime': 5}}
|
||||
@@ -705,7 +705,7 @@ class MatlabTest(unittest.TestCase):
|
||||
the_input = self.input_class(test_capa_system(), elt, state)
|
||||
assert the_input.status == 'queued'
|
||||
|
||||
@patch('xmodule.capa.inputtypes.time.time', return_value=45)
|
||||
@patch('capa.inputtypes.time.time', return_value=45)
|
||||
def test_matlab_response_timeout_exceeded(self, time): # lint-amnesty, pylint: disable=unused-argument
|
||||
|
||||
state = {'input_state': {'queuestate': 'queued', 'queuetime': 5}}
|
||||
@@ -715,7 +715,7 @@ class MatlabTest(unittest.TestCase):
|
||||
assert the_input.status == 'unsubmitted'
|
||||
assert the_input.msg == 'No response from Xqueue within {} seconds. Aborted.'.format(XQUEUE_TIMEOUT)
|
||||
|
||||
@patch('xmodule.capa.inputtypes.time.time', return_value=20)
|
||||
@patch('capa.inputtypes.time.time', return_value=20)
|
||||
def test_matlab_response_migration_of_queuetime(self, time): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""
|
||||
Test if problem was saved before queuetime was introduced.
|
||||
@@ -1212,7 +1212,7 @@ class ChemicalEquationTest(unittest.TestCase):
|
||||
With parse errors, ChemicalEquationInput should give an error message
|
||||
"""
|
||||
# Simulate answering a problem that raises the exception
|
||||
with patch('xmodule.capa.inputtypes.chemcalc.render_to_html') as mock_render:
|
||||
with patch('capa.inputtypes.chemcalc.render_to_html') as mock_render:
|
||||
mock_render.side_effect = ParseException("ȧƈƈḗƞŧḗḓ ŧḗẋŧ ƒǿř ŧḗşŧīƞɠ")
|
||||
response = self.the_input.handle_ajax(
|
||||
"preview_chemcalc",
|
||||
@@ -1222,12 +1222,12 @@ class ChemicalEquationTest(unittest.TestCase):
|
||||
assert 'error' in response
|
||||
assert "Couldn't parse formula" in response['error']
|
||||
|
||||
@patch('xmodule.capa.inputtypes.log')
|
||||
@patch('capa.inputtypes.log')
|
||||
def test_ajax_other_err(self, mock_log):
|
||||
"""
|
||||
With other errors, test that ChemicalEquationInput also logs it
|
||||
"""
|
||||
with patch('xmodule.capa.inputtypes.chemcalc.render_to_html') as mock_render:
|
||||
with patch('capa.inputtypes.chemcalc.render_to_html') as mock_render:
|
||||
mock_render.side_effect = Exception()
|
||||
response = self.the_input.handle_ajax(
|
||||
"preview_chemcalc",
|
||||
@@ -1360,7 +1360,7 @@ class FormulaEquationTest(unittest.TestCase):
|
||||
With parse errors, FormulaEquationInput should give an error message
|
||||
"""
|
||||
# Simulate answering a problem that raises the exception
|
||||
with patch('xmodule.capa.inputtypes.latex_preview') as mock_preview:
|
||||
with patch('capa.inputtypes.latex_preview') as mock_preview:
|
||||
mock_preview.side_effect = ParseException("Oopsie")
|
||||
response = self.the_input.handle_ajax(
|
||||
"preview_formcalc",
|
||||
@@ -1370,12 +1370,12 @@ class FormulaEquationTest(unittest.TestCase):
|
||||
assert 'error' in response
|
||||
assert response['error'] == "Sorry, couldn't parse formula"
|
||||
|
||||
@patch('xmodule.capa.inputtypes.log')
|
||||
@patch('capa.inputtypes.log')
|
||||
def test_ajax_other_err(self, mock_log):
|
||||
"""
|
||||
With other errors, test that FormulaEquationInput also logs it
|
||||
"""
|
||||
with patch('xmodule.capa.inputtypes.latex_preview') as mock_preview:
|
||||
with patch('capa.inputtypes.latex_preview') as mock_preview:
|
||||
mock_preview.side_effect = Exception()
|
||||
response = self.the_input.handle_ajax(
|
||||
"preview_formcalc",
|
||||
@@ -22,10 +22,10 @@ import six
|
||||
from pytz import UTC
|
||||
from six import text_type
|
||||
|
||||
from xmodule.capa.correctmap import CorrectMap
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError, ResponseError, StudentInputError
|
||||
from xmodule.capa.tests.helpers import load_fixture, new_loncapa_problem, test_capa_system
|
||||
from xmodule.capa.tests.response_xml_factory import (
|
||||
from capa.correctmap import CorrectMap
|
||||
from capa.responsetypes import LoncapaProblemError, ResponseError, StudentInputError
|
||||
from capa.tests.helpers import load_fixture, new_loncapa_problem, test_capa_system
|
||||
from capa.tests.response_xml_factory import (
|
||||
AnnotationResponseXMLFactory,
|
||||
ChoiceResponseXMLFactory,
|
||||
ChoiceTextResponseXMLFactory,
|
||||
@@ -41,8 +41,8 @@ from xmodule.capa.tests.response_xml_factory import (
|
||||
SymbolicResponseXMLFactory,
|
||||
TrueFalseResponseXMLFactory
|
||||
)
|
||||
from xmodule.capa.util import convert_files_to_filenames
|
||||
from xmodule.capa.xqueue_interface import dateformat
|
||||
from capa.util import convert_files_to_filenames
|
||||
from capa.xqueue_interface import dateformat
|
||||
|
||||
|
||||
class ResponseTest(unittest.TestCase):
|
||||
@@ -1568,7 +1568,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-class-docs
|
||||
problem = self.build_problem(answer="1+1j", tolerance=1e-3)
|
||||
self.assert_grade(problem, '1+j', 'correct')
|
||||
|
||||
@mock.patch('xmodule.capa.responsetypes.log')
|
||||
@mock.patch('capa.responsetypes.log')
|
||||
def test_staff_inputs_bad_syntax(self, mock_log):
|
||||
"""Test that staff may enter in a complex number as the answer."""
|
||||
staff_ans = "clearly bad syntax )[+1e"
|
||||
@@ -1582,7 +1582,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-class-docs
|
||||
"Content error--answer '%s' is not a valid number", staff_ans
|
||||
)
|
||||
|
||||
@mock.patch('xmodule.capa.responsetypes.log')
|
||||
@mock.patch('capa.responsetypes.log')
|
||||
def test_responsetype_i18n(self, mock_log): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""Test that LoncapaSystem has an i18n that works."""
|
||||
staff_ans = "clearly bad syntax )[+1e"
|
||||
@@ -1622,7 +1622,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-class-docs
|
||||
|
||||
problem = self.build_problem(answer=4, tolerance='10%')
|
||||
|
||||
with mock.patch('xmodule.capa.responsetypes.evaluator') as mock_eval:
|
||||
with mock.patch('capa.responsetypes.evaluator') as mock_eval:
|
||||
mock_eval.side_effect = evaluator_side_effect
|
||||
self.assert_grade(problem, 'some big input', 'incorrect')
|
||||
self.assert_grade(problem, 'some neg input', 'incorrect')
|
||||
@@ -1643,7 +1643,7 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-class-docs
|
||||
(ZeroDivisionError(), "Could not interpret '.*' as a number")
|
||||
]
|
||||
|
||||
with mock.patch('xmodule.capa.responsetypes.evaluator') as mock_eval:
|
||||
with mock.patch('capa.responsetypes.evaluator') as mock_eval:
|
||||
for err, msg_regex in errors:
|
||||
|
||||
def evaluator_side_effect(_, __, math_string):
|
||||
@@ -4,8 +4,8 @@
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
from xmodule.capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
from capa.responsetypes import LoncapaProblemError
|
||||
from capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
|
||||
|
||||
class CapaShuffleTest(unittest.TestCase):
|
||||
@@ -6,7 +6,7 @@ i.e. those with the <multiplechoiceresponse> element
|
||||
|
||||
import textwrap
|
||||
import unittest
|
||||
from xmodule.capa.tests.helpers import load_fixture, new_loncapa_problem, test_capa_system
|
||||
from capa.tests.helpers import load_fixture, new_loncapa_problem, test_capa_system
|
||||
|
||||
|
||||
class CapaTargetedFeedbackTest(unittest.TestCase):
|
||||
@@ -9,8 +9,8 @@ import unittest
|
||||
import ddt
|
||||
from lxml import etree
|
||||
|
||||
from xmodule.capa.tests.helpers import test_capa_system
|
||||
from xmodule.capa.util import (
|
||||
from capa.tests.helpers import test_capa_system
|
||||
from capa.util import (
|
||||
compare_with_tolerance,
|
||||
contextualize_text,
|
||||
get_inner_html_from_xpath,
|
||||
@@ -6,7 +6,7 @@ Tests the xqueue service interface.
|
||||
from unittest import TestCase
|
||||
from django.conf import settings
|
||||
|
||||
from xmodule.capa.xqueue_interface import XQueueInterface, XQueueService
|
||||
from capa.xqueue_interface import XQueueInterface, XQueueService
|
||||
|
||||
|
||||
class XQueueServiceTest(TestCase):
|
||||
14
common/lib/capa/setup.py
Normal file
14
common/lib/capa/setup.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# lint-amnesty, pylint: disable=missing-module-docstring
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
setup(
|
||||
name="capa",
|
||||
version="0.1",
|
||||
packages=find_packages(exclude=["tests"]),
|
||||
install_requires=[
|
||||
"setuptools",
|
||||
"lxml",
|
||||
"pytz"
|
||||
],
|
||||
)
|
||||
@@ -11,7 +11,7 @@
|
||||
# lms/templates
|
||||
# lms/djangoapps/APPNAME/templates
|
||||
# openedx/**/templates
|
||||
# xmodule/capa/templates
|
||||
# common/lib/capa/capa/templates
|
||||
#
|
||||
# Don't extract from these directory trees:
|
||||
# common/test/test_microsites/test_microsite/templates
|
||||
@@ -25,7 +25,7 @@ input_encoding = utf-8
|
||||
input_encoding = utf-8
|
||||
[mako: */templates/emails/**.txt]
|
||||
input_encoding = utf-8
|
||||
[mako: xmodule/capa/templates/**.html]
|
||||
[mako: common/lib/capa/capa/templates/**.html]
|
||||
input_encoding = utf-8
|
||||
[mako: openedx/**/templates/**.html]
|
||||
input_encoding = utf-8
|
||||
|
||||
@@ -20,6 +20,7 @@ root = Path('../..').abspath()
|
||||
# can be successfully imported
|
||||
sys.path.insert(0, root)
|
||||
sys.path.append(root / "docs/guides")
|
||||
sys.path.append(root / "common/lib/capa")
|
||||
|
||||
|
||||
# Use a settings module that allows all LMS and Studio code to be imported
|
||||
@@ -220,6 +221,7 @@ autodoc_mock_imports = [
|
||||
# the generated *.rst files
|
||||
modules = {
|
||||
'cms': 'cms',
|
||||
'common/lib/capa/capa': 'common/lib/capa',
|
||||
'lms': 'lms',
|
||||
'openedx': 'openedx',
|
||||
'xmodule': 'xmodule',
|
||||
|
||||
@@ -7,3 +7,5 @@ out from edx-platform into separate packages at some point.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
common/lib/capa/modules
|
||||
|
||||
@@ -71,7 +71,7 @@ Test Locations
|
||||
|
||||
- Python unit and integration tests: Located in subpackages called
|
||||
``tests``. For example, the tests for the ``capa`` package are
|
||||
located in ``xmodule/capa/tests``.
|
||||
located in ``common/lib/capa/capa/tests``.
|
||||
|
||||
- Javascript unit tests: Located in ``spec`` folders. For example,
|
||||
``xmodule/js/spec`` and
|
||||
@@ -432,7 +432,7 @@ Factories are often implemented using `FactoryBoy`_.
|
||||
|
||||
In general, factories should be located close to the code they use. For
|
||||
example, the factory for creating problem XML definitions is located in
|
||||
``xmodule/capa/tests/response_xml_factory.py`` because the
|
||||
``common/lib/capa/capa/tests/response_xml_factory.py`` because the
|
||||
``capa`` package handles problem XML.
|
||||
|
||||
.. _FactoryBoy: https://readthedocs.org/projects/factoryboy/
|
||||
|
||||
@@ -19,12 +19,13 @@ from django.utils.translation import gettext as _
|
||||
from edx_django_utils.cache import RequestCache
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from pytz import UTC
|
||||
from capa.tests.response_xml_factory import StringResponseXMLFactory
|
||||
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, SampleCourseFactory
|
||||
from xmodule.x_module import XModuleMixin
|
||||
from xmodule.capa.tests.response_xml_factory import StringResponseXMLFactory
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_response
|
||||
from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed
|
||||
from common.djangoapps.student.roles import CourseCcxCoachRole, CourseInstructorRole, CourseStaffRole
|
||||
|
||||
@@ -48,7 +48,7 @@ from xmodule.services import RebindUserService
|
||||
from common.djangoapps.static_replace.services import ReplaceURLService
|
||||
from common.djangoapps.static_replace.wrapper import replace_urls_wrapper
|
||||
from common.djangoapps.xblock_django.constants import ATTR_KEY_USER_ID
|
||||
from xmodule.capa.xqueue_interface import XQueueService # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from capa.xqueue_interface import XQueueService # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from lms.djangoapps.courseware.access import get_user_role, has_access
|
||||
from lms.djangoapps.courseware.entrance_exams import user_can_skip_entrance_exam, user_has_passed_entrance_exam
|
||||
from lms.djangoapps.courseware.masquerade import (
|
||||
|
||||
@@ -7,15 +7,16 @@ from unittest.mock import patch
|
||||
from crum import set_current_request
|
||||
from django.urls import reverse
|
||||
from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from lms.djangoapps.courseware.entrance_exams import (
|
||||
course_has_entrance_exam,
|
||||
get_entrance_exam_content,
|
||||
user_can_skip_entrance_exam,
|
||||
user_has_passed_entrance_exam
|
||||
)
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from lms.djangoapps.courseware.model_data import FieldDataCache
|
||||
from lms.djangoapps.courseware.module_render import get_module, handle_xblock_callback, toc_for_course
|
||||
from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase
|
||||
|
||||
@@ -16,7 +16,7 @@ from django.urls import reverse
|
||||
from pytz import UTC
|
||||
from xblock.runtime import DictKeyValueStore
|
||||
|
||||
from xmodule.capa.tests.response_xml_factory import OptionResponseXMLFactory
|
||||
from capa.tests.response_xml_factory import OptionResponseXMLFactory
|
||||
from lms.djangoapps.courseware.masquerade import (
|
||||
MASQUERADE_SETTINGS_KEY,
|
||||
CourseMasquerade,
|
||||
|
||||
@@ -39,8 +39,8 @@ from xblock.fields import ScopeIds # lint-amnesty, pylint: disable=wrong-import
|
||||
from xblock.runtime import DictKeyValueStore, KvsFieldData, Runtime # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xblock.test.tools import TestRuntime # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
from xmodule.capa.tests.response_xml_factory import OptionResponseXMLFactory # lint-amnesty, pylint: disable=reimported
|
||||
from xmodule.capa.xqueue_interface import XQueueInterface
|
||||
from capa.tests.response_xml_factory import OptionResponseXMLFactory # lint-amnesty, pylint: disable=reimported
|
||||
from capa.xqueue_interface import XQueueInterface
|
||||
from xmodule.capa_module import ProblemBlock
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.html_module import AboutBlock, CourseInfoBlock, HtmlBlock, StaticTabBlock
|
||||
|
||||
@@ -22,13 +22,13 @@ from django.urls import reverse
|
||||
from django.utils.timezone import now
|
||||
from submissions import api as submissions_api
|
||||
|
||||
from xmodule.capa.tests.response_xml_factory import (
|
||||
from capa.tests.response_xml_factory import (
|
||||
CodeResponseXMLFactory,
|
||||
CustomResponseXMLFactory,
|
||||
OptionResponseXMLFactory,
|
||||
SchematicResponseXMLFactory
|
||||
)
|
||||
from xmodule.capa.xqueue_interface import XQueueInterface
|
||||
from 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
|
||||
|
||||
@@ -12,6 +12,7 @@ from urllib.parse import quote, urlencode
|
||||
from uuid import uuid4
|
||||
|
||||
import ddt
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from completion.test_utils import CompletionWaffleTestMixin
|
||||
from crum import set_current_request
|
||||
from django.conf import settings
|
||||
@@ -30,7 +31,6 @@ from rest_framework import status
|
||||
from web_fragments.fragment import Fragment
|
||||
from xblock.core import XBlock
|
||||
from xblock.fields import Scope, String
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from xmodule.data import CertificatesDisplayBehaviors
|
||||
from xmodule.graders import ShowCorrectness
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
@@ -2207,7 +2207,7 @@ class GenerateUserCertTests(ModuleStoreTestCase):
|
||||
def test_user_with_passing_grade(self, mock_is_course_passed): # lint-amnesty, pylint: disable=unused-argument
|
||||
# If user has above passing grading then json will return cert generating message and
|
||||
# status valid code
|
||||
with patch('xmodule.capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_send_to_queue:
|
||||
with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_send_to_queue:
|
||||
mock_send_to_queue.return_value = (0, "Successfully queued")
|
||||
|
||||
resp = self.client.post(self.url)
|
||||
|
||||
@@ -8,10 +8,11 @@ from datetime import datetime
|
||||
import ddt
|
||||
from django.urls import reverse
|
||||
from pytz import UTC
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from common.djangoapps.student.tests.factories import GlobalStaffFactory
|
||||
from common.djangoapps.student.tests.factories import StaffFactory
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user