from fastapi import FastAPI, Form app = FastAPI(docs_url="/docs", openapi_url="/openapi.json") def generate_score(value): if value == "Strongly Agree": return 5 elif value == "Agree": return 4 elif value == "Neutral": return 3 elif value == "Disagree": return 2 elif value == "Strongly Disagree": return 1 def calculate_total(list): total = 0 for score in list: total = total + score return total @app.post("/quizjson") def quiz(user_data : dict): final_text = "" ambivalence_score = [] ambivalence_score.append(generate_score(user_data["Ambivalence1"])) ambivalence_score.append(generate_score(user_data["Ambivalence2"])) ambivalence_score.append(generate_score(user_data["Ambivalence3"])) ambivalence_total = calculate_total(ambivalence_score) if ambivalence_total>=3 and ambivalence_total<=7: final_text = final_text + "You exhibit few characteristics of Ambivalence. This suggests that you are generally decisive and clear about your goals and directions. You tend to make decisions confidently and are less likely to be plagued by doubts or indecisiveness. This clarity can be a significant strength, especially in situations that require quick and firm decision-making. \n\n" elif ambivalence_total>=8 and ambivalence_total<=11: final_text = final_text + "Your results indicate a moderate alignment with Ambivalence. While you can be decisive, you may sometimes find yourself hesitating when faced with multiple options. This can be due to a desire to explore all possibilities thoroughly or a fear of making the wrong choice. Developing strategies to trust your judgment more could further enhance your decision-making process. \n\n" elif ambivalence_total>=12 and ambivalence_total<=15: final_text = final_text + "You have a strong alignment with Ambivalence, suggesting that decision-making can be a significant challenge for you. You might often feel stuck when presented with choices, worried about missing out on the best option. This can lead to analysis paralysis. Embracing techniques to boost your decision-making confidence, such as setting time limits for decisions or seeking input from trusted sources, could be highly beneficial. \n\n" alienation_score = [] alienation_score.append(generate_score(user_data["Alienation1"])) alienation_score.append(generate_score(user_data["Alienation2"])) alienation_score.append(generate_score(user_data["Alienation3"])) alienation_total = calculate_total(alienation_score) if alienation_total>=3 and alienation_total<=7: final_text = final_text + "Your low score in Alienation indicates that you feel connected to your goals and dreams and believe in their attainability. You likely have a support system and resources, or at least a clear path to acquiring them, which you feel can help you achieve your aspirations. This sense of connection and possibility is a powerful driver in your personal and professional life. \n\n" elif alienation_total>=8 and alienation_total<=11: final_text = final_text + "With a moderate score in Alienation, you may sometimes feel disconnected from your dreams or doubt their feasibility. While you have aspirations, there might be moments when you question your ability to achieve them or feel that you lack the necessary support. Identifying and cultivating resources and relationships that align with your goals can enhance your sense of connection and possibility. \n\n" elif alienation_total>=12 and alienation_total<=15: final_text = final_text + "A high score in Alienation suggests that you often feel detached from your goals and unsure about their achievability. There might be a sense of lacking the resources or support needed to reach your aspirations. It's important to explore these feelings and consider ways to bridge the gap between your current reality and your dreams. This could involve reevaluating your goals, seeking new support networks, or developing a more practical approach to achieving your aspirations. \n\n" abandonment_score = [] abandonment_score.append(generate_score(user_data["Abandonment1"])) abandonment_score.append(generate_score(user_data["Abandonment2"])) abandonment_score.append(generate_score(user_data["Abandonment3"])) abandonment_total = calculate_total(abandonment_score) if abandonment_total>=3 and abandonment_total<=7: final_text = final_text + "Scoring low in Abandonment indicates that you are generally confident and willing to take risks. You do not let the fear of failure or disappointment hold you back. This can be a significant asset, especially in situations that require boldness and initiative. Your willingness to try new things and face potential setbacks head-on is a valuable trait in both personal and professional contexts. \n\n" elif abandonment_total>=8 and abandonment_total<=11: final_text = final_text + "With a moderate score in Abandonment, you might occasionally struggle with the fear of failure or disappointment. While you are willing to take risks, these fears can sometimes hold you back from fully committing to new endeavors. Balancing caution with courage and learning to embrace potential failures as learning opportunities could further empower your decision-making and risk-taking abilities. \n\n" elif abandonment_total>=12 and abandonment_total<=15: final_text = final_text + "Your high alignment with Abandonment suggests that fear of failure and disappointment significantly influences your actions. You may often find yourself avoiding new experiences or challenges due to these fears. Building resilience and finding strategies to cope with potential setbacks can be very beneficial. Consider seeking support to boost your confidence and help you embrace challenges more readily. \n\n" abundance_score = [] abundance_score.append(generate_score(user_data["Abundance1"])) abundance_score.append(generate_score(user_data["Abundance2"])) abundance_score.append(generate_score(user_data["Abundance3"])) abundance_total = calculate_total(abundance_score) if abundance_total>=3 and abundance_total<=7: final_text = final_text + "A low score in Abundance indicates that you may prefer structure and predictability over exploration and experimentation. You might find comfort in familiar environments and routines, which can provide stability and clarity. However, consider the benefits of occasionally stepping out of your comfort zone to explore new opportunities and ideas. \n\n" elif abundance_total>=8 and abundance_total<=11: final_text = final_text + "Scoring moderately in Abundance means you are open to new experiences and ideas, but you may also appreciate some level of predictability and structure. You can balance exploration with practicality, which is a valuable trait. Embracing this balance can lead to growth while still maintaining a sense of security. \n\n" elif abundance_total>=12 and abundance_total<=15: final_text = final_text + "With a high score in Abundance, you thrive in environments where exploration, experimentation, and risk-taking are involved. You are not afraid to delve into the unknown and embrace new opportunities. This adventurous spirit can lead to significant innovation and discovery. However, be mindful of maintaining a balance and not losing sight of your long-term goals amidst the excitement of new possibilities. \n\n" authority_score = [] authority_score.append(generate_score(user_data["Authority1"])) authority_score.append(generate_score(user_data["Authority2"])) authority_score.append(generate_score(user_data["Authority3"])) authority_total = calculate_total(authority_score) if authority_total>=3 and authority_total<=7: final_text = final_text + "With a low score in Authority, you may not have strong management or planning skills. Developing foresight and decision-making abilities, while also seeking guidance from mentors, could help advance your goals. \n\n" elif authority_total>=8 and authority_total<=11: final_text = final_text + "Your moderate alignment with Authority indicates some leadership and preparation skills but potential difficulty acting confidently on your own judgment. Cultivating trust in your own decisions while also using input from your team can be beneficial. \n\n" elif authority_total>=12 and authority_total<=15: final_text = final_text + "Scoring highly in Authority demonstrates your competency in strategizing, assessing challenges, and planning ahead, using both your own wisdom and trusted advice from others. This bodes well for spearheading efforts and leading successful teams. \n\n" integration_score = [] integration_score.append(generate_score(user_data["Integration1"])) integration_score.append(generate_score(user_data["Integration2"])) integration_score.append(generate_score(user_data["Integration3"])) integration_total = calculate_total(integration_score) if integration_total>=3 and integration_total<=7: final_text = final_text + "Scoring low in Integration suggests you may not frequently reflect on experiences for lessons or insights. Carving out time for self-examination and assessing what works well for you could improve your decision-making. \n\n" elif integration_total>=8 and integration_total<=11: final_text = final_text + "With a moderate Integration score, you are open to making some changes when things aren't working but may have difficulty letting go of comfortable approaches. Consider what habits, beliefs or behaviors to adjust for better alignment with your goals. \n\n" elif integration_total>=12 and integration_total<=15: final_text = final_text + "Your high Integration score shows constant learning, adaptation and refinement are priorities for you. This enables continual progress, although balancing flexibility with consistency is important so positive momentum isn't lost. \n\n" return {"response": final_text} @app.post("/quiz") def quiz(Ambivalence1: str = Form(...), Ambivalence2: str = Form(...), Ambivalence3: str = Form(...), Alienation1: str = Form(...), Alienation2: str = Form(...), Alienation3: str = Form(...), Abandonment1: str = Form(...), Abandonment2: str = Form(...), Abandonment3: str = Form(...), Abundance1: str = Form(...), Abundance2: str = Form(...), Abundance3: str = Form(...), Authority1: str = Form(...), Authority2: str = Form(...), Authority3: str = Form(...), Integration1: str = Form(...), Integration2: str = Form(...), Integration3: str = Form(...),): final_text = "" ambivalence_score = [] ambivalence_score.append(generate_score(Ambivalence1)) ambivalence_score.append(generate_score(Ambivalence2)) ambivalence_score.append(generate_score(Ambivalence3)) ambivalence_total = calculate_total(ambivalence_score) if ambivalence_total>=3 and ambivalence_total<=7: final_text = final_text + "You exhibit few characteristics of Ambivalence. This suggests that you are generally decisive and clear about your goals and directions. You tend to make decisions confidently and are less likely to be plagued by doubts or indecisiveness. This clarity can be a significant strength, especially in situations that require quick and firm decision-making. \n\n" elif ambivalence_total>=8 and ambivalence_total<=11: final_text = final_text + "Your results indicate a moderate alignment with Ambivalence. While you can be decisive, you may sometimes find yourself hesitating when faced with multiple options. This can be due to a desire to explore all possibilities thoroughly or a fear of making the wrong choice. Developing strategies to trust your judgment more could further enhance your decision-making process. \n\n" elif ambivalence_total>=12 and ambivalence_total<=15: final_text = final_text + "You have a strong alignment with Ambivalence, suggesting that decision-making can be a significant challenge for you. You might often feel stuck when presented with choices, worried about missing out on the best option. This can lead to analysis paralysis. Embracing techniques to boost your decision-making confidence, such as setting time limits for decisions or seeking input from trusted sources, could be highly beneficial. \n\n" alienation_score = [] alienation_score.append(generate_score(Alienation1)) alienation_score.append(generate_score(Alienation2)) alienation_score.append(generate_score(Alienation3)) alienation_total = calculate_total(alienation_score) if alienation_total>=3 and alienation_total<=7: final_text = final_text + "Your low score in Alienation indicates that you feel connected to your goals and dreams and believe in their attainability. You likely have a support system and resources, or at least a clear path to acquiring them, which you feel can help you achieve your aspirations. This sense of connection and possibility is a powerful driver in your personal and professional life. \n\n" elif alienation_total>=8 and alienation_total<=11: final_text = final_text + "With a moderate score in Alienation, you may sometimes feel disconnected from your dreams or doubt their feasibility. While you have aspirations, there might be moments when you question your ability to achieve them or feel that you lack the necessary support. Identifying and cultivating resources and relationships that align with your goals can enhance your sense of connection and possibility. \n\n" elif alienation_total>=12 and alienation_total<=15: final_text = final_text + "A high score in Alienation suggests that you often feel detached from your goals and unsure about their achievability. There might be a sense of lacking the resources or support needed to reach your aspirations. It's important to explore these feelings and consider ways to bridge the gap between your current reality and your dreams. This could involve reevaluating your goals, seeking new support networks, or developing a more practical approach to achieving your aspirations. \n\n" abandonment_score = [] abandonment_score.append(generate_score(Abandonment1)) abandonment_score.append(generate_score(Abandonment2)) abandonment_score.append(generate_score(Abandonment3)) abandonment_total = calculate_total(abandonment_score) if abandonment_total>=3 and abandonment_total<=7: final_text = final_text + "Scoring low in Abandonment indicates that you are generally confident and willing to take risks. You do not let the fear of failure or disappointment hold you back. This can be a significant asset, especially in situations that require boldness and initiative. Your willingness to try new things and face potential setbacks head-on is a valuable trait in both personal and professional contexts. \n\n" elif abandonment_total>=8 and abandonment_total<=11: final_text = final_text + "With a moderate score in Abandonment, you might occasionally struggle with the fear of failure or disappointment. While you are willing to take risks, these fears can sometimes hold you back from fully committing to new endeavors. Balancing caution with courage and learning to embrace potential failures as learning opportunities could further empower your decision-making and risk-taking abilities. \n\n" elif abandonment_total>=12 and abandonment_total<=15: final_text = final_text + "Your high alignment with Abandonment suggests that fear of failure and disappointment significantly influences your actions. You may often find yourself avoiding new experiences or challenges due to these fears. Building resilience and finding strategies to cope with potential setbacks can be very beneficial. Consider seeking support to boost your confidence and help you embrace challenges more readily. \n\n" abundance_score = [] abundance_score.append(generate_score(Abundance1)) abundance_score.append(generate_score(Abundance2)) abundance_score.append(generate_score(Abundance3)) abundance_total = calculate_total(abundance_score) if abundance_total>=3 and abundance_total<=7: final_text = final_text + "A low score in Abundance indicates that you may prefer structure and predictability over exploration and experimentation. You might find comfort in familiar environments and routines, which can provide stability and clarity. However, consider the benefits of occasionally stepping out of your comfort zone to explore new opportunities and ideas. \n\n" elif abundance_total>=8 and abundance_total<=11: final_text = final_text + "Scoring moderately in Abundance means you are open to new experiences and ideas, but you may also appreciate some level of predictability and structure. You can balance exploration with practicality, which is a valuable trait. Embracing this balance can lead to growth while still maintaining a sense of security. \n\n" elif abundance_total>=12 and abundance_total<=15: final_text = final_text + "With a high score in Abundance, you thrive in environments where exploration, experimentation, and risk-taking are involved. You are not afraid to delve into the unknown and embrace new opportunities. This adventurous spirit can lead to significant innovation and discovery. However, be mindful of maintaining a balance and not losing sight of your long-term goals amidst the excitement of new possibilities. \n\n" authority_score = [] authority_score.append(generate_score(Authority1)) authority_score.append(generate_score(Authority2)) authority_score.append(generate_score(Authority3)) authority_total = calculate_total(authority_score) if authority_total>=3 and authority_total<=7: final_text = final_text + "With a low score in Authority, you may not have strong management or planning skills. Developing foresight and decision-making abilities, while also seeking guidance from mentors, could help advance your goals. \n\n" elif authority_total>=8 and authority_total<=11: final_text = final_text + "Your moderate alignment with Authority indicates some leadership and preparation skills but potential difficulty acting confidently on your own judgment. Cultivating trust in your own decisions while also using input from your team can be beneficial. \n\n" elif authority_total>=12 and authority_total<=15: final_text = final_text + "Scoring highly in Authority demonstrates your competency in strategizing, assessing challenges, and planning ahead, using both your own wisdom and trusted advice from others. This bodes well for spearheading efforts and leading successful teams. \n\n" integration_score = [] integration_score.append(generate_score(Integration1)) integration_score.append(generate_score(Integration2)) integration_score.append(generate_score(Integration3)) integration_total = calculate_total(integration_score) if integration_total>=3 and integration_total<=7: final_text = final_text + "Scoring low in Integration suggests you may not frequently reflect on experiences for lessons or insights. Carving out time for self-examination and assessing what works well for you could improve your decision-making. \n\n" elif integration_total>=8 and integration_total<=11: final_text = final_text + "With a moderate Integration score, you are open to making some changes when things aren't working but may have difficulty letting go of comfortable approaches. Consider what habits, beliefs or behaviors to adjust for better alignment with your goals. \n\n" elif integration_total>=12 and integration_total<=15: final_text = final_text + "Your high Integration score shows constant learning, adaptation and refinement are priorities for you. This enables continual progress, although balancing flexibility with consistency is important so positive momentum isn't lost. \n\n" return {"response": final_text}