// Numbas version: finer_feedback_settings {"name": "Right Triangle", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["unitList", "units", "a", "angleB", "angleC", "angleA", "asinA", "b", "c"], "name": "Right Triangle", "statement": "
Referring to the triangle below.
", "variables": {"c": {"description": "", "definition": "asinA*sin(radians(angleC))", "group": "Ungrouped variables", "name": "c", "templateType": "anything"}, "angleC": {"description": "", "definition": "random(30..60 except angleB)", "group": "Ungrouped variables", "name": "angleC", "templateType": "anything"}, "units": {"description": "", "definition": "random(unitList)", "group": "Ungrouped variables", "name": "units", "templateType": "anything"}, "angleA": {"description": "", "definition": "180-(angleB+angleC)", "group": "Ungrouped variables", "name": "angleA", "templateType": "anything"}, "unitList": {"description": "Units that are to be used for the question.
", "definition": "[ \"mm\", \"cm\", \"m\", \"km\" ]", "group": "Ungrouped variables", "name": "unitList", "templateType": "list of strings"}, "a": {"description": "", "definition": "random(5..50)", "group": "Ungrouped variables", "name": "a", "templateType": "anything"}, "b": {"description": "", "definition": "asinA*sin(radians(angleB))", "group": "Ungrouped variables", "name": "b", "templateType": "anything"}, "asinA": {"description": "", "definition": "a/(sin(radians(angleA)))\n", "group": "Ungrouped variables", "name": "asinA", "templateType": "anything"}, "angleB": {"description": "angle
", "definition": "random(30..60)", "group": "Ungrouped variables", "name": "angleB", "templateType": "anything"}}, "tags": [], "extensions": ["jsxgraph"], "preamble": {"css": "", "js": ""}, "variable_groups": [{"name": "Unnamed group", "variables": []}], "parts": [{"showCorrectAnswer": true, "variableReplacements": [], "gaps": [{"strictPrecision": false, "showPrecisionHint": false, "mustBeReduced": false, "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "marks": "3", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "maxValue": "{c}", "correctAnswerStyle": "plain", "variableReplacements": [], "precision": "2", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "precisionPartialCredit": "50", "mustBeReducedPC": 0, "scripts": {}, "correctAnswerFraction": false, "showCorrectAnswer": true, "minValue": "{c}", "precisionType": "dp"}, {"strictPrecision": false, "showPrecisionHint": false, "mustBeReduced": false, "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "marks": "3", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "maxValue": "{b}", "correctAnswerStyle": "plain", "variableReplacements": [], "precision": "2", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "precisionPartialCredit": "50", "mustBeReducedPC": 0, "scripts": {}, "correctAnswerFraction": false, "showCorrectAnswer": true, "minValue": "{b}", "precisionType": "dp"}, {"strictPrecision": false, "showPrecisionHint": false, "mustBeReduced": false, "precisionMessage": "You have not given your answer to the correct precision.", "allowFractions": false, "marks": "2", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "maxValue": "{angleC}", "correctAnswerStyle": "plain", "variableReplacements": [], "precision": 0, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "precisionPartialCredit": "50", "mustBeReducedPC": 0, "scripts": {}, "correctAnswerFraction": false, "showCorrectAnswer": true, "minValue": "{angleC}", "precisionType": "dp"}], "prompt": "{plotgraph(units,a,b,c,angleA,angleB,angleC)}
\nWhat is the length of sides AB and AC?
\nPlease give answer to 2 decimal places
\nAB = [[0]] {units}
\nAC = [[1]] {units}
\nWhat is angle C to the nearest degree?
\nC = [[2]] $^{\\circ}$
", "variableReplacementStrategy": "originalfirst", "marks": 0, "type": "gapfill", "showFeedbackIcon": true, "scripts": {}}], "variablesTest": {"maxRuns": 100, "condition": "angleA<>90"}, "advice": "Use the sine rule to calculate the sides and the properties of a triangle to find the missing angle.
", "functions": {"plotgraph": {"definition": "// This functions plots a triangle based on two angles and a length\n\n//Function ot convert angles to radians\nfunction toRadians (angle) {\n return angle * (Math.PI / 180);\n}\n\n//Calculate height of triangle\nvar h = b*Math.sin(toRadians(angleC))\n\n//Set text and graph offsets to appear uniform\nvar xOffset = Math.ceil(a/10)\nvar yOffset = Math.ceil(a/2+xOffset-h/2)\n//Consider removing scale once all adjusted correctly\nvar offset = 1;\nvar textHeight =15;\nvar scale = xOffset/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 = a+2*xOffset;\nvar y_min = 0;\nvar y_max = a+2*xOffset;\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 '500px',\n '500px',\n {\n boundingBox: [0,y_max,x_max,0],\n//Change to false after testing\n axis: false,\n }\n);\n\n// div.board is the object created by JSXGraph, which you use to manipulate elements\nvar board = div.board; \n\n/*\n//Dummy text for testing variables, remove after testing\ntempText = board.create('text',[(xOffset),(h+yOffset),\nfunction () {return 'A is ' + angleA + ' B is ' + angleB + ' C is ' + angleC}]);\ntempText2 = board.create('text',[(xOffset),(yOffset/2),\nfunction () {return 'a is ' + a + ' b is ' + b + ' c is ' + c}]);\n*/\n\n//Draw three points \nvar pA = board.create('point', [(b*Math.cos(toRadians(angleC))+xOffset), (b*Math.sin(toRadians(angleC))+yOffset)], \n//Make fixed:true after testing\n {size:0, fixed:true,\n label:{offset: [0,10]}});\nvar pB = board.create('point', [(a+xOffset), (yOffset)],\n {size:0, fixed:true,\n label:{offset: [10,-10]}});\nvar pC = board.create('point', [(xOffset), (yOffset)],\n {size:0, fixed:true,\n label:{offset: [-10,-10]}});\n\n\n//Draw a line between them\nvar AB = board.create('line',[pA,pB],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar BC = board.create('line',[pC,pB],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\nvar AC = board.create('line',[pC,pA],{fixed:false, straightFirst:false, straightLast:false, strokeWidth: 1});\n\n//Draw angle and label\n//Used in other versions of this questions\nvar ABC = board.create('nonreflexangle', [pA,pB,pC], {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(0) + '\\u00B0';\n } else {\n return '';\n }\n});\nABCLabel.setAttribute({anchorX:'middle'});\n\nvar CAB = board.create('nonreflexangle', [pC,pA,pB], {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(0) + '\\u00B0';\n } else {\n return '';\n }\n});\nCABLabel.setAttribute({anchorX:'middle'});\n\n/*\nvar BCA = board.create('nonreflexangle', [pB,pC,pA], {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(0) + '\\u00B0';\n } else {\n return '';\n }\n});\nCABLabel.setAttribute({anchorX:'middle'});\n*/\n\n//Not used in this version\n/*\ntextAB = board.create('text', \n [function () {return (pA.X() + pB.X())/2},\n function () {return ((pA.Y() + pB.Y())/2)+(scaleOffset/2)},\n function () {return +pA.Dist(pB).toFixed(2) + ' ' + units}],\n {fontSize:15, anchorX:'middle'});\n*/\n\n//Set up dimension labels to be properly aligned\ntextBC = board.create('text', \n [function () {return (pB.X() + pC.X())/2},\n function () {return ((pB.Y() + pC.Y())/2)-scaleOffset},\n function () {return +pB.Dist(pC).toFixed(0) + ' ' + units}],\n {fontSize:15, anchorX:'middle'});\n\n/*\n//Not used in this version\ntextAC = board.create('text', \n [function () {return (pA.X() + pC.X())/2},\n function () {return ((pA.Y() + pC.Y())/2)+(scaleOffset/2)},\n function () {return +pA.Dist(pC).toFixed(2) + ' ' + units}],\n {fontSize:15, anchorX:'middle'});\n\nvar tABRot = board.create('transform', \n [function () {return AB.getAngle()}, \n function () {return (pA.X() + pB.X())/2}, \n function () {return (pA.Y() + pB.Y())/2}],\n {type:'rotate'});\n*/\n\n//Set up rotation transform for label\nvar tBCRot = board.create('transform', \n [function () {return BC.getAngle()}, \n function () {return (pB.X() + pC.X())/2}, \n function () {return (pB.Y() + pC.Y())/2}],\n {type:'rotate'});\n\n/*\n//Hide this for final version\nvar tACRot = board.create('transform', \n [function () {return AC.getAngle()}, \n function () {return (pA.X() + pC.X())/2}, \n function () {return (pA.Y() + pC.Y())/2}],\n {type:'rotate'});\n*/\n\n//Perform text rotations and update\n//tABRot.bindTo(textAB);\n//Hide this for final version\ntBCRot.bindTo(textBC); \n//Hide this for final version\n//tACRot.bindTo(textAC);\nboard.update();\n\nreturn div;", "parameters": [["units", "string"], ["a", "number"], ["b", "number"], ["c", "number"], ["angleA", "number"], ["angleB", "number"], ["angleC", "number"]], "type": "html", "language": "javascript"}}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Draws a triangle based on 2 angles and a side length.
"}, "rulesets": {}, "type": "question", "contributors": [{"name": "Paul Hancock", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1738/"}]}]}], "contributors": [{"name": "Paul Hancock", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1738/"}]}