Commit 246cdeec by Dmitry Viskov

New OraAggregateData.collect_ora2_responses method

parent 4abd0ef8
...@@ -25,3 +25,4 @@ Eric Fischer <efischer@edx.org> ...@@ -25,3 +25,4 @@ Eric Fischer <efischer@edx.org>
Andy Armstrong <andya@edx.org> Andy Armstrong <andya@edx.org>
Christina Roberts <christina@edx.org> Christina Roberts <christina@edx.org>
Mushtaq Ali <mushtaak@gmail.com> Mushtaq Ali <mushtaak@gmail.com>
Dmitry Viskov <dmitry.viskov@webenterprise.ru>
...@@ -495,3 +495,43 @@ class OraAggregateData(object): ...@@ -495,3 +495,43 @@ class OraAggregateData(object):
'Feedback on Peer Assessments' 'Feedback on Peer Assessments'
] ]
return header, rows return header, rows
@classmethod
def collect_ora2_responses(cls, course_id):
"""
Get information about all ora2 blocks in the course with response count for each step
Args:
course_id (string) - the course id of the course whose data we would like to return
Returns:
A dict in the format:
{
'block-v1:test-org+cs101+2017_TEST+type@openassessment+block@fb668396b505470e914bad8b3178e9e7:
{'training': 0, 'self': 0, 'done': 2, 'peer': 1, 'staff': 0, 'total': 3},
'block-v1:test-org+cs101+2017_TEST+type@openassessment+block@90b4edff50bc47d9ba037a3180c44e97:
{'training': 0, 'self': 2, 'done': 0, 'peer': 0, 'staff': 2, 'total': 4},
...
}
"""
except_statuses = ['ai', 'cancelled']
statuses = [st for st in AssessmentWorkflow().STATUS_VALUES if st not in except_statuses]
statuses.append('total')
items = AssessmentWorkflow.objects.filter(course_id=course_id).values('item_id', 'status')
result = {}
for item in items:
item_id = item['item_id']
status = item['status']
if item_id not in result:
result[item_id] = {}
for st in statuses:
result[item_id][st] = 0
if status in statuses:
result[item_id][status] += 1
result[item_id]['total'] += 1
return result
...@@ -20,10 +20,14 @@ import openassessment.assessment.api.peer as peer_api ...@@ -20,10 +20,14 @@ import openassessment.assessment.api.peer as peer_api
COURSE_ID = "Test_Course" COURSE_ID = "Test_Course"
STUDENT_ID = "Student" STUDENT_ID = "Student"
STUDENT_ID2 = "Student2"
STUDENT_ID3 = "Student3"
SCORER_ID = "Scorer" SCORER_ID = "Scorer"
ITEM_ID = "item_one" ITEM_ID = "item_one"
ITEM_ID2 = "item_two"
ITEM_ID3 = "item_three"
STUDENT_ITEM = dict( STUDENT_ITEM = dict(
student_id=STUDENT_ID, student_id=STUDENT_ID,
...@@ -376,14 +380,14 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest): ...@@ -376,14 +380,14 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest):
peer_api.get_score(self.submission['uuid'], {'must_be_graded_by': 1, 'must_grade': 0}) peer_api.get_score(self.submission['uuid'], {'must_be_graded_by': 1, 'must_grade': 0})
self._create_assessment_feedback(self.submission['uuid']) self._create_assessment_feedback(self.submission['uuid'])
def _create_submission(self, student_item_dict): def _create_submission(self, student_item_dict, steps=None):
""" """
Creates a submission and initializes a peer grading workflow. Creates a submission and initializes a peer grading workflow.
""" """
submission = sub_api.create_submission(student_item_dict, ANSWER) submission = sub_api.create_submission(student_item_dict, ANSWER)
submission_uuid = submission['uuid'] submission_uuid = submission['uuid']
peer_api.on_start(submission_uuid) peer_api.on_start(submission_uuid)
workflow_api.create_workflow(submission_uuid, STEPS) workflow_api.create_workflow(submission_uuid, steps if steps else STEPS)
return submission return submission
def _create_assessment(self, submission_uuid): def _create_assessment(self, submission_uuid):
...@@ -474,3 +478,53 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest): ...@@ -474,3 +478,53 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest):
FEEDBACK_OPTIONS['options'][0] + '\n' + FEEDBACK_OPTIONS['options'][1]+'\n', FEEDBACK_OPTIONS['options'][0] + '\n' + FEEDBACK_OPTIONS['options'][1]+'\n',
FEEDBACK_TEXT, FEEDBACK_TEXT,
]) ])
def test_collect_ora2_responses(self):
self._create_submission(dict(
student_id=STUDENT_ID,
course_id=COURSE_ID,
item_id=ITEM_ID2,
item_type="openassessment"
), ['self'])
self._create_submission(dict(
student_id=STUDENT_ID2,
course_id=COURSE_ID,
item_id=ITEM_ID2,
item_type="openassessment"
), STEPS)
self._create_submission(dict(
student_id=STUDENT_ID,
course_id=COURSE_ID,
item_id=ITEM_ID3,
item_type="openassessment"
), ['self'])
self._create_submission(dict(
student_id=STUDENT_ID2,
course_id=COURSE_ID,
item_id=ITEM_ID3,
item_type="openassessment"
), ['self'])
self._create_submission(dict(
student_id=STUDENT_ID3,
course_id=COURSE_ID,
item_id=ITEM_ID3,
item_type="openassessment"
), STEPS)
data = OraAggregateData.collect_ora2_responses(COURSE_ID)
self.assertIn(ITEM_ID, data)
self.assertIn(ITEM_ID2, data)
self.assertIn(ITEM_ID3, data)
for item in [ITEM_ID, ITEM_ID2, ITEM_ID3]:
self.assertEqual({'total', 'training', 'peer', 'self', 'staff', 'waiting', 'done'}, set(data[item].keys()))
self.assertEqual(data[ITEM_ID], {
'total': 2, 'training': 0, 'peer': 2, 'self': 0, 'staff': 0, 'waiting': 0, 'done': 0
})
self.assertEqual(data[ITEM_ID2], {
'total': 2, 'training': 0, 'peer': 1, 'self': 1, 'staff': 0, 'waiting': 0, 'done': 0
})
self.assertEqual(data[ITEM_ID3], {
'total': 3, 'training': 0, 'peer': 1, 'self': 2, 'staff': 0, 'waiting': 0, 'done': 0
})
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