Coding Workshop Procedures





Time

Activity

8:30

Icebreaker

Intro to Scratch

Explore Sample projects:

Understand the code


9:00

Guided programming

9:15

Independent, supervised work

9:45

Share out #1

9:55

New skills: Variables, Broadcast & Receive

10:15

Independent, guided programming. and user-testing

11:05

Share-out and closure


Notes:


Ice-Breaker:

  1. Turn to the person to your closest to you.

  2. Ask the person next to you where they are from.

  3. If they live in the same time zone as you, give them a high-five.

  4. If the don’t (ELSE), shake their hand and introduce yourselves.


  1. First nominate three or four students to act as robots, then divide the remaining students into three or four teams. Each team are in a race to see who can get a 'robot' around the classroom or 'maze'. Note that this could be an outdoor task. Explain to the 'robots' that they are to play dumb and only follow the instructions they are given. Then, begin the race.

  2. Throughout the race, ensure that students are using instructions like "step forward 10 paces" or "turn 90 degrees to the right".

  3. After the race has been won, discuss any problems the teams encountered getting their robot to follow their instructions. Draw out through questioning that the robot could not make decisions for itself, and so the students had to be very specific about turns and steps.

  4. Explain that a computer works by executing statements one after another in a specific order. A given order of statements is called a program. Each program executes with a given control flow ; this describes which statement we are executing, and what the next statement will be.


    1. Software is the term given to programs that run on the computer system and make the hardware work. Software has many uses, such as making a calculation or organising files. There are two main types of software: system software which runs and manages your computer, and application software which performs a specific task or function.

  1. Intro to Scratch

    1. 5 explorations (1 of each category) 3 minutes each

      1. Music

      2. Game

      3. Art

      4. Story

      5. Simulation


  1. Understand the Code

    1. Guided practice: (15 minutes)

      1. Look at code in Maze Starter

      2. Examine code for Ball sprite. (Click the big blue See Inside button on top right.)

      3. Look at bottom chunk of code and its corresponding comment. Examine other bits of code for this sprite and “translate” to English as shown in the comment in the Ball sprite.

      4. Click on Goal sprite. Read the code. Right-click in the empty area and add a comment translating the code to English

      5. Optional: What are some possible options for improving this game. Consider, for example, how commercial video games win, lose, give positive and negative feedback, as well as providing help.


  1. Remix (10 minutes)

    1. “Almost all video games provide feedback in the form of sound. Let’s remix this one by adding sounds for when the user does something good and when the do something bad.”

    2. Show options for adding sound: Choose from Library, Record your own, and upload a file.

    3. Click Sounds tab in the Ball sprite, then Electronic. Choose a sound that makes sense for when the ball touches the maze (That’s bad). The sound should be short and convey “badness.”

    4. Click Sounds tab in the Goal sprite, then Electronic. Choose a sound that makes sense for when the ball touches the goal (That’s good). The sound should be short and provide positive feedback.

    5. “What other changes could you make? How would you make this game harder? How would you make it easier”


  1. Scratch Basics tutorial: (30 Minutes) (Note to instructor: VARIABLES is called DATA in Scratch 2.0. Some of the commands in CONTROL section of Scratch 1.4 are in the EVENTS section of 2.0)

    1. Getting Started Guide for Scratch 2.0 (Online version)

    2. Getting Started Guide for Scratch 1.4 (Older application version)


