Skip to content
Snippets Groups Projects
Select Git revision
  • e22db2792630d7339722357a8915e6a0d331d4a0
  • main default
  • hsh-MOODLE_404+
  • hsh_3.10
  • master protected
  • v1.4.7
  • v1.4.6
  • v1.4.5
  • v1.4.3
  • v1.4.1
  • v1.4
  • v1.3r2
  • v1.3
  • v1.2
14 results

locallib.php

Blame
  • locallib.php 25.48 KiB
    <?php
    // This file is part of Moodle - http://moodle.org/
    //
    // Moodle is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // (at your option) any later version.
    //
    // Moodle is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // You should have received a copy of the GNU General Public License
    // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
    /**
     * Internal library of functions for module hvp
     *
     * All the hvp specific functions, needed to implement the module
     * logic, should go here. Never include this file from your lib.php!
     *
     * @package    mod_hvp
     * @copyright  2016 Joubel AS <contact@joubel.com>
     * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    
    use core\message\message;
    
    defined('MOODLE_INTERNAL') || die();
    
    require_once('autoloader.php');
    
    /**
     * Get array with settings for hvp core
     *
     * @param \context_course|\context_module [$context]
     * @return array Settings
     */
    function hvp_get_core_settings($context) {
        global $USER, $CFG;
    
        $systemcontext = \context_system::instance();
        $basepath = \mod_hvp\view_assets::getsiteroot() . '/';
    
        // Check permissions and generate ajax paths.
        $ajaxpaths = array();
        $savefreq = false;
        $ajaxpath = "{$basepath}mod/hvp/ajax.php?contextId={$context->instanceid}&token=";
        if ($context->contextlevel == CONTEXT_MODULE && has_capability('mod/hvp:saveresults', $context)) {
            $ajaxpaths['setFinished'] = $ajaxpath . \H5PCore::createToken('result') . '&action=set_finished';
            $ajaxpaths['xAPIResult'] = $ajaxpath . \H5PCore::createToken('xapiresult') . '&action=xapiresult';
        }
        if (has_capability('mod/hvp:savecontentuserdata', $context)) {
            $ajaxpaths['contentUserData'] = $ajaxpath . \H5PCore::createToken('contentuserdata') .
                '&action=contents_user_data&content_id=:contentId&data_type=:dataType&sub_content_id=:subContentId';
    
            if (get_config('mod_hvp', 'enable_save_content_state')) {
                $savefreq = get_config('mod_hvp', 'content_state_frequency');
            }
        }
    
        $core = \mod_hvp\framework::instance('core');
    
        $settings = array(
            'baseUrl' => $basepath,
            'url' => "{$basepath}pluginfile.php/{$context->instanceid}/mod_hvp",
            // NOTE: Separate context from content URL !
            'urlLibraries' => "{$basepath}pluginfile.php/{$systemcontext->id}/mod_hvp/libraries",
            'postUserStatistics' => true,
            'ajax' => $ajaxpaths,