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
49a921c8
Commit
49a921c8
authored
Oct 12, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #873 from MITx/feature-alex-crystallography-mitx
Feature alex crystallography mitx
parents
b2afa82c
adae1769
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
2 deletions
+98
-2
common/lib/capa/capa/capa_problem.py
+2
-1
common/lib/capa/capa/inputtypes.py
+44
-0
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/capa/capa/templates/crystallography.html
+51
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
49a921c8
...
...
@@ -56,7 +56,8 @@ entry_types = ['textline',
'checkboxgroup'
,
'filesubmission'
,
'javascriptinput'
,
'chemicalequationinput'
]
'crystallography'
,
'chemicalequationinput'
,]
# extra things displayed after "show answers" is pressed
solution_types
=
[
'solution'
]
...
...
common/lib/capa/capa/inputtypes.py
View file @
49a921c8
...
...
@@ -707,6 +707,50 @@ def imageinput(element, value, status, render_template, msg=''):
_reg
(
imageinput
)
#-----------------------------------------------------------------------------
def
crystallography
(
element
,
value
,
status
,
render_template
,
msg
=
''
):
eid
=
element
.
get
(
'id'
)
if
eid
is
None
:
msg
=
'cryst has no id: it probably appears outside of a known response type'
msg
+=
"
\n
See problem XML source line
%
s"
%
getattr
(
element
,
'sourceline'
,
'<unavailable>'
)
raise
Exception
(
msg
)
height
=
element
.
get
(
'height'
)
width
=
element
.
get
(
'width'
)
display_file
=
element
.
get
(
'display_file'
)
count
=
int
(
eid
.
split
(
'_'
)[
-
2
])
-
1
# HACK
size
=
element
.
get
(
'size'
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
hidden
=
element
.
get
(
'hidden'
,
''
)
# Escape answers with quotes, so they don't crash the system!
escapedict
=
{
'"'
:
'"'
}
value
=
saxutils
.
escape
(
value
,
escapedict
)
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
,
'hidden'
:
hidden
,
'inline'
:
element
.
get
(
'inline'
,
''
),
'width'
:
width
,
'height'
:
height
,
'display_file'
:
display_file
,
}
html
=
render_template
(
"crystallography.html"
,
context
)
try
:
xhtml
=
etree
.
XML
(
html
)
except
Exception
as
err
:
# TODO: needs to be self.system.DEBUG - but can't access system
if
True
:
log
.
debug
(
'[inputtypes.textline] failed to parse XML for:
\n
%
s'
%
html
)
raise
return
xhtml
_reg
(
crystallography
)
#--------------------------------------------------------------------------------
...
...
common/lib/capa/capa/responsetypes.py
View file @
49a921c8
...
...
@@ -867,7 +867,7 @@ def sympy_check2():
</customresponse>"""
}]
response_tag
=
'customresponse'
allowed_inputfields
=
[
'textline'
,
'textbox'
,
'chemicalequationinput'
]
allowed_inputfields
=
[
'textline'
,
'textbox'
,
'c
rystallography'
,
'c
hemicalequationinput'
]
def
setup_response
(
self
):
xml
=
self
.
xml
...
...
common/lib/capa/capa/templates/crystallography.html
0 → 100644
View file @
49a921c8
<
%
doinline =
"inline"
if
inline
else
""
%
>
<section
id=
"textinput_${id}"
class=
"textinput ${doinline}"
>
<div
id=
"holder"
style=
"width:${width};height:${height}"
></div>
<div
class=
"script_placeholder"
data-src=
"/static/js/raphael.js"
></div><div
class=
"script_placeholder"
data-src=
"/static/js/sylvester.js"
></div><div
class=
"script_placeholder"
data-src=
"/static/js/underscore-min.js"
></div>
<div
class=
"script_placeholder"
data-src=
"/static/js/crystallography.js"
></div>
% if state == 'unsubmitted':
<div
class=
"unanswered ${doinline}"
id=
"status_${id}"
>
% elif state == 'correct':
<div
class=
"correct ${doinline}"
id=
"status_${id}"
>
% elif state == 'incorrect':
<div
class=
"incorrect ${doinline}"
id=
"status_${id}"
>
% elif state == 'incomplete':
<div
class=
"incorrect ${doinline}"
id=
"status_${id}"
>
% endif
% if hidden:
<div
style=
"display:none;"
name=
"${hidden}"
inputid=
"input_${id}"
/>
% endif
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
%
if
size:
size=
"${size}"
%
endif
%
if
hidden:
style=
"display:none;"
%
endif
/>
<p
class=
"status"
>
% if state == 'unsubmitted':
unanswered
% elif state == 'correct':
correct
% elif state == 'incorrect':
incorrect
% elif state == 'incomplete':
incomplete
% endif
</p>
<p
id=
"answer_${id}"
class=
"answer"
></p>
% if msg:
<span
class=
"message"
>
${msg|n}
</span>
% endif
% if state in ['unsubmitted', 'correct', 'incorrect', 'incomplete'] or hidden:
</div>
% endif
</section>
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