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
733dd4fe
Commit
733dd4fe
authored
May 14, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Student training handles changes to rubric and examples mid-flight.
parent
f94334ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
19 deletions
+74
-19
apps/openassessment/assessment/api/student_training.py
+0
-0
apps/openassessment/assessment/models/student_training.py
+74
-19
apps/openassessment/assessment/test/test_student_training.py
+0
-0
No files found.
apps/openassessment/assessment/api/student_training.py
View file @
733dd4fe
This diff is collapsed.
Click to expand it.
apps/openassessment/assessment/models/student_training.py
View file @
733dd4fe
...
@@ -27,14 +27,12 @@ class StudentTrainingWorkflow(models.Model):
...
@@ -27,14 +27,12 @@ class StudentTrainingWorkflow(models.Model):
app_label
=
"assessment"
app_label
=
"assessment"
@classmethod
@classmethod
@transaction.commit_on_success
def
get_or_create_workflow
(
cls
,
submission_uuid
):
def
create_workflow
(
cls
,
submission_uuid
,
examples
):
"""
"""
Create a student training workflow.
Create a student training workflow.
Args:
Args:
submission_uuid (str): The UUID of the submission from the student being trained.
submission_uuid (str): The UUID of the submission from the student being trained.
examples (list of TrainingExamples): The training examples to show the student.
Returns:
Returns:
StudentTrainingWorkflow
StudentTrainingWorkflow
...
@@ -43,27 +41,48 @@ class StudentTrainingWorkflow(models.Model):
...
@@ -43,27 +41,48 @@ class StudentTrainingWorkflow(models.Model):
SubmissionError: There was an error retrieving the submission.
SubmissionError: There was an error retrieving the submission.
"""
"""
# Try to retrieve an existing workflow
# If we find one, return it immediately
try
:
return
cls
.
objects
.
get
(
submission_uuid
=
submission_uuid
)
# pylint:disable=E1101
except
cls
.
DoesNotExist
:
pass
# Retrieve the student item info
# Retrieve the student item info
submission
=
sub_api
.
get_submission_and_student
(
submission_uuid
)
submission
=
sub_api
.
get_submission_and_student
(
submission_uuid
)
student_item
=
submission
[
'student_item'
]
student_item
=
submission
[
'student_item'
]
# Create the workflow
# Create the workflow
workflow
=
cls
.
objects
.
create
(
return
cls
.
objects
.
create
(
submission_uuid
=
submission_uuid
,
submission_uuid
=
submission_uuid
,
student_id
=
student_item
[
'student_id'
],
student_id
=
student_item
[
'student_id'
],
item_id
=
student_item
[
'item_id'
],
item_id
=
student_item
[
'item_id'
],
course_id
=
student_item
[
'course_id'
]
course_id
=
student_item
[
'course_id'
]
)
)
# Create workflow items for each example
@transaction.commit_on_success
for
order_num
,
example
in
enumerate
(
examples
):
def
create_workflow_item
(
self
,
training_example
):
StudentTrainingWorkflowItem
.
objects
.
create
(
"""
workflow
=
workflow
,
Create a workflow item for a training example
order_num
=
order_num
,
and add it to the workflow.
training_example
=
example
,
)
Args:
training_example (TrainingExample): The training example model
associated with the next workflow item.
Returns:
StudentTrainingWorkflowItem
return
workflow
"""
order_num
=
self
.
items
.
count
()
+
1
# pylint:disable=E1101
item
=
StudentTrainingWorkflowItem
.
objects
.
create
(
workflow
=
self
,
order_num
=
order_num
,
training_example
=
training_example
)
self
.
items
.
add
(
item
)
# pylint:disable=E1101
self
.
save
()
return
item
@property
@property
def
status
(
self
):
def
status
(
self
):
...
@@ -80,21 +99,57 @@ class StudentTrainingWorkflow(models.Model):
...
@@ -80,21 +99,57 @@ class StudentTrainingWorkflow(models.Model):
return
num_complete
,
num_total
return
num_complete
,
num_total
@property
@property
def
is_complete
(
self
):
def
num_completed
(
self
):
"""
"""
Check whether all items in the workflow are complete.
Return the number of training examples that the
student successfully assessed.
Returns:
Returns:
bool
int
"""
"""
num_incomplete
=
self
.
items
.
filter
(
completed_at__isnull
=
True
)
.
count
()
# pylint:disable=E1101
return
self
.
items
.
filter
(
completed_at__isnull
=
False
)
.
count
()
# pylint:disable=E1101
return
num_incomplete
==
0
@property
def
next_incomplete_item
(
self
,
examples
):
def
next_incomplete_item
(
self
):
"""
"""
Find the next incomplete item in the workflow.
Find the next incomplete item in the workflow.
Args:
examples (list of TrainingExample): Training examples to choose from.
Returns:
StudentTrainingWorkflowItem or None
"""
# If we're already working on an item, then return that item
current_item
=
self
.
current_item
if
current_item
is
not
None
:
return
current_item
# Otherwise, pick an item that we have not completed
# from the list of examples.
completed_examples
=
[
item
.
training_example
for
item
in
self
.
items
.
all
()
# pylint:disable=E1101
]
available_examples
=
[
available
for
available
in
examples
if
available
not
in
completed_examples
]
# If there are no more items available, return None
if
len
(
available_examples
)
==
0
:
return
None
# Otherwise, create a new workflow item for the example
# and add it to the workflow
else
:
return
self
.
create_workflow_item
(
available_examples
[
0
])
@property
def
current_item
(
self
):
"""
Return the item the student is currently working on,
or None.
Returns:
Returns:
StudentTrainingWorkflowItem or None
StudentTrainingWorkflowItem or None
...
...
apps/openassessment/assessment/test/test_student_training.py
View file @
733dd4fe
This diff is collapsed.
Click to expand it.
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