Documentation

Course extends AbstractBaseApi
in package

Course Class

Represents a course in the Canvas LMS. This class provides methods to create, update, find, and fetch multiple courses from the Canvas LMS system. It utilizes Data Transfer Objects (DTOs) for handling course creation and updates.

Usage:

// Creating a new course
$courseData = [
    'name' => 'Introduction to Philosophy',
    'courseCode' => 'PHIL101',
    // ... other course data ...
];
$course = Course::create($courseData);

// Updating an existing course statically
$updatedData = [
    'name' => 'Advanced Philosophy',
    'courseCode' => 'PHIL201',
    // ... other updated data ...
];
$updatedCourse = Course::update(123, $updatedData); // where 123 is the course ID

// Updating an existing course instance
$course->name = 'Advanced Philosophy';
$course->save();

// Finding a course by ID
$course = Course::find(123);

// Fetching all courses (first page only)
$courses = Course::fetchAll();

// Fetching courses with pagination support
$paginatedResponse = Course::fetchAllPaginated(['per_page' => 10]);
$courses = $paginatedResponse->getJsonData();
$pagination = $paginatedResponse->toPaginationResult($courses);

// Fetching a specific page of courses
$paginationResult = Course::fetchPage(['page' => 2, 'per_page' => 10]);
$courses = $paginationResult->getData();
$hasNext = $paginationResult->hasNext();

// Fetching all courses from all pages
$allCourses = Course::fetchAllPages(['per_page' => 50]);

Table of Contents

Properties

$accessRestrictedByDate  : bool
$accountId  : int
$allowStudentAssignmentEdits  : bool
$allowStudentForumAttachments  : bool
$allowWikiComments  : bool
$applyAssignmentGroupWeights  : bool
$blueprint  : bool
$blueprintRestrictions  : array<string|int, mixed>|null
$blueprintRestrictionsByObjectType  : array<string|int, mixed>|null
$calendar  : array<string|int, mixed>|null
$courseCode  : string
$courseFormat  : string
$courseProgress  : array<string|int, mixed>|null
$createdAt  : string
$defaultView  : string
$endAt  : string|null
$enrollments  : array<string|int, mixed>|null
$enrollmentTermId  : int|null
$gradePassbackSetting  : string|null
$gradingPeriods  : array<string|int, mixed>|null
$gradingStandardId  : int|null
$hideFinalGrades  : bool
$id  : int
The unique identifier for the course
$integrationId  : string|null
$isPublic  : bool
$isPublicToAuthUsers  : bool
$license  : string|null
$locale  : string|null
$name  : string
$needsGradingCount  : int|null
$openEnrollment  : bool
$originalName  : string|null
$permissions  : array<string|int, mixed>|null
$publicDescription  : string|null
$publicSyllabus  : bool
$publicSyllabusToAuth  : bool
$restrictEnrollmentsToCourseDates  : bool
$rootAccountId  : int
$selfEnrollment  : bool
$sisCourseId  : string|null
The SIS identifier for the course, if defined. This field is only included if the user has permission to view SIS information.
$sisImportId  : int|null
The integration identifier for the course, if defined. This field is only included if the user has permission to view SIS information.
$startAt  : string|null
$storageQuotaMb  : int
$storageQuotaUsedMb  : int
$syllabusBody  : string|null
$template  : bool
$term  : array<string|int, mixed>|null
$timeZone  : string
$totalStudents  : int|null
$uuid  : string
The UUID of the course
$workflowState  : string
$apiClient  : HttpClientInterface
$methodAliases  : array<string|int, mixed>
Define method aliases

Methods

