# QuizStateService

- File ID: file:3xx07l:quizstateservice-cs
- Path: NexusReader.UI.Shared/Services/QuizStateService.cs
- Role: service
- Layer: frontend

## Purpose

In-memory UI/shared service that holds quiz-related state (current quiz, block id, hydration and new-quiz flag) and notifies subscribers via events when the quiz is requested or updated.

## Key Details

Simple in-memory UI service: mutates properties and raises OnQuizRequested/OnQuizUpdated events; no persistence or external I/O in this file.

## Symbols

- QuizStateService: In-memory UI/shared service that holds quiz-related state (current quiz, block id, hydration and new-quiz flag) and notifies subscribers via events when the quiz is requested or updated.
- RequestQuiz(): Sets the current quiz block id and notifies subscribers that a quiz was requested.
- SetQuiz(): Updates the current quiz and related flags, stops hydrating state, and notifies subscribers of the update.
- SetHydrating(): Sets the IsHydrating flag and notifies subscribers of the update.
- MarkQuizAsSeen(): If there is a new quiz flag, clears it and notifies subscribers.
- QuizStateService: Holds quiz-related UI state and exposes events to notify UI consumers when state changes.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Queries.Quiz (provides QuizDto)
- dependency-target: IQuizStateService (interface implemented, file not in scope)
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown

## Coverage

- Symbols: 6
- Executable symbols: 4
- Executable symbols with control flow: 4
- Grounded edges: 6
- Unresolved references: 6
- Control-flow fragments: 4
- Unresolved jumps: 4
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 6

## Control Flow Fragments

- RequestQuiz: 13 nodes, 14 edges, 1 jumps, 0 unsupported constructs
- SetQuiz: 16 nodes, 17 edges, 1 jumps, 0 unsupported constructs
- SetHydrating: 13 nodes, 14 edges, 1 jumps, 0 unsupported constructs
- MarkQuizAsSeen: 21 nodes, 24 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### QuizStateService Neighborhood

```mermaid
flowchart LR
    class_1t69b7g_quizstateservice("QuizStateService")
    file_3xx07l_quizstateservice_cs("QuizStateService")
    method_13pj2z1_markquizasseen[["MarkQuizAsSeen()"]]
    method_8psub5_requestquiz[["RequestQuiz()"]]
    method_gisz9i_sethydrating[["SetHydrating()"]]
    method_o6n51_setquiz[["SetQuiz()"]]
    type_n36vet_quizstateservice[/"QuizStateService"/]
```

### QuizStateService Execution Overview

```mermaid
flowchart TD
    class_1t69b7g_quizstateservice("QuizStateService")
    method_13pj2z1_markquizasseen[["MarkQuizAsSeen()"]]
    method_8psub5_requestquiz[["RequestQuiz()"]]
    method_gisz9i_sethydrating[["SetHydrating()"]]
    method_o6n51_setquiz[["SetQuiz()"]]
    unresolved_unresolved_1cm0tw4_call_target{"Unresolved: OnQuizUpdated (invoke)"}
    unresolved_unresolved_1egtwca_call_target{"Unresolved: OnQuizUpdated (invoke)"}
    unresolved_unresolved_1hcmv1v_call_target{"Unresolved: OnQuizUpdated (invoke)"}
    unresolved_unresolved_sgvk0u_call_target{"Unresolved: OnQuizRequested (invoke)"}
    class_1t69b7g_quizstateservice -->|contains| method_13pj2z1_markquizasseen
    class_1t69b7g_quizstateservice -->|contains| method_8psub5_requestquiz
    class_1t69b7g_quizstateservice -->|contains| method_gisz9i_sethydrating
    class_1t69b7g_quizstateservice -->|contains| method_o6n51_setquiz
    method_13pj2z1_markquizasseen -->|unresolved call| unresolved_unresolved_1cm0tw4_call_target
    method_8psub5_requestquiz -->|unresolved call| unresolved_unresolved_sgvk0u_call_target
    method_gisz9i_sethydrating -->|unresolved call| unresolved_unresolved_1hcmv1v_call_target
    method_o6n51_setquiz -->|unresolved call| unresolved_unresolved_1egtwca_call_target
```

### RequestQuiz() Control Flow

```mermaid
flowchart TD
    method_8psub5_requestquiz__call_18_OnQuizRequested_invoke_[["OnQuizRequested (invoke)"]]
    method_8psub5_requestquiz__action_17_assignment_17__linear("Set CurrentQuizBlockId")
    method_8psub5_requestquiz__action_18_branch_18__condition{"OnQuizRequested != null"}
    method_8psub5_requestquiz__action_18_branch_18__false("skip")
    method_8psub5_requestquiz__action_18_branch_18__merge("merge")
    method_8psub5_requestquiz__action_18_branch_18__true("invoke")
    method_8psub5_requestquiz__action_18_requestquiz_await_18_1__await[["Waits for async work"]]
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__condition{"OnQuizRequested != null) await OnQuizRequested(blockId"}
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__false("false")
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__merge("merge")
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__true("true")
    method_8psub5_requestquiz__entry(["RequestQuiz entry"])
    method_8psub5_requestquiz__implicit_return(["return"])
    method_8psub5_requestquiz__action_17_assignment_17__linear -->|next| method_8psub5_requestquiz__action_18_requestquiz_await_18_1__await
    method_8psub5_requestquiz__action_18_branch_18__condition -->|skip| method_8psub5_requestquiz__action_18_branch_18__false
    method_8psub5_requestquiz__action_18_branch_18__condition -->|invoke| method_8psub5_requestquiz__action_18_branch_18__true
    method_8psub5_requestquiz__action_18_branch_18__false -->|next| method_8psub5_requestquiz__action_18_branch_18__merge
    method_8psub5_requestquiz__action_18_branch_18__merge -->|next| method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__condition
    method_8psub5_requestquiz__action_18_branch_18__true -->|next| method_8psub5_requestquiz__action_18_branch_18__merge
    method_8psub5_requestquiz__action_18_requestquiz_await_18_1__await -->|next| method_8psub5_requestquiz__action_18_branch_18__condition
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__condition -->|false| method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__false
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__condition -->|true| method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__true
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__false -->|next| method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__merge
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__merge -->|blockId string passed to subscribers| method_8psub5_requestquiz__call_18_OnQuizRequested_invoke_
    method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__true -->|next| method_8psub5_requestquiz__action_18_requestquiz_branch_18_0__merge
    method_8psub5_requestquiz__call_18_OnQuizRequested_invoke_ -->|return| method_8psub5_requestquiz__implicit_return
    method_8psub5_requestquiz__entry -->|next| method_8psub5_requestquiz__action_17_assignment_17__linear
```

### SetQuiz() Control Flow

```mermaid
flowchart TD
    method_o6n51_setquiz__call_27_OnQuizUpdated_invoke_[["OnQuizUpdated (invoke)"]]
    method_o6n51_setquiz__action_23_assignment_23__linear("Set CurrentQuizBlockId")
    method_o6n51_setquiz__action_24_assignment_24__linear("Set CurrentQuiz")
    method_o6n51_setquiz__action_25_assignment_25__linear("Clear IsHydrating")
    method_o6n51_setquiz__action_26_assignment_26__linear("Set HasNewQuiz based on quiz presence")
    method_o6n51_setquiz__action_27_branch_27__condition{"OnQuizUpdated != null"}
    method_o6n51_setquiz__action_27_branch_27__false("skip")
    method_o6n51_setquiz__action_27_branch_27__merge("merge")
    method_o6n51_setquiz__action_27_branch_27__true("invoke")
    method_o6n51_setquiz__action_27_setquiz_await_27_1__await[["Waits for async work"]]
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__condition{"OnQuizUpdated != null) await OnQuizUpdated("}
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__false("false")
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__merge("merge")
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__true("true")
    method_o6n51_setquiz__entry(["SetQuiz entry"])
    method_o6n51_setquiz__implicit_return(["return"])
    method_o6n51_setquiz__action_23_assignment_23__linear -->|next| method_o6n51_setquiz__action_24_assignment_24__linear
    method_o6n51_setquiz__action_24_assignment_24__linear -->|next| method_o6n51_setquiz__action_25_assignment_25__linear
    method_o6n51_setquiz__action_25_assignment_25__linear -->|next| method_o6n51_setquiz__action_26_assignment_26__linear
    method_o6n51_setquiz__action_26_assignment_26__linear -->|next| method_o6n51_setquiz__action_27_setquiz_await_27_1__await
    method_o6n51_setquiz__action_27_branch_27__condition -->|skip| method_o6n51_setquiz__action_27_branch_27__false
    method_o6n51_setquiz__action_27_branch_27__condition -->|invoke| method_o6n51_setquiz__action_27_branch_27__true
    method_o6n51_setquiz__action_27_branch_27__false -->|next| method_o6n51_setquiz__action_27_branch_27__merge
    method_o6n51_setquiz__action_27_branch_27__merge -->|next| method_o6n51_setquiz__action_27_setquiz_branch_27_0__condition
    method_o6n51_setquiz__action_27_branch_27__true -->|next| method_o6n51_setquiz__action_27_branch_27__merge
    method_o6n51_setquiz__action_27_setquiz_await_27_1__await -->|next| method_o6n51_setquiz__action_27_branch_27__condition
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__condition -->|false| method_o6n51_setquiz__action_27_setquiz_branch_27_0__false
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__condition -->|true| method_o6n51_setquiz__action_27_setquiz_branch_27_0__true
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__false -->|next| method_o6n51_setquiz__action_27_setquiz_branch_27_0__merge
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__merge -->|no parameters notifies subscribers of state change| method_o6n51_setquiz__call_27_OnQuizUpdated_invoke_
    method_o6n51_setquiz__action_27_setquiz_branch_27_0__true -->|next| method_o6n51_setquiz__action_27_setquiz_branch_27_0__merge
    method_o6n51_setquiz__call_27_OnQuizUpdated_invoke_ -->|return| method_o6n51_setquiz__implicit_return
    method_o6n51_setquiz__entry -->|next| method_o6n51_setquiz__action_23_assignment_23__linear
```

