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
4e10c729
Commit
4e10c729
authored
Dec 10, 2013
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BLD-21: Show answer for imageresponse.
parent
ae61db9a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
61 deletions
+142
-61
CHANGELOG.rst
+2
-0
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/capa/capa/templates/imageinput.html
+71
-55
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+68
-5
No files found.
CHANGELOG.rst
View file @
4e10c729
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.
the top. Include a label indicating the component affected.
Blades: Show answer for imageresponse. BLD-21.
Blades: LTI additional Python tests. LTI must use HTTPS for
Blades: LTI additional Python tests. LTI must use HTTPS for
lis_outcome_service_url. BLD-564.
lis_outcome_service_url. BLD-564.
...
...
common/lib/capa/capa/responsetypes.py
View file @
4e10c729
...
@@ -2167,7 +2167,7 @@ class ImageResponse(LoncapaResponse):
...
@@ -2167,7 +2167,7 @@ class ImageResponse(LoncapaResponse):
answers
=
{}
answers
=
{}
for
ielt
in
self
.
ielements
:
for
ielt
in
self
.
ielements
:
ie_id
=
ielt
.
get
(
'id'
)
ie_id
=
ielt
.
get
(
'id'
)
answers
[
ie_id
]
=
(
ielt
.
get
(
'rectangle'
),
ielt
.
get
(
'regions'
))
answers
[
ie_id
]
=
{
'rectangle'
:
ielt
.
get
(
'rectangle'
),
'regions'
:
ielt
.
get
(
'regions'
)}
return
answers
return
answers
...
...
common/lib/capa/capa/templates/imageinput.html
View file @
4e10c729
<
span
>
<
div
class=
"imageinput capa_inputtype"
id=
"inputtype_${id}"
>
<input
<input
type=
"hidden"
type=
"hidden"
class=
"imageinput"
class=
"imageinput"
src=
"${src}"
src=
"${src}"
name=
"input_${id}"
name=
"input_${id}"
id=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
value=
"${value}"
/>
/>
<div
style=
"position:relative;"
>
<div
<div
id=
"imageinput_${id}"
id=
"imageinput_${id}"
style=
"background-image: url('${src}'); width: ${width}px; height: ${height}px; position: relative; left: 0; top: 0;"
style=
"
background-image: url('${src}');
width: ${width}px;
height: ${height}px;
position: relative;
left: 0;
top: 0;"
>
>
<img
<img
src=
"${STATIC_URL}green-pointer.png"
src=
"${STATIC_URL}green-pointer.png"
id=
"cross_${id}"
id=
"cross_${id}"
style=
"position: absolute; top: ${gy}px; left: ${gx}px;"
style=
"position: absolute; top: ${gy}px; left: ${gx}px;"
/>
/>
</div>
</div>
<div
data-width=
"${width}"
data-height=
"${height}"
id=
"answer_${id}"
style=
"
position: absolute;
left: 0;
top: 0;"
></div>
</div>
<script
type=
"text/javascript"
charset=
"utf-8"
>
<script
type=
"text/javascript"
charset=
"utf-8"
>
(
new
ImageInput
(
'${id}'
));
(
new
ImageInput
(
'${id}'
));
</script>
</script>
% if status == 'unsubmitted':
% if status == 'unsubmitted':
<span
<span
class=
"unanswered"
class=
"unanswered"
style=
"display: inline-block;"
style=
"display: inline-block;"
id=
"status_${id}"
id=
"status_${id}"
aria-describedby=
"input_${id}"
aria-describedby=
"input_${id}"
>
>
<span
class=
"sr"
>
Status: unanswered
</span>
<span
class=
"sr"
>
Status: unanswered
</span>
</span>
</span>
% elif status == 'correct':
% elif status == 'correct':
<span
<span
class=
"correct"
class=
"correct"
id=
"status_${id}"
id=
"status_${id}"
aria-describedby=
"input_${id}"
aria-describedby=
"input_${id}"
>
>
<span
class=
"sr"
>
Status: correct
</span>
<span
class=
"sr"
>
Status: correct
</span>
</span>
</span>
% elif status == 'incorrect':
% elif status == 'incorrect':
<span
<span
class=
"incorrect"
class=
"incorrect"
id=
"status_${id}"
id=
"status_${id}"
aria-describedby=
"input_${id}"
aria-describedby=
"input_${id}"
>
>
<span
class=
"sr"
>
Status: incorrect
</span>
<span
class=
"sr"
>
Status: incorrect
</span>
</span>
</span>
% elif status == 'incomplete':
% elif status == 'incomplete':
<span
<span
class=
"incorrect"
class=
"incorrect"
id=
"status_${id}"
id=
"status_${id}"
aria-describedby=
"input_${id}"
aria-describedby=
"input_${id}"
>
>
<span
class=
"sr"
>
Status: incorrect
</span>
<span
class=
"sr"
>
Status: incorrect
</span>
</span>
</span>
% endif
% endif
</
span
>
</
div
>
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
4e10c729
...
@@ -300,11 +300,11 @@ class @Problem
...
@@ -300,11 +300,11 @@ class @Problem
# inputtype functions.
# inputtype functions.
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
for
cls
in
classes
for
cls
in
classes
display
=
@
inputtypeDisplays
[
$
(
inputtype
).
attr
(
'id'
)]
display
=
@
inputtypeDisplays
[
$
(
inputtype
).
attr
(
'id'
)]
showMethod
=
@
inputtypeShowAnswerMethods
[
cls
]
showMethod
=
@
inputtypeShowAnswerMethods
[
cls
]
showMethod
(
inputtype
,
display
,
answers
)
if
showMethod
?
showMethod
(
inputtype
,
display
,
answers
)
if
showMethod
?
if
MathJax
?
if
MathJax
?
@
el
.
find
(
'.problem > div'
).
each
(
index
,
element
)
=>
@
el
.
find
(
'.problem > div'
).
each
(
index
,
element
)
=>
...
@@ -482,6 +482,69 @@ class @Problem
...
@@ -482,6 +482,69 @@ class @Problem
for
choice
in
answer
for
choice
in
answer
element
.
find
(
"section#forinput
#{
choice
}
"
).
addClass
'choicetextgroup_show_correct'
element
.
find
(
"section#forinput
#{
choice
}
"
).
addClass
'choicetextgroup_show_correct'
imageinput
:
(
element
,
display
,
answers
)
=>
types
=
rectangle
:
(
coords
)
=>
reg
=
/^\(([0-9]+),([0-9]+)\)-\(([0-9]+),([0-9]+)\)$/
rects
=
coords
.
replace
(
/\s*/g
,
''
).
split
(
/;/
)
$
.
each
rects
,
(
index
,
rect
)
=>
abs
=
Math
.
abs
points
=
reg
.
exec
(
rect
)
if
points
# width
width
=
abs
(
points
[
3
]
-
points
[
1
])
# height
height
=
abs
(
points
[
4
]
-
points
[
2
])
ctx
.
rect
(
points
[
1
],
points
[
2
],
width
,
height
)
ctx
.
stroke
()
ctx
.
fill
()
regions
:
(
coords
)
=>
parseCoords
=
(
coords
)
=>
reg
=
JSON
.
parse
(
coords
)
if
typeof
reg
[
0
][
0
]
is
undefined
reg
=
[
reg
]
return
reg
$
.
each
parseCoords
(
coords
),
(
index
,
regions
)
=>
ctx
.
beginPath
()
$
.
each
regions
,
(
index
,
points
)
=>
if
index
is
0
ctx
.
moveTo
(
points
[
0
],
points
[
1
])
else
ctx
.
lineTo
(
points
[
0
],
points
[
1
]);
ctx
.
closePath
()
ctx
.
stroke
()
ctx
.
fill
()
element
=
$
(
element
)
id
=
element
.
attr
(
'id'
).
replace
(
/inputtype_/
,
''
)
container
=
element
.
find
(
"#answer_
#{
id
}
"
)
canvas
=
document
.
createElement
(
'canvas'
)
canvas
.
width
=
container
.
data
(
'width'
)
canvas
.
height
=
container
.
data
(
'height'
)
if
canvas
.
getContext
ctx
=
canvas
.
getContext
(
'2d'
)
else
return
console
.
log
'Canvas is not supported.'
ctx
.
fillStyle
=
'rgba(255,255,255,.3)'
;
ctx
.
strokeStyle
=
"#FF0000"
;
ctx
.
lineWidth
=
"2"
;
$
.
each
answers
,
(
key
,
answer
)
=>
$
.
each
answer
,
(
key
,
value
)
=>
types
[
key
](
value
)
if
types
[
key
]
?
container
.
html
(
canvas
)
inputtypeHideAnswerMethods
:
inputtypeHideAnswerMethods
:
choicegroup
:
(
element
,
display
)
=>
choicegroup
:
(
element
,
display
)
=>
element
=
$
(
element
)
element
=
$
(
element
)
...
...
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