// Numbas version: exam_results_page_options {"name": "Plotting a point on a graph", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"dragpointafter": {"parameters": [], "type": "html", "language": "javascript", "definition": "// set up the board\nvar div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-11,11,11,-11],grid:true,withLabel:true});\n\nvar board = div.board;\n\nvar x = Numbas.jme.unwrapValue(scope.variables.a);\nvar y = Numbas.jme.unwrapValue(scope.variables.b);\n\nvar a = board.create('point',[x,y],{size:5});\na.setProperty({fixed:true});\nvar b = board.create('point',[10,0],{size:-1,name:'x'});\nb.setProperty({fixed:true});\nvar c = board.create('point',[0,10],{size:-1,name:'y'});\nc.setProperty({fixed:true});\n\nreturn div;"}, "dragpoint": {"parameters": [], "type": "html", "language": "javascript", "definition": "// set up the board\nvar div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-11,11,11,-11],grid:true,labels:true});\nvar board = div.board;\n\nvar x = Numbas.jme.unwrapValue(scope.variables.a);\nvar y = Numbas.jme.unwrapValue(scope.variables.b);\n\nvar a = board.create('point',[0,0],{size:5});\nvar b = board.create('point',[10,0],{size:-1,name:'x'});\nb.setProperty({fixed:true});\nvar c = board.create('point',[0,10],{size:-1,name:'y'});\nc.setProperty({fixed:true});\na.on('drag',function(){\n var x = Numbas.math.niceNumber(a.X());\n var y = Numbas.math.niceNumber(a.Y());\n Numbas.exam.currentQuestion.parts[0].gaps[0].display.studentAnswer(a.X());\n Numbas.exam.currentQuestion.parts[0].gaps[1].display.studentAnswer(y); \n});\n\nquestion.signals.on('HTMLAttached',function(e) {\n ko.computed(function(){ \nvar x = parseFloat(question.parts[0].gaps[0].display.studentAnswer());\nvar y = parseFloat(question.parts[0].gaps[1].display.studentAnswer());\nif(!(isNaN(x) || isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n a.moveTo([x,y],100);\n}\n });\n a.triggerEventHandlers('drag');\n});\n\nreturn div;\n\n\n"}}, "parts": [{"showCorrectAnswer": true, "type": "gapfill", "prompt": "

Place the point A at $(\\var{a},\\var{b})$ by dragging it.

\n

To be marked correct, you have to get the x and y coordinates within 0.1 of the asked for values.

\n

{dragpoint()}

\n

", "gaps": [{"minValue": "a-0.1", "showCorrectAnswer": true, "type": "numberentry", "mustBeReduced": false, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "maxValue": "a+0.1", "allowFractions": false, "customMarkingAlgorithm": "", "scripts": {}, "unitTests": [], "marks": 1, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "mustBeReducedPC": 0}, {"minValue": "b-0.1", "showCorrectAnswer": true, "type": "numberentry", "mustBeReduced": false, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "maxValue": "b+0.1", "allowFractions": false, "customMarkingAlgorithm": "", "scripts": {}, "unitTests": [], "marks": 1, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "mustBeReducedPC": 0}], "variableReplacements": [], "showFeedbackIcon": true, "customMarkingAlgorithm": "", "scripts": {}, "unitTests": [], "sortAnswers": false, "marks": 0, "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst"}], "variables": {"b": {"group": "Ungrouped variables", "templateType": "anything", "name": "b", "definition": "random(-10..10)", "description": ""}, "a": {"group": "Ungrouped variables", "templateType": "anything", "name": "a", "definition": "random(-10..10)", "description": ""}}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

This question allows you to practice plotting points on graphs.

"}, "advice": "

The correct position of the point A is shown in the graph below.

\n

Its $x$-coordinate is $\\var{a}$, so it is this distance from the origin in the horizontal direction (positive is to the right and negative is to the left).

\n

Its $y$-coordinate is $\\var{b}$, so it is this distance from the origin in the vertical direction (positive is upwards and negative is downwards).

\n

{dragpointafter()}

", "extensions": ["jsxgraph"], "statement": "", "ungrouped_variables": ["a", "b"], "name": "Plotting a point on a graph", "preamble": {"css": "", "js": ""}, "tags": [], "variable_groups": [], "rulesets": {}, "variablesTest": {"maxRuns": 100, "condition": "a<>0 or b<>0"}, "type": "question", "contributors": [{"name": "Anthony Brown", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/799/"}]}]}], "contributors": [{"name": "Anthony Brown", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/799/"}]}