Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
tool_generator_backend Class Reference

Backend generic code for all tool_generator commands. More...

Inheritance diagram for tool_generator_backend:
tool_generator_course_backend tool_generator_site_backend tool_generator_testplan_backend

Public Member Functions

 __construct ($size, $fixeddataset=false, $filesizelimit=false, $progress=true)
 Generic generator class. More...
 

Static Public Member Functions

static size_for_name ($sizename)
 Converts a size name into the numeric constant. More...
 

Public Attributes

int const DEFAULT_SIZE = 3
 Default size index.
 
int const MAX_SIZE = 5
 Highest (largest) size index.
 
int const MIN_SIZE = 0
 Lowest (smallest) size index.
 

Protected Member Functions

 dot ($number, $total)
 Outputs dots. More...
 
 end_log ()
 Ends a log string that was started using log function with $leaveopen.
 
 log ($langstring, $a=null, $leaveopen=false)
 Displays information as part of progress. More...
 

Protected Attributes

int bool $filesizelimit
 Maximum number of bytes for file.
 
bool $fixeddataset
 True if we want a fixed dataset or false to generate random data.
 
int $lastdot
 Epoch time at which last dot was displayed.
 
int $lastpercentage
 Epoch time at which last percentage was displayed.
 
bool $progress
 True if displaying progress.
 
int $size
 Size code (index in the above arrays)
 
int $starttime
 Epoch time at which current step (current set of dots) started.
 

Detailed Description

Backend generic code for all tool_generator commands.

@abstract

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_generator_backend::__construct (   $size,
  $fixeddataset = false,
  $filesizelimit = false,
  $progress = true 
)

Generic generator class.

Parameters
int$sizeSize as numeric index
bool$fixeddatasetTo use fixed or random data
int | bool$filesizelimitThe max number of bytes for a generated file
bool$progressTrue if progress information should be displayed
Exceptions
coding_exceptionIf parameters are invalid

Member Function Documentation

◆ dot()

tool_generator_backend::dot (   $number,
  $total 
)
protected

Outputs dots.

There is up to one dot per second. Once a minute, it displays a percentage.

Parameters
int$numberNumber of completed items
int$totalTotal number of items to complete

◆ log()

tool_generator_backend::log (   $langstring,
  $a = null,
  $leaveopen = false 
)
protected

Displays information as part of progress.

Parameters
string$langstringPart of langstring (after progress_)
mixed$aOptional lang string parameters
bool$leaveopenIf true, doesn't close LI tag (ready for dots)

◆ size_for_name()

static tool_generator_backend::size_for_name (   $sizename)
static

Converts a size name into the numeric constant.

Parameters
string$sizenameSize name e.g. 'L'
Return values
intNumeric version
Exceptions
coding_exceptionIf the size name is not known

The documentation for this class was generated from the following file: