From 67daabd191c3c54a5fea355a75bfa035ad33ae31 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 12 Dec 2022 12:02:58 +0100 Subject: [PATCH 01/60] Control random seed passing to GGB and numerical grades --- .classpath | 6 ++ .gitignore | 1 + .project | 30 +++++++ .settings/org.eclipse.jdt.core.prefs | 7 ++ .settings/org.eclipse.wst.common.component | 5 ++ ....eclipse.wst.common.project.facet.core.xml | 7 ++ amd/build/ggbq.min.js | 4 +- amd/build/ggbq.min.js.map | 2 +- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 79 +++++++++++++------ amd/src/ggbt.js | 35 +++++++- db/install.xml | 63 ++++++++------- db/upgrade.php | 19 +++++ edit_geogebra_form.php | 23 +++++- lang/en/qtype_geogebra.php | 9 +++ question.php | 48 ++++++++++- questiontype.php | 2 +- renderer.php | 5 ++ src/main/java/META-INF/MANIFEST.MF | 3 + src/main/java/META-INF/web-fragment.xml | 5 ++ version.php | 2 +- 22 files changed, 289 insertions(+), 70 deletions(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 src/main/java/META-INF/MANIFEST.MF create mode 100644 src/main/java/META-INF/web-fragment.xml diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..61b4889 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..3aae438 --- /dev/null +++ b/.project @@ -0,0 +1,30 @@ + + + Geogebra Qtype + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..db1cdcd --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..5978ec7 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index bad26cc..2b2df9d 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -2,13 +2,13 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return /** * Javascript Controller to embed GGBApplet * - * STUDENT VIEW + * StuDENT VIEW * * This class provides all the functionality for the new assign module. * * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\n * @copyright (c) International GeoGebra Institute 2018\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\n /**\n * Created by Christoph on 25.08.19.\n */\n\n const scalingContainers = {};\n let resizeTimeout;\n /**\n * Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\n */\n const resizeScalingContainer = () => {\n clearTimeout(resizeTimeout);\n resizeTimeout = setTimeout(\n () => Object.values(scalingContainers).forEach((containerClass) => {\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\n // We retrieve the formulation div container, because this gives us the correct width to adapt\n // the scaling container to.\n const formulationDivStyle = window.getComputedStyle(\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\n }), 250);\n };\n\n return {\n b64input: [],\n ggbBase64: [],\n xmlinput: [],\n ggbxml: [],\n currentvals: [],\n answerinput: [],\n responsevars: [],\n exerciseresultinput: [],\n qdiv: [],\n //parameters: {},\n ggbDataset: [],\n //applet1,\n\n init: function (appletParametersID) {\n window.GGBQ = this;\n var ggbDataset = document.getElementById(appletParametersID).dataset;\n var slot = ggbDataset.slot;\n // Add current scaling container to the object store for being able to access it later on.\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\n\n window.ggbAppletOnLoad = function (ggbAppletId) {\n if (ggbAppletId != -1) {\n document.querySelector('article').onkeydown = this.checkEnter;\n var id = ggbAppletId.substring(9);\n var ggbApplet = window[ggbAppletId];\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\n for (var label in curvals) {\n ggbApplet.setValue(label, curvals[label]);\n }\n\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\n resizeScalingContainer();\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\n // We only need one for the whole page.\n window.removeEventListener('resize', resizeScalingContainer);\n window.addEventListener('resize', resizeScalingContainer);\n\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\n\n window.GGBQ.qdiv[id].style.visibility = 'visible';\n if (window.GGBQ.answerinput[id].val() == '') {\n var responsestring = '';\n window.GGBQ.responsevars[id].forEach(function (responsevar) {\n if (ggbApplet.isDefined(responsevar)) {\n responsestring += ggbApplet.getValue(responsevar);\n } else {\n responsestring += 0;\n }\n });\n window.GGBQ.answerinput[id].val(responsestring);\n }\n }\n };\n\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\n this.ggbBase64[slot] = this.b64input[slot].val();\n\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\n this.ggbxml[slot] = this.xmlinput[slot].val();\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\n\n var parameters = JSON.parse(ggbDataset.parameters);\n if (this.ggbBase64[slot] != '') {\n parameters.ggbBase64 = this.ggbBase64[slot];\n }\n\n // Check if width and height have been manually set. The default would be \"no\", so we use the scaling container feature.\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\n parameters.scaleContainerClass = scalingContainers[slot];\n parameters.autoHeight = true;\n } else {\n // Width and height are specified in this case, so we use the given fixed width and height settings\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\n parameters.width = ggbDataset.width;\n parameters.height = ggbDataset.height;\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\n // We should always find this container, just check to be extra safe.\n if (scalingContainer) {\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\n scalingContainer.style.overflowX = 'auto';\n scalingContainer.style.overflowY = 'hidden';\n }\n }\n\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\n parameters.language = ggbDataset.lang;\n parameters.moodle = \"takingQuiz\";\n delete parameters.material_id;\n\n parameters.id = 'ggbApplet' + slot;\n\n var views = JSON.parse(ggbDataset.views);\n\n var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\n // applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\n applet1.inject(ggbDataset.div, \"preferHTML5\");\n\n $('#responseform').on('submit', this.getBase64andCheck);\n\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\n\n this.currentvals[slot] = ggbDataset.vars;\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\n },\n checkEnter: function(e) {\n e = e || event;\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\n },\n\n\n getBase64andCheck: function() {\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\n var ggbApplet = window['ggbApplet' + i];\n if (typeof ggbApplet !== \"undefined\") {\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\n\n // Workaround, to set all randomized variables.\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\n ggbApplet.evalCommand(`${key}=${value}`);\n }\n\n var responsestring = '';\n for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\n if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\n responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j]);\n } else {\n responsestring += 0;\n }\n }\n\n window.GGBQ.answerinput[i].val(responsestring);\n }\n }\n },\n\n };\n});\n"],"names":["define","$","GGBApplet","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","forEach","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","responsevars","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","ggbApplet","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","responsestring","responsevar","isDefined","getValue","parameters","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","views","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","value","evalCommand","j"],"mappings":";;;;;;;;;;;miCAWAA,6BAAO,CAAC,SAAU,+CAA+C,SAAUC,EAAGC,eAMtEC,cADEC,kBAAoB,GAKpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBM,SAAQ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B,WAAWH,eAEpDe,WAAY,SAASsC,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAI7DT,kBAAmB,eACV,IAAIU,EAAI,EAAGA,EAAI7E,OAAOqB,KAAKP,YAAYgE,OAAQD,IAAK,KACjD5C,UAAYjC,OAAO,YAAc6E,WACZ,IAAd5C,UAA2B,CAClCjC,OAAOqB,KAAKZ,SAASoE,GAAGpC,IAAIR,UAAUS,aACtC1C,OAAOqB,KAAKV,SAASkE,GAAGpC,IAAIR,UAAUU,uCAGXnD,OAAOuF,QAAQ/E,OAAOqB,KAAKmC,+CAAiB,8DAA3DwB,0BAAKC,4BACbhD,UAAUiD,sBAAeF,gBAAOC,gBAGhCpC,eAAiB,GACZsC,EAAI,EAAGA,EAAInF,OAAOqB,KAAKN,aAAa8D,GAAGC,OAAQK,IAChDlD,UAAUc,UAAU/C,OAAOqB,KAAKN,aAAa8D,GAAGM,IAChDtC,gBAAkBZ,UAAUe,SAAShD,OAAOqB,KAAKN,aAAa8D,GAAGM,IAEjEtC,gBAAkB,EAI1B7C,OAAOqB,KAAKP,YAAY+D,GAAGpC,IAAII"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n //alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n // Twingsister\r\n\r\ndefine(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n /**\r\n * Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n */\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n\r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(dice.toString());\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n //alert(\"applet creation\");debugger;\r\n var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n // applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n applet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","GGBApplet","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","views","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAmBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAGVC,6BAAO,CAAC,SAAU,+CAA+C,SAAUC,EAAGC,eAMtEC,cADEC,kBAAoB,GAKpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBX,SAAQ,SAACiB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbvC,aAAc,GACdwC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAErCzB,OAAO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AKqC,+CAAiB,8DAA3DwB,0BAAKpG,4BACbL,UAAU0G,sBAAeD,gBAAOpG,QAOhCmB,OAAOoB,KAAKN,YAAYgE,GAAGvC,IAAIjE,SAAS0B,OAAOoB,KAAK7C,aAAauG,GAAGtG,eAc3F"} \ No newline at end of file diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index 0a869f8..50c682d 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("qtype_geogebra/ggbt",["jquery","https://www.geogebra.org/apps/deployggb.js"],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var id=$("#id_ggbturl").val().split("/").pop();0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet(id)})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;$("#id_"+elementname).val(params.url);var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet(id)},injectapplet:function(id){this.parameters={material_id:id},this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j0&&(answer.val()||answer.val(strName),this.update_feedback(answer),i++)}randomizedvar.value=stringforrandomizedvars}},update_feedback:function(answernode){var id=answernode.attr("id").split("_").pop(),varname=answernode.val();if(varname){var feedback=$('input[name="feedback['+id+']"]'),feedbackfromfile=$("#id_feedbackfromfile_"+id),parser=new DOMParser,xml=window.ggbApplet.getXML(varname);if(xml){var doc=parser.parseFromString(xml,"text/xml");if(doc){var elem=doc.getElementsByTagName("caption"),fbstring="";1==elem.length?(fbstring=elem[0].getAttribute("val"),feedback.val(fbstring)):elem.length>1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +define("qtype_geogebra/ggbt",["jquery","https://www.geogebra.org/apps/deployggb.js"],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var id=$("#id_ggbturl").val().split("/").pop();0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet(id)})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;$("#id_"+elementname).val(params.url);var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet(id)},injectapplet:function(id){this.parameters={material_id:id},this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 088c89a..6c51a1a 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/**\n * Javascript Controller to embed GGBApplet\n *\n * This class provides all the functionality for the new assign module.\n *\n * @author Christoph Stadlbauer \n * @copyright (c) International GeoGebra Institute 2018\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\n /**\n * Created by Christoph on 25.08.19.\n */\n return {\n\n init: function() {\n window.GGBT = this;\n window.ggbAppletOnLoad = function() {\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\n\n if (typeof (this.ggbcheckb) == \"undefined\") {\n var applet = document.ggbApplet;\n $('input[name=\"ggbxml\"]').val(applet.getXML());\n\n var randomizedvar = document.getElementById('id_randomizedvar');\n if (!randomizedvar.value) {\n window.GGBT.getrandvars();\n }\n\n var i = 0;\n var answer = $('#id_answer_' + i);\n while (answer[0] !== undefined) {\n if (answer.val()) {\n answer.on('change focus', function(e) {\n e.preventDefault();\n window.GGBT.update_feedback($(e.target));\n });\n window.GGBT.update_feedback(answer);\n }\n answer = $('#id_answer_' + ++i);\n }\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\n }\n if (window.GGBT.usefile.checked) {\n document.getElementById('applet_container1').style.display = \"block\";\n document.getElementById('applet_options').style.display = \"flex\";\n }\n };\n\n if ($('#applet_parameters')[0] !== undefined) {\n this.ggbDataset = $('#applet_parameters')[0].dataset;\n this.parameters = JSON.parse(this.ggbDataset.parameters);\n this.views = this.ggbDataset.views;\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.410.0/web3d\");\n this.lang = this.ggbDataset.lang;\n }\n\n $('#id_loadapplet').on('click', function(e) {\n e.preventDefault();\n var id = $('#id_ggbturl').val().split(\"/\").pop();\n if (id.indexOf(\"m\") == 0) {\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\n id = id.substr(1);\n }\n }\n window.GGBT.injectapplet(id);\n });\n\n $('#id_getvars').on('click', function(e) {\n e.preventDefault();\n window.GGBT.getrandvars();\n });\n\n if (this.parameters) {\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\n }\n\n this.ggbf = document.getElementById('id_ggbtheader');\n this.usefile = document.getElementById(\"id_usefile\");\n\n if (this.ggbf === null) { // In this case we are editing a submission.\n this.ggbf = document.getElementById('id_submissiontypes');\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\n if (this.ggbcheckb !== null) {\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\n }\n }\n\n if (this.ggbf !== null) {\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\n this.ggbf.addEventListener('drop', this.handleDrop, false);\n this.usefile.addEventListener('change', this.handleusefile, false);\n }\n\n if (this.usefile.checked) {\n document.getElementById('applet_options').style.display = \"block\";\n } else {\n document.getElementById('applet_options').style.display = \"none\";\n }\n this.initoptions();\n },\n\n callback: function(params) {\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\n $('#id_' + elementname).val(params.url);\n // inject applet to div layer\n var id = (params.file).split(\".\")[0];\n if (id.indexOf(\"m\") == 0) {\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\n id = id.substr(1);\n }\n }\n this.injectapplet(id);\n },\n\n injectapplet: function(id) {\n this.parameters = {\"material_id\": id};\n this.parameters.language = this.lang;\n this.parameters.moodle = \"editingQuestionOrSubmission\";\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\n this.parameters.useBrowserForJS = false;\n\n document.getElementById('applet_container1').style.display = \"block\";\n\n window.applet1 = new GGBApplet(this.parameters, true);\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\n\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\n\n },\n\n getrandvars: function() {\n var applet = document.ggbApplet;\n if (typeof applet !== 'undefined') {\n var objNumber = applet.getObjectNumber();\n var randomizedvar = document.getElementById('id_randomizedvar');\n var stringforrandomizedvars = \"\";\n var i = 0;\n for (var j = 0; j < objNumber; j++) {\n var strName = applet.getObjectName(j);\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\n stringforrandomizedvars += strName + \",\";\n } else {\n var answer = $('#id_answer_' + i);\n if (applet.getObjectType(strName) == \"boolean\") {\n if (answer !== null && answer.length > 0) {\n if (!answer.val()) {\n answer.val(strName);\n }\n this.update_feedback(answer);\n i++;\n }\n }\n }\n randomizedvar.value = stringforrandomizedvars;\n }\n }\n },\n\n update_feedback: function(answernode) {\n var id = answernode.attr('id').split(\"_\").pop();\n var varname = answernode.val();\n if (!varname) {\n // Should not happen, but make sure this function does not fail.\n return;\n }\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\n const parser = new DOMParser();\n const xml = window.ggbApplet.getXML(varname);\n if (!xml) {\n // Should not happen, but make sure this function does not fail.\n return;\n }\n const doc = parser.parseFromString(xml, \"text/xml\");\n if (doc) {\n var elem = doc.getElementsByTagName('caption');\n var fbstring = '';\n if (elem.length == 1) {\n fbstring = elem[0].getAttribute('val');\n feedback.val(fbstring);\n } else if (elem.length > 1) {\n feedback.val('');\n fbstring = '';\n } else {\n feedback.val('');\n //this is rather an error condition but should be checked by the server\n fbstring = 'Caption not set or variable name wrong.';\n }\n feedbackfromfile.val(fbstring);\n }\n },\n\n checkEnter: function(e) {\n e = e || event;\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\n },\n\n initoptions: function() {\n this.enable_right_click = document.getElementById('enableRightClick');\n this.enable_label_drags = document.getElementById('enableLabelDrags');\n this.show_reset_icon = document.getElementById('showResetIcon');\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\n this.show_algebra_input = document.getElementById('showAlgebraInput');\n this.show_menu_bar = document.getElementById('showMenuBar');\n this.show_tool_bar = document.getElementById('showToolBar');\n\n if (typeof parameters !== 'undefined') {\n this.enable_right_click.checked = this.parameters.enableRightClick;\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\n this.show_reset_icon.checked = this.parameters.showResetIcon;\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\n this.show_menu_bar.checked = this.parameters.showMenuBar;\n this.show_tool_bar.checked = this.parameters.showToolBar;\n }\n\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\n },\n\n handlesettingschanged: function(evt) {\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\n } else {\n window.ggbApplet[evt.target.id](evt.target.checked);\n }\n },\n\n handleusefile: function() {\n if (!window.GGBT.usefile.checked) {\n document.getElementById('applet_container1').style.display = \"none\";\n document.getElementById('applet_options').style.display = \"none\";\n } else {\n document.getElementById('id_ggbturl').value = \"\";\n // document.getElementById('applet_container1').style.display = \"block\";\n }\n },\n\n handleggbdisable: function() {\n if (!window.GGBT.ggbcheckb.checked) {\n document.getElementById('applet_container1').style.display = \"none\";\n document.getElementById('applet_options').style.display = \"none\";\n if (window.GGBT.usefile.checked) {\n window.GGBT.usefile.click();\n }\n } else {\n document.getElementById('applet_container1').style.display = \"block\";\n }\n },\n\n handleDragEnter: function() {\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\n document.getElementById('applet_container1').style.visibility = \"hidden\";\n }\n },\n\n handleDragOver: function(e) {\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\n if (e.preventDefault) {\n e.preventDefault();\n }\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\n document.getElementById('applet_container1').style.visibility = \"hidden\";\n return false;\n }\n },\n\n handleDragEndLeave: function() {\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\n }\n },\n\n handleDrop: function(e) {\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\n e.preventDefault();\n e.stopPropagation();\n var file = e.dataTransfer.files[0];\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\n document.getElementById('applet_container1').style.display = \"block\";\n document.getElementById('applet_options').style.display = \"flex\";\n document.getElementById('applet_container1').style.height = \"100%\";\n //document.getElementById('applet_container1').style.width = \"100%\";\n\n document.getElementById('id_ggbturl').value = \"\";\n //this.usefile = document.getElementById(\"id_usefile\");\n if (!window.GGBT.usefile.checked) {\n window.GGBT.usefile.click();\n }\n var reader = new FileReader();\n reader.onload = function(event) {\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\n window.GGBT.parameters = {\"ggbBase64\": base64};\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\n window.applet1.inject(\"applet_container1\");\n };\n\n reader.readAsDataURL(file);\n }\n },\n\n isNumber: function(n) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n }\n };\n});\n"],"names":["define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","document","ggbApplet","getXML","getElementById","value","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","checked","style","display","ggbDataset","dataset","parameters","parse","views","lang","id","split","pop","indexOf","isNumber","substr","length","injectapplet","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AASCA,6BAAO,CAAC,SAAU,+CAA+C,SAAUC,EAAGC,iBAIpE,CAEHC,KAAM,WACFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAASC,SAASC,UACtBjB,EAAE,wBAAwBO,IAAIQ,OAAOG,UAEjBF,SAASG,eAAe,oBACzBC,OACfjB,OAAOC,KAAKiB,sBAGZC,EAAI,EACJC,OAASvB,EAAE,cAAgBsB,QACVE,IAAdD,OAAO,IACNA,OAAOhB,QACPgB,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFxB,OAAOC,KAAKwB,gBAAgB5B,EAAE0B,EAAEG,YAEpC1B,OAAOC,KAAKwB,gBAAgBL,SAEhCA,OAASvB,EAAE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,OAAOE,OAAS,SAASnC,WACjBoC,OAASpC,MAAMnE,OAAOwG,OAAOC,QAAQ,6CAA8C,IACvFnI,OAAOC,KAAKmC,WAAa,WAAc6F,QACvCjI,OAAOC,KAAKmC,WAAWuE,iBAAmB3G,OAAOC,KAAKmG,mBAAmBrE,QACzE/B,OAAOC,KAAKmC,WAAWwE,iBAAmB5G,OAAOC,KAAKoG,mBAAmBtE,QACzE/B,OAAOC,KAAKmC,WAAWyE,cAAgB7G,OAAOC,KAAKqG,gBAAgBvE,QACnE/B,OAAOC,KAAKmC,WAAW0E,oBAAsB9G,OAAOC,KAAKsG,uBAAuBxE,QAChF/B,OAAOC,KAAKmC,WAAW2E,iBAAmB/G,OAAOC,KAAKuG,mBAAmBzE,QACzE/B,OAAOC,KAAKmC,WAAW4E,YAAchH,OAAOC,KAAKwG,cAAc1E,QAC/D/B,OAAOC,KAAKmC,WAAW6E,YAAcjH,OAAOC,KAAKyG,cAAc3E,QAC/D/B,OAAOC,KAAKmC,WAAWgC,OAAS,8BAChCpE,OAAOO,QAAU,IAAIT,UAAUE,OAAOC,KAAKmC,YAAY,GAEvDpC,OAAOO,QAAQyC,OAAO,sBAG1B8E,OAAOM,cAAclE,QAI7BtB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\n\r\n define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.410.0/web3d\");\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var id = $('#id_ggbturl').val().split(\"/\").pop();\r\n if (id.indexOf(\"m\") == 0) {\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet(id);\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet(id);\r\n },\r\n\r\n injectapplet: function(id) {\r\n this.parameters = {\"material_id\": id};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","document","ggbApplet","getXML","getElementById","value","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","checked","style","display","ggbDataset","dataset","parameters","parse","views","lang","id","split","pop","indexOf","isNumber","substr","length","injectapplet","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"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AOC,KAAKmC,WAAWgC,OAAS,8BAChCpE,OAAOO,QAAU,IAAIT,UAAUE,OAAOC,KAAKmC,YAAY,GAEvDpC,OAAOO,QAAQyC,OAAO,sBAG1B8E,OAAOM,cAAclE,QAI7BtB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 94fcdd0..e1d6635 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -1,7 +1,12 @@ +/* eslint-disable */ +/* eslint-disable no-debugger */ +/*jslint devel: true */ +/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/ + /** * Javascript Controller to embed GGBApplet * - * STUDENT VIEW + * StuDENT VIEW * * This class provides all the functionality for the new assign module. * @@ -9,6 +14,23 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + + //alert("hello ggbq"); + //debugger; // eslint-disable-line + function stringfy(responsevars,ggbApplet){ + //debugcode(); + var responsestring = ''; + responsevars.forEach(function (responsevar){ + if (ggbApplet.isDefined(responsevar)){ + var value = ggbApplet.getValue(responsevar); + if (ggbApplet.getObjectType(responsevar)=="boolean"){value = (value == 0 ?"false":"true");} + responsestring += value+'%'; //Twingsister to deal with multidigit + } + }); + return responsestring.replace(/\%$/,""); // possibly cut the last % works better with explode + } + // Twingsister + define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { /** * Created by Christoph on 25.08.19. @@ -33,7 +55,6 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px'; }), 250); }; - return { b64input: [], ggbBase64: [], @@ -50,6 +71,7 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG init: function (appletParametersID) { window.GGBQ = this; + //debugcode(); var ggbDataset = document.getElementById(appletParametersID).dataset; var slot = ggbDataset.slot; // Add current scaling container to the object store for being able to access it later on. @@ -77,15 +99,10 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG window.GGBQ.qdiv[id].style.visibility = 'visible'; if (window.GGBQ.answerinput[id].val() == '') { - var responsestring = ''; - window.GGBQ.responsevars[id].forEach(function (responsevar) { - if (ggbApplet.isDefined(responsevar)) { - responsestring += ggbApplet.getValue(responsevar); - } else { - responsestring += 0; - } - }); - window.GGBQ.answerinput[id].val(responsestring); + // Twingsister + window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet)); + // Twingsister + //alert("response one"); } } }; @@ -103,7 +120,15 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG parameters.ggbBase64 = this.ggbBase64[slot]; } - // Check if width and height have been manually set. The default would be "no", so we use the scaling container feature. + // Check if seed have been manually set. The default would be "no" + if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') { + var dice=Math.floor((Math.random() * 1000) + 1); + //alert(dice.toString()); + parameters.randomSeed = dice ; + } else { + parameters.randomSeed = ggbDataset.seed; + } + //alert("Calling with random "+parameters.randomSeed.toString()); if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') { parameters.scaleContainerClass = scalingContainers[slot]; parameters.autoHeight = true; @@ -121,7 +146,6 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG scalingContainer.style.overflowY = 'hidden'; } } - // parameters.currentvals = JSON.parse(ggbDataset.vars); this.ggbDatasetVars = JSON.parse(ggbDataset.vars); parameters.language = ggbDataset.lang; @@ -131,7 +155,7 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG parameters.id = 'ggbApplet' + slot; var views = JSON.parse(ggbDataset.views); - + //alert("applet creation");debugger; var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple); // applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); applet1.inject(ggbDataset.div, "preferHTML5"); @@ -150,9 +174,13 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG var txtArea = /textarea/i.test((e.target || e.srcElement).tagName); return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13; }, + // Twingsister + // takes an an array of strings that are GGB variable names either numeric text or boolean and + // returns a percent % separated string of the values. If no value is present the variable is skipped getBase64andCheck: function() { + //debugcode(); for (var i = 0; i < window.GGBQ.answerinput.length; i++) { var ggbApplet = window['ggbApplet' + i]; if (typeof ggbApplet !== "undefined") { @@ -164,16 +192,19 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG ggbApplet.evalCommand(`${key}=${value}`); } - var responsestring = ''; - for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) { - if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) { - responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j]); - } else { - responsestring += 0; - } - } - - window.GGBQ.answerinput[i].val(responsestring); + //var responsestring = ''; + //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) { + //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) { + // Twingsister + window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet)); + // Twingsister + // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit + //} else { + // responsestring += 0; + //} + //} + //window.GGBQ.answerinput[i].val(responsestring); + //alert("response"); } } }, diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index 4433ac4..ce5e6ff 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -1,3 +1,5 @@ +/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/ +/* eslint-disable no-undef */ /** * Javascript Controller to embed GGBApplet * @@ -7,6 +9,8 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +// alert("hello ggbt"); + define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { /** * Created by Christoph on 25.08.19. @@ -14,6 +18,8 @@ return { init: function() { + + //debugcode(); window.GGBT = this; window.ggbAppletOnLoad = function() { $('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())); @@ -107,6 +113,7 @@ }, callback: function(params) { + //debugcode(); var elementname = M.core_filepicker.instances[params['client_id']].options.elementname; $('#id_' + elementname).val(params.url); // inject applet to div layer @@ -134,7 +141,6 @@ window.applet1.inject("applet_container1", "preferHTML5"); }, - getrandvars: function() { var applet = document.ggbApplet; if (typeof applet !== 'undefined') { @@ -143,28 +149,44 @@ var stringforrandomizedvars = ""; var i = 0; for (var j = 0; j < objNumber; j++) { - var strName = applet.getObjectName(j); + var strName = applet.getObjectName(j); + if (strName == "grade"){ + var answer=$('#id_answer_' + i); + if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;} + } if (applet.getObjectType(strName) == "numeric" && applet.isIndependent(strName)) { stringforrandomizedvars += strName + ","; } else { - var answer = $('#id_answer_' + i); - if (applet.getObjectType(strName) == "boolean") { + //debugcode(); + /* + if (applet.getObjectType(strName) == "boolean"){ + //alert(strName+" boolean or number"); + var answer = $('#id_answer_' + i); if (answer !== null && answer.length > 0) { if (!answer.val()) { answer.val(strName); } this.update_feedback(answer); i++; + //alert(strName); + // } } + */ } randomizedvar.value = stringforrandomizedvars; } + //if (applet.exists("grade")) { + // var answerscore = $('#id_answer_' + i); + // answerscore.val("grade"); + // this.update_feedback(answerscore); + // } } }, update_feedback: function(answernode) { var id = answernode.attr('id').split("_").pop(); + //debugcode(); var varname = answernode.val(); if (!varname) { // Should not happen, but make sure this function does not fail. @@ -179,16 +201,21 @@ return; } const doc = parser.parseFromString(xml, "text/xml"); + //alert(xml); if (doc) { var elem = doc.getElementsByTagName('caption'); + //alert("retrieve "+elem.toString()); var fbstring = ''; if (elem.length == 1) { fbstring = elem[0].getAttribute('val'); feedback.val(fbstring); + //alert("retrieve "+fbstring); } else if (elem.length > 1) { feedback.val(''); + //alert("retrieve fail length >1"); fbstring = ''; } else { + //alert("retrieve fail 1"); feedback.val(''); //this is rather an error condition but should be checked by the server fbstring = 'Caption not set or variable name wrong.'; diff --git a/db/install.xml b/db/install.xml index 1155ca2..f40ee22 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,33 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - -
-
-
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/db/upgrade.php b/db/upgrade.php index cb80f47..1da2f1e 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -73,5 +73,24 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022040800, 'qtype', 'geogebra'); } + if ($oldversion < 2022050401) { + + // Define field seeda and seed it or no to be added to qtype_geogebra_options. + $table = new xmldb_table('qtype_geogebra_options'); + $field = new xmldb_field('seeditornot', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'height'); + // Conditionally launch add field forcedimensions. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + $field = new xmldb_field('seed', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'seeditornot'); + // Conditionally launch add field seed. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Geogebra savepoint reached. + upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); + } return true; } diff --git a/edit_geogebra_form.php b/edit_geogebra_form.php index 36e3093..f307d1a 100644 --- a/edit_geogebra_form.php +++ b/edit_geogebra_form.php @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die (); - +//xdebug_break(); global $CFG; require_once($CFG->dirroot . '/question/type/shortanswer/edit_shortanswer_form.php'); require_once($CFG->dirroot . '/question/type/geogebra/question.php'); @@ -140,6 +140,16 @@ protected function definition_inner($mform) { $mform->addElement('selectyesno', 'isexercise', get_string('isexercise', 'qtype_geogebra')); $mform->addHelpButton('isexercise', 'isexercise', 'qtype_geogebra'); + // Add randomization seed + $mform->addElement('advcheckbox', 'seeditornot', get_string('seeditornotenable', 'qtype_geogebra'), + get_string('seeditornot', 'qtype_geogebra')); + $mform->setDefault('seeditornot', 0); + // If seeditornot true get a seed + $mform->addElement('text', 'seed', get_string('seed', 'qtype_geogebra')); + $mform->setType('seed', PARAM_INT); + $mform->addHelpButton('seed', 'seed', 'qtype_geogebra'); + $mform->hideIf('seed', 'seeditornot'); + $mform->addElement('advcheckbox', 'forcedimensions', get_string('forcedimensionsenable', 'qtype_geogebra'), get_string('forcedimensions', 'qtype_geogebra')); @@ -199,6 +209,7 @@ protected function data_preprocessing($question) { * or an empty array if everything is OK (true allowed for backwards compatibility too). */ public function validation($data, $files) { + //xdebug_break(); $errors = parent::validation($data, $files); $this->check_is_applet_present($data, $errors); @@ -217,6 +228,7 @@ public function validation($data, $files) { } $this->check_force_dimensions($data, $errors); + $this->check_seeditornot($data, $errors); return $errors; } @@ -286,6 +298,14 @@ private function check_force_dimensions($data, &$errors) { } } + private function check_seeditornot($data, &$errors) { + if (!empty($data['seeditornot'])) { + // If seed is being activated, seed must not be empty or zero. + if (empty($data['seed'])) { + $errors['seed'] = get_string('seednotzero', 'qtype_geogebra'); + } + } + } /** * @param $data * @param $errors @@ -533,6 +553,7 @@ private function add_applet_elements($mform) { EOD; $mform->addElement('html', $applet); } + //echo ""; $PAGE->requires->js_call_amd('qtype_geogebra/ggbt', 'init'); } diff --git a/lang/en/qtype_geogebra.php b/lang/en/qtype_geogebra.php index 6ccb060..eebfa26 100644 --- a/lang/en/qtype_geogebra.php +++ b/lang/en/qtype_geogebra.php @@ -30,6 +30,15 @@ $string['answervar'] = 'Variables for automatic grading'; $string['answervar_help'] = 'For automatic grading: A name of a boolean object in GeoGebra which is true if the student solved the question (partly). Sums up all grades for all boolean variables. The question is correct if any combination exceeds 100%, but there should be at least one combination which sums up to exactly 100%. Leave blank for manual grading.'; $string['applet_advanced_settings'] = 'Advanced Settings...'; + +$string['seeditornot'] = 'Add a custom seed'; +$string['seeditornot_help'] = 'By default the GeoGebra random generator gives a different sequence of random values for each exercise instance. If you provide a POSITIVE integer seed this is used and therefore the same random sequence is used to instantiate the question. Each student gets the same exercise. Zero IS NOT a valid seed'; +$string['seeditornotenable'] = 'Enable ad-hoc seeding'; +$string['seednotzero'] = 'You have to specify a value greater than zero for the seed'; +//add seed +$string['seed'] = 'Seed'; +$string['seed_help'] = 'The GeoGebra applet is started with a known seet for the random generator.'; +$string['seedeenable'] = 'Specify a seed manually'; $string['forcedimensions'] = 'Force applet dimensions'; $string['forcedimensions_help'] = 'By default the GeoGebra applet is being scaled automatically into the quiz layout. Enabling this option will allow you to specify width and height of the plugin manually and disable automatic scaling.'; $string['forcedimensionsenable'] = 'Specify width and height manually'; diff --git a/question.php b/question.php index 1a92839..71ca076 100644 --- a/question.php +++ b/question.php @@ -47,6 +47,8 @@ class qtype_geogebra_question extends question_graded_automatically { public $forcedimensions; public $width; public $height; + public $seeditornot; + public $seed; public $currentvals = array(); @@ -221,6 +223,36 @@ public function is_gradable_response(array $response) { return $ret; } + private function summarize(array $answers,string $resp){ + $j = 0; + $fraction = 0; + $summary = ''; + $responseclass = ''; + $values = explode("%",$resp); // Twingsister + foreach ($answers as $answer) { + //$correct = (bool)substr($resp, $j, 1); + // add a comma if necessary + if ($summary !== '') { + $summary .= ', '; + } + // the name of the variable + $summary .= $answer->answer . '='; + $responseclass .= $answer->answer . '=' . $values[$j]; + // contribution to the result + $valnum = $values[$j]; + $valnum = ($valnum == "true"?1:($valnum == "false"?0:number_format($values[$j]))); + $fraction += ($answer->fraction)*$valnum; + $summary .= format_float($valnum, 2, false, false) . ',' . + get_string('grade', 'grades') . ': ' . + format_float($answer->fraction, 2, false, false); + $j++; + } + if ($fraction > 1) { + $fraction = 1; + } + $summary .= '; ' . get_string('total', 'grades') . ': ' . $fraction; + return array('summary'=>$summary, 'fraction'=>$fraction,'responseclass'=>$responseclass); + } /** * Produce a plain text summary of a response. * @@ -235,11 +267,15 @@ public function summarise_response(array $response) { $resp = $response['answer']; if ($resp === '' && !$this->isexercise) { return get_string('noresponse', 'question'); - } else { + } else { if (!$this->isexercise) { + if($resp===null){return '';} + return $this->summarize($this->answers,$resp)['summary']; // Twingsister + /* $j = 0; $fraction = 0; $summary = ''; + $values = explode("%",$resp); // Twingsister foreach ($this->answers as $answer) { $correct = (bool)substr($resp, $j, 1); if ($summary !== '') { @@ -261,6 +297,7 @@ public function summarise_response(array $response) { $summary .= '; ' . get_string('total', 'grades') . ': ' . $fraction; return $summary; + */ } else { $result = json_decode($response['exerciseresult'], true); $summary = ''; @@ -323,6 +360,8 @@ public function classify_response(array $response) { if ($resp === '') { return array($this->id => question_classified_response::no_response()); } else { + $results= $this->summarize($this->answers,$resp); // Twingsister + /* $j = 0; $fraction = 0; $responseclass = ''; @@ -343,7 +382,8 @@ public function classify_response(array $response) { if ($fraction > 1) { $fraction = 1; } - return array($this->id => new question_classified_response(bindec($resp), $responseclass, $fraction)); + */ + return array($this->id => new question_classified_response($resp,$results['responseclass'],$results['fraction'])); //bindec($resp) } } } @@ -363,6 +403,9 @@ public function grade_response(array $response) { return array($fraction, question_state::$needsgrading); } else { if (!$this->isexercise) { + $resp = $response['answer']; + $fraction=$this->summarize($this->answers,$resp)['fraction']; + /* $i = 0; foreach ($this->answers as $answer) { if ((bool)substr($response['answer'], $i, 1)) { @@ -373,6 +416,7 @@ public function grade_response(array $response) { if ($fraction > 1) { $fraction = 1; } + */ } else { $exerciseresult = json_decode($response['exerciseresult']); $fraction = $this->calculate_exercise_fraction($exerciseresult); diff --git a/questiontype.php b/questiontype.php index 80ad005..74c7643 100644 --- a/questiontype.php +++ b/questiontype.php @@ -43,7 +43,7 @@ class qtype_geogebra extends question_type { */ public function extra_question_fields() { return array('qtype_geogebra_options', 'ggbturl', 'ggbparameters', 'ggbviews', 'ggbcodebaseversion', 'ggbxml', - 'israndomized', 'randomizedvar', 'constraints', 'isexercise', 'forcedimensions', 'width', 'height'); + 'israndomized', 'randomizedvar', 'constraints', 'isexercise','forcedimensions','width','height', 'seeditornot','seed'); } /** diff --git a/renderer.php b/renderer.php index 259f13b..1e381d1 100644 --- a/renderer.php +++ b/renderer.php @@ -133,6 +133,8 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $slot = $qa->get_slot(); $appletparametersid = $qa->get_qt_field_name('applet_parameters'); $forcedimensions = $question->forcedimensions ?: 0; + $seeditornot = $question->seeditornot ?: 0; + $seed = $question->seed ?: 0; $width = $question->width ?: 0; $height = $question->height ?: 0; $applet = << EOD; $result .= $applet; + //echo ""; $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); if ($qa->get_state() == question_state::$invalid) { diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/src/main/java/META-INF/web-fragment.xml b/src/main/java/META-INF/web-fragment.xml new file mode 100644 index 0000000..bc59abc --- /dev/null +++ b/src/main/java/META-INF/web-fragment.xml @@ -0,0 +1,5 @@ + + +Geogebra Qtype + Geogebra_Qtype + \ No newline at end of file diff --git a/version.php b/version.php index 8948c0b..2d77515 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2022050400; +$plugin->version = 2022121200; $plugin->release = '1.13.3'; $plugin->requires = 2018051702; From 41b8b376d11d3c430451bc1050896c1dfa29fce4 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Fri, 13 Jan 2023 11:01:58 +0100 Subject: [PATCH 02/60] Adding non Geotube URL and alternative URL for deploy.js --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 51 ++++++++++++++++++++++++++--------- amd/src/ggbt.js | 55 +++++++++++++++++++++++++++++++------- db/install.xml | 6 ++++- db/install.xml.old | 36 +++++++++++++++++++++++++ db/upgrade.php | 27 +++++++++++++++++++ edit_geogebra_form.php | 19 ++++++++++++- lang/en/qtype_geogebra.php | 10 +++++++ question.php | 4 +++ questiontype.php | 4 ++- renderer.php | 10 ++++++- version.php | 4 +-- 15 files changed, 202 insertions(+), 32 deletions(-) create mode 100644 db/install.xml.old diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 2b2df9d..259837e 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n //alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n // Twingsister\r\n\r\ndefine(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n /**\r\n * Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n */\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n\r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(dice.toString());\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n //alert(\"applet creation\");debugger;\r\n var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n // applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n applet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","GGBApplet","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","views","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAmBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAGVC,6BAAO,CAAC,SAAU,+CAA+C,SAAUC,EAAGC,eAMtEC,cADEC,kBAAoB,GAKpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBX,SAAQ,SAACiB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YA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,YAAYiE,OAAQD,IAAK,KACjDtG,UAAYwB,OAAO,YAAc8E,WACZ,IAAdtG,UAA2B,CAClCwB,OAAOoB,KAAKX,SAASqE,GAAGvC,IAAI/D,UAAUgE,aACtCxC,OAAOoB,KAAKT,SAASmE,GAAGvC,IAAI/D,UAAUiE,uCAGXhD,OAAOuF,QAAQhF,OAAOoB,KAAKqC,+CAAiB,8DAA3DwB,0BAAKpG,4BACbL,UAAU0G,sBAAeD,gBAAOpG,QAOhCmB,OAAOoB,KAAKN,YAAYgE,GAAGvC,IAAIjE,SAAS0B,OAAOoB,KAAK7C,aAAauG,GAAGtG,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n\r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(dice.toString());\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n if (ggbDataset.isurlggb) {\r\n \tGGBAppletname = ggbDataset.urlggb;\r\n } else {GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';}\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","views","isurlggb","urlggb","require","App","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aA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UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAInF,OAAOoB,KAAKN,YAAYsE,OAAQD,IAAK,KACjD1G,UAAYuB,OAAO,YAAcmF,WACZ,IAAd1G,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS0E,GAAG5C,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASwE,GAAG5C,IAAI9D,UAAUgE,uCAGXhD,OAAO4F,QAAQrF,OAAOoB,KAAKqC,+CAAiB,8DAA3D6B,0BAAKxG,4BACbL,UAAU8G,sBAAeD,gBAAOxG,QAOhCkB,OAAOoB,KAAKN,YAAYqE,GAAG5C,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa2G,GAAG1G,eAc3F"} \ No newline at end of file diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index 50c682d..a1aea01 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("qtype_geogebra/ggbt",["jquery","https://www.geogebra.org/apps/deployggb.js"],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var id=$("#id_ggbturl").val().split("/").pop();0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet(id)})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;$("#id_"+elementname).val(params.url);var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet(id)},injectapplet:function(id){this.parameters={material_id:id},this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +var GGBAppletstr;GGBAppletstr=document.getElementById("id_isurlggb").checked?document.getElementById("id_urlggb").value:"https://www.geogebra.org/apps/deployggb.js",define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,alert("hello custom ggb 3"),window.applet1=new GGBApplet(this.parameters,this.views,!0),this.lang=this.ggbDataset.lang),debugcode(),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){alert("other filename"),debugcode();var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",alert("hello custom ggb 4"),debugcode(),window.applet1=new GGBApplet(this.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(alert("hello custom ggb 5"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",alert("hello custom ggb 2"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 6c51a1a..62e6e9f 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\n\r\n define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.410.0/web3d\");\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var id = $('#id_ggbturl').val().split(\"/\").pop();\r\n if (id.indexOf(\"m\") == 0) {\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet(id);\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet(id);\r\n },\r\n\r\n injectapplet: function(id) {\r\n this.parameters = {\"material_id\": id};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","document","ggbApplet","getXML","getElementById","value","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","checked","style","display","ggbDataset","dataset","parameters","parse","views","lang","id","split","pop","indexOf","isNumber","substr","length","injectapplet","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAaCA,6BAAO,CAAC,SAAU,+CAA+C,SAAUC,EAAGC,iBAIpE,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAK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"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletstr = document.getElementById('id_urlggb').value;\r\n }else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.410.0/web3d\");\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n alert(\"other filename\");\r\n debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n alert(\"hello custom ggb 4\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","document","getElementById","checked","value","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","alert","lang","debugcode","httpurl","id","split","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aAEiBA,aADGC,SAASC,eAAe,eAAeC,QAC3BF,SAASC,eAAe,aAAaE,MAC7B,6CAC3CC,6BAAO,CAAC,SAAUL,eAAe,SAAUM,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAASpB,SAASqB,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjBtB,SAASC,eAAe,oBACzBE,OACfK,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFrB,OAAOC,KAAKqB,gBAAgBzB,EAAEuB,EAAEG,YAEpCvB,OAAOC,KAAKqB,gBAAgBL,SAEhCA,OAASpB,EAAE,iBAAkBmB,GAEjCxB,SAASgC,cAAc,WAAWC,WAAazB,OAAOC,KAAKyB,WAE3D1B,OAAOC,KAAK0B,QAAQjC,UACpBF,SAASC,eAAe,qBAAqBmC,MAAMC,QAAU,QAC7DrC,SAASC,eAAe,kBAAkBmC,MAAMC,QAAU,cAI/BX,IAA/BrB,EAAE,sBAAsB,UACnBiC,WAAajC,EAAE,sBAAsB,GAAGkC,aACxCC,WAAa3B,KAAK4B,MAAM/B,KAAK4B,WAAWE,iBACxCE,MAAQhC,KAAK4B,WAAWI,MAC5BC,MAAM,sBAKPnC,OAAOO,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AKoG,mBAAmB3G,QACzEM,OAAOC,KAAK+B,WAAW6E,iBAAmB7G,OAAOC,KAAKqG,mBAAmB5G,QACzEM,OAAOC,KAAK+B,WAAW8E,cAAgB9G,OAAOC,KAAKsG,gBAAgB7G,QACnEM,OAAOC,KAAK+B,WAAW+E,oBAAsB/G,OAAOC,KAAKuG,uBAAuB9G,QAChFM,OAAOC,KAAK+B,WAAWgF,iBAAmBhH,OAAOC,KAAKwG,mBAAmB/G,QACzEM,OAAOC,KAAK+B,WAAWiF,YAAcjH,OAAOC,KAAKyG,cAAchH,QAC/DM,OAAOC,KAAK+B,WAAWkF,YAAclH,OAAOC,KAAK0G,cAAcjH,QAC/DM,OAAOC,KAAK+B,WAAWqC,OAAS,8BAChClC,MAAM,sBAKNnC,OAAOO,QAAU,IAAIT,UAAUE,OAAOC,KAAK+B,YAAY,GAEvDhC,OAAOO,QAAQyC,OAAO,sBAG1B+E,OAAOM,cAAcnE,QAI7BrB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index e1d6635..e9bdd0a 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -15,8 +15,10 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - //alert("hello ggbq"); + +// alert("hello ggbq"); //debugger; // eslint-disable-line + //debugcode(); function stringfy(responsevars,ggbApplet){ //debugcode(); var responsestring = ''; @@ -29,18 +31,26 @@ }); return responsestring.replace(/\%$/,""); // possibly cut the last % works better with explode } +// function loadinit(appletParametersID) { +// debugcode(); +// var ggbDataset = document.getElementById(appletParametersID).dataset; // Twingsister +// function loadinit(appletParametersID) { +// var ggbDataset = document.getElementById(appletParametersID).dataset; + // Twingsister +//var GGBAppletstr; +// if (ggbDataset.isurlggb) { +// GGBAppletstr = ggbDataset.urlggb; +// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';} -define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { - /** - * Created by Christoph on 25.08.19. - */ + // } +//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { +define(['jquery'], function ($) { + // Created by Christoph on 25.08.19. const scalingContainers = {}; let resizeTimeout; - /** - * Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container. - */ + // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container. const resizeScalingContainer = () => { clearTimeout(resizeTimeout); resizeTimeout = setTimeout( @@ -123,7 +133,7 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG // Check if seed have been manually set. The default would be "no" if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') { var dice=Math.floor((Math.random() * 1000) + 1); - //alert(dice.toString()); + alert("random copy with "+dice.toString()); parameters.randomSeed = dice ; } else { parameters.randomSeed = ggbDataset.seed; @@ -155,10 +165,25 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG parameters.id = 'ggbApplet' + slot; var views = JSON.parse(ggbDataset.views); + // Check if GGBApplet have been manually set. + //debugcode(); + var GGBAppletname ; + if (ggbDataset.isurlggb) { + GGBAppletname = ggbDataset.urlggb; + } else {GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';} + //require.config({paths: {gb: GGBAppletname.slice(0,-3)}}); + //require(["gb"], function(gb) { + //import GGBApplet from GGBAppletname; + require([GGBAppletname],function (App){//); + var applet1; + applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); + applet1.inject(ggbDataset.div, "preferHTML5"); + }); + // GGBApplet= + // define([GGBAppletname], function (GGBobj) {return GGBobj;}); //alert("applet creation");debugger; - var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple); - // applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); - applet1.inject(ggbDataset.div, "preferHTML5"); + //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple); + //NO applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); $('#responseform').on('submit', this.getBase64andCheck); @@ -211,3 +236,5 @@ define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GG }; }); +//init(appletParametersID); +//} diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index ce5e6ff..c6ffd3e 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -10,11 +10,19 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // alert("hello ggbt"); - - define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { +var GGBAppletstr; + if (document.getElementById('id_isurlggb').checked) { + GGBAppletstr = document.getElementById('id_urlggb').value; + }else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';} + define(['jquery', GGBAppletstr], function ($, GGBApplet) { +// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { + //define(['jquery'], function ($) { /** * Created by Christoph on 25.08.19. */ + //var script = document.createElement('script'); + //script.src = 'https://www.geogebra.org/apps/deployggb.js'; + //document.getElementsByTagName('head')[0].appendChild(script); return { init: function() { @@ -59,20 +67,29 @@ this.ggbDataset = $('#applet_parameters')[0].dataset; this.parameters = JSON.parse(this.ggbDataset.parameters); this.views = this.ggbDataset.views; + alert("hello custom ggb 3"); + //debugcode(); + // if (document.getElementById('id_isurlggb').checked) { + //GGBApplet = document.getElementById('id_urlggb').value; + // } window.applet1 = new GGBApplet(this.parameters, this.views, true); // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.410.0/web3d"); this.lang = this.ggbDataset.lang; } + debugcode(); $('#id_loadapplet').on('click', function(e) { e.preventDefault(); - var id = $('#id_ggbturl').val().split("/").pop(); - if (id.indexOf("m") == 0) { + var httpurl = $('#id_ggbturl').val(); + var id = httpurl.split("/").pop(); + if(!httpurl.startsWith('http')){ + if (id.indexOf("m") == 0){ if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) { id = id.substr(1); } - } - window.GGBT.injectapplet(id); + } + window.GGBT.injectapplet({"material_id": id}); + }else{window.GGBT.injectapplet({"filename": httpurl});} }); $('#id_getvars').on('click', function(e) { @@ -113,21 +130,24 @@ }, callback: function(params) { - //debugcode(); + alert("other filename"); + debugcode(); var elementname = M.core_filepicker.instances[params['client_id']].options.elementname; $('#id_' + elementname).val(params.url); // inject applet to div layer + if(!params.file.startsWith('http')){ var id = (params.file).split(".")[0]; if (id.indexOf("m") == 0) { if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) { id = id.substr(1); } } - this.injectapplet(id); + this.injectapplet({"material_id": id}); + }else{window.GGBT.injectapplet({"filename": params.file});} }, - injectapplet: function(id) { - this.parameters = {"material_id": id}; + injectapplet: function(fileURL) { + this.parameters = fileURL ; this.parameters.language = this.lang; this.parameters.moodle = "editingQuestionOrSubmission"; // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit). @@ -135,6 +155,11 @@ document.getElementById('applet_container1').style.display = "block"; + alert("hello custom ggb 4"); + debugcode(); + // if (document.getElementById('id_isurlggb').checked) { + //GGBApplet = document.getElementById('id_urlggb').value; + // } window.applet1 = new GGBApplet(this.parameters, true); // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); @@ -262,6 +287,11 @@ window.GGBT.parameters[evt.target.id] = (evt.target.checked); $('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)); if (evt.target.id == "showToolBar" || evt.target.id == "showMenuBar" || evt.target.id == "showAlgebraInput") { + alert("hello custom ggb 5"); + //debugcode(); + // if (document.getElementById('id_isurlggb').checked) { + //GGBApplet = document.getElementById('id_urlggb').value; + // } window.applet1 = new GGBApplet(window.GGBT.parameters, true); // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1", "preferHTML5"); @@ -346,6 +376,11 @@ window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked; window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked; window.GGBT.parameters.moodle = "editingQuestionOrSubmission"; + alert("hello custom ggb 2"); + //debugcode(); + // if (document.getElementById('id_isurlggb').checked) { + //GGBApplet = document.getElementById('id_urlggb').value; + // } window.applet1 = new GGBApplet(window.GGBT.parameters, true); // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1"); diff --git a/db/install.xml b/db/install.xml index f40ee22..8572ef2 100644 --- a/db/install.xml +++ b/db/install.xml @@ -20,8 +20,12 @@ - + + + + + diff --git a/db/install.xml.old b/db/install.xml.old new file mode 100644 index 0000000..8572ef2 --- /dev/null +++ b/db/install.xml.old @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/db/upgrade.php b/db/upgrade.php index 1da2f1e..8b425ce 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,5 +92,32 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } + if ($oldversion < 2023080103) { +// TODO add urlggb urlggbact + // Define field of GGB and GGBACT + $table = new xmldb_table('qtype_geogebra_options'); + $field = new xmldb_field('isurlggb', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'seed'); + // Conditionally launch add field . + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + $field = new xmldb_field('urlggb', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'isurlggb'); + // Conditionally launch add field . + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + $field = new xmldb_field('isurlggbact', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'urlggb'); + // Conditionally launch add field . + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + $field = new xmldb_field('urlggbact', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'isurlggbact'); + // Conditionally launch add field . + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + // Geogebra savepoint reached. + upgrade_plugin_savepoint(true, 2023080103, 'qtype', 'geogebra'); + } return true; } diff --git a/edit_geogebra_form.php b/edit_geogebra_form.php index f307d1a..f6a3c11 100644 --- a/edit_geogebra_form.php +++ b/edit_geogebra_form.php @@ -140,6 +140,15 @@ protected function definition_inner($mform) { $mform->addElement('selectyesno', 'isexercise', get_string('isexercise', 'qtype_geogebra')); $mform->addHelpButton('isexercise', 'isexercise', 'qtype_geogebra'); + // Add urlggb + $mform->addElement('advcheckbox', 'isurlggb', get_string('isurlggbenable', 'qtype_geogebra'), + get_string('isurlggb', 'qtype_geogebra')); + $mform->setDefault('isurlggb', 0); + // If isurlggb true get a URL + $mform->addElement('text', 'urlggb', get_string('urlggb', 'qtype_geogebra')); + $mform->setType('urlggb', PARAM_URL); + $mform->addHelpButton('urlggb', 'urlggb', 'qtype_geogebra'); + $mform->hideIf('urlggb', 'isurlggb'); // Add randomization seed $mform->addElement('advcheckbox', 'seeditornot', get_string('seeditornotenable', 'qtype_geogebra'), get_string('seeditornot', 'qtype_geogebra')); @@ -553,7 +562,7 @@ private function add_applet_elements($mform) { EOD; $mform->addElement('html', $applet); } - //echo ""; + echo ""; $PAGE->requires->js_call_amd('qtype_geogebra/ggbt', 'init'); } @@ -618,6 +627,14 @@ private function add_geogebra_file($mform) { if (!empty($this->ggbparameters) && empty($this->ggbturl)) { $mform->setDefault('usefile', true); } + // Add urlggbact + $mform->addElement('advcheckbox', 'isurlggbact', get_string('isurlggbactenable', 'qtype_geogebra'), + get_string('isurlggbact', 'qtype_geogebra')); + $mform->setDefault('isurlggbact', 0); + $mform->addElement('text', 'urlggbact', get_string('urlggbact', 'qtype_geogebra')); + $mform->setType('urlggbact', PARAM_URL); + $mform->addHelpButton('urlggbact', 'urlggbact', 'qtype_geogebra'); + $mform->hideIf('urlggbact', 'isurlggbact'); } private function check_is_exercise_present($data, $errors) { diff --git a/lang/en/qtype_geogebra.php b/lang/en/qtype_geogebra.php index eebfa26..1367716 100644 --- a/lang/en/qtype_geogebra.php +++ b/lang/en/qtype_geogebra.php @@ -84,6 +84,16 @@ $string['show_tool_bar'] = 'Show Toolbar'; $string['stepzero'] = 'Increment is 0 for variable {$a}; either you haven\'t specified the slider’s increment or the element isn\'t a slider at all. You probably have to correct this in your GeoGebra file.'; $string['useafile'] = '... or use a ggb-file'; +$string['isurlggb'] = 'Add a custom URL for deployggb.js'; +$string['isurlggbenable'] = 'Enable a custom URL for deployggb.js'; +$string['isurlggb_help'] = 'Check to set a custom URL for deployggb.js'; +$string['isurlggbact'] = 'Add a URL for the ggb activity'; +$string['isurlggbactenable'] = 'Enable a custom URL for the ggb activity'; +$string['isurlggbact_help'] = 'Check to set a custom URL for the ggb activity'; +$string['urlggb'] = 'Custom URL for GGB'; +$string['urlggb_help'] = 'Alternative URL for the deployggb.js file, i.e. where the GeoGebra distribution is located. If it is set, this URL will be used instead of the default value set in module configuration. Usually, this field can be left empty.'; +$string['urlggbact'] = 'Custom deploy URL for an activity'; +$string['urlggbact_help'] = 'Alternative URL for an activity'; $string['valuecheckedfor'] = 'Boolean Object in GeoGebra which is used to check correctness.'; $string['variablenamewrong'] = 'A variable with that name could not be found in the GeoGebra file.'; $string['variableno'] = 'Variable {$a}'; diff --git a/question.php b/question.php index 71ca076..6c0aef4 100644 --- a/question.php +++ b/question.php @@ -49,6 +49,10 @@ class qtype_geogebra_question extends question_graded_automatically { public $height; public $seeditornot; public $seed; + public $isurlggb; + public $urlggb; + public $isurlggbact; + public $urlggbact; public $currentvals = array(); diff --git a/questiontype.php b/questiontype.php index 74c7643..fea90a1 100644 --- a/questiontype.php +++ b/questiontype.php @@ -43,7 +43,9 @@ class qtype_geogebra extends question_type { */ public function extra_question_fields() { return array('qtype_geogebra_options', 'ggbturl', 'ggbparameters', 'ggbviews', 'ggbcodebaseversion', 'ggbxml', - 'israndomized', 'randomizedvar', 'constraints', 'isexercise','forcedimensions','width','height', 'seeditornot','seed'); + 'israndomized', 'randomizedvar', 'constraints', 'isexercise','forcedimensions','width', + 'height', 'seeditornot','seed', + 'isurlggb','urlggb','isurlggbact','urlggbact'); } /** diff --git a/renderer.php b/renderer.php index 1e381d1..407852e 100644 --- a/renderer.php +++ b/renderer.php @@ -137,6 +137,10 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $seed = $question->seed ?: 0; $width = $question->width ?: 0; $height = $question->height ?: 0; + $isurlggb = $question->isurlggb ?: 0; + $urlggb = $question->urlggb ?: 0; + $isurlggbact = $question->isurlggbact ?: 0; + $urlggbact = $question->urlggbact ?: 0; $applet = <<ggbparameters @@ -157,11 +161,15 @@ public function formulation_and_controls(question_attempt $qa, question_display_ data-seed=$seed data-width=$width data-height=$height + data-isurlggb=$isurlggb + data-urlggb=$urlggb + data-isurlggbact=$isurlggbact + data-urlggbact=$urlggbact data-scalingcontainerclass=$scalingcontainerclass EOD; $result .= $applet; - //echo ""; + echo ""; $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); if ($qa->get_state() == question_state::$invalid) { diff --git a/version.php b/version.php index 2d77515..956ddbc 100644 --- a/version.php +++ b/version.php @@ -26,10 +26,10 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2022121200; +$plugin->version = 2023080103; $plugin->release = '1.13.3'; -$plugin->requires = 2018051702; +$plugin->requires = 2018051703; $plugin->dependencies = array( 'qtype_numerical' => 2014051200, 'qtype_calculated' => 2014051200, From 992e1dba63802c887c372bab449e0c366bfe1cda Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 15 Jan 2023 00:47:26 +0100 Subject: [PATCH 03/60] bug in seeding --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 11 ++++++++--- db/install.xml | 2 -- db/upgrade.php | 22 ++++++++++++---------- version.php | 2 +- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 259837e..aea28ad 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n\r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(dice.toString());\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n if (ggbDataset.isurlggb) {\r\n \tGGBAppletname = ggbDataset.urlggb;\r\n } else {GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';}\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","views","isurlggb","urlggb","require","App","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAe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kBAQhCpF,EAAE,iBAAiBqF,GAAG,SAAUnD,KAAKoD,mBAErCtF,EAAEU,SAASyB,eAAeL,WAAWsD,MAAMC,GAAG,aAAcnD,KAAKoD,wBAE5D5D,YAAYW,MAAQP,WAAWyC,UAC/B5C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAAS6C,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAInF,OAAOoB,KAAKN,YAAYsE,OAAQD,IAAK,KACjD1G,UAAYuB,OAAO,YAAcmF,WACZ,IAAd1G,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS0E,GAAG5C,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASwE,GAAG5C,IAAI9D,UAAUgE,uCAGXhD,OAAO4F,QAAQrF,OAAOoB,KAAKqC,+CAAiB,8DAA3D6B,0BAAKxG,4BACbL,UAAU8G,sBAAeD,gBAAOxG,QAOhCkB,OAAOoB,KAAKN,YAAYqE,GAAG5C,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa2G,GAAG1G,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n alert(\"entering the seed\");\r\n \tdebugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \talert(\"random copy with \"+dice.toString());\r\n \tdebugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n } else {\r\n \tGGBAppletname = ggbDataset.urlggb;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","alert","debugcode","seeditornot","randomSeed","seed","dice","Math","floor","random","toString","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","views","isurlggb","urlggb","require","App","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","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wE,GAAG/C,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa8G,GAAG7G,eAc3F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index e9bdd0a..7fcfd99 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -116,7 +116,7 @@ define(['jquery'], function ($) { } } }; - + // jquery doesn't handle the colon : but later we expect a jquery optject, so ... this.b64input[slot] = $(document.getElementById(ggbDataset.b64input)); this.ggbBase64[slot] = this.b64input[slot].val(); @@ -131,9 +131,12 @@ define(['jquery'], function ($) { } // Check if seed have been manually set. The default would be "no" + alert("entering the seed"); + debugcode(); if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') { var dice=Math.floor((Math.random() * 1000) + 1); alert("random copy with "+dice.toString()); + debugcode(); parameters.randomSeed = dice ; } else { parameters.randomSeed = ggbDataset.seed; @@ -168,9 +171,11 @@ define(['jquery'], function ($) { // Check if GGBApplet have been manually set. //debugcode(); var GGBAppletname ; - if (ggbDataset.isurlggb) { + if (!ggbDataset.isurlggb||ggbDataset.isurlggb === "0") { + GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js'; + } else { GGBAppletname = ggbDataset.urlggb; - } else {GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';} + } //require.config({paths: {gb: GGBAppletname.slice(0,-3)}}); //require(["gb"], function(gb) { //import GGBApplet from GGBAppletname; diff --git a/db/install.xml b/db/install.xml index 8572ef2..83d817f 100644 --- a/db/install.xml +++ b/db/install.xml @@ -24,8 +24,6 @@ - - diff --git a/db/upgrade.php b/db/upgrade.php index 8b425ce..9acdb28 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023080103) { + if ($oldversion < 2023160101) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -106,18 +106,20 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - $field = new xmldb_field('isurlggbact', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'urlggb'); + //$field = new xmldb_field('isurlggbact', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'urlggb'); // Conditionally launch add field . - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - $field = new xmldb_field('urlggbact', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'isurlggbact'); + //if (!$dbman->field_exists($table, $field)) { + //$field = new xmldb_field('isurlggbact', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'urlggb'); // Conditionally launch add field . - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } + // $dbman->add_field($table, $field); + //} + // $field = new xmldb_field('urlggbact', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'isurlggbact'); + // Conditionally launch add field . + //if (!$dbman->field_exists($table, $field)) { + // $dbman->add_field($table, $field); + //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023080103, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023160101, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 956ddbc..9024def 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023080103; +$plugin->version = 2023160101; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From e354043f37773f517105b108773e2a511bf68889 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 15 Jan 2023 23:37:08 +0100 Subject: [PATCH 04/60] Reqdme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0c2d001..c987140 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,6 @@ repository installed) - Load the Applet. Variables which could be randomized or can be used for checking correctness, will be extracted automatically - Choose the fraction which goes with the boolean variable - Save the question and use it for your quiz +- You can add a seed so that all random values are the same for all the class. +- You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) +- You can use an alternate source for the deploy.js file and a self hosted Geogebra codebase \ No newline at end of file From 59fbc91009693d8ba372ed60a0af4e2805674722 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 11:04:52 +0100 Subject: [PATCH 05/60] Codebase --- README.md | 2 +- edit_geogebra_form.php | 14 +++++++------- question.php | 4 ++-- questiontype.php | 4 +++- renderer.php | 8 ++++---- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c987140..1b60c7c 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ repository installed) - Save the question and use it for your quiz - You can add a seed so that all random values are the same for all the class. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) -- You can use an alternate source for the deploy.js file and a self hosted Geogebra codebase \ No newline at end of file +- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase \ No newline at end of file diff --git a/edit_geogebra_form.php b/edit_geogebra_form.php index f6a3c11..1ed8cc3 100644 --- a/edit_geogebra_form.php +++ b/edit_geogebra_form.php @@ -628,13 +628,13 @@ private function add_geogebra_file($mform) { $mform->setDefault('usefile', true); } // Add urlggbact - $mform->addElement('advcheckbox', 'isurlggbact', get_string('isurlggbactenable', 'qtype_geogebra'), - get_string('isurlggbact', 'qtype_geogebra')); - $mform->setDefault('isurlggbact', 0); - $mform->addElement('text', 'urlggbact', get_string('urlggbact', 'qtype_geogebra')); - $mform->setType('urlggbact', PARAM_URL); - $mform->addHelpButton('urlggbact', 'urlggbact', 'qtype_geogebra'); - $mform->hideIf('urlggbact', 'isurlggbact'); + //$mform->addElement('advcheckbox', 'isurlggbact', get_string('isurlggbactenable', 'qtype_geogebra'), + // get_string('isurlggbact', 'qtype_geogebra')); + //$mform->setDefault('isurlggbact', 0); + //$mform->addElement('text', 'urlggbact', get_string('urlggbact', 'qtype_geogebra')); + //$mform->setType('urlggbact', PARAM_URL); + //$mform->addHelpButton('urlggbact', 'urlggbact', 'qtype_geogebra'); + //$mform->hideIf('urlggbact', 'isurlggbact'); } private function check_is_exercise_present($data, $errors) { diff --git a/question.php b/question.php index 6c0aef4..f6b14cf 100644 --- a/question.php +++ b/question.php @@ -51,8 +51,8 @@ class qtype_geogebra_question extends question_graded_automatically { public $seed; public $isurlggb; public $urlggb; - public $isurlggbact; - public $urlggbact; + //public $isurlggbact; + //public $urlggbact; public $currentvals = array(); diff --git a/questiontype.php b/questiontype.php index fea90a1..b3db7eb 100644 --- a/questiontype.php +++ b/questiontype.php @@ -45,7 +45,9 @@ public function extra_question_fields() { return array('qtype_geogebra_options', 'ggbturl', 'ggbparameters', 'ggbviews', 'ggbcodebaseversion', 'ggbxml', 'israndomized', 'randomizedvar', 'constraints', 'isexercise','forcedimensions','width', 'height', 'seeditornot','seed', - 'isurlggb','urlggb','isurlggbact','urlggbact'); + 'isurlggb','urlggb' + //,'isurlggbact','urlggbact' + ); } /** diff --git a/renderer.php b/renderer.php index 407852e..f59de7c 100644 --- a/renderer.php +++ b/renderer.php @@ -139,8 +139,8 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $height = $question->height ?: 0; $isurlggb = $question->isurlggb ?: 0; $urlggb = $question->urlggb ?: 0; - $isurlggbact = $question->isurlggbact ?: 0; - $urlggbact = $question->urlggbact ?: 0; + //$isurlggbact = $question->isurlggbact ?: 0; + //$urlggbact = $question->urlggbact ?: 0; $applet = <<ggbparameters @@ -163,8 +163,8 @@ public function formulation_and_controls(question_attempt $qa, question_display_ data-height=$height data-isurlggb=$isurlggb data-urlggb=$urlggb - data-isurlggbact=$isurlggbact - data-urlggbact=$urlggbact + //data-isurlggbact=$isurlggbact + //data-urlggbact=$urlggbact data-scalingcontainerclass=$scalingcontainerclass EOD; From 011709dc4bd8ef7f1a3718438b121e060335af5a Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 11:10:59 +0100 Subject: [PATCH 06/60] README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b60c7c..10968b4 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ repository installed) - Save the question and use it for your quiz - You can add a seed so that all random values are the same for all the class. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) -- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase \ No newline at end of file +- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as \ No newline at end of file From 2bf8ac53ebe91e38773501daf7ae9798a7c01ef5 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 11:36:03 +0100 Subject: [PATCH 07/60] README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10968b4..8768039 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ repository installed) - Save the question and use it for your quiz - You can add a seed so that all random values are the same for all the class. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) -- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as \ No newline at end of file +- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as in [this repository](https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/deployggb.js) \ No newline at end of file From 78b2fff5c1b78df59c678eb3c3fb42e80e7086a5 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 14:11:58 +0100 Subject: [PATCH 08/60] deploy --- README.md | 4 +++- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 11 ++++++++++- amd/src/ggbt.js | 18 +++++++++++++++--- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8768039..b86a57a 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,6 @@ repository installed) - Save the question and use it for your quiz - You can add a seed so that all random values are the same for all the class. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) -- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as in [this repository](https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/deployggb.js) \ No newline at end of file +- You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as in [this repository](https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/deployggb.js). +In this case you should supply a comma separated string like "https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/,HTML5/5.0/web3d/,deployggb.js". +If a comma sepatated string like "A,B,C" is given then A+B must give the URL of displayggb.js and A+C is the codebase. \ No newline at end of file diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index aea28ad..3b32b02 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n alert(\"entering the seed\");\r\n \tdebugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \talert(\"random copy with \"+dice.toString());\r\n \tdebugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n } else {\r\n \tGGBAppletname = ggbDataset.urlggb;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","alert","debugcode","seeditornot","randomSeed","seed","dice","Math","floor","random","toString","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","views","isurlggb","urlggb","require","App","html5NoWebSimple","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC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L,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAASgD,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAItF,OAAOoB,KAAKN,YAAYyE,OAAQD,IAAK,KACjD7G,UAAYuB,OAAO,YAAcsF,WACZ,IAAd7G,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS6E,GAAG/C,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAAS2E,GAAG/C,IAAI9D,UAAUgE,uCAGXhD,OAAO+F,QAAQxF,OAAOoB,KAAKwC,+CAAiB,8DAA3D6B,0BAAK3G,4BACbL,UAAUiH,sBAAeD,gBAAO3G,QAOhCkB,OAAOoB,KAAKN,YAAYwE,GAAG/C,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa8G,GAAG7G,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n alert(\"entering the seed\");\r\n \tdebugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \talert(\"random copy with \"+dice.toString());\r\n \tdebugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!codebase===\"\"){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","alert","debugcode","seeditornot","randomSeed","seed","dice","Math","floor","random","toString","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","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GAAGvD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASmF,GAAGvD,IAAI9D,UAAUgE,uCAGXhD,OAAOuG,QAAQhG,OAAOoB,KAAKwC,+CAAiB,8DAA3DqC,0BAAKnH,4BACbL,UAAUyH,sBAAeD,gBAAOnH,QAOhCkB,OAAOoB,KAAKN,YAAYgF,GAAGvD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAasH,GAAGrH,eAc3F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 7fcfd99..21b2e6d 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -171,10 +171,18 @@ define(['jquery'], function ($) { // Check if GGBApplet have been manually set. //debugcode(); var GGBAppletname ; + var codebase ; + if (!ggbDataset.isurlggb||ggbDataset.isurlggb === "0") { GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js'; + codebase=""; } else { - GGBAppletname = ggbDataset.urlggb; + var parts=ggbDataset.urlggb.split(","); + var root=parts[0]; + var appl=parts[1]; + var base=parts[2]; + GGBAppletname = root+appl ; + codebase = root+base; } //require.config({paths: {gb: GGBAppletname.slice(0,-3)}}); //require(["gb"], function(gb) { @@ -182,6 +190,7 @@ define(['jquery'], function ($) { require([GGBAppletname],function (App){//); var applet1; applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); + if (!codebase===""){applet1.setHTML5Codebase(codebase)}; applet1.inject(ggbDataset.div, "preferHTML5"); }); // GGBApplet= diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index c6ffd3e..c5bc3b5 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -11,9 +11,18 @@ */ // alert("hello ggbt"); var GGBAppletstr; +var codebase; if (document.getElementById('id_isurlggb').checked) { - GGBAppletstr = document.getElementById('id_urlggb').value; - }else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';} + GGBAppletcode = document.getElementById('id_urlggb').value; + var parts=GGBAppletcode.split(","); + var rooturl=parts[0]; + var appl=parts[1]; + var base=parts[2]; + GGBAppletstr = rooturl+appl ; + codebase = rooturl+base; + }else { + GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js'; + codebase="";} define(['jquery', GGBAppletstr], function ($, GGBApplet) { // define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { //define(['jquery'], function ($) { @@ -73,7 +82,7 @@ var GGBAppletstr; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(this.parameters, this.views, true); - // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.410.0/web3d"); + if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} this.lang = this.ggbDataset.lang; } debugcode(); @@ -161,6 +170,7 @@ var GGBAppletstr; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(this.parameters, true); + if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1", "preferHTML5"); @@ -293,6 +303,7 @@ var GGBAppletstr; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(window.GGBT.parameters, true); + if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1", "preferHTML5"); } else { @@ -382,6 +393,7 @@ var GGBAppletstr; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(window.GGBT.parameters, true); + if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1"); }; From f888209a7b325ae1732db4dc7d453bc8dadab6ff Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 14:12:14 +0100 Subject: [PATCH 09/60] deploy --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index a1aea01..bc5d551 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -var GGBAppletstr;GGBAppletstr=document.getElementById("id_isurlggb").checked?document.getElementById("id_urlggb").value:"https://www.geogebra.org/apps/deployggb.js",define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,alert("hello custom ggb 3"),window.applet1=new GGBApplet(this.parameters,this.views,!0),this.lang=this.ggbDataset.lang),debugcode(),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){alert("other filename"),debugcode();var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",alert("hello custom ggb 4"),debugcode(),window.applet1=new GGBApplet(this.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(alert("hello custom ggb 5"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",alert("hello custom ggb 2"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +var GGBAppletstr,codebase;if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,alert("hello custom ggb 3"),window.applet1=new GGBApplet(this.parameters,this.views,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),debugcode(),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){alert("other filename"),debugcode();var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",alert("hello custom ggb 4"),debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(alert("hello custom ggb 5"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",alert("hello custom ggb 2"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 62e6e9f..b744cac 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletstr = document.getElementById('id_urlggb').value;\r\n }else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.410.0/web3d\");\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n alert(\"other filename\");\r\n debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n alert(\"hello custom ggb 4\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","document","getElementById","checked","value","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","alert","lang","debugcode","httpurl","id","split","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aAEiBA,aADGC,SAASC,eAAe,eAAeC,QAC3BF,SAASC,eAAe,aAAaE,MAC7B,6CAC3CC,6BAAO,CAAC,SAAUL,eAAe,SAAUM,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAASpB,SAASqB,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjBtB,SAASC,eAAe,oBACzBE,OACfK,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,O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 No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n alert(\"other filename\");\r\n debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n alert(\"hello custom ggb 4\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","alert","setHTML5Codebase","lang","debugcode","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACgB,GAAIC,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,IACf,MACDX,aAAe,6CACfC,SAAS,GAC7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gB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+E,OAAOM,cAAcnE,QAI7BrB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file From b93801b802f3ee4dce96738e8b953aaa9f336f1b Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 14:22:09 +0100 Subject: [PATCH 10/60] codebase --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 2 +- amd/src/ggbt.js | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index bc5d551..cfa596a 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -var GGBAppletstr,codebase;if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,alert("hello custom ggb 3"),window.applet1=new GGBApplet(this.parameters,this.views,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),debugcode(),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){alert("other filename"),debugcode();var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",alert("hello custom ggb 4"),debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(alert("hello custom ggb 5"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",alert("hello custom ggb 2"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""===!codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +var GGBAppletstr,codebase;if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,alert("hello custom ggb 3"),window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),debugcode(),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){alert("other filename"),debugcode();var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",alert("hello custom ggb 4"),debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(alert("hello custom ggb 5"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",alert("hello custom ggb 2"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index b744cac..8fe695d 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n alert(\"other filename\");\r\n debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n alert(\"hello custom ggb 4\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!codebase===\"\"){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","alert","setHTML5Codebase","lang","debugcode","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACgB,GAAIC,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,IACf,MACDX,aAAe,6CACfC,SAAS,GAC7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFrB,OAAOC,KAAKqB,gBAAgBzB,EAAEuB,EAAEG,YAEpCvB,OAAOC,KAAKqB,gBAAgBL,SAEhCA,OAASpB,EAAE,iBAAkBmB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ent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n alert(\"other filename\");\r\n debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n alert(\"hello custom ggb 4\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","alert","setHTML5Codebase","lang","debugcode","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACgB,GAAIC,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,IACf,MACDX,aAAe,6CACfC,SAAS,GAC7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFrB,OAAOC,K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F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 21b2e6d..d979a47 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -190,7 +190,7 @@ define(['jquery'], function ($) { require([GGBAppletname],function (App){//); var applet1; applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); - if (!codebase===""){applet1.setHTML5Codebase(codebase)}; + if ((!codebase==="")){applet1.setHTML5Codebase(codebase)}; applet1.inject(ggbDataset.div, "preferHTML5"); }); // GGBApplet= diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index c5bc3b5..dc53250 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -82,7 +82,9 @@ var codebase; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(this.parameters, this.views, true); - if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} + if(!(codebase==="")){ + window.applet1.setHTML5Codebase(codebase); + } this.lang = this.ggbDataset.lang; } debugcode(); @@ -170,7 +172,7 @@ var codebase; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(this.parameters, true); - if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} + if(!(codebase==="")){window.applet1.setHTML5Codebase(codebase);} // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1", "preferHTML5"); @@ -303,7 +305,7 @@ var codebase; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(window.GGBT.parameters, true); - if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} + if(!(codebase==="")){window.applet1.setHTML5Codebase(codebase);} // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1", "preferHTML5"); } else { @@ -393,7 +395,7 @@ var codebase; //GGBApplet = document.getElementById('id_urlggb').value; // } window.applet1 = new GGBApplet(window.GGBT.parameters, true); - if(!codebase===""){window.applet1.setHTML5Codebase(codebase);} + if(!(codebase==="")){window.applet1.setHTML5Codebase(codebase);} // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); window.applet1.inject("applet_container1"); }; From ef29418941df450f609412db462656e78167b7b2 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 14:22:22 +0100 Subject: [PATCH 11/60] codebase --- amd/build/ggbq.min.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/build/ggbq.min.js.map b/amd/build/ggbq.min.js.map index 2a6e19e..7f9a662 100644 --- a/amd/build/ggbq.min.js.map +++ b/amd/build/ggbq.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n alert(\"entering the seed\");\r\n \tdebugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \talert(\"random copy with \"+dice.toString());\r\n \tdebugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!codebase===\"\"){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","alert","debugcode","seeditornot","randomSeed","seed","dice","Math","floor","random","toString","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAG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GAAGrH,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n alert(\"entering the seed\");\r\n \tdebugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \talert(\"random copy with \"+dice.toString());\r\n \tdebugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if ((!codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","alert","debugcode","seeditornot","randomSeed","seed","dice","Math","floor","random","toString","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,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aAAc9D,KAAK+D,wBAE5DvE,YAAYW,MAAQP,WAAW4C,UAC/B/C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAASwD,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAI9F,OAAOoB,KAAKN,YAAYiF,OAAQD,IAAK,KACjDrH,UAAYuB,OAAO,YAAc8F,WACZ,IAAdrH,UAA2B,CAClCuB,OAAOoB,KAAKX,SAASqF,GAAGvD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASmF,GAAGvD,IAAI9D,UAAUgE,uCAGXhD,OAAOuG,QAAQhG,OAAOoB,KAAKwC,+CAAiB,8DAA3DqC,0BAAKnH,4BACbL,UAAUyH,sBAAeD,gBAAOnH,QAOhCkB,OAAOoB,KAAKN,YAAYgF,GAAGvD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAasH,GAAGrH,eAc3F"} \ No newline at end of file From 95ebbbc5644b6a3d8b05902654aa88515cef767c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 16 Jan 2023 14:26:58 +0100 Subject: [PATCH 12/60] deploy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b86a57a..f523f9a 100644 --- a/README.md +++ b/README.md @@ -25,5 +25,5 @@ repository installed) - You can add a seed so that all random values are the same for all the class. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) - You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as in [this repository](https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/deployggb.js). -In this case you should supply a comma separated string like "https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/,HTML5/5.0/web3d/,deployggb.js". +In this case you should supply a comma separated string like "https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/,deployggb.js,HTML5/5.0/web3d". If a comma sepatated string like "A,B,C" is given then A+B must give the URL of displayggb.js and A+C is the codebase. \ No newline at end of file From 32b62f37b0591bbef35604c3fbdc68b80b0a5cdd Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 17 Jan 2023 18:54:03 +0100 Subject: [PATCH 13/60] Added provision for URLed .ggb --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 8 ++++---- amd/src/ggbt.js | 16 ++++++++-------- renderer.php | 2 -- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 3b32b02..90c39d6 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n alert(\"entering the seed\");\r\n \tdebugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \talert(\"random copy with \"+dice.toString());\r\n \tdebugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if ((!codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","alert","debugcode","seeditornot","randomSeed","seed","dice","Math","floor","random","toString","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,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AiBb,UAClDW,QAAQG,OAAOhE,WAAWiE,IAAK,kBAQhC/F,EAAE,iBAAiBgG,GAAG,SAAU9D,KAAK+D,mBAErCjG,EAAEU,SAASyB,eAAeL,WAAWiE,MAAMC,GAAG,aAAc9D,KAAK+D,wBAE5DvE,YAAYW,MAAQP,WAAW4C,UAC/B/C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAASwD,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAI9F,OAAOoB,KAAKN,YAAYiF,OAAQD,IAAK,KACjDrH,UAAYuB,OAAO,YAAc8F,WACZ,IAAdrH,UAA2B,CAClCuB,OAAOoB,KAAKX,SAASqF,GAAGvD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASmF,GAAGvD,IAAI9D,UAAUgE,uCAGXhD,OAAOuG,QAAQhG,OAAOoB,KAAKwC,+CAAiB,8DAA3DqC,0BAAKnH,4BACbL,UAAUyH,sBAAeD,gBAAOnH,QAOhCkB,OAAOoB,KAAKN,YAAYgF,GAAGvD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAasH,GAAGrH,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if ((!codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAErCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAA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AO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAI3F,OAAOoB,KAAKN,YAAY8E,OAAQD,IAAK,KACjDlH,UAAYuB,OAAO,YAAc2F,WACZ,IAAdlH,UAA2B,CAClCuB,OAAOoB,KAAKX,SAASkF,GAAGpD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASgF,GAAGpD,IAAI9D,UAAUgE,uCAGXhD,OAAOoG,QAAQ7F,OAAOoB,KAAKqC,+CAAiB,8DAA3DqC,0BAAKhH,4BACbL,UAAUsH,sBAAeD,gBAAOhH,QAOhCkB,OAAOoB,KAAKN,YAAY6E,GAAGpD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAamH,GAAGlH,eAc3F"} \ No newline at end of file diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index cfa596a..7e77ead 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -var GGBAppletstr,codebase;if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,alert("hello custom ggb 3"),window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),debugcode(),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){alert("other filename"),debugcode();var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",alert("hello custom ggb 4"),debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(alert("hello custom ggb 5"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",alert("hello custom ggb 2"),window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +var GGBAppletstr,codebase;if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 8fe695d..f966959 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n alert(\"other filename\");\r\n debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n alert(\"hello custom ggb 4\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","alert","setHTML5Codebase","lang","debugcode","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACgB,GAAIC,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,IACf,MACDX,aAAe,6CACfC,SAAS,GAC7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFrB,OAAOC,KAAKqB,gBAAgBzB,EAAEuB,EAAEG,YAEpCvB,OAAOC,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at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACgB,GAAIC,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,IACf,MACDX,aAAe,6CACfC,SAAS,GAC7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE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ASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index d979a47..934c9d2 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -131,12 +131,12 @@ define(['jquery'], function ($) { } // Check if seed have been manually set. The default would be "no" - alert("entering the seed"); - debugcode(); + //alert("entering the seed"); + //debugcode(); if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') { var dice=Math.floor((Math.random() * 1000) + 1); - alert("random copy with "+dice.toString()); - debugcode(); + //alert("random copy with "+dice.toString()); + //debugcode(); parameters.randomSeed = dice ; } else { parameters.randomSeed = ggbDataset.seed; diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index dc53250..abe1d1b 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -76,7 +76,7 @@ var codebase; this.ggbDataset = $('#applet_parameters')[0].dataset; this.parameters = JSON.parse(this.ggbDataset.parameters); this.views = this.ggbDataset.views; - alert("hello custom ggb 3"); + //alert("hello custom ggb 3"); //debugcode(); // if (document.getElementById('id_isurlggb').checked) { //GGBApplet = document.getElementById('id_urlggb').value; @@ -87,7 +87,7 @@ var codebase; } this.lang = this.ggbDataset.lang; } - debugcode(); + //debugcode(); $('#id_loadapplet').on('click', function(e) { e.preventDefault(); @@ -141,8 +141,8 @@ var codebase; }, callback: function(params) { - alert("other filename"); - debugcode(); + //alert("other filename"); + //debugcode(); var elementname = M.core_filepicker.instances[params['client_id']].options.elementname; $('#id_' + elementname).val(params.url); // inject applet to div layer @@ -166,8 +166,8 @@ var codebase; document.getElementById('applet_container1').style.display = "block"; - alert("hello custom ggb 4"); - debugcode(); + //alert("hello custom ggb 4"); + //debugcode(); // if (document.getElementById('id_isurlggb').checked) { //GGBApplet = document.getElementById('id_urlggb').value; // } @@ -299,7 +299,7 @@ var codebase; window.GGBT.parameters[evt.target.id] = (evt.target.checked); $('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)); if (evt.target.id == "showToolBar" || evt.target.id == "showMenuBar" || evt.target.id == "showAlgebraInput") { - alert("hello custom ggb 5"); + // alert("hello custom ggb 5"); //debugcode(); // if (document.getElementById('id_isurlggb').checked) { //GGBApplet = document.getElementById('id_urlggb').value; @@ -389,7 +389,7 @@ var codebase; window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked; window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked; window.GGBT.parameters.moodle = "editingQuestionOrSubmission"; - alert("hello custom ggb 2"); + // alert("hello custom ggb 2"); //debugcode(); // if (document.getElementById('id_isurlggb').checked) { //GGBApplet = document.getElementById('id_urlggb').value; diff --git a/renderer.php b/renderer.php index f59de7c..e55bff6 100644 --- a/renderer.php +++ b/renderer.php @@ -163,8 +163,6 @@ public function formulation_and_controls(question_attempt $qa, question_display_ data-height=$height data-isurlggb=$isurlggb data-urlggb=$urlggb - //data-isurlggbact=$isurlggbact - //data-urlggbact=$urlggbact data-scalingcontainerclass=$scalingcontainerclass EOD; From 3fb181ea19a1b9c9b6ab55dec4b29c868ba21e40 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 17 Jan 2023 19:44:16 +0100 Subject: [PATCH 14/60] problems when using old tests --- amd/src/ggbt.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index abe1d1b..edf7bb0 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -12,6 +12,7 @@ // alert("hello ggbt"); var GGBAppletstr; var codebase; + if (document.getElementById('id_isurlggb')!== null) { if (document.getElementById('id_isurlggb').checked) { GGBAppletcode = document.getElementById('id_urlggb').value; var parts=GGBAppletcode.split(","); @@ -23,6 +24,7 @@ var codebase; }else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js'; codebase="";} + } define(['jquery', GGBAppletstr], function ($, GGBApplet) { // define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) { //define(['jquery'], function ($) { From 5cb5e9b0ee60dad47199c4fbb76d9492802a126f Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 17 Jan 2023 19:46:48 +0100 Subject: [PATCH 15/60] bug for old questions --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- db/upgrade.php | 4 ++-- version.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index 7e77ead..ddf7b07 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -var GGBAppletstr,codebase;if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index f966959..8ba4cdb 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","par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,OAAO0G,OAAOC,QAAQ,6CAA8C,IACvFlI,OAAOC,KAAK+B,WAAa,WAAcgG,QACvChI,OAAOC,KAAK+B,WAAW0E,iBAAmB1G,OAAOC,KAAKkG,mBAAmB/G,QACzEY,OAAOC,KAAK+B,WAAW2E,iBAAmB3G,OAAOC,KAAKmG,mBAAmBhH,QACzEY,OAAOC,KAAK+B,WAAW4E,cAAgB5G,OAAOC,KAAKoG,gBAAgBjH,QACnEY,OAAOC,KAAK+B,WAAW6E,oBAAsB7G,OAAOC,KAAKqG,uBAAuBlH,QAChFY,OAAOC,KAAK+B,WAAW8E,iBAAmB9G,OAAOC,KAAKsG,mBAAmBnH,QACzEY,OAAOC,KAAK+B,WAAW+E,YAAc/G,OAAOC,KAAKuG,cAAcpH,QAC/DY,OAAOC,KAAK+B,WAAWgF,YAAchH,OAAOC,KAAKwG,cAAcrH,QAC/DY,OAAOC,KAAK+B,WAAWmC,OAAS,8BAMhCnE,OAAOO,QAAU,IAAIT,UAAUE,OAAOC,KAAK+B,YAAY,GAC3C,KAAX/C,UAAgBe,OAAOO,QAAQ4B,iBAAiBlD,UAEjDe,OAAOO,QAAQuC,OAAO,sBAG1B+E,OAAOM,cAAcnE,QAI7BrB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFrB,OAAOC,KAAKqB,gBAAgBzB,EAAEuB,EAAEG,YAEpCvB,OAAOC,KAAKqB,gBAAgBL,SAEhCA,OAASpB,EAAE,iBAAkBmB,GAEjC9B,SAASsC,cAAc,WAAWC,WAAazB,OAAOC,KAAKyB,WAE3D1B,OAAOC,KAAK0B,QAAQvC,UACpBF,SAASC,eAAe,qBAAqByC,MAAMC,QAAU,QAC7D3C,SAASC,eAAe,kBAAkByC,MAAMC,QAAU,cAI/BX,IAA/BrB,EAAE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QAAQwF,YAEpBU,OAAS,IAAIC,WACjBD,OAAOE,OAAS,SAASnC,WACjBoC,OAASpC,MAAMrE,OAAO0G,OAAOC,QAAQ,6CAA8C,IACvFlI,OAAOC,KAAK+B,WAAa,WAAcgG,QACvChI,OAAOC,KAAK+B,WAAW0E,iBAAmB1G,OAAOC,KAAKkG,mBAAmB/G,QACzEY,OAAOC,KAAK+B,WAAW2E,iBAAmB3G,OAAOC,KAAKmG,mBAAmBhH,QACzEY,OAAOC,KAAK+B,WAAW4E,cAAgB5G,OAAOC,KAAKoG,gBAAgBjH,QACnEY,OAAOC,KAAK+B,WAAW6E,oBAAsB7G,OAAOC,KAAKqG,uBAAuBlH,QAChFY,OAAOC,KAAK+B,WAAW8E,iBAAmB9G,OAAOC,KAAKsG,mBAAmBnH,QACzEY,OAAOC,KAAK+B,WAAW+E,YAAc/G,OAAOC,KAAKuG,cAAcpH,QAC/DY,OAAOC,KAAK+B,WAAWgF,YAAchH,OAAOC,KAAKwG,cAAcrH,QAC/DY,OAAOC,KAAK+B,WAAWmC,OAAS,8BAMhCnE,OAAOO,QAAU,IAAIT,UAAUE,OAAOC,KAAK+B,YAAY,GAC3C,KAAX/C,UAAgBe,OAAOO,QAAQ4B,iBAAiBlD,UAEjDe,OAAOO,QAAQuC,OAAO,sBAG1B+E,OAAOM,cAAcnE,QAI7BrB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/db/upgrade.php b/db/upgrade.php index 9acdb28..7285bc5 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023160101) { + if ($oldversion < 2023170101) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023160101, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023170101, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 9024def..51f1f69 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023160101; +$plugin->version = 2023170101; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From e2393ef5424ad85153c52c3f7ca872a7ef720dc9 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 17 Jan 2023 21:20:24 +0100 Subject: [PATCH 16/60] bug in the renderer --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 4 ++-- db/upgrade.php | 4 ++-- version.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 90c39d6..43cb441 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if ((!codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,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MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAASqD,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAI3F,OAAOoB,KAAKN,YAAY8E,OAAQD,IAAK,KACjDlH,UAAYuB,OAAO,YAAc2F,WACZ,IAAdlH,UAA2B,CAClCuB,OAAOoB,KAAKX,SAASkF,GAAGpD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASgF,GAAGpD,IAAI9D,UAAUgE,uCAGXhD,OAAOoG,QAAQ7F,OAAOoB,KAAKqC,+CAAiB,8DAA3DqC,0BAAKhH,4BACbL,UAAUsH,sBAAeD,gBAAOhH,QAOhCkB,OAAOoB,KAAKN,YAAY6E,GAAGpD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAamH,GAAGlH,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAErCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAAU,GAC3BtD,UAAYuB,OAAO2B,aACnBK,QAAUC,KAAKC,MAAMlC,OAAOoB,KAAKP,YAAYiB,SAC5C,IAAIK,SAASH,QACdvD,UAAU2D,SAASD,MAAOH,Q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C,OAAOoB,KAAKT,SAASiF,GAAGrD,IAAI9D,UAAUgE,uCAGXhD,OAAOqG,QAAQ9F,OAAOoB,KAAKqC,+CAAiB,8DAA3DsC,0BAAKjH,4BACbL,UAAUuH,sBAAeD,gBAAOjH,QAOhCkB,OAAOoB,KAAKN,YAAY8E,GAAGrD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAaoH,GAAGnH,eAc3F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 934c9d2..75424ae 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -169,7 +169,7 @@ define(['jquery'], function ($) { var views = JSON.parse(ggbDataset.views); // Check if GGBApplet have been manually set. - //debugcode(); + debugcode(); var GGBAppletname ; var codebase ; @@ -190,7 +190,7 @@ define(['jquery'], function ($) { require([GGBAppletname],function (App){//); var applet1; applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); - if ((!codebase==="")){applet1.setHTML5Codebase(codebase)}; + if (!(codebase==="")){applet1.setHTML5Codebase(codebase)}; applet1.inject(ggbDataset.div, "preferHTML5"); }); // GGBApplet= diff --git a/db/upgrade.php b/db/upgrade.php index 7285bc5..fb86ed1 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023170101) { + if ($oldversion < 2023170102) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023170101, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023170102, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 51f1f69..265d725 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023170101; +$plugin->version = 2023170102; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 671b237ce04e1b0891127583e049844808f4d8e5 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 17 Jan 2023 22:46:31 +0100 Subject: [PATCH 17/60] Help messages --- lang/en/qtype_geogebra.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lang/en/qtype_geogebra.php b/lang/en/qtype_geogebra.php index 1367716..02af024 100644 --- a/lang/en/qtype_geogebra.php +++ b/lang/en/qtype_geogebra.php @@ -87,13 +87,13 @@ $string['isurlggb'] = 'Add a custom URL for deployggb.js'; $string['isurlggbenable'] = 'Enable a custom URL for deployggb.js'; $string['isurlggb_help'] = 'Check to set a custom URL for deployggb.js'; -$string['isurlggbact'] = 'Add a URL for the ggb activity'; -$string['isurlggbactenable'] = 'Enable a custom URL for the ggb activity'; -$string['isurlggbact_help'] = 'Check to set a custom URL for the ggb activity'; +//$string['isurlggbact'] = 'Add a URL for the ggb activity'; +//$string['isurlggbactenable'] = 'Enable a custom URL for the ggb activity'; +//$string['isurlggbact_help'] = 'Check to set a custom URL for the ggb activity'; $string['urlggb'] = 'Custom URL for GGB'; -$string['urlggb_help'] = 'Alternative URL for the deployggb.js file, i.e. where the GeoGebra distribution is located. If it is set, this URL will be used instead of the default value set in module configuration. Usually, this field can be left empty.'; -$string['urlggbact'] = 'Custom deploy URL for an activity'; -$string['urlggbact_help'] = 'Alternative URL for an activity'; +$string['urlggb_help'] = 'Alternative URL for the deployggb.js file, i.e. where the GeoGebra distribution is located. If it is set, this URL will be used instead of the default value set in module configuration. Usually, this field can be left empty. The string must contain three comma separated fields A,B,C and A+B is the URL of deployggb.js A+C is the codebase. For instance like in https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/,deployggb.js,HTML5/5.0/web3d'; +//$string['urlggbact'] = 'Custom deploy URL for an activity'; +//$string['urlggbact_help'] = 'Alternative URL for an activity'; $string['valuecheckedfor'] = 'Boolean Object in GeoGebra which is used to check correctness.'; $string['variablenamewrong'] = 'A variable with that name could not be found in the GeoGebra file.'; $string['variableno'] = 'Variable {$a}'; From 91d5044ce3140f8bb4a1c281ab5e7a8f3bdfb457 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 21 Jan 2023 12:13:18 +0100 Subject: [PATCH 18/60] applet options remembered --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 2 +- amd/src/ggbt.js | 17 +++++++++++------ edit_geogebra_form.php | 4 ++-- renderer.php | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index ddf7b07..82bfe59 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?window.GGBT.injectapplet({filename:httpurl}):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="none",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),"undefined"!=typeof parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="none",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); +var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 8ba4cdb..cb2130f 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"none\";\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"none\";\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,IAAIQ,OAAOE,UAEjB5B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKc,sBAGZC,EAAI,EACJC,OAASpB,EAAE,cAAgBmB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFrB,O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sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACrBN,EAAE,+BAA+BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQC,kBACnEX,EAAE,0BAA0BO,IAAIC,KAAKC,UAAUN,OAAOO,QAAQE,aAC9DZ,EAAE,oCAAoCO,IAAIJ,OAAOO,QAAQG,gCAE1B,IAAnBR,KAAKS,UAA2B,KACpCC,OAAS1B,SAAS2B,UACtBhB,EAAE,wBAAwBO,I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AAU,IAAIT,UAAUE,OAAOC,KAAK+B,YAAY,GAC3C,KAAX/C,UAAgBe,OAAOO,QAAQ4B,iBAAiBlD,UAEjDe,OAAOO,QAAQuC,OAAO,sBAG1B+E,OAAOM,cAAcnE,QAI7BrB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 75424ae..564a626 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -169,7 +169,7 @@ define(['jquery'], function ($) { var views = JSON.parse(ggbDataset.views); // Check if GGBApplet have been manually set. - debugcode(); + //debugcode(); // var GGBAppletname ; var codebase ; diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index edf7bb0..440ea79 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -38,7 +38,7 @@ var codebase; init: function() { - //debugcode(); + //debugcode();// window.GGBT = this; window.ggbAppletOnLoad = function() { $('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())); @@ -102,7 +102,9 @@ var codebase; } } window.GGBT.injectapplet({"material_id": id}); - }else{window.GGBT.injectapplet({"filename": httpurl});} + }else{ + document.getElementById('applet_options').style.display = "flex"; + window.GGBT.injectapplet({"filename": httpurl});} }); $('#id_getvars').on('click', function(e) { @@ -137,7 +139,7 @@ var codebase; if (this.usefile.checked) { document.getElementById('applet_options').style.display = "block"; } else { - document.getElementById('applet_options').style.display = "none"; + document.getElementById('applet_options').style.display = "flex"; // ex none } this.initoptions(); }, @@ -278,7 +280,7 @@ var codebase; this.show_menu_bar = document.getElementById('showMenuBar'); this.show_tool_bar = document.getElementById('showToolBar'); - if (typeof parameters !== 'undefined') { + if (typeof this.parameters !== 'undefined') { this.enable_right_click.checked = this.parameters.enableRightClick; this.enable_label_drags.checked = this.parameters.enableLabelDrags; this.show_reset_icon.checked = this.parameters.showResetIcon; @@ -286,6 +288,9 @@ var codebase; this.show_algebra_input.checked = this.parameters.showAlgebraInput; this.show_menu_bar.checked = this.parameters.showMenuBar; this.show_tool_bar.checked = this.parameters.showToolBar; + //debugcode(); + //document.getElementById('showToolBar').checked=this.show_tool_bar.checked; + } this.enable_right_click.addEventListener('change', this.handlesettingschanged, false); @@ -318,7 +323,7 @@ var codebase; handleusefile: function() { if (!window.GGBT.usefile.checked) { document.getElementById('applet_container1').style.display = "none"; - document.getElementById('applet_options').style.display = "none"; + document.getElementById('applet_options').style.display = "flex"; //ex none } else { document.getElementById('id_ggbturl').value = ""; // document.getElementById('applet_container1').style.display = "block"; @@ -328,7 +333,7 @@ var codebase; handleggbdisable: function() { if (!window.GGBT.ggbcheckb.checked) { document.getElementById('applet_container1').style.display = "none"; - document.getElementById('applet_options').style.display = "none"; + document.getElementById('applet_options').style.display = "flex"; //ex none if (window.GGBT.usefile.checked) { window.GGBT.usefile.click(); } diff --git a/edit_geogebra_form.php b/edit_geogebra_form.php index 1ed8cc3..9933cb7 100644 --- a/edit_geogebra_form.php +++ b/edit_geogebra_form.php @@ -587,9 +587,9 @@ private function add_applet_options($mform) {

- +
- +

diff --git a/renderer.php b/renderer.php index e55bff6..30718ae 100644 --- a/renderer.php +++ b/renderer.php @@ -167,7 +167,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ EOD; $result .= $applet; - echo ""; + //echo ""; $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); if ($qa->get_state() == question_state::$invalid) { From a5f998879f3e2e6e065b4f2f4cc4b571e03d6b0d Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 21 Jan 2023 12:14:25 +0100 Subject: [PATCH 19/60] more applet options remembered --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 43cb441..ef314cd 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode();\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAA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AAOoB,KAAK5C,aAAaoH,GAAGnH,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,S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AWyC,UAC/B5C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAASqD,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,eAEV,IAAIU,EAAI,EAAGA,EAAI3F,OAAOoB,KAAKN,YAAY8E,OAAQD,IAAK,KACjDlH,UAAYuB,OAAO,YAAc2F,WACZ,IAAdlH,UAA2B,CAClCuB,OAAOoB,KAAKX,SAASkF,GAAGpD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASgF,GAAGpD,IAAI9D,UAAUgE,uCAGXhD,OAAOoG,QAAQ7F,OAAOoB,KAAKqC,+CAAiB,8DAA3DqC,0BAAKhH,4BACbL,UAAUsH,sBAAeD,gBAAOhH,QAOhCkB,OAAOoB,KAAKN,YAAY6E,GAAGpD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAamH,GAAGlH,eAc3F"} \ No newline at end of file From 0774ea8368bbab5afd12ab1019e5dad916d2b390 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 22 Jan 2023 11:00:48 +0100 Subject: [PATCH 20/60] morning reset --- db/upgrade.php | 4 ++-- version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index fb86ed1..911ee46 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023170102) { + if ($oldversion < 2023170103) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023170102, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023170103, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 265d725..b8353d1 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023170102; +$plugin->version = 2023170103; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 88231b3b28e8b6e4e923e13f68625dcf26615fdc Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 22 Jan 2023 16:45:26 +0100 Subject: [PATCH 21/60] parameters global --- amd/src/ggbq.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 564a626..355757b 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -75,7 +75,7 @@ define(['jquery'], function ($) { responsevars: [], exerciseresultinput: [], qdiv: [], - //parameters: {}, + parameters: {}, //before not global ggbDataset: [], //applet1, @@ -106,7 +106,7 @@ define(['jquery'], function ($) { window.GGBQ.b64input[id].val(ggbApplet.getBase64()); window.GGBQ.xmlinput[id].val(ggbApplet.getXML()); - + window.GGBQ.qdiv[id].style.visibility = 'visible'; if (window.GGBQ.answerinput[id].val() == '') { // Twingsister @@ -125,7 +125,9 @@ define(['jquery'], function ($) { this.ggbxml[slot] = this.xmlinput[slot].val(); this.qdiv[slot] = $("#q" + (slot) + " .qtext")[0]; - var parameters = JSON.parse(ggbDataset.parameters); + + //var parameters = JSON.parse(ggbDataset.parameters); + parameters = JSON.parse(ggbDataset.parameters); if (this.ggbBase64[slot] != '') { parameters.ggbBase64 = this.ggbBase64[slot]; } From 5ec24587b80107c5b3724f8f269bf87c69b3f640 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 22 Jan 2023 16:45:47 +0100 Subject: [PATCH 22/60] parameters global 2 --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index ef314cd..3c1c33a 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {},\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n\r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAErCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAAU,GAC3BtD,UAAYuB,OAAO2B,aACnBK,QAAUC,KAAKC,MAAMlC,OAAOo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,CAClCuB,OAAOoB,KAAKX,SAASkF,GAAGpD,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASgF,GAAGpD,IAAI9D,UAAUgE,uCAGXhD,OAAOoG,QAAQ7F,OAAOoB,KAAKqC,+CAAiB,8DAA3DqC,0BAAKhH,4BACbL,UAAUsH,sBAAeD,gBAAOhH,QAOhCkB,OAAOoB,KAAKN,YAAY6E,GAAGpD,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAamH,GAAGlH,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n //var parameters = JSON.parse(ggbDataset.parameters);\r\n parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","parameters","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,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100 Subject: [PATCH 23/60] version oush global parameters --- db/upgrade.php | 4 ++-- version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index 911ee46..458ca6b 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023170103) { + if ($oldversion < 2023170104) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023170103, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023170104, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index b8353d1..acb4fbb 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023170103; +$plugin->version = 2023170104; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From b16bab098d146b9128a82955a4c2acb0e99ed619 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 30 Jan 2023 23:19:55 +0100 Subject: [PATCH 24/60] Beta full --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/build/ggbt.min.js | 4 +-- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 34 +++++++++++++----- amd/src/ggbt.js | 70 +++++++++++++++++++++++++++++++++++--- db/upgrade.php | 4 +-- edit_geogebra_form.php | 9 +++-- lang/en/qtype_geogebra.php | 3 ++ question.php | 5 +-- renderer.php | 6 ++-- version.php | 2 +- 12 files changed, 115 insertions(+), 28 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 3c1c33a..f6c03c7 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n //var parameters = JSON.parse(ggbDataset.parameters);\r\n parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n //debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1;\r\n applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n //debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","parameters","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","html5NoWebSimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eA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F,OAAOqB,KAAKoC,+CAAiB,8DAA3DqC,0BAAKhH,4BACbL,UAAUsH,sBAAeD,gBAAOhH,QAOhCkB,OAAOqB,KAAKP,YAAY6E,GAAGnD,IAAIjE,SAASyB,OAAOqB,KAAK7C,aAAamH,GAAGlH,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=true;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAGrCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAAU,GAC3BtD,UAAYuB,OAAO2B,aACnBK,QAAUC,KAAKC,MAAMlC,OAAOoB,KAAKP,YAAYiB,SAC5C,IAAIK,SA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N,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBvB,gBACS,IAAIiC,EAAI,EAAGA,EAAInG,OAAOoB,KAAKN,YAAYsF,OAAQD,IAAK,KACjD1H,UAAYuB,OAAO,YAAcmG,WACZ,IAAd1H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS0F,GAAG5D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASwF,GAAG5D,IAAI9D,UAAUgE,uCAGXhD,OAAO4G,QAAQrG,OAAOoB,KAAKqC,+CAAiB,8DAA3D6C,0BAAKxH,4BACbL,UAAU8H,sBAAeD,gBAAOxH,QAOhCkB,OAAOoB,KAAKN,YAAYqF,GAAG5D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa2H,GAAG1H,eAc3F"} \ No newline at end of file diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index 82bfe59..ab07951 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -1,3 +1,4 @@ +function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;i * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if($('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,window.applet1=new GGBApplet(this.parameters,this.views,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=fileURL,this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); + */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index cb2130f..e5558b4 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters = fileURL ;\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" || evt.target.id == \"showMenuBar\" || evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;AAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAE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EY,OAAOC,KAAK+B,WAAW4E,cAAgB5G,OAAOC,KAAKoG,gBAAgBjH,QACnEY,OAAOC,KAAK+B,WAAW6E,oBAAsB7G,OAAOC,KAAKqG,uBAAuBlH,QAChFY,OAAOC,KAAK+B,WAAW8E,iBAAmB9G,OAAOC,KAAKsG,mBAAmBnH,QACzEY,OAAOC,KAAK+B,WAAW+E,YAAc/G,OAAOC,KAAKuG,cAAcpH,QAC/DY,OAAOC,KAAK+B,WAAWgF,YAAchH,OAAOC,KAAKwG,cAAcrH,QAC/DY,OAAOC,KAAK+B,WAAWmC,OAAS,8BAMhCnE,OAAOO,QAAU,IAAIT,UAAUE,OAAOC,KAAK+B,YAAY,GAC3C,KAAX/C,UAAgBe,OAAOO,QAAQ4B,iBAAiBlD,UAEjDe,OAAOO,QAAQuC,OAAO,sBAG1B+E,OAAOM,cAAcnE,QAI7BrB,SAAU,SAASyF,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters ={ ...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,WAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACzBC,YACIP,EAAE,+BAA+BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQC,kBACnEZ,EAAE,0BAA0BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQE,aAC9Db,EAAE,oCAAoCQ,IAAIL,OAAOQ,QAAQG,gCAE1B,IAAnBT,KAAKU,UAA2B,KACpCC,OAAS3B,SAAS4B,UACtBjB,EAAE,wBAAwBQ,IAAIQ,OAAOE,UAEjB7B,SAASC,eAAe,oBACzBG,OACf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KgC,WAAWgF,iBAAmBjH,OAAOC,KAAKwG,mBAAmBrH,QACzEY,OAAOC,KAAKgC,WAAWiF,YAAclH,OAAOC,KAAKyG,cAActH,QAC/DY,OAAOC,KAAKgC,WAAWkF,YAAcnH,OAAOC,KAAK0G,cAAcvH,QAC/DY,OAAOC,KAAKgC,WAAWmC,OAAS,8BAMhCpE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ4B,iBAAiBnD,UAEjDe,OAAOQ,QAAQuC,OAAO,sBAG1BiF,OAAOM,cAAcrE,QAI7BrB,SAAU,SAAS2F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 355757b..3ff104c 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -75,7 +75,7 @@ define(['jquery'], function ($) { responsevars: [], exerciseresultinput: [], qdiv: [], - parameters: {}, //before not global + //parameters: {}, //before not global ggbDataset: [], //applet1, @@ -86,6 +86,7 @@ define(['jquery'], function ($) { var slot = ggbDataset.slot; // Add current scaling container to the object store for being able to access it later on. scalingContainers[slot] = ggbDataset.scalingcontainerclass; + //alert("no load"); window.ggbAppletOnLoad = function (ggbAppletId) { if (ggbAppletId != -1) { @@ -107,12 +108,16 @@ define(['jquery'], function ($) { window.GGBQ.b64input[id].val(ggbApplet.getBase64()); window.GGBQ.xmlinput[id].val(ggbApplet.getXML()); - window.GGBQ.qdiv[id].style.visibility = 'visible'; + //window.GGBQ.qdiv[id].style.visibility = 'visible'; + window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}}; if (window.GGBQ.answerinput[id].val() == '') { // Twingsister window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet)); // Twingsister //alert("response one"); + //alert("gogod"); + //ggbApplet.setWidth(100); + //ggbApplet.setPerspective("GD"); } } }; @@ -126,8 +131,8 @@ define(['jquery'], function ($) { this.qdiv[slot] = $("#q" + (slot) + " .qtext")[0]; - //var parameters = JSON.parse(ggbDataset.parameters); - parameters = JSON.parse(ggbDataset.parameters); + var parameters = JSON.parse(ggbDataset.parameters); + //parameters = JSON.parse(ggbDataset.parameters); if (this.ggbBase64[slot] != '') { parameters.ggbBase64 = this.ggbBase64[slot]; } @@ -171,7 +176,7 @@ define(['jquery'], function ($) { var views = JSON.parse(ggbDataset.views); // Check if GGBApplet have been manually set. - //debugcode(); // + debugcode(); // var GGBAppletname ; var codebase ; @@ -190,8 +195,21 @@ define(['jquery'], function ($) { //require(["gb"], function(gb) { //import GGBApplet from GGBAppletname; require([GGBAppletname],function (App){//); - var applet1; - applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); + var applet1 ; + //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); + if(!parameters.showToolBar){ + parameters.showToolBar=true; + parameters.customToolBar="40,0,1,41,42,50,38,6"; + } + // parameters.enableUndoRedo=false; //user controlled + //parameters.showResetIcon=false;// user defined + parameters.preventFocus=true;// get focus upon start + parameters.allowStyleBar=false;// style bar controls too much + parameters.transparentGraphics=true;// graphics and graphics 2 are transparent + parameters.playButton=false; //true not working? + parameters.autoHeight=false; // allow height computed automatically + parameters.allowUpscale=true; // let GGB upscale Applet + applet1 = new App(parameters,ggbDataset.html5nowebsimple); if (!(codebase==="")){applet1.setHTML5Codebase(codebase)}; applet1.inject(ggbDataset.div, "preferHTML5"); }); @@ -221,7 +239,7 @@ define(['jquery'], function ($) { getBase64andCheck: function() { - //debugcode(); + debugcode(); for (var i = 0; i < window.GGBQ.answerinput.length; i++) { var ggbApplet = window['ggbApplet' + i]; if (typeof ggbApplet !== "undefined") { diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index 440ea79..0f4574e 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -41,6 +41,7 @@ var codebase; //debugcode();// window.GGBT = this; window.ggbAppletOnLoad = function() { + debugcode(); $('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())); $('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())); $('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()); @@ -79,11 +80,12 @@ var codebase; this.parameters = JSON.parse(this.ggbDataset.parameters); this.views = this.ggbDataset.views; //alert("hello custom ggb 3"); - //debugcode(); + debugcode(); // if (document.getElementById('id_isurlggb').checked) { //GGBApplet = document.getElementById('id_urlggb').value; // } - window.applet1 = new GGBApplet(this.parameters, this.views, true); + //window.applet1 = new GGBApplet(this.parameters, this.views, true); + window.applet1 = new GGBApplet(this.parameters, true); if(!(codebase==="")){ window.applet1.setHTML5Codebase(codebase); } @@ -91,6 +93,7 @@ var codebase; } //debugcode(); + //$('#id_stoapplet').on('click', this.handleStoreGGB); $('#id_loadapplet').on('click', function(e) { e.preventDefault(); var httpurl = $('#id_ggbturl').val(); @@ -162,12 +165,12 @@ var codebase; }, injectapplet: function(fileURL) { - this.parameters = fileURL ; + this.parameters ={ ...this.parameters, ...fileURL}; this.parameters.language = this.lang; this.parameters.moodle = "editingQuestionOrSubmission"; // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit). this.parameters.useBrowserForJS = false; - + //window.ggbAppletOnLoad = function (ggbAppletId) {} document.getElementById('applet_container1').style.display = "block"; //alert("hello custom ggb 4"); @@ -274,6 +277,7 @@ var codebase; initoptions: function() { this.enable_right_click = document.getElementById('enableRightClick'); this.enable_label_drags = document.getElementById('enableLabelDrags'); + this.enable_undo_redo = document.getElementById('enableUndoRedo'); this.show_reset_icon = document.getElementById('showResetIcon'); this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom'); this.show_algebra_input = document.getElementById('showAlgebraInput'); @@ -283,6 +287,7 @@ var codebase; if (typeof this.parameters !== 'undefined') { this.enable_right_click.checked = this.parameters.enableRightClick; this.enable_label_drags.checked = this.parameters.enableLabelDrags; + this.enable_undo_redo.checked = this.parameters.enableUndoRedo; this.show_reset_icon.checked = this.parameters.showResetIcon; this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom; this.show_algebra_input.checked = this.parameters.showAlgebraInput; @@ -295,6 +300,7 @@ var codebase; this.enable_right_click.addEventListener('change', this.handlesettingschanged, false); this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false); + this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false); this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false); this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false); this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false); @@ -303,9 +309,13 @@ var codebase; }, handlesettingschanged: function(evt) { +debugcode(); window.GGBT.parameters[evt.target.id] = (evt.target.checked); $('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)); - if (evt.target.id == "showToolBar" || evt.target.id == "showMenuBar" || evt.target.id == "showAlgebraInput") { + if (evt.target.id == "showToolBar" || + evt.target.id == "showMenuBar" || + evt.target.id == "enableUndoRedo" || + evt.target.id == "showAlgebraInput") { // alert("hello custom ggb 5"); //debugcode(); // if (document.getElementById('id_isurlggb').checked) { @@ -366,7 +376,56 @@ var codebase; document.getElementById('applet_container1').style.removeProperty("visibility"); } }, + //handleStoreGGB: function() { + /*{ + if (typeof (window.GGBT.ggbcheckb) == "undefined" || window.GGBT.ggbcheckb.checked) { + e.preventDefault(); + e.stopPropagation(); + var file = e.dataTransfer.files[0]; + window.GGBT.ggbf.classList.remove('qtype-geogebra-hover'); + document.getElementById('applet_container1').style.removeProperty("visibility"); + document.getElementById('applet_container1').style.display = "block"; + document.getElementById('applet_options').style.display = "flex"; + document.getElementById('applet_container1').style.height = "100%"; + //document.getElementById('applet_container1').style.width = "100%"; + + document.getElementById('id_ggbturl').value = ""; + //this.usefile = document.getElementById("id_usefile"); + if (!window.GGBT.usefile.checked) { + window.GGBT.usefile.click(); + } + var reader = new FileReader(); + reader.onload = function(event) { + var base64 = event.target.result.replace("data:application/vnd.geogebra.file;base64,", ""); + */ + // debugcode(); + // var base64 = window.ggbApplet.getBase64() ; + // window.GGBT.parameters = {"ggbBase64": base64}; + /* + window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked; + window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked; + window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked; + window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked; + window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked; + window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked; + window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked; + window.GGBT.parameters.moodle = "editingQuestionOrSubmission"; + */ + // alert("hello custom ggb 2"); + //debugcode(); + // if (document.getElementById('id_isurlggb').checked) { + //GGBApplet = document.getElementById('id_urlggb').value; + // } + /* + window.applet1 = new GGBApplet(window.GGBT.parameters, true); + if(!(codebase==="")){window.applet1.setHTML5Codebase(codebase);} + // window.applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); + window.applet1.inject("applet_container1"); + }; + reader.readAsDataURL(file); + }*/ + ///}, handleDrop: function(e) { if (typeof (window.GGBT.ggbcheckb) == "undefined" || window.GGBT.ggbcheckb.checked) { e.preventDefault(); @@ -391,6 +450,7 @@ var codebase; window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked; window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked; window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked; + window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked; window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked; window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked; window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked; diff --git a/db/upgrade.php b/db/upgrade.php index 458ca6b..25b3a4f 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023170104) { + if ($oldversion < 2023300104) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023170104, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023300104, 'qtype', 'geogebra'); } return true; } diff --git a/edit_geogebra_form.php b/edit_geogebra_form.php index 9933cb7..9ed4b18 100644 --- a/edit_geogebra_form.php +++ b/edit_geogebra_form.php @@ -539,8 +539,10 @@ private function add_applet_elements($mform) { /* Button to (Re)load Applet from GeoGebraTube */ $loadappletgroup = array(); $loadappletgroup[] =& $mform->createElement('button', 'loadapplet', get_string('loadapplet', 'qtype_geogebra')); - // Hack: the button doesn't support a HelpButton. $loadappletgroup[] =& $mform->createElement('html', ' '); + //$loadappletgroup[] =& $mform->createElement('button', 'stoapplet', get_string('stoapplet', 'qtype_geogebra')); + //$loadappletgroup[] =& $mform->createElement('html', ' '); + // Hack: the button doesn't support a HelpButton. $mform->addGroup($loadappletgroup, 'loadappletgroup', get_string('loadapplet', 'qtype_geogebra'), array(' '), false); $mform->addHelpButton('loadappletgroup', 'loadapplet', 'qtype_geogebra'); $mform->disabledIf('loadappletgroup', 'usefile', 'checked'); @@ -557,7 +559,7 @@ private function add_applet_elements($mform) { data-views=$this->ggbviews data-codebase=$this->ggbcodebaseversion data-lang=$lang - data-html5NoWebSimple="true"> + data-html5nowebsimple="true"> EOD; $mform->addElement('html', $applet); @@ -575,6 +577,7 @@ private function add_applet_options($mform) { $showalgebrainput = get_string('show_algebra_input', 'qtype_geogebra'); $showmenubar = get_string('show_menu_bar', 'qtype_geogebra'); $showreseticon = get_string('show_reset_icon', 'qtype_geogebra'); + $enableundoredo = get_string('enable_undo_redo', 'qtype_geogebra'); $showtoolbar = get_string('show_tool_bar', 'qtype_geogebra'); $options = <<$enablerightclick

+ +

diff --git a/lang/en/qtype_geogebra.php b/lang/en/qtype_geogebra.php index 02af024..b73ec07 100644 --- a/lang/en/qtype_geogebra.php +++ b/lang/en/qtype_geogebra.php @@ -64,6 +64,8 @@ $string['isexercise'] = 'Use GeoGebra-Exercise for checking the question'; $string['isexercise_help'] = 'The applet contains user-defined tools which can be used for automatic checking of the exercise.\nBeware: All answers below are not applicable in this case!'; $string['israndomized'] = 'Are there any variables which should be randomized?'; +$string['stoapplet'] = 'Store the current state of the applet as initial'; +$string['stoapplet_help'] = 'Store the current state of the applet as initial'; $string['loadapplet'] = '(Re)load and show applet'; $string['loadapplet_help'] = '(Re)load the applet from GeoGebra and store the new version from GeoGebra in the database.'; $string['mineqmax'] = 'Min and Max for the randomization aren\'t specified properly for variable {$a}, either you haven\'t specified the slider’s min and max or the element isn\'t a slider at all. You probably have to correct this in your GeoGebra file.'; @@ -81,6 +83,7 @@ $string['show_algebra_input'] = 'Show Input Bar'; $string['show_menu_bar'] = 'Show Menu'; $string['show_reset_icon'] = 'Show Icon to Reset Construction'; +$string['enable_undo_redo'] = 'Show Arrows to Undo Redo'; $string['show_tool_bar'] = 'Show Toolbar'; $string['stepzero'] = 'Increment is 0 for variable {$a}; either you haven\'t specified the slider’s increment or the element isn\'t a slider at all. You probably have to correct this in your GeoGebra file.'; $string['useafile'] = '... or use a ggb-file'; diff --git a/question.php b/question.php index f6b14cf..7dac7f6 100644 --- a/question.php +++ b/question.php @@ -243,8 +243,9 @@ private function summarize(array $answers,string $resp){ $summary .= $answer->answer . '='; $responseclass .= $answer->answer . '=' . $values[$j]; // contribution to the result - $valnum = $values[$j]; - $valnum = ($valnum == "true"?1:($valnum == "false"?0:number_format($values[$j]))); + + $valnum = (array_key_exists($j,$values)?$values[$j]:1); + $valnum = ($valnum == "true"?1:($valnum == "false"?0:number_format($valnum))); $fraction += ($answer->fraction)*$valnum; $summary .= format_float($valnum, 2, false, false) . ',' . get_string('grade', 'grades') . ': ' . diff --git a/renderer.php b/renderer.php index 30718ae..cedf71f 100644 --- a/renderer.php +++ b/renderer.php @@ -116,7 +116,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $options = array('parameters' => $question->ggbparameters, 'views' => $question->ggbviews, 'codebase' => $question->ggbcodebaseversion, - 'html5NoWebSimple' => true, + 'html5nowebsimple' => true, 'div' => $ggbdivname, 'vars' => $question->currentvals, 'b64input' => $b64inputname, @@ -146,7 +146,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ data-parameters=$question->ggbparameters data-views=$question->ggbviews data-codebase=$question->ggbcodebaseversion - data-html5NoWebSimple=true + data-html5nowebsimple=true data-div=$ggbdivname data-vars=$currentvals data-b64input=$b64inputname @@ -167,7 +167,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ EOD; $result .= $applet; - //echo ""; + echo ""; $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); if ($qa->get_state() == question_state::$invalid) { diff --git a/version.php b/version.php index acb4fbb..b7eb0c1 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023170104; +$plugin->version = 2023300104; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From a1349655f657928d8b3df8cfbfc3d62fa732bd2d Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 6 Feb 2023 12:31:58 +0100 Subject: [PATCH 25/60] Added Twingsister mods --- db/upgrade.php | 4 ++-- question.php | 2 +- version.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index 25b3a4f..9ba78df 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023300104) { + if ($oldversion < 2023060204) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023300104, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2023060204, 'qtype', 'geogebra'); } return true; } diff --git a/question.php b/question.php index 7dac7f6..b63d654 100644 --- a/question.php +++ b/question.php @@ -362,7 +362,7 @@ public function classify_response(array $response) { return array($this->id => new question_classified_response(null, "Response graded manually", 0)); } else { $resp = $response['answer']; - if ($resp === '') { + if ($resp === NULL || $resp === '') { return array($this->id => question_classified_response::no_response()); } else { $results= $this->summarize($this->answers,$resp); // Twingsister diff --git a/version.php b/version.php index b7eb0c1..decddfe 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023300104; +$plugin->version = 2023060204; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 6cbd939bf54f7612c2d969e066f229bf08d50cb1 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 7 Feb 2023 10:41:45 +0100 Subject: [PATCH 26/60] push a version number --- db/upgrade.php | 4 ++-- version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index 9ba78df..e1011ea 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2023060204) { + if ($oldversion < 2024020600) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2023060204, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2024020600, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index decddfe..1103de6 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2023060204; +$plugin->version = 2024020600; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From da449af76f434609cf4e58eecb4483a85cacfbed Mon Sep 17 00:00:00 2001 From: Twingsister Date: Tue, 7 Feb 2023 10:42:05 +0100 Subject: [PATCH 27/60] a test --- ggb-qtype-grading-test.ggb | Bin 0 -> 15915 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ggb-qtype-grading-test.ggb diff --git a/ggb-qtype-grading-test.ggb b/ggb-qtype-grading-test.ggb new file mode 100644 index 0000000000000000000000000000000000000000..0bdf8033db3496ac0205689da935d25ced0cee22 GIT binary patch literal 15915 zcmeHOcQl>b(^i9sP7uAP$U$)Q5=4tGh~6W5@4XW>LDWMM2}!i*y|?HkI5>_Pz4y-d zy7vaT>-+utm9@fRIj_BE&z?Q=%rmpzt?(2Xg%AM&0Ud$!nS|;bt(Pb{DgpuxBLV_3 z@YKZE+QitvPG8r^_=Ucsg@gSgBan-w#j1v){WKWYYwh%AMCxd;4;HsDW4G+u3*Ign zkn;~CUQZ%%5>64jhdjbwo@#IMWqq^^sH07{aPtd_hP)=sir;vgxq_z_d^282;ThCU z>5Dy~50+`7>E2oR7%Zgg!5j4@e36>rCH)VKJ{oM9jt^9l5mvoij`UI@vNjc|6u6|mbX$i}lb@kd_w}!3>Fv;AN6%%7a@(*$ldz4Fb@-ap3bFX9% z!JTQbNAKCDjf7o8yh$)ld8O~2Vx?CRO#Yk-ldnz5%1@!?IS3Y4$oz5Z+5BmCFNfvi zrdpfvtA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&)+1C_=Mzt3wocN*J|^n+KXWX%UwqTeRQkGZ8pc4f;Jbzw>JdBpGmSd^2b7Eqam z_Aon90*J*wvj{*@PPTSs2|2%u%}0%AS4}VkUp8D^{8j{4=5YgN5d)7WEkNy)dPg?L|eZGzrqmUJm;b8S*^VE;xqY`E{#}Rv4NPxsna$G z8&h-Z7X;&^0w`nV)@SxNo%x(rUY?OpERvY>Ip0&ue%?1=fxHleMb^GrI-z3#edMN9 zYNf55XWw;EGE(2ki&%dZeq_0tN*YaYwe?;m0Ikz*Em>raJO#=xtxA6qzE^m+4b|AZ z1pjHj;g_bbjaOG5RvvE8$4ojC)mI9mynn(>Pmpwu0VP4z;Wq+%E$(*%|NtGNbblrtWsKr`&53jQ$s ziJGqG?xdW46?mz2ZR)~B0EmI1w5|gU)~+>!c|5*gJldHM+@-6WBm9mJICQ?!R87ty znoSv?kwnpe?f`lGP{eQyG+N#`Op4FP27|PwOGJUESR>J2*&dsc=VuL!Y&KF@8{n3?Y*>SkI;M^yhcCn1hX^-T8aL7 zmd+G2Xo}{iN4v6E)@UIl# z{)HvL#Apd&$ximCkZX^G-)RU-W-~s!N>G577ZJ{1IDm0Yag?v90ZnEisMnVNBkqsw z{y55?sQ7~@f8g_fHCH@`m;jdzZZTiH3-C|M`h(1WkogZX|3T(I$o#*G%zx1M@2d7s zLG`D4{8M@VX*2xksr=t)Ae|A5Aj#SmQljw!uM#6jJ&_a3718rkc#4Qbi144UGGC0n z`uYzSoBu83-`Dr91Sq2ZH@BnzzRdS;A^*NubS2~j{hE;9t{MGX#=q|qUCEHbxRP;k qyXb1>fB(An)l7QatC_mLy}YgP6!qdYZ3I-{TLuvUp^g9I(|-XbW{)8N literal 0 HcmV?d00001 From 84422495ef3105a5e1565db8247a5eab630fcfa0 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 13 Feb 2023 19:18:38 +0100 Subject: [PATCH 28/60] decimals --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbt.js | 8 ++++++++ question.php | 9 ++++++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index ab07951..41b280d 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.g * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]&&(this.ggbDataset=$("#applet_parameters")[0].dataset,this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang),$("#id_loadapplet").on("click",(function(e){e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); + */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){if(window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]){this.ggbDataset=$("#applet_parameters")[0].dataset;try{this.parameters=JSON.parse(this.ggbDataset.parameters)}catch(err){alert("Error parsing JSON "+err.message)}this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang}$("#id_loadapplet").on("click",(function(e){debugcode(),e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index e5558b4..f6dc351 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters ={ ...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,a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windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters ={ ...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SA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line at end of file diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index 0f4574e..d4ef404 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -77,6 +77,12 @@ var codebase; if ($('#applet_parameters')[0] !== undefined) { this.ggbDataset = $('#applet_parameters')[0].dataset; + try { + this.parameters = JSON.parse(this.ggbDataset.parameters); + } + catch(err) { + alert("Error parsing JSON "+err.message); + } this.parameters = JSON.parse(this.ggbDataset.parameters); this.views = this.ggbDataset.views; //alert("hello custom ggb 3"); @@ -95,6 +101,7 @@ var codebase; //$('#id_stoapplet').on('click', this.handleStoreGGB); $('#id_loadapplet').on('click', function(e) { + debugcode(); e.preventDefault(); var httpurl = $('#id_ggbturl').val(); var id = httpurl.split("/").pop(); @@ -426,6 +433,7 @@ debugcode(); reader.readAsDataURL(file); }*/ ///}, + handleDrop: function(e) { if (typeof (window.GGBT.ggbcheckb) == "undefined" || window.GGBT.ggbcheckb.checked) { e.preventDefault(); diff --git a/question.php b/question.php index b63d654..67c9792 100644 --- a/question.php +++ b/question.php @@ -245,11 +245,14 @@ private function summarize(array $answers,string $resp){ // contribution to the result $valnum = (array_key_exists($j,$values)?$values[$j]:1); - $valnum = ($valnum == "true"?1:($valnum == "false"?0:number_format($valnum))); + $valnum = ($valnum == "true"?1:($valnum == "false"?0:floatval($valnum))); $fraction += ($answer->fraction)*$valnum; - $summary .= format_float($valnum, 2, false, false) . ',' . + $summary .= sprintf("%.2f",$valnum) . ',' . get_string('grade', 'grades') . ': ' . - format_float($answer->fraction, 2, false, false); + sprintf("%.2f",$answer->fraction); + //$summary .= format_float($valnum, 2, false, false) . ',' . + // get_string('grade', 'grades') . ': ' . + // format_float($answer->fraction, 2, false, false); $j++; } if ($fraction > 1) { From 7c1c65c58874a7b124b7a4a36447d65fe1b1c245 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 13 Feb 2023 19:21:45 +0100 Subject: [PATCH 29/60] push version --- db/upgrade.php | 4 ++-- version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index e1011ea..c4ed95f 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2024020600) { + if ($oldversion < 2024021400) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2024020600, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2024021400, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 1103de6..68c26e5 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024020600; +$plugin->version = 2024021400; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 6a152898d5517abdde2c408997c27aab73aed15c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Thu, 16 Feb 2023 16:15:45 +0100 Subject: [PATCH 30/60] full screen button --- amd/src/ggbq.js | 1 + 1 file changed, 1 insertion(+) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 3ff104c..f0adbd5 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -209,6 +209,7 @@ define(['jquery'], function ($) { parameters.playButton=false; //true not working? parameters.autoHeight=false; // allow height computed automatically parameters.allowUpscale=true; // let GGB upscale Applet + parameters.showFullscreenButton=true; // let GGB upscale Applet applet1 = new App(parameters,ggbDataset.html5nowebsimple); if (!(codebase==="")){applet1.setHTML5Codebase(codebase)}; applet1.inject(ggbDataset.div, "preferHTML5"); From d640a279e9b02816bd245d12238efa77fc9d79b7 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Thu, 16 Feb 2023 16:16:01 +0100 Subject: [PATCH 31/60] full screen button --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index f6c03c7..7274263 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=true;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc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AoB,EAC/BtC,WAAWuC,YAAW,EACtBvC,WAAWa,YAAW,EACtBb,WAAWwC,cAAa,EACxBP,QAAU,IAAID,IAAIhC,WAAW1B,WAAWmE,kBACvB,KAAXpB,UAAgBY,QAAQS,iBAAiBrB,UAClDY,QAAQU,OAAOrE,WAAWsE,IAAK,kBAQhCpG,EAAE,iBAAiBqG,GAAG,SAAUnE,KAAKoE,mBAErCtG,EAAEU,SAASyB,eAAeL,WAAWsE,MAAMC,GAAG,aAAcnE,KAAKoE,wBAE5D5E,YAAYW,MAAQP,WAAWyC,UAC/B5C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAAS6D,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBvB,gBACS,IAAIiC,EAAI,EAAGA,EAAInG,OAAOoB,KAAKN,YAAYsF,OAAQD,IAAK,KACjD1H,UAAYuB,OAAO,YAAcmG,WACZ,IAAd1H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS0F,GAAG5D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASwF,GAAG5D,IAAI9D,UAAUgE,uCAGXhD,OAAO4G,QAAQrG,OAAOoB,KAAKqC,+CAAiB,8DAA3D6C,0BAAKxH,4BACbL,UAAU8H,sBAAeD,gBAAOxH,QAOhCkB,OAAOoB,KAAKN,YAAYqF,GAAG5D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa2H,GAAG1H,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=true;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,W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,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file From bc8a6e812eef3bba492c2ea140a81741d643b382 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Thu, 16 Feb 2023 16:24:11 +0100 Subject: [PATCH 32/60] version push --- db/upgrade.php | 4 ++-- version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index c4ed95f..f1341fa 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2024021400) { + if ($oldversion < 2024021600) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2024021400, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2024021600, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 68c26e5..de98d5e 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024021400; +$plugin->version = 2024021600; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From fbb90da5b01a515a1daabf9b49f30d2a2f8d42cb Mon Sep 17 00:00:00 2001 From: Twingsister Date: Fri, 17 Feb 2023 00:36:35 +0100 Subject: [PATCH 33/60] fullscreen --- amd/src/ggbq.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index f0adbd5..1355591 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -194,6 +194,7 @@ define(['jquery'], function ($) { //require.config({paths: {gb: GGBAppletname.slice(0,-3)}}); //require(["gb"], function(gb) { //import GGBApplet from GGBAppletname; + require([GGBAppletname],function (App){//); var applet1 ; //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); @@ -205,7 +206,7 @@ define(['jquery'], function ($) { //parameters.showResetIcon=false;// user defined parameters.preventFocus=true;// get focus upon start parameters.allowStyleBar=false;// style bar controls too much - parameters.transparentGraphics=true;// graphics and graphics 2 are transparent + parameters.transparentGraphics=false;// graphics and graphics 2 are transparent parameters.playButton=false; //true not working? parameters.autoHeight=false; // allow height computed automatically parameters.allowUpscale=true; // let GGB upscale Applet From dfe8f7470ada9942bd7424843b9b25321fbc09a6 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Fri, 17 Feb 2023 00:37:14 +0100 Subject: [PATCH 34/60] fullscreen --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 7274263..45c21ec 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=true;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAGrCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAA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AWzC,eAEpDqD,WAAY,SAAS8D,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YA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W1B,WAAWoE,kBACvB,KAAXrB,UAAgBY,QAAQU,iBAAiBtB,UAClDY,QAAQW,OAAOtE,WAAWuE,IAAK,kBAQhCrG,EAAE,iBAAiBsG,GAAG,SAAUpE,KAAKqE,mBAErCvG,EAAEU,SAASyB,eAAeL,WAAWuE,MAAMC,GAAG,aAAcpE,KAAKqE,wBAE5D7E,YAAYW,MAAQP,WAAWyC,UAC/B5C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAAS8D,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file From f0308223c6ac55ae92d4780b8f762104bf0d5e4b Mon Sep 17 00:00:00 2001 From: Twingsister Date: Fri, 17 Feb 2023 00:40:10 +0100 Subject: [PATCH 35/60] push version --- db/upgrade.php | 4 ++-- version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index f1341fa..53a1a21 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2024021600) { + if ($oldversion < 2024021700) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2024021600, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2024021700, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index de98d5e..164edc0 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024021600; +$plugin->version = 2024021700; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 89d99f4bd3bf373857981c9810f3ce0faef335e8 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Wed, 1 Mar 2023 23:25:48 +0100 Subject: [PATCH 36/60] push --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbt.js | 1 + db/upgrade.php | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index 41b280d..b78b125 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.g * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){if(window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]){this.ggbDataset=$("#applet_parameters")[0].dataset;try{this.parameters=JSON.parse(this.ggbDataset.parameters)}catch(err){alert("Error parsing JSON "+err.message)}this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang}$("#id_loadapplet").on("click",(function(e){debugcode(),e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); + */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){if(window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]){this.ggbDataset=$("#applet_parameters")[0].dataset;try{this.parameters=JSON.parse(this.ggbDataset.parameters)}catch(err){alert("Error parsing JSON "+err.message)}this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang}$("#id_loadapplet").on("click",(function(e){debugcode(),e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){delete this.parameters.ggbBase64,this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index f6dc351..23c1f42 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n this.parameters ={ ...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,K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e,cAAcG,MAAQ,GAEzCU,OAAOC,KAAK2B,QAAQxC,SACrBY,OAAOC,KAAK2B,QAAQ6F,YAEpBU,OAAS,IAAIC,WACjBD,OAAOE,OAAS,SAASrC,WACjBsC,OAAStC,MAAMxE,OAAO+G,OAAOC,QAAQ,6CAA8C,IACvFxI,OAAOC,KAAKgC,WAAa,WAAcqG,QACvCtI,OAAOC,KAAKgC,WAAW8E,iBAAmB/G,OAAOC,KAAKsG,mBAAmBnH,QACzEY,OAAOC,KAAKgC,WAAW+E,iBAAmBhH,OAAOC,KAAKuG,mBAAmBpH,QACzEY,OAAOC,KAAKgC,WAAWiF,cAAgBlH,OAAOC,KAAKyG,gBAAgBtH,QACnEY,OAAOC,KAAKgC,WAAWgF,eAAiBjH,OAAOC,KAAKwG,iBAAiBrH,QACrEY,OAAOC,KAAKgC,WAAWkF,oBAAsBnH,OAAOC,KAAK0G,uBAAuBvH,QAChFY,OAAOC,KAAKgC,WAAWmF,iBAAmBpH,OAAOC,KAAK2G,mBAAmBxH,QACzEY,OAAOC,KAAKgC,WAAWoF,YAAcrH,OAAOC,KAAK4G,cAAczH,QAC/DY,OAAOC,KAAKgC,WAAWqF,YAActH,OAAOC,KAAK6G,cAAc1H,QAC/DY,OAAOC,KAAKgC,WAAWsC,OAAS,8BAMhCvE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ+B,iBAAiBtD,UAEjDe,OAAOQ,QAAQ0C,OAAO,sBAG1BiF,OAAOM,cAAcrE,QAI7BrB,SAAU,SAAS2F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n delete this.parameters.ggbBase64;\r\n this.parameters ={ ...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,a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ef404..24874ed 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -172,6 +172,7 @@ var codebase; }, injectapplet: function(fileURL) { + delete this.parameters.ggbBase64; this.parameters ={ ...this.parameters, ...fileURL}; this.parameters.language = this.lang; this.parameters.moodle = "editingQuestionOrSubmission"; diff --git a/db/upgrade.php b/db/upgrade.php index 53a1a21..797370a 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2024021700) { + if ($oldversion < 2024030100) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2024021700, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2024030100, 'qtype', 'geogebra'); } return true; } From 2d5c5235b06976635d0f8d9d04e7fc42146eae1c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Wed, 1 Mar 2023 23:28:27 +0100 Subject: [PATCH 37/60] version push --- version.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.php b/version.php index 164edc0..796d96c 100644 --- a/version.php +++ b/version.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Version information for GeoGebra question type. + * Version information for GeoGebra question type.o * * @package qtype_geogebra * @author Christoph Stadlbauer @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024021700; +$plugin->version = 2024030100; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From b18dc1c43700182b46f79fdaa7a29b7595d19b0b Mon Sep 17 00:00:00 2001 From: Twingsister Date: Thu, 2 Mar 2023 13:00:06 +0100 Subject: [PATCH 38/60] initialization of ggbs --- amd/src/ggbt.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index 24874ed..4c76426 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -171,9 +171,12 @@ var codebase; }else{window.GGBT.injectapplet({"filename": params.file});} }, + injectapplet: function(fileURL) { - delete this.parameters.ggbBase64; - this.parameters ={ ...this.parameters, ...fileURL}; + if(this.hasOwnProperty('parameters')){ + if(this.hasOwnProperty('ggbBase64')){delete this.parameters.ggbBase64;} + } else { this.parameters=null;} + this.parameters = {...this.parameters, ...fileURL}; this.parameters.language = this.lang; this.parameters.moodle = "editingQuestionOrSubmission"; // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit). From ae78d52852f78b892f1e914b168690461c0bc099 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Thu, 2 Mar 2023 13:14:07 +0100 Subject: [PATCH 39/60] push version --- amd/build/ggbt.min.js | 2 +- amd/build/ggbt.min.js.map | 2 +- db/upgrade.php | 4 ++-- version.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/amd/build/ggbt.min.js b/amd/build/ggbt.min.js index b78b125..0690563 100644 --- a/amd/build/ggbt.min.js +++ b/amd/build/ggbt.min.js @@ -7,6 +7,6 @@ function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.g * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){if(window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]){this.ggbDataset=$("#applet_parameters")[0].dataset;try{this.parameters=JSON.parse(this.ggbDataset.parameters)}catch(err){alert("Error parsing JSON "+err.message)}this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang}$("#id_loadapplet").on("click",(function(e){debugcode(),e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){delete this.parameters.ggbBase64,this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); + */var GGBAppletstr,codebase;if(null!==document.getElementById("id_isurlggb"))if(document.getElementById("id_isurlggb").checked){GGBAppletcode=document.getElementById("id_urlggb").value;var parts=GGBAppletcode.split(","),rooturl=parts[0],appl=parts[1],base=parts[2];GGBAppletstr=rooturl+appl,codebase=rooturl+base}else GGBAppletstr="https://www.geogebra.org/apps/deployggb.js",codebase="";define("qtype_geogebra/ggbt",["jquery",GGBAppletstr],(function($,GGBApplet){return{init:function(){if(window.GGBT=this,window.ggbAppletOnLoad=function(){if(debugcode(),$('input[name="ggbparameters"]').val(JSON.stringify(window.applet1.getParameters())),$('input[name="ggbviews"]').val(JSON.stringify(window.applet1.getViews())),$('input[name="ggbcodebaseversion"]').val(window.applet1.getHTML5CodebaseVersion()),void 0===this.ggbcheckb){var applet=document.ggbApplet;$('input[name="ggbxml"]').val(applet.getXML()),document.getElementById("id_randomizedvar").value||window.GGBT.getrandvars();for(var i=0,answer=$("#id_answer_"+i);void 0!==answer[0];)answer.val()&&(answer.on("change focus",(function(e){e.preventDefault(),window.GGBT.update_feedback($(e.target))})),window.GGBT.update_feedback(answer)),answer=$("#id_answer_"+ ++i);document.querySelector("article").onkeypress=window.GGBT.checkEnter}window.GGBT.usefile.checked&&(document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex")},void 0!==$("#applet_parameters")[0]){this.ggbDataset=$("#applet_parameters")[0].dataset;try{this.parameters=JSON.parse(this.ggbDataset.parameters)}catch(err){alert("Error parsing JSON "+err.message)}this.parameters=JSON.parse(this.ggbDataset.parameters),this.views=this.ggbDataset.views,debugcode(),window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),this.lang=this.ggbDataset.lang}$("#id_loadapplet").on("click",(function(e){debugcode(),e.preventDefault();var httpurl=$("#id_ggbturl").val(),id=httpurl.split("/").pop();httpurl.startsWith("http")?(document.getElementById("applet_options").style.display="flex",window.GGBT.injectapplet({filename:httpurl})):(0==id.indexOf("m")&&(window.GGBT.isNumber(id.substr(1))||!window.GGBT.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),window.GGBT.injectapplet({material_id:id}))})),$("#id_getvars").on("click",(function(e){e.preventDefault(),window.GGBT.getrandvars()})),this.parameters&&window.applet1.inject("applet_container1","preferHTML5"),this.ggbf=document.getElementById("id_ggbtheader"),this.usefile=document.getElementById("id_usefile"),null===this.ggbf&&(this.ggbf=document.getElementById("id_submissiontypes"),this.ggbcheckb=document.getElementById("id_assignsubmission_geogebra_enabled"),null!==this.ggbcheckb&&this.ggbcheckb.addEventListener("change",this.handleggbdisable,!1)),null!==this.ggbf&&(this.ggbf.addEventListener("dragenter",this.handleDragEnter,!1),this.ggbf.addEventListener("dragover",this.handleDragOver,!1),this.ggbf.addEventListener("dragleave",this.handleDragEndLeave,!1),this.ggbf.addEventListener("dragend",this.handleDragEndLeave,!1),this.ggbf.addEventListener("drop",this.handleDrop,!1),this.usefile.addEventListener("change",this.handleusefile,!1)),this.usefile.checked?document.getElementById("applet_options").style.display="block":document.getElementById("applet_options").style.display="flex",this.initoptions()},callback:function(params){var elementname=M.core_filepicker.instances[params.client_id].options.elementname;if($("#id_"+elementname).val(params.url),params.file.startsWith("http"))window.GGBT.injectapplet({filename:params.file});else{var id=params.file.split(".")[0];0==id.indexOf("m")&&(this.isNumber(id.substr(1))||!this.isNumber(id.substr(1))&&id.length>8)&&(id=id.substr(1)),this.injectapplet({material_id:id})}},injectapplet:function(fileURL){this.hasOwnProperty("parameters")?this.hasOwnProperty("ggbBase64")&&delete this.parameters.ggbBase64:this.parameters=null,this.parameters=_objectSpread(_objectSpread({},this.parameters),fileURL),this.parameters.language=this.lang,this.parameters.moodle="editingQuestionOrSubmission",this.parameters.useBrowserForJS=!1,document.getElementById("applet_container1").style.display="block",window.applet1=new GGBApplet(this.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")},getrandvars:function(){var applet=document.ggbApplet;if(void 0!==applet)for(var objNumber=applet.getObjectNumber(),randomizedvar=document.getElementById("id_randomizedvar"),stringforrandomizedvars="",i=0,j=0;j1?(feedback.val(""),fbstring=""):(feedback.val(""),fbstring="Caption not set or variable name wrong."),feedbackfromfile.val(fbstring)}}}},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},initoptions:function(){this.enable_right_click=document.getElementById("enableRightClick"),this.enable_label_drags=document.getElementById("enableLabelDrags"),this.enable_undo_redo=document.getElementById("enableUndoRedo"),this.show_reset_icon=document.getElementById("showResetIcon"),this.enable_shift_drag_zoom=document.getElementById("enableShiftDragZoom"),this.show_algebra_input=document.getElementById("showAlgebraInput"),this.show_menu_bar=document.getElementById("showMenuBar"),this.show_tool_bar=document.getElementById("showToolBar"),void 0!==this.parameters&&(this.enable_right_click.checked=this.parameters.enableRightClick,this.enable_label_drags.checked=this.parameters.enableLabelDrags,this.enable_undo_redo.checked=this.parameters.enableUndoRedo,this.show_reset_icon.checked=this.parameters.showResetIcon,this.enable_shift_drag_zoom.checked=this.parameters.enableShiftDragZoom,this.show_algebra_input.checked=this.parameters.showAlgebraInput,this.show_menu_bar.checked=this.parameters.showMenuBar,this.show_tool_bar.checked=this.parameters.showToolBar),this.enable_right_click.addEventListener("change",this.handlesettingschanged,!1),this.enable_label_drags.addEventListener("change",this.handlesettingschanged,!1),this.enable_undo_redo.addEventListener("change",this.handlesettingschanged,!1),this.show_reset_icon.addEventListener("change",this.handlesettingschanged,!1),this.enable_shift_drag_zoom.addEventListener("change",this.handlesettingschanged,!1),this.show_algebra_input.addEventListener("change",this.handlesettingschanged,!1),this.show_menu_bar.addEventListener("change",this.handlesettingschanged,!1),this.show_tool_bar.addEventListener("change",this.handlesettingschanged,!1)},handlesettingschanged:function(evt){debugcode(),window.GGBT.parameters[evt.target.id]=evt.target.checked,$('input[name="ggbparameters"]').val(JSON.stringify(window.GGBT.parameters)),"showToolBar"==evt.target.id||"showMenuBar"==evt.target.id||"enableUndoRedo"==evt.target.id||"showAlgebraInput"==evt.target.id?(window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1","preferHTML5")):window.ggbApplet[evt.target.id](evt.target.checked)},handleusefile:function(){window.GGBT.usefile.checked?document.getElementById("id_ggbturl").value="":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex")},handleggbdisable:function(){window.GGBT.ggbcheckb.checked?document.getElementById("applet_container1").style.display="block":(document.getElementById("applet_container1").style.display="none",document.getElementById("applet_options").style.display="flex",window.GGBT.usefile.checked&&window.GGBT.usefile.click())},handleDragEnter:function(){("undefined"==typeof ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden")},handleDragOver:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)return e.preventDefault&&e.preventDefault(),window.GGBT.ggbf.classList.add("qtype-geogebra-hover"),document.getElementById("applet_container1").style.visibility="hidden",!1},handleDragEndLeave:function(){(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked)&&(window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"))},handleDrop:function(e){if(void 0===window.GGBT.ggbcheckb||window.GGBT.ggbcheckb.checked){e.preventDefault(),e.stopPropagation();var file=e.dataTransfer.files[0];window.GGBT.ggbf.classList.remove("qtype-geogebra-hover"),document.getElementById("applet_container1").style.removeProperty("visibility"),document.getElementById("applet_container1").style.display="block",document.getElementById("applet_options").style.display="flex",document.getElementById("applet_container1").style.height="100%",document.getElementById("id_ggbturl").value="",window.GGBT.usefile.checked||window.GGBT.usefile.click();var reader=new FileReader;reader.onload=function(event){var base64=event.target.result.replace("data:application/vnd.geogebra.file;base64,","");window.GGBT.parameters={ggbBase64:base64},window.GGBT.parameters.enableRightClick=window.GGBT.enable_right_click.checked,window.GGBT.parameters.enableLabelDrags=window.GGBT.enable_label_drags.checked,window.GGBT.parameters.showResetIcon=window.GGBT.show_reset_icon.checked,window.GGBT.parameters.enableUndoRedo=window.GGBT.enable_undo_redo.checked,window.GGBT.parameters.enableShiftDragZoom=window.GGBT.enable_shift_drag_zoom.checked,window.GGBT.parameters.showAlgebraInput=window.GGBT.show_algebra_input.checked,window.GGBT.parameters.showMenuBar=window.GGBT.show_menu_bar.checked,window.GGBT.parameters.showToolBar=window.GGBT.show_tool_bar.checked,window.GGBT.parameters.moodle="editingQuestionOrSubmission",window.applet1=new GGBApplet(window.GGBT.parameters,!0),""!==codebase&&window.applet1.setHTML5Codebase(codebase),window.applet1.inject("applet_container1")},reader.readAsDataURL(file)}},isNumber:function(n){return!isNaN(parseFloat(n))&&isFinite(n)}}})); //# sourceMappingURL=ggbt.min.js.map \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 23c1f42..ed182d8 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n injectapplet: function(fileURL) {\r\n delete this.parameters.ggbBase64;\r\n this.parameters ={ ...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SA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C,SACrBY,OAAOC,KAAK2B,QAAQ8F,YAEpBU,OAAS,IAAIC,WACjBD,OAAOE,OAAS,SAASrC,WACjBsC,OAAStC,MAAMzE,OAAOgH,OAAOC,QAAQ,6CAA8C,IACvFzI,OAAOC,KAAKgC,WAAa,WAAcsG,QACvCvI,OAAOC,KAAKgC,WAAW+E,iBAAmBhH,OAAOC,KAAKuG,mBAAmBpH,QACzEY,OAAOC,KAAKgC,WAAWgF,iBAAmBjH,OAAOC,KAAKwG,mBAAmBrH,QACzEY,OAAOC,KAAKgC,WAAWkF,cAAgBnH,OAAOC,KAAK0G,gBAAgBvH,QACnEY,OAAOC,KAAKgC,WAAWiF,eAAiBlH,OAAOC,KAAKyG,iBAAiBtH,QACrEY,OAAOC,KAAKgC,WAAWmF,oBAAsBpH,OAAOC,KAAK2G,uBAAuBxH,QAChFY,OAAOC,KAAKgC,WAAWoF,iBAAmBrH,OAAOC,KAAK4G,mBAAmBzH,QACzEY,OAAOC,KAAKgC,WAAWqF,YAActH,OAAOC,KAAK6G,cAAc1H,QAC/DY,OAAOC,KAAKgC,WAAWsF,YAAcvH,OAAOC,KAAK8G,cAAc3H,QAC/DY,OAAOC,KAAKgC,WAAWuC,OAAS,8BAMhCxE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ+B,iBAAiBtD,UAEjDe,OAAOQ,QAAQ0C,OAAO,sBAG1BkF,OAAOM,cAActE,QAI7BrB,SAAU,SAAS4F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n\r\n injectapplet: function(fileURL) {\r\n if(this.hasOwnProperty('parameters')){\r\n if(this.hasOwnProperty('ggbBase64')){delete this.parameters.ggbBase64;}\r\n } else { this.parameters=null;}\r\n this.parameters = {...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","hasOwnProperty","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAe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AU,SAAS6F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/db/upgrade.php b/db/upgrade.php index 797370a..d297e4d 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -92,7 +92,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2022050401, 'qtype', 'geogebra'); } - if ($oldversion < 2024030100) { + if ($oldversion < 2024030200) { // TODO add urlggb urlggbact // Define field of GGB and GGBACT $table = new xmldb_table('qtype_geogebra_options'); @@ -119,7 +119,7 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // $dbman->add_field($table, $field); //} // Geogebra savepoint reached. - upgrade_plugin_savepoint(true, 2024030100, 'qtype', 'geogebra'); + upgrade_plugin_savepoint(true, 2024030200, 'qtype', 'geogebra'); } return true; } diff --git a/version.php b/version.php index 796d96c..e556153 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024030100; +$plugin->version = 2024030200; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From f5a3462a4fb35d9f5a83c8b2c7ddb92155a954b0 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Fri, 31 Mar 2023 20:09:15 +0200 Subject: [PATCH 40/60] Backupped fields updated --- .../backup_qtype_geogebra_plugin.class.php | 7 +++++-- ggb-qtype-grading-test.ggb | Bin 15915 -> 12861 bytes 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backup/moodle2/backup_qtype_geogebra_plugin.class.php b/backup/moodle2/backup_qtype_geogebra_plugin.class.php index 72a315a..cd40cd8 100644 --- a/backup/moodle2/backup_qtype_geogebra_plugin.class.php +++ b/backup/moodle2/backup_qtype_geogebra_plugin.class.php @@ -53,8 +53,11 @@ protected function define_question_plugin_structure() { // Now create the qtype own structures. $geogebra = new backup_nested_element('geogebra', array('id'), array('ggbturl', 'ggbparameters', 'ggbviews', 'ggbcodebaseversion', 'ggbxml', 'israndomized', 'randomizedvar', - 'constraints', 'isexercise')); - + 'constraints', 'isexercise', + 'forcedimensions','width','height', + "seeditornot","seed", + "isurlggb","urlggb" + )); // Now the own qtype tree. $pluginwrapper->add_child($geogebra); diff --git a/ggb-qtype-grading-test.ggb b/ggb-qtype-grading-test.ggb index 0bdf8033db3496ac0205689da935d25ced0cee22..d7145f8120bab702554530e6051ad8c9ff68e6da 100644 GIT binary patch literal 12861 zcmeHubyOYQvL_ZGB*=jP!7aE3cL*9Bf_rdxcXtbr;1VRb1a}SY?h@QRxJ@6pZ@%~4 zdH270Yt~zHVX^4bUAww=b=9wawR;~~322x%5D*aX5aD7TO6cPe2Uss4Ac)8yATWWm zMg~?!2D-L7+WH2DIu7Rcc8vOT&KBkeYI1g~tSFv`_XrVbb3xvSZ$FX^NgWz;4ocEF zjq7uIpo_d^5wNA@;P>=UjwzG!*3c#VVseU7R$e*fxolb$^Dl=cL-G6qsxx8Gm=q8;Yn-mR|6RfX6eI>?`Dw`3VM$X(3 zqA#G=(d&JR^2mUCidpG7rz^olv(?n>m`~*^h4*@u5m-*hMQ9nI?u2kBa%# z31VHFaaw#-i9gxaAnr{32kz{b=z_+T{uSD-`ob)vG&w8`}r>1r~AIH za7L!^!c;U@uljkej)L9#PQ6(%&l%HaRs2p&@2wsB+67#f+n?XkwDv@35N^L8Pl(Lg zY~NCy5saa8h_R?aeYYEPf%dxyA? zxvlSc*B1DbUDW^;RVW8ire)d*d%Hz9gc&yFy>SH#C`(ePs{m@DRP{#IAZzgisZBJ$ z;^OrT8dh?d0yFC;pZ)^@I?VI@ye7v8N56MeNulv0QMlTJ4A zs2Kw}yZOnj7i7g&L0(4Yl7MGrL@;A+JB z{hAX-C((uD!sd;lX1eJXpu5`U;H_rUW6DCWjAKpxFdu{MT~Cg5=yo`Kl;YaF91!c5 zb?)SMJa*B^zfUC|u9;RN6CR~I)##2^i8cHY!A_-l#*;mtzx)iuqg92TO_S3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27|PwOGJUESR>J2*&dsc=VuL!Y&KF@8{n3?Y*>SkI;M^yhcCn1hX^-T8aL7 zmd+G2Xo}{iN4v6E)@UIl# z{)HvL#Apd&$ximCkZX^G-)RU-W-~s!N>G577ZJ{1IDm0Yag?v90ZnEisMnVNBkqsw z{y55?sQ7~@f8g_fHCH@`m;jdzZZTiH3-C|M`h(1WkogZX|3T(I$o#*G%zx1M@2d7s zLG`D4{8M@VX*2xksr=t)Ae|A5Aj#SmQljw!uM#6jJ&_a3718rkc#4Qbi144UGGC0n z`uYzSoBu83-`Dr91Sq2ZH@BnzzRdS;A^*NubS2~j{hE;9t{MGX#=q|qUCEHbxRP;k qyXb1>fB(An)l7QatC_mLy}YgP6!qdYZ3I-{TLuvUp^g9I(|-XbW{)8N From 0fde6b7f7d1e30911d1072fa3d0b4291a4334254 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 1 Apr 2023 22:59:18 +0200 Subject: [PATCH 41/60] adding compatiblity with live grid view --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 2 +- question.php | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 45c21ec..a3926d5 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBI,MAAM,QAGnBJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAGrCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAAU,GAC3BtD,UAAYuB,OAAO2B,aACnBK,QAAUC,KAAKC,MAAMlC,OAAOoB,KAAK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AAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBE,YAAY,IAAIE,MAAM,QAGnCJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OA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AAiBtB,UAClDY,QAAQW,OAAOtE,WAAWuE,IAAK,kBAQhCrG,EAAE,iBAAiBsG,GAAG,SAAUpE,KAAKqE,mBAErCvG,EAAEU,SAASyB,eAAeL,WAAWuE,MAAMC,GAAG,aAAcpE,KAAKqE,wBAE5D7E,YAAYW,MAAQP,WAAWyC,UAC/B5C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAAS8D,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 1355591..2428294 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -26,7 +26,7 @@ if (ggbApplet.isDefined(responsevar)){ var value = ggbApplet.getValue(responsevar); if (ggbApplet.getObjectType(responsevar)=="boolean"){value = (value == 0 ?"false":"true");} - responsestring += value+'%'; //Twingsister to deal with multidigit + responsestring += responsevar+":"+value+'%'; //Twingsister to deal with multidigit } }); return responsestring.replace(/\%$/,""); // possibly cut the last % works better with explode diff --git a/question.php b/question.php index 67c9792..6879c1a 100644 --- a/question.php +++ b/question.php @@ -232,7 +232,7 @@ private function summarize(array $answers,string $resp){ $fraction = 0; $summary = ''; $responseclass = ''; - $values = explode("%",$resp); // Twingsister + $values = explode("%",$resp); // Twingsister in values x:0.7 foreach ($answers as $answer) { //$correct = (bool)substr($resp, $j, 1); // add a comma if necessary @@ -243,8 +243,7 @@ private function summarize(array $answers,string $resp){ $summary .= $answer->answer . '='; $responseclass .= $answer->answer . '=' . $values[$j]; // contribution to the result - - $valnum = (array_key_exists($j,$values)?$values[$j]:1); + $valnum = (array_key_exists($j,$values)?explode(":",$values[$j])[1]:1); $valnum = ($valnum == "true"?1:($valnum == "false"?0:floatval($valnum))); $fraction += ($answer->fraction)*$valnum; $summary .= sprintf("%.2f",$valnum) . ',' . From b4d1a2a0519c0e8175dd44bf1294d3f9543a3c77 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 10 Apr 2023 23:42:58 +0200 Subject: [PATCH 42/60] April bump --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index e556153..5f23720 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024030200; +$plugin->version = 2024100400; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 603a5fe9eccaa9dae4b5d777f03692e49c4cff2c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 22 Apr 2023 23:39:04 +0200 Subject: [PATCH 43/60] Automatic grading restored --- amd/src/ggbq.js | 3 ++ amd/src/ggbt.js | 2 ++ question.php | 81 ++++++++++++++++++++++++++++++------------------ questiontype.php | 29 ++++++++++------- renderer.php | 7 +++-- 5 files changed, 77 insertions(+), 45 deletions(-) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 2428294..2594a5a 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -1,3 +1,5 @@ + + /* eslint-disable */ /* eslint-disable no-debugger */ /*jslint devel: true */ @@ -240,6 +242,7 @@ define(['jquery'], function ($) { // returns a percent % separated string of the values. If no value is present the variable is skipped + getBase64andCheck: function() { debugcode(); for (var i = 0; i < window.GGBQ.answerinput.length; i++) { diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index 4c76426..76243f5 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -1,3 +1,4 @@ + /*eslint linebreak-style:0 -- ['error', 'windows','unix']*/ /* eslint-disable no-undef */ /** @@ -36,6 +37,7 @@ var codebase; //document.getElementsByTagName('head')[0].appendChild(script); return { + init: function() { //debugcode();// diff --git a/question.php b/question.php index 6879c1a..0dcd782 100644 --- a/question.php +++ b/question.php @@ -26,7 +26,21 @@ global $CFG; require_once($CFG->dirroot . '/question/type/calculated/question.php'); require_once($CFG->dirroot . '/question/type/calculated/questiontype.php'); - +// $resp is "x:0.7%y:y:1%a:true" returns an array ['x'=>'0.7','y'=>'1','a'=>'true'] +function unpack_resp(string $resp){ + $res = array(); + $values = explode("%",$resp); // Twingsister in values x:0.7 + foreach ($values as $value) { + $varval = explode(":",$value); + $res[$varval[0]]=$varval[1]; + } + return $res; +} +// Twingsister the idea below abandoned simply no stats about these quizzes +//Twingsister for compatibiity with previous version where all answers are boolean response that are not boolean +// are considered as binary with true if >0.999 false otherwise. If the name of the variable ends with _n then +// outcomes must be numeric and are considered as spanning n classes from [0,1/n) to [(n-1)/n,1] + /** * Class qtype_geogebra_question */ @@ -169,7 +183,7 @@ public function is_complete_response(array $response) { $ret = $ret && array_key_exists('ggbxml', $response) && ($response['ggbxml']); if (!empty($this->answers)) { $ret = $ret && array_key_exists('answer', $response) && ($response['answer'] || $response['answer'] === '0'); - $ret = $ret && (preg_replace("/[^0,1]/", "", $response['answer']) == $response['answer']); + // Twingsister do not check well formed previously was easy i.e. 010001 $ret = $ret && (preg_replace("/[^0,1]/", "", $response['answer']) == $response['answer']); } if ($this->isexercise) { $ret = $ret && array_key_exists('exerciseresult', $response) && ($response['exerciseresult']); @@ -232,7 +246,8 @@ private function summarize(array $answers,string $resp){ $fraction = 0; $summary = ''; $responseclass = ''; - $values = explode("%",$resp); // Twingsister in values x:0.7 + $resparray=unpack_resp($resp); + //$values = explode("%",$resp); // Twingsister in values x:0.7 foreach ($answers as $answer) { //$correct = (bool)substr($resp, $j, 1); // add a comma if necessary @@ -241,9 +256,12 @@ private function summarize(array $answers,string $resp){ } // the name of the variable $summary .= $answer->answer . '='; - $responseclass .= $answer->answer . '=' . $values[$j]; // contribution to the result - $valnum = (array_key_exists($j,$values)?explode(":",$values[$j])[1]:1); + //$valnum = (array_key_exists($j,$values)?explode(":",$values[$j])[1]:"1"); + // if the answer is not there give the maximum i.e. 1. One for "true" zero for "false" + $valnum = (array_key_exists($answer->answer,$resparray)?$resparray[$answer->answer]:"1"); + //$responseclass .= $answer->answer . '=' . $values[$j]; + $responseclass .= $answer->answer . '=' . $valnum; $valnum = ($valnum == "true"?1:($valnum == "false"?0:floatval($valnum))); $fraction += ($answer->fraction)*$valnum; $summary .= sprintf("%.2f",$valnum) . ',' . @@ -340,9 +358,10 @@ public function get_validation_error(array $response) { ) { return get_string('answermissing', 'qtype_geogebra'); } - if (!(preg_replace("/[^0,1]/", "", $response['answer']) == $response['answer'])) { - return get_string('answerinvalid', 'qtype_geogebra'); - } + // Twingsister impossible to check + //if (!(preg_replace("/[^0,1]/", "", $response['answer']) == $response['answer'])) { + // return get_string('answerinvalid', 'qtype_geogebra'); + //} if ($this->isexercise && !(array_key_exists('exerciseresult', $response))) { return get_string('exerciseresultmissing', 'qtype_geogebra'); } @@ -359,7 +378,9 @@ public function get_validation_error(array $response) { * @return array subpartid => {@see question_classified_response} objects. * returns an empty array if no analysis is possible. */ + /* public function classify_response(array $response) { + xdebug_break(); if (empty($this->answers)) { return array($this->id => new question_classified_response(null, "Response graded manually", 0)); } else { @@ -368,33 +389,31 @@ public function classify_response(array $response) { return array($this->id => question_classified_response::no_response()); } else { $results= $this->summarize($this->answers,$resp); // Twingsister - /* - $j = 0; - $fraction = 0; - $responseclass = ''; - foreach ($this->answers as $answer) { - $correct = (bool)substr($resp, $j, 1); - if ($responseclass !== '') { - $responseclass .= ', '; - } - $responseclass .= $answer->answer . '='; - if ($correct) { - $fraction += $answer->fraction; - $responseclass .= 'true'; - } else { - $responseclass .= 'false'; - } - $j++; - } - if ($fraction > 1) { - $fraction = 1; - } - */ +// $j = 0; +// $fraction = 0; +// $responseclass = ''; +// foreach ($this->answers as $answer) { +// $correct = (bool)substr($resp, $j, 1); +// if ($responseclass !== '') { +// $responseclass .= ', '; +// } +// $responseclass .= $answer->answer . '='; +// if ($correct) { +// $fraction += $answer->fraction; +// $responseclass .= 'true'; +// } else { +// $responseclass .= 'false'; +// } +// $j++; +// } +// if ($fraction > 1) { +// $fraction = 1; +// } return array($this->id => new question_classified_response($resp,$results['responseclass'],$results['fraction'])); //bindec($resp) } } } - +*/ /** * Grade a response to the question, returning a fraction between * get_min_fraction() and get_max_fraction(), and the corresponding {@see question_state} diff --git a/questiontype.php b/questiontype.php index b3db7eb..0e424a8 100644 --- a/questiontype.php +++ b/questiontype.php @@ -26,6 +26,7 @@ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/question/type/shortanswer/questiontype.php'); +//require_once($CFG->dirroot . '/question/type/geogebra/question.php'); /** * GeoGebra question type @@ -110,7 +111,8 @@ public function get_random_guess_score($questiondata) { * for things like the quiz statistics report. */ public function can_analyse_responses() { - return true; + // return true; + return false; } // TODO not correct if autochecking enabled. @@ -129,17 +131,6 @@ public function can_analyse_responses() { * @return array keys are the decimal representation of the (binary) responsestring, * values are arrays of possible responses to that subquestion. */ - public function get_possible_responses($questiondata) { - // There are no possible answers which can be calculated if answers array is empty i.e. question is manually graded. - if (empty($questiondata->options->answers)) { - if ($questiondata->options->isexercise) { - return array($questiondata->id => - array(null => new question_possible_response("Response graded automatically", null))); - } - return array($questiondata->id => array(null => new question_possible_response("Response graded manually", null))); - } - - $responses = array(); /* * If one fraction is 1 for a particular answer then all other fractions may be irrelevant for correct response * for example answer[0] = e, fraction[0] = 1; answer[1] = e1, fraction[1] = 0.5; @@ -155,6 +146,19 @@ public function get_possible_responses($questiondata) { * since Case 2 could be reformulated to answer[0] = e, fraction[0] = 0.5; answer[1] = e1, * fraction[1] = 0.5 also resulting in the same grades. */ + /* + public function get_possible_responses($questiondata) { + //Twingsister this is left unchanged numerical answers are considered binary with true when equal to 1. + // There are no possible answers which can be calculated if answers array is empty i.e. question is manually graded. + if (empty($questiondata->options->answers)) { + if ($questiondata->options->isexercise) { + return array($questiondata->id => + array(null => new question_possible_response("Response graded automatically", null))); + } + return array($questiondata->id => array(null => new question_possible_response("Response graded manually", null))); + } + + $responses = array(); $answers = $questiondata->options->answers; $count = pow(2, count($answers)) - 1; for ($i = $count; $i >= 0; $i--) { @@ -186,6 +190,7 @@ public function get_possible_responses($questiondata) { return array($questiondata->id => $responses); } + */ /** * Initialise the common question_definition fields. diff --git a/renderer.php b/renderer.php index cedf71f..69267ce 100644 --- a/renderer.php +++ b/renderer.php @@ -22,7 +22,7 @@ * @copyright (c) International GeoGebra Institute 2014 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - +require_once($CFG->dirroot . '/question/type/geogebra/question.php'); /** * Generates the output for geogebra questions. */ @@ -227,8 +227,11 @@ public function specific_feedback(question_attempt $qa) { } else { $response = $qa->get_last_qt_var('answer'); $i = 0; + $resparray=unpack_resp($response); foreach ($question->answers as $answer) { - if ((bool)substr($response, $i, 1)) { + // Twingsister legacy support: for boolean answers show feedback + if (array_key_exists($answer->answer,$resparray)&& $resparray[$answer->answer] =="true"){ + // (bool)substr($response, `$i, 1)) { $feedback .= $question->format_text($answer->feedback, $answer->feedbackformat, $qa, 'question', 'answerfeedback', $answer->id); } From ff08a80c02b00d092db888ec97b9a908a66ee88c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 22 Apr 2023 23:39:28 +0200 Subject: [PATCH 44/60] grading ok --- amd/build/ggbq.min.js.map | 2 +- amd/build/ggbt.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/build/ggbq.min.js.map b/amd/build/ggbq.min.js.map index c471430..503fe63 100644 --- a/amd/build/ggbq.min.js.map +++ b/amd/build/ggbq.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAqBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBE,YAAY,IAAIE,MAAM,QAGnCJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAGrCzB,OAAO0B,gBAAkB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WH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAAS8D,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAO7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBE,YAAY,IAAIE,MAAM,QAGnCJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iB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73243c7 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n\r\n injectapplet: function(fileURL) {\r\n if(this.hasOwnProperty('parameters')){\r\n if(this.hasOwnProperty('ggbBase64')){delete this.parameters.ggbBase64;}\r\n } else { this.parameters=null;}\r\n this.parameters = {...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","hasOwnProperty","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAYA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAEHC,KAAM,cAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACzBC,YACIP,EAAE,+BAA+BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQC,kBACnEZ,EAAE,0BAA0BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQE,aAC9Db,EAAE,oCAAoCQ,IAAIL,OAAOQ,QAAQG,gCAE1B,IAAnBT,KAAKU,UAA2B,KACpCC,OAAS3B,SAAS4B,UACtBjB,EAAE,wBAAwBQ,IAAIQ,OAAOE,UAEjB7B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKe,sBAGZC,EAAI,EACJC,OAASrB,EAAE,cAAgBoB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFtB,OAAOC,KAAKsB,gBAAgB1B,EAAEwB,EAAEG,YAEpCxB,OAAOC,KAAKsB,gBAAgBL,SAEhCA,OAASrB,EAAE,iBAAkBoB,GAEjC/B,SAASuC,cAAc,WAAWC,WAAa1B,OAAO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K8G,cAAc3H,QAC/DY,OAAOC,KAAKgC,WAAWuF,YAAcxH,OAAOC,KAAK+G,cAAc5H,QAC/DY,OAAOC,KAAKgC,WAAWwC,OAAS,8BAMhCzE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ+B,iBAAiBtD,UAEjDe,OAAOQ,QAAQ0C,OAAO,sBAG1BmF,OAAOM,cAAcvE,QAI7BrB,SAAU,SAAS6F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n\r\n injectapplet: function(fileURL) {\r\n if(this.hasOwnProperty('parameters')){\r\n if(this.hasOwnProperty('ggbBase64')){delete this.parameters.ggbBase64;}\r\n } else { this.parameters=null;}\r\n this.parameters = {...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","hasOwnProperty","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAaA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAGHC,KAAM,cAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACzBC,YACIP,EAAE,+BAA+BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQC,kBACnEZ,EAAE,0BAA0BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQE,aAC9Db,EAAE,oCAAoCQ,IAAIL,OAAOQ,QAAQG,gCAE1B,IAAnBT,KAAKU,UAA2B,KACpCC,OAAS3B,SAAS4B,UACtBjB,EAAE,wBAAwBQ,IAAIQ,OAAOE,UAEjB7B,SAASC,eAAe,oBACzBG,O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AKgC,WAAWmF,cAAgBpH,OAAOC,KAAK2G,gBAAgBxH,QACnEY,OAAOC,KAAKgC,WAAWkF,eAAiBnH,OAAOC,KAAK0G,iBAAiBvH,QACrEY,OAAOC,KAAKgC,WAAWoF,oBAAsBrH,OAAOC,KAAK4G,uBAAuBzH,QAChFY,OAAOC,KAAKgC,WAAWqF,iBAAmBtH,OAAOC,KAAK6G,mBAAmB1H,QACzEY,OAAOC,KAAKgC,WAAWsF,YAAcvH,OAAOC,KAAK8G,cAAc3H,QAC/DY,OAAOC,KAAKgC,WAAWuF,YAAcxH,OAAOC,KAAK+G,cAAc5H,QAC/DY,OAAOC,KAAKgC,WAAWwC,OAAS,8BAMhCzE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ+B,iBAAiBtD,UAEjDe,OAAOQ,QAAQ0C,OAAO,sBAG1BmF,OAAOM,cAAcvE,QAI7BrB,SAAU,SAAS6F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file From 7cce494a531eb01d049e649004069b423df2901a Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 22 Apr 2023 23:41:04 +0200 Subject: [PATCH 45/60] version bump --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 5f23720..dcd5584 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024100400; +$plugin->version = 2024220400; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From df3a50b84ccdefb4c6767b00457dc97763236c9e Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 1 May 2023 12:52:41 +0200 Subject: [PATCH 46/60] no delete in the default toolbar --- amd/src/ggbq.js | 2 +- version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 2594a5a..a2c9b7d 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -202,7 +202,7 @@ define(['jquery'], function ($) { //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple); if(!parameters.showToolBar){ parameters.showToolBar=true; - parameters.customToolBar="40,0,1,41,42,50,38,6"; + parameters.customToolBar="40,0,1,41,42,50,38";//,6"; } // parameters.enableUndoRedo=false; //user controlled //parameters.showResetIcon=false;// user defined diff --git a/version.php b/version.php index dcd5584..eb1f2da 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024220400; +$plugin->version = 2024010500; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 55e60ca80ba79a68b35ca4f5066b4de7959a9f84 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 7 May 2023 10:35:55 +0200 Subject: [PATCH 47/60] added seed 100-110 unique w.r.t. userid --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- renderer.php | 22 +++++++++++++++++++++- version.php | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index a3926d5..e80a7d9 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBE,YAAY,IAAIE,MAAM,QAGnCJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAGrCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAAU,GAC3BtD,UAAYuB,OAAO2B,aACnBK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A,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAQ7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBE,YAAY,IAAIE,MAAM,QAGnCJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,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AIhC,WAAW1B,WAAWoE,kBACvB,KAAXrB,UAAgBY,QAAQU,iBAAiBtB,UAClDY,QAAQW,OAAOtE,WAAWuE,IAAK,kBAQhCrG,EAAE,iBAAiBsG,GAAG,SAAUpE,KAAKqE,mBAErCvG,EAAEU,SAASyB,eAAeL,WAAWuE,MAAMC,GAAG,aAAcpE,KAAKqE,wBAE5D7E,YAAYW,MAAQP,WAAWyC,UAC/B5C,YAAYU,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWH,mBACzDC,oBAAoBS,MAAQrC,EAAEU,SAASyB,eAAeL,WAAWF,2BACjEvC,aAAagD,MAAQS,KAAKC,MAAMjB,WAAWzC,eAEpDqD,WAAY,SAAS8D,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAQ7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file diff --git a/renderer.php b/renderer.php index 69267ce..2ebed1f 100644 --- a/renderer.php +++ b/renderer.php @@ -27,6 +27,24 @@ * Generates the output for geogebra questions. */ class qtype_geogebra_renderer extends qtype_renderer { + function remapSeed(int $seed) { + global $USER; + if($seed<100) return $seed; + elseif(100<=$seed && $seed<=110){ + // use 100 101 102 to have three different exercises + // unique across the class + //debug_break(); + return abs(intval($USER->id))+($seed-100); + // other option for implementation + //$COURSE in particular $COURSE->id a string + // $USER->idnumber a string for a natural that is set by the user + // SOME seed beyond 100 are remapped + // a seed smaller that 100 [1-99] will a generatea a constantly applied seed + // 100 will remap to $USER + // other codes i[rpvide room for remaps that align + // tests for groups courseso roles + } else {return $seed;} + } /** * Generate the display of the formulation part of the question. This is the @@ -134,7 +152,9 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $appletparametersid = $qa->get_qt_field_name('applet_parameters'); $forcedimensions = $question->forcedimensions ?: 0; $seeditornot = $question->seeditornot ?: 0; - $seed = $question->seed ?: 0; + $seed = $question->seed ?: 0;// here generate a particular seed out of $questions->seed + $seed=$this-> + remapSeed($seed); $width = $question->width ?: 0; $height = $question->height ?: 0; $isurlggb = $question->isurlggb ?: 0; diff --git a/version.php b/version.php index eb1f2da..921e553 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024010500; +$plugin->version = 2024110500; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 456e6d9117be3b97d1b2efd7a8de14dd3a09f9c4 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 7 May 2023 16:33:48 +0200 Subject: [PATCH 48/60] version bump --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 921e553..6aaff25 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024110500; +$plugin->version = 2024220401; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 6f49f456cb8a6c51716206e0c8e80a4e00f25b13 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 17 Jun 2023 17:04:53 +0200 Subject: [PATCH 49/60] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f523f9a..935b128 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ repository installed) - Load the Applet. Variables which could be randomized or can be used for checking correctness, will be extracted automatically - Choose the fraction which goes with the boolean variable - Save the question and use it for your quiz -- You can add a seed so that all random values are the same for all the class. +- You can add a seed so that all random values selected in the exercise generation are the same for all the class. Seed from 1 to 99 are applied as they are and cause all the cless to receive the same version of the exercise. Seeds from 100 to 110 ensure that a random seed is generated taking int account a system user id so that each student receive a disting exercise and always the same exercise upon different attempts. Do not use any seed or 0 to have a distinct exercise for every student and different exercises upon repeated attempts. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) - You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as in [this repository](https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/deployggb.js). In this case you should supply a comma separated string like "https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/,deployggb.js,HTML5/5.0/web3d". From 9a82eaa40cf5819e0fd1511fcac6179dfe6436b7 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 29 Jan 2024 18:23:44 +0100 Subject: [PATCH 50/60] Added reload question ggb fike from scratch, ask for save, resist errors juste grade discrepancy --- README.md | 2 +- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 139 +++++++++++++++++++++++++++++++++----- renderer.php | 36 ++++++++-- version.php | 2 +- 6 files changed, 156 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 935b128..d4e7662 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ repository installed) - Load the Applet. Variables which could be randomized or can be used for checking correctness, will be extracted automatically - Choose the fraction which goes with the boolean variable - Save the question and use it for your quiz -- You can add a seed so that all random values selected in the exercise generation are the same for all the class. Seed from 1 to 99 are applied as they are and cause all the cless to receive the same version of the exercise. Seeds from 100 to 110 ensure that a random seed is generated taking int account a system user id so that each student receive a disting exercise and always the same exercise upon different attempts. Do not use any seed or 0 to have a distinct exercise for every student and different exercises upon repeated attempts. +- You can add a seed so that all random values selected in the exercise generation are the same for all the class. Seed from 1 to 99 are applied as they are and cause all the cless to receive the same version of the exercise. Seeds from 101 to 109 ensure that a random seed is generated taking int account a system user id so that each student receive a distinct exercise and always the same exercise upon different attempts. Do not use any seed or 0 to have a distinct exercise for every student and different exercises upon repeated attempts. - You can reference a ggb with a plain https URL (see for instance details to reference ggb(s) in [this repository](https://github.com/TWINGSISTER/moodle-qtype_geogebra) reading this [README](https://twingsister.github.io/Moodle-Tests-Repository/)) - You can use an alternate source for the deployggb.js file and a self hosted Geogebra codebase as in [this repository](https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/deployggb.js). In this case you should supply a comma separated string like "https://twingsister.github.io/GeogebraMultilanguageTranslator/Geogebra/geogebra-math-apps-bundle-5-0-latest/GeoGebra/,deployggb.js,HTML5/5.0/web3d". diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index e80a7d9..77a4add 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url)},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;window.GGBQ.filename=ggbDataset.ggbturl;var slot=ggbDataset.slot;scalingContainers[slot]=ggbDataset.scalingcontainerclass,window.ggbAppletOnLoad=function(ggbAppletId){if(-1!=ggbAppletId){document.querySelector("article").onkeydown=this.checkEnter;var id=ggbAppletId.substring(9),ggbApplet=window[ggbAppletId],curvals=JSON.parse(window.GGBQ.currentvals[id]);for(var label in curvals)ggbApplet.setValue(label,curvals[label]);resizeScalingContainer(),window.removeEventListener("resize",resizeScalingContainer),window.addEventListener("resize",resizeScalingContainer),window.GGBQ.b64input[id].val(ggbApplet.getBase64()),window.GGBQ.xmlinput[id].val(ggbApplet.getXML()),window.GGBQ.qdiv[id]={style:{visibility:"visible"}},""==window.GGBQ.answerinput[id].val()&&window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet)),window.GGBQ.scratchMark&&(ggbApplet.evalCommand('Text("QUIZ RELOADED")'),window.GGBQ.scratchMark=!1)}else alert("Applet not found, please reload this page"),location.reload()},this.b64input[slot]=$(document.getElementById(ggbDataset.b64input)),this.ggbBase64[slot]=this.b64input[slot].val(),this.xmlinput[slot]=$(document.getElementById(ggbDataset.xmlinput)),this.ggbxml[slot]=this.xmlinput[slot].val(),this.qdiv[slot]=$("#q"+slot+" .qtext")[0];var parameters=JSON.parse(ggbDataset.parameters);if(""!=this.ggbBase64[slot]&&(parameters.ggbBase64=this.ggbBase64[slot]),window.GGBQ.scratchit){var httpurl=window.GGBQ.filename;httpurl.startsWith("http")?(delete parameters.ggbBase64,parameters.filename=httpurl,window.GGBQ.scratchMark=!0):alert("Reloading from Geogebra Tube not implemented")}if(ggbDataset.seeditornot&&"0"!==ggbDataset.seeditornot)parameters.randomSeed=ggbDataset.seed;else{var dice=Math.floor(1e3*Math.random()+1);parameters.randomSeed=dice}if(ggbDataset.forcedimensions&&"0"!==ggbDataset.forcedimensions){parameters.width=ggbDataset.width,parameters.height=ggbDataset.height;var scalingContainer=document.getElementsByClassName(scalingContainers[slot])[0];scalingContainer&&(scalingContainer.style.overflowX="auto",scalingContainer.style.overflowY="hidden")}else parameters.scaleContainerClass=scalingContainers[slot],parameters.autoHeight=!0;this.ggbDatasetVars=JSON.parse(ggbDataset.vars),parameters.language=ggbDataset.lang,parameters.moodle="takingQuiz",delete parameters.material_id,parameters.id="ggbApplet"+slot;var GGBAppletname,codebase;JSON.parse(ggbDataset.views);if(debugcode(),ggbDataset.isurlggb&&"0"!==ggbDataset.isurlggb){var parts=ggbDataset.urlggb.split(","),root=parts[0],appl=parts[1],base=parts[2];GGBAppletname=root+appl,codebase=root+base}else GGBAppletname="https://www.geogebra.org/apps/deployggb.js",codebase="";require([GGBAppletname],(function(App){var applet1;parameters.showToolBar||(parameters.showToolBar=!0,parameters.customToolBar="40,0,1,41,42,50,38"),parameters.preventFocus=!0,parameters.allowStyleBar=!1,parameters.transparentGraphics=!1,parameters.playButton=!1,parameters.autoHeight=!1,parameters.allowUpscale=!0,parameters.showFullscreenButton=!0,applet1=new App(parameters,ggbDataset.html5nowebsimple),debugcode(),""!==codebase&&applet1.setHTML5Codebase(codebase),applet1.inject(ggbDataset.div,"preferHTML5")})),$("#responseform").on("submit",this.preGetBase64andCheck),$(document.getElementById(ggbDataset.div)).on("mouseleave",this.getBase64andCheck),this.currentvals[slot]=ggbDataset.vars,this.answerinput[slot]=$(document.getElementById(ggbDataset.answerinput)),this.exerciseresultinput[slot]=$(document.getElementById(ggbDataset.exerciseresultinput)),this.responsevars[slot]=JSON.parse(ggbDataset.responsevars)},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},preGetBase64andCheck:function(){this.getBase64andCheck()},getBase64andCheck:function(){if(debugcode(),confirm("Do you want to save your work?"))for(var i=0;i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 250);\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //applet1,\r\n\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n //debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n }\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) {\r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n });\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array of strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n getBase64andCheck: function() {\r\n debugcode();\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\") {\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) {\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) {\r\n // Twingsister\r\n window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet));\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //} else {\r\n // responsestring += 0;\r\n //}\r\n //}\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["stringfy","responsevars","ggbApplet","responsestring","forEach","responsevar","isDefined","value","getValue","getObjectType","replace","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","init","appletParametersID","GGBQ","this","getElementById","dataset","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","parameters","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","debugcode","isurlggb","parts","urlggb","split","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","i","length","entries","key","evalCommand"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,SAASC,aAAaC,eAEzBC,eAAiB,UACrBF,aAAaG,SAAQ,SAAUC,gBAC1BH,UAAUI,UAAUD,aAAa,KAChCE,MAAQL,UAAUM,SAASH,aACW,WAAtCH,UAAUO,cAAcJ,eAAyBE,MAAmB,GAAVA,MAAa,QAAQ,QACnFJ,gBAAkBE,YAAY,IAAIE,MAAM,QAGnCJ,eAAeO,QAAQ,MAAM,GACpC,CAeVC,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBV,SAAQ,SAACgB,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,cAAc,UAAUC,cAAcA,eAC3DP,iBAAiBQ,MAAMC,MAAQC,SAASP,oBAAoBM,OACtDC,SAASP,oBAAoBQ,aAAeD,SAASP,oBAAoBS,cAAgB,UAC/F,YAET,CACHC,SAAU,GACVC,UAAW,GACXC,SAAU,GACVC,OAAQ,GACRC,YAAa,GACbC,YAAa,GACbtC,aAAc,GACduC,oBAAqB,GACrBC,KAAM,GAENC,WAAY,GAGZC,KAAM,SAAUC,oBACZnB,OAAOoB,KAAOC,SAEVJ,WAAapB,SAASyB,eAAeH,oBAAoBI,QACzDC,KAAOP,WAAWO,KAEtBnC,kBAAkBmC,MAAQP,WAAWQ,sBAGrCzB,OAAO0B,gBAAkB,SAAUC,iBACX,GAAhBA,YAAmB,CACnB9B,SAASK,cAAc,WAAW0B,UAAYP,KAAKQ,eAC/CC,GAAKH,YAAYI,UAAU,GAC3BtD,UAAYuB,OAAO2B,aACnBK,QAAUC,KA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AAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAQ7DT,kBAAmB,WACnBxB,gBACS,IAAIkC,EAAI,EAAGA,EAAIpG,OAAOoB,KAAKN,YAAYuF,OAAQD,IAAK,KACjD3H,UAAYuB,OAAO,YAAcoG,WACZ,IAAd3H,UAA2B,CAClCuB,OAAOoB,KAAKX,SAAS2F,GAAG7D,IAAI9D,UAAU+D,aACtCxC,OAAOoB,KAAKT,SAASyF,GAAG7D,IAAI9D,UAAUgE,uCAGXhD,OAAO6G,QAAQtG,OAAOoB,KAAKqC,+CAAiB,8DAA3D8C,0BAAKzH,4BACbL,UAAU+H,sBAAeD,gBAAOzH,QAOhCkB,OAAOoB,KAAKN,YAAYsF,GAAG7D,IAAIhE,SAASyB,OAAOoB,KAAK5C,aAAa4H,GAAG3H,eAc3F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function unpackStringified(s){\r\n\t\t var couples=s.split(\"%\");\r\n\t\t var results={};\r\n\t\t couples.forEach(function (couple, index) {\r\n\t\t var twos=couple.split(\":\");results[twos[0]]=twos[1];\r\n \t\t });\r\n \t\t return results;\r\n \t\t}\r\n function packStringified(a){\r\n\t\t var results=\"\";\r\n\t\t for(var key in a) {\r\n \t\t\tvar value = a[key];\r\n results += key+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n\t\t }\r\n return results.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n \t\t}\r\n \t\tfunction isInGGB(v,ggbApplet){return ggbApplet.isDefined(v);}\r\n \t\tfunction fromGGB(v,ggbApplet){\r\n \t\t\tvar res=ggbApplet.getValue(v);\r\n if (ggbApplet.getObjectType(v)==\"boolean\"){res = (res == 0 ?false:true);}\r\n \t\t \treturn res; \r\n \t\t }\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function () {\r\n\t\t\tlet url = window.location.href; \r\n\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\turl += '&scratch=1'\r\n\t\t\t} else {\r\n\t\t\t url += '?scratch=1'\r\n\t\t\t}\r\n\t\t\t//window.location.href = url;\r\n\t\t\t//window.location.reload();\r\n\t\t\twindow.location.replace(url);\r\n\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t//window.GGBQ.init(appletParametersID); \r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n\t\t\twindow.GGBQ.filename=ggbDataset.ggbturl;// the filename \r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //}\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchMark","filename","checkLoading","appletParametersID","scratchinit","GGBQ","this","init","scratch","url","location","href","indexOf","debugcode","getElementById","dataset","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","alert","reload","parameters","httpurl","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","confirm","i","length","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAC1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAUI,SAASL,SACY,WAA5BC,UAAUK,cAAcN,KAAeI,IAAe,GAARA,KAChDA,GACR,CACE,SAASG,SAASC,aAAaP,eAEzBQ,eAAiB,UACrBD,aAAajB,SAAQ,SAAUmB,gBAC1BT,UAAUC,UAAUQ,aAAa,KAChCC,MAAQV,UAAUI,SAASK,aACW,WAAtCT,UAAUK,cAAcI,eAAyBC,MAAmB,GAAVA,MAAa,QAAQ,QACnFF,gBAAkBC,YAAY,IAAIC,MAAM,QAGnCF,eAAeX,QAAQ,MAAM,GACpC,CAeVc,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBxB,SAAQ,SAAC8B,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OA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AY,SAASkE,UACjBA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAS7DV,qBAAsB,gBAAiBC,qBAEvCA,kBAAmB,cACnB1E,YACIoF,QAAQ,sCACH,IAAIC,EAAI,EAAGA,EAAIrH,OAAOwB,KAAKV,YAAYwG,OAAQD,IAAK,KACjD9I,UAAYyB,OAAO,YAAcqH,WACZ,IAAd9I,WAA6BA,UAAUgJ,eAAe,aAAc,CAG3EvH,OAAOwB,KAAKf,SAAS4G,GAAGlE,IAAI5E,UAAU6E,aACtCpD,OAAOwB,KAAKb,SAAS0G,GAAGlE,IAAI5E,UAAU8E,uCAGX5D,OAAO+H,QAAQxH,OAAOwB,KAAKkD,+CAAiB,8DAA3DvG,0BAAKc,4BACbV,UAAUgF,sBAAepF,gBAAOc,YAO5BwI,KAAK5I,SAASmB,OAAOwB,KAAK1C,aAAauI,GAAG9I,WAG3DmJ,QAAUlK,kBAAkBiK,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBrJ,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWmJ,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjBlE,MAAM,0BAWRiE,KAAKxJ,gBAAgByJ,SACT1H,OAAOwB,KAAKV,YAAYuG,GAAGlE,IAAIsE,gBAST,IAAdlJ,YAA2BiF,MAAM,mBAAmB3B,SAAS4B,YAK5F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index a2c9b7d..663e638 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -21,6 +21,28 @@ // alert("hello ggbq"); //debugger; // eslint-disable-line //debugcode(); + function unpackStringified(s){ + var couples=s.split("%"); + var results={}; + couples.forEach(function (couple, index) { + var twos=couple.split(":");results[twos[0]]=twos[1]; + }); + return results; + } + function packStringified(a){ + var results=""; + for(var key in a) { + var value = a[key]; + results += key+":"+value+'%'; //Twingsister to deal with multidigit + } + return results.replace(/\%$/,""); // possibly cut the last % works better with explode + } + function isInGGB(v,ggbApplet){return ggbApplet.isDefined(v);} + function fromGGB(v,ggbApplet){ + var res=ggbApplet.getValue(v); + if (ggbApplet.getObjectType(v)=="boolean"){res = (res == 0 ?false:true);} + return res; + } function stringfy(responsevars,ggbApplet){ //debugcode(); var responsestring = ''; @@ -65,7 +87,7 @@ define(['jquery'], function ($) { scalingContainer.querySelector('.qtext').parentElement.parentElement); scalingContainer.style.width = parseInt(formulationDivStyle.width) - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px'; - }), 250); + }), 5000); //Twingsister mod was 250 }; return { b64input: [], @@ -79,12 +101,47 @@ define(['jquery'], function ($) { qdiv: [], //parameters: {}, //before not global ggbDataset: [], + //confirmedpage: false, //Twingsister the user says sees a correct page + scratchit: false, //Twingsister turns init into a reload from file delete all what you have done + scratchMark: false, + filename:"", //applet1, - + checkLoading: function (appletParametersID){return; + if(!this.confirmedpage){ + if(confirm("if something loaded (could be an empty cartesian plane) say ok")){ + window.GGBQ.scratch(appletParametersID); + location.reload();return true; + if(confirm("if it looks as a correct question say ok")){this.confirmedpage=true;} + else {if(confirm("if it is an empty cartesian plane, please say ok to reload")){location.reload();return;}} + } + } + }, + // Twingsister load from filename + scratchinit: function (appletParametersID) { + window.GGBQ = this; + window.GGBQ.scratchit=true; + window.GGBQ.init(appletParametersID); + }, + scratch: function () { + let url = window.location.href; + if (url.indexOf('?') > -1){ + url += '&scratch=1' + } else { + url += '?scratch=1' + } + //window.location.href = url; + //window.location.reload(); + window.location.replace(url); + // window.location.hash = 'varA=some_value;varB=some_value'; + //window.GGBQ.init(appletParametersID); + }, init: function (appletParametersID) { + ////this.scratchit=true; + //this.confirmedpage=false;//Twingsister window.GGBQ = this; - //debugcode(); + debugcode(); var ggbDataset = document.getElementById(appletParametersID).dataset; + window.GGBQ.filename=ggbDataset.ggbturl;// the filename var slot = ggbDataset.slot; // Add current scaling container to the object store for being able to access it later on. scalingContainers[slot] = ggbDataset.scalingcontainerclass; @@ -106,7 +163,7 @@ define(['jquery'], function ($) { // We only need one for the whole page. window.removeEventListener('resize', resizeScalingContainer); window.addEventListener('resize', resizeScalingContainer); - + //window.GGBQ.checkLoading(appletParametersID); window.GGBQ.b64input[id].val(ggbApplet.getBase64()); window.GGBQ.xmlinput[id].val(ggbApplet.getXML()); @@ -121,7 +178,11 @@ define(['jquery'], function ($) { //ggbApplet.setWidth(100); //ggbApplet.setPerspective("GD"); } - } + if(window.GGBQ.scratchMark){ + ggbApplet.evalCommand('Text("QUIZ RELOADED")'); + window.GGBQ.scratchMark=false; + } + } else {alert("Applet not found, please reload this page");location.reload();} }; // jquery doesn't handle the colon : but later we expect a jquery optject, so ... @@ -138,7 +199,14 @@ define(['jquery'], function ($) { if (this.ggbBase64[slot] != '') { parameters.ggbBase64 = this.ggbBase64[slot]; } - + if(window.GGBQ.scratchit){ + var httpurl = window.GGBQ.filename; + if(httpurl.startsWith('http')){ + delete parameters.ggbBase64; + parameters.filename=httpurl + window.GGBQ.scratchMark=true; + }else{alert("Reloading from Geogebra Tube not implemented")} + } // Check if seed have been manually set. The default would be "no" //alert("entering the seed"); //debugcode(); @@ -194,7 +262,7 @@ define(['jquery'], function ($) { codebase = root+base; } //require.config({paths: {gb: GGBAppletname.slice(0,-3)}}); - //require(["gb"], function(gb) { + //require(["gb"], function(gb) //import GGBApplet from GGBAppletname; require([GGBAppletname],function (App){//); @@ -214,23 +282,32 @@ define(['jquery'], function ($) { parameters.allowUpscale=true; // let GGB upscale Applet parameters.showFullscreenButton=true; // let GGB upscale Applet applet1 = new App(parameters,ggbDataset.html5nowebsimple); + debugcode(); + //window.onload = function() + //window.addEventListener("load", function() if (!(codebase==="")){applet1.setHTML5Codebase(codebase)}; + //alert("foo"); applet1.inject(ggbDataset.div, "preferHTML5"); - }); + }); + // Check if seed have been manually set. The default would be "no" + //}) + //} // GGBApplet= // define([GGBAppletname], function (GGBobj) {return GGBobj;}); //alert("applet creation");debugger; //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple); //NO applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); - $('#responseform').on('submit', this.getBase64andCheck); + $('#responseform').on('submit', this.preGetBase64andCheck); + // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); this.currentvals[slot] = ggbDataset.vars; this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput)); this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput)); this.responsevars[slot] = JSON.parse(ggbDataset.responsevars); + //window.GGBQ.checkLoading(appletParametersID); }, checkEnter: function(e) { e = e || event; @@ -238,16 +315,22 @@ define(['jquery'], function ($) { return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13; }, // Twingsister - // takes an an array of strings that are GGB variable names either numeric text or boolean and + // takes an an array o strings that are GGB variable names either numeric text or boolean and // returns a percent % separated string of the values. If no value is present the variable is skipped + //confirmedpage=false,`` + preGetBase64andCheck: function() {this.getBase64andCheck();}, + getBase64andCheck: function() { debugcode(); + if(!confirm("Do you want to save your work?")){return;} for (var i = 0; i < window.GGBQ.answerinput.length; i++) { var ggbApplet = window['ggbApplet' + i]; - if (typeof ggbApplet !== "undefined") { + if (typeof ggbApplet !== "undefined" && ggbApplet.hasOwnProperty("getBase64")) { + //window.GGBQ.checkLoading(ggbApplet); + //if(!this.confirmedpage&&!confirm("Is the applet loaded correctly?")){location.reload();return;}else{this.confirmedpage=true;} window.GGBQ.b64input[i].val(ggbApplet.getBase64()); window.GGBQ.xmlinput[i].val(ggbApplet.getXML()); @@ -257,19 +340,39 @@ define(['jquery'], function ($) { } //var responsestring = ''; - //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) { - //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) { + //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [ + //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [ // Twingsister - window.GGBQ.answerinput[i].val(stringfy(window.GGBQ.responsevars[i],ggbApplet)); + var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet); + //special conditions treatement + // there are both juste and grade juste is true grade is less than one then take it to one + var outputs = unpackStringified(resp); + var justeison=((("juste" in outputs) && outputs["juste"]==="true")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet))); + if(justeison){ + if( ("grade" in outputs)&&(Number(outputs["grade"])<1)){ + outputs["grade"]="1.0"; + alert("maximum mark assigned"); + } + } + // check loading failed to work code below commented out + // Some alert added to help the user to ask for a reload + // if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark + //if(window.hasOwnProperty('RT_R_DBLCHK')&& + // (!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){ + // outputs["grade"]="1.0"; + // alert("maximum mark assigned"); + //} + resp=packStringified(outputs); + window.GGBQ.answerinput[i].val(resp); // Twingsister // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit - //} else { + //] else [ // responsestring += 0; - //} - //} + //] + //] //window.GGBQ.answerinput[i].val(responsestring); //alert("response"); - } + }else{if(typeof ggbApplet !== "undefined"){alert("quiz not loaded");location.reload()}} } }, diff --git a/renderer.php b/renderer.php index 2ebed1f..5c8370b 100644 --- a/renderer.php +++ b/renderer.php @@ -26,13 +26,17 @@ /** * Generates the output for geogebra questions. */ + + + class qtype_geogebra_renderer extends qtype_renderer { function remapSeed(int $seed) { global $USER; if($seed<100) return $seed; elseif(100<=$seed && $seed<=110){ - // use 100 101 102 to have three different exercises + // use 101 102 to 109 have three different exercises // unique across the class + // note that 100 and 110 could give problems not always true in PHP x<=x //debug_break(); return abs(intval($USER->id))+($seed-100); // other option for implementation @@ -59,7 +63,6 @@ function remapSeed(int $seed) { * @return string HTML fragment. */ public function formulation_and_controls(question_attempt $qa, question_display_options $options) { - $scalingcontainerclass = $qa->get_qt_field_name('scalingcontainer'); $result = html_writer::start_div($scalingcontainerclass); @@ -153,14 +156,14 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $forcedimensions = $question->forcedimensions ?: 0; $seeditornot = $question->seeditornot ?: 0; $seed = $question->seed ?: 0;// here generate a particular seed out of $questions->seed - $seed=$this-> - remapSeed($seed); + $seed=$this->remapSeed($seed); $width = $question->width ?: 0; $height = $question->height ?: 0; $isurlggb = $question->isurlggb ?: 0; $urlggb = $question->urlggb ?: 0; //$isurlggbact = $question->isurlggbact ?: 0; //$urlggbact = $question->urlggbact ?: 0; + $ggbturl = $question->ggbturl ?: 0; $applet = <<ggbparameters @@ -183,12 +186,18 @@ public function formulation_and_controls(question_attempt $qa, question_display_ data-height=$height data-isurlggb=$isurlggb data-urlggb=$urlggb + data-ggbturl=$ggbturl data-scalingcontainerclass=$scalingcontainerclass EOD; $result .= $applet; echo ""; - $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); + if (isset($_GET['scratch'])&& + (strcmp(htmlspecialchars($_GET['scratch']),"1")==0)){ + $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'scratchinit', array($appletparametersid)); + }else{ + $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); + } if ($qa->get_state() == question_state::$invalid) { $result .= html_writer::nonempty_tag('div', @@ -200,6 +209,23 @@ public function formulation_and_controls(question_attempt $qa, question_display_ } $result .= html_writer::end_div(); + if($ggbturl!=0){ + $button =html_writer::tag('button', 'Reload (stamped)', + array('class'=>'mod_quiz-next-nav btn btn-primary', 'type' => 'button', + //'onclick'=>'window.GGBQ.scratchjson('.$parjson.');' + //'onclick'=>'window.GGBQ.scratch("'.$appletparametersid.'")' + 'onclick'=>'window.GGBQ.scratch()' + ) + ); + $result=$button.$result; + } + // twingsister + // $parjson = "{".$appletparametersid."}"; + //$parjson=json_encode_advanced(array($appletparametersid), $sequential_keys = true, $quotes = true); + //echo $parjson;die; + //$scalingcontainerclass = $qa->get_qt_field_name('scalingcontainer'); + //$result = html_writer::start_div($scalingcontainerclass); + //$result .= html_writer::end_div(); return $result; } diff --git a/version.php b/version.php index 6aaff25..765cc3e 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024220401; +$plugin->version = 2024220402; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 1c948ad7753384345e9a2b6af42b2c168d2f6942 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 4 Feb 2024 21:22:13 +0100 Subject: [PATCH 51/60] added comment --- amd/src/ggbq.js | 1 + 1 file changed, 1 insertion(+) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 663e638..7ac75ce 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -30,6 +30,7 @@ return results; } function packStringified(a){ + //key:value%key:value FORMAT IS THIS!!! NO TRAILING % var results=""; for(var key in a) { var value = a[key]; From d13b04cb91932f0b695c002894da0e95948d115c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 4 Feb 2024 21:34:28 +0100 Subject: [PATCH 52/60] added a comment --- amd/src/ggbq.js | 1 + 1 file changed, 1 insertion(+) diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 7ac75ce..243d413 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -31,6 +31,7 @@ } function packStringified(a){ //key:value%key:value FORMAT IS THIS!!! NO TRAILING % + // DECODED IN Liveviewgrid locallib.php ggbTotal var results=""; for(var key in a) { var value = a[key]; From 9131dce3086a2917ece23e082303d38990c3167d Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 4 Feb 2024 21:34:44 +0100 Subject: [PATCH 53/60] added a comment --- amd/build/ggbq.min.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/build/ggbq.min.js.map b/amd/build/ggbq.min.js.map index 881ed3e..a4a4937 100644 --- a/amd/build/ggbq.min.js.map +++ b/amd/build/ggbq.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function unpackStringified(s){\r\n\t\t var couples=s.split(\"%\");\r\n\t\t var results={};\r\n\t\t couples.forEach(function (couple, index) {\r\n\t\t var twos=couple.split(\":\");results[twos[0]]=twos[1];\r\n \t\t });\r\n \t\t return results;\r\n \t\t}\r\n function packStringified(a){\r\n\t\t var results=\"\";\r\n\t\t for(var key in a) {\r\n \t\t\tvar value = a[key];\r\n results += key+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n\t\t }\r\n return results.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n \t\t}\r\n \t\tfunction isInGGB(v,ggbApplet){return ggbApplet.isDefined(v);}\r\n \t\tfunction fromGGB(v,ggbApplet){\r\n \t\t\tvar res=ggbApplet.getValue(v);\r\n if (ggbApplet.getObjectType(v)==\"boolean\"){res = (res == 0 ?false:true);}\r\n \t\t \treturn res; \r\n \t\t }\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function () {\r\n\t\t\tlet url = window.location.href; \r\n\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\turl += '&scratch=1'\r\n\t\t\t} else {\r\n\t\t\t url += '?scratch=1'\r\n\t\t\t}\r\n\t\t\t//window.location.href = url;\r\n\t\t\t//window.location.reload();\r\n\t\t\twindow.location.replace(url);\r\n\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t//window.GGBQ.init(appletParametersID); \r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n\t\t\twindow.GGBQ.filename=ggbDataset.ggbturl;// the filename \r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //}\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchMark","filename","checkLoading","appletParametersID","scratchinit","GGBQ","this","init","scratch","url","location","href","indexOf","debugcode","getElementById","dataset","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","alert","reload","parameters","httpurl","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","confirm","i","length","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,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AU8E,uCAGX5D,OAAO+H,QAAQxH,OAAOwB,KAAKkD,+CAAiB,8DAA3DvG,0BAAKc,4BACbV,UAAUgF,sBAAepF,gBAAOc,YAO5BwI,KAAK5I,SAASmB,OAAOwB,KAAK1C,aAAauI,GAAG9I,WAG3DmJ,QAAUlK,kBAAkBiK,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBrJ,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWmJ,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjBlE,MAAM,0BAWRiE,KAAKxJ,gBAAgByJ,SACT1H,OAAOwB,KAAKV,YAAYuG,GAAGlE,IAAIsE,gBAST,IAAdlJ,YAA2BiF,MAAM,mBAAmB3B,SAAS4B,YAK5F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function unpackStringified(s){\r\n\t\t var couples=s.split(\"%\");\r\n\t\t var results={};\r\n\t\t couples.forEach(function (couple, index) {\r\n\t\t var twos=couple.split(\":\");results[twos[0]]=twos[1];\r\n \t\t });\r\n \t\t return results;\r\n \t\t}\r\n function packStringified(a){\r\n //key:value%key:value FORMAT IS THIS!!! NO TRAILING %\r\n // DECODED IN Liveviewgrid locallib.php ggbTotal\r\n\t\t var results=\"\";\r\n\t\t for(var key in a) {\r\n \t\t\tvar value = a[key];\r\n results += key+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n\t\t }\r\n return results.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n \t\t}\r\n \t\tfunction isInGGB(v,ggbApplet){return ggbApplet.isDefined(v);}\r\n \t\tfunction fromGGB(v,ggbApplet){\r\n \t\t\tvar res=ggbApplet.getValue(v);\r\n if (ggbApplet.getObjectType(v)==\"boolean\"){res = (res == 0 ?false:true);}\r\n \t\t \treturn res; \r\n \t\t }\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function () {\r\n\t\t\tlet url = window.location.href; \r\n\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\turl += '&scratch=1'\r\n\t\t\t} else {\r\n\t\t\t url += '?scratch=1'\r\n\t\t\t}\r\n\t\t\t//window.location.href = url;\r\n\t\t\t//window.location.reload();\r\n\t\t\twindow.location.replace(url);\r\n\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t//window.GGBQ.init(appletParametersID); \r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n\t\t\twindow.GGBQ.filename=ggbDataset.ggbturl;// the filename \r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //}\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchMark","filename","checkLoading","appletParametersID","scratchinit","GGBQ","this","init","scratch","url","location","href","indexOf","debugcode","getElementById","dataset","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","alert","reload","parameters","httpurl","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","confirm","i","length","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAUI,SAASL,SACY,WAA5BC,UAAUK,cAAcN,KAAeI,IAAe,GAARA,KAChDA,GACR,CACE,SAASG,SAASC,aAAaP,eAEzBQ,eAAiB,UACrBD,aAAajB,SAAQ,SAAUmB,gBAC1BT,UAAUC,UAAUQ,aAAa,KAChCC,MAAQV,UAAUI,SAASK,aACW,WAAtCT,UAAUK,cAAcI,eAAyBC,MAAmB,GAAVA,MAAa,QAAQ,QACnFF,gBAAkBC,YAAY,IAAIC,MAAM,QAGnCF,eAAeX,QAAQ,MAAM,GACpC,CAeVc,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBxB,SAAQ,SAAC8B,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,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BA,EAAIA,GAAKC,MACK,YAAYC,MAAMF,EAAEG,QAAUH,EAAEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAS7DV,qBAAsB,gBAAiBC,qBAEvCA,kBAAmB,cACnB1E,YACIoF,QAAQ,sCACH,IAAIC,EAAI,EAAGA,EAAIrH,OAAOwB,KAAKV,YAAYwG,OAAQD,IAAK,KACjD9I,UAAYyB,OAAO,YAAcqH,WACZ,IAAd9I,WAA6BA,UAAUgJ,eAAe,aAAc,CAG3EvH,OAAOwB,KAAKf,SAAS4G,GAAGlE,IAAI5E,UAAU6E,aACtCpD,OAAOwB,KAAKb,SAAS0G,GAAGlE,IAAI5E,UAAU8E,uCAGX5D,OAAO+H,QAAQxH,OAAOwB,KAAKkD,+CAAiB,8DAA3DvG,0BAAKc,4BACbV,UAAUgF,sBAAepF,gBAAOc,YAO5BwI,KAAK5I,SAASmB,OAAOwB,KAAK1C,aAAauI,GAAG9I,WAG3DmJ,QAAUlK,kBAAkBiK,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBrJ,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWmJ,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjBlE,MAAM,0BAWRiE,KAAKxJ,gBAAgByJ,SACT1H,OAAOwB,KAAKV,YAAYuG,GAAGlE,IAAIsE,gBAST,IAAdlJ,YAA2BiF,MAAM,mBAAmB3B,SAAS4B,YAK5F"} \ No newline at end of file From 1220036af23c11c705e73622b992f1fdbe95bbf8 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 11 Mar 2024 16:37:58 +0100 Subject: [PATCH 54/60] reload --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 88 ++++++++++++++++--- .../backup_qtype_geogebra_plugin.class.php | 2 +- db/install.xml | 1 + db/upgrade.php | 9 ++ edit_geogebra_form.php | 10 ++- lang/en/qtype_geogebra.php | 5 +- question.php | 1 + questiontype.php | 2 +- renderer.php | 17 ++-- settings.php | 40 +++++++++ version.php | 2 +- 13 files changed, 155 insertions(+), 26 deletions(-) create mode 100644 settings.php diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 77a4add..39f5715 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url)},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;window.GGBQ.filename=ggbDataset.ggbturl;var slot=ggbDataset.slot;scalingContainers[slot]=ggbDataset.scalingcontainerclass,window.ggbAppletOnLoad=function(ggbAppletId){if(-1!=ggbAppletId){document.querySelector("article").onkeydown=this.checkEnter;var id=ggbAppletId.substring(9),ggbApplet=window[ggbAppletId],curvals=JSON.parse(window.GGBQ.currentvals[id]);for(var label in curvals)ggbApplet.setValue(label,curvals[label]);resizeScalingContainer(),window.removeEventListener("resize",resizeScalingContainer),window.addEventListener("resize",resizeScalingContainer),window.GGBQ.b64input[id].val(ggbApplet.getBase64()),window.GGBQ.xmlinput[id].val(ggbApplet.getXML()),window.GGBQ.qdiv[id]={style:{visibility:"visible"}},""==window.GGBQ.answerinput[id].val()&&window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet)),window.GGBQ.scratchMark&&(ggbApplet.evalCommand('Text("QUIZ RELOADED")'),window.GGBQ.scratchMark=!1)}else alert("Applet not found, please reload this page"),location.reload()},this.b64input[slot]=$(document.getElementById(ggbDataset.b64input)),this.ggbBase64[slot]=this.b64input[slot].val(),this.xmlinput[slot]=$(document.getElementById(ggbDataset.xmlinput)),this.ggbxml[slot]=this.xmlinput[slot].val(),this.qdiv[slot]=$("#q"+slot+" .qtext")[0];var parameters=JSON.parse(ggbDataset.parameters);if(""!=this.ggbBase64[slot]&&(parameters.ggbBase64=this.ggbBase64[slot]),window.GGBQ.scratchit){var httpurl=window.GGBQ.filename;httpurl.startsWith("http")?(delete parameters.ggbBase64,parameters.filename=httpurl,window.GGBQ.scratchMark=!0):alert("Reloading from Geogebra Tube not implemented")}if(ggbDataset.seeditornot&&"0"!==ggbDataset.seeditornot)parameters.randomSeed=ggbDataset.seed;else{var dice=Math.floor(1e3*Math.random()+1);parameters.randomSeed=dice}if(ggbDataset.forcedimensions&&"0"!==ggbDataset.forcedimensions){parameters.width=ggbDataset.width,parameters.height=ggbDataset.height;var scalingContainer=document.getElementsByClassName(scalingContainers[slot])[0];scalingContainer&&(scalingContainer.style.overflowX="auto",scalingContainer.style.overflowY="hidden")}else parameters.scaleContainerClass=scalingContainers[slot],parameters.autoHeight=!0;this.ggbDatasetVars=JSON.parse(ggbDataset.vars),parameters.language=ggbDataset.lang,parameters.moodle="takingQuiz",delete parameters.material_id,parameters.id="ggbApplet"+slot;var GGBAppletname,codebase;JSON.parse(ggbDataset.views);if(debugcode(),ggbDataset.isurlggb&&"0"!==ggbDataset.isurlggb){var parts=ggbDataset.urlggb.split(","),root=parts[0],appl=parts[1],base=parts[2];GGBAppletname=root+appl,codebase=root+base}else GGBAppletname="https://www.geogebra.org/apps/deployggb.js",codebase="";require([GGBAppletname],(function(App){var applet1;parameters.showToolBar||(parameters.showToolBar=!0,parameters.customToolBar="40,0,1,41,42,50,38"),parameters.preventFocus=!0,parameters.allowStyleBar=!1,parameters.transparentGraphics=!1,parameters.playButton=!1,parameters.autoHeight=!1,parameters.allowUpscale=!0,parameters.showFullscreenButton=!0,applet1=new App(parameters,ggbDataset.html5nowebsimple),debugcode(),""!==codebase&&applet1.setHTML5Codebase(codebase),applet1.inject(ggbDataset.div,"preferHTML5")})),$("#responseform").on("submit",this.preGetBase64andCheck),$(document.getElementById(ggbDataset.div)).on("mouseleave",this.getBase64andCheck),this.currentvals[slot]=ggbDataset.vars,this.answerinput[slot]=$(document.getElementById(ggbDataset.answerinput)),this.exerciseresultinput[slot]=$(document.getElementById(ggbDataset.exerciseresultinput)),this.responsevars[slot]=JSON.parse(ggbDataset.responsevars)},checkEnter:function(e){return e=e||event,/textarea/i.test((e.target||e.srcElement).tagName)||13!==(e.keyCode||e.which||e.charCode||0)},preGetBase64andCheck:function(){this.getBase64andCheck()},getBase64andCheck:function(){if(debugcode(),confirm("Do you want to save your work?"))for(var i=0;iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n function unpackStringified(s){\r\n\t\t var couples=s.split(\"%\");\r\n\t\t var results={};\r\n\t\t couples.forEach(function (couple, index) {\r\n\t\t var twos=couple.split(\":\");results[twos[0]]=twos[1];\r\n \t\t });\r\n \t\t return results;\r\n \t\t}\r\n function packStringified(a){\r\n //key:value%key:value FORMAT IS THIS!!! NO TRAILING %\r\n // DECODED IN Liveviewgrid locallib.php ggbTotal\r\n\t\t var results=\"\";\r\n\t\t for(var key in a) {\r\n \t\t\tvar value = a[key];\r\n results += key+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n\t\t }\r\n return results.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n \t\t}\r\n \t\tfunction isInGGB(v,ggbApplet){return ggbApplet.isDefined(v);}\r\n \t\tfunction fromGGB(v,ggbApplet){\r\n \t\t\tvar res=ggbApplet.getValue(v);\r\n if (ggbApplet.getObjectType(v)==\"boolean\"){res = (res == 0 ?false:true);}\r\n \t\t \treturn res; \r\n \t\t }\r\n function stringfy(responsevars,ggbApplet){\r\n //debugcode();\r\n var responsestring = '';\r\n responsevars.forEach(function (responsevar){\r\n if (ggbApplet.isDefined(responsevar)){ \r\n var value = ggbApplet.getValue(responsevar);\r\n if (ggbApplet.getObjectType(responsevar)==\"boolean\"){value = (value == 0 ?\"false\":\"true\");}\r\n responsestring += responsevar+\":\"+value+'%'; //Twingsister to deal with multidigit\r\n }\r\n });\r\n return responsestring.replace(/\\%$/,\"\"); // possibly cut the last % works better with explode\r\n }\r\n// function loadinit(appletParametersID) {\r\n// debugcode();\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n// function loadinit(appletParametersID) {\r\n// var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n // Twingsister\r\n//var GGBAppletstr;\r\n// if (ggbDataset.isurlggb) {\r\n// \tGGBAppletstr = ggbDataset.urlggb;\r\n// } else { GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';}\r\n\r\n // }\r\n//define(['jquery','https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\ndefine(['jquery'], function ($) {\r\n // Created by Christoph on 25.08.19.\r\n\r\n const scalingContainers = {};\r\n let resizeTimeout;\r\n // Resizes the ggb scaling containers to make the ggb applet scale properly to fit into its container.\r\n const resizeScalingContainer = () => {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function () {\r\n\t\t\tlet url = window.location.href; \r\n\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\turl += '&scratch=1'\r\n\t\t\t} else {\r\n\t\t\t url += '?scratch=1'\r\n\t\t\t}\r\n\t\t\t//window.location.href = url;\r\n\t\t\t//window.location.reload();\r\n\t\t\twindow.location.replace(url);\r\n\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t//window.GGBQ.init(appletParametersID); \r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n\t\t\twindow.GGBQ.filename=ggbDataset.ggbturl;// the filename \r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n };\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //}\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchMark","filename","checkLoading","appletParametersID","scratchinit","GGBQ","this","init","scratch","url","location","href","indexOf","debugcode","getElementById","dataset","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","alert","reload","parameters","httpurl","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","confirm","i","length","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAuBQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAU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SAAnBA,QAAO,OAAsBrJ,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWmJ,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjBlE,MAAM,0BAWRiE,KAAKxJ,gBAAgByJ,SACT1H,OAAOwB,KAAKV,YAAYuG,GAAGlE,IAAIsE,gBAST,IAAdlJ,YAA2BiF,MAAM,mBAAmB3B,SAAS4B,YAK5F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAUI,SAASL,SACY,WAA5BC,UAAUK,cAAcN,KAAeI,IAAe,GAARA,KAChDA,GACR,CACE,SAASG,SAASC,aAAaP,eAEzBQ,eAAiB,UACrBD,aAAajB,SAAQ,SAAUmB,gBAC1BT,UAAUC,UAAUQ,aAAa,KAChCC,MAAQV,UAAUI,SAASK,aACW,WAAtCT,UAAUK,cAAcI,eAAyBC,MAAmB,GAAVA,MAAa,QAAQ,QACnFF,gBAAkBC,YAAY,IAAIC,MAAM,QAGnCF,eAAeX,QAAQ,MAAM,GACpC,CAeVc,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBxB,SAAQ,SAAC8B,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,o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AAc+C,WACZ,IAAdxE,WAA6BA,UAAU6J,eAAe,aAAc,CAG3EpI,OAAOyB,KAAKhB,SAASsC,GAAGoB,IAAI5F,UAAU6F,aACtCpE,OAAOyB,KAAKd,SAASoC,GAAGoB,IAAI5F,UAAU8F,uCAGX5E,OAAO4I,QAAQrI,OAAOyB,KAAKiE,+CAAiB,8DAA3DvH,0BAAKc,4BACbV,UAAUgG,sBAAepG,gBAAOc,YAO5BqJ,KAAKzJ,SAASmB,OAAOyB,KAAK3C,aAAaiE,GAAGxE,WAG3DgK,QAAU/K,kBAAkB8K,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBlK,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWgK,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjB/D,MAAM,0BAWR8D,KAAKrK,gBAAgBsK,SACTvI,OAAOyB,KAAKX,YAAYiC,GAAGoB,IAAImE,gBAST,IAAd/J,YAA2BiG,MAAM,mBAAmBxC,SAASyC,YAK5F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 243d413..7918aac 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -21,6 +21,16 @@ // alert("hello ggbq"); //debugger; // eslint-disable-line //debugcode(); + + function cyclerepl(str,dic){ + var alts=dic.length; + var result; + for(var i = 0;i -1){ - url += '&scratch=1' - } else { - url += '?scratch=1' - } - //window.location.href = url; - //window.location.reload(); - window.location.replace(url); - // window.location.hash = 'varA=some_value;varB=some_value'; - //window.GGBQ.init(appletParametersID); + scratch: function (reloadggb) { + let url = window.location.href; + url=url.replaceAll(/&scratch=./g,""); + url=url.replaceAll(/\?scratch=./g,""); + //var ggbDataset = document.getElementById(appletParametersID).dataset; + //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests + // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise + switch (reloadggb.trim()) { + case 'none': + break; + case 'ncon': + break; + case 'rand': + if(confirm("This will reload this exercise with different numbers. All previous work on this exercise will be lost.")) + { + if (url.indexOf('?') > -1){ + url += '&scratch=2' + } else { + url += '?scratch=2' + } + window.location.replace(url); + } + break; + case 'redo': + if(confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")){ + if (url.indexOf('?') > -1){ + url += '&scratch=1' + } else { + url += '?scratch=1' + } + //window.location.href = url; + //window.location.reload(); + window.location.replace(url); + // window.location.hash = 'varA=some_value;varB=some_value'; + //window.GGBQ.init(appletParametersID); + } + break; + } }, init: function (appletParametersID) { ////this.scratchit=true; @@ -143,7 +185,10 @@ define(['jquery'], function ($) { window.GGBQ = this; debugcode(); var ggbDataset = document.getElementById(appletParametersID).dataset; - window.GGBQ.filename=ggbDataset.ggbturl;// the filename + var reloadggb=ggbDataset.reloadggb;//what to do with reload requests + var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from + urlprefixlist=urlprefixlist.split(","); + window.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo var slot = ggbDataset.slot; // Add current scaling container to the object store for being able to access it later on. scalingContainers[slot] = ggbDataset.scalingcontainerclass; @@ -185,7 +230,9 @@ define(['jquery'], function ($) { window.GGBQ.scratchMark=false; } } else {alert("Applet not found, please reload this page");location.reload();} + //alert("loaded:".window.GGBQ.filename) }; + // jquery doesn't handle the colon : but later we expect a jquery optject, so ... this.b64input[slot] = $(document.getElementById(ggbDataset.b64input)); @@ -220,6 +267,16 @@ define(['jquery'], function ($) { } else { parameters.randomSeed = ggbDataset.seed; } + if(window.GGBQ.scratchrandomizeit){ + window.GGBQ.scratchMark=true; + window.GGBQ.scratchrandomizeit=false; + parameters.randomSeed=Math.floor((Math.random() * 1000) + 1); + var httpurl = window.GGBQ.filename; + if(httpurl.startsWith('http')){ + delete parameters.ggbBase64; + parameters.filename=httpurl + } + } //alert("Calling with random "+parameters.randomSeed.toString()); if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') { parameters.scaleContainerClass = scalingContainers[slot]; @@ -251,6 +308,9 @@ define(['jquery'], function ($) { debugcode(); // var GGBAppletname ; var codebase ; + // the comma separated list of prefixes in URL for the GGB file + var urlprefixlist=ggbDataset.urlprefixlist; + //alert(urlprefixlist); if (!ggbDataset.isurlggb||ggbDataset.isurlggb === "0") { GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js'; @@ -293,7 +353,7 @@ define(['jquery'], function ($) { }); // Check if seed have been manually set. The default would be "no" //}) - //} + // // GGBApplet= // define([GGBAppletname], function (GGBobj) {return GGBobj;}); //alert("applet creation");debugger; diff --git a/backup/moodle2/backup_qtype_geogebra_plugin.class.php b/backup/moodle2/backup_qtype_geogebra_plugin.class.php index cd40cd8..a4b9145 100644 --- a/backup/moodle2/backup_qtype_geogebra_plugin.class.php +++ b/backup/moodle2/backup_qtype_geogebra_plugin.class.php @@ -56,7 +56,7 @@ protected function define_question_plugin_structure() { 'constraints', 'isexercise', 'forcedimensions','width','height', "seeditornot","seed", - "isurlggb","urlggb" + "isurlggb","urlggb","reloadggb" )); // Now the own qtype tree. $pluginwrapper->add_child($geogebra); diff --git a/db/install.xml b/db/install.xml index 83d817f..3eb9303 100644 --- a/db/install.xml +++ b/db/install.xml @@ -22,6 +22,7 @@ + diff --git a/db/upgrade.php b/db/upgrade.php index d297e4d..9f8eb5b 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -121,5 +121,14 @@ function xmldb_qtype_geogebra_upgrade($oldversion) { // Geogebra savepoint reached. upgrade_plugin_savepoint(true, 2024030200, 'qtype', 'geogebra'); } + if ($oldversion < 2025011301) { + $table = new xmldb_table('qtype_geogebra_options'); + //$field = new xmldb_field('reloadggb', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'urlggb'); + $field = new xmldb_field('reloadggb', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, 'urlggb'); + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + upgrade_plugin_savepoint(true, 2025011301, 'qtype', 'geogebra'); + } return true; } diff --git a/edit_geogebra_form.php b/edit_geogebra_form.php index 9ed4b18..b5ee4a6 100644 --- a/edit_geogebra_form.php +++ b/edit_geogebra_form.php @@ -38,7 +38,7 @@ class qtype_geogebra_edit_form extends question_edit_form { public $qtypeobj; - public $reload = false; + public $reload = false;//nothing todo wiith reloadggb this is a URL param when the test mustbe reloaded public $ggbturl; @@ -149,6 +149,14 @@ protected function definition_inner($mform) { $mform->setType('urlggb', PARAM_URL); $mform->addHelpButton('urlggb', 'urlggb', 'qtype_geogebra'); $mform->hideIf('urlggb', 'isurlggb'); + // Add reload ggb button control + $mform->addElement('select', 'reloadggb', get_string('reloadggb', 'qtype_geogebra'), + array('none'=>'none', 'rand'=>'reload and randomize','redo'=>'redo same exercise'));; + $mform->addHelpButton('reloadggb', 'reloadggb', 'qtype_geogebra'); + //$mform->addElement('advcheckbox', 'reload', get_string('reload', 'qtype_geogebra'), + // get_string('reload', 'qtype_geogebra')); + //$mform->setDefault('reload', 0); + // Add randomization seed $mform->addElement('advcheckbox', 'seeditornot', get_string('seeditornotenable', 'qtype_geogebra'), get_string('seeditornot', 'qtype_geogebra')); diff --git a/lang/en/qtype_geogebra.php b/lang/en/qtype_geogebra.php index b73ec07..7d9c633 100644 --- a/lang/en/qtype_geogebra.php +++ b/lang/en/qtype_geogebra.php @@ -30,7 +30,8 @@ $string['answervar'] = 'Variables for automatic grading'; $string['answervar_help'] = 'For automatic grading: A name of a boolean object in GeoGebra which is true if the student solved the question (partly). Sums up all grades for all boolean variables. The question is correct if any combination exceeds 100%, but there should be at least one combination which sums up to exactly 100%. Leave blank for manual grading.'; $string['applet_advanced_settings'] = 'Advanced Settings...'; - +$string['reloadggb'] = 'Control the reload button'; +$string['reloadggb_help'] = 'You can add a reload button to your question or not. If there is this button the user might be enabled to reload the same question or it can be enabled just to ask for a newly randomized instance.'; $string['seeditornot'] = 'Add a custom seed'; $string['seeditornot_help'] = 'By default the GeoGebra random generator gives a different sequence of random values for each exercise instance. If you provide a POSITIVE integer seed this is used and therefore the same random sequence is used to instantiate the question. Each student gets the same exercise. Zero IS NOT a valid seed'; $string['seeditornotenable'] = 'Enable ad-hoc seeding'; @@ -105,3 +106,5 @@ $string['widthnotzero'] = 'You have to specify a value greater than zero for the width'; $string['width_help'] = 'By default the GeoGebra applet will be scaled automatically to fit the quiz layout. If for some reasons this does not fit your needs, you can specify width and height manually. If the values are too high students will see a scrollbar on small screens to display the full applet.'; $string['willbereadfromfile'] = 'Will be read from GeoGebra... (see help button)'; +$string['ggbURLPrefixAlt_desc'] = 'comma separated list of URL prefixes for the library of ggb files. If loading fails an alternate URL is tried.'; +$string['ggbURLPrefixAlt'] = 'URL prefixes ggb(s).'; diff --git a/question.php b/question.php index 0dcd782..1cf106a 100644 --- a/question.php +++ b/question.php @@ -65,6 +65,7 @@ class qtype_geogebra_question extends question_graded_automatically { public $seed; public $isurlggb; public $urlggb; + public $reloadggb; //public $isurlggbact; //public $urlggbact; diff --git a/questiontype.php b/questiontype.php index 0e424a8..262429b 100644 --- a/questiontype.php +++ b/questiontype.php @@ -46,7 +46,7 @@ public function extra_question_fields() { return array('qtype_geogebra_options', 'ggbturl', 'ggbparameters', 'ggbviews', 'ggbcodebaseversion', 'ggbxml', 'israndomized', 'randomizedvar', 'constraints', 'isexercise','forcedimensions','width', 'height', 'seeditornot','seed', - 'isurlggb','urlggb' + 'isurlggb','urlggb','reloadggb' //,'isurlggbact','urlggbact' ); } diff --git a/renderer.php b/renderer.php index 5c8370b..7dbd181 100644 --- a/renderer.php +++ b/renderer.php @@ -155,6 +155,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $appletparametersid = $qa->get_qt_field_name('applet_parameters'); $forcedimensions = $question->forcedimensions ?: 0; $seeditornot = $question->seeditornot ?: 0; + $reloadggb = $question->reloadggb ?: 0; //default to 0 $seed = $question->seed ?: 0;// here generate a particular seed out of $questions->seed $seed=$this->remapSeed($seed); $width = $question->width ?: 0; @@ -164,6 +165,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ //$isurlggbact = $question->isurlggbact ?: 0; //$urlggbact = $question->urlggbact ?: 0; $ggbturl = $question->ggbturl ?: 0; + $urlprefixlist=get_config('qtype_geogebra')->ggbURLPrefixAlt; $applet = <<ggbparameters @@ -181,11 +183,13 @@ public function formulation_and_controls(question_attempt $qa, question_display_ data-lang=$lang data-forcedimensions=$forcedimensions data-seeditornot=$seeditornot + data-reloadggb=$reloadggb; data-seed=$seed data-width=$width data-height=$height data-isurlggb=$isurlggb data-urlggb=$urlggb + data-urlprefixlist=$urlprefixlist data-ggbturl=$ggbturl data-scalingcontainerclass=$scalingcontainerclass @@ -195,10 +199,12 @@ public function formulation_and_controls(question_attempt $qa, question_display_ if (isset($_GET['scratch'])&& (strcmp(htmlspecialchars($_GET['scratch']),"1")==0)){ $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'scratchinit', array($appletparametersid)); - }else{ + }else if (isset($_GET['scratch'])&& + (strcmp(htmlspecialchars($_GET['scratch']),"2")==0)){ + $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'scratchrandomize', array($appletparametersid)); + } else { $this->page->requires->js_call_amd('qtype_geogebra/ggbq', 'init', array($appletparametersid)); } - if ($qa->get_state() == question_state::$invalid) { $result .= html_writer::nonempty_tag('div', $question->get_validation_error(array('answer' => $answercurrent, @@ -209,12 +215,13 @@ public function formulation_and_controls(question_attempt $qa, question_display_ } $result .= html_writer::end_div(); - if($ggbturl!=0){ - $button =html_writer::tag('button', 'Reload (stamped)', + //echo trim($reloadggb); echo $ggbturl;die; + if(($ggbturl!=0) && strcmp(trim($reloadggb),"none")!=0){ + $button =html_writer::tag('button', 'Reload', array('class'=>'mod_quiz-next-nav btn btn-primary', 'type' => 'button', //'onclick'=>'window.GGBQ.scratchjson('.$parjson.');' //'onclick'=>'window.GGBQ.scratch("'.$appletparametersid.'")' - 'onclick'=>'window.GGBQ.scratch()' + 'onclick'=>'window.GGBQ.scratch("'.$reloadggb.'")' ) ); $result=$button.$result; diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..68681fc --- /dev/null +++ b/settings.php @@ -0,0 +1,40 @@ +. + +/** + * GeoGebra grade form + * + * @package qtype_geogebra + * @subpackage geogebra + * @copyright 2024 Twingsister + * @author Twingsister + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +if ($ADMIN->fulltree) { + $settings->add( + new admin_setting_configtext( + 'qtype_geogebra/ggbURLPrefixAlt', + get_string('ggbURLPrefixAlt', 'qtype_geogebra'), + get_string('ggbURLPrefixAlt_desc', 'qtype_geogebra'), + 'https://twingsister.github.io/Moodle-Tests-Repository/'. + ','.'https://bitbucket.org/twingsister/moodle-tests-repository/raw/master/'.','. + 'https://gitlab.com/moodle6785909/moodle-test-repository/-/raw/master/' + ) + ); +} diff --git a/version.php b/version.php index 765cc3e..aa047d0 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2024220402; +$plugin->version = 2025011301; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From 7304d86ff214f7b2e19bb6c90735b621aa7c3db7 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 16 Mar 2024 13:27:28 +0100 Subject: [PATCH 55/60] mark cannot be deleted --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 39f5715..ee4995a 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,O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,OAAW,IACnDA,QAAO,MAAU,MACjB/D,MAAM,0BAWR8D,KAAKrK,gBAAgBsK,SACTvI,OAAOyB,KAAKX,YAAYiC,GAAGoB,IAAImE,gBAST,IAAd/J,YAA2BiG,MAAM,mBAAmBxC,SAASyC,YAK5F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// marka RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAUI,SAASL,SACY,WAA5BC,UAAUK,cAAcN,KAAeI,IAAe,GAARA,KAChDA,GACR,CACE,SAASG,SAASC,aAAaP,eAEzBQ,eAAiB,UACrBD,aAAajB,SAAQ,SAAUmB,gBAC1BT,UAAUC,UAAUQ,aAAa,KAChCC,MAAQV,UAAUI,SAASK,aACW,WAAtCT,UAAUK,cAAcI,eAAyBC,MAAmB,GAAVA,MAAa,QAAQ,QACnFF,gBAAkBC,YAAY,IAAIC,MAAM,QAGnCF,eAAeX,QAAQ,MAAM,GACpC,CAeVc,6BAAO,CAAC,WAAW,SAAUC,OAIrBC,cADEC,kBAAoB,GAGpBC,uBAAyB,WAC3BC,aAAaH,eACbA,cAAgBI,YACZ,kBAAMC,OAAOC,OAAOL,mBAAmBxB,SAAQ,SAAC8B,oBAElCC,iBAAmBC,SAASC,uBAAuBH,gBAAgB,GAGnEI,oBAAsBC,OAAOC,iBAC/BL,iBAAiBM,c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O,YAAc+C,WACZ,IAAdxE,WAA6BA,UAAU8J,eAAe,aAAc,CAG3ErI,OAAOyB,KAAKhB,SAASsC,GAAGoB,IAAI5F,UAAU6F,aACtCpE,OAAOyB,KAAKd,SAASoC,GAAGoB,IAAI5F,UAAU8F,uCAGX5E,OAAO6I,QAAQtI,OAAOyB,KAAKkE,+CAAiB,8DAA3DxH,0BAAKc,4BACbV,UAAUgG,sBAAepG,gBAAOc,YAO5BsJ,KAAK1J,SAASmB,OAAOyB,KAAK3C,aAAaiE,GAAGxE,WAG3DiK,QAAUhL,kBAAkB+K,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBnK,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWiK,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjB/D,MAAM,0BAWR8D,KAAKtK,gBAAgBuK,SACTxI,OAAOyB,KAAKX,YAAYiC,GAAGoB,IAAIoE,gBAST,IAAdhK,YAA2BkG,MAAM,mBAAmBzC,SAAS0C,YAK5F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 7918aac..7d13012 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -226,7 +226,8 @@ define(['jquery'], function ($) { //ggbApplet.setPerspective("GD"); } if(window.GGBQ.scratchMark){ - ggbApplet.evalCommand('Text("QUIZ RELOADED")'); + ggbApplet.evalCommand('mark=Text("QUIZ RELOADED")'); + ggbApplet.setFixed('mark',true,false);// marka RELOADED cannot be deleted window.GGBQ.scratchMark=false; } } else {alert("Applet not found, please reload this page");location.reload();} From b07c6e5b11367e94ddea6d9814674ea88b471a9c Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sat, 16 Mar 2024 13:30:46 +0100 Subject: [PATCH 56/60] version bump --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index aa047d0..4c41b71 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2025011301; +$plugin->version = 2025011302; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From bfbeb9b9b7e21c75dacc897c3af4e571302af752 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 17 Mar 2024 19:37:10 +0100 Subject: [PATCH 57/60] save work only on exit --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 20 +++++++++++++++----- version.php | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index ee4995a..ddeeee5 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\")');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// marka RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n preGetBase64andCheck: function() {this.getBase64andCheck();},\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAUI,SAASL,SACY,WAA5BC,UAAUK,cAAcN,KAAeI,IAAe,GAARA,KAChDA,GACR,CACE,SAASG,SAASC,aAAaP,eAEzBQ,eAAiB,UACrBD,aAAajB,SAAQ,SAAUmB,gBAC1BT,UAAUC,UAAUQ,aAAa,KAChCC,MAAQV,UAAUI,SAASK,aACW,WAAtCT,UAAUK,cAAcI,eAAyBC,MAAmB,GAAVA,MAAa,QAAQ,QACnFF,gBAAkBC,YAAY,IAAIC,MAAM,QAGnCF,eAAeX,QAAQ,MAAM,GACpC,CAeVc,6BAAO,CAAC,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AEI,YAAYC,UACM,MAA7CL,EAAEM,SAAWN,EAAEO,OAASP,EAAEQ,UAAY,IAS7DV,qBAAsB,gBAAiBC,qBAEvCA,kBAAmB,cACnBrF,YACIF,QAAQ,sCACH,IAAIW,EAAI,EAAGA,EAAI/C,OAAOyB,KAAKX,YAAYgC,OAAQC,IAAK,KACjDxE,UAAYyB,OAAO,YAAc+C,WACZ,IAAdxE,WAA6BA,UAAU8J,eAAe,aAAc,CAG3ErI,OAAOyB,KAAKhB,SAASsC,GAAGoB,IAAI5F,UAAU6F,aACtCpE,OAAOyB,KAAKd,SAASoC,GAAGoB,IAAI5F,UAAU8F,uCAGX5E,OAAO6I,QAAQtI,OAAOyB,KAAKkE,+CAAiB,8DAA3DxH,0BAAKc,4BACbV,UAAUgG,sBAAepG,gBAAOc,YAO5BsJ,KAAK1J,SAASmB,OAAOyB,KAAK3C,aAAaiE,GAAGxE,WAG3DiK,QAAUhL,kBAAkB+K,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBnK,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWiK,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjB/D,MAAM,0BAWR8D,KAAKtK,gBAAgBuK,SACTxI,OAAOyB,KAAKX,YAAYiC,GAAGoB,IAAIoE,gBAST,IAAdhK,YAA2BkG,MAAM,mBAAmBzC,SAAS0C,YAK5F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\",(0,-2))');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// mark RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n // ADD LINE ABOVE TO HAVE SAVING ON EVERY MOUSE MOVE OUT OF EXERCISE (HEAVY)\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n // called upon submit\r\n preGetBase64andCheck: function() {\r\n //for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n // var ggbApplet = window['ggbApplet' + i];\r\n // if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n // in ggbAApplet do some bookeping because the user pressed next page\r\n // }\r\n //}\r\n \tthis.getBase64andCheck();\r\n },\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","getBase64andCheck","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAi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,aAAaiE,GAAGxE,WAG3DiK,QAAUhL,kBAAkB+K,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBnK,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWiK,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjB/D,MAAM,0BAWR8D,KAAKtK,gBAAgBuK,SACTxI,OAAOyB,KAAKX,YAAYiC,GAAGoB,IAAIoE,gBAST,IAAdhK,YAA2BkG,MAAM,mBAAmBzC,SAAS0C,YAK5F"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 7d13012..49792e4 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -118,7 +118,7 @@ define(['jquery'], function ($) { scratchrandomizeit: false, //Twingsistere reload and randomize scratchMark: false, filename:"", - //applet1, + //applet1, checkLoading: function (appletParametersID){return; if(!this.confirmedpage){ if(confirm("if something loaded (could be an empty cartesian plane) say ok")){ @@ -226,8 +226,8 @@ define(['jquery'], function ($) { //ggbApplet.setPerspective("GD"); } if(window.GGBQ.scratchMark){ - ggbApplet.evalCommand('mark=Text("QUIZ RELOADED")'); - ggbApplet.setFixed('mark',true,false);// marka RELOADED cannot be deleted + ggbApplet.evalCommand('mark=Text("QUIZ RELOADED",(0,-2))'); + ggbApplet.setFixed('mark',true,false);// mark RELOADED cannot be deleted window.GGBQ.scratchMark=false; } } else {alert("Applet not found, please reload this page");location.reload();} @@ -364,7 +364,8 @@ define(['jquery'], function ($) { $('#responseform').on('submit', this.preGetBase64andCheck); // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); - $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); + //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); + // ADD LINE ABOVE TO HAVE SAVING ON EVERY MOUSE MOVE OUT OF EXERCISE (HEAVY) this.currentvals[slot] = ggbDataset.vars; this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput)); @@ -384,7 +385,16 @@ define(['jquery'], function ($) { //confirmedpage=false,`` - preGetBase64andCheck: function() {this.getBase64andCheck();}, + // called upon submit + preGetBase64andCheck: function() { + //for (var i = 0; i < window.GGBQ.answerinput.length; i++) { + // var ggbApplet = window['ggbApplet' + i]; + // if (typeof ggbApplet !== "undefined" && ggbApplet.hasOwnProperty("getBase64")) { + // in ggbAApplet do some bookeping because the user pressed next page + // } + //} + this.getBase64andCheck(); + }, getBase64andCheck: function() { debugcode(); diff --git a/version.php b/version.php index 4c41b71..605d037 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2025011302; +$plugin->version = 2025011303; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From a5b176097b1c1433fb9b42235c820b8d381c29f2 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 18 Mar 2024 09:23:19 +0100 Subject: [PATCH 58/60] save your work --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/src/ggbq.js | 29 +++++++++++++++++------------ renderer.php | 7 ++++++- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index ddeeee5..21dcc6b 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){timeout=setTimeout(this.preGetBase64andCheck,6e4),window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\",(0,-2))');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// mark RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //})\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.preGetBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n // ADD LINE ABOVE TO HAVE SAVING ON EVERY MOUSE MOVE OUT OF EXERCISE (HEAVY)\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n // called upon submit\r\n preGetBase64andCheck: function() {\r\n //for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n // var ggbApplet = window['ggbApplet' + i];\r\n // if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n // in ggbAApplet do some bookeping because the user pressed next page\r\n // }\r\n //}\r\n \tthis.getBase64andCheck();\r\n },\r\n \r\n getBase64andCheck: function() {\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","preGetBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","getBase64andCheck","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MA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,OACf,UAAWC,SAA+B,SAAnBA,QAAO,OAAsBnK,QAAQ,QAAQE,YAAYE,QAAQ,QAAQF,aAEtG,UAAWiK,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjB/D,MAAM,0BAWR8D,KAAKtK,gBAAgBuK,SACTxI,OAAOyB,KAAKX,YAAYiC,GAAGoB,IAAIoE,gBAST,IAAdhK,YAA2BkG,MAAM,mBAAmBzC,SAAS0C,YAK5F"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n timeout:0,\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array'none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \ttimeout=setTimeout(this.preGetBase64andCheck,60000)\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\",(0,-2))');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// mark RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //)\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n // ADD LINE ABOVE TO HAVE SAVING ON EVERY MOUSE MOVE OUT OF EXERCISE (HEAVY)\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n // called upon submit\r\n \r\n getBase64andCheck: function() {\r\n clearTimeout(timeout);\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n preGetBase64andCheck: function() {\r\n \ttimeout=setTimeout(this.preGetBase64andCheck,60000);\r\n //for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n // var ggbApplet = window['ggbApplet' + i];\r\n // if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n // in ggbAApplet do some bookeping because the user pressed next page\r\n // }\r\n //}\r\n \tGGBQ.getBase64andCheck();\r\n }\r\n//,\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","timeout","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","preGetBase64andCheck","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,UAAUI,SAASL,SACY,WAA5BC,UAAUK,cAAcN,KAAeI,IAAe,GAAR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No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index 49792e4..a242648 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -118,6 +118,7 @@ define(['jquery'], function ($) { scratchrandomizeit: false, //Twingsistere reload and randomize scratchMark: false, filename:"", + timeout:0, //applet1, checkLoading: function (appletParametersID){return; if(!this.confirmedpage){ @@ -146,7 +147,7 @@ define(['jquery'], function ($) { url=url.replaceAll(/\?scratch=./g,""); //var ggbDataset = document.getElementById(appletParametersID).dataset; //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests - // array('none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise + // array'none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise switch (reloadggb.trim()) { case 'none': break; @@ -180,6 +181,7 @@ define(['jquery'], function ($) { } }, init: function (appletParametersID) { + timeout=setTimeout(this.preGetBase64andCheck,60000) ////this.scratchit=true; //this.confirmedpage=false;//Twingsister window.GGBQ = this; @@ -353,7 +355,7 @@ define(['jquery'], function ($) { applet1.inject(ggbDataset.div, "preferHTML5"); }); // Check if seed have been manually set. The default would be "no" - //}) + //) // // GGBApplet= // define([GGBAppletname], function (GGBobj) {return GGBobj;}); @@ -361,7 +363,7 @@ define(['jquery'], function ($) { //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple); //NO applet1.setHTML5Codebase("https://cdn.geogebra.org/apps/5.0.541.0/web3d"); - $('#responseform').on('submit', this.preGetBase64andCheck); + $('#responseform').on('submit', this.getBase64andCheck); // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck); @@ -386,17 +388,9 @@ define(['jquery'], function ($) { //confirmedpage=false,`` // called upon submit - preGetBase64andCheck: function() { - //for (var i = 0; i < window.GGBQ.answerinput.length; i++) { - // var ggbApplet = window['ggbApplet' + i]; - // if (typeof ggbApplet !== "undefined" && ggbApplet.hasOwnProperty("getBase64")) { - // in ggbAApplet do some bookeping because the user pressed next page - // } - //} - this.getBase64andCheck(); - }, getBase64andCheck: function() { + clearTimeout(timeout); debugcode(); if(!confirm("Do you want to save your work?")){return;} for (var i = 0; i < window.GGBQ.answerinput.length; i++) { @@ -448,6 +442,17 @@ define(['jquery'], function ($) { }else{if(typeof ggbApplet !== "undefined"){alert("quiz not loaded");location.reload()}} } }, + preGetBase64andCheck: function() { + timeout=setTimeout(this.preGetBase64andCheck,60000); + //for (var i = 0; i < window.GGBQ.answerinput.length; i++) { + // var ggbApplet = window['ggbApplet' + i]; + // if (typeof ggbApplet !== "undefined" && ggbApplet.hasOwnProperty("getBase64")) { + // in ggbAApplet do some bookeping because the user pressed next page + // } + //} + GGBQ.getBase64andCheck(); + } +//, }; }); diff --git a/renderer.php b/renderer.php index 7dbd181..1785d47 100644 --- a/renderer.php +++ b/renderer.php @@ -216,6 +216,11 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $result .= html_writer::end_div(); //echo trim($reloadggb); echo $ggbturl;die; + $buttonSave =html_writer::tag('button', 'Save my work', + array('class'=>'mod_quiz-next-nav btn btn-primary', 'type' => 'button', + 'onclick'=>'window.GGBQ.preGetBase64andCheck()' + ) + ); if(($ggbturl!=0) && strcmp(trim($reloadggb),"none")!=0){ $button =html_writer::tag('button', 'Reload', array('class'=>'mod_quiz-next-nav btn btn-primary', 'type' => 'button', @@ -224,7 +229,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ 'onclick'=>'window.GGBQ.scratch("'.$reloadggb.'")' ) ); - $result=$button.$result; + $result=$buttonSave." ".$button.$result; } // twingsister // $parjson = "{".$appletparametersid."}"; From 18f4cc0b7771de02cff0be28d672446333631fc7 Mon Sep 17 00:00:00 2001 From: Twingsister Date: Mon, 18 Mar 2024 09:29:08 +0100 Subject: [PATCH 59/60] version bump save your work --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 605d037..653bf77 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2025011303; +$plugin->version = 2025011304; $plugin->release = '1.13.3'; $plugin->requires = 2018051703; From ca3cbbb3225e46db6c8a6820b31affc740af294f Mon Sep 17 00:00:00 2001 From: Twingsister Date: Sun, 7 Apr 2024 12:14:33 +0200 Subject: [PATCH 60/60] Version push --- amd/build/ggbq.min.js | 2 +- amd/build/ggbq.min.js.map | 2 +- amd/build/ggbt.min.js.map | 2 +- amd/src/ggbq.js | 9 +++++---- amd/src/ggbt.js | 1 + renderer.php | 3 ++- version.php | 4 ++-- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/amd/build/ggbq.min.js b/amd/build/ggbq.min.js index 21dcc6b..683e5aa 100644 --- a/amd/build/ggbq.min.js +++ b/amd/build/ggbq.min.js @@ -9,6 +9,6 @@ function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return * @author Christoph Stadlbauer * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){timeout=setTimeout(this.preGetBase64andCheck,6e4),window.GGBQ=this,debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;iarr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i-1?url+="&scratch=2":url+="?scratch=2",window.location.replace(url));break;case"redo":confirm("This will reload this exercise with same numbers. All previous work on this exercise will be lost.")&&(url.indexOf("?")>-1?url+="&scratch=1":url+="?scratch=1",window.location.replace(url))}},init:function(appletParametersID){window.GGBQ=this,timeout=setTimeout(GGBQ.preGetBase64andCheck,18e4),debugcode();var ggbDataset=document.getElementById(appletParametersID).dataset;ggbDataset.reloadggb;urlprefixlist=(urlprefixlist=ggbDataset.urlprefixlist).split(","),window.GGBQ.filename=function(str,dic){for(var result,alts=dic.length,i=0;i\r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n timeout:0,\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array'none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n \ttimeout=setTimeout(this.preGetBase64andCheck,60000)\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n window.GGBQ = this;\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\",(0,-2))');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// mark RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //)\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n // ADD LINE ABOVE TO HAVE SAVING ON EVERY MOUSE MOVE OUT OF EXERCISE (HEAVY)\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n // called upon submit\r\n \r\n getBase64andCheck: function() {\r\n clearTimeout(timeout);\r\n debugcode();\r\n if(!confirm(\"Do you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n preGetBase64andCheck: function() {\r\n \ttimeout=setTimeout(this.preGetBase64andCheck,60000);\r\n //for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n // var ggbApplet = window['ggbApplet' + i];\r\n // if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n // in ggbAApplet do some bookeping because the user pressed next page\r\n // }\r\n //}\r\n \tGGBQ.getBase64andCheck();\r\n }\r\n//,\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","timeout","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","preGetBase64andCheck","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAiCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAEx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QAAQF,aAEtG,UAAWkK,SAAWC,OAAOD,QAAO,OAAW,IACnDA,QAAO,MAAU,MACjB9D,MAAM,0BAWR6D,KAAKvK,gBAAgBwK,SACTzI,OAAO0B,KAAKZ,YAAYmC,GAAGoB,IAAImE,gBAST,IAAdjK,YAA2BoG,MAAM,mBAAmB1C,SAAS2C,YAG7ErC,qBAAsB,WAC7BjB,QAAQ9B,WAAWmC,KAAKY,qBAAqB,KAO7Cb,KAAKkG,qBAKb"} \ No newline at end of file +{"version":3,"file":"ggbq.min.js","sources":["../src/ggbq.js"],"sourcesContent":["\r\n\r\n/* eslint-disable */\r\n/* eslint-disable no-debugger */\r\n/*jslint devel: true */\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * StuDENT VIEW\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n\r\n// alert(\"hello ggbq\");\r\n //debugger; // eslint-disable-line\r\n //debugcode();\r\n\r\n\r\n function cyclerepl(str,dic){\r\n var alts=dic.length;\r\n var result;\r\n for(var i = 0;i {\r\n clearTimeout(resizeTimeout);\r\n resizeTimeout = setTimeout(\r\n () => Object.values(scalingContainers).forEach((containerClass) => {\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(containerClass)[0];\r\n // We retrieve the formulation div container, because this gives us the correct width to adapt\r\n // the scaling container to.\r\n const formulationDivStyle = window.getComputedStyle(\r\n scalingContainer.querySelector('.qtext').parentElement.parentElement);\r\n scalingContainer.style.width = parseInt(formulationDivStyle.width)\r\n - parseInt(formulationDivStyle.paddingLeft) - parseInt(formulationDivStyle.paddingRight) + 'px';\r\n }), 5000); //Twingsister mod was 250\r\n };\r\n return {\r\n b64input: [],\r\n ggbBase64: [],\r\n xmlinput: [],\r\n ggbxml: [],\r\n currentvals: [],\r\n answerinput: [],\r\n responsevars: [],\r\n exerciseresultinput: [],\r\n qdiv: [],\r\n //parameters: {}, //before not global\r\n ggbDataset: [],\r\n //confirmedpage: false, //Twingsister the user says sees a correct page\r\n scratchit: false, //Twingsister turns init into a reload from file delete all what you have done \r\n scratchrandomizeit: false, //Twingsistere reload and randomize \r\n scratchMark: false, \r\n filename:\"\",\r\n timeout:0,\r\n //applet1,\r\n checkLoading: function (appletParametersID){return;\r\n \t if(!this.confirmedpage){\r\n \t\tif(confirm(\"if something loaded (could be an empty cartesian plane) say ok\")){\r\n \t\t\twindow.GGBQ.scratch(appletParametersID);\r\n \t\t\tlocation.reload();return true;\r\n \t\t\tif(confirm(\"if it looks as a correct question say ok\")){this.confirmedpage=true;}\r\n \t\t\t else {if(confirm(\"if it is an empty cartesian plane, please say ok to reload\")){location.reload();return;}} \r\n \t \t}\r\n \t }\r\n \t},\r\n // Twingsister load from filename\r\n scratchrandomize: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchrandomizeit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratchinit: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \twindow.GGBQ.scratchit=true;\r\n \twindow.GGBQ.init(appletParametersID); \r\n },\r\n scratch: function (reloadggb) {\r\n let url = window.location.href; \r\n url=url.replaceAll(/&scratch=./g,\"\");\r\n url=url.replaceAll(/\\?scratch=./g,\"\");\r\n //var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n //var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n // array'none'=>'none', 'ncon'=>'reload if not confirmed', 'rand'=>'reload and randomize','redo'=>'redo same exercise\r\n\t\tswitch (reloadggb.trim()) {\r\n \t\t\tcase 'none':\r\n \t\tbreak;\r\n \t\t\tcase 'ncon':\r\n \t\tbreak;\r\n \t\t\tcase 'rand':\r\n \t\tif(confirm(\"This will reload this exercise with different numbers. All previous work on this exercise will be lost.\"))\r\n \t\t\t\t{\r\n\t\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\t\turl += '&scratch=2'\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t url += '?scratch=2'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\twindow.location.replace(url);\r\n \t\t\t}\r\n \tbreak;\r\n \t\t\tcase 'redo':\r\n \t\tif(confirm(\"This will reload this exercise with same numbers. All previous work on this exercise will be lost.\")){\r\n\t\t\t\t\tif (url.indexOf('?') > -1){\r\n \t\t\t\t\t\turl += '&scratch=1'\r\n\t\t\t\t\t} else { \r\n\t\t\t\t\t url += '?scratch=1'\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//window.location.href = url;\r\n\t\t\t\t\t//window.location.reload();\r\n\t\t\t\t\twindow.location.replace(url);\r\n\t\t\t\t\t// window.location.hash = 'varA=some_value;varB=some_value';\r\n \t\t\t//window.GGBQ.init(appletParametersID); \r\n \t\t\t}\r\n \t\tbreak;\r\n \t\t}\r\n },\r\n init: function (appletParametersID) {\r\n window.GGBQ = this;\r\n \ttimeout=setTimeout(GGBQ.preGetBase64andCheck,180000)\r\n \t////this.scratchit=true;\r\n \t//this.confirmedpage=false;//Twingsister\r\n debugcode();\r\n var ggbDataset = document.getElementById(appletParametersID).dataset;\r\n var reloadggb=ggbDataset.reloadggb;//what to do with reload requests\r\n var urlprefixlist=ggbDataset.urlprefixlist;//list of prefixes of sites to daownload ggb from \r\n urlprefixlist=urlprefixlist.split(\",\");\r\n\t\t\twindow.GGBQ.filename=cyclerepl(ggbDataset.ggbturl,urlprefixlist);// the filename fron a randomized repo\r\n var slot = ggbDataset.slot;\r\n // Add current scaling container to the object store for being able to access it later on.\r\n scalingContainers[slot] = ggbDataset.scalingcontainerclass;\r\n //alert(\"no load\");\r\n\r\n window.ggbAppletOnLoad = function (ggbAppletId) {\r\n if (ggbAppletId != -1) {\r\n document.querySelector('article').onkeydown = this.checkEnter;\r\n var id = ggbAppletId.substring(9);\r\n var ggbApplet = window[ggbAppletId];\r\n var curvals = JSON.parse(window.GGBQ.currentvals[id]);\r\n for (var label in curvals) {\r\n ggbApplet.setValue(label, curvals[label]);\r\n }\r\n\r\n // Set the initial size of the scaling containers so GeoGebra applet scale a first time correctly after loading.\r\n resizeScalingContainer();\r\n // Unregister old event listeners in case we have multiple GeoGebra questions on one page.\r\n // We only need one for the whole page.\r\n window.removeEventListener('resize', resizeScalingContainer);\r\n window.addEventListener('resize', resizeScalingContainer);\r\n //window.GGBQ.checkLoading(appletParametersID);\r\n window.GGBQ.b64input[id].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[id].val(ggbApplet.getXML());\r\n \r\n //window.GGBQ.qdiv[id].style.visibility = 'visible';\r\n window.GGBQ.qdiv[id]= {style: {visibility : 'visible'}};\r\n if (window.GGBQ.answerinput[id].val() == '') {\r\n // Twingsister\r\n window.GGBQ.answerinput[id].val(stringfy(window.GGBQ.responsevars[id],ggbApplet));\r\n // Twingsister\r\n \t//alert(\"response one\");\r\n //alert(\"gogod\");\r\n \t//ggbApplet.setWidth(100);\r\n \t//ggbApplet.setPerspective(\"GD\");\r\n }\r\n\t\t\t\tif(window.GGBQ.scratchMark){\r\n\t\t\t\t\tggbApplet.evalCommand('mark=Text(\"QUIZ RELOADED\",(0,-2))');\r\n\t\t\t\t\tggbApplet.setFixed('mark',true,false);// mark RELOADED cannot be deleted\r\n\t\t\t\t\twindow.GGBQ.scratchMark=false;\r\n }\r\n } else {alert(\"Applet not found, please reload this page\");location.reload();}\r\n //alert(\"loaded:\".window.GGBQ.filename)\r\n };\r\n\r\n \r\n // jquery doesn't handle the colon : but later we expect a jquery optject, so ...\r\n this.b64input[slot] = $(document.getElementById(ggbDataset.b64input));\r\n this.ggbBase64[slot] = this.b64input[slot].val();\r\n\r\n this.xmlinput[slot] = $(document.getElementById(ggbDataset.xmlinput));\r\n this.ggbxml[slot] = this.xmlinput[slot].val();\r\n this.qdiv[slot] = $(\"#q\" + (slot) + \" .qtext\")[0];\r\n\r\n \r\n var parameters = JSON.parse(ggbDataset.parameters);\r\n //parameters = JSON.parse(ggbDataset.parameters);\r\n if (this.ggbBase64[slot] != '') {\r\n parameters.ggbBase64 = this.ggbBase64[slot];\r\n }\r\n\t\t\tif(window.GGBQ.scratchit){\r\n\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n if(httpurl.startsWith('http')){\r\n\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n }else{alert(\"Reloading from Geogebra Tube not implemented\")}\r\n\t\t\t}\r\n // Check if seed have been manually set. The default would be \"no\"\r\n //alert(\"entering the seed\");\r\n \t//debugcode();\r\n if (!ggbDataset.seeditornot || ggbDataset.seeditornot === '0') {\r\n \tvar dice=Math.floor((Math.random() * 1000) + 1);\r\n \t//alert(\"random copy with \"+dice.toString());\r\n \t//debugcode();\r\n parameters.randomSeed = dice ;\r\n } else {\r\n parameters.randomSeed = ggbDataset.seed;\r\n } \r\n\t\t\tif(window.GGBQ.scratchrandomizeit){\r\n\t\t\t\t\twindow.GGBQ.scratchMark=true;\r\n\t\t\t\t\twindow.GGBQ.scratchrandomizeit=false;\r\n \tparameters.randomSeed=Math.floor((Math.random() * 1000) + 1);\r\n\t\t\t\t\tvar httpurl = window.GGBQ.filename;\r\n \tif(httpurl.startsWith('http')){\r\n\t\t\t\t\t\tdelete parameters.ggbBase64;\r\n\t\t\t\t\t\tparameters.filename=httpurl\r\n\t\t\t\t\t}\r\n\t\t\t}\t\r\n //alert(\"Calling with random \"+parameters.randomSeed.toString());\r\n if (!ggbDataset.forcedimensions || ggbDataset.forcedimensions === '0') {\r\n parameters.scaleContainerClass = scalingContainers[slot];\r\n parameters.autoHeight = true;\r\n } else {\r\n // Width and height are specified in this case, so we use the given fixed width and height settings\r\n // of the plugin instance. Form validation of the settings asserts that both width and height are being set.\r\n parameters.width = ggbDataset.width;\r\n parameters.height = ggbDataset.height;\r\n // We need to use getElementsByClassName because colons are not allowed for jquery and Vanilla JS querySelector.\r\n const scalingContainer = document.getElementsByClassName(scalingContainers[slot])[0];\r\n // We should always find this container, just check to be extra safe.\r\n if (scalingContainer) {\r\n // Width of the scaling container is being set after the applet has been loaded. So no need to specify it here.\r\n scalingContainer.style.overflowX = 'auto';\r\n scalingContainer.style.overflowY = 'hidden';\r\n }\r\n }\r\n // parameters.currentvals = JSON.parse(ggbDataset.vars);\r\n this.ggbDatasetVars = JSON.parse(ggbDataset.vars);\r\n parameters.language = ggbDataset.lang;\r\n parameters.moodle = \"takingQuiz\";\r\n delete parameters.material_id;\r\n\r\n parameters.id = 'ggbApplet' + slot;\r\n\r\n var views = JSON.parse(ggbDataset.views);\r\n // Check if GGBApplet have been manually set.\r\n debugcode(); //\r\n \tvar GGBAppletname ;\r\n \tvar codebase ;\r\n \t// the comma separated list of prefixes in URL for the GGB file\r\n \tvar urlprefixlist=ggbDataset.urlprefixlist;\r\n \t//alert(urlprefixlist);\r\n\r\n if (!ggbDataset.isurlggb||ggbDataset.isurlggb === \"0\") {\r\n GGBAppletname = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";\r\n } else {\r\n var parts=ggbDataset.urlggb.split(\",\");\r\n \tvar root=parts[0];\r\n \tvar appl=parts[1];\r\n \tvar base=parts[2];\r\n \tGGBAppletname = root+appl ;\r\n \tcodebase = root+base;\r\n }\r\n //require.config({paths: {gb: GGBAppletname.slice(0,-3)}});\r\n //require([\"gb\"], function(gb) \r\n //import GGBApplet from GGBAppletname;\r\n\r\n require([GGBAppletname],function (App){//);\r\n \tvar applet1 ;\r\n //applet1 = new App(parameters, views, ggbDataset.html5NoWebSimple);\r\n if(!parameters.showToolBar){\r\n parameters.showToolBar=true; \r\n parameters.customToolBar=\"40,0,1,41,42,50,38\";//,6\";\r\n }\r\n // parameters.enableUndoRedo=false; //user controlled\r\n //parameters.showResetIcon=false;// user defined\r\n parameters.preventFocus=true;// get focus upon start\r\n parameters.allowStyleBar=false;// style bar controls too much \r\n parameters.transparentGraphics=false;// graphics and graphics 2 are transparent\r\n parameters.playButton=false; //true not working?\r\n parameters.autoHeight=false; // allow height computed automatically\r\n parameters.allowUpscale=true; // let GGB upscale Applet\r\n parameters.showFullscreenButton=true; // let GGB upscale Applet\r\n applet1 = new App(parameters,ggbDataset.html5nowebsimple);\r\n \tdebugcode();\r\n\t\t\t\t//window.onload = function() \r\n\t\t\t\t//window.addEventListener(\"load\", function() \r\n if (!(codebase===\"\")){applet1.setHTML5Codebase(codebase)};\r\n //alert(\"foo\");\r\n \tapplet1.inject(ggbDataset.div, \"preferHTML5\");\r\n\t\t\t});\r\n // Check if seed have been manually set. The default would be \"no\"\r\n\t\t\t //)\r\n\t\t\t //\r\n //\tGGBApplet=\r\n // define([GGBAppletname], function (GGBobj) {return GGBobj;});\r\n //alert(\"applet creation\");debugger;\r\n //var applet1 = new GGBApplet(parameters, views, ggbDataset.html5NoWebSimple);\r\n //NO applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n $('#responseform').on('submit', this.getBase64andCheck);\r\n\r\n // Do wep really need this $(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n //$(document.getElementById(ggbDataset.div)).on('mouseleave', this.getBase64andCheck);\r\n // ADD LINE ABOVE TO HAVE SAVING ON EVERY MOUSE MOVE OUT OF EXERCISE (HEAVY)\r\n\r\n this.currentvals[slot] = ggbDataset.vars;\r\n this.answerinput[slot] = $(document.getElementById(ggbDataset.answerinput));\r\n this.exerciseresultinput[slot] = $(document.getElementById(ggbDataset.exerciseresultinput));\r\n this.responsevars[slot] = JSON.parse(ggbDataset.responsevars);\r\n\t\t\t//window.GGBQ.checkLoading(appletParametersID);\r\n },\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n // Twingsister\r\n // takes an an array o strings that are GGB variable names either numeric text or boolean and\r\n // returns a percent % separated string of the values. If no value is present the variable is skipped\r\n\r\n\r\n\r\n //confirmedpage=false,``\r\n // called upon submit\r\n \r\n getBase64andCheck: function() {\r\n clearTimeout(timeout);\r\n debugcode();\r\n if(!confirm(\"DO NOT ACCEPT TO SILENCE THIS MESSAGE.\\nDo you want to save your work?\")){return;}\r\n for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n var ggbApplet = window['ggbApplet' + i];\r\n if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n \t//window.GGBQ.checkLoading(ggbApplet);\r\n \t//if(!this.confirmedpage&&!confirm(\"Is the applet loaded correctly?\")){location.reload();return;}else{this.confirmedpage=true;}\r\n window.GGBQ.b64input[i].val(ggbApplet.getBase64());\r\n window.GGBQ.xmlinput[i].val(ggbApplet.getXML());\r\n\r\n // Workaround, to set all randomized variables.\r\n for (const [key, value] of Object.entries(window.GGBQ.ggbDatasetVars)) {\r\n ggbApplet.evalCommand(`${key}=${value}`);\r\n }\r\n\r\n //var responsestring = '';\r\n //for (var j = 0; j < window.GGBQ.responsevars[i].length; j++) [\r\n //if (ggbApplet.isDefined(window.GGBQ.responsevars[i][j])) [\r\n // Twingsister\r\n var resp=stringfy(window.GGBQ.responsevars[i],ggbApplet);\r\n\t\t \t\t\t\t//special conditions treatement\r\n\t\t \t\t\t\t// there are both juste and grade juste is true grade is less than one then take it to one\r\n\t\t \t\t\t\tvar outputs = unpackStringified(resp);\r\n\t\t \t\t\t\tvar justeison=(((\"juste\" in outputs) && outputs[\"juste\"]===\"true\")||(isInGGB('juste',ggbApplet)&&fromGGB('juste',ggbApplet)));\r\n\t\t \t\t\t\tif(justeison){\r\n \t\t\t\t\tif( (\"grade\" in outputs)&&(Number(outputs[\"grade\"])<1)){\r\n \t\t\t\t\t outputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t\t alert(\"maximum mark assigned\");\r\n \t\t\t\t\t}\r\n \t\t\t\t}\r\n \t\t\t\t// check loading failed to work code below commented out\r\n \t\t\t\t// Some alert added to help the user to ask for a reload\r\n \t\t\t\t// if the global variable RT_R_DBLCHK is declared check if the ggb finish loading if not give full mark\r\n \t\t\t\t//if(window.hasOwnProperty('RT_R_DBLCHK')&&\r\n \t\t\t\t//\t(!window.hasOwnProperty('RT_R_Loaded')||!RT_R_Loaded)){\r\n \t\t\t\t//\toutputs[\"grade\"]=\"1.0\";\r\n \t\t\t\t//\talert(\"maximum mark assigned\");\r\n \t\t\t\t//}\r\n \t\t\t\tresp=packStringified(outputs);\r\n window.GGBQ.answerinput[i].val(resp);\r\n // Twingsister\r\n // responsestring += ggbApplet.getValue(window.GGBQ.responsevars[i][j])+'%'; // Twingsister:to add multi digit\r\n //] else [\r\n // responsestring += 0;\r\n //]\r\n //]\r\n //window.GGBQ.answerinput[i].val(responsestring);\r\n //alert(\"response\");\r\n }else{if(typeof ggbApplet !== \"undefined\"){alert(\"quiz not loaded\");location.reload()}}\r\n }\r\n },\r\n preGetBase64andCheck: function() {\r\n //for (var i = 0; i < window.GGBQ.answerinput.length; i++) {\r\n // var ggbApplet = window['ggbApplet' + i];\r\n // if (typeof ggbApplet !== \"undefined\" && ggbApplet.hasOwnProperty(\"getBase64\")) {\r\n // in ggbAApplet do some bookeping because the user pressed next page\r\n // }\r\n //}\r\n \ttimeout=setTimeout(GGBQ.preGetBase64andCheck,180000);\r\n \tGGBQ.getBase64andCheck();\r\n }\r\n//,\r\n\r\n };\r\n});\r\n//init(appletParametersID);\r\n//}\r\n"],"names":["unpackStringified","s","couples","split","results","forEach","couple","index","twos","packStringified","a","key","replace","isInGGB","v","ggbApplet","isDefined","fromGGB","res","getValue","getObjectType","stringfy","responsevars","responsestring","responsevar","value","define","$","resizeTimeout","scalingContainers","resizeScalingContainer","clearTimeout","setTimeout","Object","values","containerClass","scalingContainer","document","getElementsByClassName","formulationDivStyle","window","getComputedStyle","querySelector","parentElement","style","width","parseInt","paddingLeft","paddingRight","b64input","ggbBase64","xmlinput","ggbxml","currentvals","answerinput","exerciseresultinput","qdiv","ggbDataset","scratchit","scratchrandomizeit","scratchMark","filename","timeout","checkLoading","appletParametersID","scratchrandomize","GGBQ","this","init","scratchinit","scratch","reloadggb","url","location","href","replaceAll","trim","confirm","indexOf","preGetBase64andCheck","debugcode","getElementById","dataset","urlprefixlist","str","dic","result","alts","length","i","Date","now","cyclerepl","ggbturl","slot","scalingcontainerclass","ggbAppletOnLoad","ggbAppletId","onkeydown","checkEnter","id","substring","curvals","JSON","parse","label","setValue","removeEventListener","addEventListener","val","getBase64","getXML","visibility","evalCommand","setFixed","alert","reload","httpurl","parameters","startsWith","seeditornot","randomSeed","seed","dice","Math","floor","random","forcedimensions","height","overflowX","overflowY","scaleContainerClass","autoHeight","ggbDatasetVars","vars","language","lang","moodle","material_id","GGBAppletname","codebase","views","isurlggb","parts","urlggb","root","appl","base","require","App","applet1","showToolBar","customToolBar","preventFocus","allowStyleBar","transparentGraphics","playButton","allowUpscale","showFullscreenButton","html5nowebsimple","setHTML5Codebase","inject","div","on","getBase64andCheck","e","event","test","target","srcElement","tagName","keyCode","which","charCode","hasOwnProperty","entries","resp","outputs","Number"],"mappings":";;;;;;;;;;;miCAkCQ,SAASA,kBAAkBC,OAC5BC,QAAQD,EAAEE,MAAM,KAChBC,QAAQ,UACZF,QAAQG,SAAQ,SAAUC,OAAQC,WAC7BC,KAAKF,OAAOH,MAAM,KAAKC,QAAQI,KAAK,IAAIA,KAAK,MAExCJ,OACR,CACG,SAASK,gBAAgBC,OAG1BN,QAAQ,OACR,IAAIO,OAAOD,EAAG,CAETN,SAAWO,IAAI,IADVD,EAAEC,KACkB,WAEpBP,QAAQQ,QAAQ,MAAM,GAClC,CACD,SAASC,QAAQC,EAAEC,kBAAkBA,UAAUC,UAAUF,EAAI,CAC7D,SAASG,QAAQH,EAAEC,eACdG,IAAIH,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AQ9B,WAAWkC,KAAKa,qBAAqB,MAC7Cb,KAAKkG,qBAKb"} \ No newline at end of file diff --git a/amd/build/ggbt.min.js.map b/amd/build/ggbt.min.js.map index 73243c7..23e11bb 100644 --- a/amd/build/ggbt.min.js.map +++ b/amd/build/ggbt.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n\r\n injectapplet: function(fileURL) {\r\n if(this.hasOwnProperty('parameters')){\r\n if(this.hasOwnProperty('ggbBase64')){delete this.parameters.ggbBase64;}\r\n } else { this.parameters=null;}\r\n this.parameters = {...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","hasOwnProperty","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAaA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAGHC,KAAM,cAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACzBC,YACIP,EAAE,+BAA+BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQC,kBACnEZ,EAAE,0BAA0BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQE,aAC9Db,EAAE,oCAAoCQ,IAAIL,OAAOQ,QAAQG,gCAE1B,IAAnBT,KAAKU,UAA2B,KACpCC,OAAS3B,SAAS4B,UACtBjB,EAAE,wBAAwBQ,IAAIQ,OAAOE,UAEjB7B,SAASC,eAAe,oBACzBG,OACfU,OAAOC,KAAKe,sBAGZC,EAAI,EACJC,OAASrB,EAAE,cAAgBoB,QACVE,IAAdD,OAAO,IACNA,OAAOb,QACPa,OAAOE,GAAG,gBAAgB,SAASC,GAC/BA,EAAEC,iBACFtB,OAAOC,KAAKsB,gBA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4G,uBAAuBzH,QAChFY,OAAOC,KAAKgC,WAAWqF,iBAAmBtH,OAAOC,KAAK6G,mBAAmB1H,QACzEY,OAAOC,KAAKgC,WAAWsF,YAAcvH,OAAOC,KAAK8G,cAAc3H,QAC/DY,OAAOC,KAAKgC,WAAWuF,YAAcxH,OAAOC,KAAK+G,cAAc5H,QAC/DY,OAAOC,KAAKgC,WAAWwC,OAAS,8BAMhCzE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ+B,iBAAiBtD,UAEjDe,OAAOQ,QAAQ0C,OAAO,sBAG1BmF,OAAOM,cAAcvE,QAI7BrB,SAAU,SAAS6F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file +{"version":3,"file":"ggbt.min.js","sources":["../src/ggbt.js"],"sourcesContent":["\r\n/*eslint linebreak-style:0 -- ['error', 'windows','unix']*/\r\n/* eslint-disable no-undef */\r\n/**\r\n * Javascript Controller to embed GGBApplet\r\n *\r\n * This class provides all the functionality for the new assign module.\r\n *\r\n * @author Christoph Stadlbauer \r\n * @copyright (c) International GeoGebra Institute 2018\r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n\r\n// alert(\"hello ggbt\");\r\nvar GGBAppletstr;\r\nvar codebase;\r\n if (document.getElementById('id_isurlggb')!== null) {\r\n if (document.getElementById('id_isurlggb').checked) {\r\n GGBAppletcode = document.getElementById('id_urlggb').value;\r\n var parts=GGBAppletcode.split(\",\");\r\n var rooturl=parts[0];\r\n var appl=parts[1];\r\n var base=parts[2];\r\n GGBAppletstr = rooturl+appl ;\r\n codebase = rooturl+base;\r\n }else {\r\n GGBAppletstr = 'https://www.geogebra.org/apps/deployggb.js';\r\n codebase=\"\";}\r\n }\r\n define(['jquery', GGBAppletstr], function ($, GGBApplet) {\r\n// define(['jquery', 'https://www.geogebra.org/apps/deployggb.js'], function ($, GGBApplet) {\r\n //define(['jquery'], function ($) {\r\n /**\r\n * Created by Christoph on 25.08.19.\r\n */\r\n //var script = document.createElement('script');\r\n //script.src = 'https://www.geogebra.org/apps/deployggb.js';\r\n //document.getElementsByTagName('head')[0].appendChild(script);\r\n return {\r\n\r\n\r\n init: function() {\r\n\r\n //debugcode();//\r\n window.GGBT = this;\r\n window.ggbAppletOnLoad = function() {\r\n debugcode();\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.applet1.getParameters()));\r\n $('input[name=\"ggbviews\"]').val(JSON.stringify(window.applet1.getViews()));\r\n $('input[name=\"ggbcodebaseversion\"]').val(window.applet1.getHTML5CodebaseVersion());\r\n\r\n if (typeof (this.ggbcheckb) == \"undefined\") {\r\n var applet = document.ggbApplet;\r\n $('input[name=\"ggbxml\"]').val(applet.getXML());\r\n\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n if (!randomizedvar.value) {\r\n window.GGBT.getrandvars();\r\n }\r\n\r\n var i = 0;\r\n var answer = $('#id_answer_' + i);\r\n while (answer[0] !== undefined) {\r\n if (answer.val()) {\r\n answer.on('change focus', function(e) {\r\n e.preventDefault();\r\n window.GGBT.update_feedback($(e.target));\r\n });\r\n window.GGBT.update_feedback(answer);\r\n }\r\n answer = $('#id_answer_' + ++i);\r\n }\r\n document.querySelector('article').onkeypress = window.GGBT.checkEnter;\r\n }\r\n if (window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n }\r\n };\r\n\r\n if ($('#applet_parameters')[0] !== undefined) {\r\n this.ggbDataset = $('#applet_parameters')[0].dataset;\r\n try {\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n }\r\n catch(err) {\r\n alert(\"Error parsing JSON \"+err.message);\r\n }\r\n this.parameters = JSON.parse(this.ggbDataset.parameters);\r\n this.views = this.ggbDataset.views;\r\n //alert(\"hello custom ggb 3\");\r\n debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n //window.applet1 = new GGBApplet(this.parameters, this.views, true);\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){\r\n window.applet1.setHTML5Codebase(codebase);\r\n }\r\n this.lang = this.ggbDataset.lang;\r\n }\r\n //debugcode();\r\n\r\n //$('#id_stoapplet').on('click', this.handleStoreGGB);\r\n $('#id_loadapplet').on('click', function(e) {\r\n debugcode();\r\n e.preventDefault();\r\n var httpurl = $('#id_ggbturl').val();\r\n var id = httpurl.split(\"/\").pop();\r\n if(!httpurl.startsWith('http')){\r\n if (id.indexOf(\"m\") == 0){\r\n if (window.GGBT.isNumber(id.substr(1)) || (!window.GGBT.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n window.GGBT.injectapplet({\"material_id\": id});\r\n }else{\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n window.GGBT.injectapplet({\"filename\": httpurl});}\r\n });\r\n\r\n $('#id_getvars').on('click', function(e) {\r\n e.preventDefault();\r\n window.GGBT.getrandvars();\r\n });\r\n\r\n if (this.parameters) {\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n }\r\n\r\n this.ggbf = document.getElementById('id_ggbtheader');\r\n this.usefile = document.getElementById(\"id_usefile\");\r\n\r\n if (this.ggbf === null) { // In this case we are editing a submission.\r\n this.ggbf = document.getElementById('id_submissiontypes');\r\n this.ggbcheckb = document.getElementById('id_assignsubmission_geogebra_enabled');\r\n if (this.ggbcheckb !== null) {\r\n this.ggbcheckb.addEventListener('change', this.handleggbdisable, false);\r\n }\r\n }\r\n\r\n if (this.ggbf !== null) {\r\n this.ggbf.addEventListener('dragenter', this.handleDragEnter, false);\r\n this.ggbf.addEventListener('dragover', this.handleDragOver, false);\r\n this.ggbf.addEventListener('dragleave', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('dragend', this.handleDragEndLeave, false);\r\n this.ggbf.addEventListener('drop', this.handleDrop, false);\r\n this.usefile.addEventListener('change', this.handleusefile, false);\r\n }\r\n\r\n if (this.usefile.checked) {\r\n document.getElementById('applet_options').style.display = \"block\";\r\n } else {\r\n document.getElementById('applet_options').style.display = \"flex\"; // ex none\r\n }\r\n this.initoptions();\r\n },\r\n\r\n callback: function(params) {\r\n //alert(\"other filename\");\r\n //debugcode();\r\n var elementname = M.core_filepicker.instances[params['client_id']].options.elementname;\r\n $('#id_' + elementname).val(params.url);\r\n // inject applet to div layer\r\n if(!params.file.startsWith('http')){\r\n var id = (params.file).split(\".\")[0];\r\n if (id.indexOf(\"m\") == 0) {\r\n if (this.isNumber(id.substr(1)) || (!this.isNumber(id.substr(1)) && id.length > 8)) {\r\n id = id.substr(1);\r\n }\r\n }\r\n this.injectapplet({\"material_id\": id});\r\n }else{window.GGBT.injectapplet({\"filename\": params.file});}\r\n },\r\n\r\n\r\n injectapplet: function(fileURL) {\r\n if(this.hasOwnProperty('parameters')){\r\n if(this.hasOwnProperty('ggbBase64')){delete this.parameters.ggbBase64;}\r\n } else { this.parameters=null;}\r\n this.parameters = {...this.parameters, ...fileURL};\r\n this.parameters.language = this.lang;\r\n this.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // Since we only support HTML5 this should work for js-code in the applet to get executed (ggboninit).\r\n this.parameters.useBrowserForJS = false;\r\n //window.ggbAppletOnLoad = function (ggbAppletId) {}\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n\r\n //alert(\"hello custom ggb 4\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(this.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n\r\n },\r\n getrandvars: function() {\r\n var applet = document.ggbApplet;\r\n if (typeof applet !== 'undefined') {\r\n var objNumber = applet.getObjectNumber();\r\n var randomizedvar = document.getElementById('id_randomizedvar');\r\n var stringforrandomizedvars = \"\";\r\n var i = 0;\r\n for (var j = 0; j < objNumber; j++) {\r\n var strName = applet.getObjectName(j);\r\n if (strName == \"grade\"){\r\n var answer=$('#id_answer_' + i);\r\n if (answer !== null){answer.val(strName);this.update_feedback(answer);i++;}\r\n }\r\n if (applet.getObjectType(strName) == \"numeric\" && applet.isIndependent(strName)) {\r\n stringforrandomizedvars += strName + \",\";\r\n } else {\r\n //debugcode();\r\n /*\r\n if (applet.getObjectType(strName) == \"boolean\"){\r\n //alert(strName+\" boolean or number\");\r\n var answer = $('#id_answer_' + i);\r\n if (answer !== null && answer.length > 0) {\r\n if (!answer.val()) {\r\n answer.val(strName);\r\n }\r\n this.update_feedback(answer);\r\n i++;\r\n //alert(strName);\r\n //\r\n }\r\n }\r\n */\r\n }\r\n randomizedvar.value = stringforrandomizedvars;\r\n }\r\n //if (applet.exists(\"grade\")) {\r\n // var answerscore = $('#id_answer_' + i);\r\n // answerscore.val(\"grade\");\r\n // this.update_feedback(answerscore);\r\n // }\r\n }\r\n },\r\n\r\n update_feedback: function(answernode) {\r\n var id = answernode.attr('id').split(\"_\").pop();\r\n //debugcode();\r\n var varname = answernode.val();\r\n if (!varname) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n var feedback = $('input[name=\"feedback[' + id + ']\"]');\r\n var feedbackfromfile = $('#id_feedbackfromfile_' + id);\r\n const parser = new DOMParser();\r\n const xml = window.ggbApplet.getXML(varname);\r\n if (!xml) {\r\n // Should not happen, but make sure this function does not fail.\r\n return;\r\n }\r\n const doc = parser.parseFromString(xml, \"text/xml\");\r\n //alert(xml);\r\n if (doc) {\r\n var elem = doc.getElementsByTagName('caption');\r\n //alert(\"retrieve \"+elem.toString());\r\n var fbstring = '';\r\n if (elem.length == 1) {\r\n fbstring = elem[0].getAttribute('val');\r\n feedback.val(fbstring);\r\n //alert(\"retrieve \"+fbstring);\r\n } else if (elem.length > 1) {\r\n feedback.val('');\r\n //alert(\"retrieve fail length >1\");\r\n fbstring = '';\r\n } else {\r\n //alert(\"retrieve fail 1\");\r\n feedback.val('');\r\n //this is rather an error condition but should be checked by the server\r\n fbstring = 'Caption not set or variable name wrong.';\r\n }\r\n feedbackfromfile.val(fbstring);\r\n }\r\n },\r\n\r\n checkEnter: function(e) {\r\n e = e || event;\r\n var txtArea = /textarea/i.test((e.target || e.srcElement).tagName);\r\n return txtArea || (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n },\r\n\r\n initoptions: function() {\r\n this.enable_right_click = document.getElementById('enableRightClick');\r\n this.enable_label_drags = document.getElementById('enableLabelDrags');\r\n this.enable_undo_redo = document.getElementById('enableUndoRedo');\r\n this.show_reset_icon = document.getElementById('showResetIcon');\r\n this.enable_shift_drag_zoom = document.getElementById('enableShiftDragZoom');\r\n this.show_algebra_input = document.getElementById('showAlgebraInput');\r\n this.show_menu_bar = document.getElementById('showMenuBar');\r\n this.show_tool_bar = document.getElementById('showToolBar');\r\n\r\n if (typeof this.parameters !== 'undefined') {\r\n this.enable_right_click.checked = this.parameters.enableRightClick;\r\n this.enable_label_drags.checked = this.parameters.enableLabelDrags;\r\n this.enable_undo_redo.checked = this.parameters.enableUndoRedo;\r\n this.show_reset_icon.checked = this.parameters.showResetIcon;\r\n this.enable_shift_drag_zoom.checked = this.parameters.enableShiftDragZoom;\r\n this.show_algebra_input.checked = this.parameters.showAlgebraInput;\r\n this.show_menu_bar.checked = this.parameters.showMenuBar;\r\n this.show_tool_bar.checked = this.parameters.showToolBar;\r\n //debugcode();\r\n //document.getElementById('showToolBar').checked=this.show_tool_bar.checked;\r\n\r\n }\r\n\r\n this.enable_right_click.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_label_drags.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_undo_redo.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_reset_icon.addEventListener('change', this.handlesettingschanged, false);\r\n this.enable_shift_drag_zoom.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_algebra_input.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_menu_bar.addEventListener('change', this.handlesettingschanged, false);\r\n this.show_tool_bar.addEventListener('change', this.handlesettingschanged, false);\r\n },\r\n\r\n handlesettingschanged: function(evt) {\r\ndebugcode();\r\n window.GGBT.parameters[evt.target.id] = (evt.target.checked);\r\n $('input[name=\"ggbparameters\"]').val(JSON.stringify(window.GGBT.parameters));\r\n if (evt.target.id == \"showToolBar\" ||\r\n evt.target.id == \"showMenuBar\" ||\r\n evt.target.id == \"enableUndoRedo\" ||\r\n evt.target.id == \"showAlgebraInput\") {\r\n // alert(\"hello custom ggb 5\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\", \"preferHTML5\");\r\n } else {\r\n window.ggbApplet[evt.target.id](evt.target.checked);\r\n }\r\n },\r\n\r\n handleusefile: function() {\r\n if (!window.GGBT.usefile.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n } else {\r\n document.getElementById('id_ggbturl').value = \"\";\r\n // document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleggbdisable: function() {\r\n if (!window.GGBT.ggbcheckb.checked) {\r\n document.getElementById('applet_container1').style.display = \"none\";\r\n document.getElementById('applet_options').style.display = \"flex\"; //ex none\r\n if (window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n } else {\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n }\r\n },\r\n\r\n handleDragEnter: function() {\r\n if (typeof (ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n }\r\n },\r\n\r\n handleDragOver: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n if (e.preventDefault) {\r\n e.preventDefault();\r\n }\r\n window.GGBT.ggbf.classList.add('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.visibility = \"hidden\";\r\n return false;\r\n }\r\n },\r\n\r\n handleDragEndLeave: function() {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n }\r\n },\r\n //handleStoreGGB: function() {\r\n /*{\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n */\r\n // debugcode();\r\n // var base64 = window.ggbApplet.getBase64() ;\r\n // window.GGBT.parameters = {\"ggbBase64\": base64};\r\n /*\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n */\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n /*\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }*/\r\n ///},\r\n\r\n handleDrop: function(e) {\r\n if (typeof (window.GGBT.ggbcheckb) == \"undefined\" || window.GGBT.ggbcheckb.checked) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n var file = e.dataTransfer.files[0];\r\n window.GGBT.ggbf.classList.remove('qtype-geogebra-hover');\r\n document.getElementById('applet_container1').style.removeProperty(\"visibility\");\r\n document.getElementById('applet_container1').style.display = \"block\";\r\n document.getElementById('applet_options').style.display = \"flex\";\r\n document.getElementById('applet_container1').style.height = \"100%\";\r\n //document.getElementById('applet_container1').style.width = \"100%\";\r\n\r\n document.getElementById('id_ggbturl').value = \"\";\r\n //this.usefile = document.getElementById(\"id_usefile\");\r\n if (!window.GGBT.usefile.checked) {\r\n window.GGBT.usefile.click();\r\n }\r\n var reader = new FileReader();\r\n reader.onload = function(event) {\r\n var base64 = event.target.result.replace(\"data:application/vnd.geogebra.file;base64,\", \"\");\r\n window.GGBT.parameters = {\"ggbBase64\": base64};\r\n window.GGBT.parameters.enableRightClick = window.GGBT.enable_right_click.checked;\r\n window.GGBT.parameters.enableLabelDrags = window.GGBT.enable_label_drags.checked;\r\n window.GGBT.parameters.showResetIcon = window.GGBT.show_reset_icon.checked;\r\n window.GGBT.parameters.enableUndoRedo = window.GGBT.enable_undo_redo.checked;\r\n window.GGBT.parameters.enableShiftDragZoom = window.GGBT.enable_shift_drag_zoom.checked;\r\n window.GGBT.parameters.showAlgebraInput = window.GGBT.show_algebra_input.checked;\r\n window.GGBT.parameters.showMenuBar = window.GGBT.show_menu_bar.checked;\r\n window.GGBT.parameters.showToolBar = window.GGBT.show_tool_bar.checked;\r\n window.GGBT.parameters.moodle = \"editingQuestionOrSubmission\";\r\n // alert(\"hello custom ggb 2\");\r\n //debugcode();\r\n // if (document.getElementById('id_isurlggb').checked) {\r\n //GGBApplet = document.getElementById('id_urlggb').value;\r\n // }\r\n window.applet1 = new GGBApplet(window.GGBT.parameters, true);\r\n if(!(codebase===\"\")){window.applet1.setHTML5Codebase(codebase);}\r\n // window.applet1.setHTML5Codebase(\"https://cdn.geogebra.org/apps/5.0.541.0/web3d\");\r\n window.applet1.inject(\"applet_container1\");\r\n };\r\n\r\n reader.readAsDataURL(file);\r\n }\r\n },\r\n\r\n isNumber: function(n) {\r\n return !isNaN(parseFloat(n)) && isFinite(n);\r\n }\r\n };\r\n});\r\n"],"names":["GGBAppletstr","codebase","document","getElementById","checked","GGBAppletcode","value","parts","split","rooturl","appl","base","define","$","GGBApplet","init","window","GGBT","this","ggbAppletOnLoad","debugcode","val","JSON","stringify","applet1","getParameters","getViews","getHTML5CodebaseVersion","ggbcheckb","applet","ggbApplet","getXML","getrandvars","i","answer","undefined","on","e","preventDefault","update_feedback","target","querySelector","onkeypress","checkEnter","usefile","style","display","ggbDataset","dataset","parameters","parse","err","alert","message","views","setHTML5Codebase","lang","httpurl","id","pop","startsWith","injectapplet","indexOf","isNumber","substr","length","inject","ggbf","addEventListener","handleggbdisable","handleDragEnter","handleDragOver","handleDragEndLeave","handleDrop","handleusefile","initoptions","callback","params","elementname","M","core_filepicker","instances","options","url","file","fileURL","hasOwnProperty","ggbBase64","language","moodle","useBrowserForJS","objNumber","getObjectNumber","randomizedvar","stringforrandomizedvars","j","strName","getObjectName","getObjectType","isIndependent","answernode","attr","varname","feedback","feedbackfromfile","parser","DOMParser","xml","doc","parseFromString","elem","getElementsByTagName","fbstring","getAttribute","event","test","srcElement","tagName","keyCode","which","charCode","enable_right_click","enable_label_drags","enable_undo_redo","show_reset_icon","enable_shift_drag_zoom","show_algebra_input","show_menu_bar","show_tool_bar","enableRightClick","enableLabelDrags","enableUndoRedo","showResetIcon","enableShiftDragZoom","showAlgebraInput","showMenuBar","showToolBar","handlesettingschanged","evt","click","classList","add","visibility","remove","removeProperty","stopPropagation","dataTransfer","files","height","reader","FileReader","onload","base64","result","replace","readAsDataURL","n","isNaN","parseFloat","isFinite"],"mappings":";;;;;;;;;GAcA,IAAIA,aACAC,SACW,GAA8C,OAA1CC,SAASC,eAAe,kBACnBD,SAASC,eAAe,eAAeC,QAAS,CACnDC,cAAgBH,SAASC,eAAe,aAAaG,UAChDC,MAAMF,cAAcG,MAAM,KAC9BC,QAAQF,MAAM,GACdG,KAAKH,MAAM,GACXI,KAAKJ,MAAM,GACfP,aAAeS,QAAQC,KACvBT,SAAWQ,QAAQE,UAEhBX,aAAe,6CACfC,SAAS,GAE7BW,6BAAO,CAAC,SAAUZ,eAAe,SAAUa,EAAGC,iBASpC,CAGHC,KAAM,cAGFC,OAAOC,KAAOC,KACdF,OAAOG,gBAAkB,cACzBC,YACIP,EAAE,+BAA+BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQC,kBACnEZ,EAAE,0BAA0BQ,IAAIC,KAAKC,UAAUP,OAAOQ,QAAQE,aAC9Db,EAAE,oCAAoCQ,IAAIL,OAAO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AAKgC,WAAWgF,iBAAmBjH,OAAOC,KAAKwG,mBAAmBrH,QACzEY,OAAOC,KAAKgC,WAAWiF,iBAAmBlH,OAAOC,KAAKyG,mBAAmBtH,QACzEY,OAAOC,KAAKgC,WAAWmF,cAAgBpH,OAAOC,KAAK2G,gBAAgBxH,QACnEY,OAAOC,KAAKgC,WAAWkF,eAAiBnH,OAAOC,KAAK0G,iBAAiBvH,QACrEY,OAAOC,KAAKgC,WAAWoF,oBAAsBrH,OAAOC,KAAK4G,uBAAuBzH,QAChFY,OAAOC,KAAKgC,WAAWqF,iBAAmBtH,OAAOC,KAAK6G,mBAAmB1H,QACzEY,OAAOC,KAAKgC,WAAWsF,YAAcvH,OAAOC,KAAK8G,cAAc3H,QAC/DY,OAAOC,KAAKgC,WAAWuF,YAAcxH,OAAOC,KAAK+G,cAAc5H,QAC/DY,OAAOC,KAAKgC,WAAWwC,OAAS,8BAMhCzE,OAAOQ,QAAU,IAAIV,UAAUE,OAAOC,KAAKgC,YAAY,GAC3C,KAAXhD,UAAgBe,OAAOQ,QAAQ+B,iBAAiBtD,UAEjDe,OAAOQ,QAAQ0C,OAAO,sBAG1BmF,OAAOM,cAAcvE,QAI7BrB,SAAU,SAAS6F,UACPC,MAAMC,WAAWF,KAAOG,SAASH,IAGpD"} \ No newline at end of file diff --git a/amd/src/ggbq.js b/amd/src/ggbq.js index a242648..89e2391 100644 --- a/amd/src/ggbq.js +++ b/amd/src/ggbq.js @@ -22,6 +22,7 @@ //debugger; // eslint-disable-line //debugcode(); + function cyclerepl(str,dic){ var alts=dic.length; var result; @@ -181,10 +182,10 @@ define(['jquery'], function ($) { } }, init: function (appletParametersID) { - timeout=setTimeout(this.preGetBase64andCheck,60000) + window.GGBQ = this; + timeout=setTimeout(GGBQ.preGetBase64andCheck,180000) ////this.scratchit=true; //this.confirmedpage=false;//Twingsister - window.GGBQ = this; debugcode(); var ggbDataset = document.getElementById(appletParametersID).dataset; var reloadggb=ggbDataset.reloadggb;//what to do with reload requests @@ -392,7 +393,7 @@ define(['jquery'], function ($) { getBase64andCheck: function() { clearTimeout(timeout); debugcode(); - if(!confirm("Do you want to save your work?")){return;} + if(!confirm("DO NOT ACCEPT TO SILENCE THIS MESSAGE.\nDo you want to save your work?")){return;} for (var i = 0; i < window.GGBQ.answerinput.length; i++) { var ggbApplet = window['ggbApplet' + i]; if (typeof ggbApplet !== "undefined" && ggbApplet.hasOwnProperty("getBase64")) { @@ -443,13 +444,13 @@ define(['jquery'], function ($) { } }, preGetBase64andCheck: function() { - timeout=setTimeout(this.preGetBase64andCheck,60000); //for (var i = 0; i < window.GGBQ.answerinput.length; i++) { // var ggbApplet = window['ggbApplet' + i]; // if (typeof ggbApplet !== "undefined" && ggbApplet.hasOwnProperty("getBase64")) { // in ggbAApplet do some bookeping because the user pressed next page // } //} + timeout=setTimeout(GGBQ.preGetBase64andCheck,180000); GGBQ.getBase64andCheck(); } //, diff --git a/amd/src/ggbt.js b/amd/src/ggbt.js index 76243f5..18d60a2 100644 --- a/amd/src/ggbt.js +++ b/amd/src/ggbt.js @@ -10,6 +10,7 @@ * @copyright (c) International GeoGebra Institute 2018 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + // alert("hello ggbt"); var GGBAppletstr; var codebase; diff --git a/renderer.php b/renderer.php index 1785d47..52aa7c1 100644 --- a/renderer.php +++ b/renderer.php @@ -221,6 +221,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ 'onclick'=>'window.GGBQ.preGetBase64andCheck()' ) ); + $result=$buttonSave.$result; if(($ggbturl!=0) && strcmp(trim($reloadggb),"none")!=0){ $button =html_writer::tag('button', 'Reload', array('class'=>'mod_quiz-next-nav btn btn-primary', 'type' => 'button', @@ -229,7 +230,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_ 'onclick'=>'window.GGBQ.scratch("'.$reloadggb.'")' ) ); - $result=$buttonSave." ".$button.$result; + $result=$button." ".$result; } // twingsister // $parjson = "{".$appletparametersid."}"; diff --git a/version.php b/version.php index 653bf77..f2263cc 100644 --- a/version.php +++ b/version.php @@ -26,10 +26,10 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_geogebra'; -$plugin->version = 2025011304; +$plugin->version = 2025011306; $plugin->release = '1.13.3'; -$plugin->requires = 2018051703; +$plugin->requires = 2018051704; $plugin->dependencies = array( 'qtype_numerical' => 2014051200, 'qtype_calculated' => 2014051200,