added basic problem types
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Circuit Schematic
|
||||
data: |
|
||||
<!-- Logic gate: cjt 2/13/12 -->
|
||||
|
||||
<problem>
|
||||
<startouttext />
|
||||
Your goal for this lab is to design a circuit that implements a
|
||||
<!-- \overline doesn't seem to render correctly -->
|
||||
3-input logic gate that implements \(Z = \lnot{(C(A+B))}\) where the
|
||||
\(\lnot\) symbol stands for logical negation. This function is
|
||||
enumerated in the following truth table:
|
||||
|
||||
<center><pre>
|
||||
C B A | Z
|
||||
=========
|
||||
0 0 0 | 1
|
||||
0 0 1 | 1
|
||||
0 1 0 | 1
|
||||
0 1 1 | 1
|
||||
1 0 0 | 1
|
||||
1 0 1 | 0
|
||||
1 1 0 | 0
|
||||
1 1 1 | 0
|
||||
</pre></center>
|
||||
|
||||
The schematic diagram below includes the resistive pullup for the logic
|
||||
gate and some voltage sources that serve as the power supply and
|
||||
generators for the signals that will be the inputs to the gate.
|
||||
The voltage sources generate the three input signals (A, B and C), timed so that all
|
||||
possible combinations of the inputs will be generated over a \(4\mu s\)
|
||||
interval.
|
||||
|
||||
<br/><br/>Please add the appropriate pulldown network of mosfet
|
||||
switches connected to node Z to implement the truth table above, with
|
||||
\(R_{ON}\) of the mosfets chosen so that \(V_{ol}\) of the logic gate is less than
|
||||
\(0.25V\) for any combination of inputs. In the schematic tool, the mosfet
|
||||
model has \(V_{th} = 0.5V\), so \(V_{ol} \lt 0.25V\)
|
||||
will ensure that when the output of the logic gate is 0, if it is used
|
||||
as the input to some other logic gate, the mosfet to which
|
||||
it connects will be off.
|
||||
|
||||
<br/><br/>On <A href="/book-shifted/305">page 305</A> of the text we
|
||||
see from Equation (6) that \(R_{ON} = R_n \frac{L}{W}\). In the
|
||||
schematic tool, the mosfet model has \(R_n \approx 26.5k\Omega\) when
|
||||
using a \(3V\) power supply. To adjust \(R_{ON}\), double click the
|
||||
mosfet and select an appropriate value for the W/L parameter. For
|
||||
example, setting a mosfet's W/L to 10 would result in \(R_{ON} =
|
||||
2.65k\Omega\).
|
||||
|
||||
<br/><br/>Note that the "Plot offset" property of the scope probes
|
||||
on the A, B and C signals has been set so that the plots will not
|
||||
overlap, making it easier to see what's happening.
|
||||
|
||||
<br/><br/>Please do not change the voltages of the voltage sources or the
|
||||
resistance of the pullup resistor.
|
||||
|
||||
<endouttext />
|
||||
|
||||
<schematicresponse>
|
||||
<center>
|
||||
<schematic height="500" width="600" parts="g,n,s" analyses="dc,tran"
|
||||
submit_analyses="{"tran":[["Z",0.0000004,0.0000009,0.0000014,0.0000019,0.0000024,0.0000029,0.0000034,0.000039]]}"
|
||||
initial_value="[["w",[112,96,128,96]],["w",[256,96,240,96]],["w",[192,96,240,96]],["s",[240,96,0],{"color":"cyan","offset":"","plot offset":"0","_json_":3},["Z"]],["w",[32,224,192,224]],["w",[96,48,192,48]],["L",[256,96,3],{"label":"Z","_json_":6},["Z"]],["r",[192,48,0],{"name":"Rpullup","r":"10K","_json_":7},["1","Z"]],["w",[32,144,32,192]],["w",[32,224,32,192]],["w",[48,192,32,192]],["w",[32,96,32,144]],["w",[48,144,32,144]],["w",[32,48,32,96]],["w",[48,96,32,96]],["w",[32,48,48,48]],["g",[32,224,0],{"_json_":16},["0"]],["v",[96,192,1],{"name":"VC","value":"square(3,0,250K)","_json_":17},["C","0"]],["v",[96,144,1],{"name":"VB","value":"square(3,0,500K)","_json_":18},["B","0"]],["v",[96,96,1],{"name":"VA","value":"square(3,0,1000K)","_json_":19},["A","0"]],["v",[96,48,1],{"name":"Vpwr","value":"dc(3)","_json_":20},["1","0"]],["L",[96,96,2],{"label":"A","_json_":21},["A"]],["w",[96,96,104,96]],["L",[96,144,2],{"label":"B","_json_":23},["B"]],["w",[96,144,104,144]],["L",[96,192,2],{"label":"C","_json_":25},["C"]],["w",[96,192,104,192]],["w",[192,96,192,112]],["s",[112,96,0],{"color":"red","offset":"15","plot offset":"0","_json_":28},["A"]],["w",[104,96,112,96]],["s",[112,144,0],{"color":"green","offset":"10","plot offset":"0","_json_":30},["B"]],["w",[104,144,112,144]],["w",[128,144,112,144]],["s",[112,192,0],{"color":"blue","offset":"5","plot offset":"0","_json_":33},["C"]],["w",[104,192,112,192]],["w",[128,192,112,192]],["view",0,0,2,"5","10","10MEG",null,"100","4us"]]"
|
||||
/>
|
||||
</center>
|
||||
<answer type="loncapa/python">
|
||||
# for a schematic response, submission[i] is the json representation
|
||||
# of the diagram and analysis results for the i-th schematic tag
|
||||
|
||||
def get_tran(json,signal):
|
||||
for element in json:
|
||||
if element[0] == 'transient':
|
||||
return element[1].get(signal,[])
|
||||
return []
|
||||
|
||||
def get_value(at,output):
|
||||
for (t,v) in output:
|
||||
if at == t: return v
|
||||
return None
|
||||
|
||||
output = get_tran(submission[0],'Z')
|
||||
okay = True
|
||||
|
||||
# output should be 1, 1, 1, 1, 1, 0, 0, 0
|
||||
if get_value(0.0000004,output) < 2.7: okay = False;
|
||||
if get_value(0.0000009,output) < 2.7: okay = False;
|
||||
if get_value(0.0000014,output) < 2.7: okay = False;
|
||||
if get_value(0.0000019,output) < 2.7: okay = False;
|
||||
if get_value(0.0000024,output) < 2.7: okay = False;
|
||||
if get_value(0.0000029,output) > 0.25: okay = False;
|
||||
if get_value(0.0000034,output) > 0.25: okay = False;
|
||||
if get_value(0.0000039,output) > 0.25: okay = False;
|
||||
|
||||
correct = ['correct' if okay else 'incorrect']
|
||||
|
||||
</answer>
|
||||
</schematicresponse>
|
||||
|
||||
<startouttext />
|
||||
|
||||
When your circuit is ready for testing, run a \(4\mu s\) transient
|
||||
simulation to verify correct functionality and appropriate \(V_{ol}\)
|
||||
when the output of the gate is logic 0. To submit, please click
|
||||
CHECK. The checker will be verifying the voltage of the
|
||||
output node at several different times, so you'll earn a checkmark
|
||||
only <i>after</i> you've performed the transient simulation so that
|
||||
the checker will have a waveform to check!
|
||||
|
||||
<br/><br/>Hint: you'll only need 3 mosfet switches to implement the gate.
|
||||
|
||||
<br/><br/>When the gate is correctly implemented, the plot produced by the transient
|
||||
analysis should like similar to the following figure.
|
||||
|
||||
<center>
|
||||
<img src="/static/Lab3_1.png"/>
|
||||
<br/>Figure 1. Example plot output
|
||||
</center>
|
||||
|
||||
<br/><br/>Food for thought: You'll notice there are little spikes,
|
||||
sometimes called <i>glitches</i>, in the output waveform (see the
|
||||
bottom cyan-colored waveform in Figure 1). These only occur when the
|
||||
A and B inputs are changing simultaneously and the C input is high.
|
||||
Can you explain why? Think about what is happening in the pulldown
|
||||
circuitry at the time the glitches occur.
|
||||
|
||||
<endouttext />
|
||||
|
||||
</problem>
|
||||
children: []
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Custom Grader
|
||||
data: |
|
||||
<problem>
|
||||
<text>
|
||||
<h2>Example: Custom Response Problem</h2>
|
||||
|
||||
<p>
|
||||
A custom response problem accepts one or more lines of text input from the
|
||||
student, and evaluates the inputs for correctness based on evaluation using a
|
||||
python script embedded within the problem.
|
||||
</p>
|
||||
|
||||
<script type="loncapa/python">
|
||||
|
||||
def test_add(expect,ans):
|
||||
(a1,a2) = map(float,ans)
|
||||
return (a1+a2)==10
|
||||
|
||||
</script>
|
||||
|
||||
<text>
|
||||
Enter two integers which sum to 10: <br/>
|
||||
<customresponse cfn="test_add">
|
||||
<textline size="40" correct_answer="3"/><br/>
|
||||
<textline size="40" correct_answer="7"/>
|
||||
</customresponse>
|
||||
</text>
|
||||
|
||||
</text>
|
||||
</problem>
|
||||
children: []
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Formula Repsonse
|
||||
data: |
|
||||
<problem>
|
||||
<text>
|
||||
<h2>Example: Formula Response Problem</h2>
|
||||
|
||||
<p>
|
||||
A formula response problem accepts a line of text input from the
|
||||
student, and evaluates the input for correctness based on numerical sampling of
|
||||
the symbolic formula which is given.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The answer is correct if it is within a specified numerical tolerance
|
||||
of the expected answer.
|
||||
</p>
|
||||
|
||||
<p>This kind of response checking can handle symbolic expressions, but places an extra burden
|
||||
on the problem author to specify the allowed variables in the expression, and the
|
||||
numerical ranges over which the variables must be sampled to test for correctness.</p>
|
||||
|
||||
<script type="loncapa/python">
|
||||
I = "m*c^2"
|
||||
</script>
|
||||
|
||||
<text>
|
||||
<br/>
|
||||
Give an equation for the relativistic energy of an object with mass m. Explicitly indicate multiplication with a <tt>*</tt> symbol.<br/>
|
||||
</text>
|
||||
<formularesponse type="cs" samples="m,c@1,2:3,4#10" answer="$I">
|
||||
<responseparam description="Numerical Tolerance" type="tolerance"
|
||||
default="0.00001" name="tol" />
|
||||
<br/><text>E =</text> <textline size="40" math="1" />
|
||||
</formularesponse>
|
||||
|
||||
</text>
|
||||
</problem>
|
||||
children: []
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Image Response
|
||||
data: |
|
||||
<problem>
|
||||
<text>
|
||||
<h2>Example: Image Response Problem</h2>
|
||||
|
||||
<p>
|
||||
When teaching conventionally, a common check for understanding is to ask the student to point
|
||||
at something which satisfies a set of contraints. This use case is captured in the imageresponse.
|
||||
An image response problem presents an image for the student. Input is
|
||||
given by the location of mouse clicks on the image. Correctness of input can only be evaluated based on expected dimensions of a rectangle.
|
||||
|
||||
</p>
|
||||
|
||||
<text>
|
||||
Click on the cow in this image:
|
||||
<imageresponse>
|
||||
<imageinput src="/static/cow.png" width="715" height="511" rectangle="(404,150)-(715,480)" />
|
||||
</imageresponse>
|
||||
</text>
|
||||
</text>
|
||||
</problem>
|
||||
|
||||
children: []
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Multiple Choice
|
||||
data: |
|
||||
<problem>
|
||||
<text>
|
||||
<h2>Example: Multiple Choice Response Problem</h2>
|
||||
|
||||
<p>
|
||||
A multiple choice response problem presents radio buttons for student
|
||||
input. <!-->One or more of the choice may be correct.--> Correctness of
|
||||
input is evaluated based on expected answers specified within each
|
||||
"choice" stanza.
|
||||
</p>
|
||||
|
||||
<p>Select the correct choice. Grass is:</p>
|
||||
<multiplechoiceresponse direction="vertical" randomize="yes">
|
||||
<choicegroup type="MultipleChoice">
|
||||
<choice location="random" correct="false" name="red">Red</choice>
|
||||
<choice location="random" correct="true" name="green">Green</choice>
|
||||
<choice location="random" correct="false" name="yellow">Yellow</choice>
|
||||
<choice location="bottom" correct="false" name="blue">Blue</choice>
|
||||
</choicegroup>
|
||||
</multiplechoiceresponse>
|
||||
</text>
|
||||
</problem>
|
||||
children: []
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Numerical Response
|
||||
data: |
|
||||
<problem>
|
||||
<text>
|
||||
<h2>Example: Numerical Response Problem</h2>
|
||||
|
||||
<p>
|
||||
A numerical response problem accepts a line of text input from the
|
||||
student, and evaluates the input for correctness based on its
|
||||
numerical value.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The answer is correct if it is within a specified numerical tolerance
|
||||
of the expected answer.
|
||||
</p>
|
||||
|
||||
<p>Enter the numerical value of Pi:
|
||||
<numericalresponse answer="3.14159">
|
||||
<responseparam type="tolerance" default="5%" name="tol" description="Numerical Tolerance" />
|
||||
<textline />
|
||||
</numericalresponse>
|
||||
</p>
|
||||
</text>
|
||||
</problem>
|
||||
children: []
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: Option Response
|
||||
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>
|
||||
children: []
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
metadata:
|
||||
display_name: String Response
|
||||
data: |
|
||||
<problem >
|
||||
<text>
|
||||
<h2>Example: String Response Problem</h2>
|
||||
<p>
|
||||
|
||||
A string response problem accepts a line of text input from the
|
||||
student, and evaluates the input for correctness based on an expected
|
||||
answer within each input box.
|
||||
|
||||
The answer is correct if it is the expected answer.
|
||||
</p>
|
||||
</text>
|
||||
|
||||
<span style="display:inline">
|
||||
<p style="display:inline">Which US state has Lansing as its capital?    </p>
|
||||
<stringresponse answer="Michigan" type="ci">
|
||||
<textline size="20" inline="1"/>
|
||||
<hintgroup>
|
||||
<stringhint answer="wisconsin" type="cs" name="wisc">
|
||||
</stringhint>
|
||||
<stringhint answer="minnesota" type="cs" name="minn">
|
||||
</stringhint>
|
||||
<hintpart on="wisc">
|
||||
<text>The state capital of Wisconsin is Madison.</text>
|
||||
</hintpart>
|
||||
<hintpart on="minn">
|
||||
<text>The state capital of Minnesota is St. Paul.</text>
|
||||
</hintpart>
|
||||
<hintpart on="default">
|
||||
<text>The state you are looking for is also known as the 'Great Lakes State'</text>
|
||||
</hintpart>
|
||||
</hintgroup>
|
||||
</stringresponse>
|
||||
</span>
|
||||
|
||||
</problem>
|
||||
children: []
|
||||
Reference in New Issue
Block a user