mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-58859 analytics: Fix migration to core bugs and pre-migration issues
Part of MDL-57791 epic.
This commit is contained in:
parent
52c0a11022
commit
6ec2ae0f87
@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_models\local\target;
|
||||
namespace tool_models\analytics\target;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@ -106,12 +106,13 @@ class course_dropout extends \core_analytics\local\target\binary {
|
||||
return get_string('nocoursesections', 'tool_models');
|
||||
}
|
||||
|
||||
// Ongoing courses data can not be used to train.
|
||||
if ($fortraining && !$course->is_finished()) {
|
||||
if ($course->get_end() === 0) {
|
||||
// More specific error.
|
||||
if ($course->get_end() == 0) {
|
||||
// We require time end to be set.
|
||||
return get_string('nocourseendtime', 'tool_models');
|
||||
}
|
||||
|
||||
// Ongoing courses data can not be used to train.
|
||||
if ($fortraining && !$course->is_finished()) {
|
||||
return get_string('coursenotyetfinished', 'tool_models');
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tool_models_install() {
|
||||
|
||||
// TODO All of them for the moment, we will define a limited set of them once in core.
|
||||
$target = \core_analytics\manager::get_target('\tool_models\local\target\course_dropout');
|
||||
$target = \core_analytics\manager::get_target('\tool_models\analytics\target\course_dropout');
|
||||
$indicators = \core_analytics\manager::get_all_indicators();
|
||||
|
||||
// We need the model to be created in order to know all its potential indicators and set them.
|
||||
|
@ -47,7 +47,6 @@ $string['executionresultscli'] = 'Results using {$a->name} (id: {$a->id}) course
|
||||
$string['executionresults'] = 'Results using {$a->name} course duration splitting';
|
||||
$string['extrainfo'] = 'Info';
|
||||
$string['generalerror'] = 'Evaluation error. Status code {$a}';
|
||||
|
||||
$string['goodmodel'] = 'This is a good model and it can be used to predict, enable it and execute it to start getting predictions.';
|
||||
$string['indicators'] = 'Indicators';
|
||||
$string['info'] = 'Info';
|
||||
@ -55,6 +54,7 @@ $string['labelstudentdropoutyes'] = 'Student at risk of dropping out';
|
||||
$string['labelstudentdropoutno'] = 'Not at risk';
|
||||
$string['loginfo'] = 'Log extra info';
|
||||
$string['lowaccuracy'] = 'The model accuracy is low';
|
||||
$string['modelresults'] = '{$a} results';
|
||||
$string['modelslist'] = 'Models list';
|
||||
$string['modeltimesplitting'] = 'Time splitting';
|
||||
$string['nocompletiondetection'] = 'No method available to detect course completion (no completion nor competencies nor course grade pass)';
|
||||
@ -65,16 +65,11 @@ $string['nocoursestudents'] = 'No students';
|
||||
$string['nodatatoevaluate'] = 'There is no data to evaluate the model';
|
||||
$string['nodatatopredict'] = 'There is no data to use for predictions';
|
||||
$string['notdefined'] = 'Not yet defined';
|
||||
$string['prediction'] = 'Prediction';
|
||||
$string['pluginname'] = 'Analytic models';
|
||||
$string['predictionresults'] = 'Prediction results';
|
||||
$string['predictions'] = 'Predictions';
|
||||
$string['predictmodels'] = 'Predict models';
|
||||
$string['predictorresultsin'] = 'Predictor logged information in {$a} directory';
|
||||
$string['predictiondetails'] = 'Prediction details';
|
||||
$string['predictionprocessfinished'] = 'Prediction process finished';
|
||||
|
||||
$string['pluginname'] = 'Analytic models';
|
||||
$string['modelresults'] = '{$a} results';
|
||||
$string['samestartdate'] = 'Current start date is good';
|
||||
$string['sameenddate'] = 'Current end date is good';
|
||||
$string['target'] = 'Target';
|
||||
|
@ -133,7 +133,7 @@ abstract class base extends \core_analytics\calculable {
|
||||
foreach ($users as $user) {
|
||||
|
||||
$message = new \core\message\message();
|
||||
$message->component = 'analytics';
|
||||
$message->component = 'moodle';
|
||||
$message->name = 'insights';
|
||||
|
||||
$message->userfrom = get_admin();
|
||||
|
@ -673,7 +673,7 @@ class model {
|
||||
|
||||
// Filters out previous predictions keeping only the last time range one.
|
||||
$select = "modelid = :modelid AND contextid = :contextid";
|
||||
$params = array($this->model->id, $context->id);
|
||||
$params = array('modelid' => $this->model->id, 'contextid' => $context->id);
|
||||
return $DB->record_exists_select('analytics_predictions', $select, $params);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class prediction_action {
|
||||
|
||||
// We want to track how effective are our suggested actions, we pass users through a script that will log these actions.
|
||||
$params = array('action' => $actionname, 'predictionid' => $prediction->get_prediction_data()->id, 'forwardurl' => $actionurl->out(false));
|
||||
$url = new \moodle_url('/reports/insights/action.php', $params);
|
||||
$url = new \moodle_url('/report/insights/action.php', $params);
|
||||
|
||||
if ($primary === false) {
|
||||
$this->actionlink = new \action_menu_link_secondary($url, $icon, $text);
|
||||
|
@ -97,7 +97,6 @@ $string['indicator:userforumstracking'] = 'User is tracking forums';
|
||||
$string['insightmessagesubject'] = 'New insight for "{$a->contextname}": {$a->insightname}';
|
||||
$string['insightinfo'] = '{$a->insightname} - {$a->contextname}';
|
||||
$string['insightinfomessage'] = 'There are some insights you may find useful. Check out {$a}';
|
||||
$string['insights'] = 'Insights';
|
||||
$string['invalidtimesplitting'] = 'Model with id {$a} needs a time splitting method before it can be used to train';
|
||||
$string['invalidanalysablefortimesplitting'] = 'It can not be analysed using {$a} time splitting method';
|
||||
$string['messageprovider:insights'] = 'Insights generated by prediction models';
|
||||
|
@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
|
||||
$predictionid = required_param('predictionid', PARAM_INT);
|
||||
$actionname = required_param('action', PARAM_ALPHANUMEXT);
|
||||
@ -62,7 +62,7 @@ if (!isset($actions[$actionname])) {
|
||||
throw new \moodle_exception('errorunknownaction', 'report_insights');
|
||||
}
|
||||
|
||||
$modelready = $model->$model->is_enabled() && $model->is_trained() && $model->predictions_exist($context);
|
||||
$modelready = $model->is_enabled() && $model->is_trained() && $model->predictions_exist($context);
|
||||
if (!$modelready && !has_capability('moodle/analytics:managemodels', $context)) {
|
||||
|
||||
$PAGE->set_pagelayout('report');
|
||||
|
@ -71,7 +71,7 @@ class predictions_list implements \renderable, \templatable {
|
||||
|
||||
$data->predictions = array();
|
||||
foreach ($predictions as $prediction) {
|
||||
$predictionrenderable = new \core_analytics\output\prediction($prediction, $this->model);
|
||||
$predictionrenderable = new \report_insights\output\prediction($prediction, $this->model);
|
||||
$data->predictions[] = $predictionrenderable->export_for_template($output);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
$modelid = optional_param('modelid', false, PARAM_INT);
|
||||
@ -75,7 +75,7 @@ $model = new \core_analytics\model($modelid);
|
||||
$insightinfo = new stdClass();
|
||||
$insightinfo->contextname = $context->get_context_name();
|
||||
$insightinfo->insightname = $model->get_target()->get_name();
|
||||
$title = get_string('insightinfo', 'report_insights', $insightinfo);
|
||||
$title = get_string('insightinfo', 'analytics', $insightinfo);
|
||||
|
||||
|
||||
if (!$model->is_enabled() && !has_capability('moodle/analytics:managemodels', $context)) {
|
||||
@ -88,7 +88,7 @@ $PAGE->set_heading($title);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$renderable = new \core_analytics\output\predictions_list($model, $context, $othermodels);
|
||||
$renderable = new \report_insights\output\predictions_list($model, $context, $othermodels);
|
||||
echo $renderer->render($renderable);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -25,5 +25,9 @@
|
||||
|
||||
$string['disabledmodel'] = 'Sorry, this model has been disabled by the administrator';
|
||||
$string['errorpredictionnotfound'] = 'Prediction not found';
|
||||
$string['insights'] = 'Insights';
|
||||
$string['pluginname'] = 'Insights';
|
||||
$string['prediction'] = 'Prediction';
|
||||
$string['predictiondetails'] = 'Prediction details';
|
||||
$string['predictions'] = 'Predictions';
|
||||
$string['selectotherinsights'] = 'Select other insights...';
|
||||
|
@ -37,8 +37,8 @@ function report_insights_extend_navigation_course($navigation, $course, $context
|
||||
if (has_capability('moodle/analytics:listinsights', $context)) {
|
||||
|
||||
$cache = \cache::make('core', 'modelswithpredictions');
|
||||
$models = $cache->get($context->id);
|
||||
if ($models === false) {
|
||||
$modelids = $cache->get($context->id);
|
||||
if ($modelids === false) {
|
||||
// Fill the cache.
|
||||
$models = \core_analytics\manager::get_all_models(true, true, $context);
|
||||
$modelids = array_keys($models);
|
||||
@ -49,10 +49,7 @@ function report_insights_extend_navigation_course($navigation, $course, $context
|
||||
$url = new moodle_url('/report/insights/insights.php', array('contextid' => $context->id));
|
||||
$settingsnode = navigation_node::create(get_string('insights', 'report_insights'), $url, navigation_node::TYPE_SETTING,
|
||||
null, null, new pix_icon('i/settings', ''));
|
||||
$reportnode = $navigation->get('coursereports');
|
||||
if (isset($settingsnode) && !empty($reportnode)) {
|
||||
$reportnode->add_node($settingsnode);
|
||||
}
|
||||
$navigation->add_node($settingsnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
|
||||
$predictionid = required_param('id', PARAM_INT);
|
||||
|
||||
@ -46,7 +46,7 @@ if ($context->contextlevel === CONTEXT_MODULE) {
|
||||
require_capability('moodle/analytics:listinsights', $context);
|
||||
|
||||
$params = array('id' => $predictionobj->id);
|
||||
$url = new \moodle_url('/reports/insights/prediction.php', $params);
|
||||
$url = new \moodle_url('/report/insights/prediction.php', $params);
|
||||
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('report');
|
||||
@ -60,9 +60,9 @@ $prediction = new \core_analytics\prediction($predictionobj, $sampledata);
|
||||
$insightinfo = new stdClass();
|
||||
$insightinfo->contextname = $context->get_context_name();
|
||||
$insightinfo->insightname = $model->get_target()->get_name();
|
||||
$title = get_string('insightinfo', 'report_insights', $insightinfo);
|
||||
$title = get_string('insightinfo', 'analytics', $insightinfo);
|
||||
|
||||
$modelready = $model->$model->is_enabled() && $model->is_trained() && $model->predictions_exist($context);
|
||||
$modelready = $model->is_enabled() && $model->is_trained() && $model->predictions_exist($context);
|
||||
if (!$modelready && !has_capability('moodle/analytics:managemodels', $context)) {
|
||||
echo $renderer->render_model_disabled($insightinfo);
|
||||
exit(0);
|
||||
@ -73,7 +73,7 @@ $PAGE->set_heading($title);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$renderable = new \core_analytics\output\prediction($prediction, $model);
|
||||
$renderable = new \report_insights\output\prediction($prediction, $model);
|
||||
echo $renderer->render($renderable);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -29,10 +29,10 @@
|
||||
* none
|
||||
}}
|
||||
|
||||
<h2>{{#str}}prediction, analytics{{/str}}</h2>
|
||||
<h2>{{#str}}prediction, report_insights{{/str}}</h2>
|
||||
{{> report_insights/prediction}}
|
||||
|
||||
<h3>{{#str}} predictiondetails, analytics {{/str}}</h3>
|
||||
<h3>{{#str}} predictiondetails, report_insights {{/str}}</h3>
|
||||
<div class="container prediction-calculations m-t-2">
|
||||
{{#calculations}}
|
||||
<div class="{{style}}">{{name}} - {{displayvalue}}</div>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
{{/modelselector}}
|
||||
|
||||
<h3>{{#str}} predictions, analytics {{/str}}</h3>
|
||||
<h3>{{#str}} predictions, report_insights {{/str}}</h3>
|
||||
<div class="predictions-list">
|
||||
{{#predictions}}
|
||||
{{> report_insights/prediction}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user