Search moodle.org's
Developer Documentation

See Release Notes

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

(no description)

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

Defines 1 class

show_started_courses_task:: (8 methods):
  get_name()
  execute()
  update_courses_visibility()
  trigger_event()
  get_field_date()
  get_visibility()
  get_trace_message()
  get_event_classname()


Class: show_started_courses_task  - X-Ref

Simple task to automatically set the course visibility to shown when the course start date matches the current day.

get_name()   X-Ref
Get a descriptive name for this task (shown to admins).

return: string

execute()   X-Ref
Update course visibility.
IMPORTANT: It only processes courses with start/end dates within the past 24 hours and with start/end dates higher than
the current one, to avoid updating the course visibility early.

return: void

update_courses_visibility(\moodle_recordset $courses, int $visibility)   X-Ref
Make course visible or hidden if the start date has become due.

param: \moodle_recordset $courses
param: int $visibility The given courses will be set to this visibility
return: void

trigger_event(\stdClass $course)   X-Ref
Method to trigger a course event.

param: \stdClass $course The course that has been updated.

get_field_date()   X-Ref
Get the database field where the date to check is stored (startdate for showing courses and enddate for hiding courses).

return: string

get_visibility()   X-Ref
The expected visibility of the courses after running this task (show = 1 and hidden = 0).

return: int

get_trace_message()   X-Ref
The text to display in the trace message about the action that has been applied to the course.

return: string

get_event_classname()   X-Ref
The event classname to be triggered for the courses that need to be updated.

return: string