{{! This file is part of Moodle - http://moodle.org/ Moodle is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Moodle is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Moodle. If not, see . }} {{! @template tool_analytics/restorable_models Displays the list of missing prediction models that can be restored. Classes required for JS: * The list should be wrapped within a id="restorablemodelslist" element. Data attributes required for JS: * [data-widget="toggle"] indicates the clickable element for expanding/collapsing the list of indicators used by the given model. * [data-select] indicates a clickable element used for selecting multiple checkboxes. * [data-component] should be set for checkboxes that select the particular model. Context variables required for this template: * hasdata: boolean - do we have data to display * submiturl: string - URL where the form should be submitted * backurl: string - URL where the user should be sent without making any changes * sesskey: string * components: array - list of components to display - name: string - human readable name of the component - component: string - frankenstyle name of the component - models: array - list of restorable models provided by the component + defid: string - model definition identifier + targetname: string - human readable name of the target + targetclass: string - fully qualified classname of the target + indicatorsnum: int - number of indicators + indicators: array - list of indicators ~ name: string - human readable name of the indicator ~ classname: string - fully qualified classname of the indicator Example context (json): { "hasdata": true, "submiturl": "https://example.com/moodle/admin/tool/analytics/restoredefault.php", "backurl": "https://example.com/moodle/admin/tool/analytics/index.php", "sesskey": "abcdefg123456", "components": [ { "name": "Core", "component": "core", "models": [ { "defid": "id24680aceg", "targetname": "No teaching", "targetclass": "\\core\\analytics\\target\\no_teaching", "indicatorsnum": 2, "indicators": [ { "name": "There are no teachers", "classname": "\\core\\analytics\\indicator\\no_teacher" }, { "name": "There are no students", "classname": "\\core\\analytics\\indicator\\no_students" } ] }, { "defid": "id13579bdfi", "targetname": "Students at risk of dropping out", "targetclass": "\\core\\analytics\\target\\course_dropout", "indicatorsnum": 1, "indicators": [ { "name": "Read actions amount", "classname": "\\core\\analytics\\indicator\\read_actions" } ] } ] }, { "name": "Custom analytics plugin", "component": "tool_customanalytics", "models": [ { "defid": "id566dsgffg655", "targetname": "Cheater", "targetclass": "\\tool_customanalytics\\analytics\\target\\cheater", "indicatorsnum": 1, "indicators": [ { "name": "Copy-pasted submissions", "classname": "\\tool_customanalytics\\analytics\\indicator\\copy_paster_submissions" } ] } ] } ] } }}
{{^hasdata}}

{{#str}} restoredefaultnone, tool_analytics {{/str}}

{{#str}} back {{/str}}
{{/hasdata}} {{#hasdata}}

{{#str}} restoredefaultinfo, tool_analytics {{/str}}

{{#components}} {{#models}} {{/models}} {{/components}}
{{#str}} selectall {{/str}} {{#str}} target, tool_analytics {{/str}} {{#str}} indicators, tool_analytics {{/str}}
{{name}}
{{component}}
{{targetname}} {{#targethelp}} {{>core/help_icon}} {{/targethelp}}
{{targetclass}}
{{#str}} back {{/str}}
{{/hasdata}}
{{#js}} require(['jquery'], function($) { // Toggle the visibility of the indicators list. $('#restorablemodelslist').on('click', '[data-widget="toggle"]', function(e) { e.preventDefault(); var toggle = $(e.currentTarget); var listid = toggle.attr('aria-controls'); $(document.getElementById(listid)).toggle(); if (toggle.attr('aria-expanded') == 'false') { toggle.attr('aria-expanded', 'true'); } else { toggle.attr('aria-expanded', 'false'); } }); // Selecting all / all in component checkboxes. $('#restorablemodelslist').on('click', '[data-select]', function(e) { e.preventDefault(); var handler = $(e.currentTarget); var component = handler.attr('data-select'); if (component == '*') { $('input[data-component]').prop('checked', true); } else { $('input[data-component="' + component + '"]').prop('checked', true); } }); }); {{/js}}