0

I am trying to modify the message for push notification when a badge is granted to a user from the Moodle admin panel.

What it originally is:

You have been awarded the badge "%badgename%"!

More information about this badge can be found on the %badgelink% badge information page.

You can manage and download the badge from your Manage badges page.

What I have changed it to be:

You have been awarded the badge "%badgename%"!

The notification message I actually received before the modification:

You have been awarded the badge "%badgename%"!

More information about this badge can be found on the %badgelink% badge information page.

You can manage and download the badge from your Manage badges page.

The notification message I actually received after the modification:

You have been awarded the badge "%badgename%"!

You can manage and download the badge from your Manage badges page.

(Somehow, the last sentence survived the modification)

Can anyone let me know what could be the cause and how to remove it? As the notification message does changed, I think it works but the message is changed again before it is sent to the user.

Russell England
  • 9,436
  • 1
  • 27
  • 41
Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36

2 Answers2

0

How did you change the language string?

If you edited the code directly, it was probably because of the cache. You'll need to purge the caches after changing the code.

Ideally language strings should be changed via language customisation rather than in the code

Go to Site administration > Language > Language customisation > [choose language] > Open language pack

Then search for

Component = badges

String id = messagebody

Then enter your custom string in the "Local customisation" box

https://docs.moodle.org/400/en/Language_customisation

The customised strings will be stored in a file in the data root

eg:

$CFG->dataroot/lang/en_local/badges.php

You can create/edit the file directly - but then you will need to purge the caches for the changes to take affect

Click the "Purge all caches" link at the bottom of the page or go direct to yourmoodlesite/admin/purgecaches.php

Russell England
  • 9,436
  • 1
  • 27
  • 41
  • I think it is unlikely to be the cache. The change was made through Home > Site administration > Badges > Manage badges > [Badge Name] under the "Badge Message" panel. And as the message was changed after the modification was applied, it seems the app has fetched the new data from the backend. – Terry Windwalker Aug 18 '22 at 09:37
  • I will check `Site administration > Language > Language customisation > [choose language] > Open language pack` and let you know if things go well later, probably tomorrow. – Terry Windwalker Aug 18 '22 at 09:39
  • Have checked, and it doesn't work. I changed things there and it seems nothing happens. BTW, it is also not the text the system is sending to me when I open it. – Terry Windwalker Aug 22 '22 at 21:03
0

It turns out to be a backend issue.

When the badge request is sent, the message on the admin panel is used (see my question).

When the badge request is approved, the message on the language pack is used (see @RussellEngland answer).

Make sure to change both when you guys are messing around with the badges.

Terry Windwalker
  • 1,343
  • 2
  • 16
  • 36