// Numbas version: exam_results_page_options {"name": "Right Angle triangle", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "extensions": ["jsxgraph"], "ungrouped_variables": ["x1", "x2", "y1", "y2", "unitList", "unitIndex", "units", "a", "min_angle", "max_angle", "b_max", "b_min", "b", "c"], "variablesTest": {"maxRuns": 100, "condition": ""}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Draws a triangle based on 3 input points. Calculates length, area, perimeter, heights and internal angles

"}, "functions": {"plotgraph": {"parameters": [["units", "string"], ["a", "number"], ["b", "number"], ["c", "number"]], "definition": "// This functions plots a right angled triangle based on two lengths\n\n//Set text and graph offsets to appear uniform\nvar yOffset = Math.ceil(a/10);\nvar xOffset = Math.ceil(a+2*yOffset-c/2)\n//Consider removing scale once all adjusted correctly\nvar offset = 1;\nvar textHeight =15;\nvar scale = yOffset/2;\nvar scaleOffset = offset*scale;\nvar scaleText = textHeight*scale;\n// This functions plots two dimensioned lines \n// Max and min x and y values for the axis.\nvar x_min = 0;\nvar x_max = 2*(a+2*yOffset);\nvar y_min = 0;\nvar y_max = a+2*yOffset;\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 '800px',\n '400px',\n {\n boundingBox: [0,y_max,x_max,0],\n//Change to false after testing\n axis: true,\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', [xOffset, yOffset], \n {size:0, fixed:true,\n label:{offset: [-10,-10]}});\nvar B = board.create('point', [xOffset, (a+yOffset)],\n {size:0, fixed:true,\n label:{offset: [0,10]}});\nvar C = board.create('point', [(c+xOffset), yOffset],\n//Make fixed:true after testing\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\n/*\nUse din other versions of this questions\nvar ABC = board.create('nonreflexangle', [A,B,C], {type:'sector', orthoType:'square', orthoSensitivity:0.4, \nradius:function() { return scale;}\n });\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*/\n\n/*\nUsed in other versions of this question\nvar BCA = board.create('nonreflexangle', [B,C,A], {type:'sector', orthoType:'square', orthoSensitivity:0.4, \nradius:function() { return scale;}\n});\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*/\n\nvar CAB = board.create('nonreflexangle', [C,A,B], {type:'sector', orthoType:'square', orthoSensitivity:0.4, \nradius:function() { return scale;} \n});\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, remove after testing\ntempText = board.create('text',[(2*a),(a+yOffset),\n// function () {return 'ABC = ' +(180.0*ABC.Value()/Math.PI).toFixed(2)+ ' degreeSymbol'}]);\nfunction () {return 'yOffset is ' + yOffset}]);\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\n//Hide this for final version\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\n//Hide this for final version\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); \n//Hide this for final version\ntACRot.bindTo(textAC);\nboard.update();\n\nreturn div;", "type": "html", "language": "javascript"}}, "preamble": {"css": "", "js": ""}, "variables": {"a": {"name": "a", "definition": "random(5..50)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "min_angle": {"name": "min_angle", "definition": "29\n\n", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "b": {"name": "b", "definition": "random(b_min..B_max)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "unitIndex": {"name": "unitIndex", "definition": "random(0..3)\n", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "x1": {"name": "x1", "definition": "random(5..20)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "max_angle": {"name": "max_angle", "definition": "61", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "c": {"name": "c", "definition": "precround(sqrt(b^2-a^2),2)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "unitList": {"name": "unitList", "definition": "[ \"mm\", \"cm\", \"m\", \"km\" ]", "group": "Ungrouped variables", "templateType": "list of strings", "description": "

Units that are to be used for the question.

"}, "x2": {"name": "x2", "definition": "random(25..45 except x1)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "b_min": {"name": "b_min", "definition": "floor(a/(cos(radians(min_angle))))", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "y1": {"name": "y1", "definition": "random(20..45)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "b_max": {"name": "b_max", "definition": "ceil(a/(cos(radians(max_angle))))", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "units": {"name": "units", "definition": "'mm'", "group": "Ungrouped variables", "templateType": "anything", "description": ""}, "y2": {"name": "y2", "definition": "random(0..45 except y1)", "group": "Ungrouped variables", "templateType": "anything", "description": ""}}, "parts": [{"type": "gapfill", "variableReplacementStrategy": "originalfirst", "gaps": [{"precisionMessage": "You have not given your answer to the correct precision.", "precision": "2", "type": "numberentry", "allowFractions": false, "precisionType": "dp", "showFeedbackIcon": true, "scripts": {}, "correctAnswerStyle": "plain", "notationStyles": ["plain", "en", "si-en"], "showCorrectAnswer": true, "showPrecisionHint": false, "variableReplacementStrategy": "originalfirst", "mustBeReducedPC": 0, "precisionPartialCredit": 0, "strictPrecision": false, "marks": 1, "minValue": "0.99*{c}", "maxValue": "1.01*{c}", "variableReplacements": [], "correctAnswerFraction": false, "mustBeReduced": false}], "scripts": {}, "variableReplacements": [], "showFeedbackIcon": true, "showCorrectAnswer": true, "prompt": "

{plotgraph(units,a,b,c)}

\n

What is the length of side AC?

\n

Please give answer to 2 decimal places

\n

AC = [[0]] {units}

", "marks": 0}], "variable_groups": [{"name": "Unnamed group", "variables": []}], "name": "Right Angle triangle", "rulesets": {}, "statement": "

Referring to the line below.

", "advice": "

Use pythagoras theorem to find the answer.

", "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/"}]}