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
647d1514
Commit
647d1514
authored
Nov 26, 2012
by
Александр
Committed by
Alexander Kryklia
Nov 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support both regions and rectangles
parent
b4fb0cc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
common/lib/capa/capa/responsetypes.py
+9
-9
No files found.
common/lib/capa/capa/responsetypes.py
View file @
647d1514
...
...
@@ -1724,14 +1724,15 @@ class ImageResponse(LoncapaResponse):
Each <imageinput> should specify a rectangle(s) or region(s), given as an
attribute, defining the correct answer.
Rectangle(s) are more prioritized over regions due to simplicity and
backward compatibility. In this example regions will be ignored:
<imageinput src="/static/images/Lecture2/S2_p04.png" width="811" height="610"
rectangle="(10,10)-(20,30);(12,12)-(40,60)"
regions='[[[10,10], [20,30], [40, 10]], [[100,100], [120,130], [110,150]]]'/>
Regions is list of lists [region1, region2, region3, ...] where regionN
is ordered list of points: [[1,1], [100,100], [50,50], [20, 70]].
Returns:
True, if click is inside any region or rectangle. Otherwise False.
"""
snippets
=
[{
'snippet'
:
'''<imageresponse>
<imageinput src="image1.jpg" width="200" height="100"
...
...
@@ -1792,13 +1793,12 @@ class ImageResponse(LoncapaResponse):
if
(
llx
<=
gx
<=
urx
)
and
(
lly
<=
gy
<=
ury
):
correct_map
.
set
(
aid
,
'correct'
)
break
else
:
# rectangles are more prioretized for same id
if
regions
[
aid
]:
parsed_region
=
json
.
loads
(
regions
[
aid
])
for
region
in
parsed_region
:
if
Polygon
(
region
)
.
contains
(
Point
(
gx
,
gy
)):
correct_map
.
set
(
aid
,
'correct'
)
break
if
regions
[
aid
]:
parsed_region
=
json
.
loads
(
regions
[
aid
])
for
region
in
parsed_region
:
if
Polygon
(
region
)
.
contains
(
Point
(
gx
,
gy
)):
correct_map
.
set
(
aid
,
'correct'
)
break
return
correct_map
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