global $PAGE;
$predictionid = $prediction->get_prediction_data()->id;
+ $contextid = $prediction->get_prediction_data()->contextid;
+ $modelid = $prediction->get_prediction_data()->modelid;
- $PAGE->requires->js_call_amd('report_insights/actions', 'init', array($predictionid));
+ $PAGE->requires->js_call_amd('report_insights/actions', 'init', array($predictionid, $contextid, $modelid));
$actions = array();
*
* @module report_insights/actions
*/
-define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {
+define(['jquery', 'core/ajax', 'core/notification', 'core/url'], function($, Ajax, Notification, Url) {
return {
* Attach on click handlers to hide predictions.
*
* @param {Number} predictionId The prediction id.
+ * @param {Number} contextId The context in which the prediction was made.
+ * @param {Number} modelId The model id model with which the prediction was made.
* @access public
*/
- init: function(predictionId) {
+ init: function(predictionId, contextId, modelId) {
// Select the prediction with the provided id ensuring that an external function is set as method name.
$('a[data-prediction-methodname][data-prediction-id=' + predictionId + ']').on('click', function(e) {
// Move back if no remaining predictions.
if ($('.insights-list tr').length < 2) {
- if (document.referrer) {
- window.location.assign(document.referrer);
- } else {
- window.location.reload(true);
- }
+ var params = {
+ contextid: contextId,
+ modelid: modelId
+ };
+
+ var queryparams = $.param(params);
+ window.location.assign(Url.relativeUrl("report/insights/insights.php?" + queryparams));
}
}).fail(Notification.exception);
}