Commit 99f9c79f by Dennis Jen

Merge pull request #77 from edx/dsjen/aggregate-problem-submissions

Updated problem endpoint to return problem submissions.
parents 3b8f7fc3 5812dbdf
......@@ -620,8 +620,8 @@ class CourseProblemsListViewTests(DemoCourseMixin, TestCaseWithAuthentication):
expected = [
{
'module_id': module_id,
'total_submissions': 300,
'correct_submissions': 100,
'total_submissions': 150,
'correct_submissions': 50,
'part_ids': [o1.part_id, o3.part_id],
'created': alt_created.strftime(settings.DATETIME_FORMAT)
},
......
......@@ -632,11 +632,14 @@ class ProblemsListView(BaseCourseView):
allow_empty = False
def get_queryset(self):
# last_response_count is the number of submissions for the problem part and must
# be divided by the number of problem parts to get the problem submission rather
# than the problem *part* submissions
aggregation_query = """
SELECT
module_id,
SUM(last_response_count) AS total_submissions,
SUM(CASE WHEN correct=1 THEN last_response_count ELSE 0 END) AS correct_submissions,
SUM(last_response_count)/COUNT(DISTINCT part_id) AS total_submissions,
SUM(CASE WHEN correct=1 THEN last_response_count ELSE 0 END)/COUNT(DISTINCT part_id) AS correct_submissions,
GROUP_CONCAT(DISTINCT part_id) AS part_ids,
MAX(created) AS created
FROM answer_distribution
......
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