Add in some comments
This commit is contained in:
@@ -35,6 +35,9 @@ OpenEndedModule
|
|||||||
|
|
||||||
|
|
||||||
class OpenEndedChildTest(unittest.TestCase):
|
class OpenEndedChildTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test the open ended child class
|
||||||
|
"""
|
||||||
location = Location(["i4x", "edX", "sa_test", "selfassessment",
|
location = Location(["i4x", "edX", "sa_test", "selfassessment",
|
||||||
"SampleQuestion"])
|
"SampleQuestion"])
|
||||||
|
|
||||||
@@ -150,6 +153,9 @@ class OpenEndedChildTest(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class OpenEndedModuleTest(unittest.TestCase):
|
class OpenEndedModuleTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test the open ended module class
|
||||||
|
"""
|
||||||
location = Location(["i4x", "edX", "sa_test", "selfassessment",
|
location = Location(["i4x", "edX", "sa_test", "selfassessment",
|
||||||
"SampleQuestion"])
|
"SampleQuestion"])
|
||||||
|
|
||||||
@@ -291,6 +297,9 @@ class OpenEndedModuleTest(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class CombinedOpenEndedModuleTest(unittest.TestCase):
|
class CombinedOpenEndedModuleTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for the combined open ended xmodule
|
||||||
|
"""
|
||||||
location = Location(["i4x", "edX", "open_ended", "combinedopenended",
|
location = Location(["i4x", "edX", "open_ended", "combinedopenended",
|
||||||
"SampleQuestion"])
|
"SampleQuestion"])
|
||||||
definition_template = """
|
definition_template = """
|
||||||
@@ -474,6 +483,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
|
class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
|
||||||
|
"""
|
||||||
|
Test the student flow in the combined open ended xmodule
|
||||||
|
"""
|
||||||
problem_location = Location(["i4x", "edX", "open_ended", "combinedopenended", "SampleQuestion"])
|
problem_location = Location(["i4x", "edX", "open_ended", "combinedopenended", "SampleQuestion"])
|
||||||
answer = "blah blah"
|
answer = "blah blah"
|
||||||
assessment = [0, 1]
|
assessment = [0, 1]
|
||||||
@@ -486,12 +498,23 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_open_ended_load_and_save(self):
|
def test_open_ended_load_and_save(self):
|
||||||
|
"""
|
||||||
|
See if we can load the module and save an answer
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
|
#Load the module
|
||||||
module = self.get_module_from_location(self.problem_location, COURSE)
|
module = self.get_module_from_location(self.problem_location, COURSE)
|
||||||
|
|
||||||
|
#Try saving an answer
|
||||||
module.handle_ajax("save_answer", {"student_answer": self.answer})
|
module.handle_ajax("save_answer", {"student_answer": self.answer})
|
||||||
task_one_json = json.loads(module.task_states[0])
|
task_one_json = json.loads(module.task_states[0])
|
||||||
self.assertEqual(task_one_json['child_history'][0]['answer'], self.answer)
|
self.assertEqual(task_one_json['child_history'][0]['answer'], self.answer)
|
||||||
|
|
||||||
def test_open_ended_flow_reset(self):
|
def test_open_ended_flow_reset(self):
|
||||||
|
"""
|
||||||
|
Test the flow of the module if we complete the self assessment step and then reset
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
assessment = [0, 1]
|
assessment = [0, 1]
|
||||||
module = self.get_module_from_location(self.problem_location, COURSE)
|
module = self.get_module_from_location(self.problem_location, COURSE)
|
||||||
|
|
||||||
@@ -515,7 +538,13 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
|
|||||||
module.handle_ajax("reset", {})
|
module.handle_ajax("reset", {})
|
||||||
|
|
||||||
def test_open_ended_flow_correct(self):
|
def test_open_ended_flow_correct(self):
|
||||||
|
"""
|
||||||
|
Test a two step problem where the student first goes through the self assessment step, and then the
|
||||||
|
open ended step.
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
assessment = [1, 1]
|
assessment = [1, 1]
|
||||||
|
#Load the module
|
||||||
module = self.get_module_from_location(self.problem_location, COURSE)
|
module = self.get_module_from_location(self.problem_location, COURSE)
|
||||||
|
|
||||||
#Simulate a student saving an answer
|
#Simulate a student saving an answer
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ COURSE = "open_ended"
|
|||||||
|
|
||||||
|
|
||||||
class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
|
class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
|
||||||
|
"""
|
||||||
|
Test peer grading xmodule at the unit level. More detailed tests are difficult, as the module relies on an
|
||||||
|
external grading service.
|
||||||
|
"""
|
||||||
problem_location = Location(["i4x", "edX", "open_ended", "peergrading",
|
problem_location = Location(["i4x", "edX", "open_ended", "peergrading",
|
||||||
"PeerGradingSample"])
|
"PeerGradingSample"])
|
||||||
calibrated_dict = {'location': "blah"}
|
calibrated_dict = {'location': "blah"}
|
||||||
@@ -30,50 +34,99 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
"""
|
||||||
|
Create a peer grading module from a test system
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
self.test_system = test_system()
|
self.test_system = test_system()
|
||||||
self.test_system.open_ended_grading_interface = None
|
self.test_system.open_ended_grading_interface = None
|
||||||
self.peer_grading = self.get_module_from_location(self.problem_location, COURSE)
|
self.peer_grading = self.get_module_from_location(self.problem_location, COURSE)
|
||||||
|
|
||||||
def test_module_closed(self):
|
def test_module_closed(self):
|
||||||
|
"""
|
||||||
|
Test if peer grading is closed
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
closed = self.peer_grading.closed()
|
closed = self.peer_grading.closed()
|
||||||
self.assertEqual(closed, False)
|
self.assertEqual(closed, False)
|
||||||
|
|
||||||
def test_get_html(self):
|
def test_get_html(self):
|
||||||
|
"""
|
||||||
|
Test to see if the module can be rendered
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
html = self.peer_grading.get_html()
|
html = self.peer_grading.get_html()
|
||||||
|
|
||||||
def test_get_data(self):
|
def test_get_data(self):
|
||||||
|
"""
|
||||||
|
Try getting data from the external grading service
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
success, data = self.peer_grading.query_data_for_location()
|
success, data = self.peer_grading.query_data_for_location()
|
||||||
except GradingServiceError:
|
except GradingServiceError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_get_score(self):
|
def test_get_score(self):
|
||||||
|
"""
|
||||||
|
Test getting the score
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
score = self.peer_grading.get_score()
|
score = self.peer_grading.get_score()
|
||||||
|
|
||||||
def test_get_max_score(self):
|
def test_get_max_score(self):
|
||||||
|
"""
|
||||||
|
Test getting the max score
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
max_score = self.peer_grading.max_score()
|
max_score = self.peer_grading.max_score()
|
||||||
|
|
||||||
def get_next_submission(self):
|
def get_next_submission(self):
|
||||||
|
"""
|
||||||
|
Test to see if we can get the next mock submission
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
success, next_submission = self.peer_grading.get_next_submission({'location': 'blah'})
|
success, next_submission = self.peer_grading.get_next_submission({'location': 'blah'})
|
||||||
|
|
||||||
def test_save_grade(self):
|
def test_save_grade(self):
|
||||||
|
"""
|
||||||
|
Test if we can save the grade
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
self.peer_grading.save_grade(self.save_dict)
|
self.peer_grading.save_grade(self.save_dict)
|
||||||
|
|
||||||
def test_is_student_calibrated(self):
|
def test_is_student_calibrated(self):
|
||||||
|
"""
|
||||||
|
Check to see if the student has calibrated yet
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
calibrated_dict = {'location': "blah"}
|
calibrated_dict = {'location': "blah"}
|
||||||
self.peer_grading.is_student_calibrated(self.calibrated_dict)
|
self.peer_grading.is_student_calibrated(self.calibrated_dict)
|
||||||
|
|
||||||
def test_show_calibration_essay(self):
|
def test_show_calibration_essay(self):
|
||||||
|
"""
|
||||||
|
Test showing the calibration essay
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
self.peer_grading.show_calibration_essay(self.calibrated_dict)
|
self.peer_grading.show_calibration_essay(self.calibrated_dict)
|
||||||
|
|
||||||
def test_save_calibration_essay(self):
|
def test_save_calibration_essay(self):
|
||||||
|
"""
|
||||||
|
Test saving the calibration essay
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
self.peer_grading.save_calibration_essay(self.save_dict)
|
self.peer_grading.save_calibration_essay(self.save_dict)
|
||||||
|
|
||||||
def test_peer_grading_closed(self):
|
|
||||||
self.peer_grading.peer_grading_closed()
|
|
||||||
|
|
||||||
def test_peer_grading_problem(self):
|
def test_peer_grading_problem(self):
|
||||||
|
"""
|
||||||
|
See if we can render a single problem
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
self.peer_grading.peer_grading_problem(self.calibrated_dict)
|
self.peer_grading.peer_grading_problem(self.calibrated_dict)
|
||||||
|
|
||||||
def test_get_instance_state(self):
|
def test_get_instance_state(self):
|
||||||
|
"""
|
||||||
|
Get the instance state dict
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
self.peer_grading.get_instance_state()
|
self.peer_grading.get_instance_state()
|
||||||
@@ -20,7 +20,7 @@ S3_INTERFACE = {
|
|||||||
|
|
||||||
class MockQueryDict(dict):
|
class MockQueryDict(dict):
|
||||||
"""
|
"""
|
||||||
Mock a query set so that it can be used with default authorization
|
Mock a query dict so that it can be used in test classes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def getlist(self, key, default=None):
|
def getlist(self, key, default=None):
|
||||||
@@ -33,6 +33,9 @@ class MockQueryDict(dict):
|
|||||||
|
|
||||||
|
|
||||||
class DummyModulestore(object):
|
class DummyModulestore(object):
|
||||||
|
"""
|
||||||
|
A mixin that allows test classes to have convenience functions to get a module given a location
|
||||||
|
"""
|
||||||
test_system = test_system()
|
test_system = test_system()
|
||||||
|
|
||||||
def get_course(self, name):
|
def get_course(self, name):
|
||||||
|
|||||||
Reference in New Issue
Block a user