Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📜 Nicer workbooks #5860

Closed
wants to merge 15 commits into from
1,003 changes: 998 additions & 5 deletions content/pages/en.yaml

Large diffs are not rendered by default.

33 changes: 26 additions & 7 deletions content/pages/pages.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,32 @@
"type": "object",
"additionalProperties": false,
"properties": {
"title": { "type": "string" },
"teacher-guide": { "type": "array", "items": { "$ref": "#/definitions/DocSection" } },

"learn-more-sections": { "$ref": "#/definitions/BasicSections" },
"join-sections": { "$ref": "#/definitions/BasicSections" },
"home-sections": { "$ref": "#/definitions/BasicSections" },
"start-sections": { "$ref": "#/definitions/BasicSections" }
"title": {
"type": "string"
},
"teacher-guide": {
"type": "array",
"items": {
"$ref": "#/definitions/DocSection"
}
},
"learn-more-sections": {
"$ref": "#/definitions/BasicSections"
},
"join-sections": {
"$ref": "#/definitions/BasicSections"
},
"home-sections": {
"$ref": "#/definitions/BasicSections"
},
"start-sections": {
"$ref": "#/definitions/BasicSections"
},
"workbooks": {
"levels": {
"type": "array"
}
}
},
"required": [
"title", "teacher-guide", "learn-more-sections", "join-sections", "home-sections"
Expand Down
43 changes: 43 additions & 0 deletions content/workbooks/blocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@


- type : text
contents : |-
code : |-

- type : output
code : |-
answer :
lines : 1

- type : circle
goal :
code : |-
answer :

- type : MC-code
options : ["Goed" , "Fout"]
code : |-
answer :

- type : define
word :
answer :
lines : 1


- type: input
answer: |-
output: |-



- level: '1'
intro: |-
### Printen en invoer

Aan het einde van de les kun jij:

* Code schrijven die tekst print
* Een verhaal met invoer maken

exercises:
4 changes: 2 additions & 2 deletions content/workbooks/lesson3/les3a.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ print Het antwoord is antwoorden at random
```

Maar soms wil je dat de gebruiker van een programma ook opties kan toevoegen.
Dat doe je met een `add` en een `to` commando.
Dat doe je met een `add` en een `to` commando. Je kan ook iets uit een lijst verwijderen, met `remove` en `from`.

```
dieren is 🐿, 🦔, 🦇, 🦉
Expand All @@ -146,7 +146,7 @@ add dier to dieren
print het was een dieren op willekeurig
```

Je kan ook iets uit een lijst verwijderen, met `remove` en `from`.


#### Opdracht 4: Goed of fout?

Expand Down
3 changes: 2 additions & 1 deletion content/workbooks/lesson6/les6a-autogenerated.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ Denk eraan dat computers heel precies zijn, iedere spatie of punt of komma telt!
* Zit er een `ask` in de code? Kies dan zelf een antwoord.
* Zit er een `random` in de code? Kies dan een mogelijke keus van de computer.



**💻 Vraag**: Wat is de uitvoer van deze code? <br>
Code: Uitvoer:
```hedy
Expand Down Expand Up @@ -203,5 +205,4 @@ ________________________________________________________________________________
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________<br>
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________<br>
____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________<br>


2 changes: 1 addition & 1 deletion hedyweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class PageTranslations:
def __init__(self, page):
self.data = {}
if page in ['start', 'join', 'learn-more', 'for-teachers']:
if page in ['start', 'join', 'learn-more', 'for-teachers', 'workbooks']:
translations = glob.glob('content/pages/*.yaml')
else:
translations = glob.glob('content/pages/' + page + '/*.yaml')
Expand Down
82 changes: 82 additions & 0 deletions templates/workbooks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{% extends "auth.html" %}

{% block full_width_content %}
<div class="bg-blue-200 mb-4">
<div class="py-4 flex items-center w-full copy-container mx-auto">
<div class="tracking-wide text-xl font-extralight">{{ page_title }}</div>
</div>
</div>
<div class="copy-container text-business-copy" id="teacher_documentation">
<div class="flex gap-8">
<div class="flex-1">
{% if workbook.intro %}
<p>{{ workbook.intro|commonmark }}</p>
{% endif %}

{% for exercise in workbook.exercises %}
{% if exercise.contents %}
<p>{{ exercise.contents|commonmark }}</p>
<!-- contents kan ook nog een code blok hebben --!>
{% if exercise.code %}
<div class="w-full lg:w-1/2 turn-pre-into-ace my-5">
<pre class="common-mistakes" level="{{ workbook.level }}" style="font-size: 0.95em;">{{ exercise.code }}</pre>
</div>
{% endif %}

{% else %}

{% if exercise.type == 'output' or exercise.type =='question' or exercise.type =='define' or exercise.type == 'circle' or exercise.type == 'MC-code' %}
<h4 id="{{exercise.title|slugify}}">{{ exercise.icon}} {{ exercise.title }}</h4>
{{ exercise.text|commonmark }}

<table>
<tr>
<td width='5000px'>
{% if exercise.code %}
<div class="w-full lg:w-1/2 turn-pre-into-ace my-5">
<pre class="common-mistakes" level="{{ workbook.level }}" style="font-size: 0.95em;">{{ exercise.code }}</pre>
</div>
{% endif %}
</td>
<td width='600px' { text-align: left; }>
<!-- questions have lines OR options -->
{% if exercise.lines %}
{% for line in exercise.lines %}
{{ line }} <br>
{% endfor %}
{% endif %}
{% if exercise.options %}
{{ exercise.options }} <br>
{% endif %}
</td></tr>
</table>
{% endif %}

{% if exercise.type == 'input' %}
<h4 id="{{exercise.title|slugify}}">{{ exercise.icon}} {{ exercise.title }}</h4>
{{ exercise.text|commonmark }}
<table>
<tr>
<td width='800px'>
{% if exercise.lines %}
{% for line in exercise.lines %}
{{ line }} <br>
{% endfor %}
{% endif %}
</td>
<td width='600px'>
{{ exercise.output|commonmark }}
</td></tr>
</table>

{% endif %}
{% endif %}



{% endfor %}

</div>
</div>
</div>
{% endblock %}
53 changes: 53 additions & 0 deletions website/for_teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,59 @@ def for_teachers_page(self, user):
welcome_teacher=welcome_teacher,
))

