// Numbas version: exam_results_page_options {"name": "Anthony's copy of Graphs: Two random transformations", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"advice": "", "tags": [], "variables": {"yo1": {"name": "yo1", "templateType": "anything", "group": "Ungrouped variables", "definition": "yo[1]", "description": ""}, "selector": {"name": "selector", "templateType": "anything", "group": "Ungrouped variables", "definition": "shuffle([0,0,1,1])", "description": "

order is ['vsh','hsh','vsc','hsc'] 1 is on 0 is off

"}, "yo0": {"name": "yo0", "templateType": "anything", "group": "Ungrouped variables", "definition": "yo[0]", "description": ""}, "xn": {"name": "xn", "templateType": "anything", "group": "Ungrouped variables", "definition": "map((x-hsh)/hsc,x,xo)", "description": "

new transformed x values

"}, "vsh": {"name": "vsh", "templateType": "anything", "group": "Ungrouped variables", "definition": "if(selector[0]=1,random(-3..3#0.5 except 0),0)\n", "description": "

vertical shift

"}, "yo2": {"name": "yo2", "templateType": "anything", "group": "Ungrouped variables", "definition": "yo[2]", "description": ""}, "xo": {"name": "xo", "templateType": "anything", "group": "Ungrouped variables", "definition": "list(0..2)", "description": "

`original x values

"}, "yo": {"name": "yo", "templateType": "anything", "group": "Ungrouped variables", "definition": "repeat(random(-5..5),3)", "description": "

the (random) original y values which relate to the x values

"}, "hsh": {"name": "hsh", "templateType": "anything", "group": "Ungrouped variables", "definition": "if(selector[1]=1,random(-3..3 except 0),0)", "description": "

horizontal shift

"}, "vsc": {"name": "vsc", "templateType": "anything", "group": "Ungrouped variables", "definition": "if(selector[2]=1,random(-2,-1,-0.5,0.5,2),1)", "description": ""}, "hsc": {"name": "hsc", "templateType": "anything", "group": "Ungrouped variables", "definition": "if(selector[3]=1,random(-2,-1,-0.5,0.5,2),1)", "description": ""}, "recip": {"name": "recip", "templateType": "anything", "group": "Ungrouped variables", "definition": "1/hsc", "description": ""}, "yn": {"name": "yn", "templateType": "anything", "group": "Ungrouped variables", "definition": "map(vsc*y+vsh,y,yo)", "description": ""}}, "ungrouped_variables": ["selector", "vsh", "hsh", "vsc", "hsc", "yo", "yn", "xo", "xn", "yo0", "yo1", "yo2", "recip"], "statement": "

The graph of a function $y=f(x)$ is shown below. .

", "variable_groups": [], "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"description": "

Horizontal and vertical shifts and scales of a random cubic spline

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "preamble": {"css": "table#values th {\n background: none;\n text-align: center;\n}", "js": "function dragpoint_board() {\n var scope = question.scope;\n \n // var a = scope.variables.a.value;\n// var c = scope.variables.c.value;\n\n var yo0 = scope.variables.yo0.value;\n var yo1 = scope.variables.yo1.value;\n var yo2 = scope.variables.yo2.value;\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-11,11,11,-11],grid:true,labels:true});\n $(question.display.html).find('#dragpoint').append(div);\n \n var board = div.board;\n \n \n //create draggable points\n\n var np0 = board.create('point',[-5,5],{name:'A',size:5});\n var np1 = board.create('point',[0,0],{name:'B',size:5});\n var np2 = board.create('point',[5,5],{name:'C',size:5}); \n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 3;\n var points = [np0, np1, np2];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n // var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n // var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n // var point = points[i] = board.create(\n // 'point',\n // [i-(num_points-1)/2,0],\n // {\n // name:'',\n // size:2,\n // snapSizeY: 0.25, // the point will snap to y-coordinates which are multiples of 0.1\n // snapSizeX: 0.25,\n // snapToGrid: true\n // }\n // );\n \n var point = points[i];\n \n var x=point[0];\n var y=point[1];\n \n // the contents of the input box for this point\n var xstudentAnswer = question.parts[0].gaps[2*i].display.studentAnswer;\n var ystudentAnswer = question.parts[0].gaps[2*i+1].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n x = evaluate(xstudentAnswer());\n y = evaluate(ystudentAnswer());\n if(!(isNaN(x)) && !(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var x = Numbas.math.niceNumber(point.X());\n var y = Numbas.math.niceNumber(point.Y());\n xstudentAnswer(x);\n ystudentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;i\n

The point $A$ was $(-2,\\var{yo0})$ but it is now $\\big($[[0]],[[1]]$\\big)$.
The point $B$ was $(-1,\\var{yo1})$ but it is now $\\big($[[2]],[[3]]$\\big)$.
The point $C$ was $(0,\\var{yo2})$ but it is now $\\big($[[4]],[[5]]$\\big)$.

", "showFeedbackIcon": true, "scripts": {}}], "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/"}]}