// Numbas version: exam_results_page_options {"name": "Testing JSXGraph for a network diagram", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"advice": "", "statement": "
Goal: Make a diagram so students can click on the edges in a network diagram and create a tree.
", "metadata": {"licence": "None specified", "description": ""}, "rulesets": {}, "ungrouped_variables": ["a", "b"], "variablesTest": {"maxRuns": 100, "condition": "a<>b"}, "preamble": {"js": "", "css": ""}, "name": "Testing JSXGraph for a network diagram", "tags": [], "parts": [{"showCorrectAnswer": true, "marks": 0, "gaps": [{"showFeedbackIcon": true, "marks": 1, "variableReplacements": [], "type": "numberentry", "maxValue": "1", "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "minValue": "1", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "mustBeReduced": false, "correctAnswerFraction": false, "scripts": {"validate": {"order": "instead", "script": "console.log('Validating');\nreturn true;"}, "mark": {"order": "instead", "script": "console.log('Marking');\n\nvar selectedEdges=[]\n\nvar totalVertices=Object.keys(this.PointDict).length;\nconsole.log(\"There are \"+totalVertices+\" in this graph\");\n\nfor (i=0;i{createNetwork()}
\nThis will be the information only part.
", "showFeedbackIcon": true}], "variables": {"b": {"definition": "random(0.1..1#0.1)", "name": "b", "description": "", "templateType": "randrange", "group": "Ungrouped variables"}, "a": {"definition": "random(0.1..1#0.1)", "name": "a", "description": "", "templateType": "randrange", "group": "Ungrouped variables"}}, "variable_groups": [], "functions": {"createNetwork": {"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\nvar blueColor='#0000ff';\nvar grayColor='#9b9b9b';\n\nvar PointStyle={face:'o', size:5, fixed:true};\nvar LineStyle={straightFirst:false,straightLast:false,strokeWidth:5,dash:0,strokeColor:blueColor};\n\n//Setting .studentAnswer(0) prevents grading errors due to \n//undefined .studentAnswer\nquestion.parts[0].gaps[0].display.studentAnswer(0);\n\n//Create a function for changing the line styles based on state\nfunction changelinestyle(){\n// console.log(this);\n if(this.selected==true){\n this.selected=false;\n this.setAttribute({dash:1,strokeColor:grayColor});\n } else {\n this.selected=true ;\n this.setAttribute({dash:0,strokeColor:blueColor});\n }\n};\n\nvar board = div.board; \n\nvar PointDict={\"A\":0\n ,\"B\":1\n ,\"C\":2\n ,\"D\":3\n ,\"E\":4\n ,\"F\":5\n ,\"G\":6\n ,\"H\":7\n ,\"I\":8};\n\nvar PointInfoArray=[[[-2.0, 0.0],\"A\"]\n ,[[-1.0, 1.0],\"B\"]\n ,[[ 0.0, 0.0],\"C\"]\n ,[[ 1.0, 1.0],\"D\"]\n ,[[ 2.0, 0.0],\"E\"]\n ,[[ 1.0, .33],\"F\"]\n ,[[ 1.0,-.33],\"G\"]\n ,[[-1.0,-1.0],\"H\"]\n ,[[ 1.0,-1.0],\"I\"]];\n \nPointArray=[];\n\nfor (i=0;i