Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
.
/**
* Generator for the core_contentbank subsystem.
*
* @package core_contentbank
* @category test
* @copyright 2020 Sara Arjona
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_contentbank\content;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
/**
* Generator for the core_contentbank subsystem.
*
* @package core_contentbank
* @copyright 2020 Sara Arjona
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_contentbank_generator extends \component_generator_base {
/**
* Populate contentbank database tables with relevant data to simulate the process of adding items to the content bank.
*
* @param string $contenttype Content bank plugin type to add. If none is defined, contenttype_testable is used.
* @param int $itemstocreate Number of items to add to the content bank.
* @param int $userid The user identifier creating the content.
* @param context $context The context where the content will be created.
* @param bool $convert2class Whether the class should return stdClass or plugin instance.
* @param string $filepath The filepath of the file associated to the content to create.
* @param string $contentname The name of the content that will be created.
* @param int $visibility The visibility of the content that will be created.
* @return array An array with all the records added to the content bank.
*/
public function generate_contentbank_data(?string $contenttype, int $itemstocreate = 1, int $userid = 0,
?\context $context = null, bool $convert2class = true, string $filepath = 'contentfile.h5p',
string $contentname = 'Test content ', int $visibility = content::VISIBILITY_PUBLIC): array {
global $DB, $USER;
$records = [];
$contenttype = $contenttype ?? 'contenttype_testable';
$contenttypeclass = "\\$contenttype\\contenttype";
if (!class_exists($contenttypeclass)) {
// Early return with empty array because the contenttype doesn't exist.
return $records;
}
if (empty($context)) {
$context = \context_system::instance();
}
$type = new $contenttypeclass($context);
$fs = get_file_storage();
for ($i = 0; $i < $itemstocreate; $i++) {
// Create content.
$record = new stdClass();
// If only 1 item is being created, do not add a number suffix to the content name.
$record->name = ($itemstocreate === 1) ? $contentname : $contentname . $i;
$record->configdata = '';
$record->usercreated = $userid ?? $USER->id;
$record->visibility = $visibility;
$content = $type->create_content($record);
$record = $content->get_content();
// Create a dummy file.
$filerecord = array(
'contextid' => $context->id,
'component' => 'contentbank',
'filearea' => 'public',
'itemid' => $record->id,
'filepath' => '/',
'filename' => basename($filepath)
);
if (file_exists($filepath)) {
$fs->create_file_from_pathname($filerecord, $filepath);
} else {
$fs->create_file_from_string($filerecord, 'Dummy content ' . $i);
}
// Prepare the return value.
if ($convert2class) {
$records[$record->id] = $content;
} else {
$records[$record->id] = $record;
}
}
return $records;
}
}