Ejemplo n.º 1
0
def flagged_problem_list(request, course_id):
    '''
    Show a student problem list
    '''
    course = get_course_with_access(request.user, course_id, 'staff')
    student_id = unique_id_for_user(request.user)

    # call problem list service
    success = False
    error_text = ""
    problem_list = []
    base_course_url = reverse('courses')

    # Make a service that can query edX ORA.
    controller_qs = create_controller_query_service()
    try:
        problem_list_json = controller_qs.get_flagged_problem_list(course_id)
        problem_list_dict = json.loads(problem_list_json)
        success = problem_list_dict['success']
        if 'error' in problem_list_dict:
            error_text = problem_list_dict['error']
            problem_list = []
        else:
            problem_list = problem_list_dict['flagged_submissions']

    except GradingServiceError:
        #This is a staff_facing_error
        error_text = STAFF_ERROR_MESSAGE
        #This is a dev_facing_error
        log.error(
            "Could not get flagged problem list from external grading service for open ended."
        )
        success = False
    # catch error if if the json loads fails
    except ValueError:
        #This is a staff_facing_error
        error_text = STAFF_ERROR_MESSAGE
        #This is a dev_facing_error
        log.error(
            "Could not parse problem list from external grading service response."
        )
        success = False

    ajax_url = _reverse_with_slash('open_ended_flagged_problems', course_id)
    context = {
        'course': course,
        'course_id': course_id,
        'ajax_url': ajax_url,
        'success': success,
        'problem_list': problem_list,
        'error_text': error_text,
        # Checked above
        'staff_access': True,
    }
    return render_to_response(
        'open_ended_problems/open_ended_flagged_problems.html', context)
Ejemplo n.º 2
0
def flagged_problem_list(request, course_id):
    '''
    Show a student problem list
    '''
    course = get_course_with_access(request.user, course_id, 'staff')
    student_id = unique_id_for_user(request.user)

    # call problem list service
    success = False
    error_text = ""
    problem_list = []
    base_course_url = reverse('courses')

    # Make a service that can query edX ORA.
    controller_qs = create_controller_query_service()
    try:
        problem_list_json = controller_qs.get_flagged_problem_list(course_id)
        problem_list_dict = json.loads(problem_list_json)
        success = problem_list_dict['success']
        if 'error' in problem_list_dict:
            error_text = problem_list_dict['error']
            problem_list = []
        else:
            problem_list = problem_list_dict['flagged_submissions']

    except GradingServiceError:
        #This is a staff_facing_error
        error_text = STAFF_ERROR_MESSAGE
        #This is a dev_facing_error
        log.error("Could not get flagged problem list from external grading service for open ended.")
        success = False
    # catch error if if the json loads fails
    except ValueError:
        #This is a staff_facing_error
        error_text = STAFF_ERROR_MESSAGE
        #This is a dev_facing_error
        log.error("Could not parse problem list from external grading service response.")
        success = False

    ajax_url = _reverse_with_slash('open_ended_flagged_problems', course_id)
    context = {
        'course': course,
        'course_id': course_id,
        'ajax_url': ajax_url,
        'success': success,
        'problem_list': problem_list,
        'error_text': error_text,
        # Checked above
        'staff_access': True,
    }
    return render_to_response('open_ended_problems/open_ended_flagged_problems.html', context)
