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
5d73dc4b
Commit
5d73dc4b
authored
Feb 03, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quick commit in case we get snowed in
parent
20dab883
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
8 deletions
+55
-8
apps/openassessment/peer/api.py
+55
-8
No files found.
apps/openassessment/peer/api.py
View file @
5d73dc4b
...
@@ -4,6 +4,17 @@ The Peer Evaluation Workflow API exposes all public actions required to complete
...
@@ -4,6 +4,17 @@ The Peer Evaluation Workflow API exposes all public actions required to complete
the workflow for a given submission.
the workflow for a given submission.
"""
"""
import
copy
import
logging
from
django.db
import
DatabaseError
from
openassessment.peer.models
import
PeerEvaluation
from
openassessment.peer.serializers
import
PeerEvaluationSerializer
logger
=
logging
.
getLogger
(
__name__
)
PEER_TYPE
=
"Peer"
class
PeerEvaluationError
(
Exception
):
class
PeerEvaluationError
(
Exception
):
...
@@ -23,7 +34,10 @@ class PeerEvaluationRequestError(PeerEvaluationError):
...
@@ -23,7 +34,10 @@ class PeerEvaluationRequestError(PeerEvaluationError):
information which does not allow the request to be processed.
information which does not allow the request to be processed.
"""
"""
pass
def
__init__
(
self
,
field_errors
):
Exception
.
__init__
(
self
,
repr
(
field_errors
))
self
.
field_errors
=
copy
.
deepcopy
(
field_errors
)
class
PeerEvaluationWorkflowError
(
PeerEvaluationError
):
class
PeerEvaluationWorkflowError
(
PeerEvaluationError
):
...
@@ -46,7 +60,8 @@ class PeerEvaluationInternalError(PeerEvaluationError):
...
@@ -46,7 +60,8 @@ class PeerEvaluationInternalError(PeerEvaluationError):
pass
pass
def
create_evaluation
(
submission_id
,
scorer_id
,
assessment_dict
,
scored_at
=
None
):
def
create_evaluation
(
submission_id
,
scorer_id
,
assessment_dict
,
scored_at
=
None
):
"""Creates an evaluation on the given submission.
"""Creates an evaluation on the given submission.
Evaluations are created based on feedback associated with a particular
Evaluations are created based on feedback associated with a particular
...
@@ -92,10 +107,34 @@ def create_evaluation(submission_id, scorer_id, assessment_dict, scored_at=None)
...
@@ -92,10 +107,34 @@ def create_evaluation(submission_id, scorer_id, assessment_dict, scored_at=None)
}
}
"""
"""
pass
peer_evaluation
=
{
"scorer_id"
:
scorer_id
,
"submission_id"
:
submission_id
,
def
has_finished_required_evaluating
(
student_id
):
"points_earned"
:
sum
(
assessment_dict
[
"points_earned"
]),
"points_possible"
:
assessment_dict
[
"points_possible"
],
"score_type"
:
PEER_TYPE
,
"feedback"
:
assessment_dict
[
"feedback"
],
}
if
scored_at
:
peer_evaluation
[
"scored_at"
]
=
scored_at
try
:
peer_serializer
=
PeerEvaluationSerializer
(
data
=
peer_evaluation
)
if
not
peer_serializer
.
is_valid
():
raise
PeerEvaluationRequestError
(
peer_serializer
.
errors
)
peer_serializer
.
save
()
return
peer_serializer
.
data
except
DatabaseError
:
error_message
=
u"An error occurred while creating evaluation {} for submission: {} by: {}"
.
format
(
peer_evaluation
,
submission_id
,
scorer_id
)
logger
.
exception
(
error_message
)
raise
PeerEvaluationInternalError
(
error_message
)
def
has_finished_required_evaluating
(
student_id
,
required_evaluations
):
"""Check if a student still needs to evaluate more submissions
"""Check if a student still needs to evaluate more submissions
Per the contract of the peer assessment workflow, a student must evaluate a
Per the contract of the peer assessment workflow, a student must evaluate a
...
@@ -104,6 +143,9 @@ def has_finished_required_evaluating(student_id):
...
@@ -104,6 +143,9 @@ def has_finished_required_evaluating(student_id):
Args:
Args:
student_id (str): The student in the peer grading workflow to check for
student_id (str): The student in the peer grading workflow to check for
peer workflow criteria. This argument is required.
peer workflow criteria. This argument is required.
required_evaluations (int): The number of evaluations a student has to
submit before receiving the feedback on their submission. This is a
required argument.
Returns:
Returns:
bool: True if the student has evaluated enough peer submissions to move
bool: True if the student has evaluated enough peer submissions to move
...
@@ -111,7 +153,8 @@ def has_finished_required_evaluating(student_id):
...
@@ -111,7 +153,8 @@ def has_finished_required_evaluating(student_id):
evaluate more peer submissions.
evaluate more peer submissions.
Raises:
Raises:
PeerEvaluationRequestError: Raised when the student_id is invalid
PeerEvaluationRequestError: Raised when the student_id is invalid, or
the required_evaluations is not a positive integer.
PeerEvaluationInternalError: Raised when there is an internal error
PeerEvaluationInternalError: Raised when there is an internal error
while evaluating this workflow rule.
while evaluating this workflow rule.
...
@@ -120,7 +163,11 @@ def has_finished_required_evaluating(student_id):
...
@@ -120,7 +163,11 @@ def has_finished_required_evaluating(student_id):
True
True
"""
"""
pass
if
required_evaluations
<
0
:
raise
PeerEvaluationRequestError
(
"Required Evaluation count must be a positive integer."
)
return
PeerEvaluation
.
objects
.
filter
(
scorer_id
=
student_id
)
.
count
()
>=
required_evaluations
def
get_evaluations
(
submission_id
):
def
get_evaluations
(
submission_id
):
...
...
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