From 557b79129bea84d7144fcce1ddbbdef0dc22f195 Mon Sep 17 00:00:00 2001
From: ichuang
Date: Sun, 14 Oct 2012 23:26:46 -0400
Subject: [PATCH] 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.
---
.../templates/problem/latex_problem.yaml | 64 ++++++++++++++++++-
common/lib/xmodule/xmodule/x_module.py | 3 +
2 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/common/lib/xmodule/xmodule/templates/problem/latex_problem.yaml b/common/lib/xmodule/xmodule/templates/problem/latex_problem.yaml
index 23f7a23b8a..6b31c4af3e 100644
--- a/common/lib/xmodule/xmodule/templates/problem/latex_problem.yaml
+++ b/common/lib/xmodule/xmodule/templates/problem/latex_problem.yaml
@@ -47,6 +47,13 @@ metadata:
\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}
@@ -62,6 +69,23 @@ metadata:
Enter a python list of two numbers which sum to 10, eg [9,1]:
\edXabox{expect="[1,9]" type="custom" cfn="sumtest"}
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \subsection{Example image}
+
+ Include image by using the edXxml macro:
+
+ \edXxml{
}
+
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \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: |
@@ -135,6 +159,14 @@ data: |
+ An explanation of the answer can be provided by using the edXsolution macro:
+
+
+ Answer:
+ Detroit is near Canada, but it is actually in the United States.
+
+
+
Example "custom response" problem
@@ -145,12 +177,42 @@ data: |
return (a1+a2)==10
- Enter a python list of two numbers which sum to 10:
+ Enter a python list of two numbers which sum to 10, eg [9,1]:
+
+
Example image
+
+
+ Include image by using the edXxml macro:
+
+
+
+
+
Example show/hide explanation
+
+
+ Extra explanations can be tucked away behind a "showhide" toggle flag:
+
+
+
+
+ | More explanation [show] |
+
+
+ |
+
+ This is a hidden explanation. It can contain equations: [mathjaxinline]\alpha = \frac{2}{\sqrt {1+\gamma }}[/mathjaxinline]
+
+ This is some text after the showhide example.
+ |
+
+
+
+
children: []
diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py
index 3309f6270c..a53f2db7da 100644
--- a/common/lib/xmodule/xmodule/x_module.py
+++ b/common/lib/xmodule/xmodule/x_module.py
@@ -369,6 +369,9 @@ class ResourceTemplates(object):
return []
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 = yaml.load(template_content)
templates.append(Template(**template))