Repository: hedyorg/hedy

Issue:
Add comments to a lower level
In level 4 my students start to write long pieces of code >25 lines. Debugging is a lot harder if you don't have the option to use comments (`#`). Now comments are introduced in level 15, I think it would be nice to add them to an earlier level maybe between level 3 and 4. 


Discussion:
This is a great point @OnnoEbbens. The fix is easy to do, of course, but the deeper problem is how to teach comments. Do we do this in an entire level on its own as we have now? That does not really fit DG6 because it does not really allow kids to build more interesting programs because it does not give more expressive power.

Potentially, we could make a level specifically about the practice of debugging, using comments not only as a way to describe code but also to turn code on and off. In that level we can seed all adventures with errors kids have to fix? Would be a really good skill to have and we see kids lacking there. What do you think? (also tagging @MarleenGilsing to think about this)
I think it is a great idea to have a level specifically about debugging where we can introduce comments. In my opinion it would be nice to introduce this after level 4. In level 4 the students will start having issues with many lines of code that are hard to debug. This will make it easier to understand why they need to learn about debugging in the next level. Also in level 4 they have learned enough commands so we can make sufficient examples of errors to debug.
I think it's a great idea to teach kids about debugging more specifically. I love the idea of making faulty adventures and having the students fix them. I even think we could do this more often than only 1 time after level 4. Maybe instead of making it a regular level, we could make it some kind of optional sublevel with a different lay-out and add a debugging sublevel after - let's say- every other level. (For example I think level 2 could use some kind of entry-level debugging as well). 

Of course debugging is also mentioned in the quizzes, but in the quizzes kids have multiple choice options. And doing it yourself is a different skill. 

I think we should also keep in mind that there will be huge differences in debugging skills. In the levels students always have the option to just copy our examples, but this level will not, so it might cause some frustration. So we need to find a way to accomodate the students who have trouble understanding the code as well, maybe with (video) tutorials, or adding hint buttons? 




Resolving patch:
diff --git a/hedy.py b/hedy.py
--- a/hedy.py
+++ b/hedy.py
@@ -635,8 +635,10 @@ def echo(self, args):
         argument = process_characters_needing_escape(args[0])
         return "print('" + argument + "'+answer)"
 
-    def ask(self, args):
+    def comment(self, args):
+        return f"#{''.join(args)}"
 
+    def ask(self, args):
         argument = process_characters_needing_escape(args[0])
         return "answer = input('" + argument + "')"
 
@@ -1329,12 +1331,7 @@ def change_list_item(self, args):
 #         return ' and '.join(args)
 #     def orcondition(self, args):
 #         return ' or '.join(args)
-#
-# @hedy_transpiler(level=16)
-# class ConvertToPython_16(ConvertToPython_15):
-#     def comment(self, args):
-#         return f"# {args}"
-#
+
 
 #
 # @hedy_transpiler(level=19)


Test patch:
diff --git a/tests/test_level_01.py b/tests/test_level_01.py
--- a/tests/test_level_01.py
+++ b/tests/test_level_01.py
@@ -19,6 +19,8 @@ class TestsLevel1(HedyTester):
   # * negative tests should be
   # * situation_gives_exception
 
+
+
   # print tests
   def test_print(self):
     result = hedy.transpile("print Hallo welkom bij Hedy!", self.level)
@@ -177,6 +179,17 @@ def test_one_turn_left(self):
     self.assertEqual(expected, result.code)
     self.assertEqual(True, result.has_turtle)
 
+  # comment test
+  def test_comment(self):
+    code = "# geen commentaar"
+    expected = "# geen commentaar"
+    self.multi_level_tester(
+      code=code,
+      expected=expected,
+      extra_check_function=self.is_not_turtle(),
+      test_name=self.name()
+    )
+
   # combined keywords tests
   def test_multiple_forward_without_arguments(self):
     result = hedy.transpile("forward\nforward", self.level)