### SetHydrating() Control Flow

```mermaid
flowchart TD
    method_gisz9i_sethydrating__call_33_OnQuizUpdated_invoke_[["OnQuizUpdated (invoke)"]]
    method_gisz9i_sethydrating__action_32_assignment_32__linear("Set IsHydrating")
    method_gisz9i_sethydrating__action_33_branch_33__condition{"OnQuizUpdated != null"}
    method_gisz9i_sethydrating__action_33_branch_33__false("skip")
    method_gisz9i_sethydrating__action_33_branch_33__merge("merge")
    method_gisz9i_sethydrating__action_33_branch_33__true("invoke")
    method_gisz9i_sethydrating__action_33_sethydrating_await_33_1__await[["Waits for async work"]]
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__condition{"OnQuizUpdated != null) await OnQuizUpdated("}
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__false("false")
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__merge("merge")
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__true("true")
    method_gisz9i_sethydrating__entry(["SetHydrating entry"])
    method_gisz9i_sethydrating__implicit_return(["return"])
    method_gisz9i_sethydrating__action_32_assignment_32__linear -->|next| method_gisz9i_sethydrating__action_33_sethydrating_await_33_1__await
    method_gisz9i_sethydrating__action_33_branch_33__condition -->|skip| method_gisz9i_sethydrating__action_33_branch_33__false
    method_gisz9i_sethydrating__action_33_branch_33__condition -->|invoke| method_gisz9i_sethydrating__action_33_branch_33__true
    method_gisz9i_sethydrating__action_33_branch_33__false -->|next| method_gisz9i_sethydrating__action_33_branch_33__merge
    method_gisz9i_sethydrating__action_33_branch_33__merge -->|next| method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__condition
    method_gisz9i_sethydrating__action_33_branch_33__true -->|next| method_gisz9i_sethydrating__action_33_branch_33__merge
    method_gisz9i_sethydrating__action_33_sethydrating_await_33_1__await -->|next| method_gisz9i_sethydrating__action_33_branch_33__condition
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__condition -->|false| method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__false
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__condition -->|true| method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__true
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__false -->|next| method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__merge
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__merge -->|no parameters notifies subscribers that hydration state changed| method_gisz9i_sethydrating__call_33_OnQuizUpdated_invoke_
    method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__true -->|next| method_gisz9i_sethydrating__action_33_sethydrating_branch_33_0__merge
    method_gisz9i_sethydrating__call_33_OnQuizUpdated_invoke_ -->|return| method_gisz9i_sethydrating__implicit_return
    method_gisz9i_sethydrating__entry -->|next| method_gisz9i_sethydrating__action_32_assignment_32__linear
```

