mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Merge branch 'MDL-59574-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
commit
02146e0b21
55
admin/tool/analytics/classes/clihelper.php
Normal file
55
admin/tool/analytics/classes/clihelper.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Helper class that contains helper functions for cli scripts.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_analytics;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Helper class that contains helper functions for cli scripts.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class clihelper {
|
||||
|
||||
/**
|
||||
* List all models in the system. To be used from cli scripts.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function list_models() {
|
||||
cli_heading("List of models");
|
||||
echo str_pad(get_string('modelid', 'tool_analytics'), 15, ' ') . ' ' . str_pad(get_string('name'), 50, ' ') .
|
||||
' ' . str_pad(get_string('status'), 15, ' ') . "\n";
|
||||
$models = \core_analytics\manager::get_all_models();
|
||||
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();
|
||||
echo str_pad($modelid, 15, ' ') . ' ' . str_pad($name, 50, ' ') . ' ' . str_pad($isenabled, 15, ' ') . "\n";
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ $help = "Enables the provided model.
|
||||
|
||||
Options:
|
||||
--modelid Model id
|
||||
--list List models
|
||||
--timesplitting Time splitting method full class name
|
||||
-h, --help Print out this help
|
||||
|
||||
@ -42,6 +43,7 @@ Example:
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
'list' => false,
|
||||
'modelid' => false,
|
||||
'timesplitting' => false
|
||||
),
|
||||
@ -55,7 +57,12 @@ if ($options['help']) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['modelid'] === false || $options['timesplitting'] === false) {
|
||||
if ($options['list'] || $options['modelid'] === false) {
|
||||
\tool_analytics\clihelper::list_models();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['timesplitting'] === false) {
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ $help = "Evaluates the provided model.
|
||||
|
||||
Options:
|
||||
--modelid Model id
|
||||
--list List models
|
||||
--non-interactive Not interactive questions
|
||||
--timesplitting Restrict the evaluation to 1 single time splitting method (Optional)
|
||||
--filter Analyser dependant. e.g. A courseid would evaluate the model using a single course (Optional)
|
||||
@ -47,6 +48,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
'modelid' => false,
|
||||
'list' => false,
|
||||
'timesplitting' => false,
|
||||
'reuse-prev-analysed' => true,
|
||||
'non-interactive' => false,
|
||||
@ -62,8 +64,8 @@ if ($options['help']) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['modelid'] === false) {
|
||||
echo $help;
|
||||
if ($options['list'] || $options['modelid'] === false) {
|
||||
\tool_analytics\clihelper::list_models();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ $string['clearmodelpredictions'] = 'Are you sure you want to clear all "{$a}" pr
|
||||
$string['clienablemodel'] = 'You can enable the model by selecting a time-splitting method by its ID. Note that you can also enable it later using the web interface (\'none\' to exit).';
|
||||
$string['clievaluationandpredictions'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. You can allow these processes to be executed manually via the web interface by disabling the <a href="{$a}">\'onlycli\'</a> analytics setting.';
|
||||
$string['clievaluationandpredictionsnoadmin'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. It may be enabled by a site administrator.';
|
||||
$string['disabled'] = 'Disabled';
|
||||
$string['editmodel'] = 'Edit "{$a}" model';
|
||||
$string['edittrainedwarning'] = 'This model has already been trained. Note that changing its indicators or its time-splitting method will delete its previous predictions and start generating new predictions.';
|
||||
$string['enabled'] = 'Enabled';
|
||||
@ -66,6 +67,7 @@ $string['invalidanalysablestable'] = 'Invalid site analysable elements table';
|
||||
$string['invalidprediction'] = 'Invalid to get predictions';
|
||||
$string['invalidtraining'] = 'Invalid to train the model';
|
||||
$string['loginfo'] = 'Log extra info';
|
||||
$string['modelid'] = 'Model id';
|
||||
$string['modelinvalidanalysables'] = 'Invalid analysable elements for "{$a}" model';
|
||||
$string['modelresults'] = '{$a} results';
|
||||
$string['modeltimesplitting'] = 'Time splitting';
|
||||
|
Loading…
x
Reference in New Issue
Block a user