Commit 2e2affe3 by Clinton Blackburn

Added course-problems method

This replaces the submission_counts method.
parent f60923c6
...@@ -94,3 +94,13 @@ class Course(object): ...@@ -94,3 +94,13 @@ class Course(object):
path = 'courses/{0}/recent_activity/?activity_type={1}'.format(self.course_id, activity_type) path = 'courses/{0}/recent_activity/?activity_type={1}'.format(self.course_id, activity_type)
return self.client.get(path, data_format=data_format) return self.client.get(path, data_format=data_format)
def problems(self, data_format=DF.JSON):
"""
Get the problems for the course.
Arguments:
data_format (str): Format in which data should be returned
"""
path = 'courses/{0}/problems/'.format(self.course_id)
return self.client.get(path, data_format=data_format)
import json import json
import re
import httpretty import httpretty
import re
from analyticsclient.constants import activity_type as at from analyticsclient.constants import activity_type as at
from analyticsclient.constants import data_format from analyticsclient.constants import data_format
from analyticsclient.constants import demographic as demo from analyticsclient.constants import demographic as demo
from analyticsclient.exceptions import NotFoundError, InvalidRequestError from analyticsclient.exceptions import NotFoundError, InvalidRequestError
from analyticsclient.tests import ClientTestCase from analyticsclient.tests import ClientTestCase
...@@ -134,3 +134,16 @@ class CoursesTests(ClientTestCase): ...@@ -134,3 +134,16 @@ class CoursesTests(ClientTestCase):
httpretty.register_uri(httpretty.GET, uri, body='not-json') httpretty.register_uri(httpretty.GET, uri, body='not-json')
self.course.enrollment(data_format=data_format.CSV) self.course.enrollment(data_format=data_format.CSV)
self.assertEquals(httpretty.last_request().headers['Accept'], 'text/csv') self.assertEquals(httpretty.last_request().headers['Accept'], 'text/csv')
@httpretty.activate
def test_problems(self):
body = [
{
'module_id': 'i4x://a/b/c'
}
]
uri = self.get_api_url('courses/{0}/problems/'.format(self.course_id))
httpretty.register_uri(httpretty.GET, uri, body=json.dumps(body))
self.assertEqual(body, self.course.problems())
...@@ -2,7 +2,7 @@ from distutils.core import setup ...@@ -2,7 +2,7 @@ from distutils.core import setup
setup( setup(
name='edx-analytics-data-api-client', name='edx-analytics-data-api-client',
version='0.5.0', version='0.5.1',
packages=['analyticsclient'], packages=['analyticsclient'],
url='https://github.com/edx/edx-analytics-data-api-client', url='https://github.com/edx/edx-analytics-data-api-client',
description='Client used to access edX analytics data warehouse', description='Client used to access edX analytics data warehouse',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment