diff --git a/cms/static/coffee/src/models/capadescriptor.coffee b/cms/static/coffee/src/models/capadescriptor.coffee index e7bdf5d..08c8d84 100644 --- a/cms/static/coffee/src/models/capadescriptor.coffee +++ b/cms/static/coffee/src/models/capadescriptor.coffee @@ -1,6 +1,6 @@ class @CapawikiDescriptor constructor: (@element) -> - @loadParser("/static/grammars/main.jspeg") + @loadParser("/static/peg/capawiki.jspeg") @capa_box = $(".capa-box", @element) @wiki_box = $(".wiki-box", @element) diff --git a/cms/static/peg/wikisyntax.txt b/cms/static/peg/wikisyntax.txt new file mode 100644 index 0000000..6315d03 --- /dev/null +++ b/cms/static/peg/wikisyntax.txt @@ -0,0 +1,51 @@ +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. diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index a6e6436..75ed92a 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1179,10 +1179,10 @@ class FormulaResponse(LoncapaResponse): value = random.uniform(*ranges[var]) instructor_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) 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, dict(), given, diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 7285bfd..eed2cf3 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -75,9 +75,7 @@ class CapaModule(XModule): 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/capa/peg-0.7.0.min.js'), - resource_string(__name__, 'js/src/capa/xml-validator.js')]} + resource_string(__name__, 'js/src/capa/schematic.js')]} js_module_name = "Problem" css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} diff --git a/common/lib/xmodule/xmodule/capawiki_module.py b/common/lib/xmodule/xmodule/capawiki_module.py index 2e1f065..a85002d 100644 --- a/common/lib/xmodule/xmodule/capawiki_module.py +++ b/common/lib/xmodule/xmodule/capawiki_module.py @@ -12,6 +12,11 @@ log = logging.getLogger(__name__) 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): # self._definition = {'capa': '<problem />', 'wiki': ''} self._definition = definition diff --git a/common/lib/xmodule/xmodule/js/src/capa/xml-validator.js b/common/lib/xmodule/xmodule/js/src/capa/xml-validator.js deleted file mode 100644 index 3e7cc95..0000000 --- a/common/lib/xmodule/xmodule/js/src/capa/xml-validator.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -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 diff --git a/common/lib/xmodule/xmodule/js/src/capa/peg-0.7.0.min.js b/common/lib/xmodule/xmodule/js/src/capawiki/peg-0.7.0.min.js similarity index 100% rename from common/lib/xmodule/xmodule/js/src/capa/peg-0.7.0.min.js rename to common/lib/xmodule/xmodule/js/src/capawiki/peg-0.7.0.min.js diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 44376b5..257cfeb 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -3,7 +3,6 @@ import logging from .xml import XMLModuleStore from xmodule.x_module import Location from .exceptions import DuplicateItemError -import re log = logging.getLogger(__name__) @@ -60,7 +59,7 @@ def import_from_xml_capawiki(store, data_dir, course_dirs=None, eager=True, 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'): """ 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, return module_store - -import_from_xml = import_from_xml_capawiki \ No newline at end of file