Documentation

Announcement extends DiscussionTopic

Canvas LMS Announcements API

Provides functionality to manage announcements in Canvas LMS. Announcements are special discussion topics that serve as one-way broadcasts from instructors to students. This class extends DiscussionTopic and automatically applies announcement-specific filters and defaults.

Usage Examples:

// Set course context (required for all operations)
$course = Course::find(123);
Announcement::setCourse($course);

// Create a new announcement
$announcementData = [
    'title' => 'Important: Exam Schedule Update',
    'message' => 'The midterm exam has been rescheduled to next Friday',
    'published' => true,
    'delayed_post_at' => '2024-03-01T09:00:00Z'  // Schedule for future
];
$announcement = Announcement::create($announcementData);

// Find an announcement by ID
$announcement = Announcement::find(456);

// List all announcements for the course
$announcements = Announcement::get();

// Get only active announcements
$activeAnnouncements = Announcement::get(['active_only' => true]);

// Get paginated announcements
$paginatedAnnouncements = Announcement::paginate();

// Update an announcement
$updatedAnnouncement = Announcement::update(456, ['title' => 'Updated: Exam Schedule']);

// Lock/unlock an announcement to prevent/allow modifications
$announcement->lock();
$announcement->unlock();

// Delete an announcement
$announcement = Announcement::find(456);
$announcement->delete();

// Get global announcements across multiple courses
$contextCodes = ['course_123', 'course_456'];
$globalAnnouncements = Announcement::fetchGlobalAnnouncements($contextCodes);

Table of Contents

Properties

$allowRating  : bool|null
Whether the discussion allows rating
$assignmentId  : int|null
Assignment ID for graded discussions
$attachments  : array<string|int, mixed>|null
Array of file attachments
$author  : array<string, mixed>|null
Discussion topic author information
$contextCode  : string|null
Context code for global announcements (populated when using fetchGlobalAnnouncements)
$courseId  : int|null
Course ID this discussion topic belongs to
$createdAt  : string|null
Discussion topic creation timestamp
$delayedPostAt  : string|null
When the topic will be automatically published
$discussionSubentryCount  : int|null
Number of replies in the topic
$discussionType  : string|null
Discussion type (threaded, side_comment, etc.)
$expand  : bool|null
Whether threaded replies should be expanded by default
$expandLocked  : bool|null
Whether users can choose their preferred thread expansion setting
$gradingType  : string|null
Grading type for graded discussions
$groupCategoryId  : int|null
Group category ID for group discussions
$groupTopic  : bool|null
Whether the discussion is for a group
$groupTopicChildren  : array<string|int, mixed>|null
Group-specific child topics
$htmlUrl  : string|null
HTML URL to the discussion topic
$id  : int|null
Discussion topic unique identifier
$isAnnouncement  : bool|null
Whether this is an announcement
$lastReplyAt  : string|null
When the last reply was posted
$locked  : bool|null
Whether the discussion is locked
$lockedForUser  : bool|null
Whether the topic is locked for the current user
$lockExplanation  : string|null
Explanation of why the topic is locked
$lockInfo  : array<string, mixed>|null
Information about why the topic is locked
$message  : string|null
Discussion topic message/description (HTML)
$onlyGradersCanRate  : bool|null
Whether rating is only for graders
$permissions  : array<string, mixed>|null
User permissions for the topic
$pinned  : bool|null
Whether the discussion is pinned
$podcastUrl  : string|null
URL for podcast feed
$pointsPossible  : float|null
Points possible for graded discussions
$postedAt  : string|null
When the discussion topic was posted
$published  : bool|null
Whether the discussion topic is published
$readOnly  : bool|null
Whether the discussion is read only
$readState  : string|null
Read state for the current user (read, unread, partially_read)
$requireInitialPost  : bool|null
Whether users must post before seeing replies
$rootTopicId  : int|null
ID of the root topic (for group discussions)
$sortByRating  : bool|null
Whether to sort entries by rating
$sortOrder  : string|null
Default sort order of the discussion (asc or desc)
$sortOrderLocked  : bool|null
Whether users can choose their preferred sort order
$subscribed  : bool|null
Whether the current user is subscribed to notifications
$subscriptionHold  : string|null
Subscription hold status
$title  : string|null
Discussion topic title
$topicChildren  : array<string|int, mixed>|null
Child topics (for threaded discussions)
$unreadCount  : int|null
Number of unread entries for the current user
$updatedAt  : string|null
Discussion topic last update timestamp
$userCanSeePosts  : bool|null
Whether users can see posts (based on require_initial_post)
$userId  : int|null
User ID of the discussion author
$userName  : string|null
Name of the topic author
$workflowState  : string|null
Discussion workflow state
$apiClient  : HttpClientInterface
$course  : Course|null
$methodAliases  : array<string|int, mixed>
Define method aliases

