// Numbas version: exam_results_page_options {"name": "JSXGraph interactive Venn diagram", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "JSXGraph interactive Venn diagram", "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": {}, "extensions": ["jsxgraph"], "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", "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/"}]}]}], "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/"}]}