Commit 8919fbd9 by Mike Chen

clean up and putting things into right place

parent ce31fa22
class @CapawikiDescriptor class @CapawikiDescriptor
constructor: (@element) -> constructor: (@element) ->
@loadParser("/static/grammars/main.jspeg") @loadParser("/static/peg/capawiki.jspeg")
@capa_box = $(".capa-box", @element) @capa_box = $(".capa-box", @element)
@wiki_box = $(".wiki-box", @element) @wiki_box = $(".wiki-box", @element)
......
The figure below shows two identical circuits connecting a \(6\)V battery to an \(18\Omega\) resistor. The difference is that we chose to measure the voltages and currents in the two circuits differently: we used a different coordinate system of voltages and currents in our measurements.
! Figure 1 (/static/images/circuits/ard.gif)
You are to determine the voltages and currents indicated and compute the powers entering the elements.
What is the voltage (in Volts) \(v_1\) measured across the battery?
= 1/3+2 +- 2%
What is the voltage (in Volts) \(v_2\) measured across the resistor?
= 6.0
What is the current (in Amperes) \(i_1\) measured entering the battery?
= -1/3
What is the current (in Amperes) \(i_2\) measured entering the resistor?
= 1/3
What is the power (in Watts) \(P_1 = v_1 i_1\) entering the voltage source?
= -2.0
What is the power (in Watts) \(P_2 = v_2 i_2\) entering the resistor?
(x) 6.00
( ) 4.2
( ) 3/2
What is the voltage (in Volts) \(v_3\) measured across the battery?
= -6.0
What is the voltage (in Volts) \(v_4\) measured across the resistor?
= -6.0
What is the current (in Amperes) \(i_3\) measured entering the battery?
= 1/3
What is the current (in Amperes) \(i_4\) measured entering the resistor?
= -1/3
What is the power (in Watts) \(P_3 = v_3 i_3\) entering the voltage source?
= -2.0
What is the power (in Watts) \(P_4 = v_4 i_4\) entering the resistor?
= 2.0
Notice that the powers are the same in the two circuits.
That is physical reality: power moves from the battery to the resistor, independent of the coordinate systems we use to measure the voltage and the current, so long as we use associated reference directions. We must always measure current into the terminal that we put the + sign of the voltage measurement on. Think of this as the red probe of the voltmeter.
Now let's do some algebra. To make things a bit easier let's define
\(d = \sqrt(1 + 2 K R_s (V_{IN} - V_T))\)
In the space provided below write an algebraic expression for the
small-signal gain \(\frac{v_o}{v_i}\) in terms of \(R_L\), \(R_S\),
and \(d\). (Be careful, algebraic expressions can be case sensitive!)
= type:formula samples:"RL,RS,d@1,1,1:3,3,3#10" answer:"-RL/RS"
Let's introduct a multiple choice question with multiple correct answers.
(x) Choice A. This is correct.
(x) Choice B. This is also correct.
( ) Choice C. This is wrong.
...@@ -1179,10 +1179,10 @@ class FormulaResponse(LoncapaResponse): ...@@ -1179,10 +1179,10 @@ class FormulaResponse(LoncapaResponse):
value = random.uniform(*ranges[var]) value = random.uniform(*ranges[var])
instructor_variables[str(var)] = value instructor_variables[str(var)] = value
student_variables[str(var)] = value student_variables[str(var)] = value
log.debug('formula: instructor_vars=%s, expected=%s' % (instructor_variables,expected)) #log.debug('formula: instructor_vars=%s, expected=%s' % (instructor_variables,expected))
instructor_result = evaluator(instructor_variables, dict(), expected, cs=self.case_sensitive) instructor_result = evaluator(instructor_variables, dict(), expected, cs=self.case_sensitive)
try: try:
log.debug('formula: student_vars=%s, given=%s' % (student_variables,given)) #log.debug('formula: student_vars=%s, given=%s' % (student_variables,given))
student_result = evaluator(student_variables, student_result = evaluator(student_variables,
dict(), dict(),
given, given,
......
...@@ -75,9 +75,7 @@ class CapaModule(XModule): ...@@ -75,9 +75,7 @@ class CapaModule(XModule):
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')], js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')],
'js': [resource_string(__name__, 'js/src/capa/imageinput.js'), 'js': [resource_string(__name__, 'js/src/capa/imageinput.js'),
resource_string(__name__, 'js/src/capa/schematic.js'), resource_string(__name__, 'js/src/capa/schematic.js')]}
resource_string(__name__, 'js/src/capa/peg-0.7.0.min.js'),
resource_string(__name__, 'js/src/capa/xml-validator.js')]}
js_module_name = "Problem" js_module_name = "Problem"
css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]}
......
...@@ -12,6 +12,11 @@ log = logging.getLogger(__name__) ...@@ -12,6 +12,11 @@ log = logging.getLogger(__name__)
class CapawikiModule(CapaModule): class CapawikiModule(CapaModule):
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')],
'js': [resource_string(__name__, 'js/src/capa/imageinput.js'),
resource_string(__name__, 'js/src/capa/schematic.js'),
resource_string(__name__, 'js/src/capawiki/peg-0.7.0.min.js')]}
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs): def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
# self._definition = {'capa': '<problem />', 'wiki': ''} # self._definition = {'capa': '<problem />', 'wiki': ''}
self._definition = definition self._definition = definition
......
/*
1. Stealed from W3Schools XML Validator <www.w3schools.com/xml/xml_validator.asp>
2. Beautified with jsbeautifier.org
3. Feed in XML string and use return instead of alert.
*/
var xt = "",
h3OK = 1;
function checkErrorXML(x) {
xt = "";
h3OK = 1;
checkXML(x);
}
function checkXML(n) {
var l, i, nam;
nam = n.nodeName;
if (nam == "h3") {
if (h3OK == 0) {
return;
}
h3OK = 0
}
if (nam == "#text") {
xt = xt + n.nodeValue + "\n"
}
l = n.childNodes.length
for (i = 0; i < l; i++) {
checkXML(n.childNodes[i])
}
}
function validateXML(txt) {
// code for IE
console.log(txt);
if (window.ActiveXObject) {
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(txt);
if (xmlDoc.parseError.errorCode != 0) {
txt = "Error Code: " + xmlDoc.parseError.errorCode + "\n";
txt = txt + "Error Reason: " + xmlDoc.parseError.reason;
return txt;
} else {
return xmlDoc;
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation.createDocument) {
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(txt, "text/xml");
if (xmlDoc.getElementsByTagName("parsererror").length > 0) {
checkErrorXML(xmlDoc.getElementsByTagName("parsererror")[0]);
return xt;
} else {
return xmlDoc;
}
} else {
}
}
\ No newline at end of file
...@@ -3,7 +3,6 @@ import logging ...@@ -3,7 +3,6 @@ import logging
from .xml import XMLModuleStore from .xml import XMLModuleStore
from xmodule.x_module import Location from xmodule.x_module import Location
from .exceptions import DuplicateItemError from .exceptions import DuplicateItemError
import re
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -60,7 +59,7 @@ def import_from_xml_capawiki(store, data_dir, course_dirs=None, eager=True, ...@@ -60,7 +59,7 @@ def import_from_xml_capawiki(store, data_dir, course_dirs=None, eager=True,
return module_store return module_store
def import_from_xml_original(store, data_dir, course_dirs=None, eager=True, def import_from_xml(store, data_dir, course_dirs=None, eager=True,
default_class='xmodule.raw_module.RawDescriptor'): default_class='xmodule.raw_module.RawDescriptor'):
""" """
Import the specified xml data_dir into the "store" modulestore, Import the specified xml data_dir into the "store" modulestore,
...@@ -95,5 +94,3 @@ def import_from_xml_original(store, data_dir, course_dirs=None, eager=True, ...@@ -95,5 +94,3 @@ def import_from_xml_original(store, data_dir, course_dirs=None, eager=True,
return module_store return module_store
import_from_xml = import_from_xml_capawiki
\ No newline at end of file
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