Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -788,8 +788,16 @@ def roadmap():
|
|
788 |
elif data.get('type') == 2:
|
789 |
# Get roadmap data
|
790 |
roadmap_data = roadmap_collection.find_one({"_id": ObjectId(data.get("_id")), "userId": user_id})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
if roadmap_data:
|
792 |
-
return jsonify({'success': True, 'roadmapData': {'data': roadmap_data['data']}, 'activeDays': roadmap_data['activeDays'], 'practice':
|
793 |
else:
|
794 |
return jsonify({'success': False})
|
795 |
|
@@ -885,17 +893,24 @@ def roadmapmodder():
|
|
885 |
temp_data = roadmap_collection.find_one({"_id": ObjectId(obj_id)})
|
886 |
temp_data['data'][week_num-1][week_field]['data'][day_field]['youtube'][video_index]['viewed'] = True
|
887 |
|
|
|
|
|
888 |
roadmap_collection.update_one(
|
889 |
{"_id": ObjectId(obj_id)},
|
890 |
{"$set": { "data": temp_data['data'] }}
|
891 |
)
|
892 |
|
|
|
|
|
893 |
if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
|
894 |
temp_data['activeDays'].append(day_data)
|
895 |
roadmap_collection.update_one(
|
896 |
{"_id": ObjectId(obj_id)},
|
897 |
{"$set": { "activeDays": temp_data['activeDays'] }}
|
898 |
)
|
|
|
|
|
|
|
899 |
|
900 |
return jsonify({'success': True})
|
901 |
|
@@ -1064,16 +1079,25 @@ def problemhandler():
|
|
1064 |
obj_id = data.get('_id')
|
1065 |
week_day = data.get('weekDay')
|
1066 |
indexer = data.get('index')
|
|
|
1067 |
|
1068 |
-
|
1069 |
-
|
1070 |
|
1071 |
-
test = roadmap_collection.
|
1072 |
{"_id": ObjectId(obj_id)},
|
1073 |
-
{
|
1074 |
)
|
1075 |
-
|
1076 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1077 |
|
1078 |
|
1079 |
if __name__ == '__main__':
|
|
|
788 |
elif data.get('type') == 2:
|
789 |
# Get roadmap data
|
790 |
roadmap_data = roadmap_collection.find_one({"_id": ObjectId(data.get("_id")), "userId": user_id})
|
791 |
+
|
792 |
+
practice_temp = roadmap_data['practice'] # Modify to remove answer and explanation
|
793 |
+
for key in practice_temp.values():
|
794 |
+
for question in key:
|
795 |
+
if not question.get('solved', False):
|
796 |
+
question.pop('answer', None)
|
797 |
+
question.pop('explaination', None)
|
798 |
+
|
799 |
if roadmap_data:
|
800 |
+
return jsonify({'success': True, 'roadmapData': {'data': roadmap_data['data']}, 'activeDays': roadmap_data['activeDays'], 'practice': practice_temp, 'title': roadmap_data['title']})
|
801 |
else:
|
802 |
return jsonify({'success': False})
|
803 |
|
|
|
893 |
temp_data = roadmap_collection.find_one({"_id": ObjectId(obj_id)})
|
894 |
temp_data['data'][week_num-1][week_field]['data'][day_field]['youtube'][video_index]['viewed'] = True
|
895 |
|
896 |
+
print("Meow")
|
897 |
+
|
898 |
roadmap_collection.update_one(
|
899 |
{"_id": ObjectId(obj_id)},
|
900 |
{"$set": { "data": temp_data['data'] }}
|
901 |
)
|
902 |
|
903 |
+
print("Meow")
|
904 |
+
|
905 |
if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
|
906 |
temp_data['activeDays'].append(day_data)
|
907 |
roadmap_collection.update_one(
|
908 |
{"_id": ObjectId(obj_id)},
|
909 |
{"$set": { "activeDays": temp_data['activeDays'] }}
|
910 |
)
|
911 |
+
|
912 |
+
|
913 |
+
print("Meow")
|
914 |
|
915 |
return jsonify({'success': True})
|
916 |
|
|
|
1079 |
obj_id = data.get('_id')
|
1080 |
week_day = data.get('weekDay')
|
1081 |
indexer = data.get('index')
|
1082 |
+
keyer = data.get('key')
|
1083 |
|
1084 |
+
temp1 = f"practice.{week_day}"
|
1085 |
+
temp2 = f"practice.{week_day}.{indexer}.solved"
|
1086 |
|
1087 |
+
test = roadmap_collection.find_one(
|
1088 |
{"_id": ObjectId(obj_id)},
|
1089 |
+
{temp1: 1}
|
1090 |
)
|
1091 |
+
|
1092 |
+
notor = [int(key) for key in test['practice'][str(week_day)][int(indexer)]['answer'].keys()][0]
|
1093 |
+
if notor == int(keyer):
|
1094 |
+
roadmap_collection.update_one(
|
1095 |
+
{"_id": ObjectId(obj_id)},
|
1096 |
+
{"$set": { temp2 : True }}
|
1097 |
+
)
|
1098 |
+
return jsonify({"success": True, "answer": {notor: test['practice'][str(week_day)][int(indexer)]['answer'][f"{notor}"]}, "explaination": test['practice'][str(week_day)][int(indexer)]['explaination']}), 200
|
1099 |
+
else:
|
1100 |
+
return jsonify({"success": False}), 200
|
1101 |
|
1102 |
|
1103 |
if __name__ == '__main__':
|