Methods

__callStatic()  : mixed
Magic method to handle function aliases
__construct()  : mixed
Create a new DiscussionTopic instance
all()  : array<int, self>
Get all announcements from all pages
assignment()  : Assignment|null
Get the assignment associated with this discussion (if graded)
author()  : User|null
Get the author of this discussion topic
checkCourse()  : bool
Check if course context is set
course()  : Course|null
Get the course this discussion topic belongs to
create()  : self
Create a new announcement Overrides parent to ensure announcement flag is set
delete()  : self
Delete the discussion topic
fetchGlobalAnnouncements()  : array<string|int, Announcement>
Fetch global announcements across multiple courses Uses the /api/v1/announcements endpoint for cross-course announcements
find()  : self
Find a single discussion topic by ID
get()  : array<string|int, Announcement>
Fetch all announcements for the course Overrides parent to automatically filter for announcements only
getAllowRating()  : bool|null
Get allow rating status
getAssignmentId()  : int|null
Get assignment ID
getAttachments()  : array<string|int, mixed>|null
Get attachments
getAuthor()  : array<string, mixed>|null
Get author information
getContextCode()  : string|null
Get context code (for global announcements)
getCourseId()  : int|null
Get course ID
getCreatedAt()  : string|null
Get created at timestamp
getDelayedPostAt()  : string|null
Get delayed post at timestamp
getDiscussionSubentryCount()  : int|null
Get discussion subentry count
getDiscussionType()  : string|null
Get discussion type
getExpand()  : bool|null
Get expand status
getExpandLocked()  : bool|null
Get expand locked status
getGradingType()  : string|null
Get grading type
getGroupCategoryId()  : int|null
Get group category ID
getGroupTopic()  : bool|null
Get group topic status
getGroupTopicChildren()  : array<string|int, mixed>|null
Get group topic children
getHtmlUrl()  : string|null
Get HTML URL
getId()  : int|null
Get discussion topic ID
getIsAnnouncement()  : bool|null
Get is announcement status
getLastReplyAt()  : string|null
Get last reply at timestamp
getLocked()  : bool|null
Get locked status
getLockedForUser()  : bool|null
Get locked for user status
getLockExplanation()  : string|null
Get lock explanation
getLockInfo()  : array<string, mixed>|null
Get lock info
getMessage()  : string|null
Get discussion topic message
getOnlyGradersCanRate()  : bool|null
Get only graders can rate status
getPermissions()  : array<string, mixed>|null
Get permissions
getPinned()  : bool|null
Get pinned status
getPodcastUrl()  : string|null
Get podcast URL
getPointsPossible()  : float|null
Get points possible
getPostedAt()  : string|null
Get posted at timestamp
getPublished()  : bool|null
Get published status
getReadOnly()  : bool|null
Get read only status
getReadState()  : string|null
Get read state
getRequireInitialPost()  : bool|null
Get require initial post status
getRootTopicId()  : int|null
Get root topic ID
getSortByRating()  : bool|null
Get sort by rating status
getSortOrder()  : string|null
Get sort order
getSortOrderLocked()  : bool|null
Get sort order locked status
getSubscribed()  : bool|null
Get subscribed status
getSubscriptionHold()  : string|null
Get subscription hold status
getTitle()  : string|null
Get discussion topic title
getTopicChildren()  : array<string|int, mixed>|null
Get topic children
getUnreadCount()  : int|null
Get unread count
getUpdatedAt()  : string|null
Get updated at timestamp
getUserCanSeePosts()  : bool|null
Get user can see posts status
getUserId()  : int|null
Get user ID
getUserName()  : string|null
Get user name
getWorkflowState()  : string|null
Get workflow state
lock()  : bool
Lock the discussion topic
markAllAsRead()  : bool
Mark all discussion topics in course as read
markAllAsUnread()  : bool
Mark all discussion topics in course as unread
markAsRead()  : bool
Mark discussion topic as read
markAsUnread()  : bool
Mark discussion topic as unread
paginate()  : PaginationResult
Get paginated announcements
pin()  : bool
Pin the discussion topic
postImmediately()  : self
Post an announcement immediately (remove delayed posting)
save()  : static
Save the current announcement (create or update) Overrides parent to ensure announcement-specific validation
scheduleFor()  : self
Schedule an announcement to be posted at a future date
setAllowRating()  : void
Set allow rating status
setApiClient()  : void
Set the API client
setAssignmentId()  : void
Set assignment ID
setAttachments()  : void
Set attachments
setAuthor()  : void
Set author information
setContextCode()  : void
Set context code (for global announcements)
setCourse()  : void
Set the course context for discussion topic operations
setCourseId()  : void
Set course ID
setCreatedAt()  : void
Set created at timestamp
setDelayedPostAt()  : void
Set delayed post at timestamp
setDiscussionSubentryCount()  : void
Set discussion subentry count
setDiscussionType()  : void
Set discussion type
setExpand()  : void
Set expand status
setExpandLocked()  : void
Set expand locked status
setGradingType()  : void
Set grading type
setGroupCategoryId()  : void
Set group category ID
setGroupTopic()  : void
Set group topic status
setGroupTopicChildren()  : void
Set group topic children
setHtmlUrl()  : void
Set HTML URL
setId()  : void
Set discussion topic ID
setIsAnnouncement()  : void
Set is announcement status
setLastReplyAt()  : void
Set last reply at timestamp
setLocked()  : void
Set locked status
setLockedForUser()  : void
Set locked for user status
setLockExplanation()  : void
Set lock explanation
setLockInfo()  : void
Set lock info
setMessage()  : void
Set discussion topic message
setOnlyGradersCanRate()  : void
Set only graders can rate status
setPermissions()  : void
Set permissions
setPinned()  : void
Set pinned status
setPodcastUrl()  : void
Set podcast URL
setPointsPossible()  : void
Set points possible
setPostedAt()  : void
Set posted at timestamp
setPublished()  : void
Set published status
setReadOnly()  : void
Set read only status
setReadState()  : void
Set read state
setRequireInitialPost()  : void
Set require initial post status
setRootTopicId()  : void
Set root topic ID
setSortByRating()  : void
Set sort by rating status
setSortOrder()  : void
Set sort order
setSortOrderLocked()  : void
Set sort order locked status
setSubscribed()  : void
Set subscribed status
setSubscriptionHold()  : void
Set subscription hold status
setTitle()  : void
Set discussion topic title
setTopicChildren()  : void
Set topic children
setUnreadCount()  : void
Set unread count
setUpdatedAt()  : void
Set updated at timestamp
setUserCanSeePosts()  : void
Set user can see posts status
setUserId()  : void
Set user ID
setUserName()  : void
Set user name
setWorkflowState()  : void
Set workflow state
subscribe()  : bool
Subscribe to discussion topic notifications
toArray()  : array<string, mixed>
Convert discussion topic to array
toDtoArray()  : array<string, mixed>
Convert discussion topic to DTO array format
unlock()  : bool
Unlock the discussion topic
unpin()  : bool
Unpin the discussion topic
unsubscribe()  : bool
Unsubscribe from discussion topic notifications
update()  : self
Update an announcement Overrides parent to use announcement-specific DTO
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
createConfiguredHttpClient()  : HttpClient
Create an HttpClient with configured middleware
createPaginationResult()  : PaginationResult
Helper method to create PaginationResult from paginated response
getEndpoint()  : string
Get the API endpoint for this resource
getPaginatedResponse()  : PaginatedResponse
Helper method to get paginated response from API endpoint
populate()  : void
Populate the object with new data

