def redefine_option_problem(self, problem_url_name): """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} problem_xml = factory.build_xml(**factory_args) location = InstructorTaskTestCase.problem_location(problem_url_name) self.module_store.update_item(location, problem_xml)
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 = 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) with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, location.course_key): item.data = problem_xml self.module_store.update_item(item, self.user.id) self.module_store.publish(location, self.user.id)
def define_option_problem(self, problem_url_name): """Create the problem definition so the answer is Option 1""" 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} problem_xml = factory.build_xml(**factory_args) ItemFactory.create(parent_location=self.problem_section.location, category="problem", display_name=str(problem_url_name), data=problem_xml)
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 = self._option_problem_factory_args() problem_xml = factory.build_xml(**factory_args) return ItemFactory.create(parent_location=parent.location, parent=parent, category="problem", display_name=problem_url_name, data=problem_xml, **kwargs)
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 = self._option_problem_factory_args() problem_xml = factory.build_xml(**factory_args) ItemFactory.create(parent_location=parent.location, parent=parent, category="problem", display_name=problem_url_name, data=problem_xml, **kwargs)
def redefine_option_problem(self, problem_url_name): """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} problem_xml = factory.build_xml(**factory_args) location = InstructorTaskTestCase.problem_location(problem_url_name) item = self.module_store.get_item(location) with self.module_store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, location.course_key): item.data = problem_xml self.module_store.update_item(item, self.user.id) self.module_store.publish(location, self.user.id)
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, } problem_xml = factory.build_xml(**factory_args) ItemFactory.create( parent_location=parent.location, parent=parent, category="problem", display_name=problem_url_name, data=problem_xml, **kwargs )