refactor!: move common/lib/capa/capa to xmodule/capa
As part of dissolving our sub-projects in edx-platform, we are moving this package under the xmodule directory. We have fixed all the occurences of import of this package and also fixed all documents related references. This might break your platform if you have any reference of `import capa` or `from capa import` in your codebase or in any Xblock. Ref: https://openedx.atlassian.net/browse/BOM-2582
This commit is contained in:
@@ -4,7 +4,6 @@ data_file = reports/${TEST_SUITE}.coverage
|
||||
source =
|
||||
cms
|
||||
common/djangoapps
|
||||
common/lib/capa
|
||||
lms
|
||||
openedx
|
||||
pavelib
|
||||
|
||||
@@ -4,7 +4,6 @@ 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
|
||||
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
|
||||
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
|
||||
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,12 +261,6 @@
|
||||
]
|
||||
},
|
||||
"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,7 +31,6 @@ jobs:
|
||||
"cms-2",
|
||||
"common-1",
|
||||
"common-2",
|
||||
"common-3",
|
||||
"xmodule-1"
|
||||
]
|
||||
|
||||
@@ -62,7 +61,7 @@ jobs:
|
||||
- name: install requirements
|
||||
run: |
|
||||
sudo pip install -r requirements/pip.txt
|
||||
sudo pip install -r requirements/edx/testing.txt
|
||||
sudo pip install --exists-action='w' -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 -r requirements/edx/testing.txt
|
||||
sudo pip install --exists-action='w' -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: 'capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
# .. setting_default: 'xmodule.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 = 'capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = 'xmodule.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
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# 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
|
||||
# common/lib/capa/capa/templates
|
||||
# xmodule/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: common/lib/capa/capa/templates/**.html]
|
||||
[mako: xmodule/capa/templates/**.html]
|
||||
input_encoding = utf-8
|
||||
[mako: openedx/**/templates/**.html]
|
||||
input_encoding = utf-8
|
||||
|
||||
@@ -20,7 +20,6 @@ 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
|
||||
@@ -221,7 +220,6 @@ autodoc_mock_imports = [
|
||||
# the generated *.rst files
|
||||
modules = {
|
||||
'cms': 'cms',
|
||||
'common/lib/capa/capa': 'common/lib/capa',
|
||||
'lms': 'lms',
|
||||
'openedx': 'openedx',
|
||||
'xmodule': 'xmodule',
|
||||
|
||||
@@ -7,5 +7,3 @@ 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 ``common/lib/capa/capa/tests``.
|
||||
located in ``xmodule/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
|
||||
``common/lib/capa/capa/tests/response_xml_factory.py`` because the
|
||||
``xmodule/capa/tests/response_xml_factory.py`` because the
|
||||
``capa`` package handles problem XML.
|
||||
|
||||
.. _FactoryBoy: https://readthedocs.org/projects/factoryboy/
|
||||
|
||||
@@ -19,13 +19,12 @@ 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 capa.xqueue_interface import XQueueService # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.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,16 +7,15 @@ 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 capa.tests.response_xml_factory import OptionResponseXMLFactory
|
||||
from xmodule.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 capa.tests.response_xml_factory import OptionResponseXMLFactory # lint-amnesty, pylint: disable=reimported
|
||||
from capa.xqueue_interface import XQueueInterface
|
||||
from xmodule.capa.tests.response_xml_factory import OptionResponseXMLFactory # lint-amnesty, pylint: disable=reimported
|
||||
from xmodule.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 capa.tests.response_xml_factory import (
|
||||
from xmodule.capa.tests.response_xml_factory import (
|
||||
CodeResponseXMLFactory,
|
||||
CustomResponseXMLFactory,
|
||||
OptionResponseXMLFactory,
|
||||
SchematicResponseXMLFactory
|
||||
)
|
||||
from capa.xqueue_interface import XQueueInterface
|
||||
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
|
||||
|
||||
@@ -12,7 +12,6 @@ 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
|
||||
@@ -31,6 +30,7 @@ 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('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_send_to_queue:
|
||||
with patch('xmodule.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,11 +8,10 @@ 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
|
||||
|
||||
@@ -4,10 +4,10 @@ Base file for Grades tests
|
||||
|
||||
|
||||
from crum import set_current_request
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from lms.djangoapps.course_blocks.api import get_course_blocks
|
||||
|
||||
@@ -5,7 +5,7 @@ Test grading with access changes.
|
||||
|
||||
from crum import set_current_request
|
||||
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from lms.djangoapps.course_blocks.api import get_course_blocks
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import patch
|
||||
|
||||
from crum import set_current_request
|
||||
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from lms.djangoapps.courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin
|
||||
|
||||
@@ -5,8 +5,6 @@ import itertools
|
||||
import ddt
|
||||
import pytz
|
||||
from crum import set_current_request
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
|
||||
from xmodule.graders import ProblemScore
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import (
|
||||
@@ -15,6 +13,7 @@ from xmodule.modulestore.tests.django_utils import (
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.utils import TEST_DATA_DIR
|
||||
from xmodule.modulestore.xml_importer import import_course_from_xml
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from common.djangoapps.student.models import CourseEnrollment
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from lms.djangoapps.course_blocks.api import get_course_blocks
|
||||
|
||||
@@ -9,7 +9,6 @@ from unittest.mock import patch
|
||||
|
||||
import ddt
|
||||
import pytest
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from crum import set_current_request
|
||||
from django.conf import settings
|
||||
@@ -20,6 +19,7 @@ from submissions import api as sub_api
|
||||
|
||||
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.models import CourseEnrollment, CourseEnrollmentAllowed, anonymous_id_for_user
|
||||
from common.djangoapps.student.roles import CourseCcxCoachRole
|
||||
from common.djangoapps.student.tests.factories import AdminFactory, UserFactory
|
||||
|
||||
@@ -3,7 +3,7 @@ Tests of the instructor dashboard spoc gradebook
|
||||
"""
|
||||
from django.urls import reverse
|
||||
|
||||
from capa.tests.response_xml_factory import StringResponseXMLFactory
|
||||
from xmodule.capa.tests.response_xml_factory import StringResponseXMLFactory
|
||||
from common.djangoapps.student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory
|
||||
from lms.djangoapps.courseware.tests.factories import StudentModuleFactory
|
||||
from lms.djangoapps.grades.api import task_compute_all_grades_for_course
|
||||
|
||||
@@ -12,7 +12,7 @@ from opaque_keys.edx.keys import UsageKey
|
||||
from xblock.runtime import KvsFieldData
|
||||
from xblock.scorable import Score
|
||||
|
||||
from capa.responsetypes import LoncapaProblemError, ResponseError, StudentInputError
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError, ResponseError, StudentInputError
|
||||
from common.djangoapps.student.models import get_user_by_username_or_email
|
||||
from common.djangoapps.track.event_transaction_utils import create_new_event_transaction_id, set_event_transaction_type
|
||||
from common.djangoapps.track.views import task_track
|
||||
|
||||
@@ -13,7 +13,6 @@ from unittest.mock import Mock, patch
|
||||
from uuid import uuid4
|
||||
|
||||
import unicodecsv
|
||||
from capa.tests.response_xml_factory import OptionResponseXMLFactory
|
||||
from celery.states import FAILURE, SUCCESS
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.urls import reverse
|
||||
@@ -24,6 +23,7 @@ from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.capa.tests.response_xml_factory import OptionResponseXMLFactory
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from lms.djangoapps.courseware.model_data import StudentModule
|
||||
from lms.djangoapps.courseware.tests.tests import LoginEnrollmentTestCase
|
||||
|
||||
@@ -20,8 +20,8 @@ from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imp
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
|
||||
from capa.responsetypes import StudentInputError
|
||||
from capa.tests.response_xml_factory import CodeResponseXMLFactory, CustomResponseXMLFactory
|
||||
from xmodule.capa.responsetypes import StudentInputError
|
||||
from xmodule.capa.tests.response_xml_factory import CodeResponseXMLFactory, CustomResponseXMLFactory
|
||||
from lms.djangoapps.courseware.model_data import StudentModule
|
||||
from lms.djangoapps.grades.api import CourseGradeFactory
|
||||
from lms.djangoapps.instructor_task.api import (
|
||||
@@ -273,7 +273,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
self.submit_student_answer('u1', problem_url_name, [OPTION_1, OPTION_1])
|
||||
|
||||
expected_message = "bad things happened"
|
||||
with patch('capa.capa_problem.LoncapaProblem.get_grade_from_current_answers') as mock_rescore:
|
||||
with patch('xmodule.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(
|
||||
@@ -293,7 +293,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
|
||||
# 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('capa.capa_problem.LoncapaProblem.get_grade_from_current_answers') as mock_rescore:
|
||||
with patch('xmodule.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)
|
||||
|
||||
@@ -332,7 +332,7 @@ class TestRescoringTask(TestIntegrationTask):
|
||||
problem_url_name = 'H1P2'
|
||||
self.define_code_response_problem(problem_url_name)
|
||||
# we fully create the CodeResponse problem, but just pretend that we're queuing it:
|
||||
with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_send_to_queue:
|
||||
with patch('xmodule.capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_send_to_queue:
|
||||
mock_send_to_queue.return_value = (0, "Successfully queued")
|
||||
self.submit_student_answer('u1', problem_url_name, ["answer1", "answer2"])
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from freezegun import freeze_time
|
||||
from pytz import UTC
|
||||
|
||||
import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api
|
||||
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
@@ -2488,7 +2488,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
|
||||
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task') as mock_current_task:
|
||||
mock_current_task.return_value = current_task
|
||||
with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_queue:
|
||||
with patch('xmodule.capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_queue:
|
||||
mock_queue.return_value = (0, "Successfully queued")
|
||||
result = generate_students_certificates(
|
||||
None, None, self.course.id, task_input, 'certificates generated'
|
||||
|
||||
@@ -1080,6 +1080,7 @@ PROJECT_ROOT = path(__file__).abspath().dirname().dirname() # /edx-platform/lms
|
||||
REPO_ROOT = PROJECT_ROOT.dirname()
|
||||
COMMON_ROOT = REPO_ROOT / "common"
|
||||
OPENEDX_ROOT = REPO_ROOT / "openedx"
|
||||
XMODULE_ROOT = REPO_ROOT / "xmodule"
|
||||
ENV_ROOT = REPO_ROOT.dirname() # virtualenv dir /edx-platform is in
|
||||
COURSES_ROOT = ENV_ROOT / "data"
|
||||
NODE_MODULES_ROOT = REPO_ROOT / "node_modules"
|
||||
@@ -1211,7 +1212,7 @@ MAKO_MODULE_DIR = os.path.join(tempfile.gettempdir(), 'mako_lms')
|
||||
MAKO_TEMPLATE_DIRS_BASE = [
|
||||
PROJECT_ROOT / 'templates',
|
||||
COMMON_ROOT / 'templates',
|
||||
COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
|
||||
XMODULE_ROOT / 'capa' / 'templates',
|
||||
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
|
||||
OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates',
|
||||
OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates',
|
||||
@@ -1270,7 +1271,7 @@ TEMPLATES = [
|
||||
'DIRS': [
|
||||
PROJECT_ROOT / "templates",
|
||||
COMMON_ROOT / 'templates',
|
||||
COMMON_ROOT / 'lib' / 'capa' / 'capa' / 'templates',
|
||||
XMODULE_ROOT / 'capa' / 'templates',
|
||||
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
|
||||
COMMON_ROOT / 'static', # required to statically include common Underscore templates
|
||||
],
|
||||
@@ -1702,10 +1703,10 @@ COURSES_WITH_UNSAFE_CODE = []
|
||||
# Cojail REST service
|
||||
ENABLE_CODEJAIL_REST_SERVICE = False
|
||||
# .. setting_name: CODE_JAIL_REST_SERVICE_REMOTE_EXEC
|
||||
# .. setting_default: 'common.lib.capa.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
# .. setting_default: 'xmodule.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 = 'common.lib.capa.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
|
||||
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = 'xmodule.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
|
||||
|
||||
@@ -12,7 +12,7 @@ from edxval.api import ValInternalError
|
||||
from lxml.etree import XMLSyntaxError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from capa.responsetypes import LoncapaProblemError
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
from openedx.core.djangoapps.content.block_structure import api
|
||||
from openedx.core.djangoapps.content.block_structure.config import enable_storage_backing_for_cache_in_request
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#
|
||||
-e git+https://github.com/openedx/blockstore.git@1.2.1#egg=blockstore==1.2.1
|
||||
# via -r requirements/edx/github.in
|
||||
-e common/lib/capa
|
||||
# via -r requirements/edx/local.in
|
||||
-e git+https://github.com/edx/codejail.git@3.1.3#egg=codejail==3.1.3
|
||||
# via -r requirements/edx/github.in
|
||||
-e git+https://github.com/edx/django-wiki.git@1.1.0#egg=django-wiki
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#
|
||||
-e git+https://github.com/openedx/blockstore.git@1.2.1#egg=blockstore==1.2.1
|
||||
# via -r requirements/edx/testing.txt
|
||||
-e common/lib/capa
|
||||
# via -r requirements/edx/testing.txt
|
||||
-e git+https://github.com/edx/codejail.git@3.1.3#egg=codejail==3.1.3
|
||||
# via -r requirements/edx/testing.txt
|
||||
-e git+https://github.com/edx/django-wiki.git@1.1.0#egg=django-wiki
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# Python libraries to install that are local to the edx-platform repo
|
||||
-e .
|
||||
-e common/lib/capa
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#
|
||||
-e git+https://github.com/openedx/blockstore.git@1.2.1#egg=blockstore==1.2.1
|
||||
# via -r requirements/edx/base.txt
|
||||
-e common/lib/capa
|
||||
# via -r requirements/edx/base.txt
|
||||
-e git+https://github.com/edx/codejail.git@3.1.3#egg=codejail==3.1.3
|
||||
# via -r requirements/edx/base.txt
|
||||
-e git+https://github.com/edx/django-wiki.git@1.1.0#egg=django-wiki
|
||||
|
||||
@@ -27,7 +27,7 @@ exclude=''
|
||||
exclude+='^\.$'
|
||||
|
||||
# Exclude test data that includes Python (do NOT exclude unit test source code, though).
|
||||
exclude+='|^common/lib/capa/capa/safe_exec/tests/test_files/?.*$'
|
||||
exclude+='|^xmodule/capa/safe_exec/tests/test_files/?.*$'
|
||||
exclude+='|^common/test/data/?.*$'
|
||||
|
||||
# Exclude common/lib and its immediate child directories.
|
||||
@@ -38,7 +38,6 @@ exclude+='|^common/test/data/?.*$'
|
||||
# * common/lib/capa -> EXCLUDE from check.
|
||||
# * common/lib/capa/capa/safe_exec -> INCLUDE in check.
|
||||
exclude+='|^common/lib$'
|
||||
exclude+='|^common/lib/capa$'
|
||||
|
||||
# xmodule data folder
|
||||
exclude+='|^xmodule/tests/data/xml-course-root/capa$'
|
||||
|
||||
@@ -27,13 +27,13 @@ import six
|
||||
from lxml import etree
|
||||
from pytz import UTC
|
||||
|
||||
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
|
||||
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
|
||||
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 capa.capa_problem import LoncapaProblem
|
||||
from xmodule.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 capa.xqueue_interface import XQUEUE_TIMEOUT
|
||||
from xmodule.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 capa.safe_exec as safe_exec
|
||||
import capa.xqueue_interface as xqueue_interface
|
||||
import xmodule.capa.safe_exec as safe_exec
|
||||
import xmodule.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 .exceptions import CodejailServiceParseError, CodejailServiceStatusError, CodejailServiceUnavailable
|
||||
from django.utils.translation import gettext as _
|
||||
from .exceptions import CodejailServiceParseError, CodejailServiceStatusError, CodejailServiceUnavailable
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from capa.safe_exec.lazymod import LazyModule
|
||||
from xmodule.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 capa.safe_exec import safe_exec, update_hash
|
||||
from xmodule.capa.safe_exec import safe_exec, update_hash
|
||||
|
||||
|
||||
class TestSafeExec(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from capa.util import remove_markup %>
|
||||
<%! from xmodule.capa.util import remove_markup %>
|
||||
<div id="chemicalequationinput_${id}" class="chemicalequationinput">
|
||||
<div class="script_placeholder" data-src="${previewer}"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from capa.util import remove_markup
|
||||
<%! from xmodule.capa.util import remove_markup
|
||||
from django.utils.translation import ugettext as _
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
%>
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from capa.util import remove_markup %>
|
||||
<%! from xmodule.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 capa.capa_problem import LoncapaProblem, LoncapaSystem
|
||||
from capa.inputtypes import Status
|
||||
from xmodule.capa.capa_problem import LoncapaProblem, LoncapaSystem
|
||||
from xmodule.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 capa.responsetypes import LoncapaProblemError
|
||||
from capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
from xmodule.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 capa.responsetypes import LoncapaProblemError
|
||||
from capa.tests.helpers import new_loncapa_problem
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
from xmodule.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 capa.correctmap import CorrectMap
|
||||
from xmodule.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 self.cmap.get_dict() == {}
|
||||
assert not self.cmap.get_dict()
|
||||
@@ -5,8 +5,8 @@ import xml.sax.saxutils as saxutils
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from capa import customrender
|
||||
from capa.tests.helpers import test_capa_system
|
||||
from xmodule.capa import customrender
|
||||
from xmodule.capa.tests.helpers import test_capa_system
|
||||
|
||||
# just a handy shortcut
|
||||
lookup_tag = customrender.registry.get_class_for_tag
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user