ReviewApiHandler
in package
implements
ApiRoutableInterface
uses
ApiRoutableTrait
Handler for review/test-related API operations.
Tags
Table of Contents
Interfaces
- ApiRoutableInterface
- Interface for API handlers that participate in route dispatch.
Properties
Methods
- __construct() : mixed
- Constructor.
- formatNextWord() : array{term_id: int|string, solution?: string, term_text: string, group: string}
- Format response for getting next word test.
- formatTableWords() : array<string|int, mixed>
- Get all words for table test mode.
- formatTestConfig() : array<string|int, mixed>
- Get full test configuration for Alpine.js initialization.
- formatTomorrowCount() : array{count: int}
- Format response for tomorrow count.
- formatUpdateStatus() : array{status?: int, controls?: string, error?: string}
- Format response for updating review status.
- getWordReviewData() : array{term_id: int|string, solution?: string, term_text: string, group: string}
- Get the next word to test as structured data.
- routeDelete() : JsonResponse
- routeGet() : JsonResponse
- Handle a GET request for this resource.
- routePost() : JsonResponse
- routePut() : JsonResponse
- Handle a PUT request for this resource.
- tomorrowTestCount() : array{count: int}
- Return the number of reviews for tomorrow.
- updateReviewStatus() : array{status?: int, controls?: string, error?: string}
- Update word status during review/test mode.
- wordTestAjax() : array{term_id: int|string, solution?: string, term_text: string, group: string}
- Get the next word to review based on request parameters.
- frag() : string
- Extract a fragment from the fragments array.
- buildAnnotatedSentenceHtml() : string
- Build HTML for a sentence with ruby annotations.
- formatTermForTest() : array{0: string, 1: string}
- Format term for test display.
- parseSelection() : int|array<string|int, int>
- Parse selection parameter based on review key type.
Properties
$reviewFacade
private
ReviewFacade
$reviewFacade
$sessionManager
private
SessionStateManager
$sessionManager
Methods
__construct()
Constructor.
public
__construct([ReviewFacade|null $reviewFacade = null ][, SessionStateManager|null $sessionManager = null ]) : mixed
Parameters
- $reviewFacade : ReviewFacade|null = null
-
Review facade (optional)
- $sessionManager : SessionStateManager|null = null
-
Session state manager (optional)
formatNextWord()
Format response for getting next word test.
public
formatNextWord(array<string, mixed> $params) : array{term_id: int|string, solution?: string, term_text: string, group: string}
Parameters
- $params : array<string, mixed>
-
Request parameters
Return values
array{term_id: int|string, solution?: string, term_text: string, group: string}formatTableWords()
Get all words for table test mode.
public
formatTableWords(array<string, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string, mixed>
-
Request parameters
Return values
array<string|int, mixed> —Table words data
formatTestConfig()
Get full test configuration for Alpine.js initialization.
public
formatTestConfig(array<string, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string, mixed>
-
Request parameters
Return values
array<string|int, mixed> —Test configuration
formatTomorrowCount()
Format response for tomorrow count.
public
formatTomorrowCount(array<string, mixed> $params) : array{count: int}
Parameters
- $params : array<string, mixed>
-
Request parameters
Return values
array{count: int}formatUpdateStatus()
Format response for updating review status.
public
formatUpdateStatus(array<string|int, mixed> $params) : array{status?: int, controls?: string, error?: string}
Parameters
- $params : array<string|int, mixed>
-
Request parameters
Return values
array{status?: int, controls?: string, error?: string}getWordReviewData()
Get the next word to test as structured data.
public
getWordReviewData(string $reviewsql, bool $wordMode, int $testtype) : array{term_id: int|string, solution?: string, term_text: string, group: string}
Parameters
- $reviewsql : string
-
SQL projection query
- $wordMode : bool
-
Test is in word mode
- $testtype : int
-
Test type
Return values
array{term_id: int|string, solution?: string, term_text: string, group: string}routeDelete()
public
routeDelete(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
- $fragments : array<string|int, mixed>
- $params : array<string|int, mixed>
Return values
JsonResponserouteGet()
Handle a GET request for this resource.
public
routeGet(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
- $fragments : array<string|int, mixed>
-
URL path segments (resource name already consumed)
- $params : array<string|int, mixed>
-
Query parameters
Return values
JsonResponseroutePost()
public
routePost(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
- $fragments : array<string|int, mixed>
- $params : array<string|int, mixed>
Return values
JsonResponseroutePut()
Handle a PUT request for this resource.
public
routePut(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
- $fragments : array<string|int, mixed>
-
URL path segments (resource name already consumed)
- $params : array<string|int, mixed>
-
JSON body parameters
Return values
JsonResponsetomorrowTestCount()
Return the number of reviews for tomorrow.
public
tomorrowTestCount(array<string, mixed> $params) : array{count: int}
Parameters
- $params : array<string, mixed>
-
Request parameters
Return values
array{count: int}updateReviewStatus()
Update word status during review/test mode.
public
updateReviewStatus(int $wordId, int|null $status, int|null $change) : array{status?: int, controls?: string, error?: string}
Parameters
- $wordId : int
-
Word ID
- $status : int|null
-
Explicit status
- $change : int|null
-
Status change amount
Return values
array{status?: int, controls?: string, error?: string}wordTestAjax()
Get the next word to review based on request parameters.
public
wordTestAjax(array<string, mixed> $params) : array{term_id: int|string, solution?: string, term_text: string, group: string}
Parameters
- $params : array<string, mixed>
-
Request parameters
Return values
array{term_id: int|string, solution?: string, term_text: string, group: string}frag()
Extract a fragment from the fragments array.
protected
frag(array<int, string> $fragments, int $index) : string
Parameters
- $fragments : array<int, string>
-
The URL path fragments
- $index : int
-
The index to extract
Return values
string —The fragment at the index, or empty string if not present
buildAnnotatedSentenceHtml()
Build HTML for a sentence with ruby annotations.
private
buildAnnotatedSentenceHtml(array<int, array{text: string, romanization: string|null, translation: string|null, isTarget?: bool, order?: int}> $annotations, string $targetWord, int $baseType, bool $showRom, bool $showTrans) : string
Parameters
- $annotations : array<int, array{text: string, romanization: string|null, translation: string|null, isTarget?: bool, order?: int}>
-
Word annotations keyed by order
- $targetWord : string
-
The target word being tested
- $baseType : int
-
Test type (1=show term, 2=hide term, 3=hide term)
- $showRom : bool
-
Show romanization
- $showTrans : bool
-
Show translation
Return values
string —HTML with ruby annotations
formatTermForTest()
Format term for test display.
private
formatTermForTest(array<string, mixed> $wordRecord, string $sentence, int $testType[, array<int, array{text: string, romanization: string|null, translation: string|null, isTarget?: bool, order?: int}> $annotations = [] ][, bool $showContextRom = false ][, bool $showContextTrans = false ]) : array{0: string, 1: string}
Parameters
- $wordRecord : array<string, mixed>
-
Word database record
- $sentence : string
-
Sentence containing the word (word marked with })
- $testType : int
-
Test type (1-5)
- $annotations : array<int, array{text: string, romanization: string|null, translation: string|null, isTarget?: bool, order?: int}> = []
-
Word annotations (keyed by order)
- $showContextRom : bool = false
-
Show romanization on context words
- $showContextTrans : bool = false
-
Show translation on context words
Return values
array{0: string, 1: string} —[HTML display, plain word text]
parseSelection()
Parse selection parameter based on review key type.
private
parseSelection(string $reviewKey, string $selection) : int|array<string|int, int>
Parameters
- $reviewKey : string
-
The review key type
- $selection : string
-
The selection value
Return values
int|array<string|int, int> —Parsed selection value