CoursesService
extends Service
in package
Course rules that are not HTTP.
Who may create a course, which key Google site login uses, whether someone is a member, when they last opened a course, and whether that course allows anonymous lesson viewing. Controllers call these and still own routes, redirects, and session switching.
Table of Contents
Constants
- COURSE_CREATE : mixed = 'course.create'
- Permission to create courses.
- GOOGLE_KEY : mixed = 'google.com'
- Consumer key used by Google site login.
Methods
- canCreate() : mixed
- True when the current user may mint a new site-login course.
- contextAllowsAnonymousLessons() : bool
- True when this course row allows anonymous lesson preview.
- courseCreateOffered() : mixed
- The site offers course creation from the instructor home.
- googleKeyId() : mixed
- lti_key.key_id for the Google site-login consumer.
- memberCheck() : true|string
- Login + membership (or site admin) for $context_id without switching session.
- permissions() : array<string, array<string, mixed>>
- Apply to Teach. No other permission.
- setContextAnonymousLessons() : bool
- Turn anonymous lesson preview on or off for one course.
- touchVisited() : mixed
- Record that this user entered a course (flyout recency).
Constants
COURSE_CREATE
Permission to create courses.
public
mixed
COURSE_CREATE
= 'course.create'
GOOGLE_KEY
Consumer key used by Google site login.
public
mixed
GOOGLE_KEY
= 'google.com'
Methods
canCreate()
True when the current user may mint a new site-login course.
public
static canCreate([bool $fresh = false ]) : mixed
Site admins pass. Everyone else needs an active course.create grant. Instructor role in a course does not count. The old create_courses flag is not this check. $fresh reloads the grant cache first. The courses list can use the cache. Creating a course passes true.
Parameters
- $fresh : bool = false
contextAllowsAnonymousLessons()
True when this course row allows anonymous lesson preview.
public
static contextAllowsAnonymousLessons(mixed $context_id) : bool
Parameters
- $context_id : mixed
Return values
boolcourseCreateOffered()
The site offers course creation from the instructor home.
public
static courseCreateOffered() : mixed
$CFG->allow_course_create. Unset or false hides Add Course and Apply to add course. The courses waffle is a separate switch.
googleKeyId()
lti_key.key_id for the Google site-login consumer.
public
static googleKeyId() : mixed
memberCheck()
Login + membership (or site admin) for $context_id without switching session.
public
static memberCheck(mixed $context_id) : true|string
Parameters
- $context_id : mixed
Return values
true|stringpermissions()
Apply to Teach. No other permission.
public
static permissions() : array<string, array<string, mixed>>
Return values
array<string, array<string, mixed>>setContextAnonymousLessons()
Turn anonymous lesson preview on or off for one course.
public
static setContextAnonymousLessons(mixed $context_id, bool $on) : bool
Parameters
- $context_id : mixed
- $on : bool
Return values
booltouchVisited()
Record that this user entered a course (flyout recency).
public
static touchVisited(mixed $context_id) : mixed
Call only from explicit course entry (enter, nested switch, create, catalog enroll). Do not call when restoring the Google home course onto a site URL.
Parameters
- $context_id : mixed