Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
bc49d50f
Commit
bc49d50f
authored
Feb 27, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed the max points in the annotation response
parent
8f89768d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
19 deletions
+26
-19
common/lib/capa/capa/responsetypes.py
+26
-19
No files found.
common/lib/capa/capa/responsetypes.py
View file @
bc49d50f
...
...
@@ -1858,6 +1858,26 @@ class AnnotationResponse(LoncapaResponse):
xml
=
self
.
xml
self
.
scoring_map
=
self
.
_get_scoring_map
()
self
.
answer_map
=
self
.
_get_answer_map
()
self
.
maxpoints
=
self
.
_get_max_points
()
def
get_score
(
self
,
student_answers
):
''' Returns a CorrectMap for the student answer, which may include
partially correct answers.'''
student_answer
=
student_answers
[
self
.
answer_id
]
student_option
=
self
.
_get_submitted_option_id
(
student_answer
)
scoring
=
self
.
scoring_map
[
self
.
answer_id
]
is_valid
=
student_option
is
not
None
and
student_option
in
scoring
.
keys
()
(
correctness
,
points
)
=
(
'incorrect'
,
None
)
if
is_valid
:
correctness
=
scoring
[
student_option
][
'correctness'
]
points
=
scoring
[
student_option
][
'points'
]
return
CorrectMap
(
self
.
answer_id
,
correctness
=
correctness
,
npoints
=
points
)
def
get_answers
(
self
):
return
self
.
answer_map
def
_get_scoring_map
(
self
):
''' Returns a dict of option->scoring for each input. '''
...
...
@@ -1884,6 +1904,12 @@ class AnnotationResponse(LoncapaResponse):
answer_map
[
inputfield
.
get
(
'id'
)]
=
correct_option
.
get
(
'description'
)
return
answer_map
def
_get_max_points
(
self
):
''' Returns a dict of the max points for each input: input id -> maxpoints. '''
scoring
=
self
.
default_scoring
correct_points
=
scoring
.
get
(
'correct'
)
return
dict
([(
inputfield
.
get
(
'id'
),
correct_points
)
for
inputfield
in
self
.
inputfields
])
def
_find_options
(
self
,
inputfield
):
''' Returns an array of dicts where each dict represents an option. '''
elements
=
inputfield
.
findall
(
'./options/option'
)
...
...
@@ -1926,25 +1952,6 @@ class AnnotationResponse(LoncapaResponse):
return
option_ids
[
0
]
return
None
def
get_score
(
self
,
student_answers
):
''' Returns a CorrectMap for the student answer, which may include
partially correct answers.'''
student_answer
=
student_answers
[
self
.
answer_id
]
student_option
=
self
.
_get_submitted_option_id
(
student_answer
)
scoring
=
self
.
scoring_map
[
self
.
answer_id
]
is_valid
=
student_option
is
not
None
and
student_option
in
scoring
.
keys
()
(
correctness
,
points
)
=
(
'incorrect'
,
None
)
if
is_valid
:
correctness
=
scoring
[
student_option
][
'correctness'
]
points
=
scoring
[
student_option
][
'points'
]
return
CorrectMap
(
self
.
answer_id
,
correctness
=
correctness
,
npoints
=
points
)
def
get_answers
(
self
):
return
self
.
answer_map
#-----------------------------------------------------------------------------
# TEMPORARY: List of all response subclasses
...
...
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