Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api-client
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-analytics-data-api-client
Commits
b12ac07b
Commit
b12ac07b
authored
Dec 23, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10 from edx/answer-distribution-list
Added Method to Retrieve Submission Counts for Multiple Problems
parents
a4d1130d
5c6c8110
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
4 deletions
+35
-4
.pylintrc
+0
-3
analyticsclient/module.py
+17
-0
analyticsclient/tests/test_module.py
+17
-0
setup.py
+1
-1
No files found.
.pylintrc
View file @
b12ac07b
...
...
@@ -73,9 +73,6 @@ disable=
# (visual studio) and html
output-format=text
# Include message's id in output
include-ids=yes
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
...
...
analyticsclient/module.py
View file @
b12ac07b
import
analyticsclient.constants.data_format
as
DF
from
analyticsclient.exceptions
import
InvalidRequestError
class
Module
(
object
):
...
...
@@ -28,6 +29,22 @@ class Module(object):
return
self
.
client
.
get
(
path
,
data_format
=
data_format
)
def
submission_counts
(
self
,
module_ids
,
data_format
=
DF
.
JSON
):
"""
Get submission counts data for multiple modules.
Arguments:
module_ids (list[str]): IDs of modules for which data should be returned
data_format (str): Format in which to return data (default is JSON)
"""
if
not
module_ids
:
raise
InvalidRequestError
(
'At least one module ID must be supplied.'
)
module_ids
=
','
.
join
(
module_ids
)
path
=
'problems/submission_counts/?problem_ids={}'
.
format
(
module_ids
)
return
self
.
client
.
get
(
path
,
data_format
=
data_format
)
def
grade_distribution
(
self
,
data_format
=
DF
.
JSON
):
"""
Get grade distribution data for a module.
...
...
analyticsclient/tests/test_module.py
View file @
b12ac07b
import
json
import
httpretty
from
analyticsclient.exceptions
import
InvalidRequestError
from
analyticsclient.tests
import
ClientTestCase
...
...
@@ -94,3 +95,19 @@ class ModulesTests(ClientTestCase):
uri
=
self
.
get_api_url
(
'problems/{0}/grade_distribution/'
.
format
(
self
.
module_id
))
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
body
))
self
.
assertEqual
(
body
,
self
.
module
.
grade_distribution
())
@httpretty.activate
def
test_submission_counts
(
self
):
self
.
assertRaises
(
InvalidRequestError
,
self
.
module
.
submission_counts
,
None
)
body
=
[
{
'module_id'
:
self
.
module_id
,
'total'
:
100
,
'correct'
:
80
}
]
uri
=
self
.
get_api_url
(
'problems/submission_counts/'
)
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
body
))
self
.
assertEqual
(
body
,
self
.
module
.
submission_counts
([
self
.
module_id
]))
setup.py
View file @
b12ac07b
...
...
@@ -2,7 +2,7 @@ from distutils.core import setup
setup
(
name
=
'edx-analytics-data-api-client'
,
version
=
'0.
4
.0'
,
version
=
'0.
5
.0'
,
packages
=
[
'analyticsclient'
],
url
=
'https://github.com/edx/edx-analytics-data-api-client'
,
description
=
'Client used to access edX analytics data warehouse'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment