Commit efb99da8 by muhammad-ammar

address cale's feedback

parent 8d354302
...@@ -663,7 +663,7 @@ class CapaMixin(CapaFields): ...@@ -663,7 +663,7 @@ class CapaMixin(CapaFields):
else: else:
check_button = False check_button = False
check_button_checking = False check_button_checking = False
content = { content = {
'name': self.display_name, 'name': self.display_name,
'html': html, 'html': html,
......
...@@ -129,6 +129,10 @@ div.problem-progress { ...@@ -129,6 +129,10 @@ div.problem-progress {
font-size: em(16); font-size: em(16);
} }
h3.problem-header {
margin-bottom: 0 !important; // needed to overrided the %hd-2 margin-bottom
}
// +Problem - Base // +Problem - Base
// ==================== // ====================
div.problem { div.problem {
...@@ -153,10 +157,6 @@ div.problem { ...@@ -153,10 +157,6 @@ div.problem {
div.question:not(:last-child) { div.question:not(:last-child) {
margin-bottom: $baseline; margin-bottom: $baseline;
} }
h3.problem-header {
margin-bottom: 0 !important; // needed to overrided the %hd-2 margin-bottom
}
} }
// +Problem - Choice Group // +Problem - Choice Group
......
...@@ -28,16 +28,16 @@ data: | ...@@ -28,16 +28,16 @@ data: |
initial_value="[["v",[168,144,0],{"value":"dc(1)","_json_":0},["1","0"]],["r",[296,120,0],{"r":"1","_json_":1},["1","output"]],["L",[296,168,3],{"label":"output","_json_":2},["output"]],["w",[296,216,168,216]],["w",[168,216,168,192]],["w",[168,144,168,120]],["w",[168,120,296,120]],["g",[168,216,0],{"_json_":7},["0"]],["view",-67.49999999999994,-78.49999999999994,1.6000000000000003,"50","10","1G",null,"100","1","1000"]]"/> initial_value="[["v",[168,144,0],{"value":"dc(1)","_json_":0},["1","0"]],["r",[296,120,0],{"r":"1","_json_":1},["1","output"]],["L",[296,168,3],{"label":"output","_json_":2},["output"]],["w",[296,216,168,216]],["w",[168,216,168,192]],["w",[168,144,168,120]],["w",[168,120,296,120]],["g",[168,216,0],{"_json_":7},["0"]],["view",-67.49999999999994,-78.49999999999994,1.6000000000000003,"50","10","1G",null,"100","1","1000"]]"/>
</center> </center>
<answer type="loncapa/python"> <answer type="loncapa/python">
dc_value = "dc analysis not found" dc_value = "dc analysis not found"
for response in submission[0]: for response in submission[0]:
if response[0] == 'dc': if response[0] == 'dc':
for node in response[1:]: for node in response[1:]:
dc_value = node['output'] dc_value = node['output']
if dc_value == .5: if dc_value == .5:
correct = ['correct'] correct = ['correct']
else: else:
correct = ['incorrect'] correct = ['incorrect']
</answer> </answer>
</schematicresponse> </schematicresponse>
<solution> <solution>
...@@ -52,7 +52,7 @@ data: | ...@@ -52,7 +52,7 @@ data: |
</div> </div>
</solution> </solution>
</question> </question>
<question> <question>
<p>Make a high-pass filter.</p> <p>Make a high-pass filter.</p>
<schematicresponse> <schematicresponse>
...@@ -62,21 +62,21 @@ data: | ...@@ -62,21 +62,21 @@ data: |
initial_value="[[&quot;v&quot;,[160,152,0],{&quot;name&quot;:&quot;v1&quot;,&quot;value&quot;:&quot;sin(0,1,1,0,0)&quot;,&quot;_json_&quot;:0},[&quot;1&quot;,&quot;0&quot;]],[&quot;w&quot;,[160,200,240,200]],[&quot;g&quot;,[160,200,0],{&quot;_json_&quot;:2},[&quot;0&quot;]],[&quot;L&quot;,[240,152,3],{&quot;label&quot;:&quot;NodeA&quot;,&quot;_json_&quot;:3},[&quot;NodeA&quot;]],[&quot;s&quot;,[240,152,0],{&quot;color&quot;:&quot;cyan&quot;,&quot;offset&quot;:&quot;0&quot;,&quot;_json_&quot;:4},[&quot;NodeA&quot;]],[&quot;view&quot;,64.55878906250004,54.114697265625054,2.5000000000000004,&quot;50&quot;,&quot;10&quot;,&quot;1G&quot;,null,&quot;100&quot;,&quot;1&quot;,&quot;1000&quot;]]"/> initial_value="[[&quot;v&quot;,[160,152,0],{&quot;name&quot;:&quot;v1&quot;,&quot;value&quot;:&quot;sin(0,1,1,0,0)&quot;,&quot;_json_&quot;:0},[&quot;1&quot;,&quot;0&quot;]],[&quot;w&quot;,[160,200,240,200]],[&quot;g&quot;,[160,200,0],{&quot;_json_&quot;:2},[&quot;0&quot;]],[&quot;L&quot;,[240,152,3],{&quot;label&quot;:&quot;NodeA&quot;,&quot;_json_&quot;:3},[&quot;NodeA&quot;]],[&quot;s&quot;,[240,152,0],{&quot;color&quot;:&quot;cyan&quot;,&quot;offset&quot;:&quot;0&quot;,&quot;_json_&quot;:4},[&quot;NodeA&quot;]],[&quot;view&quot;,64.55878906250004,54.114697265625054,2.5000000000000004,&quot;50&quot;,&quot;10&quot;,&quot;1G&quot;,null,&quot;100&quot;,&quot;1&quot;,&quot;1000&quot;]]"/>
</center> </center>
<answer type="loncapa/python"> <answer type="loncapa/python">
ac_values = None ac_values = None
for response in submission[0]: for response in submission[0]:
if response[0] == 'ac': if response[0] == 'ac':
for node in response[1:]: for node in response[1:]:
ac_values = node['NodeA'] ac_values = node['NodeA']
print "the ac analysis value:", ac_values print "the ac analysis value:", ac_values
if ac_values == None: if ac_values == None:
correct = ['incorrect'] correct = ['incorrect']
elif ac_values[0][1] &lt; ac_values[1][1]: elif ac_values[0][1] &lt; ac_values[1][1]:
correct = ['correct'] correct = ['correct']
else: else:
correct = ['incorrect'] correct = ['incorrect']
</answer> </answer>
</schematicresponse> </schematicresponse>
<solution> <solution>
<div class="detailed-solution"> <div class="detailed-solution">
<p>Explanation</p> <p>Explanation</p>
......
...@@ -4,35 +4,37 @@ metadata: ...@@ -4,35 +4,37 @@ metadata:
markdown: !!null markdown: !!null
data: | data: |
<problem> <problem>
<question> <question>
<p> <p>
In custom Python-evaluated input (also called "write-your-own-grader" In custom Python-evaluated input (also called "write-your-own-grader"
problems), the grader uses a Python script that you create and embed in problems), the grader uses a Python script that you create and embed in
the problem to evaluate a learner's response or provide hints. These the problem to evaluate a learner's response or provide hints. These
problems can be any type. Numerical input and text input problems are problems can be any type. Numerical input and text input problems are
the most common write-your-own-grader problems. the most common write-your-own-grader problems.
</p> </p>
<p> <p>
You can use script tag format or answer tag format to create these problems. You can use script tag format or answer tag format to create these problems.
</p> </p>
<p> <p>
You can create custom Python-evaluated input problems that provide You can create custom Python-evaluated input problems that provide
partial credit or that randomize variables in the Python code. You can partial credit or that randomize variables in the Python code. You can
also add images to the solution by using an HTML "img" tag. Note that also add images to the solution by using an HTML "img" tag. Note that
the "img" tag must be between the "div" tags that are inside the the "img" tag must be between the "div" tags that are inside the
"solution" tags, and that learners do not see these images until they "solution" tags, and that learners do not see these images until they
click the "Show Answer" button. click the "Show Answer" button.
</p> </p>
<p> For more information, see <a <p>
href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/custom_python.html" target="_blank"> For more information, see <a
Write-Your-Own-Grader Problem</a> in <i>Building and Running an edX Course</i>. href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/custom_python.html" target="_blank">
</p> Write-Your-Own-Grader Problem</a> in <i>Building and Running an edX Course</i>.
<p>When you add the problem, be sure to select <strong>Settings</strong> </p>
to specify a <strong>Display Name</strong> and other values that apply.</p> <p>
<p>You can use the following example problem as a model.</p> When you add the problem, be sure to select <strong>Settings</strong>
<hr /> to specify a <strong>Display Name</strong> and other values that apply.</p>
<p>You can use the following example problem as a model.</p>
<script type="loncapa/python"> <hr />
<script type="loncapa/python">
def test_add(expect, ans): def test_add(expect, ans):
try: try:
...@@ -45,37 +47,36 @@ data: | ...@@ -45,37 +47,36 @@ data: |
def test_add_to_ten(expect, ans): def test_add_to_ten(expect, ans):
return test_add(10, ans) return test_add(10, ans)
</script> </script>
<p>Enter two integers that sum to 10.</p> <p>Enter two integers that sum to 10.</p>
<customresponse cfn="test_add_to_ten"> <customresponse cfn="test_add_to_ten">
<textline size="40" correct_answer="3" label="Integer #1"/><br/> <textline size="40" correct_answer="3" label="Integer #1"/><br/>
<textline size="40" correct_answer="7" label="Integer #2"/> <textline size="40" correct_answer="7" label="Integer #2"/>
</customresponse> </customresponse>
<solution> <solution>
<div class="detailed-solution"> <div class="detailed-solution">
<p>Explanation</p> <p>Explanation</p>
<p>Any set of integers on the line \(y = 10 - x\) satisfy these constraints.</p> <p>Any set of integers on the line \(y = 10 - x\) satisfy these constraints.</p>
</div> </div>
</solution> </solution>
</question> </question>
<question> <question>
<p>Enter two integers that sum to 20.</p> <p>Enter two integers that sum to 20.</p>
<customresponse cfn="test_add" expect="20"> <customresponse cfn="test_add" expect="20">
<textline size="40" correct_answer="11" label="Integer #1"/><br/> <textline size="40" correct_answer="11" label="Integer #1"/><br/>
<textline size="40" correct_answer="9" label="Integer #2"/> <textline size="40" correct_answer="9" label="Integer #2"/>
</customresponse> </customresponse>
<solution> <solution>
<div class="detailed-solution"> <div class="detailed-solution">
<p>Explanation</p> <p>Explanation</p>
<p>Any set of integers on the line \(y = 20 - x\) satisfy these constraints.</p> <p>Any set of integers on the line \(y = 20 - x\) satisfy these constraints.</p>
<p>To add an image to the solution, use an HTML "img" tag. Make sure to include alt text.</p> <p>To add an image to the solution, use an HTML "img" tag. Make sure to include alt text.</p>
<img src="/static/images/placeholder-image.png" width="400" <img src="/static/images/placeholder-image.png" width="400"
alt="Description of image, with a primary goal of explaining its alt="Description of image, with a primary goal of explaining its
relevance to the problem or concept being illustrated for someone relevance to the problem or concept being illustrated for someone
who is unable to see the image."/> who is unable to see the image."/>
</div> </div>
</solution> </solution>
</question> </question>
</problem> </problem>
\ No newline at end of file
...@@ -37,22 +37,22 @@ data: | ...@@ -37,22 +37,22 @@ data: |
<draggable id="11" label="few"/> <draggable id="11" label="few"/>
</drag_and_drop_input> </drag_and_drop_input>
<answer type="loncapa/python"> <answer type="loncapa/python">
correct_answer = { correct_answer = {
'1': [[70, 150], 121], '1': [[70, 150], 121],
'6': [[190, 150], 121], '6': [[190, 150], 121],
'8': [[190, 150], 121], '8': [[190, 150], 121],
'2': [[310, 150], 121], '2': [[310, 150], 121],
'9': [[310, 150], 121], '9': [[310, 150], 121],
'11': [[310, 150], 121], '11': [[310, 150], 121],
'4': [[420, 150], 121], '4': [[420, 150], 121],
'7': [[420, 150], 121], '7': [[420, 150], 121],
'3': [[550, 150], 121], '3': [[550, 150], 121],
'5': [[550, 150], 121], '5': [[550, 150], 121],
'10': [[550, 150], 121]} '10': [[550, 150], 121]}
if draganddrop.grade(submission[0], correct_answer): if draganddrop.grade(submission[0], correct_answer):
correct = ['correct'] correct = ['correct']
else: else:
correct = ['incorrect'] correct = ['incorrect']
</answer> </answer>
</customresponse> </customresponse>
</question> </question>
...@@ -77,15 +77,15 @@ data: | ...@@ -77,15 +77,15 @@ data: |
<target id="t10" x="591" y="132" w="70" h="70"/> <target id="t10" x="591" y="132" w="70" h="70"/>
</drag_and_drop_input> </drag_and_drop_input>
<answer type="loncapa/python"> <answer type="loncapa/python">
correct_answer = [{ correct_answer = [{
'draggables': ['1', '2'], 'draggables': ['1', '2'],
'targets': ['t2', 't3', 't4' ], 'targets': ['t2', 't3', 't4' ],
'rule':'anyof' 'rule':'anyof'
}] }]
if draganddrop.grade(submission[0], correct_answer): if draganddrop.grade(submission[0], correct_answer):
correct = ['correct'] correct = ['correct']
else: else:
correct = ['incorrect'] correct = ['incorrect']
</answer> </answer>
</customresponse> </customresponse>
</question> </question>
......
...@@ -3,58 +3,63 @@ metadata: ...@@ -3,58 +3,63 @@ metadata:
display_name: Math Expression Input display_name: Math Expression Input
markdown: !!null markdown: !!null
data: | data: |
<problem> <problem>
<question> <question>
<p> <p>
In math expression input problems, learners enter text that represents a In math expression input problems, learners enter text that represents a
mathematical expression into a field, and text is converted to a symbolic mathematical expression into a field, and text is converted to a symbolic
expression that appears below that field. You can refer learners to expression that appears below that field. You can refer learners to
<a href="http://edx.readthedocs.io/projects/edx-guide-for-students/en/latest/completing_assignments/SFD_mathformatting.html" target="_blank"> <a href="http://edx.readthedocs.io/projects/edx-guide-for-students/en/latest/completing_assignments/SFD_mathformatting.html" target="_blank">
Entering Mathematical and Scientific Expressions</a> in the <i>EdX Learner's Entering Mathematical and Scientific Expressions</a> in the <i>EdX Learner's
Guide</i> for information about how to enter text into the field. Guide</i> for information about how to enter text into the field.
</p> </p>
<p> <p>
Math expression problems can include unknown variables and relatively Math expression problems can include unknown variables and relatively
complicated symbolic expressions. The grader uses a numerical sampling to complicated symbolic expressions. The grader uses a numerical sampling to
determine whether the student’s response matches your math expression, to a determine whether the student’s response matches your math expression, to a
specified numerical tolerance. You must specify the allowed variables in the specified numerical tolerance. You must specify the allowed variables in the
expression as well as the range of values for each variable. expression as well as the range of values for each variable.
</p> </p>
<p> <p>
To create these problems, you use MathJax to change your plain text into To create these problems, you use MathJax to change your plain text into
"beautiful math." For more information about how to use MathJax in Studio, "beautiful math." For more information about how to use MathJax in Studio,
see <a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/mathjax.html" target="_blank"> see <a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/mathjax.html" target="_blank">
A Brief Introduction to MathJax in Studio</a> in <i>Building and Running an edx A Brief Introduction to MathJax in Studio</a> in <i>Building and Running an edx
Course</i>. Course</i>.
</p> </p>
<p>When you add the problem, be sure to select <strong>Settings</strong> <p>
to specify a <strong>Display Name</strong> and other values that apply.</p> When you add the problem, be sure to select <strong>Settings</strong>
<p>You can use the following example problems as models.</p> to specify a <strong>Display Name</strong> and other values that apply.
</p>
<p>Write an expression for the product of \( R_1\), \( R_2\), and <p>You can use the following example problems as models.</p>
the inverse of \( R_3\) .</p>
<formularesponse type="ci" samples="R_1,R_2,R_3@1,2,3:3,4,5#10" answer="$VoVi"> <p>
<responseparam type="tolerance" default="0.00001"/> Write an expression for the product of \( R_1\), \( R_2\), and
<formulaequationinput size="40" label="Enter the equation"/> the inverse of \( R_3\) .
</formularesponse> </p>
<formularesponse type="ci" samples="R_1,R_2,R_3@1,2,3:3,4,5#10" answer="$VoVi">
<script type="loncapa/python"> <responseparam type="tolerance" default="0.00001"/>
VoVi = "(R_1*R_2)/R_3" <formulaequationinput size="40" label="Enter the equation"/>
</script> </formularesponse>
</question>
<script type="loncapa/python">
<question> VoVi = "(R_1*R_2)/R_3"
<p>Let \( x\) be a variable, and let \( n\) be an arbitrary constant. </script>
What is the derivative of \( x^n\)?</p> </question>
<script type="loncapa/python"> <question>
derivative = "n*x^(n-1)" <p>
</script> Let \( x\) be a variable, and let \( n\) be an arbitrary constant.
What is the derivative of \( x^n\)?
<formularesponse type="ci" samples="x,n@1,2:3,4#10" answer="$derivative"> </p>
<responseparam type="tolerance" default="0.00001"/>
<formulaequationinput size="40" label="Enter the equation"/> <script type="loncapa/python">
</formularesponse> derivative = "n*x^(n-1)"
</question> </script>
</problem> <formularesponse type="ci" samples="x,n@1,2:3,4#10" answer="$derivative">
\ No newline at end of file <responseparam type="tolerance" default="0.00001"/>
<formulaequationinput size="40" label="Enter the equation"/>
</formularesponse>
</question>
</problem>
\ No newline at end of file
...@@ -5,33 +5,37 @@ metadata: ...@@ -5,33 +5,37 @@ metadata:
showanswer: never showanswer: never
data: | data: |
<problem> <problem>
<question> <question>
<p> <p>
In these problems (also called custom JavaScript problems or JS Input In these problems (also called custom JavaScript problems or JS Input
problems), you add a problem or tool that uses JavaScript in Studio. problems), you add a problem or tool that uses JavaScript in Studio.
Studio embeds the problem in an IFrame so that your students can Studio embeds the problem in an IFrame so that your students can
interact with it in the LMS. You can grade your students' work using interact with it in the LMS. You can grade your students' work using
JavaScript and some basic Python, and the grading is integrated into the JavaScript and some basic Python, and the grading is integrated into the
edX grading system. edX grading system.
</p> </p>
<p> <p>
The JS Input problem that you create must use HTML, JavaScript, and The JS Input problem that you create must use HTML, JavaScript, and
cascading style sheets (CSS). You can use any application creation tool, cascading style sheets (CSS). You can use any application creation tool,
such as the Google Web Toolkit (GWT), to create your JS Input problem. such as the Google Web Toolkit (GWT), to create your JS Input problem.
</p> </p>
<p> <p>
For more information, see For more information, see
<a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/custom_javascript.html" target="_blank"> <a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/custom_javascript.html" target="_blank">
Custom JavaScript Problem</a> in <i>Building and Running an edX Course</i>. Custom JavaScript Problem</a> in <i>Building and Running an edX Course</i>.
</p> </p>
<p>JavaScript developers can also see <p>
<a href="http://edx.readthedocs.io/projects/edx-developer-guide/en/latest/extending_platform/javascript.html" target="_blank"> JavaScript developers can also see
Custom JavaScript Applications</a> in the <i>EdX Developer's Guide</i>.</p> <a href="http://edx.readthedocs.io/projects/edx-developer-guide/en/latest/extending_platform/javascript.html" target="_blank">
<p>When you add the problem, be sure to select <strong>Settings</strong> Custom JavaScript Applications</a> in the <i>EdX Developer's Guide</i>.
to specify a <strong>Display Name</strong> and other values that apply.</p> </p>
<p>You can use the following example problem as a model.</p> <p>
When you add the problem, be sure to select <strong>Settings</strong>
<script type="loncapa/python"> to specify a <strong>Display Name</strong> and other values that apply.
</p>
<p>You can use the following example problem as a model.</p>
<script type="loncapa/python">
<![CDATA[ <![CDATA[
import json import json
def vglcfn(e, ans): def vglcfn(e, ans):
...@@ -53,18 +57,20 @@ data: | ...@@ -53,18 +57,20 @@ data: |
return selectedObjects["cylinder"] and not selectedObjects["cube"] return selectedObjects["cylinder"] and not selectedObjects["cube"]
''' '''
]]> ]]>
</script> </script>
<p>In the following image, click the objects until the cone is yellow <p>
and the cube is blue.</p> In the following image, click the objects until the cone is yellow
<customresponse cfn="vglcfn"> and the cube is blue.
<jsinput gradefn="WebGLDemo.getGrade" </p>
get_statefn="WebGLDemo.getState" <customresponse cfn="vglcfn">
set_statefn="WebGLDemo.setState" <jsinput gradefn="WebGLDemo.getGrade"
initial_state='{"selectedObjects":{"cube":true,"cylinder":false}}' get_statefn="WebGLDemo.getState"
width="400" set_statefn="WebGLDemo.setState"
height="400" initial_state='{"selectedObjects":{"cube":true,"cylinder":false}}'
html_file="https://studio.edx.org/c4x/edX/DemoX/asset/webGLDemo.html" width="400"
sop="false"/> height="400"
</customresponse> html_file="https://studio.edx.org/c4x/edX/DemoX/asset/webGLDemo.html"
</question> sop="false"/>
</customresponse>
</question>
</problem> </problem>
\ No newline at end of file
...@@ -87,189 +87,173 @@ metadata: ...@@ -87,189 +87,173 @@ metadata:
markdown: !!null markdown: !!null
data: | data: |
<?xml version="1.0"?> <?xml version="1.0"?>
<problem showanswer="closed" rerandomize="never" weight="10" display_name="lec1_Q2"> <problem>
<question> <question>
<p> <p>
If you have a problem that is already written in LaTeX, you can use this problem type to If you have a problem that is already written in LaTeX, you can use this problem type to
easily convert your code into XML. After you paste your code into the LaTeX editor, easily convert your code into XML. After you paste your code into the LaTeX editor,
you only need to make a few minor adjustments. you only need to make a few minor adjustments.
</p> </p>
<p> <p>
For more information, see For more information, see
<a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/problem_in_latex.html" target="_blank"> <a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/problem_in_latex.html" target="_blank">
Problem Written in LaTeX</a> in <i>Building and Running an edX Course</i>. Problem Written in LaTeX</a> in <i>Building and Running an edX Course</i>.
</p> </p>
<p>You can use the following example problems as models.</p> <p>You can use the following example problems as models.</p>
<p><strong>Example Option Problem</strong></p> <p><strong>Example Option Problem</strong></p>
<p>Which of the following countries celebrates its independence on August 15?</p> <p>Which of the following countries celebrates its independence on August 15?</p>
<br/> <br/>
<optionresponse> <optionresponse>
<optioninput options="('India','Spain','China','Bermuda')" correct="India"></optioninput> <optioninput options="('India','Spain','China','Bermuda')" correct="India"></optioninput>
</optionresponse> </optionresponse>
<solution> <solution>
<div class="detailed-solution"> <div class="detailed-solution">
<p>Explanation</p> <p>Explanation</p>
<p>India became an independent nation on August 15, 1947.</p> <p>India became an independent nation on August 15, 1947.</p>
</div> </div>
</solution> </solution>
</question> </question>
<br/> <question>
<p><strong>Example Multiple Choice Problem</strong></p>
<question> <p>Which of the following countries has the largest population?</p>
<p><strong>Example Multiple Choice Problem</strong></p> <multiplechoiceresponse>
<p>Which of the following countries has the largest population?</p> <choicegroup type="MultipleChoice">
<multiplechoiceresponse> <choice correct="false" name="brazil">Brazil</choice>
<choicegroup type="MultipleChoice"> <choice correct="false" name="germany">Germany</choice>
<choice correct="false" name="brazil">Brazil</choice> <choice correct="true" name="indonesia">Indonesia</choice>
<choice correct="false" name="germany">Germany</choice> <choice correct="false" name="russia">Russia</choice>
<choice correct="true" name="indonesia">Indonesia</choice> </choicegroup>
<choice correct="false" name="russia">Russia</choice> </multiplechoiceresponse>
</choicegroup> <solution>
</multiplechoiceresponse> <div class="detailed-solution">
<solution> <p>Explanation</p>
<div class="detailed-solution"> <p>According to September 2014 estimates:</p>
<p>Explanation</p> <p>The population of Indonesia is approximately 250 million.</p>
<p>According to September 2014 estimates:</p> <p>The population of Brazil is approximately 200 million.</p>
<p>The population of Indonesia is approximately 250 million.</p> <p>The population of Russia is approximately 146 million.</p>
<p>The population of Brazil is approximately 200 million.</p> <p>The population of Germany is approximately 81 million.</p>
<p>The population of Russia is approximately 146 million.</p> </div>
<p>The population of Germany is approximately 81 million.</p> </solution>
</div> </question>
</solution>
</question> <question>
<p><strong>Example Math Expression Problem</strong></p>
<br/> <p>What is Einstein's equation for the energy equivalent of a mass [mathjaxinline]m[/mathjaxinline]?</p>
<symbolicresponse expect="m*c^2">
<question> <textline size="90" correct_answer="m*c^2" math="1"/>
<p><strong>Example Math Expression Problem</strong></p> </symbolicresponse>
<p>What is Einstein's equation for the energy equivalent of a mass [mathjaxinline]m[/mathjaxinline]?</p> </question>
<symbolicresponse expect="m*c^2">
<textline size="90" correct_answer="m*c^2" math="1"/> <question>
</symbolicresponse> <p><strong>Example Numerical Problem</strong></p>
</question> <p>Estimate the energy savings (in J/y) if all the people ([mathjaxinline]3\times 10^8[/mathjaxinline]) in the U.&#xA0;S. switched from U.&#xA0;S. code to low-flow shower heads.</p>
<p style="display:inline">Energy saved = </p>
<br/> <numericalresponse inline="1" answer="0.52">
<textline inline="1">
<question> <responseparam type="tolerance" default="0.02"/>
<p><strong>Example Numerical Problem</strong></p> </textline>
<p>Estimate the energy savings (in J/y) if all the people ([mathjaxinline]3\times 10^8[/mathjaxinline]) in the U.&#xA0;S. switched from U.&#xA0;S. code to low-flow shower heads.</p> <p style="display:inline">&#xA0;EJ/year</p>
<p style="display:inline">Energy saved = </p> </numericalresponse>
<numericalresponse inline="1" answer="0.52"> </question>
<textline inline="1">
<responseparam type="tolerance" default="0.02"/> <question>
</textline> <p><strong>Example Fill-in-the-Blank Problem</strong></p>
<p style="display:inline">&#xA0;EJ/year</p> <p>What was the first post-secondary school in China to allow both male and female students?</p>
</numericalresponse> <stringresponse answer="Nanjing Higher Normal Institute" type="ci" >
</question> <additional_answer>National Central University</additional_answer>
<additional_answer>Nanjing University</additional_answer>
<br/> <textline label="What was the first post-secondary school in China to allow both male and female students?" size="40"/>
</stringresponse>
<question> <solution>
<p><strong>Example Fill-in-the-Blank Problem</strong></p> <div class="detailed-solution">
<p>What was the first post-secondary school in China to allow both male and female students?</p> <p>Explanation</p>
<stringresponse answer="Nanjing Higher Normal Institute" type="ci" > <p>Nanjing Higher Normal Institute first admitted female students in 1920.</p>
<additional_answer>National Central University</additional_answer> </div>
<additional_answer>Nanjing University</additional_answer> </solution>
<textline label="What was the first post-secondary school in China to allow both male and female students?" size="40"/> </question>
</stringresponse>
<solution> <question>
<div class="detailed-solution"> <p><strong>Example Custom Python-Evaluated Input Problem</strong></p>
<p>Explanation</p> <script type="loncapa/python">
<p>Nanjing Higher Normal Institute first admitted female students in 1920.</p> def test_add(expect, ans):
</div> try:
</solution> a1=int(ans[0])
</question> a2=int(ans[1])
return (a1+a2) == int(expect)
<br/> except ValueError:
return False
<question>
<p><strong>Example Custom Python-Evaluated Input Problem</strong></p> def test_add_to_ten(expect, ans):
<script type="loncapa/python"> return test_add(10, ans)
def test_add(expect, ans): </script>
try: <p>Enter two integers that sum to 10.</p>
a1=int(ans[0]) <customresponse cfn="test_add_to_ten">
a2=int(ans[1]) <textline size="40" correct_answer="3" label="Integer #1"/><br/>
return (a1+a2) == int(expect) <textline size="40" correct_answer="7" label="Integer #2"/>
except ValueError: </customresponse>
return False <solution>
<div class="detailed-solution">
def test_add_to_ten(expect, ans): <p>Explanation</p>
return test_add(10, ans) <p>Any set of integers on the line \(y = 10 - x\) satisfy these constraints.</p>
</script> </div>
<p>Enter two integers that sum to 10.</p> </solution>
<customresponse cfn="test_add_to_ten"> </question>
<textline size="40" correct_answer="3" label="Integer #1"/><br/>
<textline size="40" correct_answer="7" label="Integer #2"/> <question>
</customresponse> <p>Enter two integers that sum to 20.</p>
<solution> <customresponse cfn="test_add" expect="20">
<div class="detailed-solution"> <textline size="40" correct_answer="11" label="Integer #1"/><br/>
<p>Explanation</p> <textline size="40" correct_answer="9" label="Integer #2"/>
<p>Any set of integers on the line \(y = 10 - x\) satisfy these constraints.</p> </customresponse>
</div> <solution>
</solution> <div class="detailed-solution">
</question> <p>Explanation</p>
<p>Any set of integers on the line \(y = 20 - x\) satisfy these constraints.</p>
<br/> <p>To add an image to the solution, use an HTML "img" tag. Make sure to include alt text.</p>
<img src="/static/images/placeholder-image.png" width="400" alt="Description of image"/>
<question> </div>
<p>Enter two integers that sum to 20.</p> </solution>
<customresponse cfn="test_add" expect="20"> </question>
<textline size="40" correct_answer="11" label="Integer #1"/><br/>
<textline size="40" correct_answer="9" label="Integer #2"/> <question>
</customresponse> <p><strong>Example Image Mapped Input Problem</strong></p>
<solution> <p>
<div class="detailed-solution"> What country is home to the Great Pyramid of Giza as well as the cities
<p>Explanation</p> of Cairo and Memphis? Click the country on the map below.
<p>Any set of integers on the line \(y = 20 - x\) satisfy these constraints.</p> </p>
<p>To add an image to the solution, use an HTML "img" tag. Make sure to include alt text.</p> <imageresponse>
<img src="/static/images/placeholder-image.png" width="400" alt="Description of image"/> <imageinput src="https://studio.edx.org/c4x/edX/DemoX/asset/Africa.png"
</div> width="600" height="638" rectangle="(338,98)-(412,168)" alt="Map of
</solution> Africa"/>
</question> </imageresponse>
<solution>
<br/> <div class="detailed-solution">
<p>Explanation</p>
<question> <p>Egypt is home to not only the Pyramids, Cairo, and Memphis, but also
<p><strong>Example Image Mapped Input Problem</strong></p> the Sphinx and the ancient Royal Library of Alexandria.</p>
<p> </div>
What country is home to the Great Pyramid of Giza as well as the cities </solution>
of Cairo and Memphis? Click the country on the map below. </question>
</p>
<imageresponse> <question>
<imageinput src="https://studio.edx.org/c4x/edX/DemoX/asset/Africa.png" <p><strong>Example Hidden Explanation</strong></p>
width="600" height="638" rectangle="(338,98)-(412,168)" alt="Map of <p>You can provide additional information that only appears at certain times by including a "showhide" flag. </p>
Africa"/> <p>
</imageresponse> <table class="wikitable collapsible collapsed">
<solution> <tbody>
<div class="detailed-solution"> <tr>
<p>Explanation</p> <th> More Information [<a href="javascript:$('#sh1').toggle()" id="sh1l">show</a>]</th>
<p>Egypt is home to not only the Pyramids, Cairo, and Memphis, but also </tr>
the Sphinx and the ancient Royal Library of Alexandria.</p> <tr id="sh1" style="display:none">
</div> <td>
</solution> <p>This is a hidden explanation. It can contain equations, such as [mathjaxinline]\alpha = \frac{2}{\sqrt {1+\gamma }}[/mathjaxinline]. </p>
</question> <p>This is additional text after the hidden explanation. </p>
</td>
<br/> </tr>
</tbody>
<question> </table>
<p><strong>Example Hidden Explanation</strong></p> </p>
<p>You can provide additional information that only appears at certain times by including a "showhide" flag. </p> </question>
<p> </problem>
<table class="wikitable collapsible collapsed">
<tbody>
<tr>
<th> More Information [<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, such as [mathjaxinline]\alpha = \frac{2}{\sqrt {1+\gamma }}[/mathjaxinline]. </p>
<p>This is additional text after the hidden explanation. </p>
</td>
</tr>
</tbody>
</table>
</p>
</question>
</problem>
...@@ -4,14 +4,14 @@ metadata: ...@@ -4,14 +4,14 @@ metadata:
markdown: !!null markdown: !!null
data: | data: |
<problem> <problem>
<question> <question>
<text> <text>
<p> <p>
<h4>Problem With Adaptive Hint</h4> <h4>Problem With Adaptive Hint</h4>
</p> </p>
<p> <p>
This problem demonstrates a question with hints, based on using the <tt class="tt">hintfn</tt> method. </p> This problem demonstrates a question with hints, based on using the <tt class="tt">hintfn</tt> method. </p>
<script type="text/python" system_path="python_lib"> <script type="text/python" system_path="python_lib">
def test_str(expect, ans): def test_str(expect, ans):
print expect, ans print expect, ans
ans = ans.strip("'") ans = ans.strip("'")
...@@ -36,14 +36,14 @@ data: | ...@@ -36,14 +36,14 @@ data: |
if hint: if hint:
hint = "&lt;font color='blue'&gt;Hint: {0}&lt;/font&gt;".format(hint) hint = "&lt;font color='blue'&gt;Hint: {0}&lt;/font&gt;".format(hint)
new_cmap.set_hint_and_mode(aid,hint,'always') new_cmap.set_hint_and_mode(aid,hint,'always')
</script> </script>
<label> <label>
What is the best programming language that exists today? You may enter your answer in upper or lower case, with or without quotes. What is the best programming language that exists today? You may enter your answer in upper or lower case, with or without quotes.
<customresponse cfn="test_str" expect="python"> <customresponse cfn="test_str" expect="python">
<textline correct_answer="python"/> <textline correct_answer="python"/>
<hintgroup hintfn="hint_fn"/> <hintgroup hintfn="hint_fn"/>
</customresponse> </customresponse>
</label> </label>
</text> </text>
</question> </question>
</problem> </problem>
\ No newline at end of file
...@@ -58,30 +58,30 @@ data: | ...@@ -58,30 +58,30 @@ data: |
This problem demonstrates a question with hints, based on using the <tt class="tt">hintfn</tt> method. This problem demonstrates a question with hints, based on using the <tt class="tt">hintfn</tt> method.
</p> </p>
<script type="text/python" system_path="python_lib"> <script type="text/python" system_path="python_lib">
def test_str(expect, ans): def test_str(expect, ans):
print expect, ans print expect, ans
ans = ans.strip("'") ans = ans.strip("'")
ans = ans.strip('"') ans = ans.strip('"')
return expect == ans.lower() return expect == ans.lower()
def hint_fn(answer_ids, student_answers, new_cmap, old_cmap): def hint_fn(answer_ids, student_answers, new_cmap, old_cmap):
aid = answer_ids[0] aid = answer_ids[0]
ans = str(student_answers[aid]).lower() ans = str(student_answers[aid]).lower()
print 'hint_fn called, ans=', ans print 'hint_fn called, ans=', ans
hint = '' hint = ''
if 'java' in ans: if 'java' in ans:
hint = 'that is only good for drinking' hint = 'that is only good for drinking'
elif 'perl' in ans: elif 'perl' in ans:
hint = 'not that rich' hint = 'not that rich'
elif 'pascal' in ans: elif 'pascal' in ans:
hint = 'that is a beatnick language' hint = 'that is a beatnick language'
elif 'fortran' in ans: elif 'fortran' in ans:
hint = 'those were the good days' hint = 'those were the good days'
elif 'clu' in ans: elif 'clu' in ans:
hint = 'you must be invariant' hint = 'you must be invariant'
if hint: if hint:
hint = "&lt;font color='blue'&gt;Hint: {0}&lt;/font&gt;".format(hint) hint = "&lt;font color='blue'&gt;Hint: {0}&lt;/font&gt;".format(hint)
new_cmap.set_hint_and_mode(aid,hint,'always') new_cmap.set_hint_and_mode(aid,hint,'always')
</script> </script>
<label> <label>
What is the best programming language that exists today? You may enter your answer in upper or lower case, with or without quotes. What is the best programming language that exists today? You may enter your answer in upper or lower case, with or without quotes.
......
...@@ -1344,7 +1344,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -1344,7 +1344,7 @@ class CapaModuleTest(unittest.TestCase):
# Check the AJAX call that gets the hint by question id and hint index # Check the AJAX call that gets the hint by question id and hint index
for question_id in range(num_questions): for question_id in range(num_questions):
for hint_index in (0, 1, 2): for hint_index in range(3):
result = module.get_demand_hint(question_id, hint_index) result = module.get_demand_hint(question_id, hint_index)
hint_num = hint_index % 2 hint_num = hint_index % 2
self.assertEqual( self.assertEqual(
......
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