Properties

$allowRating

Whether the discussion allows rating

public bool|null $allowRating = null

$assignmentId

Assignment ID for graded discussions

public int|null $assignmentId = null

$attachments

Array of file attachments

public array<string|int, mixed>|null $attachments = null

$author

Discussion topic author information

public array<string, mixed>|null $author = null

$contextCode

Context code for global announcements (populated when using fetchGlobalAnnouncements)

public string|null $contextCode = null

$courseId

Course ID this discussion topic belongs to

public int|null $courseId = null

$createdAt

Discussion topic creation timestamp

public string|null $createdAt = null

$delayedPostAt

When the topic will be automatically published

public string|null $delayedPostAt = null

$discussionSubentryCount

Number of replies in the topic

public int|null $discussionSubentryCount = null

$discussionType

Discussion type (threaded, side_comment, etc.)

public string|null $discussionType = null

$expand

Whether threaded replies should be expanded by default

public bool|null $expand = null

$expandLocked

Whether users can choose their preferred thread expansion setting

public bool|null $expandLocked = null

$gradingType

Grading type for graded discussions

public string|null $gradingType = null

$groupCategoryId

Group category ID for group discussions

public int|null $groupCategoryId = null

$groupTopic

Whether the discussion is for a group

public bool|null $groupTopic = null

$groupTopicChildren

Group-specific child topics

public array<string|int, mixed>|null $groupTopicChildren = null

$htmlUrl

HTML URL to the discussion topic

public string|null $htmlUrl = null

$isAnnouncement

Whether this is an announcement

public bool|null $isAnnouncement = null

$lastReplyAt

When the last reply was posted

public string|null $lastReplyAt = null

$locked

Whether the discussion is locked

public bool|null $locked = null

$lockedForUser

Whether the topic is locked for the current user

public bool|null $lockedForUser = null

$lockExplanation

Explanation of why the topic is locked

public string|null $lockExplanation = null

$lockInfo

Information about why the topic is locked

public array<string, mixed>|null $lockInfo = null

$message

Discussion topic message/description (HTML)

public string|null $message = null

$onlyGradersCanRate

Whether rating is only for graders

public bool|null $onlyGradersCanRate = null

$permissions

User permissions for the topic

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

$pinned

Whether the discussion is pinned

public bool|null $pinned = null

$podcastUrl

URL for podcast feed

public string|null $podcastUrl = null

$pointsPossible

Points possible for graded discussions

public float|null $pointsPossible = null

$postedAt

When the discussion topic was posted

public string|null $postedAt = null

$published

Whether the discussion topic is published

public bool|null $published = null

$readOnly

Whether the discussion is read only

public bool|null $readOnly = null

$readState

Read state for the current user (read, unread, partially_read)

public string|null $readState = null

$requireInitialPost

Whether users must post before seeing replies

public bool|null $requireInitialPost = null

$rootTopicId

ID of the root topic (for group discussions)

public int|null $rootTopicId = null

$sortByRating

Whether to sort entries by rating

public bool|null $sortByRating = null

$sortOrder

Default sort order of the discussion (asc or desc)

public string|null $sortOrder = null

$sortOrderLocked

Whether users can choose their preferred sort order

