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
ecc9dde1
Commit
ecc9dde1
authored
Mar 12, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #109 from edx/sanchez/fix-max-score
Updating the grade_mixin to allow max points
parents
77666852
089d03a1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
4 deletions
+66
-4
apps/openassessment/assessment/peer_api.py
+34
-0
apps/openassessment/assessment/test/test_peer.py
+25
-0
apps/openassessment/xblock/grade_mixin.py
+7
-4
No files found.
apps/openassessment/assessment/peer_api.py
View file @
ecc9dde1
...
...
@@ -211,6 +211,40 @@ def create_assessment(
raise
PeerAssessmentInternalError
(
error_message
)
def
get_rubric_max_scores
(
submission_uuid
):
"""Gets the maximum possible value for each criterion option
Iterates over the rubric used to grade the given submission, and creates a
dictionary of maximum possible values.
Args:
submission_uuid: The submission to get the associated rubric max scores.
Returns:
A dictionary of max scores for this rubric's criteria options. Returns
None if no assessments are found for this submission.
Raises:
PeerAssessmentInternalError: Raised when there is an error retrieving
the submission, or its associated rubric.
"""
try
:
submission
=
Submission
.
objects
.
get
(
uuid
=
submission_uuid
)
assessments
=
Assessment
.
objects
.
filter
(
submission
=
submission
)
.
order_by
(
"-scored_at"
,
"-id"
)
if
assessments
:
return
{
criterion
.
name
:
criterion
.
points_possible
for
criterion
in
assessments
[
0
]
.
rubric
.
criteria
.
all
()
}
except
Submission
.
DoesNotExist
:
return
None
except
DatabaseError
:
error_message
=
_
(
u"Error getting rubric options max scores for submission uuid "
u"[{}]"
.
format
(
submission_uuid
)
)
logger
.
exception
(
error_message
)
raise
PeerAssessmentInternalError
(
error_message
)
def
get_assessment_median_scores
(
submission_id
,
must_be_graded_by
):
"""Get the median score for each rubric criterion
...
...
apps/openassessment/assessment/test/test_peer.py
View file @
ecc9dde1
...
...
@@ -534,6 +534,31 @@ class TestPeerApi(TestCase):
submission
=
peer_api
.
get_submission_to_assess
(
STUDENT_ITEM
,
3
)
self
.
assertIsNone
(
submission
)
def
test_get_max_scores
(
self
):
self
.
_create_student_and_submission
(
"Tim"
,
"Tim's answer"
)
bob_sub
,
bob
=
self
.
_create_student_and_submission
(
"Bob"
,
"Bob's answer"
)
sub
=
peer_api
.
get_submission_to_assess
(
bob
,
1
)
assessment
=
peer_api
.
create_assessment
(
sub
[
"uuid"
],
bob
[
"student_id"
],
ASSESSMENT_DICT
,
RUBRIC_DICT
,
)
self
.
assertEqual
(
assessment
[
"points_earned"
],
6
)
self
.
assertEqual
(
assessment
[
"points_possible"
],
14
)
self
.
assertEqual
(
assessment
[
"feedback"
],
ASSESSMENT_DICT
[
"feedback"
])
max_scores
=
peer_api
.
get_rubric_max_scores
(
sub
[
"uuid"
])
self
.
assertEqual
(
max_scores
[
'secret'
],
1
)
self
.
assertEqual
(
max_scores
[
'giveup'
],
10
)
@patch.object
(
Assessment
.
objects
,
'filter'
)
@raises
(
peer_api
.
PeerAssessmentInternalError
)
def
test_max_score_db_error
(
self
,
mock_filter
):
mock_filter
.
side_effect
=
DatabaseError
(
"Bad things happened"
)
tim
,
_
=
self
.
_create_student_and_submission
(
"Tim"
,
"Tim's answer"
)
peer_api
.
get_rubric_max_scores
(
tim
[
"uuid"
])
@patch.object
(
Assessment
.
objects
,
'filter'
)
@raises
(
peer_api
.
PeerAssessmentInternalError
)
def
test_median_score_db_error
(
self
,
mock_filter
):
...
...
apps/openassessment/xblock/grade_mixin.py
View file @
ecc9dde1
import
copy
from
xblock.core
import
XBlock
from
openassessment.assessment.peer_api
import
get_assessments
from
openassessment.assessment
import
peer_api
class
GradeMixin
(
object
):
...
...
@@ -17,10 +16,10 @@ class GradeMixin(object):
@XBlock.handler
def
render_grade
(
self
,
data
,
suffix
=
''
):
workflow
=
self
.
get_workflow_info
()
status
=
workflow
.
get
(
'status'
)
context
=
{}
if
status
==
"done"
:
max_scores
=
peer_api
.
get_rubric_max_scores
(
self
.
submission_uuid
)
path
=
'openassessmentblock/grade/oa_grade_complete.html'
assessment_ui_model
=
self
.
get_assessment_module
(
'peer-assessment'
)
student_submission
=
self
.
get_user_submission
(
...
...
@@ -44,8 +43,12 @@ class GradeMixin(object):
context
[
"self_assessment"
]
=
self_assessment
context
[
"rubric_criteria"
]
=
copy
.
deepcopy
(
self
.
rubric_criteria
)
context
[
"score"
]
=
student_score
for
criterion
in
context
[
"rubric_criteria"
]:
criterion
[
"median_score"
]
=
median_scores
[
criterion
[
"name"
]]
if
median_scores
is
not
None
and
max_scores
is
not
None
:
for
criterion
in
context
[
"rubric_criteria"
]:
criterion
[
"median_score"
]
=
median_scores
[
criterion
[
"name"
]]
criterion
[
"total_value"
]
=
max_scores
[
criterion
[
"name"
]]
elif
workflow
.
get
(
'status'
)
==
"waiting"
:
path
=
'openassessmentblock/grade/oa_grade_waiting.html'
elif
not
status
:
...
...
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