Skip to content

Commit

Permalink
MDL-60861 analytics: Remove enable menu, if no timesplitting method
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Dec 11, 2017
1 parent 4f657ee commit f9e09bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
30 changes: 18 additions & 12 deletions admin/tool/analytics/classes/output/models_list.php
Expand Up @@ -119,6 +119,9 @@ public function export_for_template(\renderer_base $output) {
debugging("The time splitting method '{$modeldata->timesplitting}' should include a '{$identifier}_help'
string to describe its purpose.", DEBUG_DEVELOPER);
}
} else {
$helpicon = new \help_icon('timesplittingnotdefined', 'tool_analytics');
$modeldata->timesplittinghelp = $helpicon->export_for_template($output);
}

// Has this model generated predictions?.
Expand Down Expand Up @@ -207,19 +210,22 @@ public function export_for_template(\renderer_base $output) {
}

// Enable / disable.
if ($model->is_enabled()) {
$action = 'disable';
$text = get_string('disable');
$icontype = 't/block';
} else {
$action = 'enable';
$text = get_string('enable');
$icontype = 'i/checked';
if ($model->is_enabled() || !empty($modeldata->timesplitting)) {
// If there is no timesplitting method set, the model can not be enabled.
if ($model->is_enabled()) {
$action = 'disable';
$text = get_string('disable');
$icontype = 't/block';
} else {
$action = 'enable';
$text = get_string('enable');
$icontype = 'i/checked';
}
$urlparams['action'] = $action;
$url = new \moodle_url('model.php', $urlparams);
$icon = new \action_menu_link_secondary($url, new \pix_icon($icontype, $text), $text);
$actionsmenu->add($icon);
}
$urlparams['action'] = $action;
$url = new \moodle_url('model.php', $urlparams);
$icon = new \action_menu_link_secondary($url, new \pix_icon($icontype, $text), $text);
$actionsmenu->add($icon);

// Export training data.
if (!$model->is_static() && $model->is_trained()) {
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/analytics/lang/en/tool_analytics.php
Expand Up @@ -83,6 +83,8 @@
$string['samestartdate'] = 'Current start date is good';
$string['sameenddate'] = 'Current end date is good';
$string['target'] = 'Target';
$string['timesplittingnotdefined'] = 'Time splitting is not defined.';
$string['timesplittingnotdefined_help'] = 'You need to select a time-splitting method before enabling the model.';
$string['trainandpredictmodel'] = 'Training model and calculating predictions';
$string['trainingprocessfinished'] = 'Training process finished';
$string['trainingresults'] = 'Training results';
Expand Down
3 changes: 3 additions & 0 deletions admin/tool/analytics/templates/models_list.mustache
Expand Up @@ -160,6 +160,9 @@
{{/timesplitting}}
{{^timesplitting}}
{{#str}}notdefined, tool_analytics{{/str}}
{{#timesplittinghelp}}
{{>core/help_icon}}
{{/timesplittinghelp}}
{{/timesplitting}}
</td>
<td>
Expand Down

0 comments on commit f9e09bd

Please sign in to comment.