mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-59307_master' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
d267d66fdf
3 changed files with 45 additions and 6 deletions
|
@ -117,6 +117,20 @@ class models_list implements \renderable, \templatable {
|
||||||
$actionsmenu->add($icon);
|
$actionsmenu->add($icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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';
|
||||||
|
}
|
||||||
|
$url = new \moodle_url('model.php', array('action' => $action, 'id' => $model->get_id()));
|
||||||
|
$icon = new \action_menu_link_secondary($url, new \pix_icon($icontype, $text), $text);
|
||||||
|
$actionsmenu->add($icon);
|
||||||
|
|
||||||
// Evaluate machine-learning-based models.
|
// Evaluate machine-learning-based models.
|
||||||
if ($model->get_indicators() && !$model->is_static()) {
|
if ($model->get_indicators() && !$model->is_static()) {
|
||||||
$url = new \moodle_url('model.php', array('action' => 'evaluate', 'id' => $model->get_id()));
|
$url = new \moodle_url('model.php', array('action' => 'evaluate', 'id' => $model->get_id()));
|
||||||
|
|
|
@ -51,6 +51,13 @@ switch ($action) {
|
||||||
case 'log':
|
case 'log':
|
||||||
$title = get_string('viewlog', 'tool_analytics');
|
$title = get_string('viewlog', 'tool_analytics');
|
||||||
break;
|
break;
|
||||||
|
case 'enable':
|
||||||
|
$title = get_string('enable');
|
||||||
|
break;
|
||||||
|
case 'disable':
|
||||||
|
$title = get_string('disable');
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new moodle_exception('errorunknownaction', 'analytics');
|
throw new moodle_exception('errorunknownaction', 'analytics');
|
||||||
}
|
}
|
||||||
|
@ -63,6 +70,14 @@ $PAGE->set_heading($title);
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
|
||||||
|
case 'enable':
|
||||||
|
$model->enable();
|
||||||
|
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||||
|
|
||||||
|
case 'disable':
|
||||||
|
$model->update(0, false, false);
|
||||||
|
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
|
||||||
if ($model->is_static()) {
|
if ($model->is_static()) {
|
||||||
|
|
|
@ -395,20 +395,30 @@ class model {
|
||||||
* Updates the model.
|
* Updates the model.
|
||||||
*
|
*
|
||||||
* @param int|bool $enabled
|
* @param int|bool $enabled
|
||||||
* @param \core_analytics\local\indicator\base[] $indicators
|
* @param \core_analytics\local\indicator\base[]|false $indicators False to respect current indicators
|
||||||
* @param string $timesplittingid
|
* @param string|false $timesplittingid False to respect current time splitting method
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function update($enabled, $indicators, $timesplittingid = '') {
|
public function update($enabled, $indicators = false, $timesplittingid = '') {
|
||||||
global $USER, $DB;
|
global $USER, $DB;
|
||||||
|
|
||||||
\core_analytics\manager::check_can_manage_models();
|
\core_analytics\manager::check_can_manage_models();
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
|
|
||||||
$indicatorclasses = self::indicator_classes($indicators);
|
if ($indicators !== false) {
|
||||||
|
$indicatorclasses = self::indicator_classes($indicators);
|
||||||
|
$indicatorsstr = json_encode($indicatorclasses);
|
||||||
|
} else {
|
||||||
|
// Respect current value.
|
||||||
|
$indicatorsstr = $this->model->indicators;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($timesplittingid === false) {
|
||||||
|
// Respect current value.
|
||||||
|
$timesplittingid = $this->model->timesplitting;
|
||||||
|
}
|
||||||
|
|
||||||
$indicatorsstr = json_encode($indicatorclasses);
|
|
||||||
if ($this->model->timesplitting !== $timesplittingid ||
|
if ($this->model->timesplitting !== $timesplittingid ||
|
||||||
$this->model->indicators !== $indicatorsstr) {
|
$this->model->indicators !== $indicatorsstr) {
|
||||||
// We update the version of the model so different time splittings are not mixed up.
|
// We update the version of the model so different time splittings are not mixed up.
|
||||||
|
@ -900,7 +910,7 @@ class model {
|
||||||
/**
|
/**
|
||||||
* Enabled the model using the provided time splitting method.
|
* Enabled the model using the provided time splitting method.
|
||||||
*
|
*
|
||||||
* @param string $timesplittingid
|
* @param string|false $timesplittingid False to respect the current time splitting method.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function enable($timesplittingid = false) {
|
public function enable($timesplittingid = false) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue