{"id":18246307,"url":"https://github.com/jsxgraph/moodleformulas_jsxgraph","last_synced_at":"2025-07-24T07:02:53.557Z","repository":{"id":146719765,"uuid":"273464803","full_name":"jsxgraph/moodleformulas_jsxgraph","owner":"jsxgraph","description":"JavaScript code to simplify the usage of JSXGraph in moodle formulas question type","archived":false,"fork":false,"pushed_at":"2024-06-14T13:15:12.000Z","size":562,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-06T19:56:06.370Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsxgraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-19T10:18:17.000Z","updated_at":"2024-06-14T13:15:15.000Z","dependencies_parsed_at":"2023-12-18T09:51:25.490Z","dependency_job_id":null,"html_url":"https://github.com/jsxgraph/moodleformulas_jsxgraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsxgraph/moodleformulas_jsxgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsxgraph%2Fmoodleformulas_jsxgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsxgraph%2Fmoodleformulas_jsxgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsxgraph%2Fmoodleformulas_jsxgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsxgraph%2Fmoodleformulas_jsxgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsxgraph","download_url":"https://codeload.github.com/jsxgraph/moodleformulas_jsxgraph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsxgraph%2Fmoodleformulas_jsxgraph/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266806952,"owners_count":23987420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T09:25:22.898Z","updated_at":"2025-07-24T07:02:53.507Z","avatar_url":"https://github.com/jsxgraph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Formulas extension for Moodle JSXGraph filter\n\nThe [moodle question type formulas](https://moodle.org/plugins/qtype_formulas), see also [dynamiccourseware.org](https://dynamiccourseware.org/), allows to create questions containing random values and multiple answer fields.\nThis extension was created for the [Moodle JSXGraph filter](https://github.com/jsxgraph/moodle-filter_jsxgraph) and is used to use JSXGraph constructions in formulas questions.\nIt supplies the transfer of values between the formulas question and [JSXGraph](https://jsxgraph.org) constructions. \n\n### About JSXGraph\n\nJSXGraph is a cross-browser JavaScript library for interactive geometry, function plotting, charting, and data visualization in the web browser.\nJSXGraph is implemented in pure JavaScript and does not rely on any other library. Special care has been taken to optimize the performance.\n\nHave a look at [www.jsxgraph.org](https://jsxgraph.org/).\n\n### About Moodle JSXGraph filter\n\nThe [Moodle JSXGraph filter](https://github.com/jsxgraph/moodle-filter_jsxgraph) is a plugin for [Moodle](http://moodle.org) to enable function plotting and dynamic geometry constructions with [JSXGraph](http://jsxgraph.org) within a Moodle platform.\n\n*The plugin for Moodle also contains these files.*\n\n## Installation\n\nThis extension does not need to be installed separately. \nInstead, it is already included in the Moodle filter and is delivered with it.\n\nFollow the installation instructions [here](https://github.com/jsxgraph/moodle-filter_jsxgraph#installation).\n\n## Usage\n\nThe formulas extension is used within a JSXGraph tag.\nTo do this, either the global setting \"formulasextension\" must be activated in the filter \n\n![settings](screenshots/settings.png)\n\nor the tag must contain the attribute `ext_formulas`:\n\n```html\n\u003cjsxgraph width=\"500\" height=\"500\" ext_formulas\u003e\n    ...\n\u003c/jsxgraph\u003e\n```\n\n### Insert a board into a question\n\nTo use a JSXGraph board in a formulas question, first create a question in this category. Then follow the steps below:\n\n1. As usual, assign a meaningful name for the question.\n2. Variables can be defined for the use of formulas. Do this in the \"Variables\" section. A detailed example of this can be found below.\n3. Write a question in \"Question text\".\n4. In \"Part 1\" define the inputs. Several inputs can be defined with `[...]` under \"Answer\".\n5. Under \"Part's text\" a JSXGraph board can now be integrated in the usual filter notation. If the extension is not activated globally, the tag attribute \"ext_formulas\" must be used.\n    * Warning: the code that is inside the `\u003cjsxgraph\u003e` tag must now be declared within a function.\n    * Finally, this function is transferred to an object of the JSXQuestion class with the following call:\n      ```html\n      \u003cjsxgraph width=\"500\" height=\"500\" ext_formulas\u003e\n          var jsxGraphCode = function (question) { ... };\n          new JSXQuestion(BOARDID, jsxGraphCode);\n      \u003c/jsxgraph\u003e\n      ```\n      More information on using the JSXQuestion class can be found below.\n    * Within the function `jsxGraphCode` the object of the class JSXQuestion can be accessed via the parameter `question` and its variables and methods can be used. An overview of this can be found below.\n    \n### Insert more than one board into a question\n\nAs in a normal Moodle site, you can also use several boards in a formulas question. The JSXQuestion class even offers a number of helpful methods for this case.\n\nTo use multiple boards, you can proceed in the same way as above with one board. In contrast to point 5, you must note the following:\n\n- Always hand over all boards that were declared in the tag. The best way to do this is to use the `BOARDIDS` array. E.g.:\n  ```html\n  \u003cjsxgraph width=\"500\" height=\"500\" numberOfBoards=\"2\" ext_formulas\u003e\n      var jsxGraphCode = function (question) { ... };\n      new JSXQuestion(BOARDIDS, jsxGraphCode);\n  \u003c/jsxgraph\u003e\n  ```\n  \n- As attributes and methods for JSXQuestion you should now use the following in your code:\n    * In the attribute `BOARDID` (= `firstBOARDID`) only the ID of the **first** board is saved. `BOARDIDS` contains all IDs as an array.\n    * The attribute `board` (= `firstBoard`) also only contains the reference to the **first** board. Use the `boards` array instead.\n    * The method `initBoards` initializes **all** given boards, just like the old` initBoard`. The only difference is that `initBoard` only returns the first board,` initBoards` all as an array.\n    \n        **Attention! Use the `initBoards` method of the` JSXQuestion` class instead of `JXG.JSXGraph.initBoard`, because with our method all attributes are automatically set to the correct value in the JSXQuestion object. How to assign different attributes to the individual boards can be read under [Methods](#methods).**\n    \n    * All other attributes and methods can be used normally.\n    * We aditionally offer the functions `addChildsAsc` and `addChildsDesc` to link the boards (see [Methods](#methods)).\n\n### Using the class JSXQuestion\n\n#### Initialization\n\nThe constructor `new JSXQuestion(boardIDs, jsxGraphCode, allowInputEntry, decimalPrecision)` of class JSXQuestion takes the following parameters:\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{String\u0026nbsp;|\u0026nbsp;String[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003eboardIDs\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            ID of the HTML element containing the JSXGraph board. \n            The board can be addressed within a tag using the constant \u003ccode\u003eBOARDID\u003c/code\u003e. \n            Therefore this parameter has to be set to \u003ccode\u003eBOARDID\u003c/code\u003e.\n            If more than one board is used, the array \u003ccode\u003eBOARDIDS\u003c/code\u003e must be given.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{Function}\u003c/i\u003e\u0026nbsp;\u003cb\u003ejsxGraphCode\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            JavaScript function containing the construction code.\n            The function must expect the object of class JSXQuestion as input.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n           \u003ci\u003e{Boolean}\u003c/i\u003e\u0026nbsp;\u003cb\u003eallowInputEntry\u003c/b\u003e Optional,\u0026nbsp;Default:\u0026nbsp;\u003ccode\u003efalse\u003c/code\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Should the original inputs from formulas be displayed and linked to the construction?\u003cbr\u003e\n            If this parameter is \u003ccode\u003efalse\u003c/code\u003e, the input fields for users are hidden.\u003cbr\u003e\n            If it is set to \u003ccode\u003etrue\u003c/code\u003e, the inputs are displayed and linked to the \n            construction, so that the function \u003ccode\u003ejsxGraphCode(...)\u003c/code\u003e is executed again \n            if there is a change in an input field.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003edecimalPrecision\u003c/b\u003e Optional,\u0026nbsp;Default:\u0026nbsp;\u003ccode\u003e2\u003c/code\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Number of digits to round to.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n#### Attributes\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{String[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003eBOARDIDS\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            IDs of the involved boards in an array.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{String}\u003c/i\u003e\u0026nbsp;\u003cb\u003efirstBOARDID\u003c/b\u003e\u003cbr\u003e\n            \u003ci\u003e{String}\u003c/i\u003e\u0026nbsp;\u003cb\u003eBOARDID\u003c/b\u003e\u0026nbsp;(deprecated)\n        \u003c/td\u003e\n        \u003ctd\u003e\n            ID of the \u003cb\u003efirst\u003c/b\u003e board.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{JXG.Board[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003eboards\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Array with the stored JSXGraph boards.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{JXG.Board}\u003c/i\u003e\u0026nbsp;\u003cb\u003efirstBoard\u003c/b\u003e\u003cbr\u003e\n            \u003ci\u003e{JXG.Board}\u003c/i\u003e\u0026nbsp;\u003cb\u003eboard\u003c/b\u003e\u0026nbsp;(deprecated)\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Stored \u003cb\u003efirst\u003c/b\u003e JSXGraph board.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{HTMLElement[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003einputs\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Stores the input tags from the formulas question.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{Boolean}\u003c/i\u003e\u0026nbsp;\u003cb\u003eisSolved\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Indicator if the question has been solved.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n#### Methods\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{JXG.Board}\u003c/i\u003e\u0026nbsp;\u003cb\u003einitAndAddBoard(id, attributes)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{String}\u003c/i\u003e\u0026nbsp;\u003cb\u003eid\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Object}\u003c/i\u003e\u0026nbsp;\u003cb\u003eattributes\u003c/b\u003e\u0026nbsp;[\u003ci\u003edefault: {}\u003c/i\u003e]\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Initializes and adds one board to the boards array. The \u003ccode\u003eid\u003c/code\u003e must be part of the \u003ccode\u003eBOARDIDS\u003c/code\u003e array. \n            The resulting board, which is also returned, is added to boards at this index where \u003ccode\u003eid\u003c/code\u003e is in the array \u003ccode\u003eBOARDIDS\u003c/code\u003e.\n            If a board already exists for this \u003ccode\u003eid\u003c/code\u003e, it will be deleted.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{JXG.Board[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003einitBoards(attributes)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Object\u0026nbsp;|\u0026nbsp;Object[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003eattributes\u003c/b\u003e\u0026nbsp;[\u003ci\u003edefault: {}\u003c/i\u003e]\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Initializes the board(s), saves it/them in the attributes of JSXQuestion and returns an array of boards.\n            For this, the object in \u003ccode\u003eattributes\u003c/code\u003e is forwarded to the function \n            \u003ccode\u003eJXG.JSXGraph.initBoard(...)\u003c/code\u003e. The string passed during initialization of JSXQuestion object\n            is used as the id for the board. If two parameters are specified (as in the \n            specification of \u003ccode\u003eJXG.JSXGraph.initBoard(...)\u003c/code\u003e), the first parameter\n            is ignored.\u003cbr\u003e\n            \u003ccode\u003eattributes\u003c/code\u003e can also be an array of attribute objects.\n            If there are given fewer attributes than there are boards, the first attributes are used as standard.\u003cbr\u003e The attribute \u003ccode\u003eboards\u003c/code\u003e is cleared and new initialized in this method.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{JXG.Board[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003einitBoard(firstParam, secondParam)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{String\u0026nbsp;|\u0026nbsp;Object\u0026nbsp;|\u0026nbsp;Object[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003efirstParam\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Object\u0026nbsp;|\u0026nbsp;Object[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003esecondParam\u003c/b\u003e\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            If \u003ccode\u003efirstParam\u003c/code\u003e is an string or an single (attributes-) object, this function call is forwarded to \u003ccode\u003einitAndAddBoard\u003c/code\u003e. Otherwise this function is an alias for \u003ccode\u003einitBoards\u003c/code\u003e.\u003cbr\u003e\n             \u003ci\u003eFor backward compatibility.\u003c/i\u003e\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003eaddChildsAsc()\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Calls the function \u003ccode\u003eaddChild\u003c/code\u003e ascending for each board.\n            After this function \u003ccode\u003eboards[0]\u003c/code\u003e is child of \u003ccode\u003eboards[1]\u003c/code\u003e, \u003ccode\u003eboards[1]\u003c/code\u003e is child of \u003ccode\u003eboards[2]\u003c/code\u003e etc.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n            \u003ctd\u003e\n                \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003eaddChildsDesc()\u003c/b\u003e\n            \u003c/td\u003e\n            \u003ctd\u003e\n                Calls the function \u003ccode\u003eaddChild\u003c/code\u003e descending for each board.\n                After this function \u003ccode\u003eboards[0]\u003c/code\u003e is parent of \u003ccode\u003eboards[1]\u003c/code\u003e, \u003ccode\u003eboards[1]\u003c/code\u003e is parent of \u003ccode\u003eboards[2]\u003c/code\u003e etc.\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003ebindInput(inputNumber,\u0026nbsp;valueFunction)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003einputNumber\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Function}\u003c/i\u003e\u0026nbsp;\u003cb\u003evalueFunction\u003c/b\u003e\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Links the board to the inputs. If a change has been made in the board, the \n            input with the number \u003ccode\u003einputNumber\u003c/code\u003e is assigned the value that \n            the function \u003ccode\u003evalueFunction()\u003c/code\u003e returns.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003eset(inputNumber,\u0026nbsp;value)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003einputNumber\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003evalue\u003c/b\u003e\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Fill input element of index \u003ccode\u003einputNumber\u003c/code\u003e of the formulas question \n            with \u003ccode\u003evalue\u003c/code\u003e.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003esetAllValues(values)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003evalues\u003c/b\u003e\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Set values for all formulas input fields. The array \u003ccode\u003evalues\u003c/code\u003e \n            contains the values in the appropriate order.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003eget(inputNumber,\u0026nbsp;defaultValue)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003einputNumber\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number}\u003c/i\u003e\u0026nbsp;\u003cb\u003edefaultValue\u003c/b\u003e\u0026nbsp;[\u003ci\u003edefault: 0\u003c/i\u003e]\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Get the content of input element of index \u003ccode\u003einputNumber\u003c/code\u003e of the\n            formulas question as number. If the value of the input could not be read \n            or is not a number the optional \u003ccode\u003edefaultValue\u003c/code\u003e is returned.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{Number[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003egetAllValues(defaultValues)\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e\u003csmall\u003e\n            \u003cb\u003eParameters:\u003c/b\u003e\u003cbr\u003e\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ci\u003e{Number\u0026nbsp;|\u0026nbsp;Number[\u0026nbsp;]}\u003c/i\u003e\u0026nbsp;\u003cb\u003edefaultValues\u003c/b\u003e\u0026nbsp;[\u003ci\u003edefault: 0\u003c/i\u003e]\n            \u003c/small\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Fetch all values from the formulas input fields. If the value of the input \n            could not be read or is not a number the optional entry of the array \n            \u003ccode\u003edefaultValues\u003c/code\u003e is returned.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\n            \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003ereload()\u003c/b\u003e\u003cbr\u003e\n            \u003ci\u003e{void}\u003c/i\u003e\u0026nbsp;\u003cb\u003eupdate()\u003c/b\u003e\n        \u003c/td\u003e\n        \u003ctd\u003e\n            Reload the construction by executing the given function \u003ccode\u003ejsxGraphCode\u003c/code\u003e.\n        \u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## Example\n\nConsider the following *formulas* question:\n\n![screen1](screenshots/screen1.png)\n\nThe students should drag the red points such that the blue curve has the equation *y = 2x + 10*.\nAfter having done so, the student clicks on the Check-button to check the correctness of the \nsolution. The correct solution is\n\n![screen2](screenshots/screen2.png)\n\nThe above question can be realized with *formulas* by supplying the following data:\n\n![screen 3](screenshots/screen3.png)\n\nThe variable *a* takes a random value out of the set *{2, 3}* and the variable *b* takes a \nrandom value out of the set *{10, 20}*. Since the student has to compute *ax+b* for the \nvalues *1, 2, 3, 4*, the correct values are precomputed in the global variables \n*y1, y2, y3, y4*. As correct answer we demand from the student the four values: \n*[y1, y2, y3, y4]*. If the question does not use JSXGraph there would be four input fields \nfor the answers.\n\n![screen 4](screenshots/screen4.png)\n\nWithout JSXGraph the student would have to type the four numbers of the solution into \nfour input fields. Now this question is enriched with a JSXgraph construction.\nThis can be done by adding the following code into the field \"Part's text\" in Part 1:\n\n```html\n\u003cjsxgraph width=\"400\" height=\"400\" ext_formulas\u003e\n\n    // JavaScript code to create the construction.\n    var jsxCode = function (question) {\n\n        // Import the initial y-coordinates of the four points from formulas\n        var t1, t2, t3, t4;\n        [t1, t2, t3, t4] = question.getAllValues();\n\n        // Initialize the construction\n        var board = question.initBoard(BOARDID, {\n                axis:true,\n                boundingbox: [-0.5, 35, 5.5, -5],\n                showCopyright: true,\n                showNavigation: true\n            });\n        // Four invisible, vertical lines\n        var line1 = board.create('segment', [[1,-5], [1,35]], {visible:false}),\n            line2 = board.create('segment', [[2,-5], [2,35]], {visible:false}),\n            line3 = board.create('segment', [[3,-5], [3,35]], {visible:false}),\n            line4 = board.create('segment', [[4,-5], [4,35]], {visible:false});\n\n        // The four points fixated to the lines, called 'gliders'.\n        var point_attr = {fixed: question.isSolved, snapToGrid: true, withLabel: false},\n            p = [];\n        p.push(board.create('glider', [1, t1, line1], point_attr));\n        p.push(board.create('glider', [2, t2, line2], point_attr));\n        p.push(board.create('glider', [3, t3, line3], point_attr));\n        p.push(board.create('glider', [4, t4, line4], point_attr));\n\n        // The polygonal chain, aka. polyline, through the four points\n        board.create('polygonalchain', p, {borders: {strokeWidth: 3}});\n\n        // Whenever the construction is altered the values of the points are sent to formulas.\n        question.bindInput(0, () =\u003e { return p[0].Y(); });\n        question.bindInput(1, () =\u003e { return p[1].Y(); });\n        question.bindInput(2, () =\u003e { return p[2].Y(); });\n        question.bindInput(3, () =\u003e { return p[3].Y(); });\n    };\n\n    // Execute the JavaScript code.\n    new JSXQuestion(BOARDID, jsxCode, /* if you want to see inputs: */ true);\n\n\u003c/jsxgraph\u003e\n```\n\n## Feedback\n\nAll bugs, feature requests, feedback, etc., are welcome.\n\n## Contributors\n\nThe project is based on work by [Tim Kos](https://github.com/timkos) and [Marc Bernart](https://github.com/marcbern-at).\nAt the moment it is developed by [The Center of Mobile Learning with Digital Technology](http://mobile-learning.uni-bayreuth.de/) (contact: Alfred Wassermann and Andreas Walter).\n\n\n## License\n\nSee [here](./LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsxgraph%2Fmoodleformulas_jsxgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsxgraph%2Fmoodleformulas_jsxgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsxgraph%2Fmoodleformulas_jsxgraph/lists"}