Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
4f5bf806
Commit
4f5bf806
authored
Mar 08, 2017
by
Dmitry Viskov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New OraAggregateData.collect_ora2_responses method (fix)
parent
246cdeec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
33 deletions
+61
-33
openassessment/data.py
+10
-11
openassessment/tests/test_data.py
+51
-22
No files found.
openassessment/data.py
View file @
4f5bf806
...
@@ -4,6 +4,7 @@ Aggregate data for openassessment.
...
@@ -4,6 +4,7 @@ Aggregate data for openassessment.
import
csv
import
csv
import
json
import
json
from
collections
import
defaultdict
from
django.conf
import
settings
from
django.conf
import
settings
from
submissions
import
api
as
sub_api
from
submissions
import
api
as
sub_api
from
openassessment.workflow.models
import
AssessmentWorkflow
from
openassessment.workflow.models
import
AssessmentWorkflow
...
@@ -497,12 +498,13 @@ class OraAggregateData(object):
...
@@ -497,12 +498,13 @@ class OraAggregateData(object):
return
header
,
rows
return
header
,
rows
@classmethod
@classmethod
def
collect_ora2_responses
(
cls
,
course_id
):
def
collect_ora2_responses
(
cls
,
course_id
,
desired_statuses
=
None
):
"""
"""
Get information about all ora2 blocks in the course with response count for each step
Get information about all ora2 blocks in the course with response count for each step
Args:
Args:
course_id (string) - the course id of the course whose data we would like to return
course_id (string) - the course id of the course whose data we would like to return
desired_statuses (list) - statuses to return in the result dict for each ora item
Returns:
Returns:
A dict in the format:
A dict in the format:
...
@@ -516,22 +518,19 @@ class OraAggregateData(object):
...
@@ -516,22 +518,19 @@ class OraAggregateData(object):
}
}
"""
"""
except_statuses
=
[
'ai'
,
'cancelled'
]
if
desired_statuses
:
statuses
=
[
st
for
st
in
AssessmentWorkflow
()
.
STATUS_VALUES
if
st
not
in
except_statuses
]
statuses
=
[
st
for
st
in
AssessmentWorkflow
()
.
STATUS_VALUES
if
st
in
desired_statuses
]
statuses
.
append
(
'total'
)
else
:
statuses
=
AssessmentWorkflow
()
.
STATUS_VALUES
items
=
AssessmentWorkflow
.
objects
.
filter
(
course_id
=
course_id
)
.
values
(
'item_id'
,
'status'
)
items
=
AssessmentWorkflow
.
objects
.
filter
(
course_id
=
course_id
,
status__in
=
statuses
)
.
values
(
'item_id'
,
'status'
)
result
=
{}
result
=
defaultdict
(
lambda
:
{
status
:
0
for
status
in
statuses
})
for
item
in
items
:
for
item
in
items
:
item_id
=
item
[
'item_id'
]
item_id
=
item
[
'item_id'
]
status
=
item
[
'status'
]
status
=
item
[
'status'
]
if
item_id
not
in
result
:
result
[
item_id
][
'total'
]
=
result
[
item_id
]
.
get
(
'total'
,
0
)
+
1
result
[
item_id
]
=
{}
for
st
in
statuses
:
result
[
item_id
][
st
]
=
0
if
status
in
statuses
:
if
status
in
statuses
:
result
[
item_id
][
status
]
+=
1
result
[
item_id
][
status
]
+=
1
result
[
item_id
][
'total'
]
+=
1
return
result
return
result
openassessment/tests/test_data.py
View file @
4f5bf806
...
@@ -20,14 +20,10 @@ import openassessment.assessment.api.peer as peer_api
...
@@ -20,14 +20,10 @@ 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"
ITEM_ID2
=
"item_two"
ITEM_ID3
=
"item_three"
STUDENT_ITEM
=
dict
(
STUDENT_ITEM
=
dict
(
student_id
=
STUDENT_ID
,
student_id
=
STUDENT_ID
,
...
@@ -412,6 +408,18 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest):
...
@@ -412,6 +408,18 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest):
feedback_dict
[
'submission_uuid'
]
=
submission_uuid
feedback_dict
[
'submission_uuid'
]
=
submission_uuid
peer_api
.
set_assessment_feedback
(
feedback_dict
)
peer_api
.
set_assessment_feedback
(
feedback_dict
)
def
_other_student
(
self
,
n
):
"""
n is an integer to postfix, for example _other_student(3) would return "Student_3"
"""
return
STUDENT_ID
+
'_'
+
str
(
n
)
def
_other_item
(
self
,
n
):
"""
n is an integer to postfix, for example _other_item(4) would return "item_4"
"""
return
ITEM_ID
+
'_'
+
str
(
n
)
def
test_collect_ora2_data
(
self
):
def
test_collect_ora2_data
(
self
):
headers
,
data
=
OraAggregateData
.
collect_ora2_data
(
COURSE_ID
)
headers
,
data
=
OraAggregateData
.
collect_ora2_data
(
COURSE_ID
)
...
@@ -480,51 +488,72 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest):
...
@@ -480,51 +488,72 @@ class TestOraAggregateDataIntegration(TransactionCacheResetTest):
])
])
def
test_collect_ora2_responses
(
self
):
def
test_collect_ora2_responses
(
self
):
item_id2
=
self
.
_other_item
(
2
)
item_id3
=
self
.
_other_item
(
3
)
student_id2
=
self
.
_other_student
(
2
)
student_id3
=
self
.
_other_student
(
3
)
self
.
_create_submission
(
dict
(
self
.
_create_submission
(
dict
(
student_id
=
STUDENT_ID
,
student_id
=
STUDENT_ID
,
course_id
=
COURSE_ID
,
course_id
=
COURSE_ID
,
item_id
=
ITEM_ID
2
,
item_id
=
item_id
2
,
item_type
=
"openassessment"
item_type
=
"openassessment"
),
[
'self'
])
),
[
'self'
])
self
.
_create_submission
(
dict
(
self
.
_create_submission
(
dict
(
student_id
=
STUDENT_ID
2
,
student_id
=
student_id
2
,
course_id
=
COURSE_ID
,
course_id
=
COURSE_ID
,
item_id
=
ITEM_ID
2
,
item_id
=
item_id
2
,
item_type
=
"openassessment"
item_type
=
"openassessment"
),
STEPS
)
),
STEPS
)
self
.
_create_submission
(
dict
(
self
.
_create_submission
(
dict
(
student_id
=
STUDENT_ID
,
student_id
=
STUDENT_ID
,
course_id
=
COURSE_ID
,
course_id
=
COURSE_ID
,
item_id
=
ITEM_ID
3
,
item_id
=
item_id
3
,
item_type
=
"openassessment"
item_type
=
"openassessment"
),
[
'self'
])
),
[
'self'
])
self
.
_create_submission
(
dict
(
self
.
_create_submission
(
dict
(
student_id
=
STUDENT_ID
2
,
student_id
=
student_id
2
,
course_id
=
COURSE_ID
,
course_id
=
COURSE_ID
,
item_id
=
ITEM_ID
3
,
item_id
=
item_id
3
,
item_type
=
"openassessment"
item_type
=
"openassessment"
),
[
'self'
])
),
[
'self'
])
self
.
_create_submission
(
dict
(
self
.
_create_submission
(
dict
(
student_id
=
STUDENT_ID
3
,
student_id
=
student_id
3
,
course_id
=
COURSE_ID
,
course_id
=
COURSE_ID
,
item_id
=
ITEM_ID
3
,
item_id
=
item_id
3
,
item_type
=
"openassessment"
item_type
=
"openassessment"
),
STEPS
)
),
STEPS
)
data
=
OraAggregateData
.
collect_ora2_responses
(
COURSE_ID
)
data
=
OraAggregateData
.
collect_ora2_responses
(
COURSE_ID
)
self
.
assertIn
(
ITEM_ID
,
data
)
self
.
assertIn
(
ITEM_ID
,
data
)
self
.
assertIn
(
ITEM_ID2
,
data
)
self
.
assertIn
(
item_id2
,
data
)
self
.
assertIn
(
ITEM_ID3
,
data
)
self
.
assertIn
(
item_id3
,
data
)
for
item
in
[
ITEM_ID
,
ITEM_ID2
,
ITEM_ID3
]:
for
item
in
[
ITEM_ID
,
item_id2
,
item_id3
]:
self
.
assertEqual
({
'total'
,
'training'
,
'peer'
,
'self'
,
'staff'
,
'waiting'
,
'done'
},
set
(
data
[
item
]
.
keys
()))
self
.
assertEqual
({
'total'
,
'training'
,
'peer'
,
'self'
,
'staff'
,
'waiting'
,
'done'
,
'ai'
,
'cancelled'
},
set
(
data
[
item
]
.
keys
()))
self
.
assertEqual
(
data
[
ITEM_ID
],
{
self
.
assertEqual
(
data
[
ITEM_ID
],
{
'total'
:
2
,
'training'
:
0
,
'peer'
:
2
,
'self'
:
0
,
'staff'
:
0
,
'waiting'
:
0
,
'done'
:
0
'total'
:
2
,
'training'
:
0
,
'peer'
:
2
,
'self'
:
0
,
'staff'
:
0
,
'waiting'
:
0
,
'done'
:
0
,
'ai'
:
0
,
'cancelled'
:
0
})
})
self
.
assertEqual
(
data
[
ITEM_ID2
],
{
self
.
assertEqual
(
data
[
item_id2
],
{
'total'
:
2
,
'training'
:
0
,
'peer'
:
1
,
'self'
:
1
,
'staff'
:
0
,
'waiting'
:
0
,
'done'
:
0
'total'
:
2
,
'training'
:
0
,
'peer'
:
1
,
'self'
:
1
,
'staff'
:
0
,
'waiting'
:
0
,
'done'
:
0
,
'ai'
:
0
,
'cancelled'
:
0
})
})
self
.
assertEqual
(
data
[
ITEM_ID3
],
{
self
.
assertEqual
(
data
[
item_id3
],
{
'total'
:
3
,
'training'
:
0
,
'peer'
:
1
,
'self'
:
2
,
'staff'
:
0
,
'waiting'
:
0
,
'done'
:
0
'total'
:
3
,
'training'
:
0
,
'peer'
:
1
,
'self'
:
2
,
'staff'
:
0
,
'waiting'
:
0
,
'done'
:
0
,
'ai'
:
0
,
'cancelled'
:
0
})
})
data
=
OraAggregateData
.
collect_ora2_responses
(
COURSE_ID
,
[
'staff'
,
'peer'
])
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'
,
'peer'
,
'staff'
},
set
(
data
[
item
]
.
keys
()))
self
.
assertEqual
(
data
[
ITEM_ID
],
{
'total'
:
2
,
'peer'
:
2
,
'staff'
:
0
})
self
.
assertEqual
(
data
[
item_id2
],
{
'total'
:
1
,
'peer'
:
1
,
'staff'
:
0
})
self
.
assertEqual
(
data
[
item_id3
],
{
'total'
:
1
,
'peer'
:
1
,
'staff'
:
0
})
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