// Numbas version: exam_results_page_options {"name": "Find the foci of an ellipse", "extensions": ["oldgeogebra"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"description": "

Doesn't work - used the old extension.

\n

Mark a GeoGebra worksheet.

\n

Needs a worked solution.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "preamble": {"css": "#geogebra-applet {\n text-align: center;\n}", "js": "question.signals.on('HTMLAttached',function() {\n var html = $(question.display.html);\n var url = 'https://www.geogebratube.org/material/iframe/id/108319/width/800/height/430/border/888888/rc/false/ai/false/sdz/true/smb/false/stb/true/stbh/true/ld/false/sri/true/at/preferhtml5';\n \n var applet = window.applet = new Numbas.extensions.geogebra.GeoGebraApplet(url, {width: '800px', height: '500px'});\n \n html.find('#geogebra-applet').html('').append(applet.html);\n \n var wvariables = question.scope.variables;\n var unwrap = Numbas.jme.unwrapValue;\n \n var variables = {};\n \n for(var x in wvariables) {\n variables[x] = unwrap(wvariables[x]);\n }\n \n var round = Numbas.math.precround;\n var rx1 = round(variables.x1,6);\n var ry1 = round(variables.y1,6);\n var rx2 = round(variables.x2,6);\n var ry2 = round(variables.y2,6);\n \n var f1s = {}, f2s = {};\n \n applet.geogebra_ready.done(function() {\n function checkType(name) {\n applet.getObjectType(name).done(function(type) {\n if(type!='point' || name=='f1' || name=='f2' || name=='c')\n return;\n console.log(name,type);\n\n applet.getCoords(name).done(function(x,y) {\n x = round(x,6);\n y = round(y,6);\n f1s[name] = (x==rx1 && y==ry1);\n f2s[name] = (x==rx2 && y==ry2);\n console.log(f1s[name],f2s[name]);\n \n question.parts[0].setDirty(true);\n });\n });\n }\n \n applet.setAxesVisible(false,false);\n applet.refreshViews();\n applet.evalCommand('f1 = Point[{'+variables.x1+','+variables.y1+'}]');\n applet.evalCommand('f2 = Point[{'+variables.x2+','+variables.y2+'}]');\n applet.evalCommand('c = Point[{'+variables.x3+','+variables.y3+'}]');\n applet.evalCommand('ellipse = Ellipse[f1,f2,c]');\n applet.setVisible('f1',false);\n applet.setVisible('f2',false);\n applet.setVisible('c',false);\n\n applet.onUpdate(checkType);\n applet.onAdd(checkType);\n \n });\n \n question.parts[0].mark = function() {\n var f1,f2;\n for(var x in f1s) {\n if(f1s[x]) {\n f1 = true;\n break;\n }\n }\n for(var x in f2s) {\n if(f2s[x]) {\n f2 = true;\n break;\n }\n }\n console.log(f1s,f2s);\n \n var num_foci = (f1 ? 1 : 0) + (f2 ? 1 : 0);\n this.setCredit(num_foci/2,'You got '+num_foci+' of the foci.');\n }\n question.parts[0].validate = function() {\n return true;\n }\n});"}, "advice": "", "extensions": ["oldgeogebra"], "name": "Find the foci of an ellipse", "functions": {}, "variables": {"y1": {"templateType": "anything", "definition": "random(0..2#0)", "name": "y1", "description": "", "group": "Ungrouped variables"}, "y3": {"templateType": "anything", "definition": "random(max(y1,y2)..max(y1,y2)+1#0)", "name": "y3", "description": "", "group": "Ungrouped variables"}, "x1": {"templateType": "anything", "definition": "random(-3..-1#0)", "name": "x1", "description": "", "group": "Ungrouped variables"}, "y2": {"templateType": "anything", "definition": "random(0..2#0)", "name": "y2", "description": "", "group": "Ungrouped variables"}, "x3": {"templateType": "anything", "definition": "0", "name": "x3", "description": "", "group": "Ungrouped variables"}, "x2": {"templateType": "anything", "definition": "random(1..3#0)", "name": "x2", "description": "", "group": "Ungrouped variables"}}, "ungrouped_variables": ["x1", "y1", "x2", "x3", "y3", "y2"], "parts": [{"variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Create points at the foci of this ellipse. You must use a construction which is provably correct - guessing won't earn you any marks!

\n
Applet goes here
", "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "type": "gapfill", "scripts": {}, "gaps": [{"vsetrangepoints": 5, "variableReplacements": [], "showCorrectAnswer": true, "type": "jme", "scripts": {}, "checkvariablenames": false, "variableReplacementStrategy": "originalfirst", "vsetrange": [0, 1], "marks": 2, "answer": "1", "checkingtype": "absdiff", "showFeedbackIcon": true, "expectedvariablenames": [], "showpreview": true, "checkingaccuracy": 0.001}]}], "variable_groups": [], "statement": "", "tags": ["ellipse", "focus", "geogebra", "Geogebra", "geometry"], "rulesets": {}, "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}