Example #1
0
def generate_answers_distribution_report(_entry_id, course_descriptor, _task_input, action_name):
    """ Main task to generate answers distribution as csv.

    Csv structure will be as follow:
       'id', 'gender', 'year_of_birth', 'level_of_education', q1,      , q2
        15,     f    ,    1989        ,    m                , choice 1 , choice 2

    Args:
         _entry_id (str): Instructor task id (not used).
         course_descriptor (CourseDescriptor)
         _task_input (dict): Task input paprameters.
             E.g. : {'problem_id' : '42',
                     'running_report_name' : u"fun_course_quizz-04-05-153143.csv"}
         action_name (str) : Instructor task action name (not used).

    Returns:
         The progress state of the task (TaskProgress)
    """
    task_progress = TaskProgress(action_name, 1, time())
    task_progress.update_task_state()

    store = modulestore()
    problem = fetch_problem(store, course_descriptor, _task_input['problem_id'])
    problem_size = get_problem_size(problem)
    header_row = create_header_row(problem_size)
    data_rows = fetch_student_answers(problem, problem_size)
    ancestors_row = fetch_ancestors_names(store, problem.location)
    path = get_path(_task_input['running_report_name'], problem.location)
    write_csv(header_row, data_rows, ancestors_row, path)
    return task_progress.update_task_state({'succeeded': 1})
Example #2
0
def generate_answers_distribution_report(_entry_id, course_descriptor,
                                         _task_input, action_name):
    """ Main task to generate answers distribution as csv.

    Csv structure will be as follow:
       'id', 'gender', 'year_of_birth', 'level_of_education', q1,      , q2
        15,     f    ,    1989        ,    m                , choice 1 , choice 2

    Args:
         _entry_id (str): Instructor task id (not used).
         course_descriptor (CourseDescriptor)
         _task_input (dict): Task input paprameters.
             E.g. : {'problem_id' : '42',
                     'running_report_name' : u"fun_course_quizz-04-05-153143.csv"}
         action_name (str) : Instructor task action name (not used).

    Returns:
         The progress state of the task (TaskProgress)
    """
    task_progress = TaskProgress(action_name, 1, time())
    task_progress.update_task_state()

    store = modulestore()
    problem = fetch_problem(store, course_descriptor,
                            _task_input['problem_id'])
    problem_size = get_problem_size(problem)
    header_row = create_header_row(problem_size)
    data_rows = fetch_student_answers(problem, problem_size)
    ancestors_row = fetch_ancestors_names(store, problem.location)
    path = get_path(_task_input['running_report_name'], problem.location)
    write_csv(header_row, data_rows, ancestors_row, path)
    return task_progress.update_task_state({'succeeded': 1})
Example #3
0
    def test_fetch_ancestors_names(self):
        self._generate_modules_tree_with_display_names(self.course,
                                                       'chapter', 'sequential',
                                                       'vertical', 'problem')

        ancestors = utils.fetch_ancestors_names(self.store, self.problem_module.location)
        self.assertEqual(ancestors, [self.course.display_name, 'chapter',
                                     'sequential', 'vertical'])
Example #4
0
    def test_fetch_ancestors_names(self):
        self._generate_modules_tree_with_display_names(self.course, 'chapter',
                                                       'sequential',
                                                       'vertical', 'problem')

        ancestors = utils.fetch_ancestors_names(self.store,
                                                self.problem_module.location)
        self.assertEqual(
            ancestors,
            [self.course.display_name, 'chapter', 'sequential', 'vertical'])