core_completion string

core_completion string

by Optimistic Futures IT -
Number of replies: 2

Hi,
We have changed the coursecompletedmessage string.  Please see the screen the attached image: 


We want to print student name but {$a->firstname} is not working on email. Can anyone guide us how to print username ? Thanks


Average of ratings: -
In reply to Optimistic Futures IT

Re: core_completion string

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Before using an extra variable, you need to add the variable in the completion/completion_completion.php file (line:183)

$a = [
'coursename' => get_course_display_name_for_list($course),
'courselink' => (string) new moodle_url('/course/view.php', array('id' => $course->id)), --];
++'firstname' => \core_user::get_user($data->userid)->firstname];
Average of ratings: Useful (2)
In reply to Optimistic Futures IT

Re: core_completion string

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Each language string can only include placeholders that are specifically passed into it when it is called (otherwise every language string would need to be passed a full range of all possible placeholders that might be wanted in the given context, which would be very complex to program and a massive overhead in terms of site performance).

The only way to add additional data for placeholders would be to modify the core code that uses the 'coursecompletedmessage' language string - something you should consider very carefully before you undertake it (as it adds a maintenance overhead during all future upgrades).

As an aside, all users are encouraged to use their name on these forums, rather than their organisation name. Please could you update your profile?
Average of ratings: Useful (2)