bparrino's picture
Update app.py
4340739 verified
import streamlit as st
import json
import time
import random
# Set page config
st.set_page_config(
page_title="Training Content Format Discovery",
page_icon="πŸŽ“",
layout="wide",
initial_sidebar_state="collapsed"
)
# Custom CSS
st.markdown("""
<style>
.main .block-container {
padding-top: 2rem;
padding-bottom: 2rem;
max-width: 1000px;
margin: 0 auto;
}
.stApp {
background-color: #f8f9fa;
}
.title-area {
text-align: center;
margin-bottom: 2rem;
}
.custom-subheader {
background-color: #f0f2f6;
padding: 10px;
border-radius: 5px;
margin-bottom: 10px;
font-weight: 600;
}
.results-container {
border: 1px solid #ddd;
border-radius: 5px;
padding: 20px;
background-color: white;
margin-bottom: 20px;
}
.format-card {
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 15px;
margin-bottom: 15px;
background-color: #fafafa;
}
.format-title {
font-size: 1.2rem;
font-weight: 600;
color: #2c3e50;
margin-bottom: 8px;
}
.format-description {
color: #5a6c7d;
margin-bottom: 10px;
}
.format-details {
font-size: 0.9rem;
color: #7f8c8d;
}
.match-score {
background-color: #e8f5e8;
color: #2d6a2d;
padding: 4px 8px;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 600;
float: right;
}
.stButton button {
width: 100%;
}
.footnote {
font-size: 0.8rem;
color: #6c757d;
margin-top: 2rem;
}
.settings-section {
background-color: #f8f9fa;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.examples-section {
background-color: #e9f7fe;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.placeholder-area {
border: 2px dashed #ddd;
border-radius: 10px;
padding: 40px;
text-align: center;
background-color: #f8f9fa;
color: #666;
}
</style>
""", unsafe_allow_html=True)
# Title and description
st.markdown("""
<div class="title-area">
<h1>Training Content Format Discovery πŸŽ“</h1>
<p>Find the perfect training content format for your audience, budget, and goals. Get personalized recommendations in seconds!</p>
</div>
""", unsafe_allow_html=True)
# Initialize session state
if "recommendations" not in st.session_state:
st.session_state["recommendations"] = None
if "analysis_history" not in st.session_state:
st.session_state["analysis_history"] = []
# Training content formats database
TRAINING_FORMATS = {
"video_tutorials": {
"name": "Video Tutorials",
"description": "Engaging visual content with step-by-step demonstrations",
"best_for": ["Visual learners", "Technical skills", "Software training"],
"budget": "Medium",
"production_time": "High",
"engagement": "High",
"scalability": "High",
"interaction": "Low",
"sample_link": "https://youtu.be/HPUWGE9B_UQ?si=a4vr6BL43eMCR9Th"
},
"powerpoint_presentations": {
"name": "PowerPoint Presentations",
"description": "Slide-based presentations for structured information delivery",
"best_for": ["Information sharing", "Concepts explanation", "Quick updates"],
"budget": "Very Low",
"production_time": "Low",
"engagement": "Low",
"scalability": "High",
"interaction": "Low"
},
"microlearning_modules": {
"name": "Microlearning Modules",
"description": "Bite-sized content focused on specific skills or concepts",
"best_for": ["Busy professionals", "Just-in-time learning", "Skill reinforcement"],
"budget": "Low",
"production_time": "Low",
"engagement": "Medium",
"scalability": "Very High",
"interaction": "Medium"
},
"elearning_courses": {
"name": "E-Learning Courses",
"description": "Comprehensive online courses with structured learning paths",
"best_for": ["Certification programs", "Comprehensive training", "Self-paced learning"],
"budget": "Medium",
"production_time": "High",
"engagement": "Medium",
"scalability": "Very High",
"interaction": "Medium"
},
"simulation_training": {
"name": "Simulation Training",
"description": "Virtual environments for safe practice of real-world scenarios",
"best_for": ["High-risk training", "Technical skills", "Safety training"],
"budget": "Very High",
"production_time": "Very High",
"engagement": "Very High",
"scalability": "Medium",
"interaction": "Very High"
},
"gamified_learning": {
"name": "Gamified Learning",
"description": "Game elements integrated into training content for motivation",
"best_for": ["Engagement challenges", "Younger audiences", "Skill practice"],
"budget": "High",
"production_time": "High",
"engagement": "Very High",
"scalability": "High",
"interaction": "High"
},
"mobile_learning": {
"name": "Mobile Learning",
"description": "Training content optimized for smartphones and tablets",
"best_for": ["Remote workforce", "Field training", "Accessibility"],
"budget": "Medium",
"production_time": "Medium",
"engagement": "Medium",
"scalability": "Very High",
"interaction": "Medium"
},
"blended_learning": {
"name": "Blended Learning",
"description": "Combination of online and in-person training methods",
"best_for": ["Comprehensive programs", "Varied learning styles", "Flexibility"],
"budget": "High",
"production_time": "High",
"engagement": "High",
"scalability": "Medium",
"interaction": "High"
},
"webinar_series": {
"name": "Webinar Series",
"description": "Live or recorded online presentations with Q&A sessions",
"best_for": ["Expert knowledge sharing", "Large audiences", "Thought leadership"],
"budget": "Low",
"production_time": "Low",
"engagement": "Medium",
"scalability": "Very High",
"interaction": "Medium"
},
"pdf_guides": {
"name": "PDF Guides & Manuals",
"description": "Downloadable documents with detailed instructions and references",
"best_for": ["Reference materials", "Policy training", "Quick deployment"],
"budget": "Very Low",
"production_time": "Low",
"engagement": "Low",
"scalability": "Very High",
"interaction": "Very Low"
}
}
# Scoring algorithm
def calculate_format_scores(audience_type, budget, objectives, goals, timeline, interaction_level):
scores = {}
for format_id, format_data in TRAINING_FORMATS.items():
score = 0
# Budget matching
budget_map = {"Very Low": 1, "Low": 2, "Medium": 3, "High": 4, "Very High": 5}
user_budget = budget_map.get(budget, 3)
format_budget = budget_map.get(format_data["budget"], 3)
if format_budget <= user_budget:
score += 20
else:
score -= (format_budget - user_budget) * 5
# Timeline matching
timeline_map = {"ASAP (1-2 weeks)": 1, "1 month": 2, "2-3 months": 3, "3+ months": 4}
user_timeline = timeline_map.get(timeline, 3)
production_map = {"Low": 1, "Medium": 2, "High": 3, "Very High": 4}
format_production = production_map.get(format_data["production_time"], 2)
if format_production <= user_timeline:
score += 15
else:
score -= (format_production - user_timeline) * 5
# Audience type matching
audience_matches = {
"Corporate employees": ["elearning_courses", "webinar_series", "blended_learning", "mobile_learning", "powerpoint_presentations"],
"Technical professionals": ["video_tutorials", "simulation_training", "elearning_courses"],
"Sales teams": ["gamified_learning", "mobile_learning", "powerpoint_presentations", "microlearning_modules"],
"Remote workers": ["mobile_learning", "elearning_courses", "webinar_series", "microlearning_modules"],
"New hires": ["blended_learning", "elearning_courses", "powerpoint_presentations", "video_tutorials"],
"Managers/Leaders": ["webinar_series", "blended_learning", "powerpoint_presentations", "elearning_courses"],
"External customers": ["video_tutorials", "webinar_series", "pdf_guides", "elearning_courses"],
"Field workers": ["mobile_learning", "microlearning_modules", "video_tutorials", "pdf_guides"]
}
if format_id in audience_matches.get(audience_type, []):
score += 25
# Objectives matching
objective_matches = {
"Skill development": ["simulation_training", "video_tutorials", "gamified_learning", "elearning_courses"],
"Compliance training": ["elearning_courses", "pdf_guides", "webinar_series", "blended_learning", "powerpoint_presentations"],
"Product knowledge": ["video_tutorials", "elearning_courses", "webinar_series", "mobile_learning", "powerpoint_presentations"],
"Onboarding": ["blended_learning", "elearning_courses", "video_tutorials", "powerpoint_presentations"],
"Certification prep": ["elearning_courses", "blended_learning", "webinar_series", "pdf_guides"],
"Behavior change": ["gamified_learning", "simulation_training", "microlearning_modules", "video_tutorials"],
"Knowledge sharing": ["webinar_series", "pdf_guides", "elearning_courses", "video_tutorials", "powerpoint_presentations"]
}
for objective in objectives:
if format_id in objective_matches.get(objective, []):
score += 15
# Interaction level matching
interaction_map = {"Low": 1, "Medium": 2, "High": 3, "Very High": 4}
user_interaction = interaction_map.get(interaction_level, 2)
format_interaction = interaction_map.get(format_data["interaction"], 2)
if abs(format_interaction - user_interaction) <= 1:
score += 10
# Goals matching
goal_matches = {
"Reduce training costs": ["microlearning_modules", "pdf_guides", "webinar_series", "elearning_courses", "powerpoint_presentations"],
"Improve engagement": ["gamified_learning", "simulation_training", "video_tutorials", "mobile_learning"],
"Scale training globally": ["elearning_courses", "mobile_learning", "webinar_series", "microlearning_modules"],
"Faster deployment": ["microlearning_modules", "pdf_guides", "webinar_series", "mobile_learning", "powerpoint_presentations"],
"Better retention": ["gamified_learning", "simulation_training", "microlearning_modules", "video_tutorials"],
"Measurable results": ["elearning_courses", "gamified_learning", "simulation_training", "blended_learning"]
}
for goal in goals:
if format_id in goal_matches.get(goal, []):
score += 10
scores[format_id] = max(0, min(100, score))
return scores
# Main content
col1, col2 = st.columns([1, 1])
with col1:
st.markdown('<div class="custom-subheader">Tell Us About Your Training Needs</div>', unsafe_allow_html=True)
# Audience Type
audience_type = st.selectbox(
"Who is your target audience?",
[
"Corporate employees",
"Technical professionals",
"Sales teams",
"Remote workers",
"New hires",
"Managers/Leaders",
"External customers",
"Field workers"
],
help="Select the primary audience for your training content"
)
# Budget
budget = st.select_slider(
"What's your budget range?",
options=["Very Low", "Low", "Medium", "High", "Very High"],
value="Medium",
help="Consider development, production, and deployment costs"
)
# Timeline
timeline = st.selectbox(
"When do you need this deployed?",
[
"ASAP (1-2 weeks)",
"1 month",
"2-3 months",
"3+ months"
],
index=1,
help="How quickly do you need the training content ready?"
)
# Objectives
objectives = st.multiselect(
"What are your main training objectives?",
[
"Skill development",
"Compliance training",
"Product knowledge",
"Onboarding",
"Certification prep",
"Behavior change",
"Knowledge sharing"
],
help="Select all that apply (you can choose multiple)"
)
# Goals
goals = st.multiselect(
"What are your key goals?",
[
"Reduce training costs",
"Improve engagement",
"Scale training globally",
"Faster deployment",
"Better retention",
"Measurable results"
],
help="What outcomes are most important to you?"
)
# Interaction Level
interaction_level = st.select_slider(
"How much interaction do you want?",
options=["Low", "Medium", "High", "Very High"],
value="Medium",
help="Level of learner interaction and engagement"
)
# Additional Context
additional_context = st.text_area(
"Any additional context or specific requirements?",
placeholder="e.g., Must work on mobile devices, need multilingual support, integration with LMS required...",
height=80,
help="Tell us about any special requirements or constraints"
)
# Examples for inspiration
with st.expander("Need help? See example scenarios", expanded=False):
st.markdown('<div class="examples-section">', unsafe_allow_html=True)
example_scenarios = [
{
"title": "New Employee Onboarding",
"audience": "New hires",
"budget": "Medium",
"objectives": ["Onboarding", "Skill development"],
"goals": ["Better retention", "Faster deployment"]
},
{
"title": "Sales Team Product Training",
"audience": "Sales teams",
"budget": "High",
"objectives": ["Product knowledge", "Skill development"],
"goals": ["Improve engagement", "Measurable results"]
},
{
"title": "Compliance Training Rollout",
"audience": "Corporate employees",
"budget": "Low",
"objectives": ["Compliance training"],
"goals": ["Scale training globally", "Reduce training costs"]
}
]
for i, example in enumerate(example_scenarios):
st.markdown(f"**{example['title']}**")
st.markdown(f"*Audience: {example['audience']}, Budget: {example['budget']}, Objectives: {', '.join(example['objectives'])}, Goals: {', '.join(example['goals'])}*")
st.markdown("---")
st.markdown('</div>', unsafe_allow_html=True)
# Generate recommendations button
generate_button = st.button(
"🎯 Get My Recommendations",
disabled=not objectives or not goals,
use_container_width=True
)
if not objectives:
st.info("Please select at least one training objective")
elif not goals:
st.info("Please select at least one goal")
# Display recommendations
with col2:
st.markdown('<div class="custom-subheader">Your Personalized Recommendations</div>', unsafe_allow_html=True)
if generate_button and objectives and goals:
with st.spinner("Analyzing your requirements and matching formats..."):
# Simulate processing time
time.sleep(2)
# Calculate scores
scores = calculate_format_scores(
audience_type, budget, objectives, goals, timeline, interaction_level
)
# Sort by score
sorted_formats = sorted(scores.items(), key=lambda x: x[1], reverse=True)
# Store recommendations
st.session_state["recommendations"] = {
"formats": sorted_formats,
"params": {
"audience": audience_type,
"budget": budget,
"timeline": timeline,
"objectives": objectives,
"goals": goals,
"interaction": interaction_level,
"context": additional_context
}
}
st.success("βœ… Analysis complete! Here are your recommendations:")
if st.session_state["recommendations"] is not None:
recommendations = st.session_state["recommendations"]
st.markdown('<div class="results-container">', unsafe_allow_html=True)
# Show top 5 recommendations
for i, (format_id, score) in enumerate(recommendations["formats"][:5]):
format_data = TRAINING_FORMATS[format_id]
st.markdown(f'<div class="format-card">', unsafe_allow_html=True)
st.markdown(f'<div class="format-title">{format_data["name"]} <span class="match-score">{score}% Match</span></div>', unsafe_allow_html=True)
st.markdown(f'<div class="format-description">{format_data["description"]}</div>', unsafe_allow_html=True)
# Add sample link if available
if "sample_link" in format_data:
st.markdown(f'<a href="{format_data["sample_link"]}" target="_blank" style="color: #1f77b4; text-decoration: none;">πŸ”— View Sample</a>', unsafe_allow_html=True)
st.markdown("<br>", unsafe_allow_html=True)
# Show key details
st.markdown(f"""
<div class="format-details">
<strong>Best for:</strong> {', '.join(format_data['best_for'])}<br>
<strong>Budget:</strong> {format_data['budget']} |
<strong>Production Time:</strong> {format_data['production_time']} |
<strong>Engagement:</strong> {format_data['engagement']}
</div>
""", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
# Show analysis summary
with st.expander("View Analysis Summary", expanded=False):
st.markdown("**Your Requirements:**")
st.write(f"- **Audience:** {recommendations['params']['audience']}")
st.write(f"- **Budget:** {recommendations['params']['budget']}")
st.write(f"- **Timeline:** {recommendations['params']['timeline']}")
st.write(f"- **Objectives:** {', '.join(recommendations['params']['objectives'])}")
st.write(f"- **Goals:** {', '.join(recommendations['params']['goals'])}")
st.write(f"- **Interaction Level:** {recommendations['params']['interaction']}")
if recommendations['params']['context']:
st.write(f"- **Additional Context:** {recommendations['params']['context']}")
# Action buttons
col_b1, col_b2 = st.columns(2)
with col_b1:
# Generate report
report_data = {
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
"recommendations": recommendations
}
report_json = json.dumps(report_data, indent=2)
st.download_button(
label="πŸ“Š Download Report",
data=report_json,
file_name=f"training_recommendations_{int(time.time())}.json",
mime="application/json",
use_container_width=True
)
with col_b2:
# New analysis button
if st.button("πŸ”„ New Analysis", use_container_width=True):
st.session_state["recommendations"] = None
st.rerun()
else:
# Placeholder
st.markdown("""
<div class="placeholder-area">
<h3>🎯 Your Recommendations Will Appear Here</h3>
<p>Fill out your training requirements and click 'Get My Recommendations' to discover the best content formats for your needs.</p>
</div>
""", unsafe_allow_html=True)
# Footer
st.markdown("""
<div class="footnote">
<p><strong>Note:</strong> Recommendations are based on industry best practices and typical use cases. Consider piloting your chosen format with a small group before full deployment. Results may vary based on your specific context and constraints.</p>
</div>
""", unsafe_allow_html=True)