Repository: hedyorg/hedy

Issue:
[UI idea] Remove code palette on sidebar
**Idea incl level**
As discussed many times (such as is #1835) the interface is getting crowded, too crowded. With the adventures and all added options we have way to many functionality on a small screen. This can be confusing for children as there are too many options too choice from. One solution might be to hide the code palette on the sidebar. Increasing the size of the adventure tabs and code editor / output.


Discussion:

Resolving patch:
diff --git a/app.py b/app.py
--- a/app.py
+++ b/app.py
@@ -139,18 +139,32 @@ def load_adventures_per_level(lang, level):
         # if quizzes are not enabled, do not load it
         if short_name == 'end' and not config['quiz-enabled']:
             continue
-        all_adventures.append({
+        current_adventure = {
             'short_name': short_name,
             'name': adventure['name'],
             'image': adventure.get('image', None),
             'default_save_name': adventure['default_save_name'],
             'text': adventure['levels'][level].get('story_text', 'No Story Text'),
+            'example_code': adventure['levels'][level].get('example_code'),
             'start_code': adventure['levels'][level].get('start_code', ''),
             'loaded_program': '' if not loaded_programs.get(short_name) else {
                 'name': loaded_programs.get(short_name)['name'],
                 'code': loaded_programs.get(short_name)['code']
             }
-        })
+        }
+        #Sometimes we have multiple text and example_code -> iterate these and add as well!
+        extra_stories = []
+        for i in range(2, 10):
+            extra_story = {}
+            if adventure['levels'][level].get('story_text_' + str(i)):
+                extra_story['text'] = adventure['levels'][level].get('story_text_' + str(i))
+                if adventure['levels'][level].get('example_code_' + str(i)):
+                    extra_story['example_code'] = adventure['levels'][level].get('example_code_' + str(i))
+                extra_stories.append(extra_story)
+            else:
+                break
+        current_adventure['extra_stories'] = extra_stories
+        all_adventures.append(current_adventure)
     # We create a 'level' pseudo assignment to store the loaded program for level mode, if any.
     all_adventures.append({
         'short_name': 'level',
diff --git a/hedy_content.py b/hedy_content.py
--- a/hedy_content.py
+++ b/hedy_content.py
@@ -24,8 +24,22 @@ def max_level(self):
 
   def get_defaults_for_level(self, level):
     #grabs level defaults from yaml and converts to DefaultValues type
-    default_values = self.levels[level]
-
+    default_values = copy.deepcopy(self.levels[level])
+
+    # Sometimes we have multiple text and example_code -> iterate these and add as well!
+    extra_examples = []
+    for i in range(2, 10):
+      extra_example = {}
+      if default_values.get('intro_text_' + str(i)):
+        extra_example['intro_text'] = default_values.get('intro_text_' + str(i))
+        default_values.pop('intro_text_' + str(i))
+        if default_values.get('example_code_' + str(i)):
+          extra_example['example_code'] = default_values.get('example_code_' + str(i))
+          default_values.pop('example_code_' + str(i))
+        extra_examples.append(extra_example)
+      else:
+        break
+    default_values['extra_examples'] = extra_examples
     default_type = {
       "level": str(level),
     }
@@ -69,6 +83,8 @@ class DefaultValues:
 
   level = attr.ib()
   intro_text = attr.ib(default=None)
+  example_code = attr.ib(default=None)
+  extra_examples = attr.ib(default=None)
   start_code = attr.ib(default=None)
   commands = attr.ib(default=None)
 


Test patch: