import streamlit as st import sqlite3 from datetime import datetime import pandas as pd import time class FeedbackManager: def __init__(self): self.db_path = "feedback/feedback.db" self.setup_database() def setup_database(self): """Create feedback table if it doesn't exist""" conn = sqlite3.connect(self.db_path) c = conn.cursor() c.execute(''' CREATE TABLE IF NOT EXISTS feedback ( id INTEGER PRIMARY KEY AUTOINCREMENT, rating INTEGER, usability_score INTEGER, feature_satisfaction INTEGER, missing_features TEXT, improvement_suggestions TEXT, user_experience TEXT, timestamp DATETIME ) ''') conn.commit() conn.close() def save_feedback(self, feedback_data): """Save feedback to database""" conn = sqlite3.connect(self.db_path) c = conn.cursor() c.execute(''' INSERT INTO feedback ( rating, usability_score, feature_satisfaction, missing_features, improvement_suggestions, user_experience, timestamp ) VALUES (?, ?, ?, ?, ?, ?, ?) ''', ( feedback_data['rating'], feedback_data['usability_score'], feedback_data['feature_satisfaction'], feedback_data['missing_features'], feedback_data['improvement_suggestions'], feedback_data['user_experience'], datetime.now() )) conn.commit() conn.close() def get_feedback_stats(self): """Get feedback statistics""" conn = sqlite3.connect(self.db_path) df = pd.read_sql_query("SELECT * FROM feedback", conn) conn.close() if df.empty: return { 'avg_rating': 0, 'avg_usability': 0, 'avg_satisfaction': 0, 'total_responses': 0 } return { 'avg_rating': df['rating'].mean(), 'avg_usability': df['usability_score'].mean(), 'avg_satisfaction': df['feature_satisfaction'].mean(), 'total_responses': len(df) } def render_feedback_form(self): """Render the feedback form""" st.markdown(""" """, unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) st.markdown('

📝 Share Your Feedback

', unsafe_allow_html=True) # Overall Rating st.markdown('
', unsafe_allow_html=True) st.markdown('', unsafe_allow_html=True) rating = st.slider("Overall Rating", 1, 5, 5, help="Rate your overall experience with the app", label_visibility="collapsed") st.markdown(f'
{"⭐" * rating}
', unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) # Usability Score st.markdown('
', unsafe_allow_html=True) st.markdown('', unsafe_allow_html=True) usability_score = st.slider("Usability Score", 1, 5, 5, help="Rate the app's ease of use", label_visibility="collapsed") st.markdown(f'
{"⭐" * usability_score}
', unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) # Feature Satisfaction st.markdown('
', unsafe_allow_html=True) st.markdown('', unsafe_allow_html=True) feature_satisfaction = st.slider("Feature Satisfaction", 1, 5, 5, help="Rate your satisfaction with the app's features", label_visibility="collapsed") st.markdown(f'
{"⭐" * feature_satisfaction}
', unsafe_allow_html=True) st.markdown('
', unsafe_allow_html=True) # Text Feedback st.markdown('
', unsafe_allow_html=True) st.markdown('', unsafe_allow_html=True) missing_features = st.text_area("Missing Features", placeholder="Share your feature requests...", label_visibility="collapsed") st.markdown('', unsafe_allow_html=True) improvement_suggestions = st.text_area("Improvement Suggestions", placeholder="Your suggestions for improvement...", label_visibility="collapsed") st.markdown('', unsafe_allow_html=True) user_experience = st.text_area("User Experience", placeholder="Share your experience with us...", label_visibility="collapsed") st.markdown('
', unsafe_allow_html=True) # Submit Button if st.button("Submit Feedback", key="submit_feedback"): try: # Create progress bar progress_bar = st.progress(0) status_text = st.empty() # Simulate processing with animation for i in range(100): progress_bar.progress(i + 1) if i < 30: status_text.text("Processing feedback... 📝") elif i < 60: status_text.text("Analyzing responses... 🔍") elif i < 90: status_text.text("Saving to database... 💾") else: status_text.text("Finalizing... ✨") time.sleep(0.01) # Save feedback feedback_data = { 'rating': rating, 'usability_score': usability_score, 'feature_satisfaction': feature_satisfaction, 'missing_features': missing_features, 'improvement_suggestions': improvement_suggestions, 'user_experience': user_experience } self.save_feedback(feedback_data) # Clear progress elements progress_bar.empty() status_text.empty() # Show success message with animation success_container = st.empty() success_container.markdown("""

Thank You! 🎉

Your feedback helps us improve Smart Resume AI

""", unsafe_allow_html=True) # Show balloons animation st.balloons() # Keep success message visible time.sleep(2) except Exception as e: st.error(f"Error submitting feedback: {str(e)}") def render_feedback_stats(self): """Render feedback statistics""" stats = self.get_feedback_stats() st.markdown("""

Feedback Overview 📊

""", unsafe_allow_html=True) cols = st.columns(4) metrics = [ {"label": "Total Responses", "value": f"{stats['total_responses']:,}", "delta": "↗"}, {"label": "Avg Rating", "value": f"{stats['avg_rating']:.1f}/5.0", "delta": "⭐"}, {"label": "Usability Score", "value": f"{stats['avg_usability']:.1f}/5.0", "delta": "🎯"}, {"label": "Satisfaction", "value": f"{stats['avg_satisfaction']:.1f}/5.0", "delta": "😊"} ] for col, metric in zip(cols, metrics): col.markdown(f"""
{metric['label']}
{metric['value']}
{metric['delta']}
""", unsafe_allow_html=True)