A Simple Quiz for Alice 3.2:

Slides:



Advertisements
Similar presentations
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Advertisements

Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
METHODS!.  A method is a sequence of instructions or behaviors that will be carried out when requested.  You can use them to create new methods so that.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
1 Quiz Template: Click on the match By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Distributing (Fun + Learning): The Distributive Property By: Peggy Li Under the direction of Professor Susan Rodger Duke University, June
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Can I get your number? By Melissa Dalis Professor Susan Rodger Duke University June 2011.
1 Quiz Template: Using the ‘ask user’ functions By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Learning to Program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Creating a Fancier Chicken to use in several worlds - Inheritance Susan Rodger Duke University June 2009.
Headshots in Alice Duke University Professor Susan H. Rodger Gaetjens Lezin July 2008.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
Jonathon Kuo Under the Direction of Dr. Susan Rodger
Creating a UFO Rescue Game in Alice
An Introduction to Alice (Short Version)
Teaching Characters to Walk: Learning Methods, Part 1
Comparing objects and changing color
Under the direction of Susan Rodger
Asking User for an Answer Alice 3 Tricks in Mini Trivia (2/4)
Changing Color, Using Text Objects, and Random Selection in Alice
Making Objects Move in Unison: Using Lists
Let's Race! Typing on the Home Row
Creating a UFO Rescue Game in Alice
Vehicles and Conditionals
Making Objects Move in Unison: Using Lists
A Simple Quiz for Alice 3.2:
Introduction to TouchDevelop
Checking for Collisions: Using Functions in Alice
Restricting an Event with a Conditional
How Tall Are You? Introducing Functions
Getting Started With Alice
Headshots in Alice Duke University Professor Susan H. Rodger
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
under the direction of Professor Susan Rodger
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

A Simple Quiz for Alice 3.2: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011, Edited for Alice 3 use and Part 3,4 added by Anh Trinh July 2016

Introduction and Set-up This tutorial will demonstrate how to create a simple quiz using the three different kinds of “ask user” functions: ask user for a number, ask user for true or false and ask user for a string. Let's get started by setting up the world. Open a new Alice grass world. Click on Setup Scene. Choose Browse Gallery By Group, and click Animals. Add one Penguin, one Cow, and three Chickens into your world. Arrange and resize the objects so they are easy to see. Click Edit Code when finished.

Step 1: Create the Quiz Procedure Create a new scene procedure that we will use later to hold the instructions for the quiz. Lets start by creating a quiz procedure Click on the Scene tab and choose Add Scene Procedure Name the new procedure: quiz. Click back on myFirstMethod.

Step 2: Set Up MyFirstMethod Now we will add the quiz to MyFirstMethod. Make sure you are in MyFirstMethod. Click on this.penguin in the object tree. Drag the say procedure into the procedure editor and type in: Time for a quiz. Drag in a second say procedure and type in: That is all folks! Click on this in the object tree and drag the quiz procedure in between the two penguin say commands

Step 3: Comments Now we will start writing the quiz procedure. To make our code easier to read we will add in comments. Comments make it possible to add in notes about the code like, what it will do, or who wrote the code. First click on the quiz procedure tab. To add a comment drag and drop the double slash button into the method

Step 4: Question #1 Type in the comment editor: Question 1 Click on this.penguin in the object tree, have it say: How many animals in the world? and set the duration to 2 seconds. We need a variable to store the number information we get from the user. Drag in the button to open variable option box. Name it answerNumber. Select WholeNumber beside value type, initialize it to 0 and click OK.

Step 4: Question #1 Continued... Click on the world in the object tree. Under the world's details, functions find “ask user for a number.” Click and drag the ask user for a number over the 1 and select other... Enter the string: Enter the number of animals:

Step 4: Question #1 Continued... Now we will determine what happens if the answer given is correct or incorrect. Drag and drop an If block from the bottom of the window and set it to true. Choose Relational (WholeNumber) in the true drop-down list. Select “??? == ??? “ -> answerNumber... -> Custom WholeNumber to enter in the value 5. 5 is the correct answer to this question.  

Step 4: Question #1 Continued... For this question when the “If” statement is true, the answer is correct. So we will put our response to the correct answer first. Click on this.penguin in the object tree. Under the If: Drag the say method and type: Correct Drag the turn method and select 1 When the if statement is false, the answer is incorrect. Under the Else: Drag the say method and type: Sorry, that is not correct. Run your world to take the one question quiz.

Drop in a comment and type in: Question 2 Step 5: Question #2 Now lets make a question that asks the user for a true or false response. Drop in a comment and type in: Question 2 Click on penguin in the object tree, have it say: Are there more chickens than penguins? and set the duration to 2 seconds. We need a variable to store the boolean information we get from the user. Drag in variable button from the bottom of the window . Name it answerBoolean. Select Boolean and Click OK.

Type in: Click on true and false. Step 5: Question #2 Continued... In the penguin's functions, drag and drop the “getBooleanFromUser” over the true. Type in: Click on true and false.

Drag and drop an If/Else statement and select answerBoolean. Step 5: Question #2 Continued... Now we will add in our responses to the answer in another If/Else statement. Drag and drop an If/Else statement and select answerBoolean. The If question accepts just the variable because answerBoolean is a boolean type.

Run your world to take the two question quiz. Step 5: Question #2 Continued... Now complete the question #2 by adding in the procedures as shown below: Run your world to take the two question quiz.

For our final question we will ask the user to enter a string. Step 6: Question #3 For our final question we will ask the user to enter a string. Drop in a comment and type in: Question 3 Click on penguin in the object tree, have it say: What building are we in? and set the duration to 2 seconds. Note: A string is a set of letters or characters. A space is considered a character so be careful if you have a space at the end of your word or sentence. We need a variable to store the string information we get from the user. Drag in the variable button. Name it answerString. Select TextString and ‘hello’ in initializer Click OK.

In the penguin's functions, Step 6: Question #3 Continued... In the penguin's functions, drag and drop the getStringFromUser over the ‘hello’ string. Type in: Enter acronym.

Drag and drop an If/Else statement and select true. Step 6: Question #3 Continued... Now we will add in our responses to the answer in another If/Else statement. Drag and drop an If/Else statement and select true. Click the down arrow in true and select TextString Comparison -> ???equalsIgnoreCase??? -> answerString -> Custom TextString then type in: LSRC With equalsIgnoreCase, the answer is not case-sensitive

Now play your world and take the quiz. Step 6: Question #3 Continued... Click on penguin in the object tree and add in the responses for when the answer is correct or incorrect as shown below. Now play your world and take the quiz.

Part 2: Forcing the Answer In Question 1, if the user mistypes the answer, we want the program to ask the user for the answer again until it is correct. Rewrite question 1 to add a while loop and force the user into the loop with a wrong value to start with.

Part 3: Limiting Number of Trials To limit the number of trials to 3 for example, create a new variable named numberofTrial, create a while loop that allows the question to show up as long as the students tries less than 3 times. Each time they answer incorrectly, increment numberofTrial by 1. If they answer, correctly, set numberofTrial to a number greater than 3 to break out of the while loop ( here we choose 5)

Part 4: Score Reporting Challenge: To report score to user, we have to create a local variable score for the quiz procedure, initialize it to 0, and increment it by 1 every time the student answer a question correctly. At the end, have the penguin report the score.

Part 4: Score Reporting To report the score in the end, drag the penguin say procedure in and type “You got ”. Click on the down arrow next to the string you just typed and select “You got “+???-> WholeNumber -> score

Part 4: Score Reporting Click on the down arrow next to the “You got “ + score string and select “You got “ + score + ??? -> Custom TextString and Type ” questions correct”

Quiz Procedure code