mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 22:50:19 +01:00
MDL-57791 analytics: Predictions deleted context management
This commit is contained in:
parent
9e27e298c3
commit
4a210b0688
@ -74,11 +74,6 @@ class models_list implements \renderable, \templatable {
|
||||
foreach ($predictioncontexts as $contextid => $unused) {
|
||||
// We prepare this to be used as single_select template options.
|
||||
$context = \context::instance_by_id($contextid);
|
||||
if (empty($context)) {
|
||||
// The context may have been deleted.
|
||||
unset($predictioncontexts[$contextid]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Special name for system level predictions as showing "System is not visually nice".
|
||||
if ($contextid == SYSCONTEXTID) {
|
||||
|
@ -370,14 +370,17 @@ class manager {
|
||||
global $DB;
|
||||
|
||||
if (!$predictionobj = $DB->get_record('analytics_predictions', array('id' => $predictionid))) {
|
||||
throw new \moodle_exception('errorpredictionnotfound', 'report_insights');
|
||||
throw new \moodle_exception('errorpredictionnotfound', 'analytics');
|
||||
}
|
||||
|
||||
$context = \context::instance_by_id($predictionobj->contextid, IGNORE_MISSING);
|
||||
if (!$context) {
|
||||
throw new \moodle_exception('errorpredictioncontextnotavailable', 'analytics');
|
||||
}
|
||||
|
||||
if ($requirelogin) {
|
||||
list($context, $course, $cm) = get_context_info_array($predictionobj->contextid);
|
||||
require_login($course, false, $cm);
|
||||
} else {
|
||||
$context = \context::instance_by_id($predictionobj->contextid);
|
||||
}
|
||||
|
||||
self::check_can_list_insights($context);
|
||||
|
@ -986,7 +986,9 @@ class model {
|
||||
public function get_predictions_contexts() {
|
||||
global $DB;
|
||||
|
||||
$sql = "SELECT DISTINCT contextid FROM {analytics_predictions} WHERE modelid = ?";
|
||||
$sql = "SELECT DISTINCT ap.contextid FROM {analytics_predictions} ap
|
||||
JOIN {context} ctx ON ctx.id = ap.contextid
|
||||
WHERE ap.modelid = ?";
|
||||
return $DB->get_records_sql($sql, array($this->model->id));
|
||||
}
|
||||
|
||||
@ -1044,16 +1046,16 @@ class model {
|
||||
\core_analytics\manager::check_can_list_insights($context);
|
||||
|
||||
// Filters out previous predictions keeping only the last time range one.
|
||||
$sql = "SELECT tip.*
|
||||
FROM {analytics_predictions} tip
|
||||
$sql = "SELECT ap.*
|
||||
FROM {analytics_predictions} ap
|
||||
JOIN (
|
||||
SELECT sampleid, max(rangeindex) AS rangeindex
|
||||
FROM {analytics_predictions}
|
||||
WHERE modelid = ? and contextid = ?
|
||||
GROUP BY sampleid
|
||||
) tipsub
|
||||
ON tip.sampleid = tipsub.sampleid AND tip.rangeindex = tipsub.rangeindex
|
||||
WHERE tip.modelid = ? and tip.contextid = ?";
|
||||
) apsub
|
||||
ON ap.sampleid = apsub.sampleid AND ap.rangeindex = apsub.rangeindex
|
||||
WHERE ap.modelid = ? and ap.contextid = ?";
|
||||
$params = array($this->model->id, $context->id, $this->model->id, $context->id);
|
||||
if (!$predictions = $DB->get_records_sql($sql, $params)) {
|
||||
return array();
|
||||
|
@ -42,7 +42,9 @@ $string['errornopredictresults'] = 'No results returned from the predictions pro
|
||||
$string['errornotimesplittings'] = 'This model does not have any time splitting method';
|
||||
$string['errornoroles'] = 'Student or teacher roles have not been defined. Define them in analytics settings page.';
|
||||
$string['errornotarget'] = 'This model does not have any target';
|
||||
$string['errorpredictioncontextnotavailable'] = 'This prediction context is not available anymore';
|
||||
$string['errorpredictionformat'] = 'Wrong prediction calculations format';
|
||||
$string['errorpredictionnotfound'] = 'Prediction not found';
|
||||
$string['errorpredictionsprocessor'] = 'Predictions processor error: {$a}';
|
||||
$string['errorpredictwrongformat'] = 'The predictions processor return can not be decoded: "{$a}"';
|
||||
$string['errorprocessornotready'] = 'The selected predictions processor is not ready: {$a}';
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
|
||||
$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';
|
||||
|
Loading…
x
Reference in New Issue
Block a user