__callStatic()  : mixed
Magic method to handle function aliases
__construct()  : mixed
BaseApi constructor.
conclude()  : bool
Conclude the course in the Canvas LMS system
create()  : self
Create a new Course instance
delete()  : bool
Delete the course from the Canvas LMS system
enrollments()  : array<string|int, Enrollment>
Get enrollments for this course (relationship method alias with parameter support)
fetchAll()  : array<string|int, Course>
Fetch all courses
fetchAllPages()  : array<string|int, Course>
Fetch all courses from all pages
fetchAllPaginated()  : PaginatedResponse
Fetch courses with pagination support
fetchPage()  : PaginationResult
Fetch courses from a specific page
find()  : self
Find a course by ID
getAccountId()  : int
getActiveEnrollments()  : array<string|int, Enrollment>
Get active enrollments for this course
getBlueprintRestrictions()  : array<string|int, mixed>|null
getBlueprintRestrictionsByObjectType()  : array<string|int, mixed>|null
getCalendar()  : array<string|int, mixed>|null
getCourseCode()  : string
getCourseFormat()  : string
getCourseProgress()  : array<string|int, mixed>|null
getCreatedAt()  : string
getDefaultView()  : string
getDesignerEnrollments()  : array<string|int, Enrollment>
Get designer enrollments for this course
getEndAt()  : string|null
getEnrollments()  : array<string|int, mixed>|null
getEnrollmentsAsObjects()  : array<string|int, Enrollment>
Get all enrollments for this course as Enrollment objects
getEnrollmentsData()  : array<string|int, mixed>|null
Get the course's enrollment data array (legacy method - uses embedded data)
getEnrollmentTermId()  : int|null
getGradePassbackSetting()  : string|null
getGradingPeriods()  : array<string|int, mixed>|null
getGradingStandardId()  : int|null
getId()  : int
getIntegrationId()  : string|null
getLicense()  : string|null
getLocale()  : string|null
getName()  : string
getNeedsGradingCount()  : int|null
getObserverEnrollments()  : array<string|int, Enrollment>
Get observer enrollments for this course
getOriginalName()  : string|null
getPermissions()  : array<string|int, mixed>|null
getPublicDescription()  : string|null
getRootAccountId()  : int
getSisCourseId()  : string|null
getSisImportId()  : int|null
getStartAt()  : string|null
getStorageQuotaMb()  : int
getStorageQuotaUsedMb()  : int
getStudentCount()  : int
Get the count of student enrollments in this course
getStudentEnrollments()  : array<string|int, Enrollment>
Get student enrollments for this course
getSyllabusBody()  : string|null
getTaEnrollments()  : array<string|int, Enrollment>
Get TA enrollments for this course
getTeacherCount()  : int
Get the count of teacher enrollments in this course
getTeacherEnrollments()  : array<string|int, Enrollment>
Get teacher enrollments for this course
getTerm()  : array<string|int, mixed>|null
getTimeZone()  : string
getTotalEnrollmentCount()  : int
Get the count of total enrollments in this course
getTotalStudents()  : int|null
getUuid()  : string
getWorkflowState()  : string
hasStudentEnrolled()  : bool
Check if a specific user is a student in this course
hasTeacherEnrolled()  : bool
Check if a specific user is a teacher in this course
hasUserEnrolled()  : bool
Check if a specific user is enrolled in this course
isAccessRestrictedByDate()  : bool
isAllowStudentAssignmentEdits()  : bool
isAllowStudentForumAttachments()  : bool
isAllowWikiComments()  : bool
isApplyAssignmentGroupWeights()  : bool
isBlueprint()  : bool
isHideFinalGrades()  : bool
isOpenEnrollment()  : bool
isPublic()  : bool
isPublicSyllabus()  : bool
isPublicSyllabusToAuth()  : bool
isPublicToAuthUsers()  : bool
isRestrictEnrollmentsToCourseDates()  : bool
isSelfEnrollment()  : bool
isTemplate()  : bool
reset()  : self
Deletes the current course, and creates a new equivalent course with no content, but all sections and users moved over
save()  : bool
Save the course to the Canvas LMS system
setAccessRestrictedByDate()  : void
setAccountId()  : void
setAllowStudentAssignmentEdits()  : void
setAllowStudentForumAttachments()  : void
setAllowWikiComments()  : void
setApiClient()  : void
Set the API client
setApplyAssignmentGroupWeights()  : void
setBlueprint()  : void
setBlueprintRestrictions()  : void
setBlueprintRestrictionsByObjectType()  : void
setCalendar()  : void
setCourseCode()  : void
setCourseFormat()  : void
setCourseProgress()  : void
setCreatedAt()  : void
setDefaultView()  : void
setEndAt()  : void
setEnrollments()  : void
setEnrollmentTermId()  : void
setGradePassbackSetting()  : void
setGradingPeriods()  : void
setGradingStandardId()  : void
setHideFinalGrades()  : void
setId()  : void
setIntegrationId()  : void
setIsPublic()  : void
setIsPublicToAuthUsers()  : void
setLicense()  : void
setLocale()  : void
setName()  : void
setNeedsGradingCount()  : void
setOpenEnrollment()  : void
setOriginalName()  : void
setPermissions()  : void
setPublicDescription()  : void
setPublicSyllabus()  : void
setPublicSyllabusToAuth()  : void
setRestrictEnrollmentsToCourseDates()  : void
setRootAccountId()  : void
setSelfEnrollment()  : void
setSisCourseId()  : void
setSisImportId()  : void
setStartAt()  : void
setStorageQuotaMb()  : void
setStorageQuotaUsedMb()  : void
setSyllabusBody()  : void
setTemplate()  : void
setTerm()  : void
setTimeZone()  : void
setTotalStudents()  : void
setUuid()  : void
setWorkflowState()  : void
update()  : self
Update an existing course
castValue()  : DateTime|mixed
Cast a value to the correct type
checkApiClient()  : void
Check if the API client is set, if not, instantiate a new one
convertPaginatedResponseToModels()  : array<string|int, static>
Helper method to convert paginated response data to model instances
createPaginationResult()  : PaginationResult
Helper method to create PaginationResult from paginated response
fetchAllPagesAsModels()  : array<string|int, static>
Helper method to fetch all pages and convert to model instances
getPaginatedResponse()  : PaginatedResponse
Helper method to get paginated response from API endpoint
populate()  : void
Populate the object with new data
toDtoArray()  : array<string|int, mixed>
Convert the object to an array
createFromDTO()  : self
Create a new Course instance from a CreateCourseDTO
updateFromDTO()  : self
Update an existing course from a UpdateCourseDTO

