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
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def assertXmlEqual(self, xml_str_a: str, xml_str_b: str) -> None:
# OLX attributes that will appear on capa problems when saved/exported. Excludes "markdown"
standard_capa_attributes = """
markdown_edited="false"
matlab_api_key="null"
name="null"
rerandomize="never"
source_code="null"
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tests/test_export_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_dirty_repo(self):
self.course_block.giturl, self.user)

# Make arbitrary change to course to make diff
self.course_block.matlab_api_key = 'something'
self.course_block.display_name = 'something'
modulestore().update_item(self.course_block, self.user.id)
# Touch a file in the directory, export again, and make sure
# the test file is gone
Expand Down
8 changes: 0 additions & 8 deletions cms/envs/mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -792,14 +792,6 @@ XBLOCK_SETTINGS:
ScormXBlock:
S3_BUCKET_NAME: scorm
STORAGE_FUNC: storage.s3
XQUEUE_INTERFACE:
basic_auth:
- user
- pass
django_auth:
password: pass
username: user
url: https://xqueue.localhost
YOUTUBE_API_KEY: test_youtube
ZENDESK_API_KEY: test_zendesk
ZENDESK_CUSTOM_FIELDS:
Expand Down
10 changes: 5 additions & 5 deletions cms/lib/xblock/test/test_upstream_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def setUp(self):
' force_save_button="false"'
' graceperiod="1d"'
' grading_method="last_attempt"'
' matlab_api_key="abc"'
' max_attempts="10"'
' rerandomize=""always""'
' show_correctness="never"'
' show_reset_button="false"'
' showanswer="on_correct"'
' source_code="abc"'
' submission_wait_seconds="10"'
' use_latex_compiler="false"'
' weight="1"'
Expand Down Expand Up @@ -250,7 +250,7 @@ def test_sync_updates_to_downstream_only_fields(self):
assert downstream.upstream_display_name == "Upstream Problem Title V2"
assert downstream.display_name == "Upstream Problem Title V2"
assert downstream.rerandomize == '"always"'
assert downstream.matlab_api_key == 'abc'
assert downstream.source_code == 'abc'
assert not downstream.use_latex_compiler

# These fields are "downstream only", so field defaults are preserved, and values are NOT copied from upstream
Expand All @@ -275,12 +275,12 @@ def test_sync_updates_to_downstream_only_fields(self):
' force_save_button="false"'
' graceperiod=""'
' grading_method="final_attempt"'
' matlab_api_key="def"'
' max_attempts="11"'
' rerandomize=""per_student""'
' show_correctness="past_due"'
' show_reset_button="false"'
' showanswer="attempted"'
' source_code="def"'
' submission_wait_seconds="11"'
' use_latex_compiler="true"'
' weight="2"'
Expand All @@ -304,7 +304,7 @@ def test_sync_updates_to_downstream_only_fields(self):

# Modifying synchronized fields are "unsafe" customizations
downstream.rerandomize = '"onreset"'
downstream.matlab_api_key = 'hij'
downstream.source_code = 'hij'
save_xblock_with_callback(downstream, self.user)

# Follow-up sync.
Expand All @@ -313,7 +313,7 @@ def test_sync_updates_to_downstream_only_fields(self):
# "unsafe" customizations are overridden by upstream
assert downstream.upstream_display_name == "Upstream Problem Title V3"
assert downstream.rerandomize == '"per_student"'
assert downstream.matlab_api_key == 'def'
assert downstream.source_code == 'def'
assert downstream.use_latex_compiler

# but "safe" customizations survive
Expand Down
6 changes: 3 additions & 3 deletions cms/templates/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 class="title">${_("About Exporting Courses")}</h2>
<p>${_("You can export courses and edit them outside of {studio_name}. The exported file is a .tar.gz file (that is, a .tar file compressed with GNU Zip) that contains the course structure and content. You can also re-import courses that you've exported.").format(
studio_name=settings.STUDIO_SHORT_NAME
)}</p>
<p>${Text(_("{em_start}Caution:{em_end} When you export a course, information such as MATLAB API keys, LTI passports, annotation secret token strings, and annotation storage URLs are included in the exported data. If you share your exported files, you may also be sharing sensitive or license-specific information.")).format(
<p>${Text(_("{em_start}Caution:{em_end} When you export a course, information such as LTI passports, annotation secret token strings, and annotation storage URLs are included in the exported data. If you share your exported files, you may also be sharing sensitive or license-specific information.")).format(
em_start=HTML('<strong>'),
em_end=HTML("</strong>")
)}</p>
Expand Down Expand Up @@ -151,7 +151,7 @@ <h3 class="title-3">
em_end=HTML("</strong>")
)}</h3>
<ul class="list-details list-export-includes">
<li class="item-detail">${_("Values from Advanced Settings, including MATLAB API keys and LTI passports")}</li>
<li class="item-detail">${_("Values from Advanced Settings, including LTI passports")}</li>
<li class="item-detail">${_("Course Content (all Sections, Sub-sections, and Units)")}</li>
<li class="item-detail">${_("Course Structure")}</li>
<li class="item-detail">${_("Individual Problems")}</li>
Expand Down Expand Up @@ -192,7 +192,7 @@ <h3 class="title-3">${_("What content is exported?")}</h3>
<li>${_("Course dates")}</li>
<li>${_("Grading policy")}</li>
<li>${_("Any group configurations")}</li>
<li>${_("Settings on the Advanced Settings page, including MATLAB API keys and LTI passports")}</li>
<li>${_("Settings on the Advanced Settings page, including LTI passports")}</li>
</ul>
<p>${_("The following content is not exported.")}</p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion cms/templates/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ <h3 class="title-3">${_("What content is imported?")}</h3>
<li>${_("Course dates")}</li>
<li>${_("Grading policy")}</li>
<li>${_("Any group configurations")}</li>
<li>${_("Settings on the Advanced Settings page, including MATLAB API keys and LTI passports")}</li>
<li>${_("Settings on the Advanced Settings page, including LTI passports")}</li>
</ul>
<p>${_("The following content is not imported.")}</p>
<ul>
Expand Down
44 changes: 1 addition & 43 deletions lms/djangoapps/courseware/block_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.contrib.auth.models import AnonymousUser, User # pylint: disable=imported-auth-user
from django.core.cache import cache
from django.db import transaction
from django.http import Http404, HttpResponse, HttpResponseForbidden
from django.http import Http404, HttpResponseForbidden
from django.middleware.csrf import CsrfViewMiddleware
from django.template.context_processors import csrf
from django.urls import reverse
Expand Down Expand Up @@ -690,48 +690,6 @@ def load_single_xblock(request, user_id, course_id, usage_key_string, course=Non


@csrf_exempt
def xqueue_callback(request, course_id, userid, mod_id, dispatch):
'''
Entry point for graded results from the queueing system.
'''
data = request.POST.copy()

# Test xqueue package, which we expect to be:
# xpackage = {'xqueue_header': json.dumps({'lms_key':'secretkey',...}),
# 'xqueue_body' : 'Message from grader'}
for key in ['xqueue_header', 'xqueue_body']:
if key not in data:
raise Http404

header = json.loads(data['xqueue_header'])
if not isinstance(header, dict) or 'lms_key' not in header:
raise Http404

course_key = CourseKey.from_string(course_id)

with modulestore().bulk_operations(course_key):
course = modulestore().get_course(course_key, depth=0)

instance = load_single_xblock(request, userid, course_id, mod_id, course=course)

# Transfer 'queuekey' from xqueue response header to the data.
# This is required to use the interface defined by 'handle_ajax'
data.update({'queuekey': header['lms_key']})

# We go through the "AJAX" path
# So far, the only dispatch from xqueue will be 'score_update'
try:
# Can ignore the return value--not used for xqueue_callback
instance.handle_ajax(dispatch, data)
# Save any state that has changed to the underlying KeyValueStore
instance.save()
except:
log.exception("error processing ajax call")
raise

return HttpResponse("")


@csrf_exempt
@xframe_options_exempt
@transaction.non_atomic_requests
Expand Down
80 changes: 0 additions & 80 deletions lms/djangoapps/courseware/tests/test_block_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,6 @@ def setUp(self):
# Construct a mock block for the modulestore to return
self.mock_block = MagicMock()
self.mock_block.id = 1
self.dispatch = 'score_update'

# Construct a 'standard' xqueue_callback url
self.callback_url = reverse(
'xqueue_callback',
kwargs=dict(
course_id=str(self.course_key),
userid=str(self.mock_user.id),
mod_id=self.mock_block.id,
dispatch=self.dispatch
)
)

def tearDown(self):
OverrideFieldData.provider_classes = None
Expand Down Expand Up @@ -317,63 +305,6 @@ def test_block_render_with_jump_to_id(self):
# note if the URL mapping changes then this assertion will break
assert '/courses/' + str(self.course_key) + '/jump_to_id/vertical_test' in html

def test_xqueue_callback_success(self):
"""
Test for happy-path xqueue_callback
"""
fake_key = 'fake key'
xqueue_header = json.dumps({'lms_key': fake_key})
data = {
'xqueue_header': xqueue_header,
'xqueue_body': 'hello world',
}

# Patch getmodule to return our mock block
with patch('lms.djangoapps.courseware.block_render.load_single_xblock', return_value=self.mock_block):
# call xqueue_callback with our mocked information
request = self.request_factory.post(self.callback_url, data)
render.xqueue_callback(
request,
str(self.course_key),
self.mock_user.id,
self.mock_block.id,
self.dispatch
)

# Verify that handle ajax is called with the correct data
request.POST._mutable = True # pylint: disable=protected-access
request.POST['queuekey'] = fake_key
self.mock_block.handle_ajax.assert_called_once_with(self.dispatch, request.POST)

def test_xqueue_callback_missing_header_info(self):
data = {
'xqueue_header': '{}',
'xqueue_body': 'hello world',
}

with patch('lms.djangoapps.courseware.block_render.load_single_xblock', return_value=self.mock_block):
# Test with missing xqueue data
with pytest.raises(Http404): # noqa: PT012
request = self.request_factory.post(self.callback_url, {})
render.xqueue_callback(
request,
str(self.course_key),
self.mock_user.id,
self.mock_block.id,
self.dispatch
)

# Test with missing xqueue_header
with pytest.raises(Http404): # noqa: PT012
request = self.request_factory.post(self.callback_url, data)
render.xqueue_callback(
request,
str(self.course_key),
self.mock_user.id,
self.mock_block.id,
self.dispatch
)

def _get_dispatch_url(self):
"""Helper to get dispatch URL for testing xblock callback."""
return reverse(
Expand Down Expand Up @@ -612,17 +543,6 @@ def setUp(self):
# Construct a mock block for the modulestore to return
self.mock_block = MagicMock()
self.mock_block.id = 1
self.dispatch = 'score_update'

# Construct a 'standard' xqueue_callback url
self.callback_url = reverse(
'xqueue_callback', kwargs={
'course_id': str(self.course_key),
'userid': str(self.mock_user.id),
'mod_id': self.mock_block.id,
'dispatch': self.dispatch
}
)

def _mock_file(self, name='file', size=10):
"""Create a mock file object for testing uploads"""
Expand Down
15 changes: 7 additions & 8 deletions lms/djangoapps/courseware/tests/test_submitting_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
OptionResponseXMLFactory,
SchematicResponseXMLFactory,
)
from xblock_problem.capa.xqueue_interface import XQueueInterface
from xblock_problem.capa.xqueue_submission import XQueueInterfaceSubmission

from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.models import CourseEnrollment, anonymous_id_for_user
Expand Down Expand Up @@ -789,7 +789,7 @@ def problem_setup(self, name, files):
# re-fetch the course from the database so the object is up to date
self.refresh_course()

@patch.object(XQueueInterface, '_http_post')
@patch.object(XQueueInterfaceSubmission, 'send_to_submission')
def test_three_files(self, mock_xqueue_post):
# Open the test files, and arrange to close them later.
filenames = "prog1.py prog2.py prog3.py"
Expand All @@ -801,19 +801,18 @@ def test_three_files(self, mock_xqueue_post):
self.addCleanup(fileobj.close)

self.problem_setup("the_problem", filenames)
mock_xqueue_post.return_value = (0, "ok")
mock_xqueue_post.return_value = {}
resp = self.submit_question_answer("the_problem", {'2_1': fileobjs})

assert resp.status_code == 200
json_resp = json.loads(resp.content.decode('utf-8'))
assert json_resp['success'] == 'incorrect'

# See how post got called.
# See how the hand-off to edx-submissions got called: header, body, queue key, files.
assert mock_xqueue_post.call_count == 1
args, kwargs = mock_xqueue_post.call_args
assert len(args) == 2
assert args[0].endswith('/submit/')
self.assertEqual(list(kwargs['files'].keys()), filenames.split()) # noqa: PT009
args, _ = mock_xqueue_post.call_args
assert len(args) == 4
self.assertEqual(list(args[3].keys()), filenames.split()) # noqa: PT009


@UseUnsafeCodejail()
Expand Down
8 changes: 0 additions & 8 deletions lms/envs/mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1218,14 +1218,6 @@ XBLOCK_SETTINGS:
ScormXBlock:
S3_BUCKET_NAME: scorm
STORAGE_FUNC: openedxscorm.storage.s3
XQUEUE_INTERFACE:
basic_auth:
- user
- pass
django_auth:
password: pass
username: user
url: http://localhost:18040
X_FRAME_OPTIONS: DENY
YOUTUBE_API_KEY: test_youtube_api_key
ZENDESK_API_KEY: ''
Expand Down
8 changes: 0 additions & 8 deletions lms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
USE_I18N = True
LANGUAGE_CODE = 'en' # tests assume they will get English.

XQUEUE_INTERFACE = {
"url": "http://sandbox-xqueue.edx.org",
"django_auth": {
"username": "lms",
"password": "***REMOVED***"
},
"basic_auth": ('anant', 'agarwal'),
}
XQUEUE_WAITTIME_BETWEEN_REQUESTS = 5 # seconds

# Don't rely on a real staff grading backend
Expand Down
17 changes: 0 additions & 17 deletions lms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
handle_xblock_callback,
handle_xblock_callback_noauth,
xblock_view,
xqueue_callback,
)
from lms.djangoapps.courseware.masquerade import MasqueradeView
from lms.djangoapps.courseware.views import views as courseware_views
Expand Down Expand Up @@ -354,22 +353,6 @@
path('', include(('openedx.core.djangoapps.xblock.rest_api.urls', 'openedx.core.djangoapps.xblock'),
namespace='xblock_api')),

re_path(
r'^courses/{}/xqueue/(?P<userid>[^/]*)/(?P<mod_id>.*?)/(?P<dispatch>[^/]*)$'.format( # noqa: UP032
settings.COURSE_ID_PATTERN,
),
xqueue_callback,
name='xqueue_callback',
),

re_path(
r'^courses/{}/xqueue/(?P<userid>[^/]*)/(?P<mod_id>.*?)/(?P<dispatch>[^/]*)$'.format( # noqa: UP032
settings.COURSE_ID_PATTERN,
),
xqueue_callback,
name='callback_submission',
),

# TODO: These views need to be updated before they work
path('calculate', util_views.calculate),

Expand Down
1 change: 0 additions & 1 deletion openedx/core/djangoapps/xblock/runtime/shims.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def xqueue(self):
# TODO: Refactor capa to access this directly, don't bother the runtime. Then remove it from here.
return {
'interface': None,
'construct_callback': None,
'default_queuename': None,
'waittime': 5, # seconds; should come from settings.XQUEUE_WAITTIME_BETWEEN_REQUESTS
}
Expand Down
Loading
Loading