|
import streamlit as st |
|
import json |
|
|
|
def app(): |
|
st.header("Let's explore your strengths.") |
|
|
|
|
|
if 'strength_responses' not in st.session_state: |
|
st.session_state['strength_responses'] = {} |
|
if 'stories_feedback' not in st.session_state: |
|
st.session_state['stories_feedback'] = {} |
|
if 'network_feedback' not in st.session_state: |
|
st.session_state['network_feedback'] = {} |
|
|
|
|
|
display_strength_exercise_1() |
|
|
|
|
|
display_strength_exercise_2() |
|
|
|
|
|
|
|
if st.button('Save Data'): |
|
save_data_to_file() |
|
|
|
def display_strength_exercise_1(): |
|
st.subheader('Strength Exercise 1 - Self Assessment') |
|
questions = [ |
|
"What do you enjoy the most?", |
|
"What am I called on to do most often?", |
|
"What do I do best?", |
|
"What advice or expertise do others seek from me?", |
|
] |
|
for question in questions: |
|
st.session_state.strength_responses[question] = st.text_input(question, key=question) |
|
|
|
def display_strength_exercise_2(): |
|
st.subheader('Strength Exercise 2 - Partner Assessment') |
|
for i in range(1, 3): |
|
story_key = f'story_{i}' |
|
feedback_key = f'feedback_{i}' |
|
with st.expander(f"Story {i} & Feedback"): |
|
st.session_state.stories_feedback[story_key] = st.text_area(f"Story {i}", key=story_key) |
|
st.session_state.stories_feedback[feedback_key] = st.text_area(f"Feedback for Story {i}", key=feedback_key) |
|
|
|
|
|
|
|
def display_strength_responses(): |
|
st.header("Strength Responses") |
|
|
|
|
|
file_path = 'strength_responses.json' |
|
try: |
|
with open(file_path, 'r') as file: |
|
responses = json.load(file) |
|
except FileNotFoundError: |
|
st.write("No strength responses found.") |
|
return |
|
|
|
|
|
st.subheader("Strength Exercise 1 - Self Assessment Responses") |
|
for question, response in responses.get("strength_responses", {}).items(): |
|
st.markdown(f"**{question}**: {response}") |
|
|
|
|
|
st.subheader("Strength Exercise 2 - Partner Assessment Responses") |
|
for key, text in responses.get("stories_feedback", {}).items(): |
|
st.markdown(f"**{key.replace('_', ' ').capitalize()}**: {text}") |
|
|
|
|
|
def save_data_to_file(): |
|
data_to_save = { |
|
"strength_responses": st.session_state.strength_responses, |
|
"stories_feedback": st.session_state.stories_feedback, |
|
} |
|
file_path = 'strength_responses.json' |
|
with open(file_path, 'w') as file: |
|
json.dump(data_to_save, file) |
|
st.success("Data saved successfully!") |
|
|
|
|
|
if __name__ == "__main__": |
|
app() |
|
|