Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 and 403]

tool_generator course backend code.

Copyright: 2013 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 616 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: tool_generator_course_backend  - X-Ref

Backend code for the 'make large course' tool.

__construct($shortname,$size,$fixeddataset = false,$filesizelimit = false,$progress = true,$fullname = null,$summary = null,$summaryformat = FORMAT_HTML,$additionalmodules = [])   X-Ref
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
param: array $additionalmodules potential additional modules to be added (quiz, bigbluebutton...)

get_users_per_size()   X-Ref
Returns the relation between users and course sizes.

return: array

get_size_choices()   X-Ref
Gets a list of size choices supported by this backend.

return: array List of size (int) => text description for display

check_shortname_available($shortname)   X-Ref
Checks that a shortname is available (unused).

param: string $shortname Proposed course shortname
return: string An error message if the name is unavailable or '' if OK

make()   X-Ref
Runs the entire 'make' process.

return: int Course id

create_course()   X-Ref
Creates the actual course.

return: stdClass Course record

create_users()   X-Ref
Creates a number of user accounts and enrols them on the course.
Note: Existing user accounts that were created by this system are
reused if available.


create_user_accounts($first, $last)   X-Ref
Creates user accounts with a numeric range.

param: int $first Number of first user
param: int $last Number of last user

create_assignments()   X-Ref
Creates a number of Assignment activities.


create_pages()   X-Ref
Creates a number of Page activities.


create_small_files()   X-Ref
Creates one resource activity with a lot of small files.


create_big_files()   X-Ref
Creates a number of resource activities with one big file each.


create_forum()   X-Ref
Creates one forum activity with a bunch of posts.


get_target_section()   X-Ref
Gets a section number.

Depends on $this->fixeddataset.

return: int A section number from 1 to the number of sections

get_target_user()   X-Ref
Gets a user id.

Depends on $this->fixeddataset.

return: int A user id for a random created user

limit_filesize($length)   X-Ref
Restricts the binary file size if necessary

param: int $length The total length
return: int The limited length if a limit was specified.