Note to instructor: This tutorial is a 10-step procedure. After the first few steps, some students will adopt an “I got this” attitude and start playing with what they have already learned. It is important that all students complete all 10 steps of this tutorial.


  1. Explore and create, based on what you know (10 minutes)


  1. Naming conventions: Be sure to give descriptive names to all sprites, variables, BROADCAST commands, etc. (Programming becomes much harder if these are not named. -- I tell students that I will not help them if their sprites are not named.)

  2. LOOKS Commands (15 minutes)

    1. SAY vs. THINK

    2. SET vs. CHANGE (Absolute vs. Relative)

    3. Explore Graphics Effects (Brightness, Fisheye, Mosaic, etc.)


  1. COSTUME change (change appearance or for animation) (5 minutes)

    1. Importing Costumes is the same as importing Sprites, except it happens under the Costumes tab.

    2. Animation such as flying and walking. (See built in sprites for this: bird, dog, bat, dancing girl.

    3. Create a sprite with two costumes.Using the Repeat and Wait commands, have the Sprite change costumes .


  1. MOTION and the Coordinate Plane. (5 minutes)

    1. Move mouse around and see x, y coordinates change.

    2. Create a script that makes a sprite go to a specific coordinate and then glide to another place on the Stage.

    3. Create a script where the sprite moves in a square.

    4. Introduce the Pen commands.) Challenge: Make the sprite draw a square, circle (Use the Repeat command), octagon, etc.

    5. Have students have a sprite write their name. Using the Pen Up, and Pen Down commands. (Use the spreadsheet below. Sheet # 2, called, Example, provides a good example.

      1. Good Google Sheet illustration of coordinate plane

    6. Have students experiment with PEN color, size, and shade.


  1. Introduce OPERATORS- Random numbers

    1. Have a sprite move randomly around the stage by putting random numbers in the coordinates of the Glide command. The random numbers should be between -180 to 180 for the y axis and -240 to 240 for the x axis.

    2. Challenge: How would students structure these to maximize the amount of gliding? One possible solution:



Note: This is a good place to introduce Monitors. Monitors in Scratch show the value of an item that may change, such as a sprite’s position,  the value of a variable, a sound’s volume and more. In this case, Go to MOTION and check the boxes for x position and y position.


Have students look at these values on the stage as the sprite is moving about the screen. -- Typically monitor are used during development and turned of once the program is “released.” There are many exceptions to this, the most obvious would be Score.



  1. Challenge: Change PEN color, size, and shade change based on random numbers. This  involves  knowing the possible values for a command. (200 for Pen Color, 100 for Pen Shade: A pen shade of 0 is completely black, a pen shade of 100 is completely white.)


The following variation changes the line color with each movement


    1. Change values in Graphics Effects (Brightness, Fisheye, Mosaic, etc.) based on random numbers.

  1. Free explore time.

  2. NEXT STEPS - Project brainstorming ideas



    1. MOTION

    2. COSTUME Changes

    3. LOOKS

    4. OPERATORS - Random Numbers

    5. COMMENTS  right click in grey area to add comments. (Note: Comments are not required, but highly encouraged. Helps collaborators understand code. Also helps author, especially if there has been some time between coding sessions. Programmers sometimes get in a “zone” while coding and may not recall their thinking from a prior session.)

  1. Share out Ideas for their choice for Project #1


  1. Scratch Challenges (10 minutes) and share out solutions.


  1. Editing Costumes: Making a sad cat. (15 minutes)

    1. Click the Cat sprite on the stage.

    2. Click the Costumes tab.

    3. Click the name of the existing costume and change it to “happy cat.”

    4. Click the Copy button.

    5. Rename the new costume to “sad cat.”

    6. Click Edit on the sad cat costume.

    7. Using the editing tools, make the cat look sad.


  1. CONTROL - Conditionals: If, Forever If, and If → Else

    1. Conditionals: If → Then, and Forever If (Note to instructor: There is no FOREVER IF command in 2.0. Wrap a FOREVER block around an IF block to achieve the same effect.)

    2. Using a FOREVER IF command, create code have the Sprite change costumes if it touches another (specific) sprite. (Note: Touching a Sprite tends to work better than touching a color.) - (More about touching: Touching between sprites is triggered when the assigned center(s) touch. One can assign a sprite’s center when editing the sprite. It, of course, does not need to be the actual center of the sprite.)




  1. Initialization: (Concept) One must program in the starting sprite positions and backgrounds, variables- basically, anything that changes.

Examples of initialization


  1. Backgrounds: Backgrounds are essentially costumes on the Stage.

    1. Creating new backgrounds.

    2. Changing backgrounds.


Challenge: make background change after a specified time and/or key press:

Examples of changing backgrounds.



  1. Introduce Show and Hide (LOOKS section.)


  1. Challenge: Make sprite show and hide based on conditions such as touching another sprite or touching another color. Note: If sprites change their visibility based on Show and Hide, the beginning state state must be initialized. In other words, if you want a sprite to be visible when the program starts, that must be coded. In the following example, we want the cat to disappear when the dog touches it. When the program starts again, Scratch does not “know” to show the cat unless we tell it.



  1. Introduction to VARIABLES. Adding score to the Cat and Dog game.

    1. Add a variable in the Data (Scratch 2.0) or Variables (Scratch 1.4) section.  Be descriptive when naming variables. In this case, let’s name our first variable “score.”

    2. It’s best to get in the habit of immediately initializing anything that will change. So we need to SET score to 0.

    3. Let’s create the code so that every time the dog touches the cat, it increases the variable score by 1.



  1. Practice

  2. Challenge: Create a variable called lives. Initialize its the value of lives to 9. Have the variable lives go down by 1 each time the dog touches the cat.


  1. Built-in VARIABLES: ask, answer, size, x position, y position, direction, costume #, volume, tempo, loudness, and timer.

  2. Don’t forget to initialize all variables in any program using SET.



  1. The SENSING Ask command:

    1. Practice: Storing user name as a variable and using it in a SAY command. Whatever is typed into an ASK command is stored in the built-in variable ANSWER.


Practice using ASK and ANSWER.


  1. Intro to the OPERATORS JOIN command;

    1. Have students ask user’s name and say “Hello, (name)!”-- Two JOIN commands are needed to include the end punctuation for this one. There is no limit to the number of Join commands that can be combined.



Assigning user input to a variable


Any variable can hold only one value at a time. Assuming we will ASK for more information in addition to name, it is a good idea to always assign the value of ANSWER to a new variable. In the example above, let’s create a variable called name and SET the value of name as soon as the user types in their names.



By storing the value of answer in the variable called name, we can ASK the user for more information without losing the value of the first ASK command. In the example below, when we ASK for the user’s age, we still have their name.




Challenge: Describe the output of this code:


Possible answer:

  1. Asks user for their name.

  2. Sprite says “Hello, (their name).”

  3. Sprite asks user’s age.

  4. If user types in a number greater than 18, the sprite says: “Wow, you are old, (value of variable name).”



  1. Introduction to OPERATORS

    1. 1) Create calculations with numbers: “Say 4 x 5.”

    2. 2) Create calculations with random numbers.



Creating Calculations with numbers input by users using the ASK command.



  1. Guided - Create a program that calculates dog years.  (20-30 minutes).


  1. Challenge: Create a program that calculates users age in months, days, hours, and/or minutes.

  2. How else might you use a conditional based on calculation? (Ex: if score is greater than 10, then switch levels (backgrounds).


  1. Communication between sprites: Broadcast & Receive

    1. Broadcast and Receive allows sprite to communicate with other sprites and/or the background.

    2. A BROADCAST command is a message sent out to all sprites and the background. Any sprite or background with a WHEN I RECEIVE command can perform actions based on that BROADCAST command

    3. In the example below, When the dog touches the cat, the cat script broadcasts the (coder-created) message “Go to level 2.” (Broadcast messages are created by clicking “New” in the BROADCAST block.) We have created a WHEN I RECEIVE ““Go to level 2,” the background switches. Like variables, BROADCAST commands should be as descriptive as possible.

In the cat’s script


In the Stage’s script




  1. Challenge: Change background (level) when score is more than 5.

  2. More with Conditionals: WAIT UNTIL and IF →Else

  3. Challenge: Ask user a question & provide feedback for right and wrong answers using IF →Else.


Review

  1. Blocks used so far

    1. MOTION

    2. COSTUME Changes

    3. LOOKS

    4. OPERATORS - Random Numbers

    5. VARIABLES (Built-in vs. Created)

    6. CONTROL - Conditionals: If, Forever If, and If → Else

    7. SENSING - Touching, ASK If, and Key press, x position, and y position

  2. Creating Flags: Flags are used to keep track of any aspect of a program or some other information. For example, a game may have instructions appear before the game begins. In this case, one might create a VARIABLE called GameStart. It would be assigned the value “No” during the intro and “Yes” during the game. If sprites are hidden until the game starts, then one might assign those sprites FOREVER IF GameStart=No, then HIDE.

  3. Practice: Create the scenario mentioned above.

  4. Compound Conditions

Example: If score > 20 AND Game_Start = Yes, the BROADCAST next level.

Practice: Create the scenario mentioned above.




Important: if users will input text for an answer, make sure that correct answers aren’t perceived as incorrect. Consider this code;

Ask Who was the 16th President

If ANSWER=Abe Lincoln, then SAY “Correct.”


Under this scenario, both “Lincoln” and “Abraham Lincoln” would be considered incorrect, as they do not match what is in the code.




Compound Conditionals


One could code this “Lincoln” OR “Abraham Lincoln”  OR “Abe Lincoln.” -- Still not ideal. It is best to make user input as simple as possible.


Data Validation/error capture


Example of data validation:

ASK “Type a number between 1-100.”

IF ANSWER is NOT > 0 AND < 101, SAY, “No silly. Type a number between 1-100.”



Work time



Reflection

  1. Reflect on projects: What are you working on. What would you like to do that you don’t know how to do yet?

  2. Prepare for Project #2. Which category? (Hybrids encouraged).

    1. Animation

    2. Story

    3. Game of skill

    4. Simulation

    5. Games of chance

    6. Interactive art

    7. Music

    8. Simulation

  3. What makes a good program? Brainstorm.

  4. Get students to check out projects on the Scratch website and identify what qualities made for a good project. It is easy to find the good and bad projects because statistics are kept for each uploaded project. A popular project will have lots of love-its, re-mixes and downloads.

  5. Together with students list some of the characteristics of a good project. For example some of the good project qualities: the project works well, easy to use, easy to understand, creative, fun to play, funny, cool, advanced scripts, cool sprites and backgrounds, creative drawings, and creative stories.

  6. Use student feedback to create categories for evaluation. For example project design/creativity, user friendliness, programming, backgrounds and sprites.

  7. Come up with different levels of quality. For example: excellent, good, average and needs more work.

  8. Create the rubric keeping in mind discussions of common problems and the qualities of good and not so good projects.

  9. Using the freshly created rubric, chose several projects and evaluate them in groups or as a class.


  1. Plan for project #2. (May be an extension of #1)


Optional: Teacher creates a Google Form of the student-created rubric. Students use the form to evaluate their own projects as well as those of their peers.






.





“Gallery walk” - projects set-up on computers and then have kids move around the room trying things out.


Scratch Reference

Overview of Scratch

The Stage

Dimensions and Directions on the stage 480 by 360

Code Blocks


Stack blocks are code blocks with a notch at the top or a bump at the bottom. The notches and bumps serve as visual indicators that identify how the blocks can be snapped together to create programming logic.  The majority of code blocks provided by Scratch are stack blocks.


Hat blocks are code blocks with a rounded or curved top and a bump at the bottom, visually indicating that it can be snapped on top of other stack blocks. Hat blocks provide the ability to create event-driven scripts.


Reporter blocks is a code block that has either rounded or angled sides and is specifically designed as a mechanism for providing input for other code blocks to process.


Commenting

Comments within a script help the reader understand the Scratch program. It might also help the programmer later and/or if someone else tries to work with your scripts, she will be glad to see the scripts explained in comments.

Sprites

  • Moving a Sprite

    • How far

    • How fast?

    • Which direction?

Concepts in Movement

  • Changing values in instructions

  • Initialization refers to instructions that set values when a script is run from its beginning. Most scripts will have an initialization consisting of several such instructions to ensure that the script always starts running from the same state.

  • Absolute vs relative movement

    • Go to and Glide are absolute

    • Move and Change x (or y) by are relative.


Task 1: Construct an animation that causes the cat (or any sprite) to move 100 steps and then turn 90 degrees counterclockwise each time it is run (by clicking the green flag).


Variation: Have the cat draw a square, triangle, heptagon.


Where do Sprites come from?

Costumes and Costume changes (Absolute vs. Relative)


Change costume vs. Next Costume vs. Costume #


Editing costumes using paint and draw tools

  • Sounds

  • Backgrounds

  • Loops



Task 2: Make the cat and mouse run forever.

Conditionals: Forever and Forever if


Task 3: When the mouse touches the cat, the cat looks sad.


Adding Interactivity #1


Task 4: Move the cat move using the arrow keys.


Task 5: When the cat catches the mouse, the mouse says something and his appearance changes.




Intro to Variables


Task 6: Every time the cat catches the mouse, the mouse scores a point and the mouse loses 10 health points.


Communication between sprites: Broadcast & Receive


Task 7: When the when the cat touches the mouse three times, a new sprite appears on the stage and says, “ I am here to help.” Option: Change background


Variables and Text: The ASK command.


More with text: the JOIN Command.


Task 8: When the when the cat asks the user their name, he replies “Hello, ‘name.’ I am hungry for a mouse.'"

Animation with costume changes


Phase II Exploring the examples


Phase III: Advanced Concepts

  • Changing size, appearance, speed and /or position, with variables.

  • Conditional

  • If and If Else

  • Comparing Values in a conditional statement

  • Compound conditions AND & OR

  • Show and Hide

  • Random Numbers

  • Graphic effects

  • Pen up and pen down





Websites




Scratch Curriculum Guide

http://scratched.media.mit.edu/sites/default/files/CurriculumGuide-v20110923.pdf


Comments