public bool|null $sortOrderLocked = null

$subscribed

Whether the current user is subscribed to notifications

public bool|null $subscribed = null

$subscriptionHold

Subscription hold status

public string|null $subscriptionHold = null

$topicChildren

Child topics (for threaded discussions)

public array<string|int, mixed>|null $topicChildren = null

$unreadCount

Number of unread entries for the current user

public int|null $unreadCount = null

$updatedAt

Discussion topic last update timestamp

public string|null $updatedAt = null

$userCanSeePosts

Whether users can see posts (based on require_initial_post)

public bool|null $userCanSeePosts = null

$userId

User ID of the discussion author

public int|null $userId = null

$userName

Name of the topic author

public string|null $userName = null

$workflowState

Discussion workflow state

public string|null $workflowState = null

$methodAliases

Define method aliases

protected static array<string|int, mixed> $methodAliases = ['get' => ['fetch', 'list', 'fetchAll'], 'all' => ['fetchAllPages', 'getAll'], 'paginate' => ['getPaginated', 'withPagination', 'fetchPage'], 'find' => ['one', 'getOne']]

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>
Tags
throws
InvalidArgumentException

__construct()

Create a new DiscussionTopic instance

public __construct([array<string, mixed> $data = [] ]) : mixed
Parameters
$data : array<string, mixed> = []

Discussion topic data from Canvas API

all()

Get all announcements from all pages

public static all([array<string, mixed> $params = [] ]) : array<int, self>
Parameters
$params : array<string, mixed> = []

Query parameters

Tags
throws
CanvasApiException
Return values
array<int, self>

assignment()

Get the assignment associated with this discussion (if graded)

public assignment() : Assignment|null
Tags
example
$course = Course::find(123);
DiscussionTopic::setCourse($course);

$topic = DiscussionTopic::find(456);
$assignment = $topic->assignment();

if ($assignment) {
    echo "This is a graded discussion\n";
    echo "Points possible: {$assignment->pointsPossible}\n";
    echo "Due date: {$assignment->dueAt}\n";
} else {
    echo "This is an ungraded discussion\n";
}
throws
CanvasApiException
Return values
Assignment|null

author()

Get the author of this discussion topic

public author() : User|null
Tags
example
$course = Course::find(123);
DiscussionTopic::setCourse($course);

$topic = DiscussionTopic::find(456);
$author = $topic->author();

if ($author) {
    echo "Posted by: {$author->name}\n";
    echo "Email: {$author->email}\n";
}
throws
CanvasApiException
Return values
User|null

fetchGlobalAnnouncements()

Fetch global announcements across multiple courses Uses the /api/v1/announcements endpoint for cross-course announcements

public static fetchGlobalAnnouncements(array<string|int, string> $contextCodes[, array<string, mixed> $params = [] ]) : array<string|int, Announcement>
Parameters
$contextCodes : array<string|int, string>

Array of context codes (e.g., ['course_123', 'course_456'])

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

Optional parameters (start_date, end_date, active_only, latest_only, include)

Tags
example
// Get announcements for multiple courses
$contextCodes = ['course_123', 'course_456'];
$announcements = Announcement::fetchGlobalAnnouncements($contextCodes);

// With date range
$announcements = Announcement::fetchGlobalAnnouncements(
    ['course_123', 'course_456'],
    [
        'start_date' => '2024-01-01',
        'end_date' => '2024-12-31',
        'active_only' => true
    ]
);
throws
CanvasApiException
Return values
array<string|int, Announcement>

Array of Announcement objects with context_code added

find()

Find a single discussion topic by ID

public static find(int $id[, array<string, mixed> $params = [] ]) : self
Parameters
$id : int

Discussion topic ID

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

Optional query parameters

Tags
throws
CanvasApiException
Return values
self

get()

Fetch all announcements for the course Overrides parent to automatically filter for announcements only

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

Optional parameters

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

Array of Announcement objects

