From bdf7e12c190d5f7f39bb8c65c8d7aee8637d91df Mon Sep 17 00:00:00 2001
From: Ben Fesili <ben.fesili@totara.com>
Date: Wed, 17 May 2023 10:34:22 +1200
Subject: [PATCH] Added error message definitions to lang strings file

---
 classes/view_assets.php | 2 +-
 grade.php               | 2 +-
 lang/en/hvp.php         | 4 ++++
 review.php              | 2 +-
 share.php               | 6 +++---
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/classes/view_assets.php b/classes/view_assets.php
index a96f728..8ce3442 100644
--- a/classes/view_assets.php
+++ b/classes/view_assets.php
@@ -342,7 +342,7 @@ class view_assets {
      */
     public function validatecontent() {
         if ($this->content === null) {
-            print_error('invalidhvp');
+            print_error('invalidhvp', 'mod_hvp');
         }
     }
 
diff --git a/grade.php b/grade.php
index 75781e9..2f640f8 100644
--- a/grade.php
+++ b/grade.php
@@ -53,7 +53,7 @@ $hvp = $DB->get_record_sql(
         array($cm->instance));
 
 if ($hvp === false) {
-    print_error('invalidhvp');
+    print_error('invalidhvp', 'mod_hvp');
 }
 
 // Redirect to report if a specific user is chosen.
diff --git a/lang/en/hvp.php b/lang/en/hvp.php
index 342f93d..8e922bf 100644
--- a/lang/en/hvp.php
+++ b/lang/en/hvp.php
@@ -454,6 +454,10 @@ $string['couldnotreadfilefromzip'] = 'Unable to read file from the package: %fil
 $string['couldnotparsejsonfromzip'] = 'Unable to parse JSON from the package: %fileName';
 $string['couldnotparsepostdata'] = 'Could not parse post data.';
 $string['nombstringexteension'] = 'The mbstring PHP extension is not loaded. H5P needs this to function properly';
+$string['invalidhvp'] = 'Invalid H5P activity';
+$string['nohubregistration'] = 'Not registered with H5P Hub';
+$string['invalidtoken'] = 'H5P has received an invalid token. Refresh the page and try again';
+$string['contentnotshared'] = 'H5P activity cannot be shared. Please check your H5P hub registration';
 
 // Messaging api.
 $string['messageprovider:confirmation'] = 'Confirmation of your own H5P submissions';
diff --git a/review.php b/review.php
index a975830..3f52b5a 100644
--- a/review.php
+++ b/review.php
@@ -53,7 +53,7 @@ $hvp = $DB->get_record_sql(
     [$id]);
 
 if ($hvp === false) {
-    print_error('invalidhvp');
+    print_error('invalidhvp', 'mod_hvp');
 }
 
 // Set page properties.
diff --git a/share.php b/share.php
index 186b378..d52e38b 100644
--- a/share.php
+++ b/share.php
@@ -43,7 +43,7 @@ require_capability('mod/hvp:share', $context);
 // Check if Hub registered, if not redirect to hub registration.
 if (empty(get_config('mod_hvp', 'site_uuid')) || empty(get_config('mod_hvp', 'hub_secret'))) {
     if (!has_capability('mod/hvp:contenthubregistration', \context_system::instance())) {
-        print_error('nohubregistration');
+        print_error('nohubregistration', 'mod_hvp');
     }
     redirect(new moodle_url('/mod/hvp/content_hub_registration.php'));
 }
@@ -60,10 +60,10 @@ if ($action) {
     }
     $token = required_param('_token', PARAM_RAW);
     if (!\H5PCore::validToken('share_' . $id, $token)) {
-        print_error('invalidtoken');
+        print_error('invalidtoken', 'mod_hvp');
     }
     if (empty($content['contentHubId']) || $content['shared'] !== '1') {
-        print_error('contentnotshared');
+        print_error('contentnotshared', 'mod_hvp');
     }
 
     $core = \mod_hvp\framework::instance();
-- 
GitLab