From 295e4fd9606e7c03a9dabaed3631262f3d382ea9 Mon Sep 17 00:00:00 2001 From: xinyinghou Date: Sun, 24 Aug 2025 21:32:49 +0000 Subject: [PATCH 1/3] Added a new section CodeTailorTest with four test questions --- _sources/CodeTailorTest/index.rst | 73 ++++++++++++ .../java_multi_level_per_puzzle.rst | 102 ++++++++++++++++ .../java_solution_per_puzzle.rst | 106 +++++++++++++++++ .../CodeTailorTest/multi_level_per_puzzle.rst | 96 +++++++++++++++ .../CodeTailorTest/solution_per_puzzle.rst | 112 ++++++++++++++++++ 5 files changed, 489 insertions(+) create mode 100644 _sources/CodeTailorTest/index.rst create mode 100644 _sources/CodeTailorTest/java_multi_level_per_puzzle.rst create mode 100644 _sources/CodeTailorTest/java_solution_per_puzzle.rst create mode 100644 _sources/CodeTailorTest/multi_level_per_puzzle.rst create mode 100644 _sources/CodeTailorTest/solution_per_puzzle.rst diff --git a/_sources/CodeTailorTest/index.rst b/_sources/CodeTailorTest/index.rst new file mode 100644 index 0000000..35d7c40 --- /dev/null +++ b/_sources/CodeTailorTest/index.rst @@ -0,0 +1,73 @@ +💻 CodeTailor: Pop-up a mixed-up puzzle to help while writing code +======================================================================= + +The primary goal is to complete the write-code problem, with the optional puzzle providing guidance and hints. + + +1️⃣ Get Help +^^^^^^^^^^^^ +Click the **"Get Help"** button below the problem description to access a mixed-up puzzle that will guide you through solving the write-code task. +The puzzle presents essential code snippets and logic in a scrambled order. + +2️⃣ Close Help +^^^^^^^^^^^^^^^ +Click this button to close the help view and return to the main problem. + +3️⃣ See Help Again +^^^^^^^^^^^^^^^^^^ +Reopen the help puzzle anytime by clicking this button. + + +.. image:: https://i.postimg.cc/pr7q6PBs/help-puzzle-OP.gif + :width: 800px + :align: center + + +4️⃣ 'Help me' Button – Additional Assistance in Mixed-up Puzzle +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +After solving (checking) the puzzle three times using the required number of blocks + +If you have **more than three blocks** remaining in the answering area, you can unlock the "Help me" feature in the puzzle. + +Each click will **merge** two blocks into one, reducing the number of blocks needed for consideration. + + +5️⃣ Copy Answer to Clipboard +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +After generating a correct solution within the puzzle, you can copy the completed code to your clipboard and paste it into the write-code editor. + + +.. image:: https://i.postimg.cc/T37NL8F2/help-puzzle-OP-copy-answer.gif + :width: 800px + :align: center + + +🪄 Examples - Try the "Get Help" button by yourself +==================================================== + +Starting from the next section, you will interact with three different types of puzzles as scaffolding in both java and python. + +Provide a Solution-only Personalized Adaptive Puzzle + +Provide a Block-and-Solution Personalized Adaptive Puzzle + + + +What to do next +^^^^^^^^^^^^^^^ + +.. raw:: html + +

Click on the following link to try: A Solution-only Personalized Adaptive Puzzle

