// Numbas version: finer_feedback_settings {"name": "3 point triangle TestBed", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"parts": [{"gaps": [{"correctAnswerFraction": false, "minValue": "10", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "maxValue": "30", "variableReplacementStrategy": "originalfirst", "type": "numberentry", "allowFractions": false, "correctAnswerStyle": "plain", "scripts": {}, "marks": 1, "showFeedbackIcon": true, "variableReplacements": [], "mustBeReducedPC": 0, "mustBeReduced": false}, {"correctAnswerFraction": false, "minValue": "30", "strictPrecision": true, "showPrecisionHint": true, "precisionPartialCredit": 0, "showCorrectAnswer": true, "maxValue": "40", "precision": 0, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "allowFractions": false, "correctAnswerStyle": "plain", "scripts": {}, "marks": 1, "precisionType": "dp", "showFeedbackIcon": true, "variableReplacements": [], "mustBeReducedPC": 0, "mustBeReduced": false, "precisionMessage": "You have not given your answer to the correct precision."}], "variableReplacements": [], "marks": 0, "scripts": {}, "showCorrectAnswer": true, "type": "gapfill", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "prompt": "
{plotgraph(x1,x2,y1,y2,units)}
\nWhat is length AB?
\n[[0]] {units}
\nWhat is length BC?
\n[[1]] {units}
"}], "rulesets": {}, "advice": "", "variable_groups": [{"variables": [], "name": "Unnamed group"}], "statement": "Referring to the line below.
", "ungrouped_variables": ["x1", "x2", "y1", "y2", "unitList", "unitIndex", "units"], "metadata": {"description": "Draws a triangle based on 3 input points. Calculates length, area, perimeter, heights and internal angles
", "licence": "Creative Commons Attribution 4.0 International"}, "name": "3 point triangle TestBed", "functions": {"plotgraph": {"type": "html", "language": "javascript", "definition": "// This functions plots two dimensioned lines \n// Max and min x and y values for the axis.\nvar x_min = 0;\nvar x_max = 50;\nvar y_min = 0;\nvar y_max = 50;\n//TODO check whether these are necessary for larger graphs\nvar offset = 1;\nvar scale = 1;\nvar scaleOffset = offset*scale;\n\n//Browser compatibility\nJXG.Options.text.display = 'internal';\n//Use MathJax for LaTeX display\nJXG.Options.text.useMathJax = true;\n\n// Make the JSXGraph board.\nvar div = Numbas.extensions.jsxgraph.makeBoard(\n '400px',\n '400px',\n {\n boundingBox: [x_min,y_max,x_max,y_min],\n axis: false,\n }\n);\n\n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\nvar board = div.board; \n\n//Draw three points\nvar A = board.create('point', [5, 5], \n {size:0, fixed:true,\n label:{offset: [-10,-10]}});\nvar B = board.create('point', [x1, y1],\n {size:2, fixed:false, face:'+',\n label:{offset: [0,10]}});\nvar C = board.create('point', [x2, y2],\n {size:2, fixed:false, face:'+',\n label:{offset: [10,0]}});\n\n//Draw a line between them\nvar AB = board.create('line',[A,B],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar BC = board.create('line',[B,C],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar AC = board.create('line',[A,C],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\n\n//Draw angle and label\nvar ABC = board.create('nonreflexangle', [A,B,C], {type:'sector', orthoType:'square', orthoSensitivity:0.4, radius:2});\nvar ABCLabel = ABC.label.setText(function () {\n var angle = 180.0 * ABC.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return +angle.toFixed(1) + '\\u00B0';\n } else {\n return '';\n }\n});\nABCLabel.setAttribute({anchorX:'middle'});\n\nvar BCA = board.create('nonreflexangle', [B,C,A], {type:'sector', orthoType:'square', orthoSensitivity:0.4, radius:2});\nvar BCALabel = BCA.label.setText(function () {\n var angle = 180.0 * BCA.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return +angle.toFixed(1) + '\\u00B0';\n } else {\n return '';\n }\n});\nBCALabel.setAttribute({anchorX:'middle'});\n\nvar CAB = board.create('nonreflexangle', [C,A,B], {type:'sector', orthoType:'square', orthoSensitivity:0.4, radius:2});\nvar CABLabel = CAB.label.setText(function () {\n var angle = 180.0 * CAB.Value() / Math.PI;\n if ((angle > 90.4) || (angle < 89.6)) {\n return +angle.toFixed(1) + '\\u00B0';\n } else {\n return '';\n }\n});\nCABLabel.setAttribute({anchorX:'middle'});\n\n//Dummy text for testing variables\ntempText = board.create('text',[25,45,\n function () {return 'ABC = ' +(180.0*ABC.Value()/Math.PI).toFixed(2)+ ' \\u00B0'}]);\n\n\n//Calculate midpoint\n//TODO Check whether these are useful or not\nvar midABx = (A.X() + B.X())/2;\nvar midABy = (A.Y() + B.Y())/2;\nvar midBCx = (B.X() + C.X())/2;\nvar midBCy = (B.Y() + C.Y())/2;\n\n//Set up dimension labels to be properly aligned\ntextAB = board.create('text', \n [function () {return (A.X() + B.X())/2},\n function () {return ((A.Y() + B.Y())/2)+scaleOffset},\n function () {return +A.Dist(B).toFixed(1) + ' ' +units}],\n {fontSize:15, anchorX:'middle'});\n\ntextBC = board.create('text', \n [function () {return (B.X() + C.X())/2},\n function () {return ((B.Y() + C.Y())/2)+scaleOffset},\n function () {return +B.Dist(C).toFixed(1) + ' ' +units}],\n {fontSize:15, anchorX:'middle'});\n\ntextAC = board.create('text', \n [function () {return (A.X() + C.X())/2},\n function () {return ((A.Y() + C.Y())/2)+scaleOffset},\n function () {return +A.Dist(C).toFixed(1) + ' ' +units}],\n {fontSize:15, anchorX:'middle'});\n\nvar tABRot = board.create('transform', \n [function () {return AB.getAngle()}, \n function () {return (A.X() + B.X())/2}, \n function () {return (A.Y() + B.Y())/2}],\n {type:'rotate'});\n\nvar tBCRot = board.create('transform', \n [function () {return BC.getAngle()}, \n function () {return (B.X() + C.X())/2}, \n function () {return (B.Y() + C.Y())/2}],\n {type:'rotate'});\n\nvar tACRot = board.create('transform', \n [function () {return AC.getAngle()}, \n function () {return (A.X() + C.X())/2}, \n function () {return (A.Y() + C.Y())/2}],\n {type:'rotate'});\n\n//Perform text rotations and update\ntABRot.bindTo(textAB);\ntBCRot.bindTo(textBC); \ntACRot.bindTo(textAC);\nboard.update();\n\nreturn div;", "parameters": [["x1", "number"], ["x2", "number"], ["y1", "number"], ["y2", "number"], ["units", "string"]]}}, "variables": {"units": {"group": "Ungrouped variables", "description": "", "definition": "unitList[unitIndex]", "name": "units", "templateType": "anything"}, "unitIndex": {"group": "Ungrouped variables", "description": "", "definition": "random(0..3)", "name": "unitIndex", "templateType": "anything"}, "x2": {"group": "Ungrouped variables", "description": "", "definition": "random(25..45 except x1)", "name": "x2", "templateType": "anything"}, "x1": {"group": "Ungrouped variables", "description": "", "definition": "random(5..20)", "name": "x1", "templateType": "anything"}, "unitList": {"group": "Ungrouped variables", "description": "Units that are to be used for the question.
", "definition": "[ \"mm\", \"cm\", \"m\", \"km\" ]", "name": "unitList", "templateType": "list of strings"}, "y1": {"group": "Ungrouped variables", "description": "", "definition": "random(20..45)", "name": "y1", "templateType": "anything"}, "y2": {"group": "Ungrouped variables", "description": "", "definition": "random(0..45 except y1)", "name": "y2", "templateType": "anything"}}, "preamble": {"js": "", "css": ""}, "extensions": ["jsxgraph"], "variablesTest": {"condition": "", "maxRuns": 100}, "tags": [], "type": "question", "contributors": [{"name": "David Wishart", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1461/"}]}]}], "contributors": [{"name": "David Wishart", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1461/"}]}