Work in progress to sandbox the uses of eval in LMS.

This commit is contained in:
Ned Batchelder
2013-02-14 10:17:07 -05:00
parent 0a6761c9a5
commit 33abe54e0d
5 changed files with 147 additions and 56 deletions

View File

@@ -986,7 +986,7 @@ class TestSchematicResponse(TestSubmittingProblems):
return resp
def test_get_graded(self):
resp = self.submit_question_answer('H1P1',
resp = self.submit_question_answer('schematic_problem',
[['transient', {'Z': [
[0.0000004, 2.8],
[0.0000009, 2.8],
@@ -1001,8 +1001,8 @@ class TestSchematicResponse(TestSubmittingProblems):
respdata = json.loads(resp.content)
self.assertEqual(respdata['success'], 'correct')
self.reset_question_answer('H1P1')
resp = self.submit_question_answer('H1P1',
self.reset_question_answer('schematic_problem')
resp = self.submit_question_answer('schematic_problem',
[['transient', {'Z': [
[0.0000004, 2.8],
[0.0000009, 0.0], # wrong.
@@ -1016,3 +1016,31 @@ class TestSchematicResponse(TestSubmittingProblems):
)
respdata = json.loads(resp.content)
self.assertEqual(respdata['success'], 'incorrect')
@override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE)
class TestCustomResponseCfnFunction(TestSubmittingProblems):
"""Check that cfn functions work properly."""
course_slug = "embedded_python"
course_when = "2013_Spring"
def submit_question_answer(self, problem_url_name, responses):
"""Particular to the embedded_python/2013_Spring course."""
problem_location = self.problem_location(problem_url_name)
modx_url = self.modx_url(problem_location, 'problem_check')
resp = self.client.post(modx_url, {
'input_i4x-edX-embedded_python-problem-{0}_2_1'.format(problem_url_name): responses,
})
return resp
def test_get_graded(self):
resp = self.submit_question_answer('cfn_problem', "0, 1, 2, 3, 4, 5, 'Outside of loop', 6")
respdata = json.loads(resp.content)
self.assertEqual(respdata['success'], 'correct')
self.reset_question_answer('cfn_problem')
resp = self.submit_question_answer('cfn_problem', "xyzzy!")
respdata = json.loads(resp.content)
self.assertEqual(respdata['success'], 'incorrect')