Search moodle.org's
Developer Documentation

See Release Notes

  • 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.

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

Activity completion condition.

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

Defines 1 class


Class: condition  - X-Ref

Activity completion condition.

__construct($structure)   X-Ref
Constructor.

param: \stdClass $structure Data structure from JSON decode

save()   X-Ref
Saves tree data back to a structure object.

return: stdClass Structure object (ready to be made into JSON format)

get_json(int $cmid, int $expectedcompletion)   X-Ref
Returns a JSON object which corresponds to a condition of this type.

Intended for unit testing, as normally the JSON values are constructed
by JavaScript code.

param: int $cmid Course-module id of other activity
param: int $expectedcompletion Expected completion value (COMPLETION_xx)
return: stdClass Object representing condition

is_available($not, info $info, $grabthelot, $userid)   X-Ref
Determines whether a particular item is currently available
according to this availability condition.

param: bool $not Set true if we are inverting the condition
param: info $info Item we're checking
param: bool $grabthelot Performance hint: if true, caches information
param: int $userid User ID to check availability for
return: bool True if available

get_selfids(info $info)   X-Ref
Return current item IDs (cmid and sectionid).

param: info $info
return: int[] with [0] => cmid/null, [1] => sectionid/null

get_cmid(stdClass $course, ?int $selfcmid, ?int $selfsectionid)   X-Ref
Get the cmid referenced in the access restriction.

param: stdClass $course course object
param: int|null $selfcmid current course-module ID or null
param: int|null $selfsectionid current course-section ID or null
return: int|null cmid or null if no referenced cm is found

get_previous_cmid(stdClass $course, ?int $selfcmid, ?int $selfsectionid)   X-Ref
Return the previous CM ID of an specific course-module or course-section.

param: stdClass $course course object
param: int|null $selfcmid course-module ID or null
param: int|null $selfsectionid course-section ID or null
return: int|null

load_course_structure(stdClass $course)   X-Ref
Loads static information about a course elements previous activities.

Populates two variables:
- $this->sectionprevious[] course-module previous to a cmid
- $this->sectionfastprevious[] course-section previous to a cmid

param: stdClass $course course object

get_lang_string_keyword(int $completionstate)   X-Ref
Returns a more readable keyword corresponding to a completion state.

Used to make lang strings easier to read.

param: int $completionstate COMPLETION_xx constant
return: string Readable keyword

get_description($full, $not, info $info)   X-Ref
Obtains a string describing this restriction (whether or not
it actually applies).

param: bool $full Set true if this is the 'full information' view
param: bool $not Set true if we are inverting the condition
param: info $info Item we're checking
return: string Information string (for admin) about all restrictions on

get_debug_string()   X-Ref
Obtains a representation of the options of this condition as a string,
for debugging.

return: string Text representation of parameters

update_after_restore($restoreid, $courseid, \base_logger $logger, $name)   X-Ref
Updates this node after restore, returning true if anything changed.

param: string $restoreid Restore ID
param: int $courseid ID of target course
param: \base_logger $logger Logger for any warnings
param: string $name Name of this item (for use in warning messages)
return: bool True if there was any change

completion_value_used($course, $cmid)   X-Ref
Used in course/lib.php because we need to disable the completion JS if
a completion value affects a conditional activity.

param: \stdClass $course Moodle course object
param: int $cmid Course-module id
return: bool True if this is used in a condition, false otherwise

wipe_static_cache()   X-Ref
Wipes the static cache of modules used in a condition (for unit testing).


update_dependency_id($table, $oldid, $newid)   X-Ref
No description