Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
  • (no description)

    File Size: 347 lines (13 kb)
    Included or required:0 times
    Referenced: 0 times
    Includes or requires: 0 files

    Defines 1 class

    Class: base  - X-Ref

    Base class for handling progress information.

    Subclasses should generally override the {@link current_progress} function which
    summarises all progress information.

    start_progress($description, $max = self::INDETERMINATE,$parentcount = 1)   X-Ref
    Marks the start of an operation that will display progress.

    This can be called multiple times for nested progress sections. It must
    be paired with calls to end_progress.

    The progress maximum may be {@link self::INDETERMINATE} if the current operation has
    an unknown number of steps. (This is default.)

    Calling this function will always result in a new display, so this
    should not be called exceedingly frequently.

    When it is complete by calling {@link end_progress()}, each {@link start_progress} section
    automatically adds progress to its parent, as defined by $parentcount.

    param: string $description Description to display
    param: int $max Maximum value of progress for this section
    param: int $parentcount How many progress points this section counts for

    end_progress()   X-Ref
    Marks the end of an operation that will display progress.

    This must be paired with each {@link start_progress} call.

    If there is a parent progress section, its progress will be increased
    automatically to reflect the end of the child section.

    progress($progress = self::INDETERMINATE)   X-Ref
    Indicates that progress has occurred.

    The progress value should indicate the total progress so far, from 0
    to the value supplied for $max (inclusive) in {@link start_progress}.

    You do not need to call this function for every value. It is OK to skip
    values. It is also OK to call this function as often as desired; it
    doesn't update the display if called more than once per second.

    It must be INDETERMINATE if {@link start_progress} was called with $max set to
    INDETERMINATE. Otherwise it must not be indeterminate.

    param: int $progress Progress so far

    increment_progress($incby = 1)   X-Ref
    An alternative to calling progress. This keeps track of the number of items done internally. Call this method
    with no parameters to increment the internal counter by one or you can use the $incby parameter to specify a positive
    change in progress. The internal progress counter should not exceed $max as passed to {@link start_progress} for this

    If you called {@link start_progress} with parameter INDETERMINATE then you cannot call this method.

    get_time()   X-Ref
    Gets time (this is provided so that unit tests can override it).

    return: int Current system time

    is_in_progress_section()   X-Ref

    return: bool True if currently inside a progress section

    get_current_max()   X-Ref
    Checks max value of current progress section.

    return: int Current max value - may be {@link \core\progress\base::INDETERMINATE}.

    get_current_description()   X-Ref

    return: string Current progress section description

    get_progress_proportion_range()   X-Ref
    Obtains current progress in a way suitable for drawing a progress bar.

    Progress is returned as a minimum and maximum value. If there is no
    indeterminate progress, these values will be identical. If there is
    intermediate progress, these values can be different. (For example, if
    the top level progress sections is indeterminate, then the values will
    always be 0.0 and 1.0.)

    return: array Minimum and maximum possible progress proportions

    get_progress_count()   X-Ref
    Obtains current indeterminate progress in a way suitable for adding to
    the progress display.

    This returns the number of indeterminate calls (at any level) during the
    lifetime of this progress reporter, whether or not there is a current
    indeterminate step. (The number will not be ridiculously high because
    progress calls are limited to one per second.)

    return: int Number of indeterminate progress calls