Updated confirmation

This commit is contained in:
Gourav Kumar 2026-01-07 10:23:26 +05:30
parent aee4c33b30
commit 32796f996e

View File

@ -1,3 +1,4 @@
import datetime
import json
from nicegui import ui
@ -36,7 +37,7 @@ class SurveyState:
def save_to_json(self):
data = self.convert_to_json()
with open("results.json", "w") as f:
with open(f"results/response_{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.json", "w") as f:
json.dump(data, f, indent=4)
@ -270,28 +271,38 @@ def create_survey():
container.clear()
with container:
ui.label("Review Your Answers").classes("text-h4 mb-4")
# with ui.card().classes("w-full max-w-2xl p-6"):
# with ui.column().classes("w-full gap-2"):
# ui.label(f"**Frequency:** {state.frequency}").classes("text-md")
# ui.label(f"**Features:** {', '.join(state.selected_features)}")
with ui.card().classes("w-full max-w-2xl p-6"):
with ui.column().classes("w-full gap-2"):
ui.markdown(f"**Frequency**: {state.frequency}").classes("text-md")
feature_text = ", ".join(const.TASK_OPTIONS[i] for i in state.selected_features if i != "Others")
feature_text += f", {state.other_tasks}" if state.other_tasks else ""
ui.markdown(f"**Features**: {feature_text}").classes("text-md")
# ui.separator().classes("my-2")
# for f in state.selected_features:
# d = state.feature_feedback[f]
# ui.label(f"**{f}**: {d['rating']} Stars").classes("text-primary")
# if d["rating"] >= 4:
# ui.label(f"Likes: {d['likes'] or 'No comment'}").classes("ml-4 text-grey-8")
# else:
# ui.label(f"Improvements: {d['improvements']}").classes("ml-4 text-grey-8")
ui.markdown(f"**Suggestions**: {state.suggestions}").classes("text-md")
ui.markdown(f"**Priority**: {', '.join(state.priority_tasks)}").classes("text-md")
# ui.separator().classes("my-2")
# ui.label(
# f"**Age:** {state.age or 'N/A'} | **Gender:** {state.gender} | **Location:** {state.location}"
# )
ui.separator().classes("my-2")
# with ui.row().classes("w-full justify-between mt-8"):
# ui.button("Back to Edit", on_click=show_page_3).props("outline")
# ui.button("Confirm & Submit", on_click=handle_final_submit).classes("bg-green")
with ui.column().classes("w-full gap-2"):
ui.markdown("#### Your feedback for tasks")
for fe, fd in state.feature_feedback.items():
ui.markdown(f"##### {const.TASK_OPTIONS[fe]}")
if fd["completed_on_arq"] == "Yes":
ui.markdown(f"**Rating**: {fd['rating']}")
if fd["arq_helped"]:
ui.markdown(f"**Arq helped**: {', '.join(fd['arq_helped'])}")
if fd["excel_features"]:
ui.markdown(f"**Excel features used**: {', '.join(fd['excel_features'])}")
if fd["other_apps"]:
ui.markdown(f"**Other apps used**: {fd['other_apps']}")
if fd["abandoned_why"]:
ui.markdown(f"**Task abandoned becuase**: {', '.join(fd['abandoned_why'])}")
if fd["abandoned_why_others"]:
ui.markdown(f"**Task abandoned becuase**: {fd['abandoned_why_others']}")
with ui.row().classes("w-full justify-between mt-8"):
ui.button("Back to Edit", on_click=show_page_3).props("outline")
ui.button("Confirm & Submit", on_click=handle_final_submit).classes("bg-green")
# --- FINAL PAGE: ACKNOWLEDGMENT ---
def handle_final_submit():