def test_get_student_answers(self): first_question = RF.MultipleChoiceResponseXMLFactory().build_xml( choices=[True, False, False]) second_question = RF.MultipleChoiceResponseXMLFactory().build_xml( choices=[False, True, False]) self.problem_module.data = self._build_problem(first_question, second_question) problem_monitor = ProblemMonitor(self.problem_module) cmap = self._build_correct_map('correct', 'incorrect') student_answers = self._build_student_answers('choice_0', 'choice_2') StudentModuleFactory(course_id=self.course.id, state=self._build_student_module_state(cmap, student_answers)) problem_monitor.get_student_answers() correctness_first_question = problem_monitor.question_monitors[self._build_question_id(0)].correctness student_answers_first_question = problem_monitor.question_monitors[self._build_question_id(1)].student_answers correctness_second_question = problem_monitor.question_monitors[self._build_question_id(1)].correctness student_answers_second_question = problem_monitor.question_monitors[self._build_question_id(1)].student_answers self.assertDictContainsSubset(correctness_first_question, {'correct' : 1, 'incorrect' : 0}) self.assertDictContainsSubset(student_answers_first_question, {'choice_0' : 1}) self.assertDictContainsSubset(correctness_second_question, {'correct' : 0, 'incorrect' : 1}) self.assertDictContainsSubset(student_answers_second_question, {'choice_2' : 1})
def get_stats(request, course_id, problem_id): """ et stats for a single problem (LoncapaProblem). The problem id is passed has a GET paramater with 'problem_id' key. Args: course_id (str): The course id as string. """ start_time = time.time() store = modulestore() course_key = CourseKey.from_string(course_id) problem = utils.fetch_problem(store, course_key, problem_id) problem_monitor = ProblemMonitor(problem) problem_monitor.get_student_answers() tracker.emit("course_dashboard.problem_stats.views.get_stats", {'task-time' : time.time() - start_time}) return HttpResponse(problem_monitor.get_html())
def test_get_student_answers(self): first_question = RF.MultipleChoiceResponseXMLFactory().build_xml( choices=[True, False, False]) second_question = RF.MultipleChoiceResponseXMLFactory().build_xml( choices=[False, True, False]) self.problem_module.data = self._build_problem(first_question, second_question) problem_monitor = ProblemMonitor(self.problem_module) cmap = self._build_correct_map('correct', 'incorrect') student_answers = self._build_student_answers('choice_0', 'choice_2') StudentModuleFactory(course_id=self.course.id, state=self._build_student_module_state( cmap, student_answers)) problem_monitor.get_student_answers() correctness_first_question = problem_monitor.question_monitors[ self._build_question_id(0)].correctness student_answers_first_question = problem_monitor.question_monitors[ self._build_question_id(1)].student_answers correctness_second_question = problem_monitor.question_monitors[ self._build_question_id(1)].correctness student_answers_second_question = problem_monitor.question_monitors[ self._build_question_id(1)].student_answers self.assertDictContainsSubset(correctness_first_question, { 'correct': 1, 'incorrect': 0 }) self.assertDictContainsSubset(student_answers_first_question, {'choice_0': 1}) self.assertDictContainsSubset(correctness_second_question, { 'correct': 0, 'incorrect': 1 }) self.assertDictContainsSubset(student_answers_second_question, {'choice_2': 1})
def get_stats(request, course_id, problem_id): """ et stats for a single problem (LoncapaProblem). The problem id is passed has a GET paramater with 'problem_id' key. Args: course_id (str): The course id as string. """ start_time = time.time() store = modulestore() course_key = CourseKey.from_string(course_id) try: problem = utils.fetch_problem(store, course_key, problem_id) except ItemNotFoundError: raise Http404() problem_monitor = ProblemMonitor(problem) problem_monitor.get_student_answers() tracker.emit("course_dashboard.problem_stats.views.get_stats", {'task-time': time.time() - start_time}) return HttpResponse(problem_monitor.get_html())