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
bac7e995
Commit
bac7e995
authored
Dec 18, 2014
by
muzaffaryousaf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the test for assessing cancelled sub.
Minor code refactoring. TNL-900
parent
387521a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
10 deletions
+59
-10
openassessment/assessment/api/peer.py
+4
-10
openassessment/assessment/models/peer.py
+14
-0
openassessment/assessment/test/test_peer.py
+41
-0
No files found.
openassessment/assessment/api/peer.py
View file @
bac7e995
...
...
@@ -956,8 +956,8 @@ def cancel_submission_peer_workflow(submission_uuid, comments, cancelled_by_id):
Args:
submission_uuid (str): The UUID of the peer workflow's submission.
comments: The reason for cancellation.
cancelled_by_id: The ID of the user who cancelled the peer workflow.
comments
(str)
: The reason for cancellation.
cancelled_by_id
(str)
: The ID of the user who cancelled the peer workflow.
"""
try
:
workflow
=
PeerWorkflow
.
objects
.
get
(
submission_uuid
=
submission_uuid
)
...
...
@@ -983,14 +983,8 @@ def get_submission_cancellation(submission_uuid):
submission_uuid (str): The UUID of the peer workflow's submission.
"""
try
:
workflow
=
PeerWorkflow
.
objects
.
get
(
submission_uuid
=
submission_uuid
)
workflow_cancellation
=
workflow
.
cancellations
.
latest
(
'created_at'
)
return
PeerWorkflowCancellationSerializer
(
workflow_cancellation
)
.
data
except
(
PeerWorkflow
.
DoesNotExist
,
PeerWorkflowCancellation
.
DoesNotExist
,
):
return
None
workflow_cancellation
=
PeerWorkflowCancellation
.
get_latest_workflow_cancellation
(
submission_uuid
=
submission_uuid
)
return
PeerWorkflowCancellationSerializer
(
workflow_cancellation
)
.
data
if
workflow_cancellation
else
None
except
DatabaseError
:
error_message
=
u"Error finding peer workflow cancellation for submission UUID {}."
.
format
(
submission_uuid
)
logger
.
exception
(
error_message
)
...
...
openassessment/assessment/models/peer.py
View file @
bac7e995
...
...
@@ -521,3 +521,17 @@ class PeerWorkflowCancellation(models.Model):
'cancelled_by_id'
:
cancelled_by_id
,
}
return
cls
.
objects
.
create
(
**
cancellation_params
)
@classmethod
def
get_latest_workflow_cancellation
(
cls
,
submission_uuid
):
"""
Get the latest PeerWorkflowCancellation for a submission's workflow.
Args:
submission_uuid (str): The UUID of the peer workflow's submission.
Returns:
PeerWorkflowCancellation or None
"""
workflow_cancellations
=
cls
.
objects
.
filter
(
workflow__submission_uuid
=
submission_uuid
)
.
order_by
(
"-created_at"
)
return
workflow_cancellations
[
0
]
if
workflow_cancellations
.
exists
()
else
None
openassessment/assessment/test/test_peer.py
View file @
bac7e995
...
...
@@ -893,6 +893,47 @@ class TestPeerApi(CacheResetTest):
item
=
buffy_workflow
.
find_active_assessments
()
self
.
assertIsNone
(
item
)
@raises
(
peer_api
.
PeerAssessmentWorkflowError
)
def
test_assess_the_cancelled_submission
(
self
):
# This will assess the pulled out submission to assess.
buffy_sub
,
buffy
=
self
.
_create_student_and_submission
(
"Buffy"
,
"Buffy's answer"
)
xander_sub
,
xander
=
self
.
_create_student_and_submission
(
"Xander"
,
"Xander's answer"
)
# Check for a workflow for Buffy.
buffy_workflow
=
PeerWorkflow
.
get_by_submission_uuid
(
buffy_sub
[
'uuid'
])
self
.
assertIsNotNone
(
buffy_workflow
)
# Buffy is going to review Xander's submission, so create a workflow
# item for Buffy.
PeerWorkflow
.
create_item
(
buffy_workflow
,
xander_sub
[
"uuid"
])
# Check to see if Buffy is actively reviewing Xander's submission.
item
=
buffy_workflow
.
find_active_assessments
()
self
.
assertEqual
(
xander_sub
[
"uuid"
],
item
.
submission_uuid
)
# Cancel the Xander's submission.
xander_workflow
=
PeerWorkflow
.
get_by_submission_uuid
(
xander_sub
[
'uuid'
])
PeerWorkflowCancellation
.
create
(
workflow
=
xander_workflow
,
comments
=
'Cancellation reason'
,
cancelled_by_id
=
buffy
[
'student_id'
]
)
# Check to see if Buffy is actively reviewing Xander's submission.
# She isn't able to get the submission to assess.
item
=
buffy_workflow
.
find_active_assessments
()
self
.
assertIsNone
(
item
)
# Try to assess the cancelled submission
# This will raise PeerAssessmentWorkflowError
peer_api
.
create_assessment
(
buffy_sub
[
'uuid'
],
buffy
[
"student_id"
],
ASSESSMENT_DICT
[
'options_selected'
],
ASSESSMENT_DICT
[
'criterion_feedback'
],
ASSESSMENT_DICT
[
'overall_feedback'
],
RUBRIC_DICT
,
REQUIRED_GRADED_BY
,
)
def
test_get_workflow_by_uuid
(
self
):
buffy_answer
,
_
=
self
.
_create_student_and_submission
(
"Buffy"
,
"Buffy's answer"
)
self
.
_create_student_and_submission
(
"Xander"
,
"Xander's answer"
)
...
...
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