We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Program doesn't correctly change visually when submitted
**Describe the bug**
Currently when we submit a program the user receives no feedback if their submission was successful. This issue might occur due to #1628 where we re-write the programs page structure to prevent re-loading to update user information. The program is correctly submitted in the back-end but not on the front-end (yet). With the additional issue that now the submitting achievements are not correctly shown to the user.

**Expected behavior**
When submitting a program the program box on the programs page should change visually and show the submission achievement if received.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `website/achievements.py`
Content:
```
1 from website import database
2 from hedyweb import AchievementTranslations
3 from website.auth import requires_login
4 from flask import request, jsonify, session
5 import hedy
6 
7 
8 class Achievements:
9 
10     def __init__(self):
11         self.DATABASE = database.Database()
12         self.TRANSLATIONS = AchievementTranslations()
13 
14     def routes(self, app, database):
15         global DATABASE
16         DATABASE = database
17 
18         @app.route('/achievements', methods=['POST'])
19         @requires_login
20         def push_new_achievement(user):
21             body = request.json
22             if "achievement" in body:
23                 if not session['achieved']:
24                     self.initialize_user_data(user['username'])
25                 if body['achievement'] not in session['achieved'] and body['achievement'] in self.TRANSLATIONS.get_translations(session['lang']):
26                     return jsonify({"achievements": self.verify_pushed_achievement(user.get('username'), body['achievement'])})
27             return jsonify({})
28 
29     def increase_count(self, category):
30         if category == "run":
31             session['run_programs'] += 1
32         elif category == "saved":
33             session['saved_programs'] += 1
34         elif category == "submitted":
35             session['submitted_programs'] += 1
36 
37     def initialize_user_data(self, username):
38         achievements_data = self.DATABASE.progress_by_username(username)
39         session['new_achieved'] = []
40         session['new_commands'] = []
41         session['previous_code'] = None
42         session['identical_consecutive_errors'] = 0
43         session['consecutive_errors'] = 0
44         if not achievements_data:
45             achievements_data = {}
46         if 'achieved' in achievements_data:
47             session['achieved'] = achievements_data['achieved']
48         else:
49             session['achieved'] = []
50         if 'commands' in achievements_data:
51             session['commands'] = achievements_data['commands']
52         else:
53             session['commands'] = []
54         if 'run_programs' in achievements_data:
55             session['run_programs'] = achievements_data['run_programs']
56         else:
57             session['run_programs'] = 0
58         if 'saved_programs' in achievements_data:
59             session['saved_programs'] = achievements_data['saved_programs']
60         else:
61             session['saved_programs'] = 0
62         if 'submitted_programs' in achievements_data:
63             session['submitted_programs'] = achievements_data['submitted_programs']
64         else:
65             session['submitted_programs'] = 0
66 
67     def add_single_achievement(self, username, achievement):
68         if not session['achieved']:
69             self.initialize_user_data(username)
70         if achievement not in session['achieved'] and achievement in self.TRANSLATIONS.get_translations(session['lang']):
71             return self.verify_pushed_achievement(username, achievement)
72         else:
73             return None
74 
75     def verify_run_achievements(self, username, code=None, level=None, response=None):
76         if not session['achieved']:
77             self.initialize_user_data(username)
78         self.check_programs_run()
79         if code and level:
80             self.check_code_achievements(code, level)
81         if code and response:
82             self.check_response_achievements(code, response)
83 
84         if len(session['commands']) > 0:
85             for command in session['new_commands']:
86                 session['commands'].append(command)
87             self.DATABASE.add_commands_to_username(username, session['commands'])
88 
89         if len(session['new_achieved']) > 0:
90             self.DATABASE.add_achievements_to_username(username, session['new_achieved'])
91             for achievement in session['new_achieved']:
92                 session['achieved'].append(achievement)
93             return True
94         return False
95 
96     def verify_save_achievements(self, username, adventure=None):
97         if not session['achieved']:
98             self.initialize_user_data(username)
99         self.check_programs_saved()
100         if adventure and 'adventure_is_worthwhile' not in session['achieved']:
101             session['new_achieved'].append("adventure_is_worthwhile")
102         if len(session['new_achieved']) > 0:
103             self.DATABASE.add_achievements_to_username(username, session['new_achieved'])
104             for achievement in session['new_achieved']:
105                 session['achieved'].append(achievement)
106             return True
107         return False
108 
109     def verify_submit_achievements(self, username):
110         if not session['achieved']:
111             self.initialize_user_data(username)
112         self.check_programs_submitted(session['submitted_programs'])
113 
114         if len(session['new_achieved']) > 0:
115             self.DATABASE.add_achievements_to_username(username, session['new_achieved'])
116             for achievement in session['new_achieved']:
117                 session['achieved'].append(achievement)
118             return True
119         return False
120 
121     def verify_pushed_achievement(self, username, achievement):
122         session['new_achieved'] = [achievement]
123         self.DATABASE.add_achievement_to_username(username, achievement)
124         session['achieved'].append(achievement)
125         return self.get_earned_achievements()
126 
127     def get_earned_achievements(self):
128         translations = self.TRANSLATIONS.get_translations(session['lang'])
129         translated_achievements = []
130         for achievement in session['new_achieved']:
131             translated_achievements.append([translations[achievement]['title'], translations[achievement]['text'], translations[achievement]['image']])
132         session['new_achieved'] = [] #Once we get earned achievements -> empty the array with "waiting" ones
133         session['new_commands'] = []
134         return translated_achievements
135 
136     def check_programs_run(self):
137         if 'getting_started_I' not in session['achieved'] and session['run_programs'] >= 1:
138             session['new_achieved'].append("getting_started_I")
139         if 'getting_started_II' not in session['achieved'] and session['run_programs'] >= 10:
140             session['new_achieved'].append("getting_started_II")
141         if 'getting_started_III' not in session['achieved'] and session['run_programs'] >= 50:
142             session['new_achieved'].append("getting_started_III")
143         if 'getting_started_IV' not in session['achieved'] and session['run_programs'] >= 200:
144             session['new_achieved'].append("getting_started_IV")
145         if 'getting_started_V' not in session['achieved'] and session['run_programs'] >= 500:
146             session['new_achieved'].append("getting_started_V")
147 
148     def check_programs_saved(self):
149         if 'one_to_remember_I' not in session['achieved'] and session['saved_programs'] >= 1:
150             session['new_achieved'].append("one_to_remember_I")
151         if 'one_to_remember_II' not in session['achieved'] and session['saved_programs'] >= 5:
152             session['new_achieved'].append("one_to_remember_II")
153         if 'one_to_remember_III' not in session['achieved'] and session['saved_programs'] >= 10:
154             session['new_achieved'].append("one_to_remember_III")
155         if 'one_to_remember_IV' not in session['achieved'] and session['saved_programs'] >= 25:
156             session['new_achieved'].append("one_to_remember_IV")
157         if 'one_to_remember_V' not in session['achieved'] and session['saved_programs'] >= 50:
158             session['new_achieved'].append("one_to_remember_V")
159 
160     def check_programs_submitted(self):
161         if 'deadline_daredevil_I' not in session['achieved'] and session['submitted_programs'] >= 1:
162             session['new_achieved'].append("deadline_daredevil_I")
163         if 'deadline_daredevil_II' not in session['achieved'] and session['submitted_programs'] >= 3:
164             session['new_achieved'].append("deadline_daredevil_II")
165         if 'deadline_daredevil_III' not in session['achieved'] and session['submitted_programs'] >= 10:
166             session['new_achieved'].append("deadline_daredevil_III")
167 
168     def check_code_achievements(self, code, level):
169         commands_in_code = hedy.all_commands(code, level, session['lang'])
170         if 'trying_is_key' not in session['achieved']:
171             for command in set(commands_in_code):
172                 if command not in session['commands']:
173                     session['new_commands'].append(command)
174         if set(session['commands']) == set(hedy.commands_per_level.get(hedy.HEDY_MAX_LEVEL)):
175             session['new_achieved'].append("trying_is_key")
176         if 'did_you_say_please' not in session['achieved'] and "ask" in hedy.all_commands(code, level, session['lang']):
177             session['new_achieved'].append("did_you_say_please")
178         if 'talk-talk-talk' not in session['achieved'] and hedy.all_commands(code, level, session['lang']).count("ask") >= 5:
179             session['new_achieved'].append("talk-talk-talk")
180         if 'hedy_honor' not in session['achieved'] and "Hedy" in code:
181             session['new_achieved'].append("hedy_honor")
182         if 'hedy-ious' not in session['achieved']:
183             all_print_arguments = hedy.all_print_arguments(code, level, session['lang'])
184             for argument in all_print_arguments:
185                 if all_print_arguments.count(argument) >= 10:
186                     session['new_achieved'].append("hedy-ious")
187                     break
188 
189 
190     def check_response_achievements(self, code, response):
191         if 'ninja_turtle' not in session['achieved'] and 'has_turtle' in response and response['has_turtle']:
192             session['new_achieved'].append("ninja_turtle")
193         if 'watch_out' not in session['achieved'] and 'Warning' in response and response['Warning']:
194             session['new_achieved'].append("watch_out")
195         if 'Error' in response and response['Error']:
196             session['consecutive_errors'] += 1
197             if session['previous_code'] == code:
198                 if session['identical_consecutive_errors'] == 0:
199                     session['identical_consecutive_errors'] += 2 #We have to count the first one too!
200                 session['identical_consecutive_errors'] += 1
201             if session['identical_consecutive_errors'] >= 3:
202                 if 'programming_panic' not in session['achieved']:
203                     session['new_achieved'].append("programming_panic")
204             session['previous_code'] = code
205         else:
206             if 'programming_protagonist' not in session['achieved'] and session['consecutive_errors'] >= 1:
207                 session['new_achieved'].append("programming_protagonist")
208             session['consecutive_errors'] = 0
209             session['identical_consecutive_errors'] = 0
210 
211 
212 
213
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/website/achievements.py b/website/achievements.py
--- a/website/achievements.py
+++ b/website/achievements.py
@@ -109,7 +109,7 @@
     def verify_submit_achievements(self, username):
         if not session['achieved']:
             self.initialize_user_data(username)
-        self.check_programs_submitted(session['submitted_programs'])
+        self.check_programs_submitted()
 
         if len(session['new_achieved']) > 0:
             self.DATABASE.add_achievements_to_username(username, session['new_achieved'])

{"golden_diff": "diff --git a/website/achievements.py b/website/achievements.py\n--- a/website/achievements.py\n+++ b/website/achievements.py\n@@ -109,7 +109,7 @@\n     def verify_submit_achievements(self, username):\n         if not session['achieved']:\n             self.initialize_user_data(username)\n-        self.check_programs_submitted(session['submitted_programs'])\n+        self.check_programs_submitted()\n \n         if len(session['new_achieved']) > 0:\n             self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n", "issue": "[BUG] Program doesn't correctly change visually when submitted\n**Describe the bug**\r\nCurrently when we submit a program the user receives no feedback if their submission was successful. This issue might occur due to #1628 where we re-write the programs page structure to prevent re-loading to update user information. The program is correctly submitted in the back-end but not on the front-end (yet). With the additional issue that now the submitting achievements are not correctly shown to the user.\r\n\r\n**Expected behavior**\r\nWhen submitting a program the program box on the programs page should change visually and show the submission achievement if received.\r\n\n", "before_files": [{"content": "from website import database\nfrom hedyweb import AchievementTranslations\nfrom website.auth import requires_login\nfrom flask import request, jsonify, session\nimport hedy\n\n\nclass Achievements:\n\n    def __init__(self):\n        self.DATABASE = database.Database()\n        self.TRANSLATIONS = AchievementTranslations()\n\n    def routes(self, app, database):\n        global DATABASE\n        DATABASE = database\n\n        @app.route('/achievements', methods=['POST'])\n        @requires_login\n        def push_new_achievement(user):\n            body = request.json\n            if \"achievement\" in body:\n                if not session['achieved']:\n                    self.initialize_user_data(user['username'])\n                if body['achievement'] not in session['achieved'] and body['achievement'] in self.TRANSLATIONS.get_translations(session['lang']):\n                    return jsonify({\"achievements\": self.verify_pushed_achievement(user.get('username'), body['achievement'])})\n            return jsonify({})\n\n    def increase_count(self, category):\n        if category == \"run\":\n            session['run_programs'] += 1\n        elif category == \"saved\":\n            session['saved_programs'] += 1\n        elif category == \"submitted\":\n            session['submitted_programs'] += 1\n\n    def initialize_user_data(self, username):\n        achievements_data = self.DATABASE.progress_by_username(username)\n        session['new_achieved'] = []\n        session['new_commands'] = []\n        session['previous_code'] = None\n        session['identical_consecutive_errors'] = 0\n        session['consecutive_errors'] = 0\n        if not achievements_data:\n            achievements_data = {}\n        if 'achieved' in achievements_data:\n            session['achieved'] = achievements_data['achieved']\n        else:\n            session['achieved'] = []\n        if 'commands' in achievements_data:\n            session['commands'] = achievements_data['commands']\n        else:\n            session['commands'] = []\n        if 'run_programs' in achievements_data:\n            session['run_programs'] = achievements_data['run_programs']\n        else:\n            session['run_programs'] = 0\n        if 'saved_programs' in achievements_data:\n            session['saved_programs'] = achievements_data['saved_programs']\n        else:\n            session['saved_programs'] = 0\n        if 'submitted_programs' in achievements_data:\n            session['submitted_programs'] = achievements_data['submitted_programs']\n        else:\n            session['submitted_programs'] = 0\n\n    def add_single_achievement(self, username, achievement):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        if achievement not in session['achieved'] and achievement in self.TRANSLATIONS.get_translations(session['lang']):\n            return self.verify_pushed_achievement(username, achievement)\n        else:\n            return None\n\n    def verify_run_achievements(self, username, code=None, level=None, response=None):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        self.check_programs_run()\n        if code and level:\n            self.check_code_achievements(code, level)\n        if code and response:\n            self.check_response_achievements(code, response)\n\n        if len(session['commands']) > 0:\n            for command in session['new_commands']:\n                session['commands'].append(command)\n            self.DATABASE.add_commands_to_username(username, session['commands'])\n\n        if len(session['new_achieved']) > 0:\n            self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n            for achievement in session['new_achieved']:\n                session['achieved'].append(achievement)\n            return True\n        return False\n\n    def verify_save_achievements(self, username, adventure=None):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        self.check_programs_saved()\n        if adventure and 'adventure_is_worthwhile' not in session['achieved']:\n            session['new_achieved'].append(\"adventure_is_worthwhile\")\n        if len(session['new_achieved']) > 0:\n            self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n            for achievement in session['new_achieved']:\n                session['achieved'].append(achievement)\n            return True\n        return False\n\n    def verify_submit_achievements(self, username):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        self.check_programs_submitted(session['submitted_programs'])\n\n        if len(session['new_achieved']) > 0:\n            self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n            for achievement in session['new_achieved']:\n                session['achieved'].append(achievement)\n            return True\n        return False\n\n    def verify_pushed_achievement(self, username, achievement):\n        session['new_achieved'] = [achievement]\n        self.DATABASE.add_achievement_to_username(username, achievement)\n        session['achieved'].append(achievement)\n        return self.get_earned_achievements()\n\n    def get_earned_achievements(self):\n        translations = self.TRANSLATIONS.get_translations(session['lang'])\n        translated_achievements = []\n        for achievement in session['new_achieved']:\n            translated_achievements.append([translations[achievement]['title'], translations[achievement]['text'], translations[achievement]['image']])\n        session['new_achieved'] = [] #Once we get earned achievements -> empty the array with \"waiting\" ones\n        session['new_commands'] = []\n        return translated_achievements\n\n    def check_programs_run(self):\n        if 'getting_started_I' not in session['achieved'] and session['run_programs'] >= 1:\n            session['new_achieved'].append(\"getting_started_I\")\n        if 'getting_started_II' not in session['achieved'] and session['run_programs'] >= 10:\n            session['new_achieved'].append(\"getting_started_II\")\n        if 'getting_started_III' not in session['achieved'] and session['run_programs'] >= 50:\n            session['new_achieved'].append(\"getting_started_III\")\n        if 'getting_started_IV' not in session['achieved'] and session['run_programs'] >= 200:\n            session['new_achieved'].append(\"getting_started_IV\")\n        if 'getting_started_V' not in session['achieved'] and session['run_programs'] >= 500:\n            session['new_achieved'].append(\"getting_started_V\")\n\n    def check_programs_saved(self):\n        if 'one_to_remember_I' not in session['achieved'] and session['saved_programs'] >= 1:\n            session['new_achieved'].append(\"one_to_remember_I\")\n        if 'one_to_remember_II' not in session['achieved'] and session['saved_programs'] >= 5:\n            session['new_achieved'].append(\"one_to_remember_II\")\n        if 'one_to_remember_III' not in session['achieved'] and session['saved_programs'] >= 10:\n            session['new_achieved'].append(\"one_to_remember_III\")\n        if 'one_to_remember_IV' not in session['achieved'] and session['saved_programs'] >= 25:\n            session['new_achieved'].append(\"one_to_remember_IV\")\n        if 'one_to_remember_V' not in session['achieved'] and session['saved_programs'] >= 50:\n            session['new_achieved'].append(\"one_to_remember_V\")\n\n    def check_programs_submitted(self):\n        if 'deadline_daredevil_I' not in session['achieved'] and session['submitted_programs'] >= 1:\n            session['new_achieved'].append(\"deadline_daredevil_I\")\n        if 'deadline_daredevil_II' not in session['achieved'] and session['submitted_programs'] >= 3:\n            session['new_achieved'].append(\"deadline_daredevil_II\")\n        if 'deadline_daredevil_III' not in session['achieved'] and session['submitted_programs'] >= 10:\n            session['new_achieved'].append(\"deadline_daredevil_III\")\n\n    def check_code_achievements(self, code, level):\n        commands_in_code = hedy.all_commands(code, level, session['lang'])\n        if 'trying_is_key' not in session['achieved']:\n            for command in set(commands_in_code):\n                if command not in session['commands']:\n                    session['new_commands'].append(command)\n        if set(session['commands']) == set(hedy.commands_per_level.get(hedy.HEDY_MAX_LEVEL)):\n            session['new_achieved'].append(\"trying_is_key\")\n        if 'did_you_say_please' not in session['achieved'] and \"ask\" in hedy.all_commands(code, level, session['lang']):\n            session['new_achieved'].append(\"did_you_say_please\")\n        if 'talk-talk-talk' not in session['achieved'] and hedy.all_commands(code, level, session['lang']).count(\"ask\") >= 5:\n            session['new_achieved'].append(\"talk-talk-talk\")\n        if 'hedy_honor' not in session['achieved'] and \"Hedy\" in code:\n            session['new_achieved'].append(\"hedy_honor\")\n        if 'hedy-ious' not in session['achieved']:\n            all_print_arguments = hedy.all_print_arguments(code, level, session['lang'])\n            for argument in all_print_arguments:\n                if all_print_arguments.count(argument) >= 10:\n                    session['new_achieved'].append(\"hedy-ious\")\n                    break\n\n\n    def check_response_achievements(self, code, response):\n        if 'ninja_turtle' not in session['achieved'] and 'has_turtle' in response and response['has_turtle']:\n            session['new_achieved'].append(\"ninja_turtle\")\n        if 'watch_out' not in session['achieved'] and 'Warning' in response and response['Warning']:\n            session['new_achieved'].append(\"watch_out\")\n        if 'Error' in response and response['Error']:\n            session['consecutive_errors'] += 1\n            if session['previous_code'] == code:\n                if session['identical_consecutive_errors'] == 0:\n                    session['identical_consecutive_errors'] += 2 #We have to count the first one too!\n                session['identical_consecutive_errors'] += 1\n            if session['identical_consecutive_errors'] >= 3:\n                if 'programming_panic' not in session['achieved']:\n                    session['new_achieved'].append(\"programming_panic\")\n            session['previous_code'] = code\n        else:\n            if 'programming_protagonist' not in session['achieved'] and session['consecutive_errors'] >= 1:\n                session['new_achieved'].append(\"programming_protagonist\")\n            session['consecutive_errors'] = 0\n            session['identical_consecutive_errors'] = 0\n\n\n\n", "path": "website/achievements.py"}], "after_files": [{"content": "from website import database\nfrom hedyweb import AchievementTranslations\nfrom website.auth import requires_login\nfrom flask import request, jsonify, session\nimport hedy\n\n\nclass Achievements:\n\n    def __init__(self):\n        self.DATABASE = database.Database()\n        self.TRANSLATIONS = AchievementTranslations()\n\n    def routes(self, app, database):\n        global DATABASE\n        DATABASE = database\n\n        @app.route('/achievements', methods=['POST'])\n        @requires_login\n        def push_new_achievement(user):\n            body = request.json\n            if \"achievement\" in body:\n                if not session['achieved']:\n                    self.initialize_user_data(user['username'])\n                if body['achievement'] not in session['achieved'] and body['achievement'] in self.TRANSLATIONS.get_translations(session['lang']):\n                    return jsonify({\"achievements\": self.verify_pushed_achievement(user.get('username'), body['achievement'])})\n            return jsonify({})\n\n    def increase_count(self, category):\n        if category == \"run\":\n            session['run_programs'] += 1\n        elif category == \"saved\":\n            session['saved_programs'] += 1\n        elif category == \"submitted\":\n            session['submitted_programs'] += 1\n\n    def initialize_user_data(self, username):\n        achievements_data = self.DATABASE.progress_by_username(username)\n        session['new_achieved'] = []\n        session['new_commands'] = []\n        session['previous_code'] = None\n        session['identical_consecutive_errors'] = 0\n        session['consecutive_errors'] = 0\n        if not achievements_data:\n            achievements_data = {}\n        if 'achieved' in achievements_data:\n            session['achieved'] = achievements_data['achieved']\n        else:\n            session['achieved'] = []\n        if 'commands' in achievements_data:\n            session['commands'] = achievements_data['commands']\n        else:\n            session['commands'] = []\n        if 'run_programs' in achievements_data:\n            session['run_programs'] = achievements_data['run_programs']\n        else:\n            session['run_programs'] = 0\n        if 'saved_programs' in achievements_data:\n            session['saved_programs'] = achievements_data['saved_programs']\n        else:\n            session['saved_programs'] = 0\n        if 'submitted_programs' in achievements_data:\n            session['submitted_programs'] = achievements_data['submitted_programs']\n        else:\n            session['submitted_programs'] = 0\n\n    def add_single_achievement(self, username, achievement):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        if achievement not in session['achieved'] and achievement in self.TRANSLATIONS.get_translations(session['lang']):\n            return self.verify_pushed_achievement(username, achievement)\n        else:\n            return None\n\n    def verify_run_achievements(self, username, code=None, level=None, response=None):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        self.check_programs_run()\n        if code and level:\n            self.check_code_achievements(code, level)\n        if code and response:\n            self.check_response_achievements(code, response)\n\n        if len(session['commands']) > 0:\n            for command in session['new_commands']:\n                session['commands'].append(command)\n            self.DATABASE.add_commands_to_username(username, session['commands'])\n\n        if len(session['new_achieved']) > 0:\n            self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n            for achievement in session['new_achieved']:\n                session['achieved'].append(achievement)\n            return True\n        return False\n\n    def verify_save_achievements(self, username, adventure=None):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        self.check_programs_saved()\n        if adventure and 'adventure_is_worthwhile' not in session['achieved']:\n            session['new_achieved'].append(\"adventure_is_worthwhile\")\n        if len(session['new_achieved']) > 0:\n            self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n            for achievement in session['new_achieved']:\n                session['achieved'].append(achievement)\n            return True\n        return False\n\n    def verify_submit_achievements(self, username):\n        if not session['achieved']:\n            self.initialize_user_data(username)\n        self.check_programs_submitted()\n\n        if len(session['new_achieved']) > 0:\n            self.DATABASE.add_achievements_to_username(username, session['new_achieved'])\n            for achievement in session['new_achieved']:\n                session['achieved'].append(achievement)\n            return True\n        return False\n\n    def verify_pushed_achievement(self, username, achievement):\n        session['new_achieved'] = [achievement]\n        self.DATABASE.add_achievement_to_username(username, achievement)\n        session['achieved'].append(achievement)\n        return self.get_earned_achievements()\n\n    def get_earned_achievements(self):\n        translations = self.TRANSLATIONS.get_translations(session['lang'])\n        translated_achievements = []\n        for achievement in session['new_achieved']:\n            translated_achievements.append([translations[achievement]['title'], translations[achievement]['text'], translations[achievement]['image']])\n        session['new_achieved'] = [] #Once we get earned achievements -> empty the array with \"waiting\" ones\n        session['new_commands'] = []\n        return translated_achievements\n\n    def check_programs_run(self):\n        if 'getting_started_I' not in session['achieved'] and session['run_programs'] >= 1:\n            session['new_achieved'].append(\"getting_started_I\")\n        if 'getting_started_II' not in session['achieved'] and session['run_programs'] >= 10:\n            session['new_achieved'].append(\"getting_started_II\")\n        if 'getting_started_III' not in session['achieved'] and session['run_programs'] >= 50:\n            session['new_achieved'].append(\"getting_started_III\")\n        if 'getting_started_IV' not in session['achieved'] and session['run_programs'] >= 200:\n            session['new_achieved'].append(\"getting_started_IV\")\n        if 'getting_started_V' not in session['achieved'] and session['run_programs'] >= 500:\n            session['new_achieved'].append(\"getting_started_V\")\n\n    def check_programs_saved(self):\n        if 'one_to_remember_I' not in session['achieved'] and session['saved_programs'] >= 1:\n            session['new_achieved'].append(\"one_to_remember_I\")\n        if 'one_to_remember_II' not in session['achieved'] and session['saved_programs'] >= 5:\n            session['new_achieved'].append(\"one_to_remember_II\")\n        if 'one_to_remember_III' not in session['achieved'] and session['saved_programs'] >= 10:\n            session['new_achieved'].append(\"one_to_remember_III\")\n        if 'one_to_remember_IV' not in session['achieved'] and session['saved_programs'] >= 25:\n            session['new_achieved'].append(\"one_to_remember_IV\")\n        if 'one_to_remember_V' not in session['achieved'] and session['saved_programs'] >= 50:\n            session['new_achieved'].append(\"one_to_remember_V\")\n\n    def check_programs_submitted(self):\n        if 'deadline_daredevil_I' not in session['achieved'] and session['submitted_programs'] >= 1:\n            session['new_achieved'].append(\"deadline_daredevil_I\")\n        if 'deadline_daredevil_II' not in session['achieved'] and session['submitted_programs'] >= 3:\n            session['new_achieved'].append(\"deadline_daredevil_II\")\n        if 'deadline_daredevil_III' not in session['achieved'] and session['submitted_programs'] >= 10:\n            session['new_achieved'].append(\"deadline_daredevil_III\")\n\n    def check_code_achievements(self, code, level):\n        commands_in_code = hedy.all_commands(code, level, session['lang'])\n        if 'trying_is_key' not in session['achieved']:\n            for command in set(commands_in_code):\n                if command not in session['commands']:\n                    session['new_commands'].append(command)\n        if set(session['commands']) == set(hedy.commands_per_level.get(hedy.HEDY_MAX_LEVEL)):\n            session['new_achieved'].append(\"trying_is_key\")\n        if 'did_you_say_please' not in session['achieved'] and \"ask\" in hedy.all_commands(code, level, session['lang']):\n            session['new_achieved'].append(\"did_you_say_please\")\n        if 'talk-talk-talk' not in session['achieved'] and hedy.all_commands(code, level, session['lang']).count(\"ask\") >= 5:\n            session['new_achieved'].append(\"talk-talk-talk\")\n        if 'hedy_honor' not in session['achieved'] and \"Hedy\" in code:\n            session['new_achieved'].append(\"hedy_honor\")\n        if 'hedy-ious' not in session['achieved']:\n            all_print_arguments = hedy.all_print_arguments(code, level, session['lang'])\n            for argument in all_print_arguments:\n                if all_print_arguments.count(argument) >= 10:\n                    session['new_achieved'].append(\"hedy-ious\")\n                    break\n\n\n    def check_response_achievements(self, code, response):\n        if 'ninja_turtle' not in session['achieved'] and 'has_turtle' in response and response['has_turtle']:\n            session['new_achieved'].append(\"ninja_turtle\")\n        if 'watch_out' not in session['achieved'] and 'Warning' in response and response['Warning']:\n            session['new_achieved'].append(\"watch_out\")\n        if 'Error' in response and response['Error']:\n            session['consecutive_errors'] += 1\n            if session['previous_code'] == code:\n                if session['identical_consecutive_errors'] == 0:\n                    session['identical_consecutive_errors'] += 2 #We have to count the first one too!\n                session['identical_consecutive_errors'] += 1\n            if session['identical_consecutive_errors'] >= 3:\n                if 'programming_panic' not in session['achieved']:\n                    session['new_achieved'].append(\"programming_panic\")\n            session['previous_code'] = code\n        else:\n            if 'programming_protagonist' not in session['achieved'] and session['consecutive_errors'] >= 1:\n                session['new_achieved'].append(\"programming_protagonist\")\n            session['consecutive_errors'] = 0\n            session['identical_consecutive_errors'] = 0\n\n\n\n", "path": "website/achievements.py"}]}