File size: 1,289 Bytes
59d9f71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""

Solution Retrieval Service

--------------------------

Fetches detailed solution content by solution_id.

Used after teacher selects a solution preview.



Theme 1 rules:

- No re-scoring

- No re-filtering

- Pure lookup

"""

from typing import Dict, Optional
from decision_engine.solution_loader import load_solutions

# <--- DEBUG START --->
print("\n>>> DEBUG: [Import] decision_engine/solution_service.py loaded")
# <--- DEBUG END --->

# Load once
SOLUTION_LIBRARY = load_solutions()

# Build fast lookup map
_SOLUTION_MAP = {s["solution_id"]: s for s in SOLUTION_LIBRARY}


def get_solution_details(solution_id: str) -> Optional[Dict]:
    """

    Returns the detailed solution block for a given solution_id.

    """
    # <--- DEBUG START --->
    print(f">>> DEBUG: [Solution Service] Fetching details for ID: '{solution_id}'")
    # <--- DEBUG END --->

    solution = _SOLUTION_MAP.get(solution_id)
    if not solution:
        print(f">>> DEBUG: [Solution Service] ❌ ID '{solution_id}' not found in library.")
        return None

    return {
        "solution_id": solution["solution_id"],
        "title": solution["preview"]["title"],
        "details": solution["details"],
        "pedagogy": solution.get("pedagogy", {}),
    }