UserProfile

UserProfile

Zentrales User-Profil für die ai-unboxed Plattform.

Speichert ausschließlich lernbezogene Daten (keine PII). Verwendet localStorage als Persistenzschicht.

Constructor

new UserProfile(data)

Source:
Example
const profile = UserProfile.load();
profile.completeResource('game_rotatebox');
profile.setAssessmentScore('math', 0.65);
profile.save();
Parameters:
Name Type Description
data Object

Profildaten (siehe Schema in DATA_MODEL_CONVENTIONS.md §2.2)

Members

assessmentScores :Object.<string, number>

Description:
  • Kategorie → Score (0.0–1.0)

Source:

Kategorie → Score (0.0–1.0)

Type:
  • Object.<string, number>

badges :Array.<string>

Description:
  • Badge-IDs

Source:

Badge-IDs

Type:
  • Array.<string>

completedResources :Array.<string>

Description:
  • Content-Registry IDs abgeschlossener Ressourcen

Source:

Content-Registry IDs abgeschlossener Ressourcen

Type:
  • Array.<string>

createdAt :string

Description:
  • ISO 8601 Timestamp

Source:

ISO 8601 Timestamp

Type:
  • string

interests :Array.<string>

Description:
  • Topic-Tags (identisch mit Content-Registry Topics)

Source:

Topic-Tags (identisch mit Content-Registry Topics)

Type:
  • Array.<string>

lastVisited :string|null

Description:
  • Letzte besuchte Ressource-ID

Source:

Letzte besuchte Ressource-ID

Type:
  • string | null

level :string

Description:
  • Einstufung: 'unknown'|'beginner'|'intermediate'|'advanced'

Source:

Einstufung: 'unknown'|'beginner'|'intermediate'|'advanced'

Type:
  • string

onboardingCompleted :string|null

Description:
  • Art des abgeschlossenen Onboardings

Source:

Art des abgeschlossenen Onboardings

Type:
  • string | null

recommendationsDismissed :Array.<string>

Description:
  • Weggeklickte Empfehlungs-IDs

Source:

Weggeklickte Empfehlungs-IDs

Type:
  • Array.<string>

updatedAt :string

Description:
  • ISO 8601 Timestamp

Source:

ISO 8601 Timestamp

Type:
  • string

version :number

Description:
  • Schema-Version

Source:

Schema-Version

Type:
  • number

Methods

addBadge(badgeId) → {UserProfile}

Description:
  • Vergibt ein Badge.

Source:
Parameters:
Name Type Description
badgeId string

Badge-ID

Returns:

this

Type
UserProfile

addInterest(topic) → {UserProfile}

Description:
  • Fügt eine Interesse/Topic hinzu.

Source:
Parameters:
Name Type Description
topic string

Topic-Tag

Returns:

this

Type
UserProfile

completeOnboarding(method) → {UserProfile}

Description:
  • Markiert das Onboarding als abgeschlossen.

Source:
Parameters:
Name Type Description
method 'test' | 'skip' | 'quick'

Art des Onboardings

Returns:

this

Type
UserProfile

completeResource(resourceId) → {UserProfile}

Description:
  • Markiert eine Ressource als abgeschlossen.

Source:
Parameters:
Name Type Description
resourceId string

Content-Registry ID.

Returns:

this (für Chaining)

Type
UserProfile

dismissRecommendation(resourceId) → {UserProfile}

Description:
  • Markiert eine Empfehlung als weggeklickt.

Source:
Parameters:
Name Type Description
resourceId string

Content-Registry ID

Returns:

this

Type
UserProfile

getAssessmentScore(category) → {number|null}

Description:
  • Gibt den Assessment-Score für eine Kategorie zurück.

Source:
Parameters:
Name Type Description
category string

z.B. 'math', 'history'

Returns:

Score (0.0–1.0) oder null falls nicht vorhanden.

Type
number | null

getAverageScore() → {number}

Description:
  • Berechnet den Durchschnittsscore über alle Assessment-Kategorien.

Source:
Returns:

Durchschnitt (0.0–1.0), oder 0 wenn keine Scores vorhanden.

Type
number

getCompletedCount() → {number}

Description:
  • Gibt die Anzahl abgeschlossener Ressourcen zurück.

Source:
Returns:
Type
number

hasCompleted(resourceId) → {boolean}

Description:
  • Prüft, ob eine Ressource abgeschlossen wurde.

Source:
Parameters:
Name Type Description
resourceId string

Content-Registry ID.

Returns:
Type
boolean

hasCompletedOnboarding() → {boolean}

Description:
  • Prüft, ob das Onboarding abgeschlossen wurde.

Source:
Returns:
Type
boolean

removeInterest(topic) → {UserProfile}

Description:
  • Entfernt ein Interesse.

Source:
Parameters:
Name Type Description
topic string

Topic-Tag

Returns:

this

Type
UserProfile

save() → {UserProfile}

Description:
  • Speichert das Profil in localStorage.

Source:
Returns:

this

Type
UserProfile

setAssessmentScore(category, score) → {UserProfile}

Description:
  • Setzt den Assessment-Score für eine Kategorie.

Source:
Parameters:
Name Type Description
category string

z.B. 'math', 'history'

score number

Wert zwischen 0.0 und 1.0

Returns:

this

Type
UserProfile

setLastVisited(resourceId) → {UserProfile}

Description:
  • Setzt die zuletzt besuchte Ressource.

Source:
Parameters:
Name Type Description
resourceId string

Content-Registry ID

Returns:

this

Type
UserProfile

setLevel(level) → {UserProfile}

Description:
  • Setzt das Level des Nutzers.

Source:
Parameters:
Name Type Description
level 'unknown' | 'beginner' | 'intermediate' | 'advanced'
Returns:

this

Type
UserProfile

toJSON() → {Object}

Description:
  • Serialisiert das Profil als JSON-kompatibles Objekt.

Source:
Returns:
Type
Object

(static) load() → {UserProfile}

Description:
  • Lädt das Profil aus localStorage oder erstellt ein neues. Bei erstem Laden werden Legacy-Keys eingelesen und konsolidiert.

Source:
Returns:

Das geladene oder neu erstellte Profil.

Type
UserProfile

(static) reset()

Description:
  • Löscht alle Profildaten und alle Legacy-Keys aus localStorage.

Source: