From 5e17f2faeb0a65d6b7e95346f093761468fb0ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Monlla=C3=B3?= Date: Thu, 22 Aug 2019 15:49:41 +0800 Subject: [PATCH] MDL-66091 report_insights: Usability improvements - More feedback provided for the user once they click on useful/notuseful from the email. - Replace the indicator calculations table headers for the table caption and replace the text by just "Indicators" - Replace "System" for the site name for insights generated at system level - Replace "$modelname prediction" for "$modelname" in report/insights/prediction.php heading MDL-66091 --- analytics/classes/insights_generator.php | 3 ++- report/insights/done.php | 17 +++++++++++++++-- report/insights/insights.php | 6 +++++- report/insights/lang/en/report_insights.php | 7 ++----- report/insights/prediction.php | 6 +++++- .../insights/templates/insight_details.mustache | 16 +++++----------- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/analytics/classes/insights_generator.php b/analytics/classes/insights_generator.php index 24fdfaf1d8d..6dad5ebcba9 100644 --- a/analytics/classes/insights_generator.php +++ b/analytics/classes/insights_generator.php @@ -195,7 +195,8 @@ class insights_generator { $actionurl = $action->get_url(); if (!$actionurl->get_param('forwardurl')) { - $actiondoneurl = new \moodle_url('/report/insights/done.php'); + $params = ['actionvisiblename' => $action->get_text(), 'target' => '_blank']; + $actiondoneurl = new \moodle_url('/report/insights/done.php', $params); // Set the forward url to the 'done' script. $actionurl->param('forwardurl', $actiondoneurl->out(false)); } diff --git a/report/insights/done.php b/report/insights/done.php index d64d15120b4..4878ef0092d 100644 --- a/report/insights/done.php +++ b/report/insights/done.php @@ -26,5 +26,18 @@ require_once(__DIR__ . '/../../config.php'); require_login(); -$url = new \moodle_url('/'); -redirect($url, get_string('actionsaved', 'report_insights'), null, \core\output\notification::NOTIFY_SUCCESS); +$actionvisiblename = required_param('actionvisiblename', PARAM_NOTAGS); + +$PAGE->set_pagelayout('popup'); +$PAGE->set_context(\context_system::instance()); +$PAGE->set_title(get_site()->fullname); +$PAGE->set_url(new \moodle_url('/report/insights/done.php')); + +echo $OUTPUT->header(); + +$notification = new \core\output\notification(get_string('actionsaved', 'report_insights', $actionvisiblename), + \core\output\notification::NOTIFY_SUCCESS); +$notification->set_show_closebutton(false); +echo $OUTPUT->render($notification); + +echo $OUTPUT->footer(); diff --git a/report/insights/insights.php b/report/insights/insights.php index c45aaf9e79b..2aaab8b05f3 100644 --- a/report/insights/insights.php +++ b/report/insights/insights.php @@ -103,8 +103,12 @@ if (!$model->uses_insights()) { exit(0); } +if ($context->id == SYSCONTEXTID) { + $PAGE->set_heading(get_site()->shortname); +} else { + $PAGE->set_heading($insightinfo->contextname); +} $PAGE->set_title($insightinfo->insightname); -$PAGE->set_heading($insightinfo->contextname); // Some models generate one single prediction per context. We can directly show the prediction details in this case. if ($model->get_analyser()::one_sample_per_analysable()) { diff --git a/report/insights/lang/en/report_insights.php b/report/insights/lang/en/report_insights.php index e21e8dbf31a..e8aa1d915e7 100644 --- a/report/insights/lang/en/report_insights.php +++ b/report/insights/lang/en/report_insights.php @@ -22,11 +22,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['actionsaved'] = 'Your action has been saved.'; -$string['calculatedvalue'] = 'Calculated value'; +$string['actionsaved'] = 'Your feedback of \'{$a}\' has been saved.'; $string['disabledmodel'] = 'Sorry, this model has been disabled by the administrator'; -$string['indicator'] = 'Indicator'; -$string['insightprediction'] = '{$a} prediction'; +$string['indicators'] = 'Indicators'; $string['insight'] = 'Insight'; $string['insights'] = 'Insights'; $string['justpredictions'] = 'Please note that the following insights are only predictions. It is not possible to predict the future with any certainty. The insights are provided so that action can be taken as necessary to prevent any negative predictions becoming reality.'; @@ -39,7 +37,6 @@ $string['outcomeverypositive'] = 'Very positive outcome'; $string['outcomeverynegative'] = 'Very negative outcome'; $string['pluginname'] = 'Insights'; $string['prediction'] = 'Prediction'; -$string['predictioncalculations'] = 'Indicator calculations'; $string['predictiondetails'] = 'Prediction details'; $string['nodetailsavailable'] = 'No prediction details are relevant.'; $string['timecreated'] = 'Time predicted'; diff --git a/report/insights/prediction.php b/report/insights/prediction.php index bb67a028487..6db5e394bc6 100644 --- a/report/insights/prediction.php +++ b/report/insights/prediction.php @@ -71,8 +71,12 @@ if (!$model->uses_insights()) { exit(0); } +if ($context->id == SYSCONTEXTID) { + $PAGE->set_heading(get_site()->shortname); +} else { + $PAGE->set_heading($insightinfo->contextname); +} $PAGE->set_title($insightinfo->insightname); -$PAGE->set_heading($insightinfo->contextname); echo $OUTPUT->header(); diff --git a/report/insights/templates/insight_details.mustache b/report/insights/templates/insight_details.mustache index ad61ef1b94a..33164dd933e 100644 --- a/report/insights/templates/insight_details.mustache +++ b/report/insights/templates/insight_details.mustache @@ -73,7 +73,7 @@ } }} -

{{#str}}insightprediction, report_insights, {{insightname}} {{/str}}

+

{{insightname}}

{{#showpredicionheading}} - + {{#timerange}} - + {{/timerange}}
@@ -101,29 +101,23 @@ {{#str}}predictiondetails, report_insights{{/str}}
{{#str}}timecreated, report_insights{{/str}}{{#str}}timecreated, report_insights{{/str}} {{timecreated}}
{{#str}}timerange, report_insights{{/str}}{{#str}}timerange, report_insights{{/str}} {{.}}
- - - - - - - + {{#calculations}} - + {{/calculations}}
{{#str}}predictioncalculations, report_insights{{/str}}
{{#str}}indicator, report_insights{{/str}}{{#str}}calculatedvalue, report_insights{{/str}}
{{#str}}indicators, report_insights{{/str}}
{{name}}{{name}} {{#outcomeicon}}{{> core/pix_icon}}{{/outcomeicon}} {{displayvalue}}