Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dreancaste/TriviaPP/llms.txt
Use this file to discover all available pages before exploring further.
TriviaPP automatically records the result of every completed trivia session so players can review their past performance and track long-term progress. The history is stored locally on the device using localStorage, and a separate cumulative stats object keeps running totals that surface on the Profile page.
History and stats are stored locally on the device and are not synced to any server. Clearing the browser or app storage will permanently erase the match history.
HistoryItem Interface
Each completed session is saved as a HistoryItem object:
export interface HistoryItem {
date: string;
score: number;
correctAnswers: number;
totalQuestions: number;
}
| Field | Description |
|---|
date | Human-readable locale string generated with new Date().toLocaleString() |
score | Final score for the session (multiples of 100, max 1 000) |
correctAnswers | Number of questions answered correctly |
totalQuestions | Always 10 — the fixed session length |
Cumulative Stats
Alongside the per-session log, TriviaPP maintains an aggregate stats object under the sw_stats localStorage key:
{
"gamesPlayed": 12,
"correctAnswers": 87,
"maxScore": 900
}
StorageService.updateStats(score, correctCount) is called at the end of every game. It:
- Increments
gamesPlayed by 1.
- Adds
correctCount to the running correctAnswers total.
- Replaces
maxScore if the new score exceeds the stored value.
These aggregates are displayed on the Profile page so players can see their all-time performance at a glance.
Storage Keys
| Key | Type | Contents |
|---|
sw_history | HistoryItem[] | All session records, most recent first |
sw_stats | Object | Aggregate gamesPlayed, correctAnswers, maxScore |
StorageService — History Methods
| Method | Signature | Description |
|---|
addHistory | addHistory(item: HistoryItem): void | Prepends a new session record to the history array and saves it |
getHistory | getHistory(): HistoryItem[] | Returns the full history array, or [] if none exists |
saveHistory | saveHistory(history: HistoryItem[]): void | Overwrites the entire history array in storage |
StorageService — Stats Methods
| Method | Signature | Description |
|---|
getStats | getStats(): any | Returns the stats object, defaulting to { gamesPlayed: 0, correctAnswers: 0, maxScore: 0 } |
saveStats | saveStats(stats: any): void | Persists the stats object to sw_stats |
updateStats | updateStats(score: number, correctCount: number): void | Reads, updates, and saves stats in a single call |
HistoryPage
HistoryPage reads the full history array from StorageService.getHistory() in ngOnInit and binds it to the view for display. Entries are listed most-recent-first because addHistory always prepends with Array.unshift().