Properties

$accessRestrictedByDate

public bool $accessRestrictedByDate = false

$accountId

public int $accountId

$allowStudentAssignmentEdits

public bool $allowStudentAssignmentEdits = false

$allowStudentForumAttachments

public bool $allowStudentForumAttachments = false

$allowWikiComments

public bool $allowWikiComments = false

$applyAssignmentGroupWeights

public bool $applyAssignmentGroupWeights = false

$blueprint

public bool $blueprint = false

$blueprintRestrictions

public array<string|int, mixed>|null $blueprintRestrictions = []

$blueprintRestrictionsByObjectType

public array<string|int, mixed>|null $blueprintRestrictionsByObjectType = []

$calendar

public array<string|int, mixed>|null $calendar = []

$courseCode

public string $courseCode

$courseFormat

public string $courseFormat = ''

$courseProgress

public array<string|int, mixed>|null $courseProgress = []

$createdAt

public string $createdAt = ''

$defaultView

public string $defaultView = ''

$endAt

public string|null $endAt = null

$enrollments

public array<string|int, mixed>|null $enrollments = []

$enrollmentTermId

public int|null $enrollmentTermId = null

$gradePassbackSetting

public string|null $gradePassbackSetting = null

$gradingPeriods

public array<string|int, mixed>|null $gradingPeriods = []

$gradingStandardId

public int|null $gradingStandardId = null

$hideFinalGrades

public bool $hideFinalGrades = false

$id

The unique identifier for the course

public int $id

$integrationId

public string|null $integrationId = null

$isPublic

public bool $isPublic = false

$isPublicToAuthUsers

public bool $isPublicToAuthUsers = false

$license

public string|null $license = ''

$locale

public string|null $locale = null

$needsGradingCount

public int|null $needsGradingCount = null

$openEnrollment

public bool $openEnrollment = false

$originalName