+ +.. raw:: html + + \ No newline at end of file diff --git a/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst b/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst new file mode 100644 index 0000000..e57e538 --- /dev/null +++ b/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst @@ -0,0 +1,102 @@ + +🪄 CodeTailor Examples - Try the "Get Help" button +=================================================== + +Provide a Block-and-Solution Personalized Adaptive Puzzle +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This type provides a **block-and-solution personalized adaptive puzzle** based on students' current written code. + +The students can interact with the puzzle and try to solve it. + +The students can regerenate the puzzle based on their updated code anytime by clicking the "Regerenate Help" button. + +:Movable Blocks: + Move the correct blocks from the left box to the right box and put them into the correct order. + +:Static Blocks: + - The Static blocks are the blocks that are already in position in the answer box. You can not move them. + - You can hover over the static blocks to see how many blocks are needed above and below them. + +:Paired Block Sets: + - Pairs with a correct block and an incorrect block that is not needed in a correct solution. + - Use students' own wrong code as distractor blocks. + - The incorrect blocks may contain syntactic or semantic errors. + - The correct code is randomly shown above or below the incorrect block. + + +.. activecode:: has22-example-multiper-java + :language: java + :autograde: unittest + :parsonspersonalize: partial + + Create a method ``has22(nums)`` that takes an array of integers, ``nums`` and returns ``true`` if there are at least two items in the list that are adjacent and both equal to 2, otherwise return false. + + .. table:: + :name: phrase_table_solcode + :align: left + :width: 50 + + +-------------------------------------+-------------------------------+ + | Example Input | Expected Output | + +=====================================+===============================+ + | ``has22({1, 2, 2})`` | ``true`` | + +-------------------------------------+-------------------------------+ + | ``has22({1, 2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + | ``has22({2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + + + + ~~~~ + import java.util.Scanner; + import java.util.Arrays; + + public class Has22 { + public static boolean has22(int nums) { + for (int i = 0; i < nums.length - 1; i++) { + + + + + + ==== + import static org.junit.Assert.*; + import org.junit.Test; + + class TestHelper { + public static void runAllTests() throws Exception { + if (!Has22.has22(new int[]{1, 2, 2, 3})) { + throw new Exception("Test 1 failed"); + } + if (Has22.has22(new int[]{2, 3, 2})) { + throw new Exception("Test 2 failed"); + } + if (Has22.has22(new int[]{1, 3, 4, 5})) { + throw new Exception("Test 3 failed"); + } + } + } + + + public class RunestoneTests { + @Test + public void testPhrase() throws Exception { + try { + TestHelper.runAllTests(); + System.out.println("✅ All tests passed!"); + System.out.println("Test 1: phrase(\"Sam\", \"Likes to code\") -> Sam likes to code"); + System.out.println("Test 2: phrase(123, \"code\") -> null"); + System.out.println("Test 3: phrase(\"JANE\", \"Loves JAVA\") -> Jane loves java"); + } catch (Exception e) { + System.out.println("❌ " + e.getMessage()); + fail(e.getMessage()); + } + } + } + + + +Thanks for trying CodeTailor! 🎉 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \ No newline at end of file diff --git a/_sources/CodeTailorTest/java_solution_per_puzzle.rst b/_sources/CodeTailorTest/java_solution_per_puzzle.rst new file mode 100644 index 0000000..6be8be3 --- /dev/null +++ b/_sources/CodeTailorTest/java_solution_per_puzzle.rst @@ -0,0 +1,106 @@ + +🪄 CodeTailor Examples - Try the "Get Help" button +=================================================== + +Provide a Solution-only Personalized Adaptive Puzzle +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This provides a **solution-only personalized adaptive puzzle** based on students' current written code. + +The students can regenerate the puzzle based on their updated code anytime by clicking the "Regenerate Help" button. + +:Paired Block Sets: + - Pairs a correct block with an incorrect block that is not needed in a correct solution. + - Try to use students' own wrong code as distractor blocks. + + +.. activecode:: has22-example-solper-java + :language: java + :autograde: unittest + :parsonspersonalize: movable + + Create a method ``has22(nums)`` that takes an array of integers, ``nums`` and returns ``true`` if there are at least two items in the list that are adjacent and both equal to 2, otherwise return false. + + .. table:: + :name: phrase_table_solcode + :align: left + :width: 50 + + +-------------------------------------+-------------------------------+ + | Example Input | Expected Output | + +=====================================+===============================+ + | ``has22({1, 2, 2})`` | ``true`` | + +-------------------------------------+-------------------------------+ + | ``has22({1, 2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + | ``has22({2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + + + + ~~~~ + import java.util.Scanner; + import java.util.Arrays; + + public class Has22 { + public static boolean has22(int nums) { + for (int i = 0; i < nums.length - 1; i++) { + + + + + + + ==== + import static org.junit.Assert.*; + import org.junit.Test; + + class TestHelper { + public static void runAllTests() throws Exception { + if (!Has22.has22(new int[]{1, 2, 2, 3})) { + throw new Exception("Test 1 failed"); + } + if (Has22.has22(new int[]{2, 3, 2})) { + throw new Exception("Test 2 failed"); + } + if (Has22.has22(new int[]{1, 3, 4, 5})) { + throw new Exception("Test 3 failed"); + } + } + } + + + public class RunestoneTests { + @Test + public void testPhrase() throws Exception { + try { + TestHelper.runAllTests(); + System.out.println("✅ All tests passed!"); + System.out.println("Test 1: phrase(\"Sam\", \"Likes to code\") -> Sam likes to code"); + System.out.println("Test 2: phrase(123, \"code\") -> null"); + System.out.println("Test 3: phrase(\"JANE\", \"Loves JAVA\") -> Jane loves java"); + } catch (Exception e) { + System.out.println("❌ " + e.getMessage()); + fail(e.getMessage()); + } + } + } + +What to do next +^^^^^^^^^^^^^^^ + +.. raw:: html + +

Click on the following link to try: A Java Block-and-Solution Personalized Adaptive Puzzle

+ +.. raw:: html + + \ No newline at end of file diff --git a/_sources/CodeTailorTest/multi_level_per_puzzle.rst b/_sources/CodeTailorTest/multi_level_per_puzzle.rst new file mode 100644 index 0000000..7c84cbb --- /dev/null +++ b/_sources/CodeTailorTest/multi_level_per_puzzle.rst @@ -0,0 +1,96 @@ + +🪄 CodeTailor Examples - Try the "Get Help" button +=================================================== + +Provide a Block-and-Solution Personalized Adaptive Puzzle +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This provides a **block-and-solution personalized adaptive puzzle** based on students' current written code. + +The students can interact with the puzzle and try to solve it. + +The students can regenerate the puzzle based on their updated code anytime by clicking the "Regenerate Help" button. + +:Movable Blocks: + Move the correct blocks from the left box to the right box and put them into the correct order. + +:Static Blocks: + - The Static blocks are the blocks that are already in position in the answer box. You can not move them. + - You can hover over the static blocks to see how many blocks are needed above and below them. + +:Paired Block Sets: + - Pairs a correct block with an incorrect block that is not needed in a correct solution. + - Try to use students' own wrong code as distractor blocks. + + +.. activecode:: str-mixed-example-multiper + :autograde: unittest + :nocodelens: + :parsonspersonalize: partial + + + Finish a function, ``phrase(person, thing)``: + - It has ``person`` and ``thing`` as input. + - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. + - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` + - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. + + .. table:: + :name: phrase_table_multiper + :align: left + :width: 50 + + +-------------------------------------+---------------------------------------+ + | Example Input | Expected Output | + +=====================================+=======================================+ + |``phrase("Sam", "Likes to code")`` | ``"Sam likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase("ANN", "Likes to CODE")`` | ``"Ann likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase(1, "Python")`` | ``False`` | + +-------------------------------------+---------------------------------------+ + + ~~~~ + # Here is a student's buggy code + # click the "Get Help" button above to see what it provides. + + def phrase(person, thing): + if type(person) == str and type(thing) == str: + person = person.capitalize # bug 2 + thing = thing.lower() + return person + " " + thing + # more bugs ... + + + + ==== + from unittest.gui import TestCaseGui + + class myTests(TestCaseGui): + def testOne(self): + self.assertEqual(phrase("sam", "Likes to code"), "Sam likes to code", 'phrase("sam", " Likes to code")') + self.assertEqual(phrase("mary-anne", "likes to sing"), "Mary-anne likes to sing", 'phrase("mary-anne", " likes to sing")') + self.assertEqual(phrase("ANNA", "likes to dance"), "Anna likes to dance", 'phrase("ANNA", " likes to dance")') + self.assertEqual(phrase(1111, "likes programming"), False, 'phrase(1111, " likes programming")') + myTests().main() + + + +What to do next +^^^^^^^^^^^^^^^ + +.. raw:: html + +

Click on the following link to try: A Java Solution-only Personalized Adaptive Puzzle

+ +.. raw:: html + + \ No newline at end of file diff --git a/_sources/CodeTailorTest/solution_per_puzzle.rst b/_sources/CodeTailorTest/solution_per_puzzle.rst new file mode 100644 index 0000000..738ace0 --- /dev/null +++ b/_sources/CodeTailorTest/solution_per_puzzle.rst @@ -0,0 +1,112 @@ + +🪄 CodeTailor Examples - Try the "Get Help" button +================================================== + +Provide a Solution-only Personalized Adaptive Puzzle +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This provides a **solution-only personalized adaptive puzzle** based on students' current written code. +The students can interact with the puzzle and try to solve it. + +The students can regenerate the puzzle based on their updated code anytime by clicking the "Regenerate Help" button. + +:Paired Block Sets: + - Pairs a correct block with an incorrect block that is not needed in a correct solution. + - Try to use students' own wrong code as distractor blocks. + + +.. activecode:: str-mixed-example-solper + :autograde: unittest + :parsonspersonalize: movable + :parsonsexample: str-mixed-example-pp + + Finish a function, ``phrase(person, thing)``: + - It has ``person`` and ``thing`` as input. + - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. + - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` + - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. + + .. table:: + :name: phrase_table_solper + :align: left + :width: 50 + + +-------------------------------------+---------------------------------------+ + | Example Input | Expected Output | + +=====================================+=======================================+ + |``phrase("Sam", "Likes to code")`` | ``"Sam likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase("ANN", "Likes to CODE")`` | ``"Ann likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase(1, "Python")`` | ``False`` | + +-------------------------------------+---------------------------------------+ + + ~~~~ + # Here is a student's buggy code + # click the "Get Help" button above to see what it provides. + + def phrase(person, thing): + if type(person) == str or type(thing) == str: # bug 1 + person = person.capitalize # bug 2 + thing = thing.lower() + return person + " " + thing + # more bugs ... + + + + + ==== + from unittest.gui import TestCaseGui + + class myTests(TestCaseGui): + def testOne(self): + self.assertEqual(phrase("sam", "Likes to code"), "Sam likes to code", 'phrase("sam", " Likes to code")') + self.assertEqual(phrase("mary-anne", "likes to sing"), "Mary-anne likes to sing", 'phrase("mary-anne", " likes to sing")') + self.assertEqual(phrase("ANNA", "likes to dance"), "Anna likes to dance", 'phrase("ANNA", " likes to dance")') + self.assertEqual(phrase(1111, "likes programming"), False, 'phrase(1111, " likes programming")') + + + myTests().main() + + +.. parsonsprob:: str-mixed-example-pp + :numbered: left + + Finish a function, ``phrase(person, thing)``: + - It has ``person`` and ``thing`` as input. + - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. + - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` + - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. + ----- + def phrase(person, thing): # a correct solution + ===== + if type(person) == str and type(thing) == str: + ===== + person = person.capitalize() + thing = thing.lower() + return person + " " + thing + ===== + else: + ===== + return False + + + +What to do next +^^^^^^^^^^^^^^^ + +.. raw:: html + +

Click on the following link to try: A Block-and-Solution Personalized Adaptive Puzzle

+ +.. raw:: html + + \ No newline at end of file From 132c552e3dc7e86f3200a6faaf04e0348322c0dc Mon Sep 17 00:00:00 2001 From: xinyinghou Date: Mon, 22 Sep 2025 04:24:30 +0000 Subject: [PATCH 2/3] aligned with other pages in the overview book --- _sources/ActiveCode/python.rst | 34 ++--- _sources/CodeTailorTest/index.rst | 73 ---------- .../java_multi_level_per_puzzle.rst | 88 ++++++++++-- .../java_solution_per_puzzle.rst | 97 ++++++++++--- .../CodeTailorTest/multi_level_per_puzzle.rst | 89 ++++++++---- .../CodeTailorTest/solution_per_puzzle.rst | 131 ++++++++++++------ _sources/CodeTailorTest/toctree.rst | 12 ++ build/.gitignore | 4 - 8 files changed, 333 insertions(+), 195 deletions(-) delete mode 100644 _sources/CodeTailorTest/index.rst create mode 100644 _sources/CodeTailorTest/toctree.rst delete mode 100644 build/.gitignore diff --git a/_sources/ActiveCode/python.rst b/_sources/ActiveCode/python.rst index 563055a..9f5f3bd 100644 --- a/_sources/ActiveCode/python.rst +++ b/_sources/ActiveCode/python.rst @@ -223,9 +223,9 @@ Image Processing We have a special image library that we wrote for skulpt that lets you access images pixel by pixel. This is a great way to practice nested iteration and to learn about the many different filters provided by services like Instagram, and others. -.. datafile:: golden_gate.png - :image: - :fromfile: golden_gate.png +.. .. datafile:: golden_gate.png +.. :image: +.. :fromfile: golden_gate.png Click on the reveal to see the rst for the datafile directive. @@ -237,9 +237,9 @@ Click on the reveal to see the rst for the datafile directive. .. code-block:: rst - .. datafile:: golden_gate.png - :image: - :fromfile: golden_gate.png + .. .. datafile:: golden_gate.png + .. :image: + .. :fromfile: golden_gate.png You can use images in many ways. If you have an image in your page and it has an id tag you can use that. If you have a full URL to an image you can use that. But the best thing to do if you are writing a book is to use the ``.. datafile::`` directive, this ensures that the image is available from anywhere in the book. @@ -484,12 +484,9 @@ If the JOBE server has pandas installed we can even use pandas right in the text Here is the file it will read from. -.. datafile:: country_data.csv - :fromfile: world_countries.csv .. activecode:: pandas :language: python3 - :datafile: country_data.csv import pandas as pd @@ -505,7 +502,6 @@ Here is the file it will read from. .. activecode:: pandas :language: python3 - :datafile: country_data.csv import pandas as pd @@ -516,18 +512,18 @@ Here is the file it will read from. For this example, we move our ``PartyAnimal`` class into its own file. Then, we can 'import' the ``PartyAnimal`` class in a new file and extend it, as follows: -.. datafile:: src/builtin/party.py +.. .. datafile:: src/builtin/party.py - class PartyAnimal: +.. class PartyAnimal: - def __init__(self, nam): - self.name = nam - print(self.name,'constructed') +.. def __init__(self, nam): +.. self.name = nam +.. print(self.name,'constructed') - def party(self, x) : - self.x = x - self.x = self.x + 1 - print(self.name,'party count',self.x) +.. def party(self, x) : +.. self.x = x +.. self.x = self.x + 1 +.. print(self.name,'party count',self.x) .. activecode:: inherit_cricketfan diff --git a/_sources/CodeTailorTest/index.rst b/_sources/CodeTailorTest/index.rst deleted file mode 100644 index 35d7c40..0000000 --- a/_sources/CodeTailorTest/index.rst +++ /dev/null @@ -1,73 +0,0 @@ -💻 CodeTailor: Pop-up a mixed-up puzzle to help while writing code -======================================================================= - -The primary goal is to complete the write-code problem, with the optional puzzle providing guidance and hints. - - -1️⃣ Get Help -^^^^^^^^^^^^ -Click the **"Get Help"** button below the problem description to access a mixed-up puzzle that will guide you through solving the write-code task. -The puzzle presents essential code snippets and logic in a scrambled order. - -2️⃣ Close Help -^^^^^^^^^^^^^^^ -Click this button to close the help view and return to the main problem. - -3️⃣ See Help Again -^^^^^^^^^^^^^^^^^^ -Reopen the help puzzle anytime by clicking this button. - - -.. image:: https://i.postimg.cc/pr7q6PBs/help-puzzle-OP.gif - :width: 800px - :align: center - - -4️⃣ 'Help me' Button – Additional Assistance in Mixed-up Puzzle -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -After solving (checking) the puzzle three times using the required number of blocks - -If you have **more than three blocks** remaining in the answering area, you can unlock the "Help me" feature in the puzzle. - -Each click will **merge** two blocks into one, reducing the number of blocks needed for consideration. - - -5️⃣ Copy Answer to Clipboard -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -After generating a correct solution within the puzzle, you can copy the completed code to your clipboard and paste it into the write-code editor. - - -.. image:: https://i.postimg.cc/T37NL8F2/help-puzzle-OP-copy-answer.gif - :width: 800px - :align: center - - -🪄 Examples - Try the "Get Help" button by yourself -==================================================== - -Starting from the next section, you will interact with three different types of puzzles as scaffolding in both java and python. - -Provide a Solution-only Personalized Adaptive Puzzle - -Provide a Block-and-Solution Personalized Adaptive Puzzle - - - -What to do next -^^^^^^^^^^^^^^^ - -.. raw:: html - -

Click on the following link to try: A Solution-only Personalized Adaptive Puzzle

- -.. raw:: html - - \ No newline at end of file diff --git a/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst b/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst index e57e538..c05d601 100644 --- a/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst +++ b/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst @@ -3,13 +3,11 @@ =================================================== Provide a Block-and-Solution Personalized Adaptive Puzzle -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +------------------------------------------------------------ -This type provides a **block-and-solution personalized adaptive puzzle** based on students' current written code. - -The students can interact with the puzzle and try to solve it. - -The students can regerenate the puzzle based on their updated code anytime by clicking the "Regerenate Help" button. +In this example, you receive a **block-and-solution personalized adaptive puzzle** based on your current written code. +You can interact with the puzzle and try to solve it. +You can regenerate the puzzle based on your updated code anytime by clicking the "Regenerate Help" button. :Movable Blocks: Move the correct blocks from the left box to the right box and put them into the correct order. @@ -97,6 +95,80 @@ The students can regerenate the puzzle based on their updated code anytime by cl } +.. reveal:: codetailor4_source + :showtitle: Show Source + :hidetitle: Hide Source + :modaltitle: Source for the example above + + .. code-block:: rst + + .. activecode:: has22-example-multiper-java + :language: java + :autograde: unittest + :parsonspersonalize: partial + + Create a method ``has22(nums)`` that takes an array of integers, ``nums`` and returns ``true`` if there are at least two items in the list that are adjacent and both equal to 2, otherwise return false. + + .. table:: + :name: phrase_table_solcode + :align: left + :width: 50 + + +-------------------------------------+-------------------------------+ + | Example Input | Expected Output | + +=====================================+===============================+ + | ``has22({1, 2, 2})`` | ``true`` | + +-------------------------------------+-------------------------------+ + | ``has22({1, 2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + | ``has22({2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + + + + ~~~~ + import java.util.Scanner; + import java.util.Arrays; + + public class Has22 { + public static boolean has22(int nums) { + for (int i = 0; i < nums.length - 1; i++) { -Thanks for trying CodeTailor! 🎉 -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \ No newline at end of file + + + + + ==== + import static org.junit.Assert.*; + import org.junit.Test; + + class TestHelper { + public static void runAllTests() throws Exception { + if (!Has22.has22(new int[]{1, 2, 2, 3})) { + throw new Exception("Test 1 failed"); + } + if (Has22.has22(new int[]{2, 3, 2})) { + throw new Exception("Test 2 failed"); + } + if (Has22.has22(new int[]{1, 3, 4, 5})) { + throw new Exception("Test 3 failed"); + } + } + } + + + public class RunestoneTests { + @Test + public void testPhrase() throws Exception { + try { + TestHelper.runAllTests(); + System.out.println("✅ All tests passed!"); + System.out.println("Test 1: phrase(\"Sam\", \"Likes to code\") -> Sam likes to code"); + System.out.println("Test 2: phrase(123, \"code\") -> null"); + System.out.println("Test 3: phrase(\"JANE\", \"Loves JAVA\") -> Jane loves java"); + } catch (Exception e) { + System.out.println("❌ " + e.getMessage()); + fail(e.getMessage()); + } + } + } \ No newline at end of file diff --git a/_sources/CodeTailorTest/java_solution_per_puzzle.rst b/_sources/CodeTailorTest/java_solution_per_puzzle.rst index 6be8be3..dfb1b01 100644 --- a/_sources/CodeTailorTest/java_solution_per_puzzle.rst +++ b/_sources/CodeTailorTest/java_solution_per_puzzle.rst @@ -1,17 +1,15 @@ -🪄 CodeTailor Examples - Try the "Get Help" button -=================================================== +Provide a Solution-only Personalized Adaptive Puzzle in Java +-------------------------------------------------------------- -Provide a Solution-only Personalized Adaptive Puzzle -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +In this example, you receive a **solution-only personalized adaptive puzzle** based on your current written code. +You can interact with the puzzle and try to solve it. +You can regenerate the puzzle based on your updated code anytime by clicking the "Regenerate Help" button. -This provides a **solution-only personalized adaptive puzzle** based on students' current written code. - -The students can regenerate the puzzle based on their updated code anytime by clicking the "Regenerate Help" button. :Paired Block Sets: - Pairs a correct block with an incorrect block that is not needed in a correct solution. - - Try to use students' own wrong code as distractor blocks. + - Try to use your own wrong code as distractor blocks. .. activecode:: has22-example-solper-java @@ -86,21 +84,82 @@ The students can regenerate the puzzle based on their updated code anytime by cl } } -What to do next -^^^^^^^^^^^^^^^ -.. raw:: html +.. reveal:: codetailor3_source + :showtitle: Show Source + :hidetitle: Hide Source + :modaltitle: Source for the example above + + .. code-block:: rst + + .. activecode:: has22-example-solper-java + :language: java + :autograde: unittest + :parsonspersonalize: movable + + Create a method ``has22(nums)`` that takes an array of integers, ``nums`` and returns ``true`` if there are at least two items in the list that are adjacent and both equal to 2, otherwise return false. + + .. table:: + :name: phrase_table_solcode + :align: left + :width: 50 + + +-------------------------------------+-------------------------------+ + | Example Input | Expected Output | + +=====================================+===============================+ + | ``has22({1, 2, 2})`` | ``true`` | + +-------------------------------------+-------------------------------+ + | ``has22({1, 2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + | ``has22({2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + + -

Click on the following link to try: A Java Block-and-Solution Personalized Adaptive Puzzle

+ ~~~~ + import java.util.Scanner; + import java.util.Arrays; -.. raw:: html + public class Has22 { + public static boolean has22(int nums) { + for (int i = 0; i < nums.length - 1; i++) { - \ No newline at end of file + + + ==== + import static org.junit.Assert.*; + import org.junit.Test; + + class TestHelper { + public static void runAllTests() throws Exception { + if (!Has22.has22(new int[]{1, 2, 2, 3})) { + throw new Exception("Test 1 failed"); + } + if (Has22.has22(new int[]{2, 3, 2})) { + throw new Exception("Test 2 failed"); + } + if (Has22.has22(new int[]{1, 3, 4, 5})) { + throw new Exception("Test 3 failed"); + } + } + } + + + public class RunestoneTests { + @Test + public void testPhrase() throws Exception { + try { + TestHelper.runAllTests(); + System.out.println("✅ All tests passed!"); + System.out.println("Test 1: phrase(\"Sam\", \"Likes to code\") -> Sam likes to code"); + System.out.println("Test 2: phrase(123, \"code\") -> null"); + System.out.println("Test 3: phrase(\"JANE\", \"Loves JAVA\") -> Jane loves java"); + } catch (Exception e) { + System.out.println("❌ " + e.getMessage()); + fail(e.getMessage()); + } + } + } diff --git a/_sources/CodeTailorTest/multi_level_per_puzzle.rst b/_sources/CodeTailorTest/multi_level_per_puzzle.rst index 7c84cbb..9a0c74a 100644 --- a/_sources/CodeTailorTest/multi_level_per_puzzle.rst +++ b/_sources/CodeTailorTest/multi_level_per_puzzle.rst @@ -1,15 +1,10 @@ -🪄 CodeTailor Examples - Try the "Get Help" button -=================================================== - Provide a Block-and-Solution Personalized Adaptive Puzzle -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This provides a **block-and-solution personalized adaptive puzzle** based on students' current written code. - -The students can interact with the puzzle and try to solve it. +-------------------------------------------------------------- -The students can regenerate the puzzle based on their updated code anytime by clicking the "Regenerate Help" button. +In this example, you receive a **block-and-solution personalized adaptive puzzle** based on your current written code. +You can interact with the puzzle and try to solve it. +You can regenerate the puzzle based on your updated code anytime by clicking the "Regenerate Help" button. :Movable Blocks: Move the correct blocks from the left box to the right box and put them into the correct order. @@ -75,22 +70,60 @@ The students can regenerate the puzzle based on their updated code anytime by cl myTests().main() - -What to do next -^^^^^^^^^^^^^^^ - -.. raw:: html - -

Click on the following link to try: A Java Solution-only Personalized Adaptive Puzzle

- -.. raw:: html - - \ No newline at end of file +.. reveal:: codetailor2_source + :showtitle: Show Source + :hidetitle: Hide Source + :modaltitle: Source for the example above + + .. code-block:: rst + + .. activecode:: str-mixed-example-multiper + :autograde: unittest + :nocodelens: + :parsonspersonalize: partial + + + Finish a function, ``phrase(person, thing)``: + - It has ``person`` and ``thing`` as input. + - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. + - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` + - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. + + .. table:: + :name: phrase_table_multiper + :align: left + :width: 50 + + +-------------------------------------+---------------------------------------+ + | Example Input | Expected Output | + +=====================================+=======================================+ + |``phrase("Sam", "Likes to code")`` | ``"Sam likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase("ANN", "Likes to CODE")`` | ``"Ann likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase(1, "Python")`` | ``False`` | + +-------------------------------------+---------------------------------------+ + + ~~~~ + # Here is a student's buggy code + # click the "Get Help" button above to see what it provides. + + def phrase(person, thing): + if type(person) == str and type(thing) == str: + person = person.capitalize # bug 2 + thing = thing.lower() + return person + " " + thing + # more bugs ... + + + + ==== + from unittest.gui import TestCaseGui + + class myTests(TestCaseGui): + def testOne(self): + self.assertEqual(phrase("sam", "Likes to code"), "Sam likes to code", 'phrase("sam", " Likes to code")') + self.assertEqual(phrase("mary-anne", "likes to sing"), "Mary-anne likes to sing", 'phrase("mary-anne", " likes to sing")') + self.assertEqual(phrase("ANNA", "likes to dance"), "Anna likes to dance", 'phrase("ANNA", " likes to dance")') + self.assertEqual(phrase(1111, "likes programming"), False, 'phrase(1111, " likes programming")') + myTests().main() \ No newline at end of file diff --git a/_sources/CodeTailorTest/solution_per_puzzle.rst b/_sources/CodeTailorTest/solution_per_puzzle.rst index 738ace0..5244d7e 100644 --- a/_sources/CodeTailorTest/solution_per_puzzle.rst +++ b/_sources/CodeTailorTest/solution_per_puzzle.rst @@ -1,20 +1,41 @@ +CodeTailor +---------- -🪄 CodeTailor Examples - Try the "Get Help" button -================================================== +The primary goal is to complete the write-code problem, with the optional puzzle providing guidance and hints. +The puzzle presents essential code snippets and logic in a scrambled order. -Provide a Solution-only Personalized Adaptive Puzzle -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. parsonsprob:: str-mixed-example-pp + :numbered: left -This provides a **solution-only personalized adaptive puzzle** based on students' current written code. -The students can interact with the puzzle and try to solve it. + Finish a function, ``phrase(person, thing)``: + - It has ``person`` and ``thing`` as input. + - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. + - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` + - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. + ----- + def phrase(person, thing): # a correct solution + ===== + if type(person) == str and type(thing) == str: + ===== + person = person.capitalize() + thing = thing.lower() + return person + " " + thing + ===== + else: + ===== + return False -The students can regenerate the puzzle based on their updated code anytime by clicking the "Regenerate Help" button. -:Paired Block Sets: - - Pairs a correct block with an incorrect block that is not needed in a correct solution. - - Try to use students' own wrong code as distractor blocks. +You can click the **"Get Help"** button below the problem description to access a mixed-up puzzle that will guide you through solving the write-code task. +You can click the **"Close Help"** button to close the help view and return to the main problem. +You can click the **"See Help Again"** button to reopen the help puzzle anytime. +You can click the **"Regenerate Help"** button to regenerate a new puzzle based on your current code in the write-code editor. + +Solution-only personalized adaptive puzzle +----------------------------------------------- +This provides a **solution-only personalized adaptive puzzle** based on students' current written code. +The students can interact with the puzzle and try to solve it. - .. activecode:: str-mixed-example-solper :autograde: unittest :parsonspersonalize: movable @@ -68,45 +89,67 @@ The students can regenerate the puzzle based on their updated code anytime by cl myTests().main() - -.. parsonsprob:: str-mixed-example-pp - :numbered: left - - Finish a function, ``phrase(person, thing)``: - - It has ``person`` and ``thing`` as input. - - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. - - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` - - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. - ----- - def phrase(person, thing): # a correct solution - ===== - if type(person) == str and type(thing) == str: - ===== - person = person.capitalize() +After generating a correct solution within the puzzle, you will see a **Copy answer to clipboard** button. +You can copy the completed code to your clipboard and paste it into the write-code editor. + +Click on the "Show Source" button below to see what the reStructuredText (rst) looks like for the CodeTailor code above. + +.. reveal:: codetailor1_source + :showtitle: Show Source + :hidetitle: Hide Source + :modaltitle: Source for the example above + + .. code-block:: rst + + .. activecode:: str-mixed-example-solper + :autograde: unittest + :parsonspersonalize: movable + :parsonsexample: str-mixed-example-pp + + Finish a function, ``phrase(person, thing)``: + - It has ``person`` and ``thing`` as input. + - First verify whether ``person`` and ``thing`` are strings. If not, return ``False``. + - If ``person`` and ``thing`` are two strings, return one string with the characters in ``person``, followed by an empty space, and then followed by ``thing`` + - Make sure the first letter in ``person`` is capitalized and all the characters in ``thing`` are lowercase. + + .. table:: + :name: phrase_table_solper + :align: left + :width: 50 + + +-------------------------------------+---------------------------------------+ + | Example Input | Expected Output | + +=====================================+=======================================+ + |``phrase("Sam", "Likes to code")`` | ``"Sam likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase("ANN", "Likes to CODE")`` | ``"Ann likes to code"`` | + +-------------------------------------+---------------------------------------+ + |``phrase(1, "Python")`` | ``False`` | + +-------------------------------------+---------------------------------------+ + + ~~~~ + # Here is a student's buggy code + # click the "Get Help" button above to see what it provides. + + def phrase(person, thing): + if type(person) == str or type(thing) == str: # bug 1 + person = person.capitalize # bug 2 thing = thing.lower() return person + " " + thing - ===== - else: - ===== - return False - - - -What to do next -^^^^^^^^^^^^^^^ + # more bugs ... -.. raw:: html -

Click on the following link to try: A Block-and-Solution Personalized Adaptive Puzzle

-.. raw:: html - \ No newline at end of file + myTests().main() diff --git a/_sources/CodeTailorTest/toctree.rst b/_sources/CodeTailorTest/toctree.rst new file mode 100644 index 0000000..3469b5e --- /dev/null +++ b/_sources/CodeTailorTest/toctree.rst @@ -0,0 +1,12 @@ +CodeTailor Test +:::::::::: + +.. toctree:: + :caption: CodeTailor Test + :maxdepth: 2 + + solution_per_puzzle.rst + multi_level_per_puzzle.rst + java_solution_per_puzzle.rst + java_multi_level_per_puzzle.rst + diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index 86d0cb2..0000000 --- a/build/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file From add95a7c35b67f8929f6e4ea4bf0bd8bd2938d36 Mon Sep 17 00:00:00 2001 From: xinyinghou Date: Mon, 22 Sep 2025 04:27:20 +0000 Subject: [PATCH 3/3] updated indentation --- .../java_multi_level_per_puzzle.rst | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst b/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst index c05d601..4945767 100644 --- a/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst +++ b/_sources/CodeTailorTest/java_multi_level_per_puzzle.rst @@ -103,72 +103,72 @@ You can regenerate the puzzle based on your updated code anytime by clicking the .. code-block:: rst .. activecode:: has22-example-multiper-java - :language: java - :autograde: unittest - :parsonspersonalize: partial + :language: java + :autograde: unittest + :parsonspersonalize: partial - Create a method ``has22(nums)`` that takes an array of integers, ``nums`` and returns ``true`` if there are at least two items in the list that are adjacent and both equal to 2, otherwise return false. + Create a method ``has22(nums)`` that takes an array of integers, ``nums`` and returns ``true`` if there are at least two items in the list that are adjacent and both equal to 2, otherwise return false. - .. table:: - :name: phrase_table_solcode - :align: left - :width: 50 + .. table:: + :name: phrase_table_solcode + :align: left + :width: 50 - +-------------------------------------+-------------------------------+ - | Example Input | Expected Output | - +=====================================+===============================+ - | ``has22({1, 2, 2})`` | ``true`` | - +-------------------------------------+-------------------------------+ - | ``has22({1, 2, 1, 2})`` | ``false`` | - +-------------------------------------+-------------------------------+ - | ``has22({2, 1, 2})`` | ``false`` | - +-------------------------------------+-------------------------------+ + +-------------------------------------+-------------------------------+ + | Example Input | Expected Output | + +=====================================+===============================+ + | ``has22({1, 2, 2})`` | ``true`` | + +-------------------------------------+-------------------------------+ + | ``has22({1, 2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ + | ``has22({2, 1, 2})`` | ``false`` | + +-------------------------------------+-------------------------------+ - ~~~~ - import java.util.Scanner; - import java.util.Arrays; + ~~~~ + import java.util.Scanner; + import java.util.Arrays; - public class Has22 { - public static boolean has22(int nums) { - for (int i = 0; i < nums.length - 1; i++) { + public class Has22 { + public static boolean has22(int nums) { + for (int i = 0; i < nums.length - 1; i++) { - ==== - import static org.junit.Assert.*; - import org.junit.Test; + ==== + import static org.junit.Assert.*; + import org.junit.Test; - class TestHelper { - public static void runAllTests() throws Exception { - if (!Has22.has22(new int[]{1, 2, 2, 3})) { - throw new Exception("Test 1 failed"); - } - if (Has22.has22(new int[]{2, 3, 2})) { - throw new Exception("Test 2 failed"); - } - if (Has22.has22(new int[]{1, 3, 4, 5})) { - throw new Exception("Test 3 failed"); + class TestHelper { + public static void runAllTests() throws Exception { + if (!Has22.has22(new int[]{1, 2, 2, 3})) { + throw new Exception("Test 1 failed"); + } + if (Has22.has22(new int[]{2, 3, 2})) { + throw new Exception("Test 2 failed"); + } + if (Has22.has22(new int[]{1, 3, 4, 5})) { + throw new Exception("Test 3 failed"); + } } } - } - public class RunestoneTests { - @Test - public void testPhrase() throws Exception { - try { - TestHelper.runAllTests(); - System.out.println("✅ All tests passed!"); - System.out.println("Test 1: phrase(\"Sam\", \"Likes to code\") -> Sam likes to code"); - System.out.println("Test 2: phrase(123, \"code\") -> null"); - System.out.println("Test 3: phrase(\"JANE\", \"Loves JAVA\") -> Jane loves java"); - } catch (Exception e) { - System.out.println("❌ " + e.getMessage()); - fail(e.getMessage()); + public class RunestoneTests { + @Test + public void testPhrase() throws Exception { + try { + TestHelper.runAllTests(); + System.out.println("✅ All tests passed!"); + System.out.println("Test 1: phrase(\"Sam\", \"Likes to code\") -> Sam likes to code"); + System.out.println("Test 2: phrase(123, \"code\") -> null"); + System.out.println("Test 3: phrase(\"JANE\", \"Loves JAVA\") -> Jane loves java"); + } catch (Exception e) { + System.out.println("❌ " + e.getMessage()); + fail(e.getMessage()); + } } - } - } \ No newline at end of file + } \ No newline at end of file