diff --git a/view.php b/view.php index 651cffde28a117fc6c236dffbf70391c3dd9c658..cbc9a46fd4500b9722bcd319656d1d5c1c68fd85 100644 --- a/view.php +++ b/view.php @@ -82,10 +82,15 @@ $export = ''; if (!isset($CFG->mod_hvp_export) || $CFG->mod_hvp_export === true) { // Find course context. $context = \context_course::instance($course->id); - $hvppath = "{$CFG->httpswwwroot}/pluginfile.php/{$context->id}/mod_hvp"; - - $exportfilename = ($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p'; - $export = "{$hvppath}/exports/{$exportfilename}"; + if (has_capability('mod/hvp:getexport', $context)) { + $hvppath = "{$CFG->httpswwwroot}/pluginfile.php/{$context->id}/mod_hvp"; + $exportfilename = ($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p'; + $export = "{$hvppath}/exports/{$exportfilename}"; + } +} +if (empty($export)) { + // Remove Download button when there's no export URL + $content['disable'] |= \H5PCore::DISABLE_DOWNLOAD; } // Add JavaScript settings for this content.