### MarkQuizAsSeen() Control Flow

_Warnings: diagram method_13pj2z1_markquizasseen__fragment_diagram exceeds preferred complexity thresholds (21 nodes, 24 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_13pj2z1_markquizasseen__call_40_OnQuizUpdated_invoke_[["OnQuizUpdated (invoke)"]]
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__condition{"!HasNewQuiz"}
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__false("continue")
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__merge("merge")
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__true("return")
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__condition{"!HasNewQuiz"}
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__false("continue")
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__merge("merge")
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__true("exit")
    method_13pj2z1_markquizasseen__action_39_assignment_39__linear("Clear HasNewQuiz")
    method_13pj2z1_markquizasseen__action_40_branch_40__condition{"OnQuizUpdated != null"}
    method_13pj2z1_markquizasseen__action_40_branch_40__false("skip")
    method_13pj2z1_markquizasseen__action_40_branch_40__merge("merge")
    method_13pj2z1_markquizasseen__action_40_branch_40__true("invoke")
    method_13pj2z1_markquizasseen__action_40_markquizasseen_await_40_2__await[["Waits for async work"]]
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__condition{"OnQuizUpdated != null) await OnQuizUpdated("}
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__false("false")
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__merge("merge")
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__true("true")
    method_13pj2z1_markquizasseen__entry(["MarkQuizAsSeen entry"])
    method_13pj2z1_markquizasseen__implicit_return(["return"])
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__condition -->|continue| method_13pj2z1_markquizasseen__action_38_guard_clause_38__false
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__condition -->|return| method_13pj2z1_markquizasseen__action_38_guard_clause_38__true
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__false -->|next| method_13pj2z1_markquizasseen__action_38_guard_clause_38__merge
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__merge -->|next| method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__condition
    method_13pj2z1_markquizasseen__action_38_guard_clause_38__true -->|next| method_13pj2z1_markquizasseen__action_38_guard_clause_38__merge
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__condition -->|continue| method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__false
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__condition -->|exit| method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__true
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__false -->|next| method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__merge
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__merge -->|next| method_13pj2z1_markquizasseen__action_39_assignment_39__linear
    method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__true -->|next| method_13pj2z1_markquizasseen__action_38_markquizasseen_guard_clause_38_0__merge
    method_13pj2z1_markquizasseen__action_39_assignment_39__linear -->|next| method_13pj2z1_markquizasseen__action_40_markquizasseen_await_40_2__await
    method_13pj2z1_markquizasseen__action_40_branch_40__condition -->|skip| method_13pj2z1_markquizasseen__action_40_branch_40__false
    method_13pj2z1_markquizasseen__action_40_branch_40__condition -->|invoke| method_13pj2z1_markquizasseen__action_40_branch_40__true
    method_13pj2z1_markquizasseen__action_40_branch_40__false -->|next| method_13pj2z1_markquizasseen__action_40_branch_40__merge
    method_13pj2z1_markquizasseen__action_40_branch_40__merge -->|next| method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__condition
    method_13pj2z1_markquizasseen__action_40_branch_40__true -->|next| method_13pj2z1_markquizasseen__action_40_branch_40__merge
    method_13pj2z1_markquizasseen__action_40_markquizasseen_await_40_2__await -->|next| method_13pj2z1_markquizasseen__action_40_branch_40__condition
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__condition -->|false| method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__false
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__condition -->|true| method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__true
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__false -->|next| method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__merge
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__merge -->|no parameters notifies subscribers that HasNewQuiz changed| method_13pj2z1_markquizasseen__call_40_OnQuizUpdated_invoke_
    method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__true -->|next| method_13pj2z1_markquizasseen__action_40_markquizasseen_branch_40_1__merge
    method_13pj2z1_markquizasseen__call_40_OnQuizUpdated_invoke_ -->|return| method_13pj2z1_markquizasseen__implicit_return
    method_13pj2z1_markquizasseen__entry -->|next| method_13pj2z1_markquizasseen__action_38_guard_clause_38__condition
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 4 unresolved jumps.
- Warning: control-flow: diagram method_13pj2z1_markquizasseen__fragment_diagram exceeds preferred complexity thresholds (21 nodes, 24 edges).
