Quiz
extends AbstractBaseApi
in package
Canvas LMS Quizzes API
Provides functionality to manage quizzes and assessments in Canvas LMS. This class handles creating, reading, updating, and deleting quizzes for a specific course.
Usage Examples:
// Set course context (required for all operations)
$course = Course::find(123);
Quiz::setCourse($course);
// Create a new quiz
$quizData = [
'title' => 'Midterm Exam',
'description' => 'Covers chapters 1-5',
'quiz_type' => 'assignment',
'time_limit' => 60,
'points_possible' => 100,
'due_at' => '2024-12-31T23:59:59Z'
];
$quiz = Quiz::create($quizData);
// Find a quiz by ID
$quiz = Quiz::find(456);
// List all quizzes for the course
$quizzes = Quiz::fetchAll();
// Get published quizzes only
$publishedQuizzes = Quiz::fetchAll(['published' => true]);
// Get paginated quizzes
$paginatedQuizzes = Quiz::fetchAllPaginated();
$paginationResult = Quiz::fetchPage();
// Update a quiz
$updatedQuiz = Quiz::update(456, ['time_limit' => 90]);
// Update using DTO
$updateDto = new UpdateQuizDTO(['title' => 'Updated Quiz Title']);
$updatedQuiz = Quiz::update(456, $updateDto);
// Update using instance method
$quiz = Quiz::find(456);
$quiz->setTimeLimit(120);
$success = $quiz->save();
// Publish/unpublish a quiz
$quiz->publish();
$quiz->unpublish();
// Delete a quiz
$quiz = Quiz::find(456);
$success = $quiz->delete();
Table of Contents
Constants
- VALID_HIDE_RESULTS = [null, 'always', 'until_after_last_attempt']
- Valid hide results values
- VALID_QUIZ_TYPES = ['assignment', 'practice_quiz', 'survey', 'graded_survey']
- Valid quiz types
Properties
- $accessCode : string|null
- Access code/password for the quiz
- $allDates : array<string, mixed>|null
- All date variations for the quiz
- $allowedAttempts : int|null
- Number of allowed attempts (-1 for unlimited)
- $assignmentGroupId : int|null
- Assignment group ID for graded quizzes
- $courseId : int|null
- Course ID this quiz belongs to
- $createdAt : string|null
- Quiz creation timestamp
- $description : string|null
- Quiz description (HTML)
- $dueAt : string|null
- Quiz due date
- $hideResults : string|null
- When to hide quiz results (null, always, until_after_last_attempt)
- $htmlUrl : string|null
- HTML URL to the quiz
- $id : int|null
- Quiz unique identifier
- $ipFilter : string|null
- IP address filter/restriction
- $lockAt : string|null
- Date when quiz becomes locked
- $lockdownBrowserMonitorData : string|null
- Lockdown browser monitor data
- $mobileUrl : string|null
- Mobile URL to the quiz
- $oneQuestionAtATime : bool|null
- Whether to display one question at a time
- $pointsPossible : float|null
- Maximum points possible for this quiz
- $published : bool|null
- Whether the quiz is published
- $questionCount : int|null
- Number of questions in the quiz
- $quizType : string|null
- Quiz type (assignment, practice_quiz, survey, graded_survey)
- $requireLockdownBrowser : bool|null
- Whether the quiz requires lockdown browser
- $requireLockdownBrowserForResults : bool|null
- Whether the quiz requires lockdown browser for results
- $requireLockdownBrowserMonitor : bool|null
- Whether the quiz requires lockdown browser monitor
- $showCorrectAnswers : bool|null
- Whether to show correct answers after submission
- $shuffleAnswers : bool|null
- Whether to shuffle answers
- $timeLimit : int|null
- Time limit in minutes
- $title : string|null
- Quiz title
- $unlockAt : string|null
- Date when quiz becomes available
- $updatedAt : string|null
- Quiz last update timestamp
- $workflowState : string|null
- Quiz workflow state (published, unpublished, etc.)
- $apiClient : HttpClientInterface
- $course : Course
- $methodAliases : array<string|int, mixed>
- Define method aliases
Methods
- __callStatic() : mixed
- Magic method to handle function aliases
- __construct() : mixed
- Create a new Quiz instance
- checkCourse() : bool
- Check if course context is set
- create() : self
- Create a new quiz
- delete() : bool
- Delete the quiz
- fetchAll() : array<string|int, Quiz>
- Fetch all quizzes for the course
- fetchAllPages() : array<string|int, Quiz>
- Fetch all pages of quizzes
- fetchAllPaginated() : PaginatedResponse
- Fetch all quizzes with pagination support
- fetchPage() : PaginationResult
- Fetch a single page of quizzes
- find() : self
- Find a single quiz by ID
- getAccessCode() : string|null
- Get access code
- getAllDates() : array<string, mixed>|null
- Get all dates
- getAllowedAttempts() : int|null
- Get allowed attempts
- getAssignmentGroupId() : int|null
- Get assignment group ID
- getCourseId() : int|null
- Get course ID
- getCreatedAt() : string|null
- Get created at timestamp
- getCurrentUserSubmission() : QuizSubmission|null
- Get current user's submission for this quiz
- getDescription() : string|null
- Get quiz description
- getDueAt() : string|null
- Get due date
- getHideResults() : string|null
- Get hide results setting
- getHtmlUrl() : string|null
- Get HTML URL
- getId() : int|null
- Get quiz ID
- getIpFilter() : string|null
- Get IP filter
- getLockAt() : string|null
- Get lock date
- getLockdownBrowserMonitorData() : string|null
- Get lockdown browser monitor data
- getMobileUrl() : string|null
- Get mobile URL
- getOneQuestionAtATime() : bool|null
- Get one question at a time status
- getPointsPossible() : float|null
- Get points possible
- getPublished() : bool|null
- Get published status
- getQuestionCount() : int|null
- Get question count
- getQuizType() : string|null
- Get quiz type
- getRequireLockdownBrowser() : bool|null
- Get require lockdown browser status
- getRequireLockdownBrowserForResults() : bool|null
- Get require lockdown browser for results status
- getRequireLockdownBrowserMonitor() : bool|null
- Get require lockdown browser monitor status
- getShowCorrectAnswers() : bool|null
- Get show correct answers status
- getShuffleAnswers() : bool|null
- Get shuffle answers status
- getSubmissions() : array<string|int, QuizSubmission>
- Get all submissions for this quiz
- getSubmissionsPaginated() : PaginationResult
- Get paginated submissions for this quiz
- getTimeLimit() : int|null
- Get time limit
- getTitle() : string|null
- Get quiz title
- getUnlockAt() : string|null
- Get unlock date
- getUpdatedAt() : string|null
- Get updated at timestamp
- getWorkflowState() : string|null
- Get workflow state
- isPublished() : bool
- Check if the quiz is published
- publish() : bool
- Publish the quiz
- save() : bool
- Save the current quiz (create or update)
- setAccessCode() : void
- Set access code
- setAllDates() : void
- Set all dates
- setAllowedAttempts() : void
- Set allowed attempts
- setApiClient() : void
- Set the API client
- setAssignmentGroupId() : void
- Set assignment group ID
- setCourse() : void
- Set the course context for quiz operations
- setCourseId() : void
- Set course ID
- setCreatedAt() : void
- Set created at timestamp
- setDescription() : void
- Set quiz description
- setDueAt() : void
- Set due date
- setHideResults() : void
- Set hide results setting
- setHtmlUrl() : void
- Set HTML URL
- setId() : void
- Set quiz ID
- setIpFilter() : void
- Set IP filter
- setLockAt() : void
- Set lock date
- setLockdownBrowserMonitorData() : void
- Set lockdown browser monitor data
- setMobileUrl() : void
- Set mobile URL
- setOneQuestionAtATime() : void
- Set one question at a time status
- setPointsPossible() : void
- Set points possible
- setPublished() : void
- Set published status
- setQuestionCount() : void
- Set question count
- setQuizType() : void
- Set quiz type
- setRequireLockdownBrowser() : void
- Set require lockdown browser status
- setRequireLockdownBrowserForResults() : void
- Set require lockdown browser for results status
- setRequireLockdownBrowserMonitor() : void
- Set require lockdown browser monitor status
- setShowCorrectAnswers() : void
- Set show correct answers status
- setShuffleAnswers() : void
- Set shuffle answers status
- setTimeLimit() : void
- Set time limit
- setTitle() : void
- Set quiz title
- setUnlockAt() : void
- Set unlock date
- setUpdatedAt() : void
- Set updated at timestamp
- setWorkflowState() : void
- Set workflow state
- startSubmission() : QuizSubmission
- Start a new submission for this quiz
- toArray() : array<string, mixed>
- Convert quiz to array
- toDtoArray() : array<string, mixed>
- Convert quiz to DTO array format
- unpublish() : bool
- Unpublish the quiz
- update() : self
- Update a quiz
- 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
- isSafeToUpdateProperty() : bool
- Check if a property is safe to update from API response
- validateDescription() : void
- Validate quiz description for XSS prevention
Constants
VALID_HIDE_RESULTS
Valid hide results values
public
mixed
VALID_HIDE_RESULTS
= [null, 'always', 'until_after_last_attempt']
VALID_QUIZ_TYPES
Valid quiz types
public
mixed
VALID_QUIZ_TYPES
= ['assignment', 'practice_quiz', 'survey', 'graded_survey']
Properties
$accessCode
Access code/password for the quiz
public
string|null
$accessCode
= null
$allDates
All date variations for the quiz
public
array<string, mixed>|null
$allDates
= null
$allowedAttempts
Number of allowed attempts (-1 for unlimited)
public
int|null
$allowedAttempts
= null
$assignmentGroupId
Assignment group ID for graded quizzes
public
int|null
$assignmentGroupId
= null
$courseId
Course ID this quiz belongs to
public
int|null
$courseId
= null
$createdAt
Quiz creation timestamp
public
string|null
$createdAt
= null
$description
Quiz description (HTML)
public
string|null
$description
= null
$dueAt
Quiz due date
public
string|null
$dueAt
= null
$hideResults
When to hide quiz results (null, always, until_after_last_attempt)
public
string|null
$hideResults
= null
$htmlUrl
HTML URL to the quiz
public
string|null
$htmlUrl
= null
$id
Quiz unique identifier
public
int|null
$id
= null
$ipFilter
IP address filter/restriction
public
string|null
$ipFilter
= null
$lockAt
Date when quiz becomes locked
public
string|null
$lockAt
= null
$lockdownBrowserMonitorData
Lockdown browser monitor data
public
string|null
$lockdownBrowserMonitorData
= null
$mobileUrl
Mobile URL to the quiz
public
string|null
$mobileUrl
= null
$oneQuestionAtATime
Whether to display one question at a time
public
bool|null
$oneQuestionAtATime
= null
$pointsPossible
Maximum points possible for this quiz
public
float|null
$pointsPossible
= null
$published
Whether the quiz is published
public
bool|null
$published
= null
$questionCount
Number of questions in the quiz
public
int|null
$questionCount
= null
$quizType
Quiz type (assignment, practice_quiz, survey, graded_survey)
public
string|null
$quizType
= null
$requireLockdownBrowser
Whether the quiz requires lockdown browser
public
bool|null
$requireLockdownBrowser
= null
$requireLockdownBrowserForResults
Whether the quiz requires lockdown browser for results
public
bool|null
$requireLockdownBrowserForResults
= null
$requireLockdownBrowserMonitor
Whether the quiz requires lockdown browser monitor
public
bool|null
$requireLockdownBrowserMonitor
= null
$showCorrectAnswers
Whether to show correct answers after submission
public
bool|null
$showCorrectAnswers
= null
$shuffleAnswers
Whether to shuffle answers
public
bool|null
$shuffleAnswers
= null
$timeLimit
Time limit in minutes
public
int|null
$timeLimit
= null
$title
Quiz title
public
string|null
$title
= null
$unlockAt
Date when quiz becomes available
public
string|null
$unlockAt
= null
$updatedAt
Quiz last update timestamp
public
string|null
$updatedAt
= null
$workflowState
Quiz workflow state (published, unpublished, etc.)
public
string|null
$workflowState
= null
$apiClient
protected
static HttpClientInterface
$apiClient
$course
protected
static Course
$course
$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()
Create a new Quiz instance
public
__construct([array<string, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string, mixed> = []
-
Quiz data from Canvas API
checkCourse()
Check if course context is set
public
static checkCourse() : bool
Tags
Return values
boolcreate()
Create a new quiz
public
static create(array<string, mixed>|CreateQuizDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateQuizDTO
-
Quiz data
Tags
Return values
self —Created Quiz object
delete()
Delete the quiz
public
delete() : bool
Tags
Return values
bool —True if deletion was successful, false otherwise
fetchAll()
Fetch all quizzes for the course
public
static fetchAll([array<string, mixed> $params = [] ]) : array<string|int, Quiz>
Parameters
- $params : array<string, mixed> = []
-
Optional parameters
Tags
Return values
array<string|int, Quiz> —Array of Quiz objects
fetchAllPages()
Fetch all pages of quizzes
public
static fetchAllPages([array<string, mixed> $params = [] ]) : array<string|int, Quiz>
Parameters
- $params : array<string, mixed> = []
-
Optional parameters
Tags
Return values
array<string|int, Quiz> —Array of Quiz objects from all pages
fetchAllPaginated()
Fetch all quizzes with pagination support
public
static fetchAllPaginated([array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $params : array<string, mixed> = []
-
Optional parameters
Tags
Return values
PaginatedResponsefetchPage()
Fetch a single page of quizzes
public
static fetchPage([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Optional parameters
Tags
Return values
PaginationResultfind()
Find a single quiz by ID
public
static find(int $id) : self
Parameters
- $id : int
-
Quiz ID
Tags
Return values
selfgetAccessCode()
Get access code
public
getAccessCode() : string|null
Return values
string|nullgetAllDates()
Get all dates
public
getAllDates() : array<string, mixed>|null
Return values
array<string, mixed>|nullgetAllowedAttempts()
Get allowed attempts
public
getAllowedAttempts() : int|null
Return values
int|nullgetAssignmentGroupId()
Get assignment group ID
public
getAssignmentGroupId() : int|null
Return values
int|nullgetCourseId()
Get course ID
public
getCourseId() : int|null
Return values
int|nullgetCreatedAt()
Get created at timestamp
public
getCreatedAt() : string|null
Return values
string|nullgetCurrentUserSubmission()
Get current user's submission for this quiz
public
getCurrentUserSubmission() : QuizSubmission|null
Tags
Return values
QuizSubmission|null —Quiz submission instance or null if no submission
getDescription()
Get quiz description
public
getDescription() : string|null
Return values
string|nullgetDueAt()
Get due date
public
getDueAt() : string|null
Return values
string|nullgetHideResults()
Get hide results setting
public
getHideResults() : string|null
Return values
string|nullgetHtmlUrl()
Get HTML URL
public
getHtmlUrl() : string|null
Return values
string|nullgetId()
Get quiz ID
public
getId() : int|null
Return values
int|nullgetIpFilter()
Get IP filter
public
getIpFilter() : string|null
Return values
string|nullgetLockAt()
Get lock date
public
getLockAt() : string|null
Return values
string|nullgetLockdownBrowserMonitorData()
Get lockdown browser monitor data
public
getLockdownBrowserMonitorData() : string|null
Return values
string|nullgetMobileUrl()
Get mobile URL
public
getMobileUrl() : string|null
Return values
string|nullgetOneQuestionAtATime()
Get one question at a time status
public
getOneQuestionAtATime() : bool|null
Return values
bool|nullgetPointsPossible()
Get points possible
public
getPointsPossible() : float|null
Return values
float|nullgetPublished()
Get published status
public
getPublished() : bool|null
Return values
bool|nullgetQuestionCount()
Get question count
public
getQuestionCount() : int|null
Return values
int|nullgetQuizType()
Get quiz type
public
getQuizType() : string|null
Return values
string|nullgetRequireLockdownBrowser()
Get require lockdown browser status
public
getRequireLockdownBrowser() : bool|null
Return values
bool|nullgetRequireLockdownBrowserForResults()
Get require lockdown browser for results status
public
getRequireLockdownBrowserForResults() : bool|null
Return values
bool|nullgetRequireLockdownBrowserMonitor()
Get require lockdown browser monitor status
public
getRequireLockdownBrowserMonitor() : bool|null
Return values
bool|nullgetShowCorrectAnswers()
Get show correct answers status
public
getShowCorrectAnswers() : bool|null
Return values
bool|nullgetShuffleAnswers()
Get shuffle answers status
public
getShuffleAnswers() : bool|null
Return values
bool|nullgetSubmissions()
Get all submissions for this quiz
public
getSubmissions([array<string|int, mixed> $params = [] ]) : array<string|int, QuizSubmission>
Parameters
- $params : array<string|int, mixed> = []
-
Optional parameters for filtering submissions
Tags
Return values
array<string|int, QuizSubmission> —Array of quiz submission instances
getSubmissionsPaginated()
Get paginated submissions for this quiz
public
getSubmissionsPaginated([array<string|int, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string|int, mixed> = []
-
Optional parameters for filtering
Tags
Return values
PaginationResult —Pagination result with submissions
getTimeLimit()
Get time limit
public
getTimeLimit() : int|null
Return values
int|nullgetTitle()
Get quiz title
public
getTitle() : string|null
Return values
string|nullgetUnlockAt()
Get unlock date
public
getUnlockAt() : string|null
Return values
string|nullgetUpdatedAt()
Get updated at timestamp
public
getUpdatedAt() : string|null
Return values
string|nullgetWorkflowState()
Get workflow state
public
getWorkflowState() : string|null
Return values
string|nullisPublished()
Check if the quiz is published
public
isPublished() : bool
Return values
boolpublish()
Publish the quiz
public
publish() : bool
Tags
Return values
bool —True if publish was successful, false otherwise
save()
Save the current quiz (create or update)
public
save() : bool
Tags
Return values
bool —True if save was successful, false otherwise
setAccessCode()
Set access code
public
setAccessCode(string|null $accessCode) : void
Parameters
- $accessCode : string|null
setAllDates()
Set all dates
public
setAllDates(array<string, mixed>|null $allDates) : void
Parameters
- $allDates : array<string, mixed>|null
setAllowedAttempts()
Set allowed attempts
public
setAllowedAttempts(int|null $allowedAttempts) : void
Parameters
- $allowedAttempts : int|null
setApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
setAssignmentGroupId()
Set assignment group ID
public
setAssignmentGroupId(int|null $assignmentGroupId) : void
Parameters
- $assignmentGroupId : int|null
setCourse()
Set the course context for quiz 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
setDescription()
Set quiz description
public
setDescription(string|null $description) : void
Parameters
- $description : string|null
Tags
setDueAt()
Set due date
public
setDueAt(string|null $dueAt) : void
Parameters
- $dueAt : string|null
setHideResults()
Set hide results setting
public
setHideResults(string|null $hideResults) : void
Parameters
- $hideResults : string|null
setHtmlUrl()
Set HTML URL
public
setHtmlUrl(string|null $htmlUrl) : void
Parameters
- $htmlUrl : string|null
setId()
Set quiz ID
public
setId(int|null $id) : void
Parameters
- $id : int|null
setIpFilter()
Set IP filter
public
setIpFilter(string|null $ipFilter) : void
Parameters
- $ipFilter : string|null
setLockAt()
Set lock date
public
setLockAt(string|null $lockAt) : void
Parameters
- $lockAt : string|null
setLockdownBrowserMonitorData()
Set lockdown browser monitor data
public
setLockdownBrowserMonitorData(string|null $lockdownBrowserMonitorData) : void
Parameters
- $lockdownBrowserMonitorData : string|null
setMobileUrl()
Set mobile URL
public
setMobileUrl(string|null $mobileUrl) : void
Parameters
- $mobileUrl : string|null
setOneQuestionAtATime()
Set one question at a time status
public
setOneQuestionAtATime(bool|null $oneQuestionAtATime) : void
Parameters
- $oneQuestionAtATime : bool|null
setPointsPossible()
Set points possible
public
setPointsPossible(float|null $pointsPossible) : void
Parameters
- $pointsPossible : float|null
setPublished()
Set published status
public
setPublished(bool|null $published) : void
Parameters
- $published : bool|null
setQuestionCount()
Set question count
public
setQuestionCount(int|null $questionCount) : void
Parameters
- $questionCount : int|null
setQuizType()
Set quiz type
public
setQuizType(string|null $quizType) : void
Parameters
- $quizType : string|null
setRequireLockdownBrowser()
Set require lockdown browser status
public
setRequireLockdownBrowser(bool|null $requireLockdownBrowser) : void
Parameters
- $requireLockdownBrowser : bool|null
setRequireLockdownBrowserForResults()
Set require lockdown browser for results status
public
setRequireLockdownBrowserForResults(bool|null $requireLockdownBrowserForResults) : void
Parameters
- $requireLockdownBrowserForResults : bool|null
setRequireLockdownBrowserMonitor()
Set require lockdown browser monitor status
public
setRequireLockdownBrowserMonitor(bool|null $requireLockdownBrowserMonitor) : void
Parameters
- $requireLockdownBrowserMonitor : bool|null
setShowCorrectAnswers()
Set show correct answers status
public
setShowCorrectAnswers(bool|null $showCorrectAnswers) : void
Parameters
- $showCorrectAnswers : bool|null
setShuffleAnswers()
Set shuffle answers status
public
setShuffleAnswers(bool|null $shuffleAnswers) : void
Parameters
- $shuffleAnswers : bool|null
setTimeLimit()
Set time limit
public
setTimeLimit(int|null $timeLimit) : void
Parameters
- $timeLimit : int|null
setTitle()
Set quiz title
public
setTitle(string|null $title) : void
Parameters
- $title : string|null
setUnlockAt()
Set unlock date
public
setUnlockAt(string|null $unlockAt) : void
Parameters
- $unlockAt : string|null
setUpdatedAt()
Set updated at timestamp
public
setUpdatedAt(string|null $updatedAt) : void
Parameters
- $updatedAt : string|null
setWorkflowState()
Set workflow state
public
setWorkflowState(string|null $workflowState) : void
Parameters
- $workflowState : string|null
startSubmission()
Start a new submission for this quiz
public
startSubmission([array<string|int, mixed> $params = [] ]) : QuizSubmission
Parameters
- $params : array<string|int, mixed> = []
-
Optional parameters like access_code
Tags
Return values
QuizSubmission —Created quiz submission instance
toArray()
Convert quiz to array
public
toArray() : array<string, mixed>
Return values
array<string, mixed>toDtoArray()
Convert quiz to DTO array format
public
toDtoArray() : array<string, mixed>
Return values
array<string, mixed>unpublish()
Unpublish the quiz
public
unpublish() : bool
Tags
Return values
bool —True if unpublish was successful, false otherwise
update()
Update a quiz
public
static update(int $id, array<string, mixed>|UpdateQuizDTO $data) : self
Parameters
- $id : int
-
Quiz ID
- $data : array<string, mixed>|UpdateQuizDTO
-
Quiz data
Tags
Return values
self —Updated Quiz object
castValue()
Cast a value to the correct type
protected
castValue(string $key, mixed $value) : DateTime|mixed
Parameters
- $key : string
- $value : mixed
Tags
Return values
DateTime|mixedcheckApiClient()
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>createPaginationResult()
Helper method to create PaginationResult from paginated response
protected
static createPaginationResult(PaginatedResponse $paginatedResponse) : PaginationResult
Parameters
- $paginatedResponse : PaginatedResponse
Return values
PaginationResultfetchAllPagesAsModels()
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
PaginatedResponsepopulate()
Populate the object with new data
protected
populate(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Tags
isSafeToUpdateProperty()
Check if a property is safe to update from API response
private
isSafeToUpdateProperty(string $property) : bool
Parameters
- $property : string
Return values
boolvalidateDescription()
Validate quiz description for XSS prevention
private
validateDescription(string $description) : void
Parameters
- $description : string