File size: 2,213 Bytes
9c8703c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from dataclasses import dataclass
from typing import List, Dict, Any

@dataclass
class SurveyResponse:
    def __init__(self, 
                 major: str, 
                 age_group: str, 
                 class_subject: str, 
                 exhibits: List[str], 
                 tour_length_minutes: int, 
                 time_period: List[str], 
                 materiality: List[str], 
                 region: List[str], 
                 colour: List[str],
                 purpose: List[str],
                 themes: List[str],
                 additional_interests: str,
                 additional_notes: str) -> None:
        self.major = major
        self.age_group = age_group
        self.class_subject = class_subject
        self.exhibits = exhibits
        self.tour_length_minutes = tour_length_minutes
        self.time_period = time_period
        self.materiality = materiality
        self.region = region
        self.colour = colour
        self.purpose = purpose
        self.themes = themes
        self.additional_interests = additional_interests
        self.additional_notes = additional_notes

@dataclass
class Preferences:
    exhibits: List[str]
    time_period: List[str]
    materiality: List[str]
    region: List[str]
    colour: List[str]
    purpose: List[str]
    themes: List[str]
    additional_interests: List[str]
        
    def count_preferences(self) -> int:
        total = 0
        for field, value in self.__dict__.items():
            if field == "additional_interests":
                continue  # skip this field
            if isinstance(value, list) and value:
                total += len(value)
        return total
    
def format_survey_context(survey: Dict[str, Any]) -> str:
    return f"""
This museum tour is for a volunteer guide majoring in {survey['major']}.
The audience is students aged {survey['age_group']} in a {survey['class_subject']} class.
The class is interested in: {", ".join(survey['topics_of_interest'])}.
Please focus on the following exhibit: {", ".join(survey['exhibit_name'])}.
The tour will be approximately {survey['tour_length_minutes']} minutes long.

Additional guide notes: {survey['additional_notes']}
""".strip()