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
10 changes: 9 additions & 1 deletion doc/guide/author/topics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4048,7 +4048,7 @@
<subsubsection xml:id="interactive-program-activecode-tests">
<title>Tests for Interactive Programs</title>

<p>There are currently two ways to make automated tests for ActiveCode programs. The first way is to simply provide code in the <tag>tests</tag> element of the <tag>program</tag> as described in <xref ref="interactive-program-activecode"/>. It will be assumed this code is unit tests and it will be run automatically with the user's submission.</p>
<p>There are currently two main ways to make automated tests for ActiveCode programs. The first way is to simply provide code in the <tag>tests</tag> element of the <tag>program</tag> as described in <xref ref="interactive-program-activecode"/>. It will be assumed this code is unit tests and it will be run automatically with the user's submission.</p>

<p>Below is an example of unit tested Python. For more examples, see <url href="https://runestone.academy/ns/books/published/PTXSB/coding-exercises.html">the Coding Exercises section of the Sample Book</url></p>

Expand Down Expand Up @@ -4096,6 +4096,8 @@
<p>Structured IO tests are added as <tag>iotest</tag>s to the <tag>tests</tag> element. Each <tag>iotest</tag> element must have a single <tag>input</tag> and <tag>output</tag> element. The <tag>input</tag> element contains the input that will be fed to the program, and the <tag>match</tag> element contains the expected output of the program. Indentation for both will be normalized in the same way that programs are (so multiple-line sample output can be indented in your source document).</p>

<p>When evaluated, the program output and test <tag>output</tag> will have leading and trailing spaces removed. Other than that spacing, the two must match exactly to be considered a "passed" test.</p>

<p>GDScript has it's own way to test based on the GDPractice addon library. The sample book has three examples of testing with gdscript.</p>
</subsubsection>
</subsection>

Expand Down Expand Up @@ -4133,6 +4135,12 @@
<cell></cell>
<cell>AC + IO</cell>
</row>
<row>
<cell>GDScript</cell>
<cell><c>gdscript</c></cell>
<cell>AC</cell>
<cell>AC</cell>
</row>
<row>
<cell>Java</cell>
<cell><c>java</c></cell>
Expand Down
1 change: 1 addition & 0 deletions doc/guide/publisher/publication-file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@
<li><c>javascript</c> (JavaScript)</li>
<li><c>html</c> (<init>HTML</init>)</li>
<li><c>sql</c> (<init>SQL</init>)</li>
<li><c>gdscript</c> (<init>GDScript</init>)</li>
<li><c>c</c> (C, Runestone server only)</li>
<li><c>cpp</c> (C++, Runestone server only)</li>
<li><c>java</c> (Java, Runestone server only)</li>
Expand Down
2 changes: 1 addition & 1 deletion doc/guide/publisher/runestone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<li>As much as possible, non-interactive versions of these problems will render in less-capable formats, like <init>PDF</init>, <init>EPUB</init>, and braille.</li>

<li>A <tag>program</tag> element with the attribute <attr>interactive</attr> set to <c>activecode</c> (even outside of a an exercise) will be realized as a Runestone ActiveCode interactive program, where programs can be edited, compiled, and run. In some cases a CodeLens interactive trace utility is also available. The <attr>language</attr> must be set. Supported values for the language when hosted at Runestone are: <c>python</c>, <c>python3</c>, <c>c</c>, <c>cpp</c> (C++), <c>javascript</c>, <c>java</c>, <c>kotlin</c>, <c>octave</c> (Matlab), <c>sql</c>, and <c>html</c>. When hosted on your own server, <c>python</c>, <c>javascript</c>, <c>sql</c>, and <c>html</c>, are supported with in-browser routines. So you do not need to configure <em>anything</em> server-side for this capability. See subsections of <xref ref="interactive-program-activecode"/> for details.</li>
<li>A <tag>program</tag> element with the attribute <attr>interactive</attr> set to <c>activecode</c> (even outside of a an exercise) will be realized as a Runestone ActiveCode interactive program, where programs can be edited, compiled, and run. In some cases a CodeLens interactive trace utility is also available. The <attr>language</attr> must be set. Supported values for the language when hosted at Runestone are: <c>python</c>, <c>python3</c>, <c>c</c>, <c>cpp</c> (C++), <c>gdscript</c>, <c>javascript</c>, <c>java</c>, <c>kotlin</c>, <c>octave</c> (Matlab), <c>sql</c>, and <c>html</c>. When hosted on your own server, <c>python</c>, <c>javascript</c>, <c>sql</c>, and <c>html</c>, are supported with in-browser routines. So you do not need to configure <em>anything</em> server-side for this capability. See subsections of <xref ref="interactive-program-activecode"/> for details.</li>

