Skip to main content

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;
}
FieldDescription
dateHuman-readable locale string generated with new Date().toLocaleString()
scoreFinal score for the session (multiples of 100, max 1 000)
correctAnswersNumber of questions answered correctly
totalQuestionsAlways 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:
  1. Increments gamesPlayed by 1.
  2. Adds correctCount to the running correctAnswers total.
  3. 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

KeyTypeContents
sw_historyHistoryItem[]All session records, most recent first
sw_statsObjectAggregate gamesPlayed, correctAnswers, maxScore

StorageService — History Methods

MethodSignatureDescription
addHistoryaddHistory(item: HistoryItem): voidPrepends a new session record to the history array and saves it
getHistorygetHistory(): HistoryItem[]Returns the full history array, or [] if none exists
saveHistorysaveHistory(history: HistoryItem[]): voidOverwrites the entire history array in storage

StorageService — Stats Methods

MethodSignatureDescription
getStatsgetStats(): anyReturns the stats object, defaulting to { gamesPlayed: 0, correctAnswers: 0, maxScore: 0 }
saveStatssaveStats(stats: any): voidPersists the stats object to sw_stats
updateStatsupdateStats(score: number, correctCount: number): voidReads, 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().

Build docs developers (and LLMs) love