Update app.py
Browse files
app.py
CHANGED
@@ -82,6 +82,18 @@ def save_responses_to_json(username, responses):
|
|
82 |
with open("UserChoices.json", "w") as json_file:
|
83 |
json.dump(user_data, json_file, indent=4)
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
# Streamlit component to display the quiz and handle responses
|
86 |
def show_mbti_quiz():
|
87 |
st.title('FlexTemp Personality Test')
|
@@ -127,14 +139,26 @@ def show_mbti_quiz():
|
|
127 |
st.write(f"Your MBTI type according to AI: {mbti_type_llm}")
|
128 |
except Exception as e:
|
129 |
st.error(f"Error occurred: {e}")
|
130 |
-
|
131 |
-
# Save responses and
|
132 |
save_responses_to_json(participant_name, responses)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
with open("UserChoices.json", "r") as json_file:
|
134 |
json_data = json_file.read()
|
135 |
-
|
136 |
st.download_button(
|
137 |
-
label="Download UserChoices",
|
138 |
data=json_data,
|
139 |
file_name="UserChoices.json",
|
140 |
mime="application/json"
|
|
|
82 |
with open("UserChoices.json", "w") as json_file:
|
83 |
json.dump(user_data, json_file, indent=4)
|
84 |
|
85 |
+
# Function to save personality results to Output.json
|
86 |
+
def save_personality_to_output_json(username, mbti_type_classic, mbti_type_llm):
|
87 |
+
output_data = {
|
88 |
+
"username": username,
|
89 |
+
"mbti_type_classic": mbti_type_classic,
|
90 |
+
"mbti_type_llm": mbti_type_llm
|
91 |
+
}
|
92 |
+
|
93 |
+
# Save to Output.json
|
94 |
+
with open("Output.json", "w") as json_file:
|
95 |
+
json.dump(output_data, json_file, indent=4)
|
96 |
+
|
97 |
# Streamlit component to display the quiz and handle responses
|
98 |
def show_mbti_quiz():
|
99 |
st.title('FlexTemp Personality Test')
|
|
|
139 |
st.write(f"Your MBTI type according to AI: {mbti_type_llm}")
|
140 |
except Exception as e:
|
141 |
st.error(f"Error occurred: {e}")
|
142 |
+
|
143 |
+
# Save responses and personality info to Output.json
|
144 |
save_responses_to_json(participant_name, responses)
|
145 |
+
save_personality_to_output_json(participant_name, mbti_type_classic, mbti_type_llm)
|
146 |
+
|
147 |
+
with open("Output.json", "r") as json_file:
|
148 |
+
json_data = json_file.read()
|
149 |
+
|
150 |
+
st.download_button(
|
151 |
+
label="Download Output.json",
|
152 |
+
data=json_data,
|
153 |
+
file_name="Output.json",
|
154 |
+
mime="application/json"
|
155 |
+
)
|
156 |
+
|
157 |
with open("UserChoices.json", "r") as json_file:
|
158 |
json_data = json_file.read()
|
159 |
+
|
160 |
st.download_button(
|
161 |
+
label="Download UserChoices.json",
|
162 |
data=json_data,
|
163 |
file_name="UserChoices.json",
|
164 |
mime="application/json"
|