<commit_before><?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/>.

/**
 * tool_generator course backend code.
 *
 * @package tool_generator
 * @copyright 2013 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

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

/**
 * Backend code for the 'make large course' tool.
 *
 * @package tool_generator
 * @copyright 2013 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class tool_generator_course_backend extends tool_generator_backend {
    /**
     * @var array Number of sections in course
     */
    private static $paramsections = array(1, 10, 100, 500, 1000, 2000);
    /**
     * @var array Number of assignments in course
     */
    private static $paramassignments = array(1, 10, 100, 500, 1000, 2000);
    /**
     * @var array Number of Page activities in course
     */
    private static $parampages = array(1, 50, 200, 1000, 5000, 10000);
    /**
     * @var array Number of students enrolled in course
     */
    private static $paramusers = array(1, 100, 1000, 10000, 50000, 100000);
    /**
     * Total size of small files: 1KB, 1MB, 10MB, 100MB, 1GB, 2GB.
     *
     * @var array Number of small files created in a single file activity
     */
    private static $paramsmallfilecount = array(1, 64, 128, 1024, 16384, 32768);
    /**
     * @var array Size of small files (to make the totals into nice numbers)
     */
    private static $paramsmallfilesize = array(1024, 16384, 81920, 102400, 65536, 65536);
    /**
     * Total size of big files: 8KB, 8MB, 80MB, 800MB, 8GB, 16GB.
     *
     * @var array Number of big files created as individual file activities
     */
    private static $parambigfilecount = array(1, 2, 5, 10, 10, 10);
    /**
     * @var array Size of each large file
     */
    private static $parambigfilesize = array(8192, 4194304, 16777216, 83886080,
            858993459, 1717986918);
    /**
     * @var array Number of forum discussions
     */
    private static $paramforumdiscussions = array(1, 10, 100, 500, 1000, 2000);
    /**
     * @var array Number of forum posts per discussion
     */
    private static $paramforumposts = array(2, 2, 5, 10, 10, 10);

    /**
     * @var string Course shortname
     */
    private $shortname;

    /**
     * @var string Course fullname.
     */
    private $fullname = "";

    /**
     * @var string Course summary.
     */
    private $summary = "";

    /**
     * @var string Course summary format, defaults to FORMAT_HTML.
     */
    private $summaryformat = FORMAT_HTML;

    /**
     * @var testing_data_generator Data generator
     */
    protected $generator;

    /**
     * @var stdClass Course object
     */
    private $course;

    /**
     * @var array Array from test user number (1...N) to userid in database
     */
    private $userids;

    /**
     * Constructs object ready to create course.
     *
     * @param string $shortname Course shortname
     * @param int $size Size as numeric index
     * @param bool $fixeddataset To use fixed or random data
     * @param int|bool $filesizelimit The max number of bytes for a generated file
     * @param bool $progress True if progress information should be displayed
     */
    public function __construct(
        $shortname,
        $size,
        $fixeddataset = false,
        $filesizelimit = false,
        $progress = true,
        $fullname = null,
        $summary = null,
        $summaryformat = FORMAT_HTML) {

        // Set parameters.
        $this->shortname = $shortname;
        if (is_null($fullname)) {
            $this->fullname = get_string(
                'fullname',
                'tool_generator',
                array(
                    'size' => get_string('shortsize_' . $size, 'tool_generator')
                )
            );
        } else {
            $this->fullname = $fullname;
        }
        if (!is_null($summary)) {
            $this->summary = $summary;
            $this->summaryformat = $summaryformat;
        }

        parent::__construct($size, $fixeddataset, $filesizelimit, $progress);
    }
<commit_msg>MDL-49224 tooL_generator: fallback to "Test course <x>" when no fullname specified<commit_after><?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/>.

/**
 * tool_generator course backend code.
 *
 * @package tool_generator
 * @copyright 2013 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

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

/**
 * Backend code for the 'make large course' tool.
 *
 * @package tool_generator
 * @copyright 2013 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class tool_generator_course_backend extends tool_generator_backend {
    /**
     * @var array Number of sections in course
     */
    private static $paramsections = array(1, 10, 100, 500, 1000, 2000);
    /**
     * @var array Number of assignments in course
     */
    private static $paramassignments = array(1, 10, 100, 500, 1000, 2000);
    /**
     * @var array Number of Page activities in course
     */
    private static $parampages = array(1, 50, 200, 1000, 5000, 10000);
    /**
     * @var array Number of students enrolled in course
     */
    private static $paramusers = array(1, 100, 1000, 10000, 50000, 100000);
    /**
     * Total size of small files: 1KB, 1MB, 10MB, 100MB, 1GB, 2GB.
     *
     * @var array Number of small files created in a single file activity
     */
    private static $paramsmallfilecount = array(1, 64, 128, 1024, 16384, 32768);
    /**
     * @var array Size of small files (to make the totals into nice numbers)
     */
    private static $paramsmallfilesize = array(1024, 16384, 81920, 102400, 65536, 65536);
    /**
     * Total size of big files: 8KB, 8MB, 80MB, 800MB, 8GB, 16GB.
     *
     * @var array Number of big files created as individual file activities
     */
    private static $parambigfilecount = array(1, 2, 5, 10, 10, 10);
    /**
     * @var array Size of each large file
     */
    private static $parambigfilesize = array(8192, 4194304, 16777216, 83886080,
            858993459, 1717986918);
    /**
     * @var array Number of forum discussions
     */
    private static $paramforumdiscussions = array(1, 10, 100, 500, 1000, 2000);
    /**
     * @var array Number of forum posts per discussion
     */
    private static $paramforumposts = array(2, 2, 5, 10, 10, 10);

    /**
     * @var string Course shortname
     */
    private $shortname;

    /**
     * @var string Course fullname.
     */
    private $fullname = "";

    /**
     * @var string Course summary.
     */
    private $summary = "";

    /**
     * @var string Course summary format, defaults to FORMAT_HTML.
     */
    private $summaryformat = FORMAT_HTML;

    /**
     * @var testing_data_generator Data generator
     */
    protected $generator;

    /**
     * @var stdClass Course object
     */
    private $course;

    /**
     * @var array Array from test user number (1...N) to userid in database
     */
    private $userids;

    /**
     * Constructs object ready to create course.
     *
     * @param string $shortname Course shortname
     * @param int $size Size as numeric index
     * @param bool $fixeddataset To use fixed or random data
     * @param int|bool $filesizelimit The max number of bytes for a generated file
     * @param bool $progress True if progress information should be displayed
     */
    public function __construct(
        $shortname,
        $size,
        $fixeddataset = false,
        $filesizelimit = false,
        $progress = true,
        $fullname = null,
        $summary = null,
        $summaryformat = FORMAT_HTML) {

        // Set parameters.
        $this->shortname = $shortname;

        // We can't allow fullname to be set to an empty string.
        if (empty($fullname)) {
            $this->fullname = get_string(
                'fullname',
                'tool_generator',
                array(
                    'size' => get_string('shortsize_' . $size, 'tool_generator')
                )
            );
        } else {
            $this->fullname = $fullname;
        }

        // Summary, on the other hand, should be empty-able.
        if (!is_null($summary)) {
            $this->summary = $summary;
            $this->summaryformat = $summaryformat;
        }

        parent::__construct($size, $fixeddataset, $filesizelimit, $progress);
    }

{'fraction_non_alphanumeric': 0.10789823234903444, 'fraction_numerical': 0.04935118013691632, 'mean_word_length': 2.331518039482641, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3009937', 'n_tokens_mistral': 3229, 'n_tokens_neox': 2768, 'n_words': 1025}