public string|null $originalName = null

$permissions

public array<string|int, mixed>|null $permissions = []

$publicDescription

public string|null $publicDescription = null

$publicSyllabus

public bool $publicSyllabus = false

$publicSyllabusToAuth

public bool $publicSyllabusToAuth = false

$restrictEnrollmentsToCourseDates

public bool $restrictEnrollmentsToCourseDates = false

$rootAccountId

public int $rootAccountId

$selfEnrollment

public bool $selfEnrollment = false

$sisCourseId

The SIS identifier for the course, if defined. This field is only included if the user has permission to view SIS information.

public string|null $sisCourseId = null

$sisImportId

The integration identifier for the course, if defined. This field is only included if the user has permission to view SIS information.

public int|null $sisImportId = null

$startAt

public string|null $startAt = null

$storageQuotaMb

public int $storageQuotaMb = 0

$storageQuotaUsedMb

public int $storageQuotaUsedMb = 0

$syllabusBody

public string|null $syllabusBody = null

$template

public bool $template = false

$term

public array<string|int, mixed>|null $term = []

$timeZone

public string $timeZone = ''

$totalStudents

public int|null $totalStudents = null

$uuid

The UUID of the course

public string $uuid

$workflowState

public string $workflowState

$methodAliases

Define method aliases

protected static array<string|int, mixed> $methodAliases = ['fetchAll' => ['all', 'get', 'getAll'], 'find' => ['one', 'getOne'], 'fetchAllPaginated' => ['allPaginated', 'getPaginated'], 'fetchAllPages' => ['allPages', 'getPages'], 'fetchPage' => ['page', 'getPage']]

Methods

__callStatic()

Magic method to handle function aliases

public static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string
$arguments : array<string|int, mixed>

__construct()

BaseApi constructor.

