// Numbas version: finer_feedback_settings {"name": "Use information from a GeoGebra applet in marking", "extensions": ["geogebra"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "preamble": {"css": "", "js": "// we need a container element to make available to the question right now; the applet will be attached to it once it's loaded\nvar container = document.createElement('div');\ncontainer.className = 'numbas-geogebra-applet numbas-geogebra-loading';\ncontainer.innerHTML = 'GeoGebra applet loading...';\nquestion.scope.setVariable('applet',new Numbas.jme.types.THTML(container));\n\n// request the applet; the 'then' function runs once the applet has been loaded\nNumbas.extensions.geogebra.createGeogebraApplet({material_id: 'gEWtutTS'}).then(function(d) {\n // run some commands to manipulate the worksheet\n var app = d.app;\n question.geogebra_app = app;\n app.evalCommand('time_text=Text(\"'+new Date()+'\")');\n app.setCoords('time_text',1,2);\n app.setFixed('time_text',true,false);\n app.setCoords('A',0,2);\n app.setFixed('A',true,true);\n app.setCoords('B',2,0);\n app.setFixed('B',true,true);\n app.setPointCapture(1,0);\n \n var interval = setInterval(function() {\n if(container.parentNode) {\n container.innerHTML = '';\n container.className = 'numbas-geogebra-applet numbas-geogebra-loaded';\n container.appendChild(d.element);\n clearInterval(interval);\n }\n },10);\n\n question.signals.on('partsGenerated',function() {\n var p = question.getPart('p0');\n console.log(p);\n \n var objects = question.geogebra_objects = {A: true, B: true};\n app.registerAddListener(function(name) {\n objects[name] = true;\n console.log('add',name);\n p.setDirty(true);\n });\n app.registerUpdateListener(function(name) {\n p.setDirty(true);\n });\n app.registerRemoveListener(function(name) {\n p.setDirty(true);\n delete objects[name];\n });\n });\n});"}, "variablesTest": {"condition": "", "maxRuns": 100}, "parts": [{"variableReplacementStrategy": "originalfirst", "unitTests": [], "extendBaseMarkingAlgorithm": true, "type": "extension", "marks": "3", "showCorrectAnswer": true, "scripts": {"mark": {"order": "instead", "script": "var part = this;\npart.answered = true;\nvar app = question.geogebra_app;\nvar got = false;\nfor(var name in question.geogebra_objects) {\n console.log(name);\n var exists = app.exists(name);\n if(!exists) {\n continue;\n }\n var type = app.getObjectType(name);\n if(type!='point') {\n continue;\n }\n var x = app.getXcoord(name);\n var y = app.getYcoord(name);\n if(x==4 && y==4) {\n got = true;\n break;\n }\n};\nif(got) {\n part.setCredit(1,\"You put a point at (4,4)\");\n} else {\n part.setCredit(0,\"You didn't put a point at (4,4)\");\n}"}}, "customMarkingAlgorithm": "", "prompt": "

{applet}

\n

Place a point at coordinates $(3,3)$.

", "showFeedbackIcon": true, "variableReplacements": []}], "variable_groups": [], "advice": "", "ungrouped_variables": [], "variables": {}, "name": "Use information from a GeoGebra applet in marking", "metadata": {"description": "

An example of using the GeoGebra extension to ask the student to create a geometric construction, with marking and steps.

", "licence": "Creative Commons Attribution 4.0 International"}, "functions": {}, "extensions": ["geogebra"], "rulesets": {}, "statement": "

Numbas can use GeoGebra to mark a student's geometric construction. In this question, the part is marked correct once the student has constructed an equilateral triangle. The student can achieve this by any means - simple compass and ruler operations, or with the \"Regular polygon\" tool.

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