Skip to content

Commit

Permalink
MDL-66536 course: Custom message for students at risk
Browse files Browse the repository at this point in the history
AMOS BEGIN
    MOV [insightinfomessage,analytics],[insightinfomessageplain,analytics]
AMOS END
  • Loading branch information
David Monllaó committed Sep 18, 2019
1 parent 16cb4f3 commit 41db259
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions course/classes/analytics/target/course_enrolments.php
Expand Up @@ -71,6 +71,27 @@ public function get_insight_subject(int $modelid, \context $context) {
return get_string('studentsatriskincourse', 'course', $context->get_context_name(false));
}

/**
* Returns the body message for the insight.
*
* @param \context $context
* @param string $contextname
* @param \stdClass $user
* @param \moodle_url $insighturl
* @return string[] The plain text message and the HTML message
*/
public function get_insight_body(\context $context, string $contextname, \stdClass $user, \moodle_url $insighturl): array {
global $OUTPUT;

$a = (object)['coursename' => $contextname, 'userfirstname' => $user->firstname];
$fullmessage = get_string('studentsatriskinfomessage', 'course', $a) . PHP_EOL . PHP_EOL . $insighturl->out(false);
$fullmessagehtml = $OUTPUT->render_from_template('core_analytics/insight_info_message',
['url' => $insighturl->out(false), 'insightinfomessage' => get_string('studentsatriskinfomessage', 'course', $a)]
);

return [$fullmessage, $fullmessagehtml];
}

/**
* Discards courses that are not yet ready to be used for training or prediction.
*
Expand Down
2 changes: 1 addition & 1 deletion lang/en/analytics.php
Expand Up @@ -68,8 +68,8 @@
$string['eventinsightsviewed'] = 'Insights viewed';
$string['fixedack'] = 'Acknowledged';
$string['insightmessagesubject'] = 'New insight for "{$a}"';
$string['insightinfomessage'] = 'The system generated an insight for you: {$a}';
$string['insightinfomessagehtml'] = 'The system generated an insight for you.';
$string['insightinfomessageplain'] = 'The system generated an insight for you: {$a}';
$string['insightinfomessageaction'] = '{$a->text}: {$a->url}';
$string['invalidtimesplitting'] = 'Model with ID {$a} needs an analysis interval before it can be used for training.';
$string['invalidanalysablefortimesplitting'] = 'It cannot be analysed using {$a} analysis interval.';
Expand Down
3 changes: 3 additions & 0 deletions lang/en/course.php
Expand Up @@ -52,6 +52,9 @@
$string['privacy:metadata:completionsummary'] = 'The course contains completion information about the user.';
$string['privacy:metadata:favouritessummary'] = 'The course contains information relating to the course being starred by the user.';
$string['studentsatriskincourse'] = 'Students at risk in {$a} course';
$string['studentsatriskinfomessage'] = 'Hi {$a->userfirstname},
</br><br/>Students in the {$a->coursename} course have been identified as being at risk.';
$string['target:coursecompletion'] = 'Students at risk of not meeting the course completion conditions';
$string['target:coursecompletion_help'] = 'This target describes whether the student is considered at risk of not meeting the course completion conditions.';
$string['target:coursecompetencies'] = 'Students at risk of not achieving the competencies assigned to a course';
Expand Down

0 comments on commit 41db259

Please sign in to comment.