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
5c6c8110
Commit
5c6c8110
authored
Dec 17, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Method to Retrieve Submission Counts for Multiple Problems
parent
a4d1130d
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 @
5c6c8110
...
@@ -73,9 +73,6 @@ disable=
...
@@ -73,9 +73,6 @@ disable=
# (visual studio) and html
# (visual studio) and html
output-format=text
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
# 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
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
# written in a file name "pylint_global.[txt|html]".
...
...
analyticsclient/module.py
View file @
5c6c8110
import
analyticsclient.constants.data_format
as
DF
import
analyticsclient.constants.data_format
as
DF
from
analyticsclient.exceptions
import
InvalidRequestError
class
Module
(
object
):
class
Module
(
object
):
...
@@ -28,6 +29,22 @@ class Module(object):
...
@@ -28,6 +29,22 @@ class Module(object):
return
self
.
client
.
get
(
path
,
data_format
=
data_format
)
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
):
def
grade_distribution
(
self
,
data_format
=
DF
.
JSON
):
"""
"""
Get grade distribution data for a module.
Get grade distribution data for a module.
...
...
analyticsclient/tests/test_module.py
View file @
5c6c8110
import
json
import
json
import
httpretty
import
httpretty
from
analyticsclient.exceptions
import
InvalidRequestError
from
analyticsclient.tests
import
ClientTestCase
from
analyticsclient.tests
import
ClientTestCase
...
@@ -94,3 +95,19 @@ class ModulesTests(ClientTestCase):
...
@@ -94,3 +95,19 @@ class ModulesTests(ClientTestCase):
uri
=
self
.
get_api_url
(
'problems/{0}/grade_distribution/'
.
format
(
self
.
module_id
))
uri
=
self
.
get_api_url
(
'problems/{0}/grade_distribution/'
.
format
(
self
.
module_id
))
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
body
))
httpretty
.
register_uri
(
httpretty
.
GET
,
uri
,
body
=
json
.
dumps
(
body
))
self
.
assertEqual
(
body
,
self
.
module
.
grade_distribution
())
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 @
5c6c8110
...
@@ -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.
4
.0'
,
version
=
'0.
5
.0'
,
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'
,
...
...
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