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
9ce51ec6
Commit
9ce51ec6
authored
Nov 27, 2012
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for single list syntax in regions
parent
647d1514
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
common/lib/capa/capa/responsetypes.py
+12
-5
No files found.
common/lib/capa/capa/responsetypes.py
View file @
9ce51ec6
...
@@ -1758,9 +1758,10 @@ class ImageResponse(LoncapaResponse):
...
@@ -1758,9 +1758,10 @@ class ImageResponse(LoncapaResponse):
def
get_score
(
self
,
student_answers
):
def
get_score
(
self
,
student_answers
):
correct_map
=
CorrectMap
()
correct_map
=
CorrectMap
()
expectedset
=
self
.
get_answers
()
expectedset
=
self
.
get_answers
()
# import ipdb; ipdb.set_trace()
for
aid
in
self
.
answer_ids
:
# loop through IDs of <imageinput>
for
aid
in
self
.
answer_ids
:
# loop through IDs of <imageinput>
# fields in our stanza
# fields in our stanza
# import ipdb; ipdb.set_trace()
given
=
student_answers
[
aid
]
# this should be a string of the form '[x,y]'
given
=
student_answers
[
aid
]
# this should be a string of the form '[x,y]'
correct_map
.
set
(
aid
,
'incorrect'
)
correct_map
.
set
(
aid
,
'incorrect'
)
...
@@ -1795,10 +1796,16 @@ class ImageResponse(LoncapaResponse):
...
@@ -1795,10 +1796,16 @@ class ImageResponse(LoncapaResponse):
break
break
if
regions
[
aid
]:
if
regions
[
aid
]:
parsed_region
=
json
.
loads
(
regions
[
aid
])
parsed_region
=
json
.
loads
(
regions
[
aid
])
for
region
in
parsed_region
:
if
parsed_region
:
if
Polygon
(
region
)
.
contains
(
Point
(
gx
,
gy
)):
if
type
(
parsed_region
[
0
][
0
])
!=
list
:
correct_map
.
set
(
aid
,
'correct'
)
# we have [[1,2],[3,4],[5,6] - single region
break
# instead of [[[1,2],[3,4],[5,6], [[1,2],[3,4],[5,6]]
# or [[[1,2],[3,4],[5,6]] - multiple regions syntax
parsed_region
=
[
parsed_region
]
for
region
in
parsed_region
:
if
Polygon
(
region
)
.
contains
(
Point
(
gx
,
gy
)):
correct_map
.
set
(
aid
,
'correct'
)
break
return
correct_map
return
correct_map
def
get_answers
(
self
):
def
get_answers
(
self
):
...
...
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