Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions _sources/ActiveCode/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down Expand Up @@ -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

Expand All @@ -505,7 +502,6 @@ Here is the file it will read from.

.. activecode:: pandas
:language: python3
:datafile: country_data.csv

import pandas as pd

Expand All @@ -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
Expand Down
174 changes: 174 additions & 0 deletions _sources/CodeTailorTest/java_multi_level_per_puzzle.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@

🪄 CodeTailor Examples - Try the "Get Help" button
===================================================

Provide a Block-and-Solution Personalized Adaptive Puzzle
------------------------------------------------------------

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.

: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());
}
}
}


.. 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++) {





====
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());
}
}
}
Loading