Exemplo n.º 1
0
    $context = \context_course::instance($course->id);
    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;
}
// Find cm context
$context = \context_module::instance($cm->id);
// Add JavaScript settings for this content.
$cid = 'cid-' . $content['id'];
$settings['contents'][$cid] = array('library' => \H5PCore::libraryToString($content['library']), 'jsonContent' => $safeparameters, 'fullScreen' => $content['library']['fullscreen'], 'exportUrl' => $export, 'title' => $content['title'], 'disable' => $content['disable'], 'url' => "{$CFG->httpswwwroot}/mod/hvp/view.php?id={$id}", 'contentUrl' => "{$CFG->httpswwwroot}/pluginfile.php/{$context->id}/mod_hvp/content/" . $content['id'], 'contentUserData' => array(0 => \mod_hvp\content_user_data::load_pre_loaded_user_data($content['id'])));
// Get assets for this content.
$preloadeddependencies = $core->loadContentDependencies($content['id'], 'preloaded');
$files = $core->getDependenciesFiles($preloadeddependencies);
// Determine embed type.
$embedtype = \H5PCore::determineEmbedType($content['embedType'], $content['library']['embedTypes']);
if ($embedtype === 'div') {
    $context = \context_system::instance();
    $hvppath = "/pluginfile.php/{$context->id}/mod_hvp";
    // Schedule JavaScripts for loading through Moodle.
    foreach ($files['scripts'] as $script) {
        $url = $hvppath . $script->path . $script->version;
        $settings['loadedJs'][] = $url;
        $PAGE->requires->js(new moodle_url($CFG->httpswwwroot . $url), true);
    }
    // Schedule stylesheets for loading through Moodle.
Exemplo n.º 2
0
require __DIR__ . '/../../config.php';
require_once "locallib.php";
$action = required_param('action', PARAM_ALPHA);
switch ($action) {
    /*
     * Handle user data reporting
     *
     * Type: HTTP POST
     *
     * Parameters:
     *  - content_id
     *  - data_type
     *  - sub_content_id
     */
    case 'contentsuserdata':
        \mod_hvp\content_user_data::handle_ajax();
        break;
        /*
         * Handle restricting H5P libraries
         *
         * Type: HTTP GET
         *
         * Parameters:
         *  - library_id
         *  - restrict (0 or 1)
         *  - token
         */
    /*
     * Handle restricting H5P libraries
     *
     * Type: HTTP GET