public __construct(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

conclude()

Conclude the course in the Canvas LMS system

public conclude() : bool
Return values
bool

create()

Create a new Course instance

public static create(CreateCourseDTO|array<string|int, mixed> $courseData) : self
Parameters
$courseData : CreateCourseDTO|array<string|int, mixed>
Tags
throws
Exception
Return values
self

delete()

Delete the course from the Canvas LMS system

public delete() : bool
Return values
bool

enrollments()

Get enrollments for this course (relationship method alias with parameter support)

public enrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

This method provides a clean, explicit way to access course enrollments without conflicts with Canvas API data structure. Supports all Canvas API enrollment parameters for filtering.

Parameters
$params : array<string|int, mixed> = []

Query parameters for filtering enrollments:

  • type[]: Filter by enrollment type (e.g., ['StudentEnrollment', 'TeacherEnrollment'])
  • role[]: Filter by enrollment role
  • state[]: Filter by enrollment state (e.g., ['active', 'invited'])
  • user_id: Filter by specific user ID
  • include[]: Include additional data (e.g., ['user', 'avatar_url'])
Tags
example
$course = Course::find(123);

// Get all enrollments
$enrollments = $course->enrollments();

// Get active student enrollments
$activeStudents = $course->enrollments([
    'type[]' => ['StudentEnrollment'],
    'state[]' => ['active']
]);

// Get enrollments with user data included
$enrollmentsWithUsers = $course->enrollments([
    'include[]' => ['user']
]);
throws
CanvasApiException

If the course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of Enrollment objects

fetchAll()

Fetch all courses

public static fetchAll([array<string|int, mixed> $params = [] ]) : array<string|int, Course>
Parameters
$params : array<string|int, mixed> = []
Tags
throws
CanvasApiException
Return values
array<string|int, Course>

fetchAllPages()

Fetch all courses from all pages

public static fetchAllPages([array<string|int, mixed> $params = [] ]) : array<string|int, Course>
Parameters
$params : array<string|int, mixed> = []

Query parameters for the request

Tags
throws
CanvasApiException
Return values
array<string|int, Course>

fetchAllPaginated()

Fetch courses with pagination support

public static fetchAllPaginated([array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
$params : array<string|int, mixed> = []

Query parameters for the request

Tags
throws
CanvasApiException
Return values
PaginatedResponse

find()

Find a course by ID

public static find(int $id) : self
Parameters
$id : int
Tags
throws
CanvasApiException
Return values
self

getAccountId()

public getAccountId() : int
Return values
int

getActiveEnrollments()

Get active enrollments for this course

public getActiveEnrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

Convenience method to get only active enrollments in the current course.

Parameters
$params : array<string|int, mixed> = []

Additional query parameters

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of active Enrollment objects

getBlueprintRestrictions()

public getBlueprintRestrictions() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getBlueprintRestrictionsByObjectType()

public getBlueprintRestrictionsByObjectType() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getCalendar()

public getCalendar() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getCourseCode()

public getCourseCode() : string
Return values
string

getCourseFormat()

public getCourseFormat() : string
Return values
string

getCourseProgress()

public getCourseProgress() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getCreatedAt()

public getCreatedAt() : string
Return values
string

getDefaultView()

public getDefaultView() : string
Return values
string

getDesignerEnrollments()

Get designer enrollments for this course

public getDesignerEnrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

Convenience method to get only designer enrollments in the current course.

Parameters
$params : array<string|int, mixed> = []

Additional query parameters

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of designer Enrollment objects

getEndAt()

public getEndAt() : string|null
Return values
string|null

getEnrollments()

public getEnrollments() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getEnrollmentsAsObjects()

Get all enrollments for this course as Enrollment objects

public getEnrollmentsAsObjects([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

This method fetches all enrollments in the current course. Use the $params array to filter enrollments by type, state, or other Canvas API parameters.

Parameters
$params : array<string|int, mixed> = []

Query parameters for filtering enrollments (e.g., ['type[]' => ['StudentEnrollment']]

Tags
throws
CanvasApiException

If the course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of Enrollment objects

getEnrollmentsData()

Get the course's enrollment data array (legacy method - uses embedded data)

public getEnrollmentsData() : array<string|int, mixed>|null

This returns the raw enrollments array that may be embedded in the course object from certain Canvas API calls. For fetching current enrollments from the API, use getEnrollmentsAsObjects() instead.

Return values
array<string|int, mixed>|null

Raw enrollments data array or null

getEnrollmentTermId()

public getEnrollmentTermId() : int|null
Return values
int|null

getGradePassbackSetting()

public getGradePassbackSetting() : string|null
Return values
string|null

getGradingPeriods()

public getGradingPeriods() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getGradingStandardId()

public getGradingStandardId() : int|null
Return values
int|null

getId()

public getId() : int
Return values
int

getIntegrationId()

public getIntegrationId() : string|null
Return values
string|null

getLicense()

public getLicense() : string|null
Return values
string|null

getLocale()

public getLocale() : string|null
Return values
string|null

getName()

public getName() : string
Return values
string

getNeedsGradingCount()

public getNeedsGradingCount() : int|null
Return values
int|null

getObserverEnrollments()

Get observer enrollments for this course

public getObserverEnrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

Convenience method to get only observer enrollments in the current course.

Parameters
$params : array<string|int, mixed> = []

Additional query parameters

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of observer Enrollment objects

getOriginalName()

public getOriginalName() : string|null
Return values
string|null

getPermissions()

public getPermissions() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getPublicDescription()

public getPublicDescription() : string|null
Return values
string|null

getRootAccountId()

public getRootAccountId() : int
Return values
int

getSisCourseId()

public getSisCourseId() : string|null
Return values
string|null

getSisImportId()

public getSisImportId() : int|null
Return values
int|null

getStartAt()

public getStartAt() : string|null
Return values
string|null

getStorageQuotaMb()

public getStorageQuotaMb() : int
Return values
int

getStorageQuotaUsedMb()

public getStorageQuotaUsedMb() : int
Return values
int

getStudentCount()

Get the count of student enrollments in this course

public getStudentCount() : int
Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
int

Number of student enrollments

getStudentEnrollments()

Get student enrollments for this course

public getStudentEnrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

Convenience method to get only student enrollments in the current course.

Parameters
$params : array<string|int, mixed> = []

Additional query parameters

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of student Enrollment objects

getSyllabusBody()

public getSyllabusBody() : string|null
Return values
string|null

getTaEnrollments()

Get TA enrollments for this course

public getTaEnrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

Convenience method to get only TA enrollments in the current course.

Parameters
$params : array<string|int, mixed> = []

Additional query parameters

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of TA Enrollment objects

getTeacherCount()

Get the count of teacher enrollments in this course

public getTeacherCount() : int
Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
int

Number of teacher enrollments

getTeacherEnrollments()

Get teacher enrollments for this course

public getTeacherEnrollments([array<string|int, mixed> $params = [] ]) : array<string|int, Enrollment>

Convenience method to get only teacher enrollments in the current course.

Parameters
$params : array<string|int, mixed> = []

Additional query parameters

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
array<string|int, Enrollment>

Array of teacher Enrollment objects

getTerm()

public getTerm() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getTimeZone()

public getTimeZone() : string
Return values
string

getTotalEnrollmentCount()

Get the count of total enrollments in this course

public getTotalEnrollmentCount([array<string|int, mixed> $params = [] ]) : int
Parameters
$params : array<string|int, mixed> = []

Optional parameters to filter the count

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
int

Total number of enrollments (with optional filters)

getTotalStudents()

public getTotalStudents() : int|null
Return values
int|null

getUuid()

public getUuid() : string
Return values
string

getWorkflowState()

public getWorkflowState() : string
Return values
string

hasStudentEnrolled()

Check if a specific user is a student in this course

public hasStudentEnrolled(int $userId) : bool
Parameters
$userId : int

The user ID to check

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
bool

True if user has a student enrollment in the course

hasTeacherEnrolled()

Check if a specific user is a teacher in this course

public hasTeacherEnrolled(int $userId) : bool
Parameters
$userId : int

The user ID to check

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
bool

True if user has a teacher enrollment in the course

hasUserEnrolled()

Check if a specific user is enrolled in this course

public hasUserEnrolled(int $userId[, string|null $enrollmentType = null ]) : bool
Parameters
$userId : int

The user ID to check enrollment for

$enrollmentType : string|null = null

Optional: specific enrollment type to check for

Tags
throws
CanvasApiException

If course ID is not set or API request fails

Return values
bool

True if user is enrolled in the course (with optional type filter)

isAccessRestrictedByDate()

public isAccessRestrictedByDate() : bool
Return values
bool

isAllowStudentAssignmentEdits()

public isAllowStudentAssignmentEdits() : bool
Return values
bool

isAllowStudentForumAttachments()

public isAllowStudentForumAttachments() : bool
Return values
bool

isAllowWikiComments()

public isAllowWikiComments() : bool
Return values
bool

isApplyAssignmentGroupWeights()

public isApplyAssignmentGroupWeights() : bool
Return values
bool

isBlueprint()

public isBlueprint() : bool
Return values
bool

isHideFinalGrades()

public isHideFinalGrades() : bool
Return values
bool

isOpenEnrollment()

public isOpenEnrollment() : bool
Return values
bool

isPublic()

public isPublic() : bool
Return values
bool

isPublicSyllabus()

public isPublicSyllabus() : bool
Return values
bool

isPublicSyllabusToAuth()

public isPublicSyllabusToAuth() : bool
Return values
bool

isPublicToAuthUsers()

public isPublicToAuthUsers() : bool
Return values
bool

isRestrictEnrollmentsToCourseDates()

public isRestrictEnrollmentsToCourseDates() : bool
Return values
bool

isSelfEnrollment()

public isSelfEnrollment() : bool
Return values
bool

isTemplate()

public isTemplate() : bool
Return values
bool

reset()

Deletes the current course, and creates a new equivalent course with no content, but all sections and users moved over

public reset() : self
Tags
throws
CanvasApiException
throws
Exception
Return values
self

save()

Save the course to the Canvas LMS system

public save() : bool
Tags
throws
Exception
Return values
bool

setAccessRestrictedByDate()

public setAccessRestrictedByDate(bool $accessRestrictedByDate) : void
Parameters
$accessRestrictedByDate : bool

setAccountId()

public setAccountId(int $accountId) : void
Parameters
$accountId : int

setAllowStudentAssignmentEdits()

public setAllowStudentAssignmentEdits(bool $allowStudentAssignmentEdits) : void
Parameters
$allowStudentAssignmentEdits : bool

setAllowStudentForumAttachments()

public setAllowStudentForumAttachments(bool $allowStudentForumAttachments) : void
Parameters
$allowStudentForumAttachments : bool

setAllowWikiComments()

public setAllowWikiComments(bool $allowWikiComments) : void
Parameters
$allowWikiComments : bool

setApplyAssignmentGroupWeights()

public setApplyAssignmentGroupWeights(bool $applyAssignmentGroupWeights) : void
Parameters
$applyAssignmentGroupWeights : bool

setBlueprint()

public setBlueprint(bool $blueprint) : void
Parameters
$blueprint : bool

setBlueprintRestrictions()

public setBlueprintRestrictions(array<string|int, mixed>|null $blueprintRestrictions) : void
Parameters
$blueprintRestrictions : array<string|int, mixed>|null

setBlueprintRestrictionsByObjectType()

public setBlueprintRestrictionsByObjectType(array<string|int, mixed>|null $blueprintRestrictionsByObjectType) : void
Parameters
$blueprintRestrictionsByObjectType : array<string|int, mixed>|null

setCalendar()

public setCalendar(array<string|int, mixed>|null $calendar) : void
Parameters
$calendar : array<string|int, mixed>|null

setCourseCode()

public setCourseCode(string $courseCode) : void
Parameters
$courseCode : string

setCourseFormat()

public setCourseFormat(string $courseFormat) : void
Parameters
$courseFormat : string

setCourseProgress()

public setCourseProgress(array<string|int, mixed>|null $courseProgress) : void
Parameters
$courseProgress : array<string|int, mixed>|null

setCreatedAt()

public setCreatedAt(string $createdAt) : void
Parameters
$createdAt : string

setDefaultView()

public setDefaultView(string $defaultView) : void
Parameters
$defaultView : string

setEndAt()

public setEndAt(string|null $endAt) : void
Parameters
$endAt : string|null

setEnrollments()

public setEnrollments(array<string|int, mixed>|null $enrollments) : void
Parameters
$enrollments : array<string|int, mixed>|null

setEnrollmentTermId()

public setEnrollmentTermId(int|null $enrollmentTermId) : void
Parameters
$enrollmentTermId : int|null

setGradePassbackSetting()

public setGradePassbackSetting(string|null $gradePassbackSetting) : void
Parameters
$gradePassbackSetting : string|null

setGradingPeriods()

public setGradingPeriods(array<string|int, mixed>|null $gradingPeriods) : void
Parameters
$gradingPeriods : array<string|int, mixed>|null

setGradingStandardId()

public setGradingStandardId(int|null $gradingStandardId) : void
Parameters
$gradingStandardId : int|null

setHideFinalGrades()

public setHideFinalGrades(bool $hideFinalGrades) : void
Parameters
$hideFinalGrades : bool

setId()

public setId(int $id) : void
Parameters
$id : int

setIntegrationId()

public setIntegrationId(string|null $integrationId) : void
Parameters
$integrationId : string|null

setIsPublic()

public setIsPublic(bool $isPublic) : void
Parameters
$isPublic : bool

setIsPublicToAuthUsers()

public setIsPublicToAuthUsers(bool $isPublicToAuthUsers) : void
Parameters
$isPublicToAuthUsers : bool

setLicense()

public setLicense(string|null $license) : void
Parameters
$license : string|null

setLocale()

public setLocale(string|null $locale) : void
Parameters
$locale : string|null

setName()

public setName(string $name) : void
Parameters
$name : string

setNeedsGradingCount()

public setNeedsGradingCount(int|null $needsGradingCount) : void
Parameters
$needsGradingCount : int|null

setOpenEnrollment()

public setOpenEnrollment(bool $openEnrollment) : void
Parameters
$openEnrollment : bool

setOriginalName()

public setOriginalName(string|null $originalName) : void
Parameters
$originalName : string|null

setPermissions()

public setPermissions(array<string|int, mixed>|null $permissions) : void
Parameters
$permissions : array<string|int, mixed>|null

setPublicDescription()

public setPublicDescription(string|null $publicDescription) : void
Parameters
$publicDescription : string|null

setPublicSyllabus()

public setPublicSyllabus(bool $publicSyllabus) : void
Parameters
$publicSyllabus : bool

setPublicSyllabusToAuth()

public setPublicSyllabusToAuth(bool $publicSyllabusToAuth) : void
Parameters
$publicSyllabusToAuth : bool

setRestrictEnrollmentsToCourseDates()

public setRestrictEnrollmentsToCourseDates(bool $restrictEnrollmentsToCourseDates) : void
Parameters
$restrictEnrollmentsToCourseDates : bool

setRootAccountId()

public setRootAccountId(int $rootAccountId) : void
Parameters
$rootAccountId : int

setSelfEnrollment()

public setSelfEnrollment(bool $selfEnrollment) : void
Parameters
$selfEnrollment : bool

setSisCourseId()

public setSisCourseId(string|null $sisCourseId) : void
Parameters
$sisCourseId : string|null

setSisImportId()

public setSisImportId(int|null $sisImportId) : void
Parameters
$sisImportId : int|null

setStartAt()

public setStartAt(string|null $startAt) : void
Parameters
$startAt : string|null

setStorageQuotaMb()

public setStorageQuotaMb(int $storageQuotaMb) : void
Parameters
$storageQuotaMb : int

setStorageQuotaUsedMb()

public setStorageQuotaUsedMb(int $storageQuotaUsedMb) : void
Parameters
$storageQuotaUsedMb : int

setSyllabusBody()

public setSyllabusBody(string|null $syllabusBody) : void
Parameters
$syllabusBody : string|null

setTemplate()

public setTemplate(bool $template) : void
Parameters
$template : bool

setTerm()

public setTerm(array<string|int, mixed>|null $term) : void
Parameters
$term : array<string|int, mixed>|null

setTimeZone()

public setTimeZone(string $timeZone) : void
Parameters
$timeZone : string

setTotalStudents()

public setTotalStudents(int|null $totalStudents) : void
Parameters
$totalStudents : int|null

setUuid()

public setUuid(string $uuid) : void
Parameters
$uuid : string

setWorkflowState()

public setWorkflowState(string $workflowState) : void
Parameters
$workflowState : string

castValue()

Cast a value to the correct type

protected castValue(string $key, mixed $value) : DateTime|mixed
Parameters
$key : string
$value : mixed
Tags
throws
Exception
Return values
DateTime|mixed

checkApiClient()

Check if the API client is set, if not, instantiate a new one

protected static checkApiClient() : void

convertPaginatedResponseToModels()

Helper method to convert paginated response data to model instances

protected static convertPaginatedResponseToModels(PaginatedResponse $paginatedResponse) : array<string|int, static>
Parameters
$paginatedResponse : PaginatedResponse
Return values
array<string|int, static>

fetchAllPagesAsModels()

Helper method to fetch all pages and convert to model instances

protected static fetchAllPagesAsModels(string $endpoint[, array<string|int, mixed> $params = [] ]) : array<string|int, static>
Parameters
$endpoint : string

The API endpoint path

$params : array<string|int, mixed> = []

Query parameters for the request

Return values
array<string|int, static>

getPaginatedResponse()

Helper method to get paginated response from API endpoint

protected static getPaginatedResponse(string $endpoint[, array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
$endpoint : string

The API endpoint path

$params : array<string|int, mixed> = []

Query parameters for the request

Return values
PaginatedResponse

populate()

Populate the object with new data

protected populate(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Tags
throws
Exception

toDtoArray()

Convert the object to an array

protected toDtoArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results