getAllowRating()

Get allow rating status

public getAllowRating() : bool|null
Return values
bool|null

getAssignmentId()

Get assignment ID

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

getAttachments()

Get attachments

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

getAuthor()

Get author information

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

getContextCode()

Get context code (for global announcements)

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

getCourseId()

Get course ID

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

getCreatedAt()

Get created at timestamp

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

getDelayedPostAt()

Get delayed post at timestamp

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

getDiscussionSubentryCount()

Get discussion subentry count

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

getDiscussionType()

Get discussion type

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

getExpand()

Get expand status

public getExpand() : bool|null
Return values
bool|null

getExpandLocked()

Get expand locked status

public getExpandLocked() : bool|null
Return values
bool|null

getGradingType()

Get grading type

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

getGroupCategoryId()

Get group category ID

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

getGroupTopic()

Get group topic status

public getGroupTopic() : bool|null
Return values
bool|null

getGroupTopicChildren()

Get group topic children

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

getHtmlUrl()

Get HTML URL

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

getId()

Get discussion topic ID

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

getIsAnnouncement()

Get is announcement status

public getIsAnnouncement() : bool|null
Return values
bool|null

getLastReplyAt()

Get last reply at timestamp

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

getLocked()

Get locked status

public getLocked() : bool|null
Return values
bool|null

getLockedForUser()

Get locked for user status

public getLockedForUser() : bool|null
Return values
bool|null

getLockExplanation()

Get lock explanation

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

getLockInfo()

Get lock info

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

getMessage()

Get discussion topic message

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

getOnlyGradersCanRate()

Get only graders can rate status

public getOnlyGradersCanRate() : bool|null
Return values
bool|null

getPermissions()

Get permissions

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

getPinned()

Get pinned status

public getPinned() : bool|null
Return values
bool|null

getPodcastUrl()

Get podcast URL

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

getPointsPossible()

Get points possible

public getPointsPossible() : float|null
Return values
float|null

getPostedAt()

Get posted at timestamp

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

getPublished()

Get published status

public getPublished() : bool|null
Return values
bool|null

getReadOnly()

Get read only status

public getReadOnly() : bool|null
Return values
bool|null

getReadState()

Get read state

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

getRequireInitialPost()

Get require initial post status

public getRequireInitialPost() : bool|null
Return values
bool|null

getRootTopicId()

Get root topic ID

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

getSortByRating()

Get sort by rating status

public getSortByRating() : bool|null
Return values
bool|null

getSortOrder()

Get sort order

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

getSortOrderLocked()

Get sort order locked status

public getSortOrderLocked() : bool|null
Return values
bool|null

getSubscribed()

Get subscribed status

public getSubscribed() : bool|null
Return values
bool|null

getSubscriptionHold()

Get subscription hold status

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

getTitle()

Get discussion topic title

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

getTopicChildren()

Get topic children

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

getUnreadCount()

Get unread count

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

getUpdatedAt()

Get updated at timestamp

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

getUserCanSeePosts()

Get user can see posts status

public getUserCanSeePosts() : bool|null
Return values
bool|null

getUserId()

Get user ID

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

getUserName()

Get user name

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

getWorkflowState()

Get workflow state

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

markAllAsRead()

Mark all discussion topics in course as read

public static markAllAsRead() : bool
Tags
throws
CanvasApiException
Return values
bool

True if marking all as read was successful, false otherwise

markAllAsUnread()

Mark all discussion topics in course as unread

public static markAllAsUnread() : bool
Tags
throws
CanvasApiException
Return values
bool

True if marking all as unread was successful, false otherwise

markAsRead()

Mark discussion topic as read

public markAsRead() : bool
Tags
throws
CanvasApiException
Return values
bool

True if marking as read was successful, false otherwise

markAsUnread()

Mark discussion topic as unread

public markAsUnread() : bool
Tags
throws
CanvasApiException
Return values
bool

True if marking as unread was successful, false otherwise