@route("/workbooks/<level>", methods=["GET"])
def get_workbooks(self, level):
content = hedyweb.PageTranslations("workbooks").get_page_translations(g.lang)
workbooks = content['workbooks']
line = '_' * 30
workbook_for_level = workbooks['levels'][int(level)-1]

for exercise in workbook_for_level['exercises']:
if exercise['type'] == 'output':
exercise['title'] = 'Output'
exercise['icon'] = '💻'
exercise['text'] = '**Vraag**: Wat is de uitvoer van deze code?'

# lines zou ik hier ook uit het antwoord kunnen uitrekenen!
exercise['lines'] = [line for x in range(exercise['lines'])]

if exercise['type'] == 'circle':
exercise['title'] = 'Aanwijzen'
exercise['icon'] = '◯'
exercise['text'] = f'**Vraag**: Omcirkel {exercise['goal']} in deze code:'

elif exercise['type'] == 'input':
exercise['title'] = 'Input'
exercise['icon'] = '🧑‍💻'
exercise['text'] = '**Vraag**: Welke code hoort bij deze uitvoer?'
a = len(exercise['answer'].split('\n'))
exercise['lines'] = [line for x in range(a)]

elif exercise['type'] == 'MC-code':
exercise['title'] = 'Kies'
exercise['icon'] = '🤔'
exercise['text'] = '**Vraag**: Is deze code goed of fout?'
# let op! op een dag willen we misschien wel ander soorten MC, dan moet
# deze tekst anders
exercise['options'] = '〇 ' + ' 〇 '.join(exercise['options'])

elif exercise['type'] == 'define':
exercise['title'] = 'Definiëer'
exercise['icon'] = '📖'
exercise['text'] = f'**Vraag**: Wat betekent {exercise['word']}?'
exercise['lines'] = [line for x in range(exercise['lines'])]

elif exercise['type'] == 'question':
exercise['title'] = 'Open vraag'
exercise['icon'] = '✍️'
exercise['lines'] = [line for x in range(exercise['lines'])]

return render_template("workbooks.html",
current_page="teacher-manual",
level=level,
page_title=f'Workbook {level}',
workbook=workbook_for_level)

@route("/manual", methods=["GET"], defaults={'section_key': 'intro'})
@route("/manual/<section_key>", methods=["GET"])
def get_teacher_manual(self, section_key):
Expand Down
Loading