Beispiel #1
0
def add_xml_scenario(scname, description, xml):
    """
    Add a scenario defined in XML.
    """
    assert scname not in SCENARIOS
    usage = parse_xml_string(xml, Usage)
    SCENARIOS[scname] = Scenario(description, usage)
Beispiel #2
0
def test_problem_submission():
    problem_usage = parse_xml_string("""
        <problem>
            <textinput name='vote_count' input_type='int'/>

            <script>
                numvotes = 4
            </script>
            <equality name='votes_named' left='./vote_count/@student_input' right='$numvotes'>
                Number of upvotes matches entered string
            </equality>
        </problem>
    """, Usage)
    problem_usage.store_initial_state()
    runtime = WorkbenchRuntime()
    problem = runtime.create_block(problem_usage)
    json_data = json.dumps({"vote_count": [{"name": "input", "value": "4"}]})
    resp = runtime.handle(problem, 'check', make_request(json_data))
    resp_data = json.loads(text_of_response(resp))
    assert_equals(resp_data['check_results']['votes_named'], True)
Beispiel #3
0
from xblock.core import XBlock
from xblock.parse import parse_xml_string
from .runtime import Usage

# Build the scenarios, which are named trees of usages.

Scenario = namedtuple("Scenario", "description usage")  # pylint: disable=C0103

SCENARIOS = {}

for class_name, cls in XBlock.load_classes():
    # Each XBlock class can provide scenarios to display in the workbench.
    if hasattr(cls, "workbench_scenarios"):
        for i, (desc, xml) in enumerate(cls.workbench_scenarios()):
            scname = "%s.%d" % (class_name, i)
            usage = parse_xml_string(xml, Usage)
            SCENARIOS[scname] = Scenario(desc, usage)
    else:
        # No specific scenarios, just show it with three generic children.
        default_children = [Usage("debugchild", []) for _ in xrange(3)]
        scname = "%s.0" % class_name
        usage = Usage(class_name, default_children)
        SCENARIOS[scname] = Scenario(class_name, usage)

SCENARIOS.update({
    'gettysburg': Scenario(
        "a bunch of html",
        Usage("html", [], {
            'content': u"""
                <h2>Gettysburg Address</h2>
Beispiel #4
0
from xblock.core import XBlock
from xblock.parse import parse_xml_string
from .runtime import Usage

# Build the scenarios, which are named trees of usages.

Scenario = namedtuple("Scenario", "description usage")

SCENARIOS = []

for name, cls in XBlock.load_classes():
    # Each XBlock class can provide scenarios to display in the workbench.
    if hasattr(cls, "workbench_scenarios"):
        for desc, xml in cls.workbench_scenarios():
            SCENARIOS.append(Scenario(desc, parse_xml_string(xml, Usage)))
    else:
        # No specific scenarios, just show it with three generic children.
        default_children = [Usage("debugchild", []) for _ in xrange(3)]
        SCENARIOS.append(Scenario(name, Usage(name, default_children)))

SCENARIOS.extend([
    Scenario(
        "a bunch of html",
        Usage("html", [], {
            'content': u"""
                <h2>Installing Enthought for Windows</h2>

                <p>To download Enthought on your Windows machine, you should follow these steps:</p>

                <ul>
Beispiel #5
0
from xblock.core import XBlock
from xblock.parse import parse_xml_string
from .runtime import Usage

# Build the scenarios, which are named trees of usages.

Scenario = namedtuple("Scenario", "description usage")

SCENARIOS = {}

for class_name, cls in XBlock.load_classes():
    # Each XBlock class can provide scenarios to display in the workbench.
    if hasattr(cls, "workbench_scenarios"):
        for i, (desc, xml) in enumerate(cls.workbench_scenarios()):
            scname = "%s.%d" % (class_name, i)
            usage = parse_xml_string(xml, Usage)
            SCENARIOS[scname] = Scenario(desc, usage)
    else:
        # No specific scenarios, just show it with three generic children.
        default_children = [Usage("debugchild", []) for _ in xrange(3)]
        scname = "%s.0" % class_name
        usage = Usage(class_name, default_children)
        SCENARIOS[scname] = Scenario(class_name, usage)

SCENARIOS.update({
    'gettysburg':
    Scenario(
        "a bunch of html",
        Usage(
            "html", [], {
                'content':