abhicodes commited on
Commit
fcdd696
1 Parent(s): 3c392e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -30
app.py CHANGED
@@ -544,7 +544,7 @@ def result():
544
  if 'email' not in session:
545
  return redirect(url_for('home'))
546
 
547
- app.config['MYSQL_DB'] = 'sql12660485'
548
  curr = mysql.cursor()
549
 
550
  curr.execute("SELECT * FROM `custom` WHERE id=%s AND type=%s", (session['id'], session['type'],))
@@ -553,8 +553,6 @@ def result():
553
  curr.execute("SELECT result FROM `custom` WHERE type=%s", (session['type'],))
554
  avg = curr.fetchall()
555
 
556
- avg_tuple = tuple({'result': item[0]} for item in avg)
557
-
558
  dynamic = [list(eval(d[0])) for d in avg]
559
 
560
  dyna = []
@@ -565,9 +563,8 @@ def result():
565
  temp2 = temp2 + dynamic[j][i]
566
  dyna.append(temp2 / len(dynamic))
567
 
568
-
569
  ques = []
570
- for i in range(1, len(dyna)+1):
571
  ques.append("Question " + str(i) + "")
572
 
573
  curr.execute("SELECT * FROM assessments WHERE assessid = %s", (session['type'],))
@@ -592,71 +589,121 @@ def result():
592
  avg_score = round(((temp_score + 100) / 200) * (90 - 10) + 10, 2)
593
  if key == 1101:
594
  if avg_score >= 66:
595
- result_dict[key] = {"average_score": avg_score, "name": "Psychological well being", "description": "Refers to an individual`s mental state and overall happiness, including feelings of fulfillment, purpose, and contentment.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1101]}
 
 
596
  elif avg_score >= 30:
597
- result_dict[key] = {"average_score": avg_score, "name": "Psychological well being", "description": "Refers to an individual`s mental state and overall happiness, including feelings of fulfillment, purpose, and contentment.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1101]}
 
 
598
  elif avg_score < 30:
599
- result_dict[key] = {"average_score": avg_score, "name": "Psychological well being", "description": "Refers to an individual`s mental state and overall happiness, including feelings of fulfillment, purpose, and contentment.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1101]}
 
 
600
 
601
  elif key == 1102:
602
  if avg_score >= 66:
603
- result_dict[key] = {"average_score": avg_score, "name": "Health aspects", "description": "Refers to an individual`s physical health, including factors such as nutrition, exercise, and access to medical care.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1102]}
 
 
604
  elif avg_score >= 30:
605
- result_dict[key] = {"average_score": avg_score, "name": "Health aspects", "description": "Refers to an individual`s physical health, including factors such as nutrition, exercise, and access to medical care.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1102]}
 
 
606
  elif avg_score < 30:
607
- result_dict[key] = {"average_score": avg_score, "name": "Health aspects", "description": "Refers to an individual`s physical health, including factors such as nutrition, exercise, and access to medical care.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1102]}
 
 
608
 
609
  elif key == 1103:
610
  if avg_score >= 66:
611
- result_dict[key] = {"average_score": avg_score, "name": "Time management", "description": "Refers to an individual`s ability to effectively manage their time and prioritize tasks to maximize productivity and reduce stress.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1103]}
 
 
612
  elif avg_score >= 30:
613
- result_dict[key] = {"average_score": avg_score, "name": "Time management", "description": "Refers to an individual`s ability to effectively manage their time and prioritize tasks to maximize productivity and reduce stress.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1103]}
 
 
614
  elif avg_score < 30:
615
- result_dict[key] = {"average_score": avg_score, "name": "Time management", "description": "Refers to an individual`s ability to effectively manage their time and prioritize tasks to maximize productivity and reduce stress.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1103]}
 
 
616
 
617
  elif key == 1104:
618
  if avg_score >= 66:
619
- result_dict[key] = {"average_score": avg_score, "name": "Educational standards", "description": "Refers to the quality of education provided in a given community, including factors such as curriculum, teaching quality, and access to resources.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1104]}
 
 
620
  elif avg_score >= 30:
621
- result_dict[key] = {"average_score": avg_score, "name": "Educational standards", "description": "Refers to the quality of education provided in a given community, including factors such as curriculum, teaching quality, and access to resources.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1104]}
 
 
622
  elif avg_score < 30:
623
- result_dict[key] = {"average_score": avg_score, "name": "Educational standards", "description": "Refers to the quality of education provided in a given community, including factors such as curriculum, teaching quality, and access to resources.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1104]}
 
 
624
 
625
  elif key == 1105:
626
  if avg_score >= 66:
627
- result_dict[key] = {"average_score": avg_score, "name": "Cultural diversity", "description": "Refers to the range of cultures, beliefs, and practices within a given community, and the level of acceptance and celebration of diversity.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1105]}
 
 
628
  elif avg_score >= 30:
629
- result_dict[key] = {"average_score": avg_score, "name": "Cultural diversity", "description": "Refers to the range of cultures, beliefs, and practices within a given community, and the level of acceptance and celebration of diversity.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1105]}
 
 
630
  elif avg_score < 30:
631
- result_dict[key] = {"average_score": avg_score, "name": "Cultural diversity", "description": "Refers to the range of cultures, beliefs, and practices within a given community, and the level of acceptance and celebration of diversity.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1105]}
 
 
632
 
633
  elif key == 1106:
634
  if avg_score >= 66:
635
- result_dict[key] = {"average_score": avg_score, "name": "Social well-being", "description": "Social well-being refers to the quality of an individual`s social interactions, relationships, and sense of community belonging.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1106]}
 
 
636
  elif avg_score >= 30:
637
- result_dict[key] = {"average_score": avg_score, "name": "Social well-being", "description": "Social well-being refers to the quality of an individual`s social interactions, relationships, and sense of community belonging.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1106]}
 
 
638
  elif avg_score < 30:
639
- result_dict[key] = {"average_score": avg_score, "name": "Social well-being", "description": "Social well-being refers to the quality of an individual`s social interactions, relationships, and sense of community belonging.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1106]}
 
 
640
 
641
  elif key == 1107:
642
  if avg_score >= 66:
643
- result_dict[key] = {"average_score": avg_score, "name": "Good governance", "description": "Refers to the effectiveness and transparency of governing systems and institutions in promoting the well-being of all members of a community.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1107]}
 
 
644
  elif avg_score >= 30:
645
- result_dict[key] = {"average_score": avg_score, "name": "Good governance", "description": "Refers to the effectiveness and transparency of governing systems and institutions in promoting the well-being of all members of a community.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1107]}
 
 
646
  elif avg_score < 30:
647
- result_dict[key] = {"average_score": avg_score, "name": "Good governance", "description": "Refers to the effectiveness and transparency of governing systems and institutions in promoting the well-being of all members of a community.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1107]}
 
 
648
 
649
  elif key == 1108:
650
  if avg_score >= 66:
651
- result_dict[key] = {"average_score": avg_score, "name": "Community vitality", "description": "Refers to the health and vibrancy of a community, including factors such as social cohesion, civic engagement, and access to resources.", "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1108]}
 
 
652
  elif avg_score >= 30:
653
- result_dict[key] = {"average_score": avg_score, "name": "Community vitality", "description": "Refers to the health and vibrancy of a community, including factors such as social cohesion, civic engagement, and access to resources.", "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1108]}
 
 
654
  elif avg_score < 30:
655
- result_dict[key] = {"average_score": avg_score, "name": "Community vitality", "description": "Refers to the health and vibrancy of a community, including factors such as social cohesion, civic engagement, and access to resources.", "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1108]}
 
 
656
 
657
  suggest_dict = dict(sorted(result_dict.items()))
658
 
659
- curr.execute("SELECT `Questions`,`response`, `result`, `datetime` FROM `custom`, `assessments` WHERE `id`=%s AND `type`=%s AND custom.type = assessments.assessId", (session['id'], session['type'],))
 
 
660
  details = curr.fetchone()
661
 
662
  mysql.commit()
 
544
  if 'email' not in session:
545
  return redirect(url_for('home'))
546
 
547
+ app.config['MYSQL_DB'] = 'test'
548
  curr = mysql.cursor()
549
 
550
  curr.execute("SELECT * FROM `custom` WHERE id=%s AND type=%s", (session['id'], session['type'],))
 
553
  curr.execute("SELECT result FROM `custom` WHERE type=%s", (session['type'],))
554
  avg = curr.fetchall()
555
 
 
 
556
  dynamic = [list(eval(d[0])) for d in avg]
557
 
558
  dyna = []
 
563
  temp2 = temp2 + dynamic[j][i]
564
  dyna.append(temp2 / len(dynamic))
565
 
 
566
  ques = []
567
+ for i in range(1, len(dyna) + 1):
568
  ques.append("Question " + str(i) + "")
569
 
570
  curr.execute("SELECT * FROM assessments WHERE assessid = %s", (session['type'],))
 
589
  avg_score = round(((temp_score + 100) / 200) * (90 - 10) + 10, 2)
590
  if key == 1101:
591
  if avg_score >= 66:
592
+ result_dict[key] = {"average_score": avg_score, "name": "Psychological well being",
593
+ "description": "Refers to an individual`s mental state and overall happiness, including feelings of fulfillment, purpose, and contentment.",
594
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1101]}
595
  elif avg_score >= 30:
596
+ result_dict[key] = {"average_score": avg_score, "name": "Psychological well being",
597
+ "description": "Refers to an individual`s mental state and overall happiness, including feelings of fulfillment, purpose, and contentment.",
598
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1101]}
599
  elif avg_score < 30:
600
+ result_dict[key] = {"average_score": avg_score, "name": "Psychological well being",
601
+ "description": "Refers to an individual`s mental state and overall happiness, including feelings of fulfillment, purpose, and contentment.",
602
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1101]}
603
 
604
  elif key == 1102:
605
  if avg_score >= 66:
606
+ result_dict[key] = {"average_score": avg_score, "name": "Health aspects",
607
+ "description": "Refers to an individual`s physical health, including factors such as nutrition, exercise, and access to medical care.",
608
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1102]}
609
  elif avg_score >= 30:
610
+ result_dict[key] = {"average_score": avg_score, "name": "Health aspects",
611
+ "description": "Refers to an individual`s physical health, including factors such as nutrition, exercise, and access to medical care.",
612
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1102]}
613
  elif avg_score < 30:
614
+ result_dict[key] = {"average_score": avg_score, "name": "Health aspects",
615
+ "description": "Refers to an individual`s physical health, including factors such as nutrition, exercise, and access to medical care.",
616
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1102]}
617
 
618
  elif key == 1103:
619
  if avg_score >= 66:
620
+ result_dict[key] = {"average_score": avg_score, "name": "Time management",
621
+ "description": "Refers to an individual`s ability to effectively manage their time and prioritize tasks to maximize productivity and reduce stress.",
622
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1103]}
623
  elif avg_score >= 30:
624
+ result_dict[key] = {"average_score": avg_score, "name": "Time management",
625
+ "description": "Refers to an individual`s ability to effectively manage their time and prioritize tasks to maximize productivity and reduce stress.",
626
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1103]}
627
  elif avg_score < 30:
628
+ result_dict[key] = {"average_score": avg_score, "name": "Time management",
629
+ "description": "Refers to an individual`s ability to effectively manage their time and prioritize tasks to maximize productivity and reduce stress.",
630
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1103]}
631
 
632
  elif key == 1104:
633
  if avg_score >= 66:
634
+ result_dict[key] = {"average_score": avg_score, "name": "Educational standards",
635
+ "description": "Refers to the quality of education provided in a given community, including factors such as curriculum, teaching quality, and access to resources.",
636
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1104]}
637
  elif avg_score >= 30:
638
+ result_dict[key] = {"average_score": avg_score, "name": "Educational standards",
639
+ "description": "Refers to the quality of education provided in a given community, including factors such as curriculum, teaching quality, and access to resources.",
640
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1104]}
641
  elif avg_score < 30:
642
+ result_dict[key] = {"average_score": avg_score, "name": "Educational standards",
643
+ "description": "Refers to the quality of education provided in a given community, including factors such as curriculum, teaching quality, and access to resources.",
644
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1104]}
645
 
646
  elif key == 1105:
647
  if avg_score >= 66:
648
+ result_dict[key] = {"average_score": avg_score, "name": "Cultural diversity",
649
+ "description": "Refers to the range of cultures, beliefs, and practices within a given community, and the level of acceptance and celebration of diversity.",
650
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1105]}
651
  elif avg_score >= 30:
652
+ result_dict[key] = {"average_score": avg_score, "name": "Cultural diversity",
653
+ "description": "Refers to the range of cultures, beliefs, and practices within a given community, and the level of acceptance and celebration of diversity.",
654
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1105]}
655
  elif avg_score < 30:
656
+ result_dict[key] = {"average_score": avg_score, "name": "Cultural diversity",
657
+ "description": "Refers to the range of cultures, beliefs, and practices within a given community, and the level of acceptance and celebration of diversity.",
658
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1105]}
659
 
660
  elif key == 1106:
661
  if avg_score >= 66:
662
+ result_dict[key] = {"average_score": avg_score, "name": "Social well-being",
663
+ "description": "Social well-being refers to the quality of an individual`s social interactions, relationships, and sense of community belonging.",
664
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1106]}
665
  elif avg_score >= 30:
666
+ result_dict[key] = {"average_score": avg_score, "name": "Social well-being",
667
+ "description": "Social well-being refers to the quality of an individual`s social interactions, relationships, and sense of community belonging.",
668
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1106]}
669
  elif avg_score < 30:
670
+ result_dict[key] = {"average_score": avg_score, "name": "Social well-being",
671
+ "description": "Social well-being refers to the quality of an individual`s social interactions, relationships, and sense of community belonging.",
672
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1106]}
673
 
674
  elif key == 1107:
675
  if avg_score >= 66:
676
+ result_dict[key] = {"average_score": avg_score, "name": "Good governance",
677
+ "description": "Refers to the effectiveness and transparency of governing systems and institutions in promoting the well-being of all members of a community.",
678
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1107]}
679
  elif avg_score >= 30:
680
+ result_dict[key] = {"average_score": avg_score, "name": "Good governance",
681
+ "description": "Refers to the effectiveness and transparency of governing systems and institutions in promoting the well-being of all members of a community.",
682
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1107]}
683
  elif avg_score < 30:
684
+ result_dict[key] = {"average_score": avg_score, "name": "Good governance",
685
+ "description": "Refers to the effectiveness and transparency of governing systems and institutions in promoting the well-being of all members of a community.",
686
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1107]}
687
 
688
  elif key == 1108:
689
  if avg_score >= 66:
690
+ result_dict[key] = {"average_score": avg_score, "name": "Community vitality",
691
+ "description": "Refers to the health and vibrancy of a community, including factors such as social cohesion, civic engagement, and access to resources.",
692
+ "suggestions_text": [list(eval(d[3])) for d in suggests if d[0] == 1108]}
693
  elif avg_score >= 30:
694
+ result_dict[key] = {"average_score": avg_score, "name": "Community vitality",
695
+ "description": "Refers to the health and vibrancy of a community, including factors such as social cohesion, civic engagement, and access to resources.",
696
+ "suggestions_text": [list(eval(d[2])) for d in suggests if d[0] == 1108]}
697
  elif avg_score < 30:
698
+ result_dict[key] = {"average_score": avg_score, "name": "Community vitality",
699
+ "description": "Refers to the health and vibrancy of a community, including factors such as social cohesion, civic engagement, and access to resources.",
700
+ "suggestions_text": [list(eval(d[1])) for d in suggests if d[0] == 1108]}
701
 
702
  suggest_dict = dict(sorted(result_dict.items()))
703
 
704
+ curr.execute(
705
+ "SELECT `Questions`,`response`, `result`, `datetime` FROM `custom`, `assessments` WHERE `id`=%s AND `type`=%s AND custom.type = assessments.assessId",
706
+ (session['id'], session['type'],))
707
  details = curr.fetchone()
708
 
709
  mysql.commit()