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
5200534a
Commit
5200534a
authored
Dec 21, 2012
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template for drag_and_drop capaproblem
parent
9790881a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
5 deletions
+100
-5
common/lib/capa/capa/inputtypes.py
+48
-0
common/lib/capa/capa/responsetypes.py
+6
-4
common/lib/capa/capa/templates/drag_and_drop_input.html
+41
-0
common/lib/xmodule/xmodule/capa_module.py
+3
-1
common/lib/xmodule/xmodule/js/src/capa/drag_and_drop.js
+2
-0
No files found.
common/lib/capa/capa/inputtypes.py
View file @
5200534a
...
...
@@ -735,3 +735,51 @@ class ChemicalEquationInput(InputTypeBase):
registry
.
register
(
ChemicalEquationInput
)
#-----------------------------------------------------------------------------
class
OpenEndedInput
(
InputTypeBase
):
"""
A text area input for code--uses codemirror, does syntax highlighting, special tab handling,
etc.
"""
template
=
"openendedinput.html"
tags
=
[
'openendedinput'
]
# pulled out for testing
submitted_msg
=
(
"Feedback not yet available. Reload to check again. "
"Once the problem is graded, this message will be "
"replaced with the grader's feedback"
)
@classmethod
def
get_attributes
(
cls
):
"""
Convert options to a convenient format.
"""
return
[
Attribute
(
'rows'
,
'30'
),
Attribute
(
'cols'
,
'80'
),
Attribute
(
'hidden'
,
''
),
]
def
setup
(
self
):
"""
Implement special logic: handle queueing state, and default input.
"""
# if no student input yet, then use the default input given by the problem
if
not
self
.
value
:
self
.
value
=
self
.
xml
.
text
# Check if problem has been queued
self
.
queue_len
=
0
# Flag indicating that the problem has been queued, 'msg' is length of queue
if
self
.
status
==
'incomplete'
:
self
.
status
=
'queued'
self
.
queue_len
=
self
.
msg
self
.
msg
=
self
.
submitted_msg
def
_extra_context
(
self
):
"""Defined queue_len, add it """
return
{
'queue_len'
:
self
.
queue_len
,}
registry
.
register
(
OpenEndedInput
)
#-----------------------------------------------------------------------------
common/lib/capa/capa/responsetypes.py
View file @
5200534a
...
...
@@ -33,7 +33,7 @@ from correctmap import CorrectMap
from
datetime
import
datetime
from
util
import
*
from
lxml
import
etree
from
lxml.html.soupparser
import
fromstring
as
fromstring_bs
# uses Beautiful Soup!!! FIXME?
from
lxml.html.soupparser
import
fromstring
as
fromstring_bs
# uses Beautiful Soup!!! FIXME?
import
xqueue_interface
log
=
logging
.
getLogger
(
'mitx.'
+
__name__
)
...
...
@@ -869,7 +869,9 @@ def sympy_check2():
response_tag
=
'customresponse'
allowed_inputfields
=
[
'textline'
,
'textbox'
,
'crystallography'
,
'chemicalequationinput'
,
'vsepr_input'
]
allowed_inputfields
=
[
'textline'
,
'textbox'
,
'crystallography'
,
'chemicalequationinput'
,
'vsepr_input'
,
'drag_and_drop'
]
def
setup_response
(
self
):
xml
=
self
.
xml
...
...
@@ -1044,7 +1046,7 @@ def sympy_check2():
pretty_print
=
True
)
#msg = etree.tostring(fromstring_bs(msg),pretty_print=True)
msg
=
msg
.
replace
(
' '
,
''
)
#msg = re.sub('<html>(.*)</html>','\\1',msg,flags=re.M|re.DOTALL)
# python 2.7
#msg = re.sub('<html>(.*)</html>','\\1',msg,flags=re.M|re.DOTALL)
# python 2.7
msg
=
re
.
sub
(
'(?ms)<html>(.*)</html>'
,
'
\\
1'
,
msg
)
messages
[
0
]
=
msg
...
...
@@ -1763,7 +1765,7 @@ class ImageResponse(LoncapaResponse):
def
get_score
(
self
,
student_answers
):
correct_map
=
CorrectMap
()
expectedset
=
self
.
get_answers
()
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
given
=
student_answers
[
aid
]
# this should be a string of the form '[x,y]'
correct_map
.
set
(
aid
,
'incorrect'
)
...
...
common/lib/capa/capa/templates/drag_and_drop_input.html
0 → 100644
View file @
5200534a
<section
id=
"inputtype_${id}"
class=
"capa_inputtype"
>
<div
class=
"drag_and_drop_problem"
id=
"drag_and_drop_div_${id}"
style=
"width:${width};height:${height}"
></div>
<div
class=
"script_placeholder"
data-src=
"/static/js/raphael.js"
></div>
% if status == 'unsubmitted':
<div
class=
"unanswered"
id=
"status_${id}"
>
% elif status == 'correct':
<div
class=
"correct"
id=
"status_${id}"
>
% elif status == 'incorrect':
<div
class=
"incorrect"
id=
"status_${id}"
>
% elif status == 'incomplete':
<div
class=
"incorrect"
id=
"status_${id}"
>
% endif
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value|h}"
style=
"display:none;"
/>
<p
class=
"status"
>
% if status == 'unsubmitted':
unanswered
% elif status == 'correct':
correct
% elif status == 'incorrect':
incorrect
% elif status == 'incomplete':
incomplete
% endif
</p>
<p
id=
"answer_${id}"
class=
"answer"
></p>
% if msg:
<span
class=
"message"
>
${msg|n}
</span>
% endif
% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
</div>
% endif
</section>
common/lib/xmodule/xmodule/capa_module.py
View file @
5200534a
...
...
@@ -83,7 +83,9 @@ class CapaModule(XModule):
resource_string
(
__name__
,
'js/src/javascript_loader.coffee'
),
],
'js'
:
[
resource_string
(
__name__
,
'js/src/capa/imageinput.js'
),
resource_string
(
__name__
,
'js/src/capa/schematic.js'
)]}
resource_string
(
__name__
,
'js/src/capa/schematic.js'
),
resource_string
(
__name__
,
'js/src/capa/drag_and_drop.js'
)
]}
js_module_name
=
"Problem"
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/capa/display.scss'
)]}
...
...
common/lib/xmodule/xmodule/js/src/capa/drag_and_drop.js
0 → 100644
View file @
5200534a
alert
(
'drag-and-drop js is loaded'
)
\ No newline at end of file
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