// Numbas version: exam_results_page_options {"name": "JSXGraph demo", "metadata": {"description": "

Some questions which use JSXGraph to create interactive graphics.

", "licence": "Creative Commons Attribution 4.0 International"}, "duration": 0, "percentPass": "0", "showQuestionGroupNames": true, "shuffleQuestionGroups": false, "showstudentname": true, "question_groups": [{"name": "Drawing diagrams", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "", "", ""], "variable_overrides": [[], [], [], [], []], "questions": [{"name": "Create a JSXGraph diagram using JME code: Three triangle centres lie on a line", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

This demonstrates how to construct a JSXGraph diagram in JME code.

\n

The construction shows a triangle and its orthocentre, circumcentre and centroid. They are always collinear. You can move the vertices of the triangle.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

{triangle_diagram}

\n

This diagram was created using the following JME code:

\n
jsxgraph(
  600,600,
  [
    ['point',[-2,-2],[\"name\":\"A\"]],
    ['point',[2,-2],[\"name\":\"B\"]],
    ['point',[1,2],[\"name\":\"C\"]],
    ['circumcenter',['A','B','C'],[\"name\":\"circumcenter\"]],
    ['polygon',['A','B','C']],
    ['segment',['B','C'],['name':'side_A', \"visible\": false]],
    ['segment',['A','C'],['name':'side_B', \"visible\": false]],
    ['segment',['B','A'],['name':'side_C', \"visible\": false]],
    ['perpendicular',['side_A','A'], dotted_line+[\"name\": \"p_a\"] ],
    ['perpendicular',['side_B','B'], dotted_line+[\"name\": \"p_b\"] ],
    ['perpendicular',['side_C','C'], dotted_line+[\"name\": \"p_c\"] ],
    ['circle',['A','B','C'],[\"strokeOpacity\": 0.3]],
    ['midpoint',['A','B'],['name':'M_c', \"visible\": false]],
    ['midpoint',['A','C'],['name':'M_b', \"visible\": false]],
    ['midpoint',['C','B'],['name':'M_a', \"visible\": false]],
    ['line',['A','M_a'],dashed_line+[\"name\": \"median_a\"]],
    ['line',['B','M_b'],dashed_line+[\"name\": \"median_b\"]],
    ['line',['C','M_c'],dashed_line+[\"name\": \"median_c\"]],
    ['intersection',['median_a','median_b'],[\"name\":\"centroid\"]],
    ['intersection',['p_a','p_b'],[\"name\":\"orthocenter\"]],
    ['line',['centroid','orthocenter']]
  ],
  [
    \"axis\": false
  ]
)
", "advice": "", "rulesets": {}, "variables": {"triangle_diagram": {"name": "triangle_diagram", "group": "Ungrouped variables", "definition": "jsxgraph(\n 600,600,\n [\n ['point',[-2,-2],[\"name\":\"A\"]],\n ['point',[2,-2],[\"name\":\"B\"]],\n ['point',[1,2],[\"name\":\"C\"]],\n ['circumcenter',['A','B','C'],[\"name\":\"circumcenter\"]],\n ['polygon',['A','B','C']],\n ['segment',['B','C'],['name':'side_A', \"visible\": false]],\n ['segment',['A','C'],['name':'side_B', \"visible\": false]],\n ['segment',['B','A'],['name':'side_C', \"visible\": false]],\n ['perpendicular',['side_A','A'], dotted_line+[\"name\": \"p_a\"] ],\n ['perpendicular',['side_B','B'], dotted_line+[\"name\": \"p_b\"] ],\n ['perpendicular',['side_C','C'], dotted_line+[\"name\": \"p_c\"] ],\n ['circle',['A','B','C'],[\"strokeOpacity\": 0.3]],\n ['midpoint',['A','B'],['name':'M_c', \"visible\": false]],\n ['midpoint',['A','C'],['name':'M_b', \"visible\": false]],\n ['midpoint',['C','B'],['name':'M_a', \"visible\": false]],\n ['line',['A','M_a'],dashed_line+[\"name\": \"median_a\"]],\n ['line',['B','M_b'],dashed_line+[\"name\": \"median_b\"]],\n ['line',['C','M_c'],dashed_line+[\"name\": \"median_c\"]],\n ['intersection',['median_a','median_b'],[\"name\":\"centroid\"]],\n ['intersection',['p_a','p_b'],[\"name\":\"orthocenter\"]],\n ['line',['centroid','orthocenter']]\n ],\n [\n \"axis\": false\n ]\n)", "description": "", "templateType": "anything"}, "dashed_line": {"name": "dashed_line", "group": "Ungrouped variables", "definition": "[\"dash\": 4, \"strokeOpacity\": 0.3, \"color\": \"gray\"]", "description": "", "templateType": "anything"}, "dotted_line": {"name": "dotted_line", "group": "Ungrouped variables", "definition": "dashed_line+[\"dash\":1]", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["triangle_diagram", "dashed_line", "dotted_line"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Create a JSXGraph diagram using JessieCode: Three triangle centres lie on a line", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Laura Midgley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/18287/"}], "tags": [], "metadata": {"description": "

This question demonstrates how to construct a JSXGraph diagram using JessieCode.

\n

The construction shows a triangle and its orthocentre, circumcentre and centroid. They are always collinear. You can move the vertices of the triangle.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

{triangle_diagram}

\n

This diagram was created using the following JessieCode:

\n
jessiecode(
  600,600,
  \"\"\"
    A = point(-2,-2);
    B = point(2,-2);
    C = point(1,2);
 
    circumcenter = circumcenter(A,B,C) << name: \"circumcenter\" >>;
    circle(A,B,C) << strokeOpacity: 0.3 >>;
 
    side_a = segment(B,C) << visible: false >>;
    side_b = segment(A,C) << visible: false >>;
    side_c = segment(B,A) << visible: false >>;
 
    polygon(A,B,C);
    
    M_a = midpoint(B,C) << visible: false >>;
    M_b = midpoint(A,C) << visible: false >>;
    M_c = midpoint(B,A) << visible: false >>;
 
    median_a = line(A,M_a) << dash: 4, color: \"gray\", strokeOpacity: 0.3 >>;
    median_b = line(B,M_b) << dash: 4, color: \"gray\", strokeOpacity: 0.3 >>;
    median_c = line(C,M_c) << dash: 4, color: \"gray\", strokeOpacity: 0.3 >>;
    
    centroid = intersection(median_a,median_b) << name: \"centroid\" >>;
 
    p_a = perpendicular(side_a,A) << dash: 1, color: \"gray\", strokeOpacity: 0.3 >>;
    p_b = perpendicular(side_b,B) << dash: 1, color: \"gray\", strokeOpacity: 0.3 >>;
    p_c = perpendicular(side_c,C) << dash: 1, color: \"gray\", strokeOpacity: 0.3 >>;
 
    orthocenter = intersection(p_a,p_b) << name: \"orthocenter\" >>;
 
    euler_line = line(orthocenter, centroid);
  \"\"\",
  [
    \"axis\": false
  ]
)
", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"triangle_diagram": {"name": "triangle_diagram", "group": "Ungrouped variables", "definition": "jessiecode(\n 600,600,\n \"\"\"\n A = point(-2,-2);\n B = point(2,-2);\n C = point(1,2);\n \n circumcenter = circumcenter(A,B,C) << name: \"circumcenter\" >>;\n circle(A,B,C) << strokeOpacity: 0.3 >>;\n \n side_a = segment(B,C) << visible: false >>;\n side_b = segment(A,C) << visible: false >>;\n side_c = segment(B,A) << visible: false >>;\n \n polygon(A,B,C);\n \n M_a = midpoint(B,C) << visible: false >>;\n M_b = midpoint(A,C) << visible: false >>;\n M_c = midpoint(B,A) << visible: false >>;\n \n median_a = line(A,M_a) << dash: 4, color: \"gray\", strokeOpacity: 0.3 >>;\n median_b = line(B,M_b) << dash: 4, color: \"gray\", strokeOpacity: 0.3 >>;\n median_c = line(C,M_c) << dash: 4, color: \"gray\", strokeOpacity: 0.3 >>;\n \n centroid = intersection(median_a,median_b) << name: \"centroid\" >>;\n \n p_a = perpendicular(side_a,A) << dash: 1, color: \"gray\", strokeOpacity: 0.3 >>;\n p_b = perpendicular(side_b,B) << dash: 1, color: \"gray\", strokeOpacity: 0.3 >>;\n p_c = perpendicular(side_c,C) << dash: 1, color: \"gray\", strokeOpacity: 0.3 >>;\n \n orthocenter = intersection(p_a,p_b) << name: \"orthocenter\" >>;\n \n euler_line = line(orthocenter, centroid);\n \"\"\",\n [\n \"axis\": false\n ]\n)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["triangle_diagram"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Plot a function", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

This question demonstrates how to plot a graph of a function using JSXGraph.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

The amplitude of this sine curve is {amplitude} and its period is {period}.

\n

{diagram}

", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"period": {"name": "period", "group": "Ungrouped variables", "definition": "random(1..max_period)", "description": "", "templateType": "anything", "can_override": false}, "amplitude": {"name": "amplitude", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything", "can_override": false}, "diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jsxgraph(\n 500,500,\n [-1, amplitude+1, 2*max_period+1, -amplitude-1],\n [\n \"f\": ['functiongraph',[function]]\n ]\n)", "description": "", "templateType": "anything", "can_override": false}, "max_period": {"name": "max_period", "group": "Ungrouped variables", "definition": "6", "description": "", "templateType": "anything", "can_override": false}, "function": {"name": "function", "group": "Ungrouped variables", "definition": "expression(\"sin(2*pi*x/period)*amplitude\")", "description": "

The function to plot.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["function", "period", "amplitude", "diagram", "max_period"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Immediately show a plot of the student's function", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

This question shows a JSXGraph diagram above a mathematical expression input, containing a plot of the expression the student enters.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jsxgraph(\n 500,500,\n [\n \"f\": ['functiongraph',[expr,-5,5], [\"id\": \"f\"]]\n ]\n)", "description": "", "templateType": "anything", "can_override": false}, "expr": {"name": "expr", "group": "Ungrouped variables", "definition": "expression(\"x\")", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["diagram", "expr"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "0", "scripts": {}, "customMarkingAlgorithm": "jxg_input:\n [ jxg_show(diagram[\"f\"],false) ]\n +\n if(studentExpr<>nothing,\n if(set(findvars(studentExpr))<>set(\"x\"),\n warn(\"Your expression must only use the variable $x$\");\n []\n ,\n [ jxg_show(diagram[\"f\"],true)\n , jxg_set_term(diagram[\"f\"], studentExpr)\n ]\n )\n ,\n []\n )", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

{diagram}

\n

Write an expression in terms of $x$ in the box below. It will be plotted in the box above.

", "answer": "x", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "x", "value": ""}]}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Plot an implicit curve corresponding to a function given by the student", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://clppc:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

This shows how to take an expression given by the student and plot the implicit curve of points where it equals zero.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

{diagram}

", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jsxgraph(400,400, [-4,4,4,-4], [\n \"a\": [\"slider\", [[-3.5,2.5],[-1.5,2.5],[-3,0,3]], [\"id\": \"a\"]],\n \"b\": [\"slider\", [[-3.5,1.5],[-1.5,1.5],[-3,0,3]], [\"id\": \"b\"]],\n \"f\": [\"implicitcurve\", [expr], [\"id\": \"f\"]]\n])", "description": "", "templateType": "anything", "can_override": false}, "expr": {"name": "expr", "group": "Ungrouped variables", "definition": "expression(\"x^2+y^2-a\")", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["expr", "diagram"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write an expression in terms of the coordinates $(x,y)$ and the parameters $a$ and $b$.

\n

The plot above will show points where your expression equals zero.

\n

Note: very complicated plots can slow down your device.

\n

A nice expression is sin(x^2+y^2)+4a^2y^2(x^2+y^2-b^2)

\n

$f(x,y,a,b) = $ [[0]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "0", "scripts": {}, "customMarkingAlgorithm": "plotExpr:\n try(\n simplify(\n expand_juxtapositions(parse(studentAnswer), expand_juxtapositions_settings),\n 'basic'\n )\n , error,\n expression(\"1\")\n )\n\njxg_input:\n [ jxg_set_term(diagram[\"f\"], plotExpr) ]\n\nmark:\n nothing", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "x", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "x", "value": ""}]}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}, {"name": "Marked diagrams", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "Position a circle so it touches a point", "Place points on a Venn diagram", "Make a spanning tree", "Interactive 2D optimisation"], "variable_overrides": [[], [], [], [], [], []], "questions": [{"name": "Move a point to the given coordinates", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

The student is shown a diagram containing a single point at the origin. They must move the point to the given integer coordinates.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "

The point should go here:

\n

{correct_diagram}

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"coords": {"name": "coords", "group": "Ungrouped variables", "definition": "vector(x,y)", "description": "", "templateType": "anything", "can_override": false}, "diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jessiecode(400,400,\"\"\"\n point(0,0) <>;\n\"\"\")", "description": "", "templateType": "anything", "can_override": false}, "x": {"name": "x", "group": "Ungrouped variables", "definition": "random(-3..3)", "description": "", "templateType": "anything", "can_override": false}, "y": {"name": "y", "group": "Ungrouped variables", "definition": "random(-3..3 except x)", "description": "", "templateType": "anything", "can_override": false}, "correct_diagram": {"name": "correct_diagram", "group": "Ungrouped variables", "definition": "jessiecode(400,400,\"\"\"\n point({x},{y}) <>;\n\"\"\")", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["x", "y", "coords", "diagram", "correct_diagram"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "extension", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "student_pos: jxg_position(diagram[\"A\"])\n\nmark:\n correctif(student_pos=coords)\n\ninterpreted_answer: student_pos", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Move the dot to the coordinates $\\var[rowvector]{coords}$.

\n

{diagram}

"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Create a line with given gradient", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

The student is shown a diagram containing a line between two points. They're given a gradient and $y$-intercept.

\n

They must manipulate the line or the points so that the line has the given gradient and $y$-intercept.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"gradient": {"name": "gradient", "group": "Ungrouped variables", "definition": "dy/dx", "description": "

The gradient that the student's line should have. Designed to be a nice fraction.

", "templateType": "anything", "can_override": false}, "diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jessiecode(400,400,[-5,10,10,-5],\"\"\"\n a = point(1,0) <>;\n b = point(2,0) <>;\n line = line(a,b) <>;\n\"\"\")", "description": "

The diagram shown to the student.

", "templateType": "anything", "can_override": false}, "dx": {"name": "dx", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "

A randomly chosen change in x to get a nice gradient.

", "templateType": "anything", "can_override": false}, "dy": {"name": "dy", "group": "Ungrouped variables", "definition": "random(-5..5 except 0)", "description": "

A randomly chosen change in y to get a nice gradient.

", "templateType": "anything", "can_override": false}, "y_intercept": {"name": "y_intercept", "group": "Ungrouped variables", "definition": "random(0..4)", "description": "

The point at which the student's line should cross the y axis.

", "templateType": "anything", "can_override": false}, "x_intercept": {"name": "x_intercept", "group": "Ungrouped variables", "definition": "let([g,y], gradient_intercept_pair,\n -y/g\n)", "description": "

The position at which the line crosses the x axis

", "templateType": "anything", "can_override": false}, "gradient_intercept_pair": {"name": "gradient_intercept_pair", "group": "Ungrouped variables", "definition": "[gradient,y_intercept]", "description": "

The gradient and y-intercept of the line as a pair, to be replaced by the student's answer for adaptive marking in part b.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["dx", "dy", "gradient", "y_intercept", "diagram", "gradient_intercept_pair", "x_intercept"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "extension", "useCustomName": false, "customName": "", "marks": "2", "scripts": {}, "customMarkingAlgorithm": "student_line: diagram[\"l\"]\n\nstudent_gradient: jxg_slope(student_line)\n\nstudent_intercept: jxg_rise(student_line)\n\ncorrect_gradient (Does the student's line have the right gradient?):\n if(student_gradient=gradient, \n add_credit(0.5,\"Your line has the right gradient.\"),\n negative_feedback(\"Your line does not have the correct gradient (yours has {student_gradient}).\")\n )\n\ncorrect_intercept (Does the student's line have the right y-intercept?):\n if(student_intercept=y_intercept, \n add_credit(0.5,\"Your line has the right $y$-intercept.\"),\n negative_feedback(\"Your line does not have the correct $y$-intercept (yours has {student_intercept}).\")\n )\n\nmark:\n apply(correct_gradient);\n apply(correct_intercept)\n\ninterpreted_answer: [student_gradient,student_intercept]", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Construct a line with gradient {gradient} and $y$-intercept {y_intercept}.

\n

You can move the line by dragging it, or move the two points individually.

\n

{diagram}

"}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Where does the line cross the $x$ axis?

\n

$x = $ [[0]]

", "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [{"variable": "gradient_intercept_pair", "part": "p0", "must_go_first": false}], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": "0.5", "exploreObjective": null, "minValue": "x_intercept", "maxValue": "x_intercept", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "JSXGraph: position a circle so it touches a point", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

The student is shown a Cartesian diagram containing a point $P$ and a circle. They must move the point and change its radius so that the point $P$ is touching the circle.

\n

They can type the radius and coordinates in, or move the circle around on the diagram.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

{diagram}

", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jessiecode(400,400,\"\"\"\n\n A = point(0,0) <>;\n C = circle(A,1) <>;\n \n P = point({p[0]},{p[1]}) <>;\n\"\"\")", "description": "", "templateType": "anything", "can_override": false}, "p": {"name": "p", "group": "Ungrouped variables", "definition": "vector(random(-4..-1),random(1..4))", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["diagram", "p"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "centre: jxg_position(diagram[\"A\"])\n\nradius: jxg_radius(diagram[\"C\"])\n\nin_right_quadrant:\n if(centre[0]>0 and centre[1]>0,\n add_credit(1/2, \"The centre of your circle is in the top-right quadrant.\")\n , negative_feedback(\"Your circle is not in the top-right quadrant.\")\n )\n\ntouches_point:\n if(isclose(len(centre-p),radius,0,0.1),\n add_credit(1/2, \"Your circle is touching the point.\")\n , negative_feedback(\"Your circle is not touching the point.\")\n )\n\nmark:\n apply(in_right_quadrant);\n apply(touches_point)\n\ninterpreted_answer: [centre, radius]", "extendBaseMarkingAlgorithm": false, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Make the circle touch the point $P$. The circle's centre must be in the top-right quadrant of the graph.

\n

You can change its radius and the position of its centre.

\n

Radius: [[0]]

\n

Coordinates of the centre: [[1]]

", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "Radius", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "jxg_input (Update the diagram after the student's answer changes):\n if(not isnan(studentnumber) and studentNumber>0,\n [jxg_set(diagram[\"C\"],\"Radius\",studentNumber)]\n ,\n []\n )\n\njxg_output (Fill in the answer box after the diagram changes):\n dpformat(jxg_radius(diagram[\"C\"]),2)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "1", "maxValue": "1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "matrix", "useCustomName": true, "customName": "Coordinates of the centre", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "jxg_input: \n [ jxg_set_position(diagram[\"A\"],studentMatrix[0]) ]\n\njxg_output:\n let([x,y],jxg_position(diagram[\"A\"]),\n [[dpformat(x,2),dpformat(y,2)]]\n )", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "transpose(vector(0,0))", "correctAnswerFractions": false, "numRows": 1, "numColumns": "2", "allowResize": false, "tolerance": 0, "markPerCell": false, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "JSXGraph interactive Venn diagram", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

This question demonstrates a few ways of interacting with a Venn diagram drawn using JSXGraph.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

This question demonstrates a few ways of interacting with a Venn diagram.

\n

Here's a blank Venn diagram with two subsets:

\n

{venn_diagram_2(\"A\",\"B\")}

", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"n": {"name": "n", "group": "One point", "definition": "random(-5..5 except 0)", "description": "", "templateType": "anything", "can_override": false}, "ns": {"name": "ns", "group": "Ungrouped variables", "definition": "shuffle(-7..7 except 0)[0..6]", "description": "", "templateType": "anything", "can_override": false}, "venn_diagram_many_checkboxes": {"name": "venn_diagram_many_checkboxes", "group": "Ungrouped variables", "definition": "jxg_add_objects(venn_diagram_2(\"Positive\",\"Even\"),\n map(['point',[i-len(ns)/2,3],[\"id\":'n_{i}',\"size\":5,name:\"{ns[i]}\"]],i,0..len(ns)-1)\n)", "description": "", "templateType": "anything", "can_override": false}, "marking_matrix": {"name": "marking_matrix", "group": "Ungrouped variables", "definition": "map(\n [award(1,n>0),award(1,mod(n,2)=0)],\n n,\n ns\n)", "description": "", "templateType": "anything", "can_override": false}, "venn_diagram_one_checkboxes": {"name": "venn_diagram_one_checkboxes", "group": "One point", "definition": "jxg_run_jessiecode(venn_diagram_2(\"Positive\",\"Even\"),\"\"\"\n A = point(0,3) <>;\n\"\"\")", "description": "", "templateType": "anything", "can_override": false}, "venn_diagram_one_solo": {"name": "venn_diagram_one_solo", "group": "One point", "definition": "jxg_run_jessiecode(venn_diagram_2(\"Positive\",\"Even\"),\"\"\"\n A = point(0,3) <>;\n\"\"\")", "description": "", "templateType": "anything", "can_override": false}, "venn_diagram_many_solo": {"name": "venn_diagram_many_solo", "group": "Ungrouped variables", "definition": "jxg_add_objects(venn_diagram_2(\"Positive\",\"Even\"),\n map(['point',[i-len(ns)/2,3],[\"id\":'n_{i}',\"size\":5,name:\"{ns[i]}\"]],i,0..len(ns)-1)\n)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["ns", "venn_diagram_many_checkboxes", "marking_matrix", "venn_diagram_many_solo"], "variable_groups": [{"name": "One point", "variables": ["n", "venn_diagram_one_checkboxes", "venn_diagram_one_solo"]}], "functions": {"venn_diagram_2": {"parameters": [["set1_name", "string"], ["set2_name", "string"]], "type": "jsxgraphboard", "language": "jme", "definition": "jessiecode(500,400,[-5,4,5,-4],\"\"\"\n r = 2.5;\n circle([-1.5,0],r) <>;\n circle([1.5,0],r) <>;\n text(-2.5,-r-0.5,\"{set1_name}\") <>;\n text(2.5,-r-0.5,\"{set2_name}\") <>;\n\"\"\",\n [\"grid\": false, \"axis\": false]\n)"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "information", "useCustomName": true, "customName": "Placing one point", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

The following two parts show two ways of interactively placing a point on a Venn diagram, and marking it.

\n

In the first, there's a diagram and checkboxes for membership of each subset. When you move the point the checkboxes are updated, and if you change the checkboxes the point is moved to an appropriate point on the diagram.

\n

If you're assessing the student's ability to interpret a Venn diagram, the checkboxes make explicit the meaning of the point's position, so they shouldn't be visible. The second part just shows the diagram.

"}, {"type": "m_n_2", "useCustomName": true, "customName": "One point, with checkboxes", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "diagram: venn_diagram_one_checkboxes\n\npoint (The point that the student should move): diagram[\"A\"]\n\nshould_move (After the student changes a tickbox, should the point move?):\n studentAnswer <> jxg_output\n\njxg_input (After the student changes a tickbox, move the point if necessary):\n if(should_move,\n let(\n // encode the subset memberships together as a number\n q, 2*award(1,studentAnswer[0][0]) + award(1,studentAnswer[1][0]),\n // appropriate positions for each combination of subset memberships\n ps, [vector(0,3), vector(2,0), vector(-2,0), vector(0,0)],\n // move the point\n [jxg_set_position(point,ps[q])]\n ),\n // if the point's position already matches the student's answer, don't move it\n []\n )\n\ncoords (The coordinates of the point):\n jxg_position(point)\n\nin_set_one (Is the point in the first subset circle?):\n jxg_has_point(diagram[\"c_1\"], coords)\n\nin_set_two (Is the point in the second subset circle?):\n jxg_has_point(diagram[\"c_2\"], coords)\n\njxg_output (Fill in the answer widget when the board changes):\n // The answer format for multiple choice parts is a 2D array of true/false values.\n // For \"choose several from a list\" parts, the array has one column, and a row for each choice.\n [[in_set_one], [in_set_two]]", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

This Venn diagram shows the properties \"even\" and \"positive\" for integers.

\n

Decide if {n} is positive, and if it is even. Tick the boxes below, or move the point labelled {n} to the appropriate position on the diagram.

\n

{venn_diagram_one_checkboxes}

", "minMarks": 0, "maxMarks": "1", "shuffleChoices": false, "displayType": "checkbox", "displayColumns": 0, "minAnswers": 0, "maxAnswers": 0, "warningType": "none", "showCellAnswerState": true, "markingMethod": "all-or-nothing", "choices": ["Positive", "Even"], "matrix": ["award(1,n>0)", "award(1,mod(n,2)=0)"], "distractors": ["", ""]}, {"type": "extension", "useCustomName": true, "customName": "One point, without checkboxes", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "diagram: venn_diagram_one_solo\n\npoint: diagram[\"A\"]\n\ncoords: jxg_position(point)\n\nin_set_one: jxg_has_point(diagram[\"c_1\"], coords)\n\nin_set_two: jxg_has_point(diagram[\"c_2\"], coords)\n\ncorrect_in_set_one: n>0\n\ncorrect_in_set_two: mod(n,2)=0\n\ncorrect_answer: [correct_in_set_one, correct_in_set_two]\n\nmark_set_one:\n if(in_set_one = correct_in_set_one,\n add_credit(0.5,if(in_set_one, \"{n} is positive.\", \"{n} is not positive.\"))\n ,\n negative_feedback(\n if(in_set_one, \n \"You said that {n} is positive, but it is not.\"\n , \"You said that {n} is not positive, but it is.\"\n )\n )\n )\n\nmark_set_two:\n if(in_set_two = correct_in_set_two,\n add_credit(0.5,if(in_set_one, \"{n} is even.\", \"{n} is not even.\"))\n ,\n negative_feedback(\n if(in_set_two, \n \"You said that {n} is even, but it is not.\"\n , \"You said that {n} is not even, but it is.\"\n )\n )\n )\n\nmark:\n apply(mark_set_one);\n apply(mark_set_two)\n\ninterpreted_answer:\n [in_set_one, in_set_two]", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

This Venn diagram shows the properties \"even\" and \"positive\" for integers.

\n

Move the point representing the number {n} to an appropriate position on the diagram.

\n

{venn_diagram_one_solo}

"}, {"type": "information", "useCustomName": true, "customName": "Placing several points", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

The following two parts show two ways of interactively placing several points on a Venn diagram, and marking them.

\n

In the first, there's a diagram and checkboxes for membership of each subset. When you move a point the checkboxes are updated, and if you change the checkboxes the corresponding is moved to an appropriate point on the diagram.

\n

If you're assessing the student's ability to interpret a Venn diagram, the checkboxes make explicit the meaning of the point's position, so they shouldn't be visible. The second part just shows the diagram.

"}, {"type": "m_n_x", "useCustomName": true, "customName": "Several points, with checkboxes", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "diagram: venn_diagram_many_checkboxes\n\nshould_change (After the student changes their input, which points need to move?):\n filter(\n [contained[0][i],contained[1][i]] <> [studentAnswer[0][i], studentAnswer[1][i]],\n i,\n 0..len(ns)-1\n )\n\njxg_input (After the student changes their answer, move the corresponding points):\n map(\n let(\n // encode the subset memberships together as a number in [0,1,2,3]\n q, 2*award(1,studentAnswer[0][i]) + award(1,studentAnswer[1][i]),\n // each point should be at a different y coordinate so they don't overlap\n y, 1.5*(-1 + 2*i/(len(ns)-1)),\n // positions for each combination of subset memberships\n ps, [vector(i-len(ns)/2,3),vector(2,y),vector(-2,y),vector(0,y)],\n // move the point to a position matching the chosen subset memberships\n jxg_set_position(diagram[\"n_{i}\"],ps[q])\n ),\n i,\n should_change\n )\n\n\ncoords (The coordinates of each point): \n map(jxg_position(diagram[\"n_{i}\"]),i,0..len(ns)-1)\n\ncontained (For each subset circle, decide for each point if it's inside that subset or not):\n map(map(jxg_has_point(diagram[x], c[0], c[1]),c,coords), x, [\"c_1\",\"c_2\"])\n\njxg_output (Fill in the answer widget when the diagram changes): \n contained", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

The Venn diagram below represents the set of integers, with the positive and even numbers as subsets.

\n

For each of the numbers {join(ns,', ')}, decide if it is positive and if it is even. Tick the boxes below, or move the points representing the numbers to the appropriate positions on the diagram.

\n

{venn_diagram_many_checkboxes}

", "minMarks": 0, "maxMarks": "6", "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": false, "shuffleAnswers": false, "displayType": "checkbox", "warningType": "none", "showCellAnswerState": true, "markingMethod": "score per matched cell", "choices": "map(string(n),n,ns)", "matrix": "marking_matrix", "layout": {"type": "all", "expression": ""}, "answers": ["Positive", "Even"]}, {"type": "extension", "useCustomName": true, "customName": "Several points, without checkboxes", "marks": "6", "scripts": {}, "customMarkingAlgorithm": "diagram: venn_diagram_many_solo\n\npoints (The points to move):\n map(diagram[\"n_{i}\"],i,0..len(ns)-1)\n\ncoords (The coordinates of each point): \n map(jxg_position(p),p,points)\n\ncorrect_memberships:\n map(\n [n>0, mod(n,2)=0],\n n,\n ns\n )\n\nstudent_memberships (For each point, is it inside each of the subset circles?):\n map(\n [jxg_has_point(diagram[\"c_1\"],c), jxg_has_point(diagram[\"c_2\"],c)],\n c,\n coords\n )\n\ncredit_per: 1/(2*len(ns))\n\nmark_points:\n map(\n let(\n [c_1,c_2], correct, \n [s_1,s_2], student,\n if(c_1 = s_1,\n add_credit(credit_per,if(c_1, \"{n} is positive.\", \"{n} is not positive.\"))\n ,\n negative_feedback(\n if(s_1, \n \"You said that {n} is positive, but it is not.\"\n , \"You said that {n} is not positive, but it is.\"\n )\n )\n )\n if(c_2 = s_2,\n add_credit(credit_per,if(c_2, \"{n} is even.\", \"{n} is not even.\"))\n ,\n negative_feedback(\n if(s_2, \n \"You said that {n} is even, but it is not.\"\n , \"You said that {n} is not even, but it is.\"\n )\n )\n )\n ),\n [correct,student,n],\n zip(correct_memberships, student_memberships, ns)\n )\n\nmark:\n apply(mark_points)\n\ninterpreted_answer:\n student_memberships", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

The Venn diagram below represents the set of integers, with the positive and even numbers as subsets.

\n

For each of the numbers {join(ns,', ')}, decide if it is positive and if it is even. Move the points representing the numbers to the appropriate positions on the diagram.

\n

{venn_diagram_many_solo}

"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "JSXGraph: make a spanning tree", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

The student must make a spanning tree of the complete graph $K_5$. They can tick boxes to include or exclude edges, or toggle them by clicking on a visual representation of the graph.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

A spanning tree of a graph is a subset of its edges which includes every vertex but has no cycles.

\n

Make a spanning tree of this graph. To include an edge in your spanning tree, tick the corresponding box below, or click on an edge in the diagram to toggle it. Excluded edges are faded out.

\n

{diagram}

", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jsxgraph(400,400,[-2,2,2,-2],\n // a circle of points\n map(\n [\n 'point',\n [cos(i*2pi/num_points), sin(i*2pi/num_points)], \n [\"id\": \"p{i}\", \"name\": vertex_names[i], \"fixed\": true]\n ],\n i,\n 0..num_points-1\n )+\n // every possible edge between the points\n map(\n [\n 'segment',\n ['p{i}','p{j}'],\n [\"id\":\"l_{i}_{j}\"],\n // when an edge is clicked, toggle its opacity \n // - this is used to represent whether the edge is included\n [\"up\": \"l_{i}_{j}.strokeopacity = 1.2 - l_{i}_{j}.strokeopacity;\"\n ]\n ],\n [i,j],\n combinations(0..num_points-1,2)\n ),\n [\"grid\": false, \"axis\": false]\n)", "description": "", "templateType": "anything", "can_override": false}, "num_points": {"name": "num_points", "group": "Ungrouped variables", "definition": "5", "description": "", "templateType": "anything", "can_override": false}, "vertex_names": {"name": "vertex_names", "group": "Ungrouped variables", "definition": "map(capitalise(letterordinal(i)),i,0..num_points-1)", "description": "", "templateType": "anything", "can_override": false}, "q": {"name": "q", "group": "Ungrouped variables", "definition": "is_spanning_tree([[false,true,true],[false,false,false],[false,false,false]])", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["diagram", "num_points", "vertex_names", "q"], "variable_groups": [], "functions": {"is_spanning_tree": {"parameters": [["adjacency", "list"]], "type": "boolean", "language": "javascript", "definition": "var visited = {};\nvar num_visited = 0;\nvar symm = adjacency.map(function(row,i) { return row.map(function(x,j) { return i0.5, false),\n j,\n 0..num_points-1\n ),\n i,\n 0..num_points-1\n )\n\nmark:\n correctif(is_spanning_tree(studentanswer))", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": false, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minMarks": 0, "maxMarks": "5", "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": false, "shuffleAnswers": false, "displayType": "checkbox", "warningType": "none", "showCellAnswerState": true, "markingMethod": "all-or-nothing", "choices": "vertex_names", "matrix": "repeat([1]+repeat(0,num_points-1),num_points)", "layout": {"type": "strictlowertriangle", "expression": ""}, "answers": "vertex_names"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "JSXGraph: interactive 2D optimisation", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "tags": [], "metadata": {"description": "

A 2D linear programming problem: optimise the profit from producing two different kinds of product, which both use the same limited resources.

\n

A JSXGraph diagram illustrates the problem and can be used to find an answer.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

A factory produces two items, {prod_1_name} and {prod_2_name}.

\n

They both use {resource_1_name} and {resource_2_name}.

\n

You have {max_resource_1} {resource_1_unit} {resource_1_name} and {max_resource_2} {resource_2_unit} {resource_2_name}.

\n

Each {prod_1_name} uses {resource_1_per_prod_1} {resource_1_unit} {resource_1_name} and {resource_2_per_prod_1} {resource_2_unit} {resource_2_name}, and can be sold for {currency(prod_1_price,\"£\",\"p\")}.

\n

Each {prod_2_name} uses {resource_1_per_prod_2} {resource_1_unit} {resource_1_name} and {resource_2_per_prod_2} {resource_2_unit} {resource_2_name}, and can be sold for {currency(prod_2_price,\"£\",\"p\")}.

\n

The graph below shows these constraints: the horizontal axis corresponds to the number of {prod_1_name} produced, and the vertical axis corresponds to the number of {prod_2_name} produced.

\n

The solid lines show the constraints corresponding to the amounts of {resource_1_name} and {resource_2_name} available, and the dashed line represents revenue.

\n

{diagram}

", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"max_resource_1": {"name": "max_resource_1", "group": "Setup", "definition": "random(100..200#10)", "description": "", "templateType": "anything", "can_override": false}, "resource_1_per_prod_1": {"name": "resource_1_per_prod_1", "group": "Setup", "definition": "round(max_resource_1/random(1..10))", "description": "", "templateType": "anything", "can_override": false}, "resource_1_per_prod_2": {"name": "resource_1_per_prod_2", "group": "Setup", "definition": "round(max_resource_1/random(8..20))", "description": "", "templateType": "anything", "can_override": false}, "max_resource_2": {"name": "max_resource_2", "group": "Setup", "definition": "random(1000..2000#50)", "description": "", "templateType": "anything", "can_override": false}, "resource_2_per_prod_1": {"name": "resource_2_per_prod_1", "group": "Setup", "definition": "round(max_resource_2/random(8..20))", "description": "", "templateType": "anything", "can_override": false}, "resource_2_per_prod_2": {"name": "resource_2_per_prod_2", "group": "Setup", "definition": "round(max_resource_2/random(1..10))", "description": "", "templateType": "anything", "can_override": false}, "resource_1_name, resource_2_name": {"name": "resource_1_name, resource_2_name", "group": "Ungrouped variables", "definition": "[\"metal\", \"plastic\"]", "description": "", "templateType": "anything", "can_override": false}, "prod_1_name, prod_2_name": {"name": "prod_1_name, prod_2_name", "group": "Ungrouped variables", "definition": "[\"toy\", \"kitchen utensil\"]", "description": "", "templateType": "anything", "can_override": false}, "prod_1_price": {"name": "prod_1_price", "group": "Setup", "definition": "random(1..3#0.1)", "description": "", "templateType": "anything", "can_override": false}, "prod_2_price": {"name": "prod_2_price", "group": "Setup", "definition": "random(1..3#0.1)", "description": "", "templateType": "anything", "can_override": false}, "resource_1_unit, resource_2_unit": {"name": "resource_1_unit, resource_2_unit", "group": "Ungrouped variables", "definition": "[\"kg\", \"kg\"]", "description": "", "templateType": "anything", "can_override": false}, "diagram": {"name": "diagram", "group": "Diagram", "definition": "jessiecode(400,400,[-prod_1_max_production*0.3, prod_2_max_production*1.5, prod_1_max_production*1.5, -prod_2_max_production*0.3],\"\"\"\n l1a = point(0,{max_resource_1/resource_1_per_prod_2}) <>;\n l1b = point({max_resource_1/resource_1_per_prod_1},0) <>;\n l1 = line(l1a,l1b) <>;\n\n l2a = point(0,{max_resource_2/resource_2_per_prod_2}) <>;\n l2b = point({max_resource_2/resource_2_per_prod_1},0) <>;\n l2 = line(l2a,l2b) <>;\n \n oa = point(0,0) <>;\n ob = point(function() {\"\"\"+\"\"\" return oa.X()+1; },function() {\"\"\"+\"\"\" return oa.Y() - {prod_1_price/prod_2_price}; }) <>;\n objective = line(oa,ob) <>;\n\"\"\")", "description": "", "templateType": "anything", "can_override": false}, "prod_1_max_production": {"name": "prod_1_max_production", "group": "Setup", "definition": "min(max_resource_1/resource_1_per_prod_1, max_resource_2/resource_2_per_prod_1)", "description": "", "templateType": "anything", "can_override": false}, "prod_2_max_production": {"name": "prod_2_max_production", "group": "Setup", "definition": "min(max_resource_1/resource_1_per_prod_2, max_resource_2/resource_2_per_prod_2)", "description": "", "templateType": "anything", "can_override": false}, "points_to_consider": {"name": "points_to_consider", "group": "Marking", "definition": "[\n [floor(prod_1_max_production),0],\n [0,floor(prod_2_max_production)]\n] + let([ix,iy],intersection,\n [[floor(ix),floor(iy)], [floor(ix),ceil(iy)], [ceil(ix),floor(iy)]]\n)", "description": "", "templateType": "anything", "can_override": false}, "intersection": {"name": "intersection", "group": "Marking", "definition": "let(\n m, matrix([resource_1_per_prod_1, resource_1_per_prod_2], [resource_2_per_prod_1, resource_2_per_prod_2]),\n d, det(m),\n im, 1/d * matrix([resource_2_per_prod_2, -resource_1_per_prod_2], [-resource_2_per_prod_1, resource_1_per_prod_1]),\n im*vector(max_resource_1, max_resource_2)\n)", "description": "", "templateType": "anything", "can_override": false}, "valid_points": {"name": "valid_points", "group": "Marking", "definition": "filter(\n let([prod_1,prod_2],p,\n resource_1_per_prod_1 * prod_1 + resource_1_per_prod_2 * prod_2 <= max_resource_1\n and\n resource_2_per_prod_1 * prod_1 + resource_2_per_prod_2 * prod_2 <= max_resource_2\n ),\n p,\n points_to_consider\n)\n ", "description": "", "templateType": "anything", "can_override": false}, "revenue": {"name": "revenue", "group": "Marking", "definition": "map(\n prod_1_price * prod_1 + prod_2_price * prod_2,\n [prod_1,prod_2],\n valid_points\n)", "description": "", "templateType": "anything", "can_override": false}, "best_x,best_y": {"name": "best_x,best_y", "group": "Ungrouped variables", "definition": "let(\n i, filter(revenue[i]=top_revenue, i, 0..len(revenue)-1)[0],\n valid_points[i]\n)", "description": "", "templateType": "anything", "can_override": false}, "top_revenue": {"name": "top_revenue", "group": "Marking", "definition": "max(revenue)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["resource_1_name, resource_2_name", "prod_1_name, prod_2_name", "resource_1_unit, resource_2_unit", "best_x,best_y"], "variable_groups": [{"name": "Setup", "variables": ["max_resource_1", "resource_1_per_prod_1", "resource_1_per_prod_2", "resource_2_per_prod_1", "resource_2_per_prod_2", "max_resource_2", "prod_1_price", "prod_2_price", "prod_1_max_production", "prod_2_max_production"]}, {"name": "Diagram", "variables": ["diagram"]}, {"name": "Marking", "variables": ["points_to_consider", "intersection", "valid_points", "revenue", "top_revenue"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "student_prod_1: interpreted_answers[0]\n\nstudent_prod_2: interpreted_answers[1]\n\nstudent_revenue:\n student_prod_1 * prod_1_price + student_prod_2 * prod_2_price\n\nmark:\n correctif(student_revenue >= top_revenue)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

How many of each product should you make, in order to maximise your income? You can type your answer in the boxes below, or move the point on the diagram above.

\n

[[0]] {prod_1_name}

\n

[[1]] {prod_2_name}

\n

", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "Number of {prod_1_name} to make", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "point: diagram[\"p\"]\n\npos: jxg_position(point)\n\njxg_input:\n if(pos[1]=studentNumber, [], [jxg_set_position(point, vector(studentNumber,pos[1]))])\n\njxg_output:\n dpformat(pos[0],0)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "best_x", "maxValue": "best_x", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Number of {prod_2_name} to make", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "point: diagram[\"p\"]\n\npos: jxg_position(point)\n\njxg_input:\n if(pos[1]=studentNumber, [], [jxg_set_position(point, vector(pos[0],studentNumber))])\n\njxg_output:\n dpformat(pos[1],0)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": false, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "best_y", "maxValue": "best_y", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "precisionType": "dp", "precision": 0, "precisionPartialCredit": 0, "precisionMessage": "You have not given your answer to the correct precision.", "strictPrecision": false, "showPrecisionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}], "allowPrinting": true, "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": false, "showresultspage": "never", "navigatemode": "menu", "onleave": {"action": "none", "message": ""}, "preventleave": false, "typeendtoleave": false, "startpassword": "", "allowAttemptDownload": false, "downloadEncryptionKey": ""}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"showactualmark": true, "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0, "intro": "

This exam contains some questions demonstrating features of the JSXGraph extension.

", "end_message": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": []}, "diagnostic": {"knowledge_graph": {"topics": [], "learning_objectives": []}, "script": "diagnosys", "customScript": ""}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": ["jsxgraph"], "custom_part_types": [], "resources": []}