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
71130ce8
Commit
71130ce8
authored
Feb 05, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a uuid to the submission model object
parent
58733b0d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
27 deletions
+51
-27
apps/openassessment/peer/api.py
+5
-5
apps/openassessment/peer/test/test_api.py
+35
-21
apps/submissions/models.py
+3
-0
apps/submissions/serializers.py
+8
-1
No files found.
apps/openassessment/peer/api.py
View file @
71130ce8
...
...
@@ -62,7 +62,7 @@ class PeerEvaluationInternalError(PeerEvaluationError):
pass
def
create_evaluation
(
submission_id
,
scorer_id
,
assessment_dict
,
def
create_evaluation
(
submission_
uu
id
,
scorer_id
,
assessment_dict
,
scored_at
=
None
):
"""Creates an evaluation on the given submission.
...
...
@@ -70,8 +70,8 @@ def create_evaluation(submission_id, scorer_id, assessment_dict,
rubric.
Args:
submission_
id (str): The submission
id this assessment is associated
with. The submission
_
id is required and must already exist in the
submission_
uuid (str): The submission uu
id this assessment is associated
with. The submission
uu
id is required and must already exist in the
Submission model.
scorer_id (str): The user ID for the user giving this assessment. This
is required to create an assessment on a submission.
...
...
@@ -110,7 +110,7 @@ def create_evaluation(submission_id, scorer_id, assessment_dict,
"""
try
:
submission
=
Submission
.
objects
.
get
(
pk
=
submission_id
)
submission
=
Submission
.
objects
.
get
(
pk
=
submission_
uu
id
)
peer_evaluation
=
{
"scorer_id"
:
scorer_id
,
"submission"
:
submission
.
pk
,
...
...
@@ -130,7 +130,7 @@ def create_evaluation(submission_id, scorer_id, assessment_dict,
except
DatabaseError
:
error_message
=
u"An error occurred while creating evaluation {} for submission: {} by: {}"
.
format
(
assessment_dict
,
submission_id
,
submission_
uu
id
,
scorer_id
)
logger
.
exception
(
error_message
)
...
...
apps/openassessment/peer/test/test_api.py
View file @
71130ce8
...
...
@@ -28,9 +28,9 @@ THURSDAY = datetime.datetime(2007, 9, 16, 0, 0, 0, 0, pytz.UTC)
@ddt
class
TestApi
(
TestCase
):
def
test_create_evaluation
(
self
):
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
submission
=
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
evaluation
=
api
.
create_evaluation
(
"1"
,
submission
[
"uuid"
]
,
STUDENT_ITEM
[
"student_id"
],
ASSESSMENT_DICT
)
...
...
@@ -38,33 +38,40 @@ class TestApi(TestCase):
@file_data
(
'test_valid_evaluations.json'
)
def
test_get_evaluations
(
self
,
assessment_dict
):
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
api
.
create_evaluation
(
"1"
,
STUDENT_ITEM
[
"student_id"
],
assessment_dict
)
evaluations
=
api
.
get_evaluations
(
"1"
)
submission
=
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
api
.
create_evaluation
(
submission
[
"uuid"
],
STUDENT_ITEM
[
"student_id"
],
assessment_dict
)
evaluations
=
api
.
get_evaluations
(
submission
[
"uuid"
])
self
.
assertEqual
(
1
,
len
(
evaluations
))
self
.
_assert_evaluation
(
evaluations
[
0
],
**
assessment_dict
)
@file_data
(
'test_valid_evaluations.json'
)
def
test_get_evaluations_with_date
(
self
,
assessment_dict
):
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
submission
=
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
api
.
create_evaluation
(
"1"
,
STUDENT_ITEM
[
"student_id"
],
assessment_dict
,
MONDAY
submission
[
"uuid"
],
STUDENT_ITEM
[
"student_id"
],
assessment_dict
,
MONDAY
)
evaluations
=
api
.
get_evaluations
(
"1"
)
evaluations
=
api
.
get_evaluations
(
submission
[
"uuid"
]
)
self
.
assertEqual
(
1
,
len
(
evaluations
))
self
.
_assert_evaluation
(
evaluations
[
0
],
**
assessment_dict
)
self
.
assertEqual
(
evaluations
[
0
][
"scored_at"
],
MONDAY
)
def
test_student_finished_evaluating
(
self
):
self
.
_create_student_and_submission
(
"Bob"
,
"Bob's answer"
)
self
.
_create_student_and_submission
(
"Sally"
,
"Sally's answer"
)
self
.
_create_student_and_submission
(
"Jim"
,
"Jim's answer"
)
bob
=
self
.
_create_student_and_submission
(
"Bob"
,
"Bob's answer"
)
s
ally
=
s
elf
.
_create_student_and_submission
(
"Sally"
,
"Sally's answer"
)
jim
=
self
.
_create_student_and_submission
(
"Jim"
,
"Jim's answer"
)
self
.
assertFalse
(
api
.
has_finished_required_evaluating
(
"Tim"
,
3
))
api
.
create_evaluation
(
"1"
,
"Tim"
,
ASSESSMENT_DICT
)
api
.
create_evaluation
(
"2"
,
"Tim"
,
ASSESSMENT_DICT
)
api
.
create_evaluation
(
bob
[
"uuid"
]
,
"Tim"
,
ASSESSMENT_DICT
)
api
.
create_evaluation
(
sally
[
"uuid"
]
,
"Tim"
,
ASSESSMENT_DICT
)
self
.
assertFalse
(
api
.
has_finished_required_evaluating
(
"Tim"
,
3
))
api
.
create_evaluation
(
"3"
,
"Tim"
,
ASSESSMENT_DICT
)
api
.
create_evaluation
(
jim
[
"uuid"
]
,
"Tim"
,
ASSESSMENT_DICT
)
self
.
assertTrue
(
api
.
has_finished_required_evaluating
(
"Tim"
,
3
))
@raises
(
api
.
PeerEvaluationRequestError
)
...
...
@@ -97,25 +104,32 @@ class TestApi(TestCase):
@raises
(
api
.
PeerEvaluationInternalError
)
def
test_error_on_evaluation_creation
(
self
,
mock_filter
):
mock_filter
.
side_effect
=
DatabaseError
(
"Bad things happened"
)
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
submission
=
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
api
.
create_evaluation
(
"1"
,
STUDENT_ITEM
[
"student_id"
],
ASSESSMENT_DICT
,
MONDAY
submission
[
"uuid"
],
STUDENT_ITEM
[
"student_id"
],
ASSESSMENT_DICT
,
MONDAY
)
@patch.object
(
PeerEvaluation
.
objects
,
'filter'
)
@raises
(
api
.
PeerEvaluationInternalError
)
def
test_error_on_get_evaluation
(
self
,
mock_filter
):
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
api
.
create_evaluation
(
"1"
,
STUDENT_ITEM
[
"student_id"
],
ASSESSMENT_DICT
,
MONDAY
)
submission
=
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
api
.
create_evaluation
(
submission
[
"uuid"
],
STUDENT_ITEM
[
"student_id"
],
ASSESSMENT_DICT
,
MONDAY
)
mock_filter
.
side_effect
=
DatabaseError
(
"Bad things happened"
)
api
.
get_evaluations
(
"1"
)
api
.
get_evaluations
(
submission
[
"uuid"
]
)
@staticmethod
def
_create_student_and_submission
(
student
,
answer
,
date
=
None
):
new_student_item
=
STUDENT_ITEM
.
copy
()
new_student_item
[
"student_id"
]
=
student
create_submission
(
new_student_item
,
answer
,
date
)
return
create_submission
(
new_student_item
,
answer
,
date
)
def
_assert_evaluation
(
self
,
evaluation
,
points_earned
,
points_possible
,
feedback
):
...
...
apps/submissions/models.py
View file @
71130ce8
...
...
@@ -5,6 +5,7 @@ different problem types, and is therefore ignorant of ORA workflow.
"""
from
django.db
import
models
from
django.utils.timezone
import
now
from
django_extensions.db.fields
import
UUIDField
class
StudentItem
(
models
.
Model
):
...
...
@@ -52,6 +53,8 @@ class Submission(models.Model):
because it makes caching trivial.
"""
uuid
=
UUIDField
(
primary_key
=
True
)
student_item
=
models
.
ForeignKey
(
StudentItem
)
# Which attempt is this? Consecutive Submissions do not necessarily have
...
...
apps/submissions/serializers.py
View file @
71130ce8
...
...
@@ -15,7 +15,14 @@ class StudentItemSerializer(serializers.ModelSerializer):
class
SubmissionSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Submission
fields
=
(
'student_item'
,
'attempt_number'
,
'submitted_at'
,
'created_at'
,
'answer'
)
fields
=
(
'uuid'
,
'student_item'
,
'attempt_number'
,
'submitted_at'
,
'created_at'
,
'answer'
)
class
ScoreSerializer
(
serializers
.
ModelSerializer
):
...
...
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