Example #1
0
def generate(request, course_id, problem_id):
    """ Submit 'generate_answers_distribution_report' task to celery.

    Args:
         course_id (str): The course id as string.
         problem_id (str): The problem id as string.

    Return:
         Redirect to Report Manager dashboard.
    """
    store = modulestore()
    course_key = get_course_key(course_id)
    problem = fetch_problem(store, course_key, problem_id)

    running_report_name = build_answers_distribution_report_name(problem)

    input_args = {
        'problem_id': problem_id,
        'running_report_name': running_report_name
    }

    try:
        submit_generate_answers_distribution_report(request, course_key,
                                                    input_args)
        return redirect('course-dashboard:reports-manager:dashboard',
                        course_id)
    except AlreadyRunningError:
        messages.warning(
            request, _("A report on answers distribution is already running"))
        return redirect('course-dashboard:reports-manager:dashboard',
                        course_id)
Example #2
0
def generate(request, course_id, problem_id):
    """ Submit 'generate_answers_distribution_report' task to celery.

    Args:
         course_id (str): The course id as string.
         problem_id (str): The problem id as string.

    Return:
         Redirect to Report Manager dashboard.
    """
    store = modulestore()
    course_key = get_course_key(course_id)
    problem = fetch_problem(store, course_key, problem_id)

    running_report_name = build_answers_distribution_report_name(problem)

    input_args = {'problem_id' : problem_id,
                  'running_report_name' : running_report_name}

    try:
        submit_generate_answers_distribution_report(request, course_key, input_args)
        return redirect('course-dashboard:reports-manager:dashboard', course_id)
    except AlreadyRunningError:
        messages.warning(request, _("A report on answers distribution is already running"))
        return redirect('course-dashboard:reports-manager:dashboard', course_id)
Example #3
0
 def test_submit_generate_answers_distribution_report(self):
     api_call = lambda: submit_generate_answers_distribution_report(
         self.create_task_request(self.instructor),
         self.course.id,
         task_input={}
     )
     self._test_resubmission(api_call)
Example #4
0
def generate(request, course_id, problem_module_id):
    """
    launch the generate_answers_distribution_report task and redirect to  dashboard
    """

    course_key = get_course_key(course_id)

    ## Get the name of the problem module and of its ancestors
    store = modulestore()
    problem_module = get_problem_module(course_id, problem_module_id)
    add_ancestors_names_to_problem_module(problem_module[0], store)
    running_report_name = u"{}-{}-{}/{}.csv".format(course_key.org,
                                                    course_key.course,
                                                    problem_module[0].ancestors_names['great_grandparent'][:100],
                                                    problem_module[0].display_name[:100])

    input_args = {'problem_module_id' : problem_module_id, 'running_report_name' : running_report_name}

    try:
        submit_generate_answers_distribution_report(request, course_key, input_args)
        return redirect('course-dashboard:answers-distribution-reports-manager:dashboard', course_id)
    except AlreadyRunningError:
        messages.warning(request, _("A report on answers distribution is already running"))
        return redirect('course-dashboard:answers-distribution', course_id)