Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Felienne/hedy
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Mar 19, 2020
2 parents efdee4b + e2913d1 commit 17c5654
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 71 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Levels
------

In its current form, Hedy consists of 13 different levels. The levels
follow the lesson series [**Python in de klas**(Python in the
classroom)[^1] ]in such a way that these existing lessons can be
follow the lesson series [**Python in de klas**](http://pythonindeklas.nl/)
("Python in the classroom") in such a way that these existing lessons can be
executed with Hedy instead of with Python.

### Level 1: Printing and input
Expand All @@ -90,8 +90,8 @@ create lists and retrieve elements, including random elements from lists
with [`at`]. Adding lists and especially adding the option to select a
random item from a list allows for the creation of more interesting
programs such as a guessing game, a story with random elements, which is
an assignment from [**Python in de klas**(Python in the
classroom)[^2] ], or a customized dice.
an assignment from [**Python in de klas**](http://pythonindeklas.nl/)
("Python in the classroom"), or a customized dice.

###Level 3: Quotation marks and types
In Level 3 the first syntactic element is introduced: the use of
Expand All @@ -104,15 +104,7 @@ programming concepts, which underlines their interdependency. The
variable syntax using [`is`] remains unchanged, meaning that learners
can now use both [`number is 12`] and [`name is Hedy`].

### Level 4: Calculations
In Level 4, students learn to calculate with variables, so addition,
multiplication, subtraction and division are introduced. While this
might seem like a simple step, our experience taught us that the use of
[`*`] for multiplication, rather than $\times$, and the use of a
period rather than a comma as decimal separator for non-US students is a
steep learning curve and should be treated as a separate learning goal.

### Level 5: Selection with if and else flat
### Level 4: Selection with if and else flat

In Level 5, selection with the if statement is introduced, but the
syntax is ‘flat’, i.e. placed on one line, resembling a regular syntax
Expand All @@ -122,7 +114,7 @@ Else statements are also included, and are also placed on one line,
using the keyword [`else`]:\
[`if name is print else print `].

### Level 6: Repetition with repeat x times
### Level 5: Repetition with repeat x times

In working with non-English native Python novices. Research has found
the keyword [`for`] to be a confusing word for repetition, especially
Expand All @@ -132,6 +124,16 @@ Quorum [@stefik_quorum_2017] syntax [`repeat x times`]. In this
initial form, like the if the syntax is placed on one line:\
[`repeat 5 times print `]

### Level 6: Calculations
Note: this level was originally planed as 4, is now moved up to 6. Might be moved to another place based on experiences of kids testing now.
In Level 4, students learn to calculate with variables, so addition,
multiplication, subtraction and division are introduced. While this
might seem like a simple step, our experience taught us that the use of
[`*`] for multiplication, rather than $\times$, and the use of a
period rather than a comma as decimal separator for non-US students is a
steep learning curve and should be treated as a separate learning goal.


### Level 7: Code blocks

After Level 6, there is a clear need to ‘move on’, as the body of a loop
Expand Down
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def index():
return jsonify({"Error": str(E)})

arguments_dict['page_title'] = response_texts_lang['Page_Title']
arguments_dict['level_title'] = response_texts_lang['Level']
arguments_dict['code_title'] = response_texts_lang['Code']
arguments_dict['docs_title'] = response_texts_lang['Docs']
arguments_dict['video_title'] = response_texts_lang['Video']
Expand Down Expand Up @@ -165,6 +166,7 @@ def docs():
arguments_dict['level'] = level
arguments_dict['pagetitle'] = f'Level{level}'
arguments_dict['lang'] = lang
arguments_dict['level_title'] = response_texts_lang['Level']
arguments_dict['code_title'] = response_texts_lang['Code']
arguments_dict['docs_title'] = response_texts_lang['Docs']
arguments_dict['video_title'] = response_texts_lang['Video']
Expand All @@ -187,6 +189,7 @@ def video():
arguments_dict['pagetitle'] = f'Level{level}'
arguments_dict['lang'] = lang
arguments_dict['selected_page'] = 'video'
arguments_dict['level_title'] = response_texts_lang['Level']
arguments_dict['code_title'] = response_texts_lang['Code']
arguments_dict['docs_title'] = response_texts_lang['Docs']
arguments_dict['video_title'] = response_texts_lang['Video']
Expand All @@ -208,6 +211,7 @@ def contact():
arguments_dict['pagetitle'] = f'Level{level}'
arguments_dict['lang'] = lang
arguments_dict['selected_page'] = 'video'
arguments_dict['level_title'] = response_texts_lang['Level']
arguments_dict['code_title'] = response_texts_lang['Code']
arguments_dict['docs_title'] = response_texts_lang['Docs']
arguments_dict['video_title'] = response_texts_lang['Video']
Expand Down
4 changes: 2 additions & 2 deletions docs/nl-level3.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ In Level 3 kunnen we ook weer steen schaar papier programmeren. Maar als je er t
Herinnering: random (je zegt ren-dom) is het Engelse woord voor willekeurig.

# Maak dobbelsteen na
Je kunt ook in Level 3 weer een dobbelsteen maken. Je kunt trouwens ook zinnen maken met de dobbelwaarde in de zin.
Die van Regenwormen maak je zo, in een mooie zin (met aanhalingstekens natuurlijk)
Je kunt ook in Level 3 weer een dobbelsteen maken. Je kunt nu ook zinnen maken met de dobbelwaarde in de zin.
Die van Regenwormen maak je zo, in een mooie zin (met aanhalingstekens natuurlijk).

* `keuzes is 1, 2, 3, 4, 5, regenworm`
* `print 'je hebt ' keuzes at random ' gegooid'`
Expand Down
81 changes: 81 additions & 0 deletions docs/nl-level4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
In level 4 blijven de regels hetzelfde voor ask en print. Je moet dus nog steeds aanhalingstekens gebruiken als je iets wilt printen.
Er komt nu wel een nieuwe code bij, de if. if is Engels voor als.

Hier vind je weer een aantal opdrachten om mee aan de slag te gaan.

# Niet voor je kleine zusje of broertje!
Toen ik zelf leerde programmeren, wat het eerste programma dat ik maakte een programma om te kijken of mijn zusje niet stiekem op de computer zat.
Dat kun jij nu ook maken, het gaat zo:

* `naam is ask Hoe heet jij?`
* `if naam is Felienne print 'ok jij mag computeren' else print 'verboden toegang voor jou'`

Deze code bekijkt of de naam die wordt ingetypt precies "Felienne" is. Zo kan, dan print Hedy de eerste code, anders de tweede.
Let op, Hedy kijkt letterlijk naar de naam, dus het moet precies kloppen, ook met hoofdletter.

# Steen, schaar, papier
In Level 4 kunnen we ook weer steen schaar papier programmeren, maar nu kun je ook echt tegen de computer spelen, en bekijken wie de winnaar is.
Hier is het begin van het programma, maak jij de regels zelf af?

* `jouwkeuze is ask wat kies jij?`
* `keuzes is steen, schaar, papier`
* `computerkeuze is keuzes at random`
* `if computerkeuze is schaar and jouw_keuze is papier print 'de computer wint'`
* `if computerkeuze is schaar and jouw_keuze is steen print 'jij wint'`

Herinnering: random (je zegt ren-dom) is het Engelse woord voor willekeurig, and is het Engelse woord voor en.

# Maak dobbelsteen na
Je kunt ook in Level 4 weer een dobbelsteen maken en daarbij een if gebruiken. Bijv zo:

* `keuzes is 1, 2, 3, 4, 5, regenworm`
* `worp is keuzes at random`
* `print 'je hebt worp gegooid'`
* `if worp is regenworm print 'Je mag stoppen met gooien.' else print 'Je moet nog een keer hoor!`

Maar misschien wil jij wel een dobbelsteen uit een heel ander spel namaken.

# Wie doet de afwas?
Ook je afwasprogramma kun je nu leuker maken met een if. Bijvoorbeeld zo:

Dat doe je zo:

* `mensen is mama, papa, Emma, Sophie`
* `afwasser is mensen at random`
* `if afwasser is Sophie print 'chips ik moet de afwas doen' else print 'gelukkig geen afwas want ' afwasser ' doet het'`

# Een beter verhaal
Wat je ook kunt doet is je verhaal weer leuker maken, want nu kun je verschillende eindes programmeren.

###Voorbeeld
Maak een verhaal met twee eindes, bijvoorbeeld zo:

* De prinses loopt door het bos
* Ze komt een monster tegen

Goed einde:
* Ze pakt haar zwaard en het monster rent snel weg

Slecht einde
* Het monster eet de prinses op


### Opdracht

Nu jij!

1. Schrijf een verhaal met twee eindes

### Voorbeeld Hedy code
* `print 'De prinses loopt door het bos'`
* `print 'Ze komt een monster tegen'`
* `einde is ask Wil je een goed of slecht einde?`
* `if einde is goed print 'Ze pakt haar zwaard en het monster rent snel weg' else print 'Het monster eet de prinses op'`

### Een interactief verhaal
Je kunt ook zorgen dat er weer een naam ingevoerd kan worden. Dat werkt net zoals in level 3. Dat kun je dus ook combineren met een if, en dan heb je al een heel programma gemaakt!

### Herhaling in je verhaal of spel
Helaas kun je nu steeds maar 1 dobbelsteen gooien, of 1 keer bepalen wie de afwas doet. Regenwormen moet eigenlijk met 8 dobbelstenen, en
misschien wil jij wel een afwasrooster maken voor de hele week! Some is het handig als je codes een paar keer kan herhalen.
Dat kun je leren in Level 5.
77 changes: 32 additions & 45 deletions grammars/level4.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,35 @@
start: _EOL* statement+
start: program
program: command ("\n" command)*
command: "print " (quoted_text | list_access | var) (" " (quoted_text | list_access | var))* -> print
| "if " equality_check " " command " else " command -> ifelse
| "if " equality_check " " command -> ifs //if cannot be used in Python, hence ifs
| text " is ask " textwithspaces punctuation* -> ask
| text " is " text ((", "|",") text)+ -> assign_list
| text " is " text -> assign //placing it here means print is will print 'is' and print is Felienne will print 'is Felienne'
| text " is " var " at " (index | random) -> list_access_var
| text " " textwithspaces -> invalid

//TODO: I don't like the " " and "print " in the commands
//would rather have them here but I am unsure how to stop hem from appearing in the tree that way
//leaving as such for now

equality_check: text " is " text (" and " equality_check)* -> equality_check
var: LETTER+ -> var //TODO: should be used in assign too?
list_access : var " at " (index | random) -> list_access

index : DIGIT+
random : "random"
punctuation : PUNCTUATION -> punctuation
textwithspaces: (LETTER | DIGIT | WS_INLINE)+ -> text
quoted_text: QUOTE (LETTER | DIGIT | PUNCTUATION | WS_INLINE)+ QUOTE -> text
QUOTE : "'"
text: (LETTER | DIGIT)+ -> text
PUNCTUATION: "!" | "?" | "." //uppercase places tokens in tree

%import common.LETTER // imports from terminal library
%import common.DIGIT // imports from terminal library
%import common.WS_INLINE // imports from terminal library
%import common.NEWLINE // imports from terminal library

statement: function_call
| assignment _EOL+
| expression _EOL+

function_call: NAME expression _EOL+

assignment: NAME "is" expression

?expression: sum
| expression "=" sum -> eq
| expression "!=" sum -> ne
| expression "<=" sum -> le
| expression ">=" sum -> ge
| expression "<" sum -> lt
| expression ">" sum -> gt

?sum: product
| sum "+" product -> addition
| sum "-" product -> substraction

?product: atom
| product "*" atom -> multiplication
| product "/" atom -> division
| product "%" atom -> modulo

?atom: NAME
| INTEGER
| FLOAT
| STRING
| "[" (expression? | (expression ",")+ expression) "]" -> list
| "(" expression? ")"
| NAME "at" expression -> list_access // TODO: shift reduce errors


_EOL: /(\r?\n[\t ]*)+/

%import common.WS_INLINE
%import common.SIGNED_INT -> INTEGER
%import common.FLOAT -> FLOAT
%import common.CNAME -> NAME
%import common._STRING_ESC_INNER
%import common.ESCAPED_STRING -> STRING // TODO: support single quoted strings

%declare INDENT DEDENT

%ignore WS_INLINE
48 changes: 48 additions & 0 deletions grammars/level6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
start: _EOL* statement+

statement: function_call
| assignment _EOL+
| expression _EOL+

function_call: NAME expression _EOL+

assignment: NAME "is" expression

?expression: sum
| expression "=" sum -> eq
| expression "!=" sum -> ne
| expression "<=" sum -> le
| expression ">=" sum -> ge
| expression "<" sum -> lt
| expression ">" sum -> gt

?sum: product
| sum "+" product -> addition
| sum "-" product -> substraction

?product: atom
| product "*" atom -> multiplication
| product "/" atom -> division
| product "%" atom -> modulo

?atom: NAME
| INTEGER
| FLOAT
| STRING
| "[" (expression? | (expression ",")+ expression) "]" -> list
| "(" expression? ")"
| NAME "at" expression -> list_access // TODO: shift reduce errors


_EOL: /(\r?\n[\t ]*)+/

%import common.WS_INLINE
%import common.SIGNED_INT -> INTEGER
%import common.FLOAT -> FLOAT
%import common.CNAME -> NAME
%import common._STRING_ESC_INNER
%import common.ESCAPED_STRING -> STRING // TODO: support single quoted strings

%declare INDENT DEDENT

%ignore WS_INLINE

0 comments on commit 17c5654

Please sign in to comment.