postImmediately()

Post an announcement immediately (remove delayed posting)

public postImmediately() : self
Tags
throws
CanvasApiException
Return values
self

save()

Save the current announcement (create or update) Overrides parent to ensure announcement-specific validation

public save() : static
Tags
throws
CanvasApiException
Return values
static

scheduleFor()

Schedule an announcement to be posted at a future date

public scheduleFor(string $datetime) : self
Parameters
$datetime : string

ISO 8601 formatted datetime (e.g., '2024-03-15T10:00:00Z')

Tags
throws
CanvasApiException
Return values
self

setAllowRating()

Set allow rating status

public setAllowRating(bool|null $allowRating) : void
Parameters
$allowRating : bool|null

setAssignmentId()

Set assignment ID

public setAssignmentId(int|null $assignmentId) : void
Parameters
$assignmentId : int|null

setAttachments()

Set attachments

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

setAuthor()

Set author information

public setAuthor(array<string, mixed>|null $author) : void
Parameters
$author : array<string, mixed>|null

setContextCode()

Set context code (for global announcements)

public setContextCode(string|null $contextCode) : void
Parameters
$contextCode : string|null

setCourse()

Set the course context for discussion topic operations

public static setCourse(Course $course) : void
Parameters
$course : Course

The course to operate on

setCourseId()

Set course ID

public setCourseId(int|null $courseId) : void
Parameters
$courseId : int|null

setCreatedAt()

Set created at timestamp

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

setDelayedPostAt()

Set delayed post at timestamp

public setDelayedPostAt(string|null $delayedPostAt) : void
Parameters
$delayedPostAt : string|null

setDiscussionSubentryCount()

Set discussion subentry count

public setDiscussionSubentryCount(int|null $discussionSubentryCount) : void
Parameters
$discussionSubentryCount : int|null

setDiscussionType()

Set discussion type

public setDiscussionType(string|null $discussionType) : void
Parameters
$discussionType : string|null

setExpand()

Set expand status

public setExpand(bool|null $expand) : void
Parameters
$expand : bool|null

setExpandLocked()

Set expand locked status

public setExpandLocked(bool|null $expandLocked) : void
Parameters
$expandLocked : bool|null

setGradingType()

Set grading type

public setGradingType(string|null $gradingType) : void
Parameters
$gradingType : string|null

setGroupCategoryId()

Set group category ID

public setGroupCategoryId(int|null $groupCategoryId) : void
Parameters
$groupCategoryId : int|null

setGroupTopic()

Set group topic status

public setGroupTopic(bool|null $groupTopic) : void
Parameters
$groupTopic : bool|null

setGroupTopicChildren()

Set group topic children

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

setHtmlUrl()

Set HTML URL

public setHtmlUrl(string|null $htmlUrl) : void
Parameters
$htmlUrl : string|null

setId()

Set discussion topic ID

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

setIsAnnouncement()

Set is announcement status

public setIsAnnouncement(bool|null $isAnnouncement) : void
Parameters
$isAnnouncement : bool|null

setLastReplyAt()

Set last reply at timestamp

public setLastReplyAt(string|null $lastReplyAt) : void
Parameters
$lastReplyAt : string|null

setLocked()

Set locked status

public setLocked(bool|null $locked) : void
Parameters
$locked : bool|null

setLockedForUser()

Set locked for user status

public setLockedForUser(bool|null $lockedForUser) : void
Parameters
$lockedForUser : bool|null

setLockExplanation()

Set lock explanation

public setLockExplanation(string|null $lockExplanation) : void
Parameters
$lockExplanation : string|null

setLockInfo()

Set lock info

public setLockInfo(array<string, mixed>|null $lockInfo) : void
Parameters
$lockInfo : array<string, mixed>|null

setMessage()

Set discussion topic message

public setMessage(string|null $message) : void
Parameters
$message : string|null

setOnlyGradersCanRate()

Set only graders can rate status

public setOnlyGradersCanRate(bool|null $onlyGradersCanRate) : void
Parameters
$onlyGradersCanRate : bool|null

setPermissions()

Set permissions

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

setPinned()

Set pinned status

public setPinned(bool|null $pinned) : void
Parameters
$pinned : bool|null

setPodcastUrl()

Set podcast URL

public setPodcastUrl(string|null $podcastUrl) : void
Parameters
$podcastUrl : string|null

setPointsPossible()

Set points possible

public setPointsPossible(float|null $pointsPossible) : void
Parameters
$pointsPossible : float|null

setPostedAt()

Set posted at timestamp

public setPostedAt(string|null $postedAt) : void
Parameters
$postedAt : string|null

setPublished()

Set published status

public setPublished(bool|null $published) : void
Parameters
$published : bool|null

setReadOnly()

Set read only status

public setReadOnly(bool|null $readOnly) : void
Parameters
$readOnly : bool|null

setReadState()

Set read state

public setReadState(string|null $readState) : void
Parameters
$readState : string|null

setRequireInitialPost()

Set require initial post status

public setRequireInitialPost(bool|null $requireInitialPost) : void
Parameters
$requireInitialPost : bool|null

setRootTopicId()

Set root topic ID

public setRootTopicId(int|null $rootTopicId) : void
Parameters
$rootTopicId : int|null

setSortByRating()

Set sort by rating status

public setSortByRating(bool|null $sortByRating) : void
Parameters
$sortByRating : bool|null

setSortOrder()

Set sort order

public setSortOrder(string|null $sortOrder) : void
Parameters
$sortOrder : string|null

setSortOrderLocked()

Set sort order locked status

public setSortOrderLocked(bool|null $sortOrderLocked) : void
Parameters
$sortOrderLocked : bool|null

setSubscribed()

Set subscribed status

public setSubscribed(bool|null $subscribed) : void
Parameters
$subscribed : bool|null

setSubscriptionHold()

Set subscription hold status

public setSubscriptionHold(string|null $subscriptionHold) : void
Parameters
$subscriptionHold : string|null

setTitle()

Set discussion topic title

public setTitle(string|null $title) : void
Parameters
$title : string|null

setTopicChildren()

Set topic children

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

setUnreadCount()

Set unread count

public setUnreadCount(int|null $unreadCount) : void
Parameters
$unreadCount : int|null

setUpdatedAt()

Set updated at timestamp

public setUpdatedAt(string|null $updatedAt) : void
Parameters
$updatedAt : string|null

setUserCanSeePosts()

Set user can see posts status

public setUserCanSeePosts(bool|null $userCanSeePosts) : void
Parameters
$userCanSeePosts : bool|null

setUserId()

Set user ID

public setUserId(int|null $userId) : void
Parameters
$userId : int|null

setUserName()

Set user name

public setUserName(string|null $userName) : void
Parameters
$userName : string|null

setWorkflowState()

Set workflow state

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

subscribe()

Subscribe to discussion topic notifications

public subscribe() : bool
Tags
throws
CanvasApiException
Return values
bool

True if subscription was successful, false otherwise

toArray()

Convert discussion topic to array

public toArray() : array<string, mixed>
Return values
array<string, mixed>

toDtoArray()

Convert discussion topic to DTO array format

public toDtoArray() : array<string, mixed>
Return values
array<string, mixed>

unlock()

Unlock the discussion topic

public unlock() : bool
Tags
throws
CanvasApiException
Return values
bool

True if unlocking was successful, false otherwise

unpin()

Unpin the discussion topic

public unpin() : bool
Tags
throws
CanvasApiException
Return values
bool

True if unpinning was successful, false otherwise

unsubscribe()

Unsubscribe from discussion topic notifications

public unsubscribe() : bool
Tags
throws
CanvasApiException
Return values
bool

True if unsubscription was successful, false otherwise

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>

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

        
On this page

Search results