starting enviroment
This commit is contained in:
@@ -57,7 +57,8 @@ entry_types = ['textline',
|
||||
'filesubmission',
|
||||
'javascriptinput',
|
||||
'crystallography',
|
||||
'chemicalequationinput',]
|
||||
'chemicalequationinput',
|
||||
'vsepr_input']
|
||||
|
||||
# extra things displayed after "show answers" is pressed
|
||||
solution_types = ['solution']
|
||||
|
||||
@@ -707,7 +707,7 @@ 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:
|
||||
@@ -740,18 +740,64 @@ def crystallography(element, value, status, render_template, msg=''):
|
||||
}
|
||||
|
||||
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)
|
||||
log.debug('[inputtypes.crystallography] failed to parse XML for:\n%s' % html)
|
||||
raise
|
||||
return xhtml
|
||||
|
||||
_reg(crystallography)
|
||||
|
||||
|
||||
def vsepr_input(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 += "\nSee 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("vsepr_input.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.vsepr_input] failed to parse XML for:\n%s' % html)
|
||||
raise
|
||||
return xhtml
|
||||
|
||||
_reg(vsepr_input)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -867,7 +867,8 @@ def sympy_check2():
|
||||
</customresponse>"""}]
|
||||
|
||||
response_tag = 'customresponse'
|
||||
allowed_inputfields = ['textline', 'textbox', 'crystallography', 'chemicalequationinput']
|
||||
|
||||
allowed_inputfields = ['textline', 'textbox', 'crystallography', 'chemicalequationinput, vsepr_input']
|
||||
|
||||
def setup_response(self):
|
||||
xml = self.xml
|
||||
|
||||
60
common/lib/capa/capa/templates/vsepr_input.html
Normal file
60
common/lib/capa/capa/templates/vsepr_input.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<% doinline = "inline" if inline else "" %>
|
||||
|
||||
<section id="textinput_${id}" class="textinput ${doinline}" >
|
||||
<table><tr><td height='600'>
|
||||
<div id="vsepr_div">
|
||||
<canvas id="vsepr" width="${width}" height="${height}">
|
||||
</canvas>
|
||||
</div>
|
||||
</td><td valign ='top'>
|
||||
<select id="molecule_select" size="18">
|
||||
</select>
|
||||
<input id="submit_button" type="button" value="Submit"/>
|
||||
</td></tr></table>
|
||||
|
||||
<div class="script_placeholder" data-src="/static/js/vsepr/vsepr.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>
|
||||
Reference in New Issue
Block a user