careerv3 / strengths.py
ombhojane's picture
Upload 88 files
8d404bc verified
import streamlit as st
import json
def app():
st.header("Let's explore your strengths.")
# Initialize session state for holding responses if not already present
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'] = {}
# Strengths Exercise 1 - Self Assessment
display_strength_exercise_1()
# Strengths Exercise 2 - Partner Assessment
display_strength_exercise_2()
# Save Button
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")
# Load the 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
# Display strength exercise 1 responses
st.subheader("Strength Exercise 1 - Self Assessment Responses")
for question, response in responses.get("strength_responses", {}).items():
st.markdown(f"**{question}**: {response}")
# Display strength exercise 2 responses
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' # You can adjust the file name as needed
with open(file_path, 'w') as file:
json.dump(data_to_save, file)
st.success("Data saved successfully!")
if __name__ == "__main__":
app()