diff --git a/data/quiz-bank.json b/data/quiz-bank.json index a48705f..4767ced 100644 --- a/data/quiz-bank.json +++ b/data/quiz-bank.json @@ -1,89 +1,804 @@ { "version": "2.0.0", - "description": "CodeSensei quiz bank — contextual questions organized by concept. Supports multiple choice, free-response, and code-prediction formats. The quiz-selector.sh script reads this bank for spaced repetition and hybrid quiz selection.", + "description": "CodeSensei quiz bank \u2014 contextual questions organized by concept. Supports multiple choice, free-response, and code-prediction formats. The quiz-selector.sh script reads this bank for spaced repetition and hybrid quiz selection.", "quizzes": { "variables": [ { "belt": "white", "question": "If you write `let score = 10` and then `score = 25`, what is `score` now?", - "options": ["10", "25", "35"], + "options": [ + "10", + "25", + "35" + ], "correct": 1, - "explanation": "Variables can change! When you write `score = 25`, the old value (10) gets replaced with the new one (25). That's why it's called a 'variable' — it varies.", - "hint": "Think of a variable like a whiteboard — you can erase what's there and write something new." + "explanation": "Variables can change! When you write `score = 25`, the old value (10) gets replaced with the new one (25). That's why it's called a 'variable' \u2014 it varies.", + "hint": "Think of a variable like a whiteboard \u2014 you can erase what's there and write something new." }, { "belt": "white", "question": "What does `const` mean when declaring a variable?", - "options": ["The value can change anytime", "The value stays the same — it's constant", "The variable is deleted after use"], + "options": [ + "The value can change anytime", + "The value stays the same \u2014 it's constant", + "The variable is deleted after use" + ], "correct": 1, - "explanation": "`const` is short for 'constant' — once you set the value, it can't be changed. Use it when you know the value shouldn't change, like a user's ID.", + "explanation": "`const` is short for 'constant' \u2014 once you set the value, it can't be changed. Use it when you know the value shouldn't change, like a user's ID.", "hint": "The word 'const' is short for something that means 'unchanging.'" + }, + { + "belt": "white", + "question": "What happens if you try to use a variable before you create it?", + "options": [ + "It automatically becomes 0", + "You get an error", + "It works fine with an empty value" + ], + "correct": 1, + "explanation": "You can't use something that doesn't exist yet! The program will throw an error telling you the variable is not defined. Always declare your variables before using them.", + "hint": "Think about trying to open a box that hasn't been built yet." + }, + { + "belt": "yellow", + "question": "What is the difference between `let` and `var` in JavaScript?", + "options": [ + "There is no difference", + "`let` is block-scoped while `var` is function-scoped", + "`var` is newer than `let`" + ], + "correct": 1, + "explanation": "`let` respects curly braces \u2014 it only exists inside the block where it's declared. `var` ignores blocks and is available throughout the entire function. Modern code prefers `let` because it's more predictable.", + "hint": "Think about whether a variable 'leaks out' of an if-block or stays contained." + } + ], + "data-types": [ + { + "belt": "white", + "question": "Which of these is a string?", + "options": [ + "42", + "true", + "\"hello\"", + "null" + ], + "correct": 2, + "explanation": "A string is text wrapped in quotes. \"hello\" is a string because it has quotes around it. 42 is a number, true is a boolean, and null means 'nothing.'", + "hint": "Strings are always wrapped in something to show they're text." + }, + { + "belt": "white", + "question": "What is the data type of the value `true`?", + "options": [ + "String", + "Number", + "Boolean", + "Object" + ], + "correct": 2, + "explanation": "A boolean is a true/false value \u2014 like a light switch that's either on or off. Booleans are used in conditionals to make decisions in your code.", + "hint": "This data type only has two possible values." + }, + { + "belt": "yellow", + "question": "What does `null` represent in programming?", + "options": [ + "The number zero", + "An empty string", + "The intentional absence of any value", + "An error" + ], + "correct": 2, + "explanation": "`null` means 'nothing on purpose.' It's different from 0 (which is a number) or an empty string (which is still a string). It's like an empty parking spot \u2014 the spot exists, but nothing is in it.", + "hint": "It's not zero, not empty text \u2014 it's deliberately nothing." + } + ], + "conditionals": [ + { + "belt": "white", + "question": "What does an `if` statement do?", + "options": [ + "Repeats code multiple times", + "Runs code only when a condition is true", + "Defines a new variable" + ], + "correct": 1, + "explanation": "An `if` statement checks a condition and only runs the code inside it when that condition is true. It's how programs make decisions \u2014 like a traffic light deciding whether cars can go.", + "hint": "Think about how you make decisions in real life: IF it's raining, THEN bring an umbrella." + }, + { + "belt": "white", + "question": "What does `else` do in an if/else statement?", + "options": [ + "It ends the program", + "It runs when the `if` condition is false", + "It checks a second condition" + ], + "correct": 1, + "explanation": "`else` is the fallback \u2014 it runs when the `if` condition is NOT true. Together, if/else covers both possibilities: 'if this is true, do A; otherwise, do B.'", + "hint": "IF it's sunny, wear sunglasses. Otherwise (ELSE)..." + }, + { + "belt": "yellow", + "question": "What does this code output? `let x = 5; if (x > 10) { console.log('big'); } else { console.log('small'); }`", + "options": [ + "'big'", + "'small'", + "Nothing \u2014 it errors", + "'big' and 'small'" + ], + "correct": 1, + "explanation": "Since x is 5, and 5 is NOT greater than 10, the `if` condition is false. So the `else` block runs, printing 'small'. Only one branch of an if/else ever runs.", + "hint": "Check the condition: is 5 greater than 10?" + }, + { + "belt": "orange", + "format": "free_response", + "question": "Explain what a 'ternary operator' is and when you might prefer it over a full if/else statement.", + "expected_understanding": "A ternary is a shorthand if/else written as `condition ? valueIfTrue : valueIfFalse`. It's useful for simple, single-expression decisions, like setting a variable based on a condition.", + "hint": "It's a one-line way to choose between two values based on a condition." + } + ], + "functions": [ + { + "belt": "white", + "question": "What is a function in programming?", + "options": [ + "A type of variable", + "A reusable block of code that performs a specific task", + "A file that stores data" + ], + "correct": 1, + "explanation": "A function is like a recipe \u2014 it's a set of instructions you can run whenever you need them. You define it once, then 'call' it by name whenever you want it to execute.", + "hint": "Think of something you can use over and over again." + }, + { + "belt": "yellow", + "question": "Why do developers put code inside functions instead of writing everything in one long file?", + "options": [ + "It makes the code run faster", + "So they can reuse the same code without copying it", + "Functions are required by the programming language" + ], + "correct": 1, + "explanation": "Functions are reusable recipes! Write it once, use it many times. If you need to calculate a total in 10 different places, you write one function and call it 10 times instead of copying the same code.", + "hint": "Think about why a chef writes down a recipe instead of memorizing every step every time." + }, + { + "belt": "yellow", + "question": "What does `return` do inside a function?", + "options": [ + "It restarts the function from the beginning", + "It sends a value back to wherever the function was called", + "It prints the value to the screen" + ], + "correct": 1, + "explanation": "`return` sends a result back from the function. Think of asking someone a question \u2014 `return` is their answer coming back to you. After `return`, the function stops running.", + "hint": "If you ask a calculator to compute 2+2, it needs to give the answer back to you somehow." + }, + { + "belt": "orange", + "question": "What is the difference between a function parameter and an argument?", + "options": [ + "They are the same thing", + "A parameter is the placeholder in the definition; an argument is the actual value passed when calling", + "Parameters are for input; arguments are for output" + ], + "correct": 1, + "explanation": "When you define `function greet(name)`, `name` is a parameter \u2014 a placeholder. When you call `greet('Alice')`, 'Alice' is the argument \u2014 the actual value. Parameters are the parking spots, arguments are the cars that park in them.", + "hint": "One belongs to the function definition, the other to the function call." + } + ], + "loops": [ + { + "belt": "white", + "question": "What does a loop do in programming?", + "options": [ + "It deletes repeated code", + "It runs the same code multiple times", + "It connects two files together" + ], + "correct": 1, + "explanation": "A loop repeats a block of code \u2014 either a set number of times or until a condition is met. Instead of writing the same code 100 times, you write it once inside a loop.", + "hint": "Think about a song that has a repeating chorus." + }, + { + "belt": "white", + "question": "How many times does this loop run? `for (let i = 0; i < 3; i++) { console.log(i); }`", + "options": [ + "2 times", + "3 times", + "4 times", + "It runs forever" + ], + "correct": 1, + "explanation": "The loop starts at i=0 and runs while i is less than 3. So it runs for i=0, i=1, i=2 \u2014 that's 3 times. When i becomes 3, the condition `i < 3` is false and the loop stops.", + "hint": "Count: 0, 1, 2... how many numbers is that?" + }, + { + "belt": "yellow", + "question": "What is an 'infinite loop' and why is it a problem?", + "options": [ + "A loop that runs very fast", + "A loop that never stops because its condition is always true", + "A loop that processes infinite data" + ], + "correct": 1, + "explanation": "An infinite loop happens when the loop's exit condition is never met \u2014 like `while (true)` with no `break`. The program gets stuck running forever, freezing your application. Always make sure your loop has a way to stop!", + "hint": "What happens if you tell someone to keep walking and never tell them when to stop?" + }, + { + "belt": "orange", + "question": "When would you use a `while` loop instead of a `for` loop?", + "options": [ + "When you want the loop to run faster", + "When you don't know in advance how many times the loop should run", + "When you're looping through an array", + "There's no practical difference" + ], + "correct": 1, + "explanation": "`for` loops are great when you know the count (loop 10 times, loop through an array). `while` loops are better when you're waiting for a condition to change (keep reading input until the user types 'quit'). Use the one that makes your intent clearer.", + "hint": "Think about 'repeat 5 times' versus 'repeat until done.'" + } + ], + "arrays": [ + { + "belt": "white", + "question": "What is an array?", + "options": [ + "A single value like a number or string", + "An ordered list that can hold multiple values", + "A function that returns multiple results" + ], + "correct": 1, + "explanation": "An array is like a numbered list. It holds multiple values in order, and you can access each one by its position (index). For example, `['apple', 'banana', 'cherry']` is an array of three strings.", + "hint": "Think of a shopping list \u2014 it holds multiple items in order." + }, + { + "belt": "white", + "question": "In most programming languages, what is the index of the FIRST element in an array?", + "options": [ + "1", + "0", + "-1", + "It depends on the value" + ], + "correct": 1, + "explanation": "Arrays start counting at 0, not 1! So `fruits[0]` gives you the first fruit, `fruits[1]` the second, and so on. This is called 'zero-based indexing' and trips up almost every beginner.", + "hint": "It's not what you'd expect from everyday counting." + }, + { + "belt": "yellow", + "question": "What does `.push()` do to an array?", + "options": [ + "Removes the first element", + "Adds a new element to the end", + "Sorts the array", + "Reverses the array" + ], + "correct": 1, + "explanation": "`.push()` adds an item to the END of an array. Think of it like pushing someone to the back of a line. `[1, 2].push(3)` gives you `[1, 2, 3]`.", + "hint": "Imagine pushing something onto the end of a stack." + }, + { + "belt": "orange", + "question": "What does `.filter()` return?", + "options": [ + "A single value", + "A new array with only the elements that pass a test", + "The original array, modified", + "A boolean" + ], + "correct": 1, + "explanation": "`.filter()` creates a NEW array containing only the elements where your test function returns true. The original array is unchanged. `[1,2,3,4].filter(n => n > 2)` returns `[3, 4]`.", + "hint": "Think of a coffee filter \u2014 it keeps some things and lets others pass through." + } + ], + "objects": [ + { + "belt": "white", + "question": "What is an object in programming?", + "options": [ + "A list of numbered items", + "A collection of named properties (key-value pairs)", + "A function that creates other functions" + ], + "correct": 1, + "explanation": "An object groups related data under named keys. For example, `{ name: 'Alice', age: 25 }` stores a person's info. Unlike arrays (which use numbers), objects use descriptive names to access values.", + "hint": "Think of a contact card with labeled fields like 'name' and 'phone.'" + }, + { + "belt": "white", + "question": "How do you access the `name` property of this object? `const user = { name: 'Sam', age: 30 };`", + "options": [ + "user[0]", + "user.name", + "user->name", + "name.user" + ], + "correct": 1, + "explanation": "Dot notation (`user.name`) is the most common way to access object properties. You can also use bracket notation (`user['name']`), which is useful when the property name is stored in a variable.", + "hint": "The object name comes first, then a dot, then the property name." + }, + { + "belt": "yellow", + "question": "What is the difference between an array and an object?", + "options": [ + "Arrays are faster than objects", + "Arrays use numbered positions; objects use named keys", + "Objects can only store strings", + "There is no real difference" + ], + "correct": 1, + "explanation": "Arrays are ordered lists accessed by index (position number). Objects are collections accessed by key (property name). Use arrays for lists of similar things, objects for describing something with multiple properties.", + "hint": "One uses numbers to find items, the other uses names." + }, + { + "belt": "orange", + "format": "free_response", + "question": "When would you choose to use an array versus an object to store data? Give an example of each.", + "expected_understanding": "Arrays for ordered lists of similar items (e.g., a list of usernames). Objects for describing something with named properties (e.g., a user profile with name, email, age). The choice depends on whether order/position or named access matters more.", + "hint": "Think about a grocery list versus a recipe card." } ], "html": [ { "belt": "white", "question": "What does HTML define on a webpage?", - "options": ["The colors and fonts", "The structure and content", "The animations and interactions"], + "options": [ + "The colors and fonts", + "The structure and content", + "The animations and interactions" + ], "correct": 1, - "explanation": "HTML defines WHAT is on the page — headings, paragraphs, images, buttons. It's the skeleton. CSS handles how it looks, and JavaScript handles what it does.", + "explanation": "HTML defines WHAT is on the page \u2014 headings, paragraphs, images, buttons. It's the skeleton. CSS handles how it looks, and JavaScript handles what it does.", "hint": "Think of building a house. One thing defines where the walls and rooms go..." }, { "belt": "yellow", "question": "If you want to add a clickable link to another website, which HTML tag would you use?", - "options": ["", "", "