Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-submissions
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
edx
edx-submissions
Commits
4221a98f
Commit
4221a98f
authored
Mar 08, 2016
by
Eric Fischer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #43 from edx/efischer/score_summary
Use score summaries in data download
parents
feb2ae3d
8d14bab0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
+19
-17
submissions/api.py
+15
-15
submissions/tests/test_api.py
+4
-2
No files found.
submissions/api.py
View file @
4221a98f
...
...
@@ -447,27 +447,27 @@ def get_all_course_submission_information(course_id, item_type, read_replica=Tru
if
read_replica
:
submission_qs
=
_use_read_replica
(
submission_qs
)
query
=
submission_qs
.
select_related
(
'student_item
'
)
.
prefetch_related
(
'score_set
'
)
.
filter
(
query
=
submission_qs
.
select_related
(
'student_item
__scoresummary__latest__submission
'
)
.
filter
(
student_item__course_id
=
course_id
,
student_item__item_type
=
item_type
,
)
.
iterator
()
for
submission
in
query
:
student_item
=
submission
.
student_item
if
submission
.
score_set
.
count
()
>
0
:
for
score
in
submission
.
score_set
.
all
(
):
yield
(
StudentItemSerializer
(
student_item
)
.
data
,
SubmissionSerializer
(
submission
)
.
data
,
ScoreSerializer
(
score
)
.
data
)
else
:
# Make sure we return submission information even if there isn't a score associated with it.
yield
(
StudentItemSerializer
(
student_item
)
.
data
,
SubmissionSerializer
(
submission
)
.
data
,
{}
)
serialized_score
=
{}
if
hasattr
(
student_item
,
'scoresummary'
):
latest_score
=
student_item
.
scoresummary
.
latest
# We only include the score for a given submission if it is not a reset score and it "counts", that is
,
# if it is the latest score on the score summary tracking the submission's student_item. This matches the
# behavior of the API's get_score method.
if
(
not
latest_score
.
is_hidden
())
and
latest_score
.
submission
.
uuid
==
submission
.
uuid
:
serialized_score
=
ScoreSerializer
(
latest_score
)
.
data
yield
(
StudentItemSerializer
(
student_item
)
.
data
,
SubmissionSerializer
(
submission
)
.
data
,
serialized_score
)
def
get_top_submissions
(
course_id
,
item_id
,
item_type
,
number_of_top_scores
,
use_cache
=
True
,
read_replica
=
True
):
...
...
submissions/tests/test_api.py
View file @
4221a98f
...
...
@@ -127,7 +127,8 @@ class TestSubmissionsApi(TestCase):
self
.
assertDictEqual
(
SECOND_STUDENT_ITEM
,
submissions_and_scores
[
1
][
0
])
self
.
_assert_submission
(
submissions_and_scores
[
1
][
1
],
submission3
[
'answer'
],
student_item2
.
pk
,
1
)
self
.
_assert_score
(
submissions_and_scores
[
1
][
2
],
3
,
4
)
# submission4 also pertains to this student item and got its score later, so no score will be reported here
self
.
assertEqual
(
submissions_and_scores
[
1
][
2
],
{})
self
.
assertDictEqual
(
STUDENT_ITEM
,
submissions_and_scores
[
2
][
0
])
self
.
_assert_submission
(
submissions_and_scores
[
2
][
1
],
submission2
[
'answer'
],
student_item1
.
pk
,
2
)
...
...
@@ -135,7 +136,8 @@ class TestSubmissionsApi(TestCase):
self
.
assertDictEqual
(
STUDENT_ITEM
,
submissions_and_scores
[
3
][
0
])
self
.
_assert_submission
(
submissions_and_scores
[
3
][
1
],
submission1
[
'answer'
],
student_item1
.
pk
,
1
)
self
.
_assert_score
(
submissions_and_scores
[
3
][
2
],
1
,
4
)
# submission2 also pertains to this student item and got its score later, so no score will be reported here
self
.
assertEqual
(
submissions_and_scores
[
3
][
2
],
{})
def
test_get_submission
(
self
):
# Test base case that we can create a submission and get it back
...
...
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