improved latex problem template; hls codemirror box autosizes height;
capa responsetypes can now include "inline='1'" for their span to be inline
This commit is contained in:
@@ -45,6 +45,9 @@
|
||||
refresh_hls(el);
|
||||
$(this).dequeue();
|
||||
});
|
||||
// resize the codemirror box
|
||||
h = el.height();
|
||||
el.find('.CodeMirror-scroll').height(h-100);
|
||||
}
|
||||
|
||||
// compile & save button
|
||||
|
||||
@@ -63,7 +63,7 @@ class StudentInputError(Exception):
|
||||
|
||||
|
||||
class LoncapaResponse(object):
|
||||
'''
|
||||
"""
|
||||
Base class for CAPA responsetypes. Each response type (ie a capa question,
|
||||
which is part of a capa problem) is represented as a subclass,
|
||||
which should provide the following methods:
|
||||
@@ -89,7 +89,7 @@ class LoncapaResponse(object):
|
||||
- required_attributes : list of required attributes (each a string) on the main response XML stanza
|
||||
- hint_tag : xhtml tag identifying hint associated with this response inside hintgroup
|
||||
|
||||
'''
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta # abc = Abstract Base Class
|
||||
|
||||
response_tag = None
|
||||
@@ -164,6 +164,8 @@ class LoncapaResponse(object):
|
||||
- renderer : procedure which produces HTML given an ElementTree
|
||||
'''
|
||||
tree = etree.Element('span') # render ourself as a <span> + our content
|
||||
if self.xml.get('inline',''): # problem author can make this span display:inline
|
||||
tree.set('class','inline')
|
||||
for item in self.xml:
|
||||
item_xhtml = renderer(item) # call provided procedure to do the rendering
|
||||
if item_xhtml is not None: tree.append(item_xhtml)
|
||||
|
||||
@@ -3,25 +3,146 @@ metadata:
|
||||
display_name: Problem Written in LaTeX
|
||||
source_processor_url: https://qisx.mit.edu:5443/latex2edx
|
||||
source_code: |
|
||||
\subsection{Example: Option Response Problem in Latex}
|
||||
|
||||
% Nearly any kind of edX problem can be authored using Latex as
|
||||
% the source language. Write latex as usual, including equations. The
|
||||
% key new feature is the \edXabox{} macro, which specifies an "Answer
|
||||
% Box" that queries students for a response, and specifies what the
|
||||
% epxected (correct) answer is.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{Example "option" problem}
|
||||
|
||||
Where is the earth?
|
||||
|
||||
|
||||
\edXabox{options='up','down' expect='down'}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{Example "symbolic" problem}
|
||||
|
||||
What is Einstein's equation for the energy equivalent of a mass $m$?
|
||||
|
||||
\edXabox{type='symbolic' size='90' expect='m*c^2' }
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{Example "numerical" problem}
|
||||
|
||||
Estimate the energy savings (in J/y) if all the people
|
||||
($3\times 10^8$) in the U.~S. switched from U.~S. code to low flow
|
||||
shower heads.
|
||||
|
||||
\edXinline{Energy saved = }\edXabox{expect="0.52" type="numerical" tolerance='0.02' inline='1' } %
|
||||
\edXinline{~EJ/year}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{Example "multiple choice" problem}
|
||||
|
||||
What color is a bannana?
|
||||
|
||||
\edXabox{ type="multichoice" expect="Yellow" options="Red","Green","Yellow","Blue" }
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{Example "string response" problem}
|
||||
|
||||
In what U.S. state is Detroit located?
|
||||
|
||||
\edXabox{ type="string" expect="Michigan" options="ci" }
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{Example "custom response" problem}
|
||||
|
||||
This problem demonstrates the use of a custom python script used for
|
||||
checking the answer.
|
||||
|
||||
\begin{edXscript}
|
||||
def sumtest(expect,ans):
|
||||
(a1,a2) = map(float,eval(ans))
|
||||
return (a1+a2)==10
|
||||
\end{edXscript}
|
||||
|
||||
Enter a python list of two numbers which sum to 10, eg [9,1]:
|
||||
|
||||
\edXabox{expect="[1,9]" type="custom" cfn="sumtest"}
|
||||
|
||||
data: |
|
||||
<problem>
|
||||
<text>
|
||||
<h2>Example: Option Response Problem</h2>
|
||||
<p>
|
||||
An option response problem presents option boxes for students to select from. Correctness of input is evaluated based
|
||||
on which option is defined as correct in the optioninput statement.
|
||||
</p>
|
||||
<p>Select the correct options:</p>
|
||||
<optionresponse direction="vertical" randomize="yes">
|
||||
<p><text class="inline">The location of the sky is: </text><optioninput inline="1" options="('Up','Down')" correct="Up"></optioninput></p>
|
||||
<p><text>The location of the earth is: </text><optioninput options="('Up','Down')" correct="Down"></optioninput></p>
|
||||
</optionresponse>
|
||||
</text>
|
||||
</problem>
|
||||
<?xml version="1.0"?>
|
||||
<problem>
|
||||
<text>
|
||||
<p>
|
||||
<h4>Example "option" problem</h4>
|
||||
</p>
|
||||
<p>
|
||||
Where is the earth? </p>
|
||||
<p>
|
||||
<optionresponse>
|
||||
<optioninput options="('up','down')" correct="down"/>
|
||||
</optionresponse>
|
||||
</p>
|
||||
<p>
|
||||
<h4>Example "symbolic" problem</h4>
|
||||
</p>
|
||||
<p>
|
||||
What is Einstein's equation for the energy equivalent of a mass [mathjaxinline]m[/mathjaxinline]? </p>
|
||||
<p>
|
||||
<symbolicresponse expect="m*c^2">
|
||||
<textline size="90" correct_answer="m*c^2" math="1"/>
|
||||
</symbolicresponse>
|
||||
</p>
|
||||
<p>
|
||||
<h4>Example "numerical" problem</h4>
|
||||
</p>
|
||||
<p>
|
||||
Estimate the energy savings (in J/y) if all the people ([mathjaxinline]3\times 10^8[/mathjaxinline]) in the U. S. switched from U. S. code to low flow shower heads. </p>
|
||||
<p>
|
||||
<p style="display:inline">Energy saved = </p>
|
||||
<numericalresponse answer="0.52">
|
||||
<textline inline="1">
|
||||
<responseparam description="Numerical Tolerance" type="tolerance" default="0.02" name="tol"/>
|
||||
</textline>
|
||||
</numericalresponse>
|
||||
<p style="display:inline"> EJ/year</p>
|
||||
</p>
|
||||
<p>
|
||||
<h4>Example "multiple choice" problem</h4>
|
||||
</p>
|
||||
<p>
|
||||
What color is a bannana? </p>
|
||||
<p>
|
||||
<multiplechoiceresponse>
|
||||
<choicegroup direction="vertical">
|
||||
<choice correct="false" name="1"><span> Red</span></choice>
|
||||
<choice correct="false" name="2"><span> Green</span></choice>
|
||||
<choice correct="true" name="3"><span> Yellow</span></choice>
|
||||
<choice correct="false" name="4"><span> Blue</span></choice>
|
||||
</choicegroup>
|
||||
</multiplechoiceresponse>
|
||||
</p>
|
||||
<p>
|
||||
<h4>Example "string response" problem</h4>
|
||||
</p>
|
||||
<p>
|
||||
In what U.S. state is Detroit located? </p>
|
||||
<p>
|
||||
<stringresponse answer="Michigan">
|
||||
<textline/>
|
||||
</stringresponse>
|
||||
</p>
|
||||
<p>
|
||||
<h4>Example "custom response" problem</h4>
|
||||
</p>
|
||||
<p>
|
||||
This problem demonstrates the use of a custom python script used for checking the answer. </p>
|
||||
<script type="text/python" system_path="python_lib">
|
||||
def sumtest(expect,ans):
|
||||
(a1,a2) = map(float,eval(ans))
|
||||
return (a1+a2)==10
|
||||
</script>
|
||||
<p>
|
||||
Enter a python list of two numbers which sum to 10, eg [9,1]: </p>
|
||||
<p>
|
||||
<customresponse cfn="sumtest" expect="[1,9]">
|
||||
<textline correct_answer="[1,9]"/>
|
||||
</customresponse>
|
||||
</p>
|
||||
</text>
|
||||
</problem>
|
||||
children: []
|
||||
|
||||
Reference in New Issue
Block a user