diff --git a/frontend/src/lib/components/ChildrenFeedback.svelte b/frontend/src/lib/components/ChildrenFeedback.svelte
index 0d8c92e4..f03b154f 100644
--- a/frontend/src/lib/components/ChildrenFeedback.svelte
+++ b/frontend/src/lib/components/ChildrenFeedback.svelte
@@ -144,16 +144,21 @@ const promise = setup();
{milestongeGroups[aid][Number(mid)].text[$locale].title}
{#if Number(score) > 0}
+
{$_("childData.recommendOk")}
-
+
{:else if Number(score) === 0}
+
{$_("childData.recommendWatch")}
+
{:else}
+
{$_("childData.recommmendHelp")}
+
{/if}
{/each}
diff --git a/frontend/src/lib/components/DataDisplay/DetailedFeedbackModal.svelte b/frontend/src/lib/components/DataDisplay/DetailedFeedbackModal.svelte
new file mode 100644
index 00000000..5309e67f
--- /dev/null
+++ b/frontend/src/lib/components/DataDisplay/DetailedFeedbackModal.svelte
@@ -0,0 +1,63 @@
+
+
+
+{#await promise}
+
+
{$_("childData.loadingMessage")}
+
+{:then detailedFeedback}
+{#if showAlert }
+
+{/if}
+
+
+ {#each Object.keys(detailedFeedback) as key}
+
+ {key}
+ {detailedFeedback[key]}
+
+ {/each}
+
+
+{:catch error}
+
+{/await}
diff --git a/mondey_backend/src/mondey_backend/routers/scores.py b/mondey_backend/src/mondey_backend/routers/scores.py
index 223d9ab3..1dcf0be5 100644
--- a/mondey_backend/src/mondey_backend/routers/scores.py
+++ b/mondey_backend/src/mondey_backend/routers/scores.py
@@ -11,6 +11,7 @@
from ..models.children import Child
from ..models.milestones import MilestoneAgeScore
from ..models.milestones import MilestoneAgeScores
+from ..models.milestones import MilestoneAnswer
from ..models.milestones import MilestoneAnswerSession
from ..models.milestones import MilestoneGroupStatistics
from .utils import _session_has_expired
@@ -79,6 +80,29 @@ def leq(val: float, lim: float) -> bool:
return TrafficLight.green.value
+def compute_detailed_feedback_for_answers(
+ session: SessionDep,
+ answers: list[MilestoneAnswer],
+ statistics: dict[int, MilestoneAgeScores],
+ age: int,
+) -> dict[int, int]:
+ milestonegroup_result: dict[int, int] = {} # type: ignore
+ for answer in answers:
+ if statistics.get(answer.milestone_id) is None: # type: ignore
+ stat = calculate_milestone_statistics_by_age(
+ session,
+ answer.milestone_id, # type: ignore
+ ) # type: ignore
+
+ statistics[answer.milestone_id] = stat # type: ignore
+ feedback = compute_feedback_simple(
+ statistics[answer.milestone_id].scores[age], # type: ignore
+ answer.answer, # type: ignore
+ ) # type: ignore
+ milestonegroup_result[answer.milestone_id] = feedback # type: ignore
+ return milestonegroup_result
+
+
def compute_detailed_milestonegroup_feedback_for_answersession(
session: SessionDep,
answersession: MilestoneAnswerSession,
@@ -99,20 +123,9 @@ def compute_detailed_milestonegroup_feedback_for_answersession(
result: dict[int, dict[int, int]] = {}
statistics: dict[int, MilestoneAgeScores] = {}
for milestonegroup_id, answers in filtered_answers.items():
- milestonegroup_result: dict[int, int] = result.get(milestonegroup_id, {}) # type: ignore
- for answer in answers:
- if statistics.get(answer.milestone_id) is None: # type: ignore
- stat = calculate_milestone_statistics_by_age(
- session,
- answer.milestone_id, # type: ignore
- ) # type: ignore
-
- statistics[answer.milestone_id] = stat # type: ignore
- feedback = compute_feedback_simple(
- statistics[answer.milestone_id].scores[age], # type: ignore
- answer.answer, # type: ignore
- ) # type: ignore
- milestonegroup_result[answer.milestone_id] = feedback # type: ignore
+ milestonegroup_result = compute_detailed_feedback_for_answers(
+ session, answers, statistics, age
+ )
result[milestonegroup_id] = milestonegroup_result # type: ignore
return result
diff --git a/mondey_backend/src/mondey_backend/routers/users.py b/mondey_backend/src/mondey_backend/routers/users.py
index 03b67381..d07c4e75 100644
--- a/mondey_backend/src/mondey_backend/routers/users.py
+++ b/mondey_backend/src/mondey_backend/routers/users.py
@@ -24,12 +24,14 @@
from ..models.users import UserRead
from ..models.users import UserUpdate
from ..users import fastapi_users
+from .scores import compute_detailed_feedback_for_answers
from .scores import compute_detailed_milestonegroup_feedback_for_answersession
from .scores import compute_summary_milestonegroup_feedback_for_answersession
from .utils import _session_has_expired
from .utils import add
from .utils import child_image_path
from .utils import get
+from .utils import get_child_age_in_months
from .utils import get_db_child
from .utils import get_milestonegroups_for_answersession
from .utils import get_or_create_current_milestone_answer_session
@@ -270,6 +272,34 @@ def get_milestonegroups_for_session(
answersession = get(session, MilestoneAnswerSession, answersession_id)
return get_milestonegroups_for_answersession(session, answersession)
+ @router.get(
+ "/feedback/answersession={answersession_id}/milestonegroup={milestonegroup_id}/details",
+ response_model=dict[int, int],
+ )
+ def get_detailed_feedback_for_milestonegroup(
+ session: SessionDep,
+ current_active_user: CurrentActiveUserDep,
+ answersession_id: int,
+ milestonegroup_id: int,
+ ) -> dict[int, int]:
+ answersession = get(session, MilestoneAnswerSession, answersession_id)
+ m = get(session, MilestoneGroupPublic, milestonegroup_id)
+ answers = [
+ answersession.answers[ms.id]
+ for ms in m.milestones
+ if ms.id in answersession.answers and ms.id is not None
+ ]
+ child = get_db_child(session, current_active_user, answersession.child_id)
+ age = get_child_age_in_months(child, answersession.created_at)
+ statistics = {} # type: ignore
+ feedback = compute_detailed_feedback_for_answers(
+ session,
+ answers,
+ statistics,
+ age,
+ )
+ return feedback
+
@router.get(
"/feedback/answersession={answersession_id}/summary",
response_model=dict[int, int],