Ejemplo n.º 3
0
def flagged_problem_list(request, course_id):
    """
    Show a student problem list
    """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_with_access(request.user, "staff", course_key)

    # call problem list service
    success = False
    error_text = ""
    problem_list = []

    # Make a service that can query edX ORA.
    controller_qs = create_controller_query_service()
    try:
        problem_list_dict = controller_qs.get_flagged_problem_list(course_key)
        success = problem_list_dict["success"]
        if "error" in problem_list_dict:
            error_text = problem_list_dict["error"]
            problem_list = []
        else:
            problem_list = problem_list_dict["flagged_submissions"]

    except GradingServiceError:
        # This is a staff_facing_error
        error_text = STAFF_ERROR_MESSAGE
        # This is a dev_facing_error
        log.error("Could not get flagged problem list from external grading service for open ended.")
        success = False
    # catch error if if the json loads fails
    except ValueError:
        # This is a staff_facing_error
        error_text = STAFF_ERROR_MESSAGE
        # This is a dev_facing_error
        log.error("Could not parse problem list from external grading service response.")
        success = False

    ajax_url = _reverse_with_slash("open_ended_flagged_problems", course_key)
    context = {
        "course": course,
        "course_id": course_id,
        "ajax_url": ajax_url,
        "success": success,
        "problem_list": problem_list,
        "error_text": error_text,
        # Checked above
        "staff_access": True,
    }
    return render_to_response("open_ended_problems/open_ended_flagged_problems.html", context)
Ejemplo n.º 4
0
def take_action_on_flags(request, course_id):
    """
    Takes action on student flagged submissions.
    Currently, only support unflag and ban actions.
    """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    if request.method != 'POST':
        raise Http404

    required = ['submission_id', 'action_type', 'student_id']
    for key in required:
        if key not in request.POST:
            error_message = u'Missing key {0} from submission.  Please reload and try again.'.format(
                key)
            response = {
                'success': False,
                'error': STAFF_ERROR_MESSAGE + error_message
            }
            return HttpResponse(json.dumps(response),
                                content_type="application/json")

    p = request.POST
    submission_id = p['submission_id']
    action_type = p['action_type']
    student_id = p['student_id']
    student_id = student_id.strip(' \t\n\r')
    submission_id = submission_id.strip(' \t\n\r')
    action_type = action_type.lower().strip(' \t\n\r')

    # Make a service that can query edX ORA.
    controller_qs = create_controller_query_service()
    try:
        response = controller_qs.take_action_on_flags(course_key, student_id,
                                                      submission_id,
                                                      action_type)
        return HttpResponse(json.dumps(response),
                            content_type="application/json")
    except GradingServiceError:
        log.exception(
            u"Error taking action on flagged peer grading submissions, "
            u"submission_id: {0}, action_type: {1}, grader_id: {2}".format(
                submission_id, action_type, student_id))
        response = {'success': False, 'error': STAFF_ERROR_MESSAGE}
        return HttpResponse(json.dumps(response),
                            content_type="application/json")
Ejemplo n.º 5
0
def take_action_on_flags(request, course_id):
    """
    Takes action on student flagged submissions.
    Currently, only support unflag and ban actions.
    """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    if request.method != 'POST':
        raise Http404

    required = ['submission_id', 'action_type', 'student_id']
    for key in required:
        if key not in request.POST:
            error_message = u'Missing key {0} from submission.  Please reload and try again.'.format(key)
            response = {
                'success': False,
                'error': STAFF_ERROR_MESSAGE + error_message
            }
            return HttpResponse(json.dumps(response), content_type="application/json")

    p = request.POST
    submission_id = p['submission_id']
    action_type = p['action_type']
    student_id = p['student_id']
    student_id = student_id.strip(' \t\n\r')
    submission_id = submission_id.strip(' \t\n\r')
    action_type = action_type.lower().strip(' \t\n\r')

    # Make a service that can query edX ORA.
    controller_qs = create_controller_query_service()
    try:
        response = controller_qs.take_action_on_flags(course_key, student_id, submission_id, action_type)
        return HttpResponse(json.dumps(response), content_type="application/json")
    except GradingServiceError:
        log.exception(
            u"Error taking action on flagged peer grading submissions, "
            u"submission_id: {0}, action_type: {1}, grader_id: {2}"
            .format(submission_id, action_type, student_id)
        )
        response = {
            'success': False,
            'error': STAFF_ERROR_MESSAGE
        }
        return HttpResponse(json.dumps(response), content_type="application/json")