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
9355cc55
Commit
9355cc55
authored
Jun 05, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #406 from edx/sanchez/TIM-612-Workflow-API-Rollback-Support
Pass over unknown workflow steps.
parents
ab7cfa6b
406e7122
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
4 deletions
+67
-4
apps/openassessment/workflow/models.py
+2
-1
apps/openassessment/workflow/test/test_api.py
+65
-3
No files found.
apps/openassessment/workflow/models.py
View file @
9355cc55
...
...
@@ -189,7 +189,8 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
Simple helper function for retrieving all the steps in the given
Workflow.
"""
steps
=
list
(
self
.
steps
.
all
())
# Do not return steps that are not recognized in the AssessmentWorkflow.
steps
=
list
(
self
.
steps
.
filter
(
name__in
=
AssessmentWorkflow
.
STEPS
))
if
not
steps
:
# If no steps exist for this AssessmentWorkflow, assume
# peer -> self for backwards compatibility
...
...
apps/openassessment/workflow/test/test_api.py
View file @
9355cc55
...
...
@@ -11,6 +11,8 @@ from submissions.models import Submission
import
openassessment.workflow.api
as
workflow_api
from
openassessment.assessment.models
import
StudentTrainingWorkflow
import
submissions.api
as
sub_api
from
openassessment.assessment.api
import
peer
as
peer_api
from
openassessment.assessment.api
import
self
as
self_api
ITEM_1
=
{
"student_id"
:
"Optimus Prime 001"
,
...
...
@@ -53,6 +55,60 @@ class TestAssessmentWorkflowApi(CacheResetTest):
peer_workflows
=
list
(
PeerWorkflow
.
objects
.
filter
(
submission_uuid
=
submission
[
"uuid"
]))
self
.
assertFalse
(
peer_workflows
)
def
test_assessment_module_rollback_update_workflow
(
self
):
"""
Test that updates work when assessment modules roll back
This test is designed to instantiate a workflow with an installed
assessment module, then verify the workflow can be updated even when
the status is set to an uninstalled assessment module.
"""
requirements
=
{
"special"
:
{},
"peer"
:
{
"must_grade"
:
1
,
"must_be_graded_by"
:
1
},
"self"
:
{}
}
# We'll cheat to create the workflow with the new 'special' status,
# otherwise the creation logic will not allow unknown an unknown status
# to be set.
real_steps
=
AssessmentWorkflow
.
STEPS
AssessmentWorkflow
.
STEPS
=
[
"special"
]
+
real_steps
workflow
,
submission
=
self
.
_create_workflow_with_status
(
"user 1"
,
"test/1/1"
,
"peer-problem"
,
"special"
,
steps
=
[
"special"
,
"peer"
,
"self"
])
AssessmentWorkflow
.
STEPS
=
real_steps
workflow_api
.
get_workflow_for_submission
(
submission
[
"uuid"
],
requirements
)
peer_workflows
=
list
(
PeerWorkflow
.
objects
.
filter
(
submission_uuid
=
submission
[
"uuid"
]))
self
.
assertTrue
(
peer_workflows
)
with
patch
.
object
(
peer_api
,
'submitter_is_finished'
)
as
mock_peer_submit
:
mock_peer_submit
.
return_value
=
True
workflow
=
workflow_api
.
get_workflow_for_submission
(
submission
[
"uuid"
],
requirements
)
self
.
assertEquals
(
"self"
,
workflow
[
'status'
])
with
patch
.
object
(
self_api
,
'submitter_is_finished'
)
as
mock_self_submit
:
mock_self_submit
.
return_value
=
True
workflow
=
workflow_api
.
get_workflow_for_submission
(
submission
[
"uuid"
],
requirements
)
self
.
assertEquals
(
"waiting"
,
workflow
[
'status'
])
def
test_update_peer_workflow
(
self
):
submission
=
sub_api
.
create_submission
(
ITEM_1
,
"Shoot Hot Rod"
)
workflow
=
workflow_api
.
create_workflow
(
submission
[
"uuid"
],
[
"training"
,
"peer"
])
...
...
@@ -195,7 +251,8 @@ class TestAssessmentWorkflowApi(CacheResetTest):
updated_counts
=
workflow_api
.
get_status_counts
(
"test/1/1"
,
"peer-problem"
,
[
"peer"
,
"self"
])
self
.
assertEqual
(
counts
,
updated_counts
)
def
_create_workflow_with_status
(
self
,
student_id
,
course_id
,
item_id
,
status
,
answer
=
"answer"
):
def
_create_workflow_with_status
(
self
,
student_id
,
course_id
,
item_id
,
status
,
answer
=
"answer"
,
steps
=
None
):
"""
Create a submission and workflow with a given status.
...
...
@@ -207,10 +264,14 @@ class TestAssessmentWorkflowApi(CacheResetTest):
Kwargs:
answer (unicode): Submission answer.
steps (list): A list of steps to create the workflow with. If not
specified the default steps are "peer", "self".
Returns:
None
workflow, submission
"""
if
not
steps
:
steps
=
[
"peer"
,
"self"
]
submission
=
sub_api
.
create_submission
({
"student_id"
:
student_id
,
"course_id"
:
course_id
,
...
...
@@ -218,7 +279,8 @@ class TestAssessmentWorkflowApi(CacheResetTest):
"item_type"
:
"openassessment"
,
},
answer
)
workflow
=
workflow_api
.
create_workflow
(
submission
[
'uuid'
],
[
"peer"
,
"self"
]
)
workflow
=
workflow_api
.
create_workflow
(
submission
[
'uuid'
],
steps
)
workflow_model
=
AssessmentWorkflow
.
objects
.
get
(
uuid
=
workflow
[
'uuid'
])
workflow_model
.
status
=
status
workflow_model
.
save
()
return
workflow
,
submission
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