Commit 557b7912 by ichuang

added image, solution, showhide examples to latex_problem template;

fixed x_module.py to only load *.yaml files as templates
TODO: Note that bad templates cause the CMS not to load; it should throw
exceptions instead of dying.
parent a8cbcca9
...@@ -47,6 +47,13 @@ metadata: ...@@ -47,6 +47,13 @@ metadata:
\edXabox{ type="string" expect="Michigan" options="ci" } \edXabox{ type="string" expect="Michigan" options="ci" }
An explanation of the answer can be provided by using the edXsolution
macro. Click on "Show Answer" to see the solution.
\begin{edXsolution}
Detroit is near Canada, but it is actually in the United States.
\end{edXsolution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Example "custom response" problem} \subsection{Example "custom response" problem}
...@@ -63,6 +70,23 @@ metadata: ...@@ -63,6 +70,23 @@ metadata:
\edXabox{expect="[1,9]" type="custom" cfn="sumtest"} \edXabox{expect="[1,9]" type="custom" cfn="sumtest"}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Example image}
Include image by using the edXxml macro:
\edXxml{<img src="http://autoid.mit.edu/images/mit_dome.jpg"/>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Example show/hide explanation}
Extra explanations can be tucked away behind a "showhide" toggle flag:
\edXshowhide{sh1}{More explanation}{This is a hidden explanation. It
can contain equations: $\alpha = \frac{2}{\sqrt{1+\gamma}}$ }
This is some text after the showhide example.
data: | data: |
<?xml version="1.0"?> <?xml version="1.0"?>
<problem> <problem>
...@@ -135,6 +159,14 @@ data: | ...@@ -135,6 +159,14 @@ data: |
</stringresponse> </stringresponse>
</p> </p>
<p> <p>
An explanation of the answer can be provided by using the edXsolution macro: </p>
<p>
<solution>
<font color="blue">Answer: </font>
<font color="blue">Detroit is near Canada, but it is actually in the United States. </font>
</solution>
</p>
<p>
<h4>Example "custom response" problem</h4> <h4>Example "custom response" problem</h4>
</p> </p>
<p> <p>
...@@ -145,12 +177,42 @@ data: | ...@@ -145,12 +177,42 @@ data: |
return (a1+a2)==10 return (a1+a2)==10
</script> </script>
<p> <p>
Enter a python list of two numbers which sum to 10: </p> Enter a python list of two numbers which sum to 10, eg [9,1]: </p>
<p> <p>
<customresponse cfn="sumtest" expect="[1,9]"> <customresponse cfn="sumtest" expect="[1,9]">
<textline correct_answer="[1,9]"/> <textline correct_answer="[1,9]"/>
</customresponse> </customresponse>
</p> </p>
<p>
<h4>Example image</h4>
</p>
<p>
Include image by using the edXxml macro: </p>
<p>
<img src="http://autoid.mit.edu/images/mit_dome.jpg"/>
</p>
<p>
<h4>Example show/hide explanation</h4>
</p>
<p>
Extra explanations can be tucked away behind a "showhide" toggle flag: </p>
<p>
<table class="wikitable collapsible collapsed">
<tbody>
<tr>
<th> More explanation [<a href="javascript:$('#sh1').toggle()" id="sh1l">show</a>]</th>
</tr>
<tr id="sh1" style="display:none">
<td>
<p>
This is a hidden explanation. It can contain equations: [mathjaxinline]\alpha = \frac{2}{\sqrt {1+\gamma }}[/mathjaxinline] </p>
<p>
This is some text after the showhide example. </p>
</td>
</tr>
</tbody>
</table>
</p>
</text> </text>
</problem> </problem>
children: [] children: []
...@@ -369,6 +369,9 @@ class ResourceTemplates(object): ...@@ -369,6 +369,9 @@ class ResourceTemplates(object):
return [] return []
for template_file in resource_listdir(__name__, dirname): for template_file in resource_listdir(__name__, dirname):
if not template_file.endswith('.yaml'):
log.warning("Skipping unknown template file %s" % template_file)
continue
template_content = resource_string(__name__, os.path.join(dirname, template_file)) template_content = resource_string(__name__, os.path.join(dirname, template_file))
template = yaml.load(template_content) template = yaml.load(template_content)
templates.append(Template(**template)) templates.append(Template(**template))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment