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
d24adc15
Commit
d24adc15
authored
May 16, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #334 from edx/will/multiple-objects-error
Fix for TIM-572
parents
afa783a4
d6cd4d55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
7 deletions
+60
-7
apps/openassessment/assessment/models/peer.py
+13
-4
apps/openassessment/assessment/test/test_models.py
+47
-3
No files found.
apps/openassessment/assessment/models/peer.py
View file @
d24adc15
...
...
@@ -178,14 +178,23 @@ class PeerWorkflow(models.Model):
peer_workflow
=
cls
.
get_by_submission_uuid
(
submission_uuid
)
try
:
workflow_item
,
__
=
PeerWorkflowItem
.
objects
.
get_or_create
(
workflow_item
s
=
PeerWorkflowItem
.
objects
.
filter
(
scorer
=
scorer_workflow
,
author
=
peer_workflow
,
submission_uuid
=
submission_uuid
)
workflow_item
.
started_at
=
now
()
workflow_item
.
save
()
return
workflow_item
if
len
(
workflow_items
)
>
0
:
item
=
workflow_items
[
0
]
else
:
item
=
PeerWorkflowItem
.
objects
.
create
(
scorer
=
scorer_workflow
,
author
=
peer_workflow
,
submission_uuid
=
submission_uuid
)
item
.
started_at
=
now
()
item
.
save
()
return
item
except
DatabaseError
:
error_message
=
_
(
u"An internal error occurred while creating a new peer workflow "
...
...
apps/openassessment/assessment/test/test_models.py
View file @
d24adc15
...
...
@@ -3,14 +3,12 @@
Tests for assessment models.
"""
import
mock
from
django.db
import
IntegrityError
from
openassessment.test_utils
import
CacheResetTest
from
submissions
import
api
as
sub_api
from
openassessment.assessment.models
import
(
Rubric
,
Criterion
,
CriterionOption
,
InvalidOptionSelection
,
AssessmentFeedback
,
AssessmentFeedbackOption
,
StudentTrainingWorkflow
PeerWorkflow
,
PeerWorkflowItem
)
...
...
@@ -202,3 +200,49 @@ class AssessmentFeedbackTest(CacheResetTest):
# There should be two options in the database
self
.
assertEqual
(
AssessmentFeedbackOption
.
objects
.
count
(),
2
)
class
PeerWorkflowTest
(
CacheResetTest
):
"""
Tests for the peer workflow model.
"""
STUDENT_ITEM
=
{
'student_id'
:
'test_student'
,
'course_id'
:
'test_course'
,
'item_type'
:
'openassessment'
,
'item_id'
:
'test_item'
}
OTHER_STUDENT
=
{
'student_id'
:
'test_student_2'
,
'course_id'
:
'test_course'
,
'item_type'
:
'openassessment'
,
'item_id'
:
'test_item'
}
def
test_create_item_multiple_available
(
self
):
# Bugfix TIM-572
submitter_sub
=
sub_api
.
create_submission
(
self
.
STUDENT_ITEM
,
'test answer'
)
submitter_workflow
=
PeerWorkflow
.
objects
.
create
(
student_id
=
self
.
STUDENT_ITEM
[
'student_id'
],
item_id
=
self
.
STUDENT_ITEM
[
'item_id'
],
course_id
=
self
.
STUDENT_ITEM
[
'course_id'
],
submission_uuid
=
submitter_sub
[
'uuid'
]
)
scorer_sub
=
sub_api
.
create_submission
(
self
.
OTHER_STUDENT
,
'test answer 2'
)
scorer_workflow
=
PeerWorkflow
.
objects
.
create
(
student_id
=
self
.
OTHER_STUDENT
[
'student_id'
],
item_id
=
self
.
OTHER_STUDENT
[
'item_id'
],
course_id
=
self
.
OTHER_STUDENT
[
'course_id'
],
submission_uuid
=
scorer_sub
[
'uuid'
]
)
for
_
in
range
(
2
):
PeerWorkflowItem
.
objects
.
create
(
scorer
=
scorer_workflow
,
author
=
submitter_workflow
,
submission_uuid
=
submitter_sub
[
'uuid'
]
)
# This used to cause an error when `get_or_create` returned multiple workflow items
PeerWorkflow
.
create_item
(
scorer_workflow
,
submitter_sub
[
'uuid'
])
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