diff --git a/.guides/assessments.json b/.guides/assessments.json index feee21a..865cb90 100644 --- a/.guides/assessments.json +++ b/.guides/assessments.json @@ -10,7 +10,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\"\n}", "grader": "1", "guidance": "Here is the correct answer:\n\n```java\nif(x % 2 == 0)\n {System.out.print(\"Even\");}\nelse\n {System.out.print(\"Odd\");}\n```\n\nHere is why the other options are incorrect:\n\n* `if x % 2 = 0` - The equality operator (`==`) is not used.\n* `if x / 2 == 0` - The `/` operator is division. To be even, there can be no remainder. The modulo operator (`%`) must be used instead.\n* `System.out.print(Even);` - The quotation marks are missing. Without them, Java will try to print the variable `Even`, which has not been declared. \n* `System.out.print(Odd);` - The quotation marks are missing. Without them, Java will try to print the variable `Odd`, which has not been declared. ", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -45,7 +44,10 @@ ] }, "bloomsObjectiveLevel": "4", - "learningObjectives": "SWBAT construct an if else statement" + "learningObjectives": "SWBAT construct an if else statement", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -79,7 +81,6 @@ } ], "guidance": "The correct answers are:\n\n```\nIf statements only ask if a boolean expression is true.\n\nIf statements are the simplest of all the conditionals.\n```\n\nIf statements can only ask if a boolean expression is true. An else statement takes into account a false boolean expression.\n\nIf statements are the simplest because they ignore when a boolean expression is false, and they do not ask subsequent boolean expressions.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -114,7 +115,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT understand the characteristics of an if statement" + "learningObjectives": "SWBAT understand the characteristics of an if statement", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -128,7 +132,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\",\n \"turtleModelCode\": \"modelTurtle.forward(100)\\nmodelTurtle.left(120)\\nmodelTurtle.forward(100)\\nmodelTurtle.left(120)\\nmodelTurtle.forward(100)\\nmodelTurtle.left(120)\",\n \"executable_code\": \"for i in range(0,3):\\nmyTurtle.forward(100)\\nmyTurtle.left(120)\\npass\",\n \"programmingLang\": \"pseudo\"\n}", "grader": "5", "guidance": "The loop header is setting up how many times code is repeated. In the case of a triangle, it makes sense to repeat 3 times - one for each side.\n\n```\nREPEAT 3 TIMES\n forward(100)\n left(120)\nENDREPEAT\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -154,7 +157,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT... define a loop header" + "learningObjectives": "SWBAT... define a loop header", + "showGuidanceAfterResponseOption": { + "type": "Always" + } }, "linkedId": "5038b41f-51e1-4de2-bba9-0435fc132d47", "libraryId": "a6135984-c66a-483f-9eb2-48cdba182812", @@ -171,7 +177,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\",\n \"max_wrong_lines\": 1,\n \"turtleModelCode\": \"modelTurtle.forward(100)\\nmodelTurtle.left(90)\\nmodelTurtle.forward(100)\\nmodelTurtle.left(90)\\nmodelTurtle.forward(100)\\nmodelTurtle.left(90)\\nmodelTurtle.forward(100)\\nmodelTurtle.left(90)\",\n \"executable_code\": \"for i in range(0,4):\\nmyTurtle.forward(100)\\nmyTurtle.left(90)\\npass\",\n \"programmingLang\": \"pseudo\"\n}", "grader": "5", "guidance": "The loop header is setting up how many times code is repeated. In the case of a square, it makes sense to repeat 4 times - one for each side.\n\nThe loop body are the lines to be repeated, in this case the blocks instructing the turtle to turn and step forward.\n\n```\nREPEAT 4 TIMES\n forward(100)\n left(90)\nENDREPEAT\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -199,7 +204,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT... define a loop body" + "learningObjectives": "SWBAT... define a loop body", + "showGuidanceAfterResponseOption": { + "type": "Always" + } }, "libraryId": "a6135984-c66a-483f-9eb2-48cdba182812", "version": 0, @@ -216,7 +224,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "![](.guides/img/fenceSoln.png)", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -238,7 +245,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -250,7 +260,6 @@ "instructions": "Select the appropriate vocabulary words in the paragraph below.", "text": "In code, we use loops to repeat or <<>> over sections of code. The <<>> indicates how many times the loop will repeat the code. The code section that is repeated is called the <<>>.", "guidance": "", - "showGuidanceAfterResponse": false, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -281,6 +290,9 @@ 0, "." ] + }, + "showGuidanceAfterResponseOption": { + "type": "Never" } } }, @@ -315,7 +327,6 @@ } ], "guidance": "`i` is never incremented, so `i` remains `0` forever. Because `i=0` forever, `i<=5` will ALWAYS be true.\n\nWithout the incriminator, we get an infinite loop!", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -330,7 +341,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -364,7 +378,6 @@ } ], "guidance": "Because the print statement is *after* the increment of i, we see values 2-10. Flipping the two lines within the loop body would change the values to 0-8.\n\nBecause we do not use fence-posting, we have an extraneous `,` in our output.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -379,7 +392,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -408,7 +424,6 @@ } ], "guidance": "Even though it is the last part of the for loop header, the incrementing is the first piece of the header run after an iteration.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -436,7 +451,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -450,7 +468,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"can_indent\": false,\n \"max_wrong_lines\": 2\n}", "grader": "1", "guidance": "", - "showGuidanceAfterResponse": false, "points": 1, "oneTimeTest": false, "metadata": { @@ -477,7 +494,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -511,7 +531,6 @@ } ], "guidance": "After the print command use parentheses and quotation marks around the words to be printed.\n```\nSystem.out.print(\"Hello world\");\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -534,7 +553,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -558,7 +580,6 @@ } ], "guidance": "`System.out.println(\"Hello\");` inserts a new line character after `Hello` which is hard to see when you only print one line of text. However, if you print two lines like:\n```\nSystem.out.println(\"Hello\");\nSystem.out.println(\"World!\");\n```\nIt outputs:\n```\nHello\nWorld!\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -581,7 +602,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -615,7 +639,6 @@ } ], "guidance": "The `print` command sends your output to your computer's default output which is the computer console or terminal.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -630,7 +653,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -642,7 +668,6 @@ "instructions": "Fill in the blank with the missing text that will print the text `Hi!` **with** a newline character?", "text": "`System.out.<<>>(\"Hi!\");`", "guidance": "To add the newline character, you use the `println` command instead of the `print` command. The code should look like: `System.out.println(\"Hi!\")`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -667,6 +692,9 @@ 0, "(\"Hi!\");`" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -696,7 +724,6 @@ } ], "guidance": "For each variable, the data type and name of the variable *never* change. The value can be re-assigned as many times as you want!", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -724,7 +751,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -736,7 +766,6 @@ "instructions": "Fill in the following with the appropriate vocabulary to explain the difference between a double and an int.", "text": "A <<>> is a <<>> meaning it has a <<>>, where an <<>> is a <<>> meaning it does not have a decimal.", "guidance": "A `double` is a floating point number or a rational number meaning it has a decimal or represents a fraction, where an `int` (short for integer) is a whole number meaning it does not have a decimal.\n\nBoth can be positive or negative!", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -781,6 +810,9 @@ 0, " meaning it does not have a decimal." ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -815,7 +847,6 @@ } ], "guidance": "Boolean values in Java are case sensitive and must start with a lowercase letter: `true` or `false`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -838,7 +869,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -850,7 +884,6 @@ "instructions": "Complete the line of code below so that variable declaration and assignment is correct.", "text": "`<<>> var;`\n`var = \"a <<>> is made up of words and num63rs<<<\">>>;`", "guidance": "Unlike the previous data types, `String` is capitalized and the value of a String is surrounded by double quotation marks.\n\n```\nString var;\nvar = \"a string is made up of words and num63rs\";\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -889,6 +922,9 @@ 0, ";`" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -923,7 +959,6 @@ } ], "guidance": "Java does not allow different variables to have the same name - regardless of data type.\n\nAdditionally, Java does not allow spaces in variable names - either user `camelCase` or `snake_case` to separate words.\n\nSince Java variables are case sensitive, `var` and `Var` are different variables.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -946,7 +981,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -960,7 +998,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\",\n \"vartests\": [{\"initcode\": \"output = ''\", \"code\": \"\", \"message\": \"Testing...\", \"variables\": {\"output\": \"510\"}}\n ],\n \"executable_code\": \"my_variable = 5\\noutput += str(my_variable)\\nmy_variable = 10\\noutput += str(my_variable)\",\n \"programmingLang\": \"java\"\n }", "grader": "4", "guidance": "You will use an `int` instead of a double since 5 and 10 are whole numbers. Additionally, if you use `double` it would print out `5.0` and `10.0` by default.\n\nYou cannot assign a String (`\"10\"`) to an `int`.\n\nYou do not need to re-declare when you reassign (`int my_variable = 10`).\n\n```\nint my_variable = 5;\nSystem.out.println(my_variable);\nmy_variable = 10;\nSystem.out.println(my_variable);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -982,7 +1019,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1016,7 +1056,6 @@ } ], "guidance": "Here are the basic rules for variable names: \n1. Start with a letter, dollar sign or underscore\n2. Remainder of variable name is letters, numbers, or underscores\n3. Cannot use a Java keyword\n4. Variables are case sensitive", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1039,7 +1078,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1098,7 +1140,6 @@ } ], "guidance": "The four basic data types that you have learned so far are:\n\nString - collections of letters, numbers, and symbols\nboolean - true or false\nint - integers (no decimal)\ndouble - numbers with a decimal", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1121,7 +1162,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1134,7 +1178,6 @@ "command": "java -cp code/fundamentals/ Lab_Challenge", "preExecuteCommand": "javac code/fundamentals/Lab_Challenge.java", "guidance": "If you used the hint, you could have done this lab in 2 lines:\n```\n System.out.println(greeting + \" Today is \" + dayOfWeek + \", \" + month + \" \" + day + \".\");\n System.out.println(\"The current wait time is \" + currentWaitMinutes + \" minutes.\");\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -1194,7 +1237,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1207,7 +1253,6 @@ "command": "java -cp code/fundamentals/ Exercise1", "preExecuteCommand": "javac code/fundamentals/Exercise1.java", "guidance": "```\nboolean my_boolean = true;\nSystem.out.println(my_boolean);\nmy_boolean = test;\nSystem.out.println(my_boolean);\n```\nYou can initialize `my_boolean` on a separate line and use `print` instead of `println`.\n```\nboolean my_boolean;\nmy_boolean = true;\nSystem.out.print(my_boolean);\nmy_boolean = test;\nSystem.out.print(my_boolean);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -1254,7 +1299,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1267,7 +1315,6 @@ "command": "java -cp code/fundamentals/ Exercise2", "preExecuteCommand": "javac code/fundamentals/Exercise2.java", "guidance": "You can do the declaration and initialization on the same line:\n```\n int my_int = first_num;\n System.out.println(my_int);\n my_int = second_num;\n System.out.println(my_int);\n my_int = third_num;\n System.out.println(my_int);\n```\nYou can also use `print` instead of `println`", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -1320,7 +1367,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1333,7 +1383,6 @@ "command": "java -cp code/fundamentals/ Exercise3", "preExecuteCommand": "javac code/fundamentals/Exercise3.java", "guidance": "Because the string variables are already declared and initialized, you simply need to access them. You need to use `println` to ensure the newlines after each line is printed.\n```\n System.out.println(line1);\n System.out.println(line2);\n```\n\nYou could use empty `println` commands if you wanted:\n```\n System.out.print(line1);\n System.out.println();\n System.out.print(line2);\n System.out.println();\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -1386,7 +1435,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1399,7 +1451,6 @@ "command": "java -cp code/fundamentals/ Exercise4", "preExecuteCommand": "javac code/fundamentals/Exercise4.java", "guidance": "You can separate your decleration and initialization onto two lines. Also, you can initialize to either `0` or `0.0` or `0.00` etc\n\n```\ndouble my_double = 0;\nSystem.out.println(my_double);\nmy_double = one;\nSystem.out.println(my_double);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -1445,7 +1496,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1458,7 +1512,6 @@ "command": "java -cp code/fundamentals/ Exercise5", "preExecuteCommand": "javac code/fundamentals/Exercise5.java", "guidance": "You should not use **any** `println` statements - instead, only use `print`. It does not matter where you split up the string...\n\n```\nSystem.out.print(\"Okay, it is time to \");\nSystem.out.print(\"learn about operators.\");\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -1497,7 +1550,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1526,7 +1582,6 @@ } ], "guidance": "Since a double can represent the same value as an integer (`2.0` is the same value as `2`), but not necessarily the other way around (`2.4` cannot be an int) the result will be a double. For example:\n\n`7.0 + 3 = 10.0`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1549,7 +1604,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1561,7 +1619,6 @@ "instructions": "Use the fewest characters possible to complete the code as described.", "text": "`int evens = 0;`\n`//add 2`\n`evens <<<+=2>>>;`\n`int all = 0;`\n`//add 1`\n`all<<<++>>>;`", "guidance": "```\nint evens = 0;\n//add 2\nevens+=2;\nint all = 0;\n//add 1\nall++;\n```\nIf you are incrementing by 1, the shortest way is the `++` operator, if you are incrementing by any other number (like 2) the shortest way is the `+=` operator.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -1598,6 +1655,9 @@ 0, ";`" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -1612,7 +1672,6 @@ "options": "{\n \"sortableId\":\"sortable\",\n \"trashId\":\"sortableTrash\"\n}", "grader": "1", "guidance": "```\nString a = \"I understand\";\nString b = a + \" String concatenation!\";\nSystem.out.println(b);\n```\nIn Java, Strings must use double quotes (\") - not single quotes ('). \n\nAdditionally, you need to either end or start with a space when concatenating two Strings to get normal spacing in your resulting String. \n\nString a needs to be declared and instantiated *before* you use it in the instantiation of String b.\n\nSince you are concatenating String a in the initialization of String b, you do not need to concatenate it *again* in the print statement.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -1635,7 +1694,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1647,7 +1709,6 @@ "instructions": "Use the fewest characters possible to complete the code as described.", "text": "`int a = 42;`\n`int b = 2;`\n`//decrement a by 1`\n`a<<<-->>>;`\n`//decrement a by b`\n`a<<<-=b>>>;`", "guidance": "```\nint a = 42;\nint b = 2;\n//decrement a by 1\na--;\n//decrement a by b\na-=b;\n```\n\nTo decrement by 1, you use the `--` operator. To decrement or subtract by any other number, you use `-=`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -1683,6 +1744,9 @@ 0, ";`" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -1717,7 +1781,6 @@ } ], "guidance": "`int`s and `double`s behave differently with the division operator. Using `double` will result in a decimal where `int` will result in a whole number with the decimal removed. This means that `10/3` is either `3.3333...` or `3` based on data types.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1740,7 +1803,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1774,7 +1840,6 @@ } ], "guidance": "Modulo is the remainder after division is performed. So division is a part of modulo, but modulo is not division. Modulo can be used to determine if a number is even or odd, but modulo can do more than that. Finally, the `%` is used with modulo, but modulo does not deal with percentages.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1797,7 +1862,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1809,7 +1877,6 @@ "instructions": "Complete the code below so that the program prints the product of `a` and `b`.", "text": "```\nint a = 5;\nint b = 9;\nSystem.out.println( a <<<*>>> b);\n```", "guidance": "Use `*` for multiplication. You also need to add the variable b, multiplication requires two numbers.\n\n`System.out.println(a * b);`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -1842,6 +1909,9 @@ 0, " b);\n```" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -1876,7 +1946,6 @@ } ], "guidance": "Modulo is a type of division, so it is done in order from left to right with the `/` and `*` operators.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1899,7 +1968,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1913,7 +1985,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\" : \"sortableTrash\"\n}", "grader": "", "guidance": "```\ndouble a = 2;\nSystem.out.println(5/a);\n```\n\nFor \"normal\" division to take place, a needs to be a `double` because `5` is not. If it was `5.0` then `int` vs `double` would not matter.\n\nCasting the result as `double` is not necessary since the result of division including a double is always going to be a double.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -1935,7 +2006,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -1969,7 +2043,6 @@ } ], "guidance": "Because modulo is a type of division, you cannot modulo divide by 0. Similar to `/0`, `%0` produces an error.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -1992,7 +2065,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2004,7 +2080,6 @@ "instructions": "Enter the appropriate operator for each definition.", "text": "This operator checks if two values are equal - <<<==>>>\nThis operator assigns a value to a variable - <<<=>>>\nThis operator checks if two values are not equal - <<>>", "guidance": "* The `=` operator assigns a value to a variable\n* The `==` operator checks equality between two values\n* The `!=` operator checks inequality between two values", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -2042,6 +2117,9 @@ "\nThis operator checks if two values are not equal - ", 0 ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -2076,7 +2154,6 @@ } ], "guidance": "There are two conditions that would cause `a <= b` to be true. One is if `a` is less than `b` and the other is `a` is equal to `b`. \n\nAs long as one of those conditions is true, then `a <= b` will be true.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2099,7 +2176,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2133,7 +2213,6 @@ } ], "guidance": "The `>=` operator only returns `true` if the first number is greater than or equal to the second number. So the follow statements would evaluate to true:\n`19 >= 19` and `19 >= 9`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2156,7 +2235,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2168,7 +2250,6 @@ "instructions": "Fill in the blanks for the following two statements.", "text": "For an `&&` statement to be true, all of the boolean expressions must be <<>>.\n\nFor an `&&` statement to be false, only one of the boolean expressions needs to be <<>>.", "guidance": "All of the boolean expressions must be true if an and statement is true.\n\nOnly one boolean expression needs to be false for an and statement to be false.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -2204,6 +2285,9 @@ 0, "." ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -2216,7 +2300,6 @@ "instructions": "Fill in the blanks for the following two statements.", "text": "For an `||` statement to be false, all of the boolean expressions must be <<>>.\n\nFor an `||` statement to be true, only one of the boolean expressions needs to be <<>>.", "guidance": "The `or` operator requires that all boolean expressions be false for the whole thing to be false.\n\nHowever, only one boolean expressions needs to be true for an `or` operator to be true.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -2252,6 +2335,9 @@ 0, "." ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -2264,7 +2350,6 @@ "instructions": "Evaluate the two expressions below.\n\n", "text": "`5 != 4` returns <<>>\n`! 5 == 4` returns <<>>", "guidance": "Both values evaluate to `true`. In the second case, 5==4 first evaluates to `false` and then `! false` evaluates to `true`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -2299,6 +2384,9 @@ "\n`! 5 == 4` returns ", 0 ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -2311,7 +2399,6 @@ "instructions": "Use the dropdown menus to complete the text below.", "text": "## Or Operator\nWhen using the `||` operator, Java checks to see if the first boolean expression is <<>>. If it is <<>>, Java returns <<>> and ignores the second boolean expression.\n\n## And Operator\nWhen using the `&&` operator, Java checks to see if the first boolean expression is <<>>. If it is <<>>, Java returns <<>> and ignores the second boolean expression.", "guidance": "If the first boolean expression for the `||` operator is true, then the entire thing is true. The second boolean expression is ignored.\n\nIf the first boolean expression for the `&&` operator is false, then the entire thing is false. The second boolean expression is ignored.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -2360,6 +2447,9 @@ 0, " and ignores the second boolean expression." ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -2389,7 +2479,6 @@ } ], "guidance": "Because the first three conditions evaluate as true, when combined with `&&` evaluates as true. When you reach the `||` operator you then have `true || #unknown condition#`. Java short circuits and evaluates the entire line as `true` without ever evaluating the #unknown condition#.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2412,7 +2501,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2436,7 +2528,6 @@ } ], "guidance": "First, start by evaluating the expressions in the parentheses.\n\n`( 7 >= 7)` returns true.\n`(true || 99 < 1)` returns true\n`! (3 > 5 && 7 < 10)` returns true\n`2 != 4` returns true\nSo the boolean expression is now `true && true || true && true`, which returns true.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2459,7 +2550,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2471,7 +2565,6 @@ "instructions": "", "text": "<<<*>>> is the operator for multiplication\n<<<%>>> is the operator for modulo\n<<>> is the operator for division\nThe <<>> operator might return a result different from a calculator if both numbers are `int`s", "guidance": "\\* is the operator for multiplication\n% is the operator for modulo\n/ is the operator for division\nThe / operator might return a result different from a calculator if both numbers are `int`s", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -2513,6 +2606,9 @@ 0, " operator might return a result different from a calculator if both numbers are `int`s" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -2547,7 +2643,6 @@ } ], "guidance": "Only the `+` operator can be used with Strings. It serves as the concatenation operator - merging two strings together.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2570,7 +2665,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2584,7 +2682,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\"\n}", "grader": "1", "guidance": "Order of operations starts with any expression in parentheses. Next, any exponents are calculated. Then multiplication and division (including modulo) are done moving from left to right. Finally, addition and subtraction are done moving from left to right.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -2606,7 +2703,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2630,7 +2730,6 @@ } ], "guidance": "Starting with parentheses, `5 != 3` is `true`. So `! true` would be `false`. \n\nUsing the short circuit principal, we can stop evaluating the problem because when we use the `&&` operator, both boolean expressions must be `true` for it to return `true`. Since we have `false` for the first expression, it cannot be `true`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2653,7 +2752,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2667,7 +2769,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The compilation bug is located on the following line:\n```\nboolean b = 9;\n```\n\nThe bug is that `b` is declared as a `boolean` but is being assigned `9` which is an `int`. To correct this, you would replace `boolean` with `int` which results in:\n```\nint b = 9;\n```\n", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -2689,7 +2790,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2703,7 +2807,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The following will solve the code:\n```\nint a = 4;\nint b = 9;\n```\n\nBut there are other valid solutions! Can you find another one?", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -2725,7 +2828,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2739,7 +2845,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "Here are a few ways to accomplish this task:\n\n```\nSystem.out.println( 5 == 4 );\nSystem.out.println( ! 5 < 8 && 6 >= 2 );\nSystem.out.println( 5 > 8 || 6 < 2 );\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -2762,7 +2867,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2776,7 +2884,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The variables names can be anything you want. One needs to contain the string `Hello` and the other `world`. Don’t forget that there needs to be a space separating the two words. To print both variables at once, use the `+` operator to concatenate the strings.\n```\nString var_1 = \"Hello \";\nString var_2 = \"world\";\nSystem.out.println(var_1 + var_2);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -2798,7 +2905,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2812,7 +2922,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "You can either declare one or both of the variables as double:\n\n```\ndouble seven = 7.0;\ndouble two = 2.0;\nSystem.out.println(seven/two);\n```\n\nOr you can type cast one or both of the variables:\n```\nint seven = 7;\nint two = 2;\nSystem.out.println( (double) seven / (double) two);\n```\n", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -2834,7 +2943,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2873,7 +2985,6 @@ } ], "guidance": "```java\nwords = \"3.7\";\nSystem.out.println(Integer.parseInt(words) + number);\n```\nis invalid because `3.7` cannot be parsed into an int. The string must have an integer value. You can see in the other parse examples (`parseBoolean` and `parseDouble`) that words has to be re-assigned to a compatible String.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -2896,7 +3007,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -2910,7 +3024,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "", - "showGuidanceAfterResponse": false, "points": 1, "oneTimeTest": false, "metadata": { @@ -2932,7 +3045,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -2945,7 +3061,6 @@ "command": "java -cp code/operators/ Exercise5", "preExecuteCommand": "javac code/operators/Exercise5.java", "guidance": "Your friend is attempting to add Strings - but the `+` operate concatenates them! To solve this, you need to use `Integer.parseInt()` to transform the user input to `int`s. One example of a solution is:\n```\nint sum = Integer.parseInt(firstNum) + Integer.parseInt(secondNum);\nSystem.out.println(firstNum + \" + \" + secondNum + \" = \" + String.valueOf(sum));\n```\nYou might have noticed you do not need the `String.valueOf` since Java auto-converts some types - but being explicit is helpful to the readers of your code!", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -3003,7 +3118,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3017,7 +3135,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\"\n}", "grader": "1", "guidance": "```\nif( 7 != 4 ) {\n System.out.println(\"Only print this if true\");\n}\nSystem.out.println(\"Always print me!\");\n```\nThe three main pieces of an if statement are:\n1) The keyword `if`\n2) A boolean expression in `()`\n3) Statements in `{}` the run only if `true`", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -3039,7 +3156,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3068,7 +3188,6 @@ } ], "guidance": "The case where age is 18 is not covered by this set of if statements.\n```\nif( age < 18 ) {\nSystem.out.println(\"No voting, try again next year.\"); }\nif( age > 18 ) {\nSystem.out.println(\"You can vote!\"); }\n```\nTo correct it, you would need to change the third line of code to:\n```\nif( age >= 18 ) {\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3091,7 +3210,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3125,7 +3247,6 @@ } ], "guidance": "The program will only know the boolean expression is false after reaching the if statement. The first line with the `if` keyword is always checked, it is the code in the `{}` which will not be run if the boolean expression is false.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3140,7 +3261,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3152,7 +3276,6 @@ "instructions": "Complete the if statements below so that it will determine if the variable `num` is even or odd.", "text": "`if<<<(>>>num%2==0<<<)>>> <<<{>>>`\n` System.out.println(\"Even\");`\n`<<<}>>>`\n`if<<<(>>>num%2==1<<<)>>> <<<{>>>`\n` System.out.println(\"Odd\");`\n`<<<}>>>`", "guidance": "```\nif(num%2==0) {\n System.out.println(\"Even\");\n}\nif(num%2==1) {\n System.out.println(\"Odd\");\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -3198,6 +3321,9 @@ 0, "`" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -3232,7 +3358,6 @@ } ], "guidance": "Java uses curly braces to group code commands. While indention is helpful, it does not effect how the program runs. Instead, you need to use curly braces to tell Java what code runs in both the true condition (after the `if`) and the false condition (after the `else`).\n\nAdditionally, because `else` refers to the `if`, it does not need its own boolean expression. Nor does it need parentheses.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3255,7 +3380,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3269,7 +3397,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\"\n}", "grader": "1", "guidance": "```\nif ( num % 2 == 0 ) {\n System.out.println(\"Even\");\n} else {\n System.out.println(\"Odd\");\n}\n```\nIf the remainder of `num`/2 is `0` then it is even. We can find the remainder using `%` the modulo operator.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -3291,7 +3418,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3325,7 +3455,6 @@ } ], "guidance": "The corrected code looks like:\n```\nif (3 > 4) {\n System.out.println(\"true\");\n}\nelse {\n System.out.println(\"false\");\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3340,7 +3469,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3374,7 +3506,6 @@ } ], "guidance": "Compound conditionals allow you to test two or more things to be true, and they make your code more concise and easy to read.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3397,7 +3528,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3411,7 +3545,6 @@ "options": "{\n \"sortableId\": \"sortable\"\n}", "grader": "1", "guidance": "```\nif( rainy ) {\n if( windy ) {\n System.out.print(\"Wear a rain jacket.\"); }\n else {\n System.out.print(\"Bring an umbrella!\"); }\n} else {\n if( cold ) {\n System.out.print(\"You might need a coat.\"); }\n else {\n System.out.print(\"Enjoy your day!\"); }\n}\n```\n\nBy nesting if-else statements, you can create 4 unique cases: rainy and windy, rainy but not windy, not rainy and cold, and not rainy or cold.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -3425,7 +3558,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3459,7 +3595,6 @@ } ], "guidance": "`switch (num) { `\nThe `switch` keyword is followed by the variable in parentheses. \nThe case statements are surrounded by curly braces.\n\n`case \"one\" : number = 1; break;`\nEach case keyword is followed by a value and `:`\nAfter the code that should run if the variable == value, a `break;` ends the switch case.\n\n`default: number = -1;`\nIt is best practice to have the final case be `default`. Since it is the final case, it does not need a `break;` statement.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3482,7 +3617,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3511,7 +3649,6 @@ } ], "guidance": "Generating race winners requires comparing unknown times and for categories you will need a compound conditional -- so you need `if else`.\n\nSimilarly, a car's milage is going to fall into a range. Additionally, you will need to check against variables to see if the service has been done -- so you need `if else`.\n\nA `switch` would work well in the phone example since the user can only press 10 discrete buttons with constant values.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3534,7 +3671,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3568,7 +3708,6 @@ } ], "guidance": "By listing the items from most expensive to least expensive, we can assume that every item after the true case is also affordable.\n\n```\nswitch(pennies) {\n case 4: System.out.println(\"Goldfish (4 pennies)\");\n case 3: System.out.println(\"Jump rope (3 pennies)\");\n case 2: System.out.println(\"Pet rock (2 pennies)\");\n case 1: System.out.println(\"Marble (1 penny)\"); break;\n default: System.out.println(\"It looks like you need some pennies!\");\n}\n```\n\nAdditionally, by removing the `break` statements between cases, Java continues down until the end of case 1. \n\nExploiting these two facts results in only having to state each item once.\n\nThe one break statement after case 1 is so that the out of money message should really only show if they do not have any pennies.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -3583,7 +3722,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3595,7 +3737,6 @@ "instructions": "Select the correct key word to make the code below a valid switch statement.", "text": "```\n<<>> (years) {\n <<>> 5: System.out.println(\"5 year award\"); <<>>;\n <<>> 10: System.out.println(\"10 year award\"); <<>>;\n <<>> 20: System.out.println(\"20 year award\"); <<>>;\n <<>> 30: System.out.println(\"30 year award\"); <<>>;\n default: System.out.println(\"You are not eligible for a longevity award this year\");\n}\n```", "guidance": "```\nswitch (years) {\n case 5: System.out.println(\"5 years of employment award\"); break;\n case 10: System.out.println(\"10 years of employment award\"); break;\n case 20: System.out.println(\"20 years of employment award\"); break;\n case 30: System.out.println(\"30 years of employment award\"); break;\n default: System.out.println(\"You are not eligible for a longevity award this year\");\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -3644,6 +3785,9 @@ 0, ";\n default: System.out.println(\"You are not eligible for a longevity award this year\");\n}\n```" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -3656,7 +3800,6 @@ "instructions": "Complete the paragraph below using the drop downs.", "text": "A switch statement uses a variable to make decisions. It checks if the variable is <<>> to the value listed after the key word <<>>. After the `:` is code that runs if that case is true. The code ends with a <<>> statement. The default case should be <<>>.", "guidance": "A switch statement uses a variable to make decisions. It checks if the variable is equal to the value listed after the key word case. After the `:` is code that runs if that case is true. The code ends with a break statement. The default case should be last.\n\nIn code, this looks like:\n```\nint dayOfWeek = 3;\nswitch(dayOfWeek) {\n\n case 1: System.out.print(\"Sunday\"); break;\n case 2: System.out.print(\"Monday\"); break;\n case 3: System.out.print(\"Tuesday\"); break;\n case 4: System.out.print(\"Wednesday\"); break;\n case 5: System.out.print(\"Thursday\"); break;\n case 6: System.out.print(\"Friday\"); break;\n case 7: System.out.print(\"Saturday\"); break;\n default : System.out.print(\"Invalid\");\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -3699,6 +3842,9 @@ 0, "." ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -3712,7 +3858,6 @@ "command": "java -cp code/conditionals/ Lab_Challenge", "preExecuteCommand": "javac code/conditionals/Lab_Challenge.java", "guidance": "One way to complete this challenge is a switch statement:\n```\nString monthString;\n switch (month) {\n case 1: monthString = \"January\"; break;\n case 2: monthString = \"February\"; break;\n case 3: monthString = \"March\"; break;\n case 4: monthString = \"April\"; break;\n case 5: monthString = \"May\"; break;\n case 6: monthString = \"June\"; break;\n case 7: monthString = \"July\"; break;\n case 8: monthString = \"August\"; break;\n case 9: monthString = \"September\"; break;\n case 10: monthString = \"October\"; break;\n case 11: monthString = \"November\"; break;\n case 12: monthString = \"December\"; break;\n default: monthString = \"Invalid month\"; break;\n }\n System.out.println(monthString);\n```\n\nYou could have also used either if or if-else statements too!", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -3828,7 +3973,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3841,7 +3989,6 @@ "command": "java -cp code/conditionals/ Exercise1", "preExecuteCommand": "javac code/conditionals/Exercise1.java", "guidance": "You can do this with a single if statement using a compound conditional.\n```\nif( (x >= 0 && x <=25) || (x >= 75 && x <=100) )\n { System.out.println(String.valueOf(x) + \" is between 0 and 25 or 75 and 100\"); }\n```\nAlternatively, you could use other combinations such as two separate if statements.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -3922,7 +4069,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -3935,7 +4085,6 @@ "command": "java -cp code/conditionals/ Exercise2", "preExecuteCommand": "javac code/conditionals/Exercise2.java", "guidance": "A single if else can be used to solve this exercise. The real trick is remembering that modulo `%` is the correct operator to check for \"is divisible by\".\n\n```\nif ( x % 5 == 0 )\n { System.out.println(String.valueOf(x) + \" is divisible by 5\"); }\nelse\n { System.out.println(String.valueOf(x) + \" is not divisible by 5\"); }\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -4010,7 +4159,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4023,7 +4175,6 @@ "command": "java -cp code/conditionals/ Exercise3", "preExecuteCommand": "javac code/conditionals/Exercise3.java", "guidance": "You can use a single `if else` with compound conditionals to complete this challenge:\n```\nif ( x % 5 == 0 && x % 2 == 0)\n { System.out.println(String.valueOf(x) + \" is divisible by 5 and even\"); }\nelse\n { System.out.println(String.valueOf(x) + \" is not divisible by 5 or it is odd\"); }\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -4097,7 +4248,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4110,7 +4264,6 @@ "command": "java -cp code/conditionals/ Exercise4", "preExecuteCommand": "javac code/conditionals/Exercise4.java", "guidance": "There are a few ways to do this. One way is to use a `switch case`:\n```\nswitch (x) {\n case \"yellow\": case \"red\": case \"blue\": System.out.println(x + \" is a primary color\"); break;\n default: System.out.println(x + \" is not a primary color\"); break;\n}\n```\n\nOr you could use a compound conditional in an `if else`:\n```\nif( x.equals(\"yellow\") || x.equals(\"red\") || x.equals(\"blue\") )\n {System.out.println(x + \" is a primary color\");}\nelse\n {System.out.println(x + \" is not a primary color\");}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -4192,7 +4345,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4205,7 +4361,6 @@ "command": "java -cp code/conditionals/ Exercise5", "preExecuteCommand": "javac code/conditionals/Exercise5.java", "guidance": "You can either use a switch case or if else for this:\n\n```\nswitch (x) {\n case \"a\": case \"e\": case \"i\": case \"o\": case \"u\": System.out.println(x + \" is a vowel\"); break;\n default: System.out.println(x + \" is not a vowel\"); break;\n}\n```\n\n```\nif( x.equals(\"a\") || x.equals(\"e\") || x.equals(\"i\") || x.equals(\"o\") || x.equals(\"u\") )\n {System.out.println(x + \" is a vowel\");}\nelse\n {System.out.println(x + \" is not a vowel\");}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "options": { @@ -4293,7 +4448,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4307,7 +4465,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "Since we want to include the numbers from `1` through `100` in our sum, which starts at `0`, the appropriate loop header to use will be `for (int i = 1; i <= 100; i++)`. Remember that `<` is not inclusive, but `<=` is. The loop iterator variable `i` is then added to the `sum` during each iteration. Finally, the `sum` is printed. Thus, the correct solution is:\n```java\nint sum = 0;\nfor (int i = 1; i <= 100; i++) {\n sum += i;\n}\nSystem.out.println(sum);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -4323,7 +4480,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4357,7 +4517,6 @@ } ], "guidance": "Only choices #1 and #4 are correct because they are both executed **exactly** 100 times. `for (int i = 0; i < 100; i++)` goes from 0 to 99 and `for (int i = 1; i <= 100; i++)` goes from 1 to 100. Both of those ranges include 100 iterations.\n\n`for (int i = 0; i <= 100; i++)` goes from 0 to 100 which is a total of 101 iterations.\n\n`for (int i = 1; i < 100; i++)` goes from 1 to 99 which is only 99 iterations.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -4372,7 +4531,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4386,7 +4548,6 @@ "options": "{\n \"sortableId\": \"sortable\"\n}", "grader": "1", "guidance": "The solution is:\n```java\nint i = 0;\nwhile( i < 10 ) {\n System.out.println(\"Java\");\n i++;\n}\n```\nNotice that the variable is declared **before** the while loop and is incremented **inside** the loop.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -4400,7 +4561,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4412,7 +4576,6 @@ "instructions": "Fill in the blanks such that the while loop will stop once `total` is greater than 100.", "text": "int <<>> = 0;\nwhile ( <<>> ) {\n //increment total by some random number\n if(<<>> > 100)\n { <<>> }\n}", "guidance": "The correct solution looks like: \n```\nint total = 0;\nwhile ( true ) {\n //increment total by some random number\n if(total > 100)\n { break; }\n}\n```\n\nYou can make the same loop work without the if statement and break...\n```\nint total = 0;\nwhile (total < 100) {\n //increment total by some random number\n}\n```\n", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -4446,6 +4609,9 @@ 0, " }\n}" ] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -4460,7 +4626,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\"}", "grader": "1", "guidance": "You may have noticed that the line number corresponds with how many digits are printed on each line. For example, **line #1** prints just the number **1** and **line #5** prints numbers **1 through 5**. This means that the outer loop iterator variable `line` should start at 1 and go through 12. The inner loop iterator variable `num` depends on the outer loop variable `line` which is why `num <= line` is included in the loop header. This means `num` will only go up to `line` but never over. Additionally, the output produced by the inner loop **do not** include a newline character, which enables the numbers to be printed side by side. Only the outer loop will include the newline character to help separate the lines from each other.\n\n**Solution:**\n```java\nfor (int line = 1; line <= 12; line++) {\n for (int num = 1; num <= line; num++) {\n System.out.print(num + \" \");\n }\n System.out.println(\"\");\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -4476,7 +4641,10 @@ "opened": [] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4488,7 +4656,6 @@ "instructions": "Fill in the blanks such that the nested loop will print out:\n\n```\n&&\n*\n*\n*\n&&\n*\n*\n*\n&&\n*\n*\n*\n&&\n*\n*\n*\n```", "text": "```java\nfor(int i = 0; i < <<<4>>>; i++) {\n System.out.println(\"<<<&&>>>\");\n for(int j = 0; j < <<<3>>>; j++) {\n System.out.println(\"<<<*>>>\");\n }\n}\n```", "guidance": "The tricky part is to identify the pattern. The first pattern is that `&& * * *` is repeated 4 times. The pattern within that is that you have a `&&` followed by 3 `*`. Once you are able to break this up - it is clear that the outer loop should repeat 4 times and the inner loop should repeat 3.\n\nThe next part is where to place the print statements. In this case, since the one-off `&&` is printed *before* the repeating `*` - the print statement in the outer loop needs to be placed *before* the inner loop.\n\n```\nfor(int i = 0; i < 4; i++) {\n System.out.println(\"&&\");\n for(int j = 0; j < 3; j++) {\n System.out.println(\"*\");\n }\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -4523,6 +4690,9 @@ "\");\n }\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -4537,7 +4707,6 @@ "options": "{\n \"sortableId\": \"sortable\",\n \"trashId\": \"sortableTrash\"\n}", "grader": "1", "guidance": "`String var = \"this is a string\";`\nUnlike the other data types so far, `String` is uppercase. The string must be surrounded by double quotation marks `\"`.\n", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -4559,7 +4728,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4573,7 +4745,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "It does not matter where you split up the string...but the first line needs to use `print` instead of `println`. You can also use `print` for both.\n\n```\nSystem.out.print(\"Okay, it is time to \");\nSystem.out.print(\"learn about operators.\");\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": false, "metadata": { @@ -4595,7 +4766,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4629,7 +4803,6 @@ } ], "guidance": "Since all of the loop iterators start at 0, you have to count 0 as the first iteration. You want a total of 10 iterations which is why only choices #2 and #3 are correct. Remember that the operator `<` does not include the end value but the `<=` operator does.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -4652,7 +4825,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4666,7 +4842,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\"}", "grader": "1", "guidance": "In order to produce the provided output, the code blocks **with indentations** should look like:\n```java\nfor (int x = 0; x < 5; x++) {\n if (x % 2 == 0) {\n System.out.println(\"Even Odd Even\");\n }\n else {\n System.out.println(\"Odd Even Odd\");\n }\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -4688,7 +4863,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4722,7 +4900,6 @@ } ], "guidance": "Only choice #3 will result in an infinite `while` loop because `lives` will never reach `0` or less to terminate the loop. \n\nThe `while` loops in choices #1 and #4 are not executed because the boolean expression in the loop header never evaluates to true. \n\nThe `while` loop in choice #2 executes but is ended once `lives` reaches `0` due to `lives` being decremented after each iteration.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -4745,7 +4922,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4779,7 +4959,6 @@ } ], "guidance": "By definition, an **infinite loop** occurs when a program has no test conditions to cause a loop to stop. The program above will indefinitely ask the user for input and store that input regardless of what the user enters.\n\nChoices #1 and #2 are correct because they will offer a condition for the loop to stop depending on what the user enters.\n\nChoice #3 will result in errors because the `for` loop syntax is incorrect. The program can still run, but the infinite loop is not resolved.\n\nChoice #4 will result in an error because the String `s` needs to be initialized.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -4807,7 +4986,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4821,7 +5003,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The pattern can be identified as follow. There is one line of `XOXOXOXOX` following by two lines of `OXO`. Thus, we will need an outer `for` loop like `for (int x = 0; x < 1; x++)`. The outer loop will only run **once**. On the other hand, the inner loop needs to run **twice**, thus something like `for (int y = 0; y < 2; y++)` is needed. The outer loop should print `XOXOXOXOX` whereas the inner loop should print `OXO`. However, these two nested loops will only produce the output:\n```java\nXOXOXOXOX\nOXO\nOXO\n```\nTo iterate or repeat the pattern **three times**, we will have to modify the outer loop to run three times instead of once. Thus, all we have to do is change the outer loop header from `x < 1` to `x < 3`. Here is one possible solution:\n```java\nfor (int x = 0; x < 3; x++) {\n System.out.println(\"XOXOXOXOX\");\n for (int y = 0; y < 2; y++) {\n System.out.println(\"OXO\");\n }\n}\n```\nAlternatively, if you don't want to modify the existing nested loops, you can nest them inside another loop that runs **three times**. Here is another potential solution:\n```java\nfor (int z = 0; z < 3; z++) {\n for (int x = 0; x < 1; x++) {\n System.out.println(\"XOXOXOXOX\");\n for (int y = 0; y < 2; y++) {\n System.out.println(\"OXO\");\n }\n }\n}\n```\nNote that the outermost loop `for (int z = 0; z < 3; z++)` doesn't actually produce any output, it just runs three times, causing the identified pattern to print three times as well.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -4843,7 +5024,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4857,7 +5041,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "Here are some sample solutions:\n```java\nfor (int i = 0; i < 10; i++) {\n System.out.println(x);\n}\n```\n```java\nint i = 0;\nwhile (i < 10) {\n System.out.println(x);\n i++;\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -4879,7 +5062,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4892,7 +5078,6 @@ "command": "java -cp code/loops/ Exercise3", "preExecuteCommand": "javac code/loops/Exercise3.java", "guidance": "You can use either the `for` or `while` loop to complete this assignment. If using a `for` loop, the iterating variable should start at `a` and get incremented by 1 until it reaches `b`. Below is a sample solution involving the `for` loop.\n```java\nint sum = 0;\n \nfor (int iter = a; iter <= b; iter++) {\n sum += iter;\n}\n \nif (a == b) {\n sum = a;\n}\n \nSystem.out.println(sum);\n```\n\nAlternatively, you can use the `while` loop by setting the iterating variable to `a` and incrementing it by 1 after each time it gets added to the sum. Here is a solution that uses the `while` loop:\n```java\nint sum = 0;\nint iter = a;\n \nwhile (iter <= b) {\n sum += iter;\n iter++;\n}\n \nif (a == b) {\n sum = a;\n}\n \nSystem.out.println(sum);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "options": { @@ -4960,7 +5145,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -4974,7 +5162,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The only places where you can add a `break;` statement to successfully print `Print me!` and solve the infinite loops are **1)** after `System.out.println(\"Print me!\");` and **2)** after the first closing curly brace `}` that was initially on line 7 in the original code. See solution below:\n```java\nfor (int i = 100; i <= 100; i--) {\n while (true) {\n System.out.println(\"Print me!\");\n break;\n }\n break;\n}\n```\n\nBoth the `for` and `while` loops in the code cause the program to run indefinitely. The first `break;` statement in the solution will allow the program to exit the `while` loop and the second `break;` statement in the solution will allow the program to exit the `for` loop. In order for `Print me!` to be printed, the `break;` statement must go *after* the print statement.", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -4996,7 +5183,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5010,7 +5200,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The first step is to recognize the two patterns that exist. Notice how the numerical values are printed in ascending order starting at `1` and ending at `5`. Thus, you should implement a loop that starts and ends according to the line number (e.g. `for (int i = 1; i < 6; i++)`). In addition, each iteration should print the existing line number followed by a newline character (e.g. `System.out.println(i);`).\n\nSecond, the `.` start at 4 and then decreases by 1 after every iteration until it reaches zero. An example loop header could be `for (int j = ; j > 0; j--)`.\n\nNow all that's left to do is to combine the two loops in a manner that associates **BOTH** loops. Notice how the line number can also represent how many `.` are replaced. So the second loop can be rewritten as `for (int j = 5 - i; j > 0; j--)`. Another important detail is to not include `ln` when printing `.` because it will cause the `.` to be on different lines (e.g. `System.out.print(\".\");`). Below is a sample solution using a nested `for` loop but any two combinations of `for` and `while` loops will work.\n```java\nfor (int i = 1; i < 6; i++) {\n for (int j = 5 - i; j > 0; j--) {\n System.out.print(\".\");\n }\n System.out.println(i);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -5032,7 +5221,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5066,7 +5258,6 @@ } ], "guidance": "All of the choices above are correct **except** choice #2. It's important to recognize that the `tina.forward(100);` and `tina.right(90);` commands occur exactly **four** times. Thus, a loop that iterates those commands four times is needed. While all of the choices have a loop header that runs four times, choice #2 has a header that only runs **three** times and is therefore incorrect.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -5094,7 +5285,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5106,7 +5300,6 @@ "instructions": "Here is the output to a sample program:\n\n```java\n2\n4\n6\n8\n10\n```\nFill in the blanks below so that the loop outputs what's shown above.", "text": "```java\nfor (int n=<<<2>>>; n<<<<=>>>10; n+=<<<2>>>) {\n System.out.println(<<>>);\n}\n```", "guidance": "First, it is important to determine the pattern of the output. `2` is printed first and `10` is printed last. In addition, the numbers from `2` through `10` are printed in increments of `2`s. Noticing this pattern enables us to fill out the loop header like so: \n`for (int n=2; n<=10; n+=2)`\n\nFinally, we need to print the output. Remember that the loop iterator variable `n` is an integer itself so it can be printed like so:\n`System.out.println(n);`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -5154,6 +5347,9 @@ ");\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -5166,7 +5362,6 @@ "instructions": "Fill in the blanks below with either `while` or `for`.", "text": "A <<>> loop usually contains a boolean expression(s) in its header and nothing else.\nA <<>> loop contains a header that specifies where an iterator variable starts, where it ends, and how it is changed per iteration.\nA <<>> loop is better if a command needs to be executed a certain number of times.\nA counting variable needs to be declared and initialized before a <<>> loop can be executed properly.", "guidance": "One big difference between a `while` loop and a `for` loop is that a `while` loop only contains a boolean expression(s) within its header. That means a counting variable must be declared and initialized before a `while` loop can be used properly. On the other hand, the header of a `for` loop contains an iterator variable which helps to determine how many times the `for` loop will run.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": true, @@ -5209,6 +5404,9 @@ " loop can be executed properly." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -5223,7 +5421,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\"}", "grader": "1", "guidance": "A `while` loop requires the following:\n1. An iterator or counting variable *before* the keyword `while`.\n2. A boolean expression in `()` or header *following* the keyword `while`.\n3. A change in the iterator or counting variable *inside* the body of the `while` loop.\n\nThus, the solution is:\n```java\nint i = 10;\nwhile (i <= 100) {\n System.out.println(i);\n i+=10;\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -5250,7 +5447,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5284,7 +5484,6 @@ } ], "guidance": "The `break` statement is used to stop and exit a loop **not** a program. `break` statements are often used to prevent situations where an infinite loop might be involved; however, `break` statements are not always required.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -5307,7 +5506,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5319,7 +5521,6 @@ "instructions": "Fill in the blanks below so that the `while` loop prints `Java` **10** times.", "text": "```java\nint <<>> = 0;\nwhile (count <<<<>>> 10) {\n System.out.println(\"Java\");\n count = count <<<+>>> 1;\n}\n```", "guidance": "The counting variable that is being used in the code is called `count`. If `count` is initialized to `0`, then **ten iterations** will cause it to stop at `9`. Thus, `count < 10` is the correct loop header. `count = count + 1` does the same thing as `count++` and will increment the counting variable by `1` after during each iterations.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -5351,6 +5552,9 @@ " 1;\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -5363,7 +5567,6 @@ "instructions": "Fill in the blanks such that the loop will **stop and exit** after it has run **100** times.", "text": "```java\nint total = 0;\nwhile (true) {\n total = <<>> + 1;\n if (total > <<<99>>>) {\n <<>>;\n }\n}\n```", "guidance": "`total` is the counting variable that is used in the code above. To increment `total` so that it iterates **100 times**, `total = total + 1` is needed. Since `total` starts at `0` and we want it to iterate 100 times before stopping, we will insert a `break` statement to stop the loop once `total > 99` becomes true. The range from `0` through `99` is a total of exactly 100 iterations.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "showValues": false, @@ -5395,6 +5598,9 @@ ";\n }\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -5429,7 +5635,6 @@ } ], "guidance": "By definition, a **nested loop** is when one loop exists inside another loop. There are are restrictions on the type of loop that can be nested nor the number of nested loops that can be used (though it is rare to implement more than two nested loops). Thus, a `for` loop can be nested in another `for` loop and a `while` loop can be nested inside another `while` loop. In addition, a `for` loop can be nested inside a `while` loop and vice versa. ", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -5452,7 +5657,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5466,7 +5674,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "The first step is to figure out the pattern that `tina` moves. First `tina` moves forward by 100 pixels. Then `tina` turns left 120 degrees. Thus `tina`'s commands are `tina.forward(100)` and then `tina.left(120)`. This pattern happens exactly three times.\n\nNext is setting the loop so that `tina`'s commands are iterated three times. Per requirements, your loop header should include `int i = 0` and `i++`. Here are some possible solutions:\n```java\nfor(int i = 0; i < 3; i++) {\n tina.forward(100);\n tina.left(120);\n}\n```\n```java\nfor(int i = 0; i <= 2; i++) {\n tina.forward(100);\n tina.left(120);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -5493,7 +5700,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5527,7 +5737,6 @@ } ], "guidance": "In order to store integers into an array, `int[]` must be used. Also, we know we want elements in the array to be initialized to numbers 1 through 5 which means we cannot use `new`. Thus, the correct answer is `int[] numbers = {1, 2, 3, 4, 5};`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -5562,7 +5771,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Create an array using both the initializer list and new methods" + "learningObjectives": "SWBAT Create an array using both the initializer list and new methods", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5576,7 +5788,6 @@ "text": "1. `System.out.println(tenths[0])` will print <<<1.2>>>.\n2. `System.out.println(tenths[2])` will print <<<3.4>>>.\n3. `System.out.println(tenths[4])` will print <<>>.", "distractors": "2.3\n4.5\n", "guidance": "Remember that array indices always start at `0`. Thus, `tenths[0]` refers to the first element, `tenths[2]` refers to the third element, and `tenths[4]` refers to the fifth element. The first element is `1.2`, the third element is `3.4`, and the fifth element does not exist. Therefore, an `ArrayIndexOutOfBoundsException` error message will be returned.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -5627,6 +5838,9 @@ "." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -5641,7 +5855,6 @@ "text": "```java\n<<>>[] test = {\"<<>> test: \", \"Second test: \", \"Third test: \"};\nint[] scores = <<>> int[<<<3>>>];\n\nscores[<<<0>>>] = 84;\n<<>>[1] = 76;\nscores[2] = <<<97>>>;\n\nSystem.out.println(<<>>[0] + scores[<<<0>>>]);\nSystem.out.println(test[<<<1>>>] + scores[<<<1>>>]);\nSystem.out.println(test[<<<2>>>] + <<>>[2]);\n```", "distractors": "", "guidance": "The first array uses the **initializer list** method to populate Strings into the array. Thus, `String[]` is needed. While initializing the String array, the first element should be initialized to \"`First` test: \". \n\nThe second array uses the **new** method to populate ints into the array. Thus, `new` is needed followed by int[`3`] in order to store 3 elements.\n\nDue to the **new** method, the int array will be populated with the default `0`. To change the elements, you must specify the indices at which they are located and assign them the appropriate values. For example, `scores[0] = 84;` will replace the first element in the array with `84`.\n\nThe print statements should refer to the elements' indices starting from `0` and going through `2`. You need to use both arrays in your print statements. For example, `System.out.println(test[0] + scores[0]);`\n\n**Solution:**\n```java\nString[] test = {\"First test: \", \"Second test: \", \"Third test: \"};\nint[] scores = new int[3];\n\nscores[0] = 84;\nscores[1] = 76;\nscores[2] = 97;\n\nSystem.out.println(test[0] + scores[0]);\nSystem.out.println(test[1] + scores[1]);\nSystem.out.println(test[2] + scores[2]);\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -5717,6 +5930,9 @@ "[2]);\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -5751,7 +5967,6 @@ } ], "guidance": "In order to modify an array element, you must specify the index at which that element is located within brackets `[]`. Also, remember that array indices start at `0` for the first element, then `1` for the second element, etc. Since we want to replace the first `Friday` with `Thursday`, which is the fourth element in the array, we need to access index number `3`. Thus, the correct answer is choice **#2**: `weekdays[3] = \"Thursday\";`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -5786,7 +6001,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Access and modify array elements" + "learningObjectives": "SWBAT Access and modify array elements", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5800,7 +6018,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The first step is to initialize all of the elements inside the array. The array type is **double**, therefore you cannot initialize the elements as Strings (i.e `\"23.67\"`, etc.). Next, the `for` loop needs to run exactly **three** times to iterate through the three elements that we have. You cannot use `for (int i = 0; i <= 3; i++) {` because that will cause the loop to run **four** times. We do not have a fourth element so the system will encounter an `ArrayIndexOutOfBoundsException` error. Use `for (int i = 0; i < debt.length; i++) {` instead because `debt.length` will always keep track of how many elements are in our array. Lastly, we need to print `debt[i]`, not `debt`. Remember, `debt` is the array itself, not the array elements. Printing `debt` will only print its memory address.\n\n**Solution:**\n```java\ndouble[] debt = {23.67, 82.96, 34.51};\nfor (int i = 0; i < debt.length; i++) {\n System.out.println(debt[i]);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -5834,7 +6051,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Iterate through arrays using a for loop" + "learningObjectives": "SWBAT Iterate through arrays using a for loop", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5868,7 +6088,6 @@ } ], "guidance": "The biggest advantage of an enhanced `for` loop is that it cuts down on the amount of code needed to **print all of the elements** inside an array. Unfortunately, it cannot access array indices, modify array elements, nor print specific elements within an array.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -5903,7 +6122,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT Iterate through arrays using an enhanced for loop" + "learningObjectives": "SWBAT Iterate through arrays using an enhanced for loop", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -5917,7 +6139,6 @@ "text": "```java\nint[] numbers = {15, 48, 22, 93, 75};\n\n<<>> (<<>> i : numbers) {\n <<>> (i % 2 == <<<0>>>) {\n System.out.println(\"Even\");\n }\n else {\n System.out.println(\"<<>>\");\n }\n}\n```", "distractors": "", "guidance": "The code implements an enhanced `for` loop, thus you need to specify the type for `i` which is `int`. A conditional `if` is needed to direct the program to print `Even` if the element has no remainder when dividing by 2, `if (i % 2 == 0)`. Otherwise, the element is an odd number and the program will print `Odd`.\n\n**Solution:**\n```java\nint[] numbers = {15, 48, 22, 93, 75};\n\nfor (int i : numbers) {\n if (i % 2 == 0) {\n System.out.println(\"Even\");\n }\n else {\n System.out.println(\"Odd\");\n }\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -5974,6 +6195,9 @@ "\");\n }\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -6008,7 +6232,6 @@ } ], "guidance": "**Guide:**\n* The elements `18`, `21`, `15`, `2`, and `68` are added to the array called `ages`.\n* An enhanced `for` loop is used which causes `i` to take on the value of each element.\n* If `i` is greater than or equal to `18`, then the system prints `Eligible`.\n* Otherwise, the system will print `Ineligible`.\n* `18`, `21`, and `68` will result in `Eligible` since they are greater than or equal to `18`.\n* `15` and `2` are less than `18` so they will result in `Ineligible`.\n\n**Solution:**\n```java\nEligible\nEligible\nIneligible\nIneligible\nEligible\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6035,7 +6258,10 @@ "opened": [] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Determine array output" + "learningObjectives": "SWBAT Determine array output", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6069,7 +6295,6 @@ } ], "guidance": "There are *unique* labels for data types in ArrayLists. Instead of `int`, `double`, and `boolean`, ArrayLists use `Integer`, `Double`, and `Boolean`. Only `String`s is similarly used between ArrayLists and arrays. Thus, it should be `ArrayList list = new ArrayList();` rather than `ArrayList list = new ArrayList();`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6104,7 +6329,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT Create an empty ArrayList" + "learningObjectives": "SWBAT Create an empty ArrayList", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6138,7 +6366,6 @@ } ], "guidance": "By following the syntax for adding and removing ArrayList elements, you should end up with the output `[I, really, hate, bean sprouts]`.\n\n**Code Flow:**\n`words.add(\"I\");` ---> `[I]`\n`words.add(\"love\");` ---> `[I, love]`\n`words.remove(1);` ---> `[I]`\n`words.add(\"hate\");` ---> `[I, hate]`\n`words.add(1, \"really\");` ---> `[I, really, hate]`\n`words.add(3, \"bean sprouts\");` ---> `[I, really, hate, bean sprouts]`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6173,7 +6400,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Add and remove ArrayList elements" + "learningObjectives": "SWBAT Add and remove ArrayList elements", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6187,7 +6417,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":false,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "Before any ArrayList methods can be used, an ArrayList must be created first, `ArrayList name = new ArrayList();`. After the ArrayList is created, it is empty by default so neither the `get()` nor `set()` methods will work. You must add an element to the ArrayList, thus, `name.add(\"Peter\");` comes next. Since the output is `Parker`, you want the print statement to come after `name.set(0, \"Parker\");`. Otherwise, `Peter` will be printed instead.\n\n**Solution:**\n```java\nArrayList name = new ArrayList();\nname.add(\"Peter\");\nname.set(0, \"Parker\");\nSystem.out.println(name.get(0));\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -6221,7 +6450,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Get and set ArrayList elements" + "learningObjectives": "SWBAT Get and set ArrayList elements", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6235,7 +6467,6 @@ "text": "```java\n<<>><Double> BMI = <<>> ArrayList<<<>>>();\nBMI.<<>>(18.5);\nBMI.<<>>(25.0);\nBMI.<<>>(30.0);\n\nfor (<<>> d : <<>>) {\n System.out.println(<<>>);\n}\n```", "distractors": "get\nset", "guidance": "The correct syntax for creating an empty Double ArrayList is `ArrayList BMI = new ArrayList();`. The `get()` and `set()` methods cannot be used on an empty ArrayList. Only `add()` can be used to add elements to the empty ArrayList. Since the ArrayList is of type Double, `Double` must be used to type the iterating variable `d`. On the other side of the colon `:` is the reference of the ArrayList name `BMI`. Then the final step is to print `d` which has taken on all elements of the ArrayList in order.\n\n**Solution:**\n```java\nArrayList BMI = new ArrayList();\nBMI.add(18.5);\nBMI.add(25.0);\nBMI.add(30.0);\n\nfor (Double d : BMI) {\n System.out.println(d);\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -6304,6 +6535,9 @@ ");\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -6318,7 +6552,6 @@ "text": "1. Can be initialized by adding elements into curly braces `{}`: <<>>\n2. Can add or remove elements after being created: <<>>\n3. Can change the order of elements without modifying existing elements: <<>>\n4. Can use `length` to determine the number of elements: <<>>\n", "distractors": "", "guidance": "Although it is possible to initialize elements at the start, arrays are **static** so adding or removing elements *after* initialization is not possible. On the other hand, ArrayLists are **dynamic** so it is possible to add, remove, and reorder elements. Arrays use `length` while ArrayLists use `size()` to determine the number of existing elements.\n\n**Solution:**\n1. Array\n2. ArrayList\n3. ArrayList\n4. Array", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -6372,6 +6605,9 @@ "\n" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -6386,7 +6622,6 @@ "text": "```java\nArrayList scores = new ArrayList<Integer>();\nscores.<<>>(68);\nscores.<<>>(92);\nscores.<<>>(100);\nscores.<<>>(88);\n \n<<>> feedback = \"\";\n\n<<>> (Integer i : <<>>) {\n if (i == <<<100>>>) {\n <<>> = \"You got a perfect score!\";\n break;\n }\n <<>> {\n feedback = \"Keep up the hard work!\";\n }\n}\n \nSystem.out.println(<<>>);\n```", "distractors": "", "guidance": "**Guide:**\n* All of the test scores need to be added to `scores` using `add()`.\n* `feedback` is of type `String`.\n* Enhanced `for` loop is needed due to the given syntax `(Integer i : scores)`.\n* If the iterating variable equals `100`, then `You got a perfect score!` will be assigned to `feedback`.\n* `else`, `Keep up the hard work!` will be assigned.\n* Lastly, the program should print the resulting `feedback`.\n\n**Solution:**\n```java\nArrayList scores = new ArrayList();\nscores.add(68);\nscores.add(92);\nscores.add(100);\nscores.add(88);\n \nString feedback = \"\";\n\nfor (Integer i : scores) {\n if (i == 100) {\n feedback = \"You got a perfect score!\";\n break;\n }\n else {\n feedback = \"Keep up the hard work!\";\n }\n}\n \nSystem.out.println(feedback);\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -6461,6 +6696,9 @@ ");\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -6495,7 +6733,6 @@ } ], "guidance": "Only choice **#4** will modify the `list` so that `Carrot` will replace `Banana` at index 2. Choice **#1** will only add `Carrot` to the end of the `list`. Choice **#2** will only remove the second `Banana` stored at index 2. And finally, choice **#3** will just access index 1 without modifying any elements.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6522,7 +6759,10 @@ "opened": [] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Modify ArrayList elements" + "learningObjectives": "SWBAT Modify ArrayList elements", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6556,7 +6796,6 @@ } ], "guidance": "To decode the message, follow each commands below:\n* message.add(\"a\"); ---> [a]\n* message.add(\"bad\"); ---> [a, bad]\n* message.add(0, \"today\"); ---> [today, a, bad]\n* message.set(1, \"is\"); ---> [today, is, bad]\n* message.remove(2); ---> [today, is]\n* message.add(\"good\"); ---> [today, is, good]\n* message.add(2, \"a\"); ---> [today, is, a, good]\n* message.add(\"day\"); ---> [today, is, a, good, day]\n* System.out.print(s); ---> `todayisagoodday`\n\n**Note** that the enhanced for loop will iterate through the elements and print them **without** any newlines nor spaces.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6583,7 +6822,10 @@ "opened": [] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Determine ArrayList output" + "learningObjectives": "SWBAT Determine ArrayList output", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6617,7 +6859,6 @@ } ], "guidance": "`Integer` is used for ArrayLists, not arrays. Remember, a 2D array is just an array inside another array. Therefore, the correct type is `int`. When creating a 2D array, the numbers that go into the brackets represent how many rows and columns will be created, not the row and column indices.\n\n**Solution:**\n`int[][] elements = new int[2][4];`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6652,7 +6893,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Create a 2D array using the initializer list method" + "learningObjectives": "SWBAT Create a 2D array using the initializer list method", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6686,7 +6930,6 @@ } ], "guidance": "Remember that array indices start at `0`, **not** at `1`. Thus, `2.2` is located at row index 1 and column index 1. To access an element inside a 2D array, the row and column indices must go into brackets `[][]`.\n\n**Solution:**\n`sqroots[1][1] = 2.24;`", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6721,7 +6964,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Access and modify 2D array elements" + "learningObjectives": "SWBAT Access and modify 2D array elements", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6735,7 +6981,6 @@ "text": "```java\n<<>>[][] family = { {\"Grandpa\", \"Grandma\"},\n {\"Dad\", \"Mom\"},\n {\"Brother\", \"Sister\"} };\n\nfor (int i = 0; i < family.<<>>; i++) {\n <<>> (int j = 0; j < family<<<[>>>0<<<]>>>.length; j++) {\n <<>> (j == <<>>[0].length - 1) {\n System.out.<<>>(family[i][j]);\n }\n else {\n System.out.<<>>(family[i][j] + \" \");\n }\n }\n}\n```", "distractors": "", "guidance": "**Guide:**\n* The 2D array is of type `String`.\n* The `for` loops include the iterating variable `i` that ends before `family.length` and the iterating variable `j` that ends before `family[0].length`.\n* `if` `j` gets to the end of the column index, `family[0].length - 1`, print the element with `println`, else, print the element with `print` and an empty space.\n\n**Solution:**\n```java\nString[][] family = { {\"Grandpa\", \"Grandma\"},\n {\"Dad\", \"Mom\"},\n {\"Brother\", \"Sister\"} };\n\nfor (int i = 0; i < family.length; i++) {\n for (int j = 0; j < family[0].length; j++) {\n if (j == family[0].length - 1) {\n System.out.println(family[i][j]);\n }\n else {\n System.out.print(family[i][j] + \" \");\n }\n }\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "metadata": { @@ -6804,6 +7049,9 @@ "(family[i][j] + \" \");\n }\n }\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -6818,7 +7066,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "**Guide:**\n* 2D arrays of integer is typed as `int`, not `Integer`.\n* To use an enhanced `for` loop, the first iterating variable must be `int[]` rather than `int`.\n* The iterating variables in an enhanced `for` loop cannot manipulate element indices, only element values, thus `if (j == 4 | j == 16)` is needed rather than `if (j == squares[0].length - 1)`.\n* Print using `println` for when `j` is `4` or `16`.\n* Print using `print` for when `j` is anything else with a space.\n\n**Solution:**\n```java\nint[][] squares = {{1, 4},{9, 16}};\nfor (int[] i : squares) {\n for (int j : i) {\n if (j == 4 | j == 16) {\n System.out.println(j);\n }\n else {\n System.out.print(j + \" \");\n }\n }\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -6844,7 +7091,10 @@ "opened": [] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Determine 2D array output" + "learningObjectives": "SWBAT Determine 2D array output", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6878,7 +7128,6 @@ } ], "guidance": "The program creates a 2D array and populates each index with Strings. Then some elements are printed with a newline while others are printed with a space. The solution guide below shows the sequence in which the elements are populated. Note that the `x`'s represent placeholders.\n\n**Solution Guide:**\n* Empty 2D array:\n```java\nx x\nx x\nx x\n```\n* `names[0][1] = \"First name\";`\n```java\nx First name\nx x\nx x\n```\n* `names[0][0] = \"Last name\";`\n```java\nLast name First name\nx x\nx x\n```\n* `names[2][0] = \"Man\";`\n```java\nLast name First name\nx x\nMan x\n```\n* `names[1][1] = \"Peter\";`\n```java\nLast name First name\nx Peter\nMan x\n```\n* `names[1][0] = \"Parker\";`\n```java\nLast name First name\nParker Peter\nMan x\n```\n* `names[2][1] = \"Spider\";`\n```java\nLast name First name\nParker Peter\nMan Spider\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -6905,7 +7154,10 @@ "opened": [] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Determine 2D array output" + "learningObjectives": "SWBAT Determine 2D array output", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6919,7 +7171,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\"}", "grader": "1", "guidance": "**Guide:**\n* First, create a new array with 5 elements, `boolean[] bools = new boolean[5]`.\n* Create a `for` loop that iterates through the length of the array and increments by 1 after every iteration, `for (int i = 0; i < bools.length; i++)`\n* If the index is even, modify the element and change it to `true`, `if (i % 2 == 0) { bools[i] = true }`.\n* Since the `new` method automatically initializes all elements to `false` by default, there is no need to include an `else` statement.\n\n**Solution:**\n```java\nboolean[] bools = new boolean[5];\nfor (int i = 0; i < bools.length; i++) {\n if (i % 2 == 0) {\n bools[i] = true;\n }\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -6953,7 +7204,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT determine correct array syntax" + "learningObjectives": "SWBAT determine correct array syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -6987,7 +7241,6 @@ } ], "guidance": "Both the `add()` and `remove()` methods will affect the size of the ArrayList. The size of the ArrayList will increase by one after `add()` is used and will decrease by 1 after `removed()` is used. `get()` and `set()` will access and modify an element respectively, but they do not change the size of the ArrayList.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -7022,7 +7275,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT Understand ArrayList methods" + "learningObjectives": "SWBAT Understand ArrayList methods", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7056,7 +7312,6 @@ } ], "guidance": "The 2D array is of type `int`, therefore the element has to be an integer `6` rather than a String `\"6\"`. 2D array indices start at 0, not 1; therefore, `0` is located at row index 1 and column index 2. To change `0` to `6`, the correct command is `keypad[1][2] = 6;`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -7091,7 +7346,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT Determine correct 2D array syntax" + "learningObjectives": "SWBAT Determine correct 2D array syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7105,7 +7363,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "If you used a nested `for` loop in your code, you would need to identify the pattern that exists within the chessboard. One noticeable pattern is shown below:\n```java\nOX\nXO\n```\n* **Even** row index and **even** column index = `O`\n* **Odd** row index and **odd** column index = `O`\n* **Even** row index and **odd** column index = `X`\n* **Odd** row index and **even** column index = `X`\n\n**Sample Solution:**\n```java\nfor (int i = 0; i < chessboard.length; i++) {\n for (int j = 0; j < chessboard[0].length; j++) {\n if ((i % 2 == 0) && (j % 2 == 0)) {\n chessboard[i][j] = \"O\";\n }\n else if ((i % 2 == 1) && (j % 2 == 1)) {\n chessboard[i][j] = \"O\";\n }\n else if ((i % 2 == 0) && (j % 2 == 1)) {\n chessboard[i][j] = \"X\";\n }\n else if ((i % 2 == 1) && (j % 2 == 0)) {\n chessboard[i][j] = \"X\";\n }\n }\n}\n```\n\nIf you tried to access each row/column index, then you would need to have 64 lines of code in your program to assigned each row/column pair of indices either `O` or `X`.\n```java\nchessboard[0][0] = \"O\";\nchessboard[0][1] = \"X\";\nchessboard[1][0] = \"X\";\nchessboard[1][1] = \"O\";\n...\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -7139,7 +7396,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT Apply correct 2D array syntax" + "learningObjectives": "SWBAT Apply correct 2D array syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7153,7 +7413,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "You can use several ways to print the elements inside `oceans`. You can either print each element by referring to its **index** number:\n```java\nSystem.out.println(oceans[0]);\nSystem.out.println(oceans[1]);\nSystem.out.println(oceans[2]);\nSystem.out.println(oceans[3]);\nSystem.out.println(oceans[4]);\n```\n\nOr you can use an **enhanced** `for` loop:\n```java\nfor (String s : oceans) {\n System.out.println(s);\n}\n```\n\nLastly, you can use a regular `for` loop:\n```java\nfor (int i = 0; i < oceans.length; i++) {\n System.out.println(oceans[i]);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -7187,7 +7446,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT Apply correct array syntax" + "learningObjectives": "SWBAT Apply correct array syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7201,7 +7463,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "There are multiple ways to print the desired result. One way is to add all of the specified elements into the ArrayList first. Then add a *Place Holder* element, set that *Place Holder* element to anything such as *Delete*, and finally, remove that *Delete* element.\n\n**Sample Solution:**\n```java\noceans.add(\"Pacific\");\noceans.add(\"Atlantic\");\noceans.add(\"Indian\");\noceans.add(\"Arctic\");\noceans.add(\"Southern\");\noceans.add(\"Place Holder\");\noceans.set(5, \"Delete\");\noceans.remove(5);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -7235,7 +7496,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT Apply correct ArrayList syntax" + "learningObjectives": "SWBAT Apply correct ArrayList syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7248,7 +7512,6 @@ "command": "java -cp code/arrays/ Exercise3", "preExecuteCommand": "javac code/arrays/Exercise3.java", "guidance": "There are so many different ways to approach this problem. One solution is to add the arguments in reverse order into the ArrayList. This will cause the ArrayList to hold six elements where the last three elements is the reverse of the first three. Then, all that's left to do is to remove the first three elements. Now you have a reversed ArrayList.\n\n**Sample Solution:**\n```java\nreverse.add(args[2]);\nreverse.add(args[1]);\nreverse.add(args[0]);\nreverse.remove(0);\nreverse.remove(0);\nreverse.remove(0);\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "options": { @@ -7335,7 +7598,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT Apply correct ArrayList syntax" + "learningObjectives": "SWBAT Apply correct ArrayList syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7348,7 +7614,6 @@ "command": "java -cp code/arrays/ Exercise4", "preExecuteCommand": "javac code/arrays/Exercise4.java", "guidance": "First, you would need to modify the 2D array (`nums`) so that `a`, `b`, `c`, and `d` are placed at the correct row and column indices. Next, you'd need to calculate the correct row, column, and total sums while also placing them in the appropriate row and column indices. The code below showcases how each set of row and column indices pair is accessed and modified. **Note** that the total sum is just the arguments added together and then multiplied by 2.\n\n```java\nnums[0][0] = a;\nnums[0][1] = b;\nnums[0][2] = a + b;\nnums[1][0] = c;\nnums[1][1] = d;\nnums[1][2] = c + d;\nnums[2][0] = a + c;\nnums[2][1] = b + d;\nnums[2][2] = ((a+b) + (c+d) + (a+c) + (b+d));\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "options": { @@ -7428,7 +7693,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT Apply correct 2D array syntax" + "learningObjectives": "SWBAT Apply correct 2D array syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7441,7 +7709,6 @@ "command": "java -cp code/arrays/ Exercise5", "preExecuteCommand": "javac code/arrays/Exercise5.java", "guidance": "To add input into the ArrayList `numList`, you can use `add()`. Since this method is inside of the `while` loop, the system will keep adding integers into `numList` until a non-integer is entered.\n```java\nnumList.add(input);\n```\n\nTo iterate through `numList`, add all elements to `total`, and calculate the average `avg`, you can use an enhanced `for` loop or a regular `for` loop.\n```java\nfor (Integer i : numList) {\n total += i;\n avg = total / numList.size();\n}\n```\n```java\nfor (int i = 0; i < numList.size(); i++) {\n total += numList.get(i);\n avg = total / numList.size();\n}\n```\n\n", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "options": { @@ -7526,7 +7793,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT Apply correct ArrayList syntax" + "learningObjectives": "SWBAT Apply correct ArrayList syntax", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7561,7 +7831,6 @@ } ], "guidance": "The `write` method is used to write text to a file in Java.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -7596,7 +7865,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT identify the method used to write strings to a text file" + "learningObjectives": "SWBAT identify the method used to write strings to a text file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7636,7 +7908,6 @@ } ], "guidance": "## Correct Answers\nThe correct answers are:\n\n```java\ntext1 = \"Once upon a time\\n\";\ntext2 = \"In a land far, far away\\n\";\ntext3 = \"Lived a king and queen\\n\";\nwriter.write(text1);\nwriter.write(text2);\nwriter.write(text3);\n```\nEach string has a newline character at the end.\n\n```java\ntext = \"Once upon a time\\nIn a land far, far away\\nLived a king and queen\";\nwriter.write(text);\n```\nThe string uses two newline characters to write the text over three lines.\n\n```java\nString text1 = \"Once upon a time\";\nString text2 = \"In a land far, far away\";\nString text3 = \"Lived a king and queen\";\nwriter.write(text1);\nwriter.newLine();\nwriter.write(text2);\nwriter.newLine();\nwriter.write(text3);\n```\nThe above code uses the `newLine` method to write a newline separator in the file.\n\n## Incorrect Answers\nThe following code snippet is **not correct** because there are no newline characters. All three strings would be on the same line.\n\n```java\nString text1 = \"Once upon a time\";\nString text2 = \"In a land far, far away\";\nString text3 = \"Lived a king and queen\";\nwriter.write(text1);\nwriter.write(text2);\nwriter.write(text3);\n```\n\nThe following code snippet is **not correct** because the `write` method takes just a string or a string and two integers. In the code below, three strings are passed to the `writer` method.\n\n```java\nString text1 = \"Once upon a time\\n\";\nString text2 = \"In a land far, far away\\n\";\nString text3 = \"Lived a king and queen\\n\";\nwriter.write(text1, text2, text3);\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -7672,7 +7943,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT write properly formatted text to a file" + "learningObjectives": "SWBAT write properly formatted text to a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7707,7 +7981,6 @@ } ], "guidance": "Remember, reading and writing to memory is much faster than reading or writing to disk. So using `BufferedWriter` will be faster than `FileWriter` because `BufferedWriter` writes to memory while `FileWriter` writes to disk.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -7742,7 +8015,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT explain why buffers are useful" + "learningObjectives": "SWBAT explain why buffers are useful", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7756,7 +8032,6 @@ "text": "<<>> to a file will erase its contents before adding the string.\n<<>> to a file will keep its contents and add the string at the end.", "distractors": "Adding\n", "guidance": "**Writing** to a file will overwrite it. That means all existing content will be replaced with the new content.\n**Appending** to a file keeps the existing content and adds the new content at the end of the file.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "arePartialPointsAllowed": true, @@ -7804,6 +8079,9 @@ " to a file will keep its contents and add the string at the end." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -7818,7 +8096,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\"}", "grader": "1", "guidance": "Here is the correct answer:\n\n```java\nString path = \"tongueTwister.txt\";\ntry {\n BufferedWriter writer = new BufferedWriter(new FileWriter(path));\n writer.write(\"Peter Piper picked a peck of pickled peppers\\n\");\n writer.write(\"A peck of pickled peppers Peter Piper picked\\n\");\n writer.write(\"If Peter Piper picked a peck of pickled peppers\\n\");\n writer.write(\"Where’s the peck of pickled peppers Peter Piper picked?\");\n writer.close();\n} catch (IOException e) {\n System.out.println(e);\n}\n```", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "metadata": { @@ -7844,7 +8121,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT demonstrate writing to a file" + "learningObjectives": "SWBAT demonstrate writing to a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7858,7 +8138,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "Here is the solution:\n\n```java\nString path = \"quotes.txt\";\ntry {\n BufferedWriter writer = new BufferedWriter(new FileWriter(path, true));\n String text = \"The time is always right to do what is right.\";\n writer.newLine();\n writer.write(text);\n writer.close();\n} catch (IOException e) {\n System.out.println(e);\n}\n```\n\nThere are two important ideas to keep in mind. One, you do not want to overwrite the file, so you need to append to the file. Be sure to select the `try` statement that has the Boolean `true`. Two, you want the quote to appear on its own line, so you need to call the `newLine` method before the `write` method.", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "metadata": { @@ -7884,7 +8163,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT append a string to a file" + "learningObjectives": "SWBAT append a string to a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7919,7 +8201,6 @@ } ], "guidance": "The correct answers are those where the `skip` method has an argument that is positive and less than 22 (the number of characters in the line). When the argument is greater than 22, Java will return text from the second line of the file. Java will return an error if the argument is negative.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -7955,7 +8236,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT use the skip method to ignore a set of characters when reading a file" + "learningObjectives": "SWBAT use the skip method to ignore a set of characters when reading a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -7990,7 +8274,6 @@ } ], "guidance": "The `readLine` method reads from the file until it comes across a newline character. The `read` method reads only one character at a time.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8025,7 +8308,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT define what the readLine method does" + "learningObjectives": "SWBAT define what the readLine method does", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8055,7 +8341,6 @@ } ], "guidance": "The correct answer is: \n\n```\nYou want to iteration until a condition is met (the end of the file) as opposed to iterating a specific number of times.\n```\n\nWe do not know how many lines of text there are in a file. A for loop is not a good choice because it runs a specified number of times. Instead, use a while loop to test for the end of the file. This way your loop runs the correct amount of iterations.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8090,7 +8375,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT explain why a while loop is preferable to a for loop when iterating over a file" + "learningObjectives": "SWBAT explain why a while loop is preferable to a for loop when iterating over a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8104,7 +8392,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The correct answer is:\n\n```java\ntry {\n BufferedReader reader = new BufferedReader(new FileReader(path));\n String line = reader.readLine();\n StringTokenizer tokens = new StringTokenizer(line, \" \");\n while (tokens.hasMoreTokens()) {\n System.out.println(tokens.nextToken());\n }\n} catch (IOException e) {\n System.out.println(e);\n}\n```\n\nThe method `hasMoreTokens` returns a Boolean value; so it should be used in the while loop. The `nextToken` method returns a string; so it should be used in the print statement.", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "metadata": { @@ -8138,7 +8425,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT create tokens from a string read from a file" + "learningObjectives": "SWBAT create tokens from a string read from a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8152,7 +8442,6 @@ "text": "In **Code Example 1**, Java reads from the file stored in the variable <<>> and writes to file stored in variable <<>>.\n\nIn **Code Example 2**, Java reads from the file stored in the variable <<>> and writes to file stored in variable <<>>.", "distractors": "", "guidance": "In the first example, Java is reading from `myFile1.txt` and writing to `myFile2.txt`.\nIn the second example, Java is reading from `myFile4.txt` and writing to `myFile3.txt`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "arePartialPointsAllowed": true, @@ -8207,6 +8496,9 @@ "." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -8221,7 +8513,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The correct answer is:\n\n```java\nBufferedReader reader = new BufferedReader(new FileReader(path));\nwhile(reader.ready()) {\n System.out.println(reader.readLine());\n}\nreader.close();\n```\n\nYou do not use the `BufferedWriter` class when reading a document.", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "metadata": { @@ -8247,7 +8538,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT print each line of a text file" + "learningObjectives": "SWBAT print each line of a text file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8261,7 +8555,6 @@ "text": "```java\nBufferedReader reader = new BufferedReader(new FileReader(path));\nString <<>> = reader.readLine();\nwhile(currentLine <<>> null) {\n System.out.println(<<>>);\n currentLine = reader.<<>>;\n}\nreader.close();\n```", "distractors": "==\nread()\nline", "guidance": "The correct answer is:\n\n```java\nBufferedReader reader = new BufferedReader(new FileReader(path));\nString currentLine = reader.readLine();\nwhile(currentLine != null) {\n System.out.println(currentLine);\n currentLine = reader.readLine();\n}\nreader.close();\n```\n\n* You do not use `==` because `null` means you have reached the end of the file. You should keep reading as long as you have not reached the end of the file. Use `!=` instead.\n* You do not use `read()` because this only reads one character at a time. It would not output the text as you would expect.\n* You do not use `line` because this variable name is not used in the given code.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "arePartialPointsAllowed": true, @@ -8308,6 +8601,9 @@ ";\n}\nreader.close();\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -8343,7 +8639,6 @@ } ], "guidance": "The correct answer is:\n\n```java\nCSVReader reader = new CSVReader(new FileReader(path));\n```\n\n* The `BufferedReader` class is not used when working with CSV files\n* The `CSVReader` class is wrapped around a `Filewriter` object", - "showGuidanceAfterResponse": false, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8379,7 +8674,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT declare a CSVReader object" + "learningObjectives": "SWBAT declare a CSVReader object", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -8414,7 +8712,6 @@ } ], "guidance": "Once a CSV has been read, each row is stored as an array of strings. So manipulating CSV information is based on working with arrays (indexing, slicing, methods, functions, etc.) and working with strings (printing, methods, etc.).", - "showGuidanceAfterResponse": false, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8450,7 +8747,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT identify how CSV data is stored once it has been read" + "learningObjectives": "SWBAT identify how CSV data is stored once it has been read", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -8485,7 +8785,6 @@ } ], "guidance": "A delimiter is a character that separates units of data. In a CSV file, the default delimiter is a comma. Here is an example of a file with a comma delimiter:\n\nName,Breed\nBear,German Shepherd\nRoxy,Black Lab\nBella,Yorkie\nLucky,Terrier", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8521,7 +8820,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT define a delimiter" + "learningObjectives": "SWBAT define a delimiter", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8535,7 +8837,6 @@ "text": "The <<>> object is used to read a CSV file.\nThe <<>> object is used to write to a CSV file.", "distractors": "BufferedReader\nBufferedWriter", "guidance": "The `CSVReader` object is used to read CSV files, while the `CSVWriter` object is used to write to a CSV file. The `BufferedReader` and `BufferedWriter` objects are used to read and write to text files.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "arePartialPointsAllowed": true, @@ -8584,6 +8885,9 @@ " object is used to write to a CSV file." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -8598,7 +8902,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The correct answer is:\n\n```java\nCSVReader reader = new CSVReader(new FileReader(path));\nfor (String[] row : reader) {\n for (String item : row) {\n System.out.print(item + \" \");\n }\n System.out.println();\n}\n```\n\n* Use a `CSVReader` object when reading a CSV file, which is why `BufferedReader` is incorrect.\n* Each row read from the file is an array of strings which is why `String row` is incorrect. \n* We want to print each row as it appears in the CSV file. That means each element in the array `row` should be printed on the same line. That is why `System.out.println(item + \" \");` is incorrect.", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "metadata": { @@ -8632,7 +8935,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT iterate over a CSV and print each row" + "learningObjectives": "SWBAT iterate over a CSV and print each row", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8667,7 +8973,6 @@ } ], "guidance": "The correct answer is:\n\n```java\nrow.split(\"|\")\n```\n\n* The method is `split`, which is why `separate` is incorrect\n* The `split` method splits a string based on a string not a character, which is why `'|'` is incorrect\n* The string to be split is `row`, which is why `line` is incorrect", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8703,7 +9008,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT to parse a CSV file with a delimiter that is not a comma" + "learningObjectives": "SWBAT to parse a CSV file with a delimiter that is not a comma", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8738,7 +9046,6 @@ } ], "guidance": "The variable `text` is an ArrayList of strings. If you print `text`, it will print the entirety of the list — including square brackets. Printing `text.get(0)` will print just the first element in the ArrayList, no square brackets. If you want the text, print the string inside the list, not the list itself.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8774,7 +9081,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT demonstrate how to read the contents of a file into a variable and then manipulate the text in the variable" + "learningObjectives": "SWBAT demonstrate how to read the contents of a file into a variable and then manipulate the text in the variable", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8809,7 +9119,6 @@ } ], "guidance": "The correct answer is:\n\n```java\nBufferedWriter writer = new BufferedWriter(new FileWriter(path, true));\n```\n\nThe boolean value `true` is used after the file path in the `FileWriter` object.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8845,7 +9154,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT demonstrate how to append to a text file" + "learningObjectives": "SWBAT demonstrate how to append to a text file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8859,7 +9171,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The correct answer is:\n\n```java\nStringTokenizer tokens = new StringTokenizer(line, \" \");\nwhile (tokens.hasMoreTokens()) {\n System.out.println(tokens.nextToken());\n}\n```\n\n* The `StringTokenizer` object uses the `hasMoreTokens` method, not the `ready` method.\n* The `StringTokenizer` object uses the `nextToken` method to get the next token, not the `token` method.\n* The `StringTokenizer` object uses the literal string `\" \"` instead of the word `space` to represent a space.", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "metadata": { @@ -8898,7 +9209,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT create tokens from a string read from a file" + "learningObjectives": "SWBAT create tokens from a string read from a file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8928,7 +9242,6 @@ } ], "guidance": "When you read line from a text file, Java will read up until the newline character. The newly read line does not include the newline character. So when you write the same line to a new file, you need to add a newline character to preserve the original format.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -8964,7 +9277,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT explain why it is important to manually new lines when writing to a file." + "learningObjectives": "SWBAT explain why it is important to manually new lines when writing to a file.", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -8978,7 +9294,6 @@ "arePartialPointsAllowed": false, "timeoutSeconds": 40, "guidance": "", - "showGuidanceAfterResponse": false, "points": 20, "oneTimeTest": false, "metadata": { @@ -9000,7 +9315,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -9012,36 +9330,38 @@ "instructions": "Submit your code when ready", "command": "java -cp code/files LabChallenge", "preExecuteCommand": "javac code/files/LabChallenge.java", - "guidance": "Here is one possible solution:\n\n```java\nimport java.io.*;\nimport java.util.ArrayList;\n\npublic class LabChallenge {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line\n \n ArrayList text = new ArrayList();\n try {\n BufferedReader reader = new BufferedReader(new FileReader(path));\n while (reader.ready()) {\n text.add(reader.readLine());\n }\n reader.close();\n } catch (IOException e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a file.\\n\");\n }\n for (String line : text) {\n String replaceLine = line.replace(\"Burma\", \"Myanmar\");\n System.out.println(replaceLine);\n }\n \n //add code above this line \n }\n}\n```\n\nThis solution performs the following steps:\n* Create an ArrayList\n* Iterate over the text file\n* Read a line from the text file and append it to the ArrayList\n* Once the file has been read, iterate over the elements in the ArrayList\n* Use the `replace` method to replace the word `Burma` with `Myanmar`\n* Print this new line", - "showGuidanceAfterResponse": true, - "points": 20, - "oneTimeTest": true, "options": { + "timeout": 30, "ignoreCase": true, "ignoreWhitespaces": true, "ignoreNewline": true, - "matchSubstring": true, - "timeout": 30 + "matchSubstring": true }, + "guidance": "Here is one possible solution:\n\n```java\nimport java.io.*;\nimport java.util.ArrayList;\n\npublic class LabChallenge {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line\n \n ArrayList text = new ArrayList();\n try {\n BufferedReader reader = new BufferedReader(new FileReader(path));\n while (reader.ready()) {\n text.add(reader.readLine());\n }\n reader.close();\n } catch (IOException e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a file.\\n\");\n }\n for (String line : text) {\n String replaceLine = line.replace(\"Burma\", \"Myanmar\");\n System.out.println(replaceLine);\n }\n \n //add code above this line \n }\n}\n```\n\nThis solution performs the following steps:\n* Create an ArrayList\n* Iterate over the text file\n* Read a line from the text file and append it to the ArrayList\n* Once the file has been read, iterate over the elements in the ArrayList\n* Use the `replace` method to replace the word `Burma` with `Myanmar`\n* Print this new line", + "showGuidanceAfterResponseOption": { + "type": "Always" + }, + "maxAttemptsCount": 1, + "points": 20, "showExpectedAnswer": true, "arePartialPointsAllowed": true, "sequence": [ { - "arguments": ".guides/secure/files/labChallengeText1.txt", + "arguments": ".guides/lab-files/labChallengeText1.txt", "input": "", "output": "My name is Myanmar.\nMyanmar is 10 years old.\nHello Myanmar.", "showFeedback": false, "feedback": "" }, { - "arguments": ".guides/secure/files/labChallengeText2.txt", + "arguments": ".guides/lab-files/labChallengeText2.txt", "input": "", "output": "Nothing left to do but Myanmar, Myanmar, Myanmar.\nMyanmar gone and he ain't never coming back.\nDark Myanmar rising.", "showFeedback": false, "feedback": "" }, { - "arguments": ".guides/secure/files/labChallengeText3.txt", + "arguments": ".guides/lab-files/labChallengeText3.txt", "input": "", "output": "Take me out to the Myanmar\nBuy me some Myanmar and Myanmar\nRoot, root for the Myanmar", "showFeedback": false, @@ -9056,7 +9376,10 @@ } ], "files": [ - "code/files/LabChallenge.java" + "code/files/LabChallenge.java", + ".guides/secure/files/labChallengeText1.txt", + ".guides/secure/files/labChallengeText2.txt", + ".guides/secure/files/labChallengeText3.txt" ], "opened": [ { @@ -9080,7 +9403,6 @@ "command": "java -cp code/files Exercise1", "preExecuteCommand": "javac code/files/Exercise1.java", "guidance": "Here is one possible solution:\n\n```java\nimport java.io.*;\n\npublic class Exercise1 {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line\n try {\n BufferedReader reader = new BufferedReader(new FileReader(path));\n int lineCount = 0;\n int characterCount = 0;\n while (reader.ready()) {\n String line = reader.readLine();\n lineCount++;\n characterCount += line.length();\n }\n System.out.println(String.valueOf(lineCount) + \" lines\");\n System.out.println(String.valueOf(characterCount) + \" characters\");\n reader.close();\n } catch (IOException e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a file.\\n\");\n }\n //add code above this line \n }\n}\n```\n\nThis program takes the following steps:\n* Open the file in a `BufferedReader` objects\n* Initialize variables to count the lines and the characters\n* Iterate over the text file\n* Read a line from the file\n* Increment the line counting variable by 1\n* Increment the character counting variable by the length of the line read\n* After the loop runs, print the results", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "options": { @@ -9146,7 +9468,10 @@ ] }, "bloomsObjectiveLevel": "6", - "learningObjectives": "SWBAT read from a text file, count the number of lines of text and the number of characters" + "learningObjectives": "SWBAT read from a text file, count the number of lines of text and the number of characters", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9159,7 +9484,6 @@ "command": "sh .guides/csv.sh Exercise2", "preExecuteCommand": "", "guidance": "Here is one potential solution:\n\n```java\nimport java.io.*;\nimport com.opencsv.*;\nimport org.apache.commons.lang3.ObjectUtils;\n\npublic class Exercise2 {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line\n try {\n CSVReader reader = new CSVReader(new FileReader(path));\n double column0 = 0.0;\n double column1 = 0.0;\n double column2 = 0.0;\n double column3 = 0.0;\n int rows = 0;\n \n for (String[] row : reader) {\n rows++;\n for (int i = 0; i < 4; i++) {\n if (i == 0) {\n column0 += Float.parseFloat(row[i]);\n } else if (i == 1) {\n column1 += Float.parseFloat(row[i]);\n } else if (i == 2) {\n column2 += Float.parseFloat(row[i]);\n } else if (i == 3) {\n column3 += Float.parseFloat(row[i]);\n }\n }\n }\n System.out.print(String.valueOf(column0/rows) + \" \");\n System.out.print(String.valueOf(column1/rows) + \" \");\n System.out.print(String.valueOf(column2/rows) + \" \");\n System.out.println(column3/rows);\n \n reader.close();\n } catch (Exception e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a CSV\");\n } \n //add code above this line \n }\n}\n```\n\nThis program does the following things:\n* Create a `CSVReader` object with the `path` variable\n* Create variables for the total values for each of the four columns in the CSV file\n* Create a variable for the number of rows in the CSV file\n* Iterate over the CSV file; for each row increment the row variable\n* Each row in the CSV is an array of strings, iterate over this array\n* Add the floating point value for each element to its respective column variable\n* After iterating over the CSV file, print the average value for each column", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "options": { @@ -9225,7 +9549,10 @@ ] }, "bloomsObjectiveLevel": "6", - "learningObjectives": "SWBAT read a CSV file and find the average for each column in the file" + "learningObjectives": "SWBAT read a CSV file and find the average for each column in the file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9238,7 +9565,6 @@ "command": "java -cp code/files Exercise3", "preExecuteCommand": "javac code/files/Exercise3.java", "guidance": "Here is one potential solution:\n\n```java\nimport java.io.*;\nimport java.util.ArrayList;\n\npublic class Exercise3 {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line\n ArrayList text = new ArrayList();\n try {\n BufferedReader reader = new BufferedReader(new FileReader(path));\n while (reader.ready()) {\n text.add(reader.readLine());\n }\n reader.close();\n } catch (IOException e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a file.\\n\");\n } \n for (int i = text.size() - 1; i >= 0; i--) {\n System.out.println(text.get(i));\n } \n //add code above this line \n }\n}\n```\n\nThe program does the following things:\n* ", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "options": { @@ -9292,7 +9618,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9305,7 +9634,6 @@ "command": "java -cp code/files Exercise4", "preExecuteCommand": "javac code/files/Exercise4.java", "guidance": "Here is one possible solution:\n\n```java\nimport java.io.*;\n\npublic class Exercise4 {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line \n try {\n BufferedReader reader = new BufferedReader(new FileReader(path));\n String delimiter = \"\\t\";\n int oldestAge = 0;\n String oldestName = \"\";\n while(reader.ready()) {\n String line = reader.readLine();\n String[] tokens = line.split(delimiter);\n if (Integer.parseInt(tokens[1]) > oldestAge) {\n oldestAge = Integer.parseInt(tokens[1]);\n oldestName = tokens[0];\n }\n }\n System.out.println(\"The oldest person is \" + oldestName + \".\");\n reader.close();\n } catch (IOException e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a CSV\");\n }\n //add code above this line \n }\n}\n```\n\nThe program does the following things:\n* This problem uses a tab (`\\t`) for the delimiter, so use a `BufferedReader` object instead of a `CSVReader` object\n* Create variables to keep track of the oldest age (`oldestAge`) and oldest name (`oldestName`); set `oldestAge` to 0\n* Iterate over the CSV file\n* Use the `split` method and a tab to create tokens from each row in the CSV\n* Compare the second element in each row to the oldest age\n* If the number in the CSV file is greater than `oldestAge`, store the number from the CSV in the variable\n* Set `oldestName` to the name from CSV file\n* After the loop runs, print out the name of the person who is the oldest", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "options": { @@ -9371,7 +9699,10 @@ ] }, "bloomsObjectiveLevel": "6", - "learningObjectives": "SWBAT read a tab delimited CSV file and print the oldest person in the file" + "learningObjectives": "SWBAT read a tab delimited CSV file and print the oldest person in the file", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9384,7 +9715,6 @@ "command": "sh .guides/csv.sh Exercise5", "preExecuteCommand": "", "guidance": "Here is one possible solution:\n\n```java\nimport java.io.*;\nimport com.opencsv.*;\nimport org.apache.commons.lang3.ObjectUtils;\nimport java.util.ArrayList;\n\npublic class Exercise5 {\n public static void main(String args[]) {\n \n String path = args[0];\n //add code below this line\n ArrayList cities = new ArrayList();\n try {\n CSVReader reader = new CSVReader(new FileReader(path));\n reader.skip(1);\n for (String[] row : reader) {\n if (Integer.parseInt(row[2]) < 0) {\n cities.add(row[0]);\n }\n }\n System.out.print(\"The following cities are in the Southern Hemisphere: \");\n for (String city : cities) {\n int lastCity = cities.size() - 1;\n if (city.equals(cities.get(lastCity))) {\n System.out.println(city + \".\");\n } else {\n System.out.print(city + \", \");\n }\n }\n reader.close();\n } catch (Exception e) {\n System.out.println(e);\n } finally {\n System.out.println(\"Finished reading a CSV\");\n }\n //add code above this line \n }\n}\n```\n\nThe program does the following things:\n* Create an ArrayList for the cities in the Southern Hemisphere\n* Read over the CSV file and skip the header row\n* Iterate over the CSV file\n* If the latitude is less than 0, add the city to the ArrayList\n* Use `print` to print the text `\"The following cities are in the Southern Hemisphere: \"`\n* Calculate the last index of the ArrayList\n* Iterate over the ArrayList\n* If it is the last city, use `println` to print the city name and a period\n* If not the last city, use `print` to print the city name followed by a comma and a space", - "showGuidanceAfterResponse": true, "points": 20, "oneTimeTest": true, "options": { @@ -9450,7 +9780,10 @@ ] }, "bloomsObjectiveLevel": "6", - "learningObjectives": "SWBAT read a CSV and print out relevant information" + "learningObjectives": "SWBAT read a CSV and print out relevant information", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9485,7 +9818,6 @@ } ], "guidance": "", - "showGuidanceAfterResponse": false, "showExpectedAnswer": true, "points": 20, "incorrectPoints": 0, @@ -9515,7 +9847,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -9528,7 +9863,6 @@ "command": "python3 .guides/secure/partial_points_test.py", "timeoutSeconds": 40, "guidance": "", - "showGuidanceAfterResponse": false, "arePartialPointsAllowed": false, "oneTimeTest": false, "previewType": "NONE", @@ -9558,7 +9892,10 @@ ] }, "bloomsObjectiveLevel": "", - "learningObjectives": "" + "learningObjectives": "", + "showGuidanceAfterResponseOption": { + "type": "Never" + } } }, { @@ -9572,7 +9909,6 @@ "text": "* <<>> - Determines the visibility of the method.\n* <<>> - Determines the association of the method.\n* <<>> - Determines the return value of the method.\n* <<>> - Are optional and go within the parentheses following the method name.", "distractors": "", "guidance": "Generally speaking, methods typically start with the following keywords: `public`, `static`, and `void`. These determine the visibility, association, and return value of the method respectively. Then the name of the method is declared followed by parentheses. Within the parentheses are the **parameters**, which are optional.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -9621,6 +9957,9 @@ " - Are optional and go within the parentheses following the method name." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -9656,7 +9995,6 @@ } ], "guidance": "Though `System.out.println(\"Thanks\");` will print what the method is defined to do, doing so is not the correct way to call a method. To call a method, you need to specify the method's name, followed by parentheses, followed by parameters if any are required. Notice that the method has no parameters, so `sayThanks();` is the correct way to call the method.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -9692,7 +10030,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT successfully call a method" + "learningObjectives": "SWBAT successfully call a method", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9706,7 +10047,6 @@ "text": "* Specifies any parameters that are used within the method: <<<@param>>>\n* Specifies any values that are returned from the method: <<<@return>>>\n* Specifies the names of those who wrote or developed the method: <<<@author>>>\n* Specifies what version the method is currently on: <<<@version>>>", "distractors": "", "guidance": "The four most commonly used Java documentation code are: `@param`, `@return`, `@author`, and `@version`. These correspond to what parameters the method uses, what values the method returns, who wrote the method, and what version the method is on respectively.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -9760,6 +10100,9 @@ 0 ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -9774,7 +10117,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "Some methods start with `public static void` but all methods will include the name of the method, followed by parentheses, followed by any optional parameter(s) within those parentheses. Since `printActor()` is a method and not a parameter, `public static void main(printActors)` cannot be the correct choice. \n\nGiven these rules, only `public static void printActors()` is suitable as a method. Within the body of this method, we want the names of the actors to be printed in this order: `Ben Affleck`, then `Kevin Bacon`, and finally `George Clooney`. To do so, simply include the print statements for all of the names **with** a newline.\n\n**Solution:**\n```java\npublic static void printActors() {\n System.out.println(\"Ben Affleck\");\n System.out.println(\"Kevin Bacon\");\n System.out.println(\"George Clooney\");\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -9802,7 +10144,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT put together a simple method" + "learningObjectives": "SWBAT put together a simple method", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -9816,7 +10161,6 @@ "text": "```java\n<<>>\n * This method prints the message \"This is my method\"\n * \n * <<<@author>>> FirstName LastName\n * <<<@version>>> 2.0\n <<<*/>>>\npublic static void myMethod<<<()>>> {\n System.out.println(\"This is my method\");\n}\n```", "distractors": "", "guidance": "* The first blank is the beginning of a JavaDoc. JavaDocs always start with `/**`.\n* The second blank talks about `FirstName` and `LastName` which represents the author; `@author` is the solution.\n* The third blank has a decimal after it which represents a version number; `@version` is the solution.\n* The fourth blank is the end of the JavaDoc. JavaDocs always end with `*/`.\n* Finally, the method header needs to have parentheses `()` following the method name.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -9866,6 +10210,9 @@ " {\n System.out.println(\"This is my method\");\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -9880,7 +10227,6 @@ "text": "The argument for `z` is <<<4>>>.\nThe argument for `y` is <<<5>>>.\nThe argument for `x` is <<<2>>>.", "distractors": "", "guidance": "Java reads the arguments from left to right and matches those to the parameters from left to right as well. Thus, `x` will become `2`, `y` will become `5`, and `z` will become `4`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -9932,6 +10278,9 @@ "." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -9967,7 +10316,6 @@ } ], "guidance": "The `try catch` block can be used to catch exceptions. It cannot be used to catch compilation errors, which is the job of the compiler itself.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -10003,7 +10351,10 @@ ] }, "bloomsObjectiveLevel": "1", - "learningObjectives": "SWBAT determine the usage of a try catch block" + "learningObjectives": "SWBAT determine the usage of a try catch block", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10017,7 +10368,6 @@ "text": "```java\npublic static void myMethod(<<>> x, int <<>>) {\n System.out.println(x + y);\n}\n\npublic static void main(String args[]) {\n myMethod(<<<\"High\">>>, <<<5>>>);\n}\n```", "distractors": "", "guidance": "The output that we are looking for is `High5`. We know that there are two parameters and one of them is an `int`. Thus, the other parameter must be a `String` with the value of `\"High\"`. This leaves the previous variable to be `5`.\n\n**Solution:**\n```java\npublic static void myMethod(String x, int y) {\n System.out.println(x + y);\n}\n\npublic static void main(String args[]) {\n myMethod(\"High\", 5);\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -10072,6 +10422,9 @@ ");\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -10086,7 +10439,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\"}", "grader": "1", "guidance": "First, the method needs to be defined. The only method available other than `main()` is `public static void printArrayList(ArrayList arrayList)`. To print the ArrayList, you will need a `for` loop, thus `for (String s : arrayList)` comes next. Lastly, to print the elements, simply use `System.out.println(s)`.\n\nFor the `main()` method, an ArrayList needs to be created before elements can be added. This means `ArrayList names = new ArrayList()` and `names.add(\"Alan\")` are needed respectively. Finally, to call the method and provide an ArrayList as an argument, use `printArrayList(names)`.\n\n**Solution:**\n```java\npublic static void printArrayList(ArrayList arrayList) {\n for (String s : arrayList) {\n System.out.println(s);\n }\n}\npublic static void main(String args[]) {\n ArrayList names = new ArrayList();\n names.add(\"Alan\");\n printArrayList(names);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -10120,7 +10472,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT define a method and call it in main()" + "learningObjectives": "SWBAT define a method and call it in main()", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10155,7 +10510,6 @@ } ], "guidance": "The parameters' order matters. According to the method, two integers and then a String are needed respectively. Only the arguments `5, 10, \"15\"` follow the specified parameter types `int, int, String`.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -10191,7 +10545,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT determine appropriate arguments for specified parameters" + "learningObjectives": "SWBAT determine appropriate arguments for specified parameters", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10205,7 +10562,6 @@ "text": "```java\npublic static void findCircumference(<<>> diameter) {\n System.out.println(<<>> * 3.14);\n}\n\npublic static void main(String args[]) {\n <<>>(2.2);\n}\n```", "distractors": "", "guidance": "To specify a **double** as a parameter, simply use `double`. To print the circumference, multiply the `diameter` by `3.14` within the print statement. To call the method, use the method's name `findCircumference()`.\n\n**Solution:**\n```java\npublic static void findCircumference(double diameter) {\n System.out.println(diameter * 3.14);\n}\n\npublic static void main(String args[]) {\n findCircumference(2.2);\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -10249,6 +10605,9 @@ "(2.2);\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -10263,7 +10622,6 @@ "text": "<<>> declared inside a method have <<>> scope. This means you can only reference the variable from <<>> the method. Trying to reference the variable from <<>> the method will cause an error.", "distractors": "", "guidance": "Variables used within a particular method are said to be **local** to that method alone. Other methods cannot access that variable. An attempt to do so will result in an error signaling that the variable cannot be found.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -10317,6 +10675,9 @@ " the method will cause an error." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -10352,7 +10713,6 @@ } ], "guidance": "If you go through each variable, you'll notice that only variable `a` is not contained within a method. This is the most telling sign that it is a **global** variable. `b`, on the other hand, is a parameter, and c and d are local variables.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -10388,7 +10748,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT distinguish between global and local variables" + "learningObjectives": "SWBAT distinguish between global and local variables", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10402,7 +10765,6 @@ "text": "If a variable is declared and initialized both globally and locally, that variable will <<>> its value depending on its <<>>.\n\nIf a global variable is modified by a method, it will <<>> its <<>> value and take on its <<>> value instead.\n\nVariables that are **final** are also known as <<>> and cannot be <<>> after initialization.", "distractors": "", "guidance": "In Java, declared global and local variables are considered separate. The only exception is if a method modifies a global variable locally. In such a case, the global value is lost and the local value is gained. Lastly, constants are **final** because they cannot be altered after they are declared and initialized.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -10466,6 +10828,9 @@ " after initialization." ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -10480,7 +10845,6 @@ "text": "```java\nstatic <<>> int MIN_AGE = 18;\n\npublic <<>> void isEligible(<<>> age) {\n if (age >= <<>>) {\n System.out.println(\"Eligible\");\n }\n else {\n System.out.println(\"Not eligible\");\n }\n}\n```", "distractors": "", "guidance": "Remember that constants cannot be modified and are denoted in all uppercase and underscores along with being declared as `final`. The constant here is `MIN_AGE` and it is being used in comparison with the integer parameter `age`. The method can only access the constant if it is `static`. If `age` is greater than or equal to the constant, then the voter is eligible. If not, then the voter is not eligible.\n\n**Solution:**\n```java\nstatic final int MIN_AGE = 18;\n\npublic static void isEligible(int age) {\n if (age >= MIN_AGE) {\n System.out.println(\"Eligible\");\n }\n else {\n System.out.println(\"Not eligible\");\n }\n}\n```", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "arePartialPointsAllowed": false, @@ -10529,6 +10893,9 @@ ") {\n System.out.println(\"Eligible\");\n }\n else {\n System.out.println(\"Not eligible\");\n }\n}\n```" ], "regexPositions": [] + }, + "showGuidanceAfterResponseOption": { + "type": "Always" } } }, @@ -10543,7 +10910,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The first thing to notice is that `grade` is an `int` because it is being compared to the integer `65`. Remember that we want `< 65`, not `<= 65`. Since `result` is being modified to `\"fail\"`, all you need is the assignment operator `=`. Using `String result = \"fail\";` will create a local variable, which we do not want. Then all that's left is to print `result`.\n\n**Solution:**\n```java\npublic static void passFail(int grade) {\n if (grade < 65) {\n result = \"fail\";\n }\n System.out.println(result);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -10569,7 +10935,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT modify a global variable within a local scope" + "learningObjectives": "SWBAT modify a global variable within a local scope", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10604,7 +10973,6 @@ } ], "guidance": "The return type is specified in every method header, usually behind the `static` or `public` keyword. In this case, the return type is `int[]` which represents an integer array. Note that `numbers` is a representation for the integer array. It is **not** an actual data type.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -10640,7 +11008,10 @@ ] }, "bloomsObjectiveLevel": "2", - "learningObjectives": "SWBAT determine a method's return type" + "learningObjectives": "SWBAT determine a method's return type", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10675,7 +11046,6 @@ } ], "guidance": "If you follow the program, you'll notice that the `getBaseHeight()` method is returned within the `getTriangleArea()` method. In other words, `getBaseHeight()` helps `getTriangleArea()` perform a particular task. This makes `getBaseHeight()` function as a helper method. `String args[]` is a parameter and `void` is a return type; neither are actually methods.", - "showGuidanceAfterResponse": true, "showExpectedAnswer": true, "points": 1, "incorrectPoints": 0, @@ -10711,7 +11081,10 @@ ] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT determine helper methods within programs" + "learningObjectives": "SWBAT determine helper methods within programs", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10725,7 +11098,6 @@ "options": "{\"sortableId\":\"sortable\",\"max_wrong_lines\":10,\"exec_limit\":2500,\"can_indent\":true,\"x_indent\":50,\"lang\":\"en\",\"trashId\":\"sortableTrash\"}", "grader": "1", "guidance": "The first step is to determine the return value of the method. The problem asks for a **boolean** return value, therefore the method header should be `public static boolean passes(int grade)`. Note how the parameter is an **int** since the method requires an integer. Next, the boolean statement needs to be returned as **true** if the `grade` is **greater than or equal to** `65`. Rather than using a conditional, we can simply return a boolean expression: `return (grade >= 65);`.\n\n**Solution:**\n```java\npublic static boolean passes(int grade) {\n return (grade >= 65);\n}\n```", - "showGuidanceAfterResponse": true, "points": 1, "oneTimeTest": true, "metadata": { @@ -10753,7 +11125,10 @@ "opened": [] }, "bloomsObjectiveLevel": "3", - "learningObjectives": "SWBAT return a boolean method" + "learningObjectives": "SWBAT return a boolean method", + "showGuidanceAfterResponseOption": { + "type": "Always" + } } }, { @@ -10767,7 +11142,6 @@ "text": "```java\npublic static <<>> findPositionChange(double pStart, double pFinal) {\n double pChange = <<>> - <<>>;\n return <<>>;\n}\n\npublic static double findVelocity(double pStart, double <<>>, double time) {\n return <<>>(pStart, pFinal) / <<