Lessons fixes (#1609)

* fixing a bunch of lessons

* more fixes

* more fixes

* more cleanup

* Additional fixes
This commit is contained in:
Peli de Halleux
2018-11-09 15:36:46 -08:00
committed by GitHub
parent 2aa8d0cec6
commit 50367217f3
20 changed files with 75 additions and 91 deletions

View File

@ -15,7 +15,7 @@ input.onButtonPressed(Button.A, () => {
newAction();
}
})
input.onLogoDown(() => {
input.onGesture(Gesture.LogoDown, function () {
if (action == 1) {
game.addScore(1);
newAction();
@ -36,13 +36,13 @@ input.onButtonPressed(Button.B, () => {
## Challenge 1
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`.
Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
Now let's add some more types of instructions for the player to follow. Let's add `"PRESS PIN 0"`.
Change the global variable `action` to `math.randomRange(0, 3)` so that we can add a new **IF** statement that checks if `action == 3`. If it does, display instructions to press pin 0.
```typescript
let action = 0;
export function newAction() {
action = Math.randomRange(0, 4)
action = Math.randomRange(0, 3)
if (action == 0) {
basic.showString("PUSH A", 150) // ***
}
@ -60,7 +60,7 @@ export function newAction() {
## Challenge 2
Now let's implement `PRESS PIN 0` in the main. Create a condition of `input->on pin pressed("P0")` that will add one to the score and calls the method `new action`.
Now let's implement `PRESS PIN 0` in the main. Create a condition in an `input.onPinPressed` event that, whet pin `P0` is pressed, will add one to the score and then calls the `newAction` function.
```typescript
let action = 0;

View File

@ -21,7 +21,7 @@ let action = Math.randomRange(0, 3)
```blocks
let action = Math.randomRange(0, 3)
if (action == 0) {
basic.showString("PUSH A", 150)
basic.showString("PUSH A")
}
```
@ -41,14 +41,14 @@ input.onButtonPressed(Button.A, () => {
```blocks
let action = Math.randomRange(0, 3)
if (action == 1) {
basic.showString("LOGO DOWN", 150)
basic.showString("LOGO DOWN")
}
```
## 5. Write the code that increments the score if the @boardname@ logo is tilted down when the global variable called 'action' is equal to 1
```blocks
input.onLogoDown(() => {
input.onGesture(Gesture.LogoDown, function () {
let action = Math.randomRange(0, 3)
if (action == 1) {
game.addScore(1)
@ -61,14 +61,14 @@ input.onLogoDown(() => {
```blocks
let action = Math.randomRange(0, 3)
if (action == 2) {
basic.showString("SHAKE", 150)
basic.showString("SHAKE")
}
```
## 7. Write the code that increments the score if the @boardname@ is shaken when the global variable called 'action' is equal to 2
```blocks
input.onLogoDown(() => {
input.onGesture(Gesture.LogoDown, function () {
let action = Math.randomRange(0, 3)
if (action == 1) {
game.addScore(1)

View File

@ -15,10 +15,12 @@ Variables
## Prior learning/place of lesson in scheme of work
Learn how to create a catch the egg game game with **plot**, `led->plot` , **unplot**, `led->unplot`, and **acceleration** `input -> acceleration` to turn on and off LED lights on the LED screen. We will be learning how to create a catch the egg game app using global variables, forever loop, local variable, input acceleration, math min, math max, math random, math mod, if (conditionals), game library as well as simple commands, such as led plot, led unplot, and pause.
Learn how to create a catch the egg game game with ``||led:plot||`` , ``||led:unplot||``, and ``||input:acceleration||`` to turn on and off LED lights on the screen.
## Documentation
The blocks used in this lesson:
```cards
let x = 2;
led.unplot(0, 0);

View File

@ -8,25 +8,22 @@ Welcome! This tutorial will teach how to create a counter with a while loop. Let
## ~
Create a variable that acts as a counter and set it to 0.
Create a variable that acts as a counter and set it to `0`.
```blocks
let count = 0
```
Add a while loop that will loop over and over until the variable `count` equals 10.
Add a while loop that will loop over and over until the variable ``||variables:count||`` equals `10`.
```blocks
let count = 0
while (count < 10) {
}
```
Let's add a pause. Then show the value of the the count.
Let's add a pause. Then show the value of ``||variables:count||``.
```blocks
let count = 0;
@ -34,11 +31,9 @@ while (count < 10) {
basic.pause(100);
basic.showNumber(count)
}
```
Increase the value of count by one.
Increase the value of ``||variables:count||`` by one.
```blocks
let count = 0
@ -49,10 +44,8 @@ while (count < 10) {
}
```
## ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/digi-yoyo/challenges)!
## ~

View File

@ -19,7 +19,7 @@ while (count < 10) {
## Challenge 1
How about we create a counter that counts backwards from 10 to 1? Let's add a while loop that executes only when `count` is greater than 0.
How about we create a counter that counts backwards from `10` to `1`? Let's add a while loop that executes only when ``||variables:count||`` is greater than `0`.
```blocks
@ -33,19 +33,15 @@ while (count < 10) {
while (count > 0) {
}
```
## Challenge 2
Inside of the while loop, let's add `pause->(1000)` so that we have a pause between each number as it's counting down. Also, let's show `count`!
Inside of the while loop, let's add a ``||basic:pause||`` that waits for one seccond so that we have a pause between each number as it's counting down. Also, let's show ``||variables:count||``!
```blocks
let count = 0;
let count = 0;
while (count < 10) {
basic.pause(100);
basic.showNumber(count);
@ -62,12 +58,11 @@ while (count > 0) {
## Challenge 3
Now, we need `count` to decrease by one after the @boardname@ has displayed the value of `count`.
Now, we need ``||variables:count||`` to decrease by one after the @boardname@ has displayed the value of ``||variables:count||``.
We can do this by adding this line:
```blocks
let count = 0;
count = count + (count - 1);
```

View File

@ -10,7 +10,7 @@ Use this activity document to guide your work in the [guess the number tutorial]
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Describe what "input -> on button pressed" does?
## 1. Describe what ``||input:on button pressed||`` does?
<br />
@ -26,7 +26,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
```blocks
let randomNumber = Math.randomRange(0, 10)
basic.showNumber(randomNumber, 150)
basic.showNumber(randomNumber)
```
![](/static/mb/empty-microbit.png)

View File

@ -12,20 +12,19 @@ Collection
* [quiz](/lessons/headbands/quiz)
* [quiz answers](/lessons/headbands/quiz-answers)
## Class
Year 7
## Prior learning/place of lesson in scheme of work
Learn how to create a charades game with **collections**, ` create -> Collection of` , to store and retrieve data . We will be learning how to create a charades game using global variables, collection of string, add, Boolean, on logo down, on logo up, forever loop, if statements, running time as well as simple commands, such as show string and show number.
Learn how to create a charades game using **[arrays](/types/array)** to store and retrieve data. We'll learn how to create a charades game using global variables, a collection of strings, math add, Boolean, on logo down, on logo up, forever loop, if statements, running time as well as simple commands, such as show string and show number.
## What the teacher needs to know
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
* Algorithm: An unambiguous set of rules or a precise step-by-step guide to solve a problem or achieve a particular objective.
* Command: An instruction for the computer to execute, written in a particular programming language.
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
* Data: A structured set of numbers, possibly representing digitized text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
* Decomposing: The process through which problems or systems are broken down into their component parts, each of which may then be considered separately.
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
@ -117,4 +116,3 @@ Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algor
## Intended follow on
Publish script to the classroom.

View File

@ -11,12 +11,12 @@ coll.push("clock")
coll.push("night")
coll.push("cat")
coll.push("cow")
input.onLogoUp(() => {
input.onGesture(Gesture.LogoUp, function () {
let index = Math.randomRange(0, coll.length)
let word = coll[index]
basic.showString(word, 150)
basic.showString(word)
})
input.onScreenDown(() => {
input.onGesture(Gesture.ScreenDown, function () {
game.addScore(1)
})
game.startCountdown(30000)
@ -24,7 +24,7 @@ game.startCountdown(30000)
## Challenge 1
Let's add more words for the player to act out! But first, we need to increase the time in one round to give the player more time get through all the words. Let's change the `game->start countdown` statement.
Let's add more words for the player to act out! But first, we need to increase the time in one round to give the player more time get through all the words. Let's change the ``||game:start countdown||`` statement.
```blocks
let coll: string[] = []
@ -33,12 +33,12 @@ coll.push("clock")
coll.push("night")
coll.push("cat")
coll.push("cow")
input.onLogoUp(() => {
input.onGesture(Gesture.LogoUp, function () {
let index = Math.randomRange(0, coll.length)
let word = coll[index]
basic.showString(word, 150)
basic.showString(word)
})
input.onScreenDown(() => {
input.onGesture(Gesture.ScreenDown, function () {
game.addScore(1)
})
@ -49,7 +49,7 @@ game.startCountdown(60000)
## Challenge 2
Now let's add 5 more words to our list of charade words. Right above the the line `word:=coll->at(index)` add 5 lines that say `coll->add("")`. In this example, we will add the words **bicycle, telephone, sun, car, and ant** but you can add whatever words you like.
Now let's add 5 more words to our list of charade words. Right above the the line ``||arrays:get value at index||`` add 5 lines that say ``||arrays:coll add value to end||``. In this example, we will add the words **bicycle, telephone, sun, car, and ant** but you can add whatever words you like.
```blocks
let coll: string[] = []
@ -63,12 +63,12 @@ coll.push("telephone")
coll.push("sun")
coll.push("car")
coll.push("ant")
input.onLogoUp(() => {
input.onGesture(Gesture.LogoUp, function () {
let index = Math.randomRange(0, coll.length)
let word = coll[index]
basic.showString(word, 150)
basic.showString(word)
})
input.onScreenDown(() => {
input.onGesture(Gesture.ScreenDown, function () {
game.addScore(1)
})
game.startCountdown(30000)
@ -78,13 +78,9 @@ game.startCountdown(30000)
## Challenge 3
Remove a life using `game->remove life` when the screen is down using the `input->on screen down` event.
Remove a life using ``||game.remove life||`` when the screen is down using the ``||input:on screen down||`` event.
## Challenge 4
The collection has a function `random` that returns a random element. Update your code to use this function instead of using `math->random`.
## Challenge 5!
## Challenge 4!
Play the game and try guessing all these words in less than 2 minutes!

View File

@ -24,13 +24,13 @@ coll.push("puppy")
coll.push("clock")
```
Write the line of code that will display the string "puppy" using `data->coll`.
Write the line of code that will display the string "puppy" using ``||variables:coll||``.
<br/>
```blocks
let coll: string[] = []
basic.showString(coll[0], 150)
basic.showString(coll[0])
```
## 3. Consider the following lines of code.
@ -42,13 +42,13 @@ coll.push("clock")
coll.push("cat")
```
Write the line of code that will display the string "cat" using `data->coll`.
Write the line of code that will display the string "cat" using ``||variables:coll||``.
<br/>
```blocks
let coll: string[] = []
basic.showString(coll[2], 150)
basic.showString(coll[2])
```
## 4. Consider the following line of code.
@ -57,7 +57,7 @@ basic.showString(coll[2], 150)
let coll: string[] = []
```
Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
Write the five (5) lines of code that will add the following five words to ``||variables:coll||``: `"puppy"`, `"clock"`, `"night"`, `"cat"`, and `"cow"`.
<br/>
@ -79,4 +79,3 @@ let coll: string[] = []
let index = Math.randomRange(0, coll.length)
let word = coll[index]
```

View File

@ -16,20 +16,20 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
<br/>
## 2. Write the line of code that will display the string "puppy" using "data->coll".
## 2. Write the line of code that will display the string "puppy" using `coll`.
```blocks
let coll = (<string[]>[])
let coll: string[] = []
coll.push("puppy")
coll.push("clock")
```
<br/>
## 3. Write the line of code that will display the string "cat" using `"data->coll".
## 3. Write the line of code that will display the string "cat" using `coll`.
```blocks
let coll = (<string[]>[])
let coll: string[] = []
coll.push("puppy")
coll.push("clock")
coll.push("cat")
@ -37,7 +37,7 @@ coll.push("cat")
<br/>
## 4. Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
## 4. Write the five (5) lines of code that will add the following five words to `coll`: puppy, clock, night, cat, cow.
```typescript
let coll : string[] = [];

View File

@ -17,12 +17,12 @@ On Logo Up
## Prior learning/place of lesson in scheme of work
Learn how to plot image **on logo up**, `on logo up` to run code when the @boardname@ screen is facing up and vertically orientated. We will be learning how to plot an image with the logo up, basic show LEDs, and logo down.
Learn how to plot an image using ``||input:on logo up||`` to run code when the @boardname@ screen is facing up and vertically orientated. We will be learning how to plot an image with the logo up, basic show LEDs, and logo down.
## Documentation
```cards
input.onLogoUp(() => {})
input.onLogoDown(() => {})
input.onGesture(Gesture.LogoUp, function () {})
input.onGesture(Gesture.LogoDown, function () {})
basic.showLeds(`
. . . . .
. . . . .

View File

@ -8,7 +8,7 @@ Welcome! This tutorial will help you display an arrow pointing toward the logo!
## ~
Using the **accelerometer** sensor, the @boardname@ can detect when the **logo** is oriented **up**. We call that the **logo up** event. We will use `on logo up` to register an event handler that will run when the **logo up** event happens.
Using the **accelerometer** sensor, the @boardname@ can detect when the **logo** is oriented **up**. We call that the **logo up** event. We will use ``||input:on logo up||`` to register an event handler that will run when the **logo up** event happens.
```blocks
input.onGesture(Gesture.LogoUp, () => {
@ -16,7 +16,7 @@ input.onGesture(Gesture.LogoUp, () => {
})
```
When the @boardname@ goes logo up, the code nested under the `on logo up` function will run. Let's add a line of code to show LEDs in there.
When the @boardname@ goes logo up, the code nested under the ``||input:on logo up||`` function will run. Let's add a line of code to show LEDs in there.
```blocks
input.onGesture(Gesture.LogoUp, () => {

View File

@ -7,7 +7,7 @@ Coding challenges for magic logo.
Complete the [magic logo](/lessons/magic-logo/activity) activity and your code will look like this:
```blocks
input.onLogoUp(() => {
input.onGesture(Gesture.LogoUp, function () {
basic.showLeds(`
. . # . .
. # # # .
@ -25,7 +25,7 @@ input.onLogoUp(() => {
How about when the logo is down? We should display an arrow pointing downward!
```blocks
input.onLogoUp(() => {
input.onGesture(Gesture.LogoUp, function () {
basic.showLeds(`
. . # . .
. # # # .
@ -34,7 +34,7 @@ input.onLogoUp(() => {
. . # . .
`)
})
input.onLogoDown(() => {
input.onGesture(Gesture.LogoDown, function () {
basic.showLeds(`
. . # . .
. . # . .

View File

@ -28,7 +28,7 @@ The `logo up` event is raised when...
<br/>
```blocks
input.onLogoUp(() => {
input.onGesture(Gesture.LogoUp, function () {
})
```
@ -43,7 +43,7 @@ input.onLogoUp(() => {
<br/>
```blocks
input.onLogoDown(() => {
input.onGesture(Gesture.LogoDown, function () {
basic.showLeds(`
. . # . .
. . # . .

View File

@ -8,7 +8,7 @@ show an image that points up when the logo is up.
Use the hints from the [magic logo activity](/lessons/magic-logo/activity) to answer this quiz!
## 1. Define what `input->on logo up` does
## 1. Define what ``||input:on logo up||`` does
<br/>

View File

@ -10,7 +10,7 @@ Use this activity document to guide your work in the [night light tutorial](/les
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Describe what "led->set brightness" does ?
## 1. Describe what ``||led:set brightness||`` does ?
## 2. If the picture below is the @boardname@, write the code that sets all the LEDs to full brightness and turns on all the LEDs