<li>Similarly, a <tag>program</tag> element with the attribute <attr>interactive</attr> set to <c>codelens</c> (even outside of a an exercise) will be realized as a Runestone CodeLens interactive program. This allows a reader to step through the program, much like in a debugger, but with more informative displays of the intermediate state of the program (and nothing like breakpoints or changing variable's values). This ability varies by language, and by hosting location. See subsections of <xref ref="interactive-program-codelens"/> for details.</li>

Expand Down
3 changes: 3 additions & 0 deletions examples/sample-book/gdpractice/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.uid
*.import
.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[preset.0]

name="L1.P1.double_value"
platform="Web"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patches=PackedStringArray()
patch_delta_encoding=false
patch_delta_compression_level_zstd=19
patch_delta_min_reduction=0.1
patch_delta_include_filters="*"
patch_delta_exclude_filters=""
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
export_files=PackedStringArray()

[preset.0.options]

custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
variant/thread_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/ensure_cross_origin_isolation_headers=true
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color(0, 0, 0, 1)
threads/emscripten_pool_size=8
threads/godot_pool_size=4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# L1.P1 — Double the value
#
# Complete get_double() so that it returns twice its input.
extends Node


# Returns double `value`.
func get_double(value: int) -> int:
return value * 2 # return value
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]

[ext_resource type="Script" path="res://practice_solutions/L1.P1.double_value/practice.gd" id="1_practice"]

[node name="DoubleValue" type="Node"]
script = ExtResource("1_practice")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"practice.gd": "dd1c49fd44f1767b1b8417209dfe21f3",
"practice.tscn": "06200c4c9124d206646c1778fb846492"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# L1.P1 — Double the value
#
# Complete get_double() so that it returns twice its input.
extends Node


# Returns double `value`.
func get_double(value: int) -> int:
return value
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene format=3]

[ext_resource type="Script" path="res://practices/L1.P1.double_value/practice.gd" id="1_bmi4d"]

[node name="DoubleValue" type="Node" unique_id=2012261070]
script = ExtResource("1_bmi4d")
1 change: 1 addition & 0 deletions examples/sample-book/gdpractice/L2.P9.visual_2d/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[preset.0]

name="L2.P9.visual_2d_input_motion"
platform="Web"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patches=PackedStringArray()
patch_delta_encoding=false
patch_delta_compression_level_zstd=19
patch_delta_min_reduction=0.1
patch_delta_include_filters="*"
patch_delta_exclude_filters=""
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
export_files=PackedStringArray()

[preset.0.options]

custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
variant/thread_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/ensure_cross_origin_isolation_headers=true
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color(0, 0, 0, 1)
threads/emscripten_pool_size=8
threads/godot_pool_size=4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends Node2D

const SPEED := 200.0


func _physics_process(delta: float) -> void:
if Input.is_action_pressed("move_right"):
position.x += SPEED * delta # position.x += 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gd_scene format=3]

[ext_resource type="Script" path="res://practice_solutions/L2.P9.visual_2d_input_motion/practice.gd" id="2_9_practice_script"]


[node name="Visual2DInputMotion" type="Node2D"]
script = ExtResource("2_9_practice_script")



[node name="ColorRect" type="ColorRect" parent="."]
offset_left = -25.0
offset_top = -25.0
offset_right = 25.0
offset_bottom = 25.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[gd_scene format=3]

[ext_resource type="Script" path="res://practices/L2.P9.visual_2d_input_motion/practice.gd" id="1_edxaw"]

[node name="Visual2DInputMotion" type="Node2D" unique_id=2142483323]
script = ExtResource("1_edxaw")

[node name="ColorRect" type="ColorRect" parent="." unique_id=1691221339]
offset_left = -25.0
offset_top = -25.0
offset_right = 25.0
offset_bottom = 25.0
1 change: 1 addition & 0 deletions examples/sample-book/gdpractice/first_script/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[preset.0]

name="first_script"
platform="Web"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patches=PackedStringArray()
patch_delta_encoding=false
patch_delta_compression_level_zstd=19
patch_delta_min_reduction=0.1
patch_delta_include_filters="*"
patch_delta_exclude_filters=""
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
export_files=PackedStringArray()

[preset.0.options]

custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
variant/thread_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/ensure_cross_origin_isolation_headers=true
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color(0, 0, 0, 1)
threads/emscripten_pool_size=8
threads/godot_pool_size=4
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Sprite2D

var speed = 400
var angular_speed = PI

func _init():
pass


func _process(delta):
rotation += angular_speed * delta
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_scene format=3 uid="uid://bjhwjm0antqag"]

[ext_resource type="Texture2D" uid="uid://bdpv0unclpdb7" path="res://icon.svg" id="1_8yiog"]
[ext_resource type="Script" uid="uid://emhnchkq5m3g" path="res://practice_solutions/first_script/practice.gd" id="2_i5sem"]

[node name="PracticeSlot" type="Sprite2D" unique_id=171888414]
position = Vector2(584, 314)
texture = ExtResource("1_8yiog")
script = ExtResource("2_i5sem")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://bpn5euisle6xo"]

[ext_resource type="Texture2D" uid="uid://bdpv0unclpdb7" path="res://icon.svg" id="1_14gxo"]

[node name="PracticeSlot" type="Sprite2D" unique_id=1816805197]
position = Vector2(584, 314)
texture = ExtResource("1_14gxo")
Binary file not shown.
Loading