Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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: 596 lines (20 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)   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

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.