Skip to content
Snippets Groups Projects
Select Git revision
  • a1a2fa818ff108b9924e04ffa0f7d425a951c69b
  • main default protected
  • dev/grabowski
  • origin/main
  • hsh_1.22.4
  • 1.22.4
  • 1.22.3
  • 1.22.2
  • 1.22.1
  • 1.22
  • 1.21
  • 1.20.2
  • 1.20.1
  • 1.20.0
  • 1.19.1
  • 1.19
  • 1.18
  • 1.17.2
  • 1.17.1
  • 1.17
  • 1.16
  • 1.15
  • 1.14
  • 1.13
24 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,