// Numbas version: exam_results_page_options {"name": "Plot Graph", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["selector", "vsh", "hsh", "vsc", "hsc", "yo", "yn", "xo", "xn", "yo0", "yo1", "yo2", "yo3", "yo4", "maxx", "maxy"], "preamble": {"css": "table#values th {\n background: none;\n text-align: center;\n}", "js": "function dragpoint_board() {\nvar 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 var yo3 = scope.variables.yo3.value; \n var yo4 = scope.variables.yo4.value;\n \n var maxx = scope.variables.maxx.value;\n var maxy = scope.variables.maxy.value;\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-maxx,maxy,maxx,-maxy],grid:true});\n $(question.display.html).find('#dragpoint').append(div);\n \n var board = div.board;\n \n \n //create stationary points\n \n var op0 = board.create('point',[1,yo0],{name:'Janaury',fixed:true,size:2,color:'black'});\n var op1 = board.create('point',[2,yo1],{name:'February',fixed:true,size:2,color:'black'});\n var op2 = board.create('point',[3,yo2],{name:'March',fixed:true,size:2,color:'black'});\n var op3 = board.create('point',[4,yo3],{name:'April',fixed:true,size:2,color:'black'});\n var op4 = board.create('point',[5,yo4],{name:'May',fixed:true,size:2,color:'black'});\n \n \n //create draggable points\n //why are there are a cloine under each one?\n var np0 = board.create('point',[1,yo0],{name:'January',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n //var np1 = board.create('point',[2,yo1],{name:'February',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n //var np2 = board.create('point',[3,yo2],{name:'March',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n //var np3 = board.create('point',[4,yo3],{name:'April',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n //var np4 = board.create('point',[5,yo4],{name:'May',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n \n \n \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 = 5;\n //var points = [np0, np1, np2, np3, np4];\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;inew y values after the transformation

", "name": "yn"}, "maxy": {"definition": "12", "templateType": "anything", "group": "Ungrouped variables", "description": "", "name": "maxy"}, "yo0": {"definition": "random(5..12#0.1)", "templateType": "anything", "group": "Ungrouped variables", "description": "", "name": "yo0"}, "xn": {"definition": "map((x-hsh)/hsc,x,xo)", "templateType": "anything", "group": "Ungrouped variables", "description": "

new transformed x values

", "name": "xn"}, "hsc": {"definition": "if(selector='hsc',random(-2,-1,-0.5,0.5,2),1)", "templateType": "anything", "group": "Ungrouped variables", "description": "", "name": "hsc"}, "yo": {"definition": "repeat(random(-5..5),5)", "templateType": "anything", "group": "Ungrouped variables", "description": "

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

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

horizontal shift

", "name": "hsh"}, "yo3": {"definition": "random(5..12#0.1 except yo0 except yo1 except yo2)", "templateType": "anything", "group": "Ungrouped variables", "description": "", "name": "yo3"}, "vsc": {"definition": "if(selector='vsc',random(-2,-1,-0.5,0.5,2),1)", "templateType": "anything", "group": "Ungrouped variables", "description": "", "name": "vsc"}, "xo": {"definition": "list(-2..2)", "templateType": "anything", "group": "Ungrouped variables", "description": "

original x values

", "name": "xo"}, "yo4": {"definition": "random(5..12#0.1 except yo0 except yo1 except yo2 except yo3)", "templateType": "anything", "group": "Ungrouped variables", "description": "", "name": "yo4"}, "vsh": {"definition": "if(selector='vsh',random(-3..3#0.5 except 0),0)\n", "templateType": "anything", "group": "Ungrouped variables", "description": "

vertical shift

", "name": "vsh"}}, "statement": "", "advice": "", "rulesets": {"std": ["all", "fractionNumbers"]}, "extensions": ["jsxgraph"], "parts": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "metadata": {"licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International", "description": "

of a random cubic spline

"}, "variable_groups": [], "functions": {}, "type": "question", "contributors": [{"name": "Gareth Woods", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/978/"}]}]}], "contributors": [{"name": "Gareth Woods", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/978/"}]}