Commit 42025461 by Nimisha Asthagiri Committed by GitHub

Merge pull request #13533 from edx/beryl/integration-tests

Grades python integration tests
parents 81083570 613652b7
......@@ -354,7 +354,21 @@ class TestCourseGrader(TestSubmittingProblems):
self.add_dropdown_to_section(self.homework.location, 'p3', 1)
self.refresh_course()
def weighted_setup(self):
def weighted_setup(self, hw_weight=0.25, final_weight=0.75):
"""
Set up a simple course for testing weighted grading functionality.
"""
# pylint: disable=attribute-defined-outside-init
self.set_weighted_policy(hw_weight, final_weight)
# set up a structure of 1 homework and 1 final
self.homework = self.add_graded_section_to_course('homework')
self.problem = self.add_dropdown_to_section(self.homework.location, 'H1P1')
self.final = self.add_graded_section_to_course('Final Section', 'Final')
self.final_question = self.add_dropdown_to_section(self.final.location, 'FinalQuestion')
def set_weighted_policy(self, hw_weight=0.25, final_weight=0.75):
"""
Set up a simple course for testing weighted grading functionality.
"""
......@@ -366,23 +380,17 @@ class TestCourseGrader(TestSubmittingProblems):
"min_count": 1,
"drop_count": 0,
"short_label": "HW",
"weight": 0.25
"weight": hw_weight
}, {
"type": "Final",
"name": "Final Section",
"short_label": "Final",
"weight": 0.75
"weight": final_weight
}
]
}
self.add_grading_policy(grading_policy)
# set up a structure of 1 homework and 1 final
self.homework = self.add_graded_section_to_course('homework')
self.problem = self.add_dropdown_to_section(self.homework.location, 'H1P1')
self.final = self.add_graded_section_to_course('Final Section', 'Final')
self.final_question = self.add_dropdown_to_section(self.final.location, 'FinalQuestion')
def dropping_setup(self):
"""
Set up a simple course for testing the dropping grading functionality.
......@@ -619,6 +627,17 @@ class TestCourseGrader(TestSubmittingProblems):
self.submit_question_answer('FinalQuestion', {'2_1': 'Correct', '2_2': 'Correct'})
self.check_grade_percent(1.0)
def test_grade_updates_on_weighted_change(self):
"""
Test that the course grade updates when the
assignment weights change.
"""
self.weighted_setup()
self.submit_question_answer('H1P1', {'2_1': 'Correct', '2_2': 'Correct'})
self.check_grade_percent(0.25)
self.set_weighted_policy(0.75, 0.25)
self.check_grade_percent(0.75)
def dropping_homework_stage1(self):
"""
Get half the first homework correct and all of the second
......
......@@ -208,15 +208,24 @@ class InstructorTaskModuleTestCase(InstructorTaskCourseTestCase):
else:
return TEST_COURSE_KEY.make_usage_key('problem', problem_url_name)
def _option_problem_factory_args(self, correct_answer=OPTION_1, num_inputs=1, num_responses=2):
"""
Returns the factory args for the option problem type.
"""
return {
'question_text': 'The correct answer is {0}'.format(correct_answer),
'options': [OPTION_1, OPTION_2],
'correct_option': correct_answer,
'num_responses': num_responses,
'num_inputs': num_inputs,
}
def define_option_problem(self, problem_url_name, parent=None, **kwargs):
"""Create the problem definition so the answer is Option 1"""
if parent is None:
parent = self.problem_section
factory = OptionResponseXMLFactory()
factory_args = {'question_text': 'The correct answer is {0}'.format(OPTION_1),
'options': [OPTION_1, OPTION_2],
'correct_option': OPTION_1,
'num_responses': 2}
factory_args = self._option_problem_factory_args()
problem_xml = factory.build_xml(**factory_args)
ItemFactory.create(parent_location=parent.location,
parent=parent,
......@@ -225,13 +234,10 @@ class InstructorTaskModuleTestCase(InstructorTaskCourseTestCase):
data=problem_xml,
**kwargs)
def redefine_option_problem(self, problem_url_name):
def redefine_option_problem(self, problem_url_name, correct_answer=OPTION_1, num_inputs=1, num_responses=2):
"""Change the problem definition so the answer is Option 2"""
factory = OptionResponseXMLFactory()
factory_args = {'question_text': 'The correct answer is {0}'.format(OPTION_2),
'options': [OPTION_1, OPTION_2],
'correct_option': OPTION_2,
'num_responses': 2}
factory_args = self._option_problem_factory_args(correct_answer, num_inputs, num_responses)
problem_xml = factory.build_xml(**factory_args)
location = InstructorTaskTestCase.problem_location(problem_url_name)
item = self.module_store.get_item(location)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment