diff --git a/admin/tool/analytics/classes/clihelper.php b/admin/tool/analytics/classes/clihelper.php index c46e6fc8239..87365807f35 100644 --- a/admin/tool/analytics/classes/clihelper.php +++ b/admin/tool/analytics/classes/clihelper.php @@ -48,7 +48,7 @@ class clihelper { foreach ($models as $model) { $modelid = $model->get_id(); $isenabled = $model->is_enabled() ? get_string('enabled', 'tool_analytics') : get_string('disabled', 'tool_analytics'); - $name = $model->get_target()->get_name(); + $name = $model->get_name(); echo str_pad($modelid, 15, ' ') . ' ' . str_pad($name, 50, ' ') . ' ' . str_pad($isenabled, 15, ' ') . "\n"; } } diff --git a/admin/tool/analytics/classes/output/invalid_analysables.php b/admin/tool/analytics/classes/output/invalid_analysables.php index dbdaa00ef41..fd205f1dd8e 100644 --- a/admin/tool/analytics/classes/output/invalid_analysables.php +++ b/admin/tool/analytics/classes/output/invalid_analysables.php @@ -125,7 +125,7 @@ class invalid_analysables implements \renderable, \templatable { // Prepare the context object. $data = new \stdClass(); - $data->modelname = $this->model->get_target()->get_name(); + $data->modelname = $this->model->get_name(); if ($this->page > 0) { $prev = clone $PAGE->url; diff --git a/admin/tool/analytics/classes/output/models_list.php b/admin/tool/analytics/classes/output/models_list.php index b0431a35da5..97b6c060f7a 100644 --- a/admin/tool/analytics/classes/output/models_list.php +++ b/admin/tool/analytics/classes/output/models_list.php @@ -84,7 +84,7 @@ class models_list implements \renderable, \templatable { $data->models = array(); foreach ($this->models as $model) { - $modeldata = $model->export(); + $modeldata = $model->export($output); // Check if there is a help icon for the target to show. $identifier = $modeldata->target->get_identifier(); @@ -120,6 +120,8 @@ class models_list implements \renderable, \templatable { $modeldata->indicators = $indicators; } + $modeldata->indicatorsnum = count($modeldata->indicators); + // Check if there is a help icon for the time splitting method. if (!empty($modeldata->timesplitting)) { $identifier = $modeldata->timesplitting->get_identifier(); diff --git a/admin/tool/analytics/classes/task/predict_models.php b/admin/tool/analytics/classes/task/predict_models.php index 91f3c850688..6ea0d0d6356 100644 --- a/admin/tool/analytics/classes/task/predict_models.php +++ b/admin/tool/analytics/classes/task/predict_models.php @@ -65,7 +65,7 @@ class predict_models extends \core\task\scheduled_task { \tool_analytics\output\helper::reset_page(); if ($result) { - echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_target()->get_name())); + echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name())); $renderer = $PAGE->get_renderer('tool_analytics'); echo $renderer->render_get_predictions_results(false, array(), $result, $model->get_analyser()->get_logs()); } diff --git a/admin/tool/analytics/classes/task/train_models.php b/admin/tool/analytics/classes/task/train_models.php index 3c0c3c96019..67c0a3a5f81 100644 --- a/admin/tool/analytics/classes/task/train_models.php +++ b/admin/tool/analytics/classes/task/train_models.php @@ -76,7 +76,7 @@ class train_models extends \core\task\scheduled_task { \tool_analytics\output\helper::reset_page(); if ($result) { - echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_target()->get_name())); + echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name())); $renderer = $PAGE->get_renderer('tool_analytics'); echo $renderer->render_get_predictions_results($result, $model->get_analyser()->get_logs()); diff --git a/admin/tool/analytics/lang/en/tool_analytics.php b/admin/tool/analytics/lang/en/tool_analytics.php index 34c1585ff71..4c8fe86a313 100644 --- a/admin/tool/analytics/lang/en/tool_analytics.php +++ b/admin/tool/analytics/lang/en/tool_analytics.php @@ -81,6 +81,7 @@ $string['importmodel'] = 'Import model'; $string['indicators'] = 'Indicators'; $string['indicators_help'] = 'The indicators are what you think will lead to an accurate prediction of the target.'; $string['indicators_link'] = 'Indicators'; +$string['indicatorsnum'] = 'Number of indicators: {$a}'; $string['info'] = 'Info'; $string['ignoreversionmismatches'] = 'Ignore version mismatches'; $string['ignoreversionmismatchescheckbox'] = 'Ignore the differences between this site version and the original site version.'; @@ -96,6 +97,7 @@ $string['loginfo'] = 'Log extra info'; $string['missingmoodleversion'] = 'Imported file does not define a moodle version number'; $string['modelid'] = 'Model ID'; $string['modelinvalidanalysables'] = 'Invalid analysable elements for "{$a}" model'; +$string['modelname'] = 'Model name'; $string['modelresults'] = '{$a} results'; $string['modeltimesplitting'] = 'Time splitting'; $string['nextpage'] = 'Next page'; diff --git a/admin/tool/analytics/model.php b/admin/tool/analytics/model.php index d70fad3660a..1a65f88a363 100644 --- a/admin/tool/analytics/model.php +++ b/admin/tool/analytics/model.php @@ -40,7 +40,7 @@ $url = new \moodle_url('/admin/tool/analytics/model.php', $params); switch ($action) { case 'edit': - $title = get_string('editmodel', 'tool_analytics', $model->get_target()->get_name()); + $title = get_string('editmodel', 'tool_analytics', $model->get_name()); break; case 'evaluate': $title = get_string('evaluatemodel', 'tool_analytics'); diff --git a/admin/tool/analytics/templates/models_list.mustache b/admin/tool/analytics/templates/models_list.mustache index b49c9e212cd..601dd5296d7 100644 --- a/admin/tool/analytics/templates/models_list.mustache +++ b/admin/tool/analytics/templates/models_list.mustache @@ -20,85 +20,118 @@ Template for models list. Classes required for JS: - * none + * The list od models wrapped within a id="predictionmodelslist" element. Data attributes required for JS: - * none + * [data-widget="toggle"] indicates the clickable element for expanding/collapsing + the list of indicators used by the given model. Context variables required for this template: - * none + * models: array - list of models to display + - id: int - model unique identifier + - name: object - data for the inplace editable element template + - target: string - name of the target associated with the model + - targetclass: string - fully qualified name of the target class + - targethelp: object - data for the help tooltip template + - enabled: bool - is the model enabled + - indicatorsnum: int - number of indicators + - indicators: array - list of indicators used by the model + + name: string - name of the indicator + + help: object - data for the help tooltip template + - insights: object - data for the single select template + - noinsights: string - text to display instead of insights + * warnings: array - list of data for notification warning template + * infos: array - list of data for notification info template + * createmodelurl: string - URL to create a new model + * importmodelurl: string - URL to import a model Example context (json): { "models": [ { + "id": 11, + "name": { + "component": "local_analyticsdemo", + "itemtype": "modelname", + "itemid": 42, + "displayvalue": "Prevent devs at risk", + "value": "" + }, "target": "Prevent devs at risk", - "targethelp": [ - { - "title": "Help with something", - "url": "http://example.org/help", - "linktext": "", - "icon":{ - "extraclasses": "iconhelp", - "attributes": [ - {"name": "src", "value": "../../../pix/help.svg"}, - {"name": "alt", "value": "Help icon"} - ] - } + "targetclass": "\\local_analyticsdemo\\analytics\\target\\dev_risk", + "targethelp": { + "title": "Help with Prevent devs at risk", + "text": "This target blah blah ...", + "url": "http://example.org/help", + "linktext": "", + "icon": { + "extraclasses": "iconhelp", + "attributes": [ + {"name": "src", "value": "../../../pix/help.svg"}, + {"name": "alt", "value": "Help icon"} + ] } - ], + }, "enabled": 1, - "indicators": [{ - "name": "Indicator 1", - "help": [{ - "title": "Help with something", + "indicatorsnum": 2, + "indicators": [ + { + "name": "Indicator 1", + "help": { + "text": "This indicator blah blah ...", + "title": "Help with Indicator 1", "url": "http://example.org/help", "linktext": "", - "icon":{ + "icon": { "extraclasses": "iconhelp", "attributes": [ {"name": "src", "value": "../../../pix/help.svg"}, {"name": "alt", "value": "Help icon"} ] } - }] + } }, { - "name": "Indicator 2", - "help": [{ - "title": "Help with something", + "name": "Indicator 2", + "help": { + "text": "This indicator blah blah ...", + "title": "Help with Indicator 2", "url": "http://example.org/help", "linktext": "", - "icon":{ + "icon": { "extraclasses": "iconhelp", "attributes": [ {"name": "src", "value": "../../../pix/help.svg"}, {"name": "alt", "value": "Help icon"} ] } - }] - }], - "timesplitting": "Quarters", - "timesplittinghelp": [ - { - "title": "Help with something", - "url": "http://example.org/help", - "linktext": "", - "icon":{ - "extraclasses": "iconhelp", - "attributes": [ - {"name": "src", "value": "../../../pix/help.svg"}, - {"name": "alt", "value": "Help icon"} - ] } } ], + "timesplitting": "Quarters", + "timesplittinghelp": { + "text": "This time splitting methof blah blah ...", + "title": "Help with Quarters", + "url": "http://example.org/help", + "linktext": "", + "icon": { + "extraclasses": "iconhelp", + "attributes": [ + {"name": "src", "value": "../../../pix/help.svg"}, + {"name": "alt", "value": "Help icon"} + ] + } + }, "noinsights": "No insights available yet" } ], - "warnings": { - "message": "Hey, this is a warning" - } + "warnings": [ + { + "message": "Be ware, this is just an example!" + } + ], + "createmodelurl": "#", + "importmodelurl": "#" } }} @@ -114,11 +147,11 @@ {{#str}}createmodel, tool_analytics{{/str}} {{#str}}importmodel, tool_analytics{{/str}} -
{{#str}}target, tool_analytics{{/str}} | +{{#str}}modelname, tool_analytics{{/str}} | {{#str}}enabled, tool_analytics{{/str}} | {{#str}}indicators, tool_analytics{{/str}} | {{#str}}modeltimesplitting, tool_analytics{{/str}} | @@ -130,10 +163,15 @@ {{#models}}
---|---|---|---|---|
- {{target}}
- {{#targethelp}}
- {{>core/help_icon}}
- {{/targethelp}}
+ {{#name}}
+ {{>core/inplace_editable}}
+ {{/name}}
+
+ {{targetclass}}
+ {{#targethelp}}
+ {{>core/help_icon}}
+ {{/targethelp}}
+
|
{{#enabled}} @@ -144,7 +182,15 @@ {{/enabled}} |
-
|