// Numbas version: exam_results_page_options {"name": "Testing JSXGraph for a single edge", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variablesTest": {"maxRuns": 100, "condition": "a<>b"}, "tags": [], "variables": {"b": {"definition": "random(0.1..1#0.1)", "group": "Ungrouped variables", "description": "", "templateType": "randrange", "name": "b"}, "a": {"definition": "random(0.1..1#0.1)", "group": "Ungrouped variables", "description": "", "templateType": "randrange", "name": "a"}}, "statement": "

{createNetwork()}

\n

Goal: Make a diagram so students can click on the edges in a network diagram and create a tree (or something like that).

", "rulesets": {}, "advice": "", "name": "Testing JSXGraph for a single edge", "variable_groups": [], "parts": [{"variableReplacements": [], "prompt": "

Selected the edge AB so it is a solid line if you want.

\n

", "showFeedbackIcon": true, "marks": 0, "showCorrectAnswer": true, "type": "gapfill", "variableReplacementStrategy": "originalfirst", "gaps": [{"mustBeReducedPC": 0, "showFeedbackIcon": true, "minValue": "1", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "scripts": {"mark": {"order": "instead", "script": "console.log('Marking');\nconsole.log(question.parts[0].gaps[0].selected);\nthis.setCredit(0.5,\"Half Work!\");"}, "validate": {"order": "instead", "script": "console.log('Validating');\nreturn true;"}}, "allowFractions": false, "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": false, "maxValue": "1", "marks": "1", "type": "numberentry", "mustBeReduced": false}], "scripts": {}}], "metadata": {"licence": "None specified", "description": ""}, "ungrouped_variables": ["a", "b"], "preamble": {"css": "", "js": ""}, "extensions": ["jsxgraph"], "functions": {"createNetwork": {"type": "html", "language": "javascript", "parameters": [], "definition": "// This function creates the board and sets it up, then returns an\n// HTML div tag containing the board.\n \n// The line is described by the equation \n// y = a*x + b\n\n// This function takes as its parameters the coefficients a and b,\n// and the coordinates (x2,y2) of a point on the line.\n\n// First, make the JSXGraph board.\n// The function provided by the JSXGraph extension wraps the board up in \n// a div tag so that it's easier to embed in the page.\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','266px',\n{boundingBox: [-3,2,3,-2],\n axis: false,\n showNavigation: false,\n grid: true\n});\n\n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\n\nquestion.parts[0].gaps[0].display.studentAnswer(0);\n\nfunction changelinestyle(line){\n if(line.selected==true){\n line.selected=false;\n line.setAttribute({dash:1});\n // question.parts[0].gaps[0].display.studentAnswer(0);\n question.parts[0].gaps[0].selected=false;\n console.log(question.parts[0]);\n } else {\n line.selected=true ;\n line.setAttribute({dash:0});\n // question.parts[0].gaps[0].display.studentAnswer(1);\n question.parts[0].gaps[0].selected=true;\n console.log(question.parts[0]);\n }\n \n };\n\nvar board = div.board; \n\nvar pointa=board.create('point',[-2.0, 0.0], {face:'o', size:3, fixed:true},{name:\"a\"}); \nvar pointb=board.create('point',[-1.0, 1.0], {face:'o', size:3, fixed:true,name:\"b\"}); \n\nvar lineab=board.create('line',[pointa,pointb],{straightFirst:false,straightLast:false,strokeWidth:3,dash:0})\nlineab.selected=true;\n\nlineab.on('down',function(){changelinestyle(lineab)});\n\n\n// pointa.on('down',function(){board.create('point',[2,2], {face:'o', size:1})})\n\nreturn div;"}}, "type": "question", "contributors": [{"name": "Joshua Capel", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1479/"}]}]}], "contributors": [{"name": "Joshua Capel", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1479/"}]}