Commit d5cb6d47 authored by colmoneill's avatar colmoneill

flash messages on success

parent 36c5f685
......@@ -148,18 +148,20 @@ def check_quiz(id):
answers[k] = [None, False]
answers_list = [ answers[k] for k in sorted(answers.keys()) ]
print(len(answers_list))
# print(len(answers_list))
number_correct = len(list(filter(lambda t: t[1], answers_list)))
print(number_correct)
# print(number_correct)
badge_ok = math.floor((len(answers_list) / 3) * 2)
print(badge_ok)
# print(badge_ok)
user = current_user.get_id()
if number_correct >= badge_ok:
#award badge
print('award badge ' + badge)
bdd.user.update({"_id": ObjectId(user), "badges.name": badge}, {"$set": {"badges.$.lvl": 2}}, multi=True)
print({ "badges.name": badge,"_id": ObjectId(user)}, {"$set": {"badges.$.lvl": 2}})
bdd.user.update({"_id": ObjectId(user), "badges.name": badge}, {"$set": {"badges.$.lvl": 1}}, multi=True)
# print({ "badges.name": badge,"_id": ObjectId(user)}, {"$set": {"badges.$.lvl": 2}})
#({'badges.name': 'electronique', '_id': ObjectId('5b3f847e5087266741cf1fef')}, {'$set': {'badges.$.lvl': 1}})
success_message = 'Félicitations, vous venez d\'obtenir le badge ' + badge
flash(success_message, 'success')
else:
print('user got less than required amount')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment