Esempio n. 1
0
def all_sequential_open_distrib(request, course_id):
    """
    Creates a json with the open distribution for all the subsections in the course.

    `request` django request

    `course_id` the course ID for the course interested in

    Returns the format in dashboard_data.get_d3_sequential_open_distrib
    """

    data = {}

    # Only instructor for this particular course can request this information
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    if has_instructor_access_for_class(request.user, course_key):
        try:
            data = dashboard_data.get_d3_sequential_open_distrib(course_key)
        except Exception as ex:  # pylint: disable=broad-except
            log.error('Generating metrics failed with exception: %s', ex)
            data = {'error': "error"}
    else:
        data = {'error': "Access Denied: User does not have access to this course's data"}

    return HttpResponse(json.dumps(data), content_type="application/json")
Esempio n. 2
0
def all_sequential_open_distrib(request, course_id):
    """
    Creates a json with the open distribution for all the subsections in the course.

    `request` django request

    `course_id` the course ID for the course interested in

    Returns the format in dashboard_data.get_d3_sequential_open_distrib
    """

    json = {}

    # Only instructor for this particular course can request this information
    if has_instructor_access_for_class(request.user, course_id):
        try:
            json = dashboard_data.get_d3_sequential_open_distrib(course_id)
        except Exception as ex:  # pylint: disable=broad-except
            log.error('Generating metrics failed with exception: %s', ex)
            json = {'error': "error"}
    else:
        json = {
            'error':
            "Access Denied: User does not have access to this course's data"
        }

    return HttpResponse(simplejson.dumps(json), mimetype="application/json")
Esempio n. 3
0
def all_sequential_open_distrib(request, course_id, enrollment):
    """
    Creates a json with the open distribution for all the subsections in the course.

    `request` django request

    `course_id` the course ID for the course interested in

    `enrollment` the number of students enrolled in the course

    Returns the format in dashboard_data.get_d3_sequential_open_distrib
    """

    data = {}

    # Only instructor for this particular course can request this information
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    if has_instructor_access_for_class(request.user, course_key):
        try:
            data = dashboard_data.get_d3_sequential_open_distrib(course_key, int(enrollment))
        except Exception as ex:  # pylint: disable=broad-except
            log.error('Generating metrics failed with exception: %s', ex)
            data = {'error': "error"}
    else:
        data = {'error': "Access Denied: User does not have access to this course's data"}

    return HttpResponse(json.dumps(data), content_type="application/json")
    def test_get_d3_sequential_open_distrib(self):

        d3_data = get_d3_sequential_open_distrib(self.course.id)

        for data in d3_data:
            for stack_data in data['data']:
                for problem in stack_data['stackData']:
                    value = problem['value']
                self.assertEquals(0, value)
Esempio n. 5
0
    def test_get_d3_sequential_open_distrib(self):

        d3_data = get_d3_sequential_open_distrib(self.course.id)

        for data in d3_data:
            for stack_data in data['data']:
                for problem in stack_data['stackData']:
                    value = problem['value']
                self.assertEquals(0, value)
    def test_get_d3_sequential_open_distrib(self, mock_client):
        mock_client.return_value.modules.return_value.sequential_open_distribution.return_value = [{'count': 0}]

        d3_data = get_d3_sequential_open_distrib(self.course.id, USER_COUNT)

        for data in d3_data:
            for stack_data in data['data']:
                for problem in stack_data['stackData']:
                    value = problem['value']
                self.assertEquals(USER_COUNT, value)
    def test_get_d3_sequential_open_distrib(self, mock_client):
        mock_client.return_value.modules.return_value.sequential_open_distribution.return_value = [{'count': 0}]

        d3_data = get_d3_sequential_open_distrib(self.course.id, USER_COUNT)

        for data in d3_data:
            for stack_data in data['data']:
                for problem in stack_data['stackData']:
                    value = problem['value']
                self.assertEquals(USER_COUNT, value)