// Numbas version: exam_results_page_options {"name": "3 side triangle", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["x1", "x2", "y1", "y2", "unitList", "units", "AB", "BC", "AC", "A", "B", "C", "angleOffset", "piTest", "DoublePi"], "statement": "

Referring to the line below.

", "extensions": ["jsxgraph"], "name": "3 side triangle", "variablesTest": {"condition": "BC < AB + AC\nand\nA > 30\n\n\n", "maxRuns": 100}, "advice": "", "tags": [], "variables": {"A": {"group": "Ungrouped variables", "templateType": "anything", "name": "A", "description": "

Angle at point A

", "definition": "precround((arccos((AB^2+AC^2-BC^2)/(2(AB)(AC))))*(180/PI),2)\n"}, "x1": {"group": "Ungrouped variables", "templateType": "anything", "name": "x1", "description": "", "definition": "random(5..20)"}, "units": {"group": "Ungrouped variables", "templateType": "anything", "name": "units", "description": "", "definition": "random(unitList)"}, "unitList": {"group": "Ungrouped variables", "templateType": "list of strings", "name": "unitList", "description": "

Units that are to be used for the question.

", "definition": "[ \"mm\", \"cm\", \"m\", \"km\" ]"}, "BC": {"group": "Ungrouped variables", "templateType": "anything", "name": "BC", "description": "

Length of side BC

", "definition": "random(49..99 except AB)"}, "DoublePi": {"group": "Ungrouped variables", "templateType": "anything", "name": "DoublePi", "description": "", "definition": "piTest^2\n\n"}, "y2": {"group": "Ungrouped variables", "templateType": "anything", "name": "y2", "description": "", "definition": "random(0..45 except y1)"}, "angleOffset": {"group": "Ungrouped variables", "templateType": "anything", "name": "angleOffset", "description": "

An offset angle to force triangle to be drawn anywhere between AB vertical and BC horizontal.

", "definition": "random(0..(90-A))"}, "B": {"group": "Ungrouped variables", "templateType": "anything", "name": "B", "description": "

Angle at point B

", "definition": "precround((arccos((AB^2+BC^2-AC^2)/(2(AB)(BC))))*(180/PI),2)"}, "AC": {"group": "Ungrouped variables", "templateType": "anything", "name": "AC", "description": "

Lentgh of side AC

", "definition": "random(15..49 except AB except BC)"}, "AB": {"group": "Ungrouped variables", "templateType": "anything", "name": "AB", "description": "

Length of side AB

", "definition": "random(20..60)"}, "piTest": {"group": "Ungrouped variables", "templateType": "anything", "name": "piTest", "description": "", "definition": "PI"}, "x2": {"group": "Ungrouped variables", "templateType": "anything", "name": "x2", "description": "", "definition": "random(25..45 except x1)"}, "C": {"group": "Ungrouped variables", "templateType": "anything", "name": "C", "description": "

Angle at point C

", "definition": "precround((180-(A+B)),2)"}, "y1": {"group": "Ungrouped variables", "templateType": "anything", "name": "y1", "description": "", "definition": "random(20..45)"}}, "preamble": {"css": "", "js": ""}, "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": {"language": "javascript", "parameters": [], "definition": "//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; \nx1 = Numbas.jme.unwrapValue(scope.variables.x1);\nx2 = Numbas.jme.unwrapValue(scope.variables.x2);\ny1 = Numbas.jme.unwrapValue(scope.variables.y1);\ny2 = Numbas.jme.unwrapValue(scope.variables.y2);\n//AB = Numbas.jme.unwrapValue(scope.variables.AB);\n//BC = Numbas.jme.unwrapValue(scope.variables.BC);\n//AC = Numbas.jme.unwrapValue(scope.variables.AC);\n//A = Numbas.jme.unwrapValue(scope.variables.A);\n//B = Numbas.jme.unwrapValue(scope.variables.B);\n//C = Numbas.jme.unwrapValue(scope.variables.C);\n//angleOffset = Numbas.jme.unwrapValue(scope.variables.angleOffset);\nunits = Numbas.jme.unwrapValue(scope.variables.units);\n\n// This functions plots two dimensioned lines \n// Max and min x and y values for the axis.\n// TODO Determine these based on point values\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//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;", "type": "html"}}, "parts": [{"prompt": "

{plotgraph()}

\n

What is length AB?

\n

[[0]] {units}

\n

What is length BC?

\n

[[1]] {units}

", "gaps": [{"maxValue": "30", "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "mustBeReduced": false, "marks": 1, "minValue": "10", "mustBeReducedPC": 0, "correctAnswerFraction": false, "showFeedbackIcon": true, "showCorrectAnswer": true, "correctAnswerStyle": "plain", "type": "numberentry", "scripts": {}, "variableReplacements": [], "allowFractions": false}, {"maxValue": "40", "precisionType": "dp", "precision": 0, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "mustBeReduced": false, "marks": 1, "minValue": "30", "mustBeReducedPC": 0, "showPrecisionHint": true, "correctAnswerFraction": false, "precisionPartialCredit": 0, "showFeedbackIcon": true, "showCorrectAnswer": true, "strictPrecision": true, "type": "numberentry", "correctAnswerStyle": "plain", "scripts": {}, "precisionMessage": "You have not given your answer to the correct precision.", "variableReplacements": [], "allowFractions": false}], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "type": "gapfill", "marks": 0, "showCorrectAnswer": true, "scripts": {}, "showFeedbackIcon": true}], "rulesets": {}, "variable_groups": [{"name": "Unnamed group", "variables": []}], "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/"}]}