MDL-67788 h5p: fix issue for non logged-in users
authorSara Arjona <sara@moodle.com>
Thu, 16 Apr 2020 12:09:25 +0000 (14:09 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 16 Apr 2020 13:50:10 +0000 (15:50 +0200)
h5p/classes/helper.php

index dd12ca6..b561b5e 100644 (file)
@@ -312,6 +312,8 @@ class helper {
         $factory = new factory();
         $core = $factory->get_core();
 
+        // When there is a logged in user, her information will be passed to the player. It will be used for tracking.
+        $usersettings = isloggedin() ? ['name' => $USER->username, 'mail' => $USER->email] : [];
         $settings = array(
             'baseUrl' => $basepath,
             'url' => "{$basepath}pluginfile.php/{$systemcontext->instanceid}/core_h5p",
@@ -321,7 +323,7 @@ class helper {
             'saveFreq' => false,
             'siteUrl' => $CFG->wwwroot,
             'l10n' => array('H5P' => $core->getLocalization()),
-            'user' => ['name' => $USER->username, 'mail' => $USER->email],
+            'user' => $usersettings,
             'hubIsEnabled' => true,
             'reportingIsEnabled' => false,
             'crossorigin' => null,