<section xml:id="splice-integration">
<title>SPLICE Integration</title>
<p>
<url href="https://cssplice.org/" visual="cssplice.org">SPLICE</url>
is a project to supply documentation and infrastructure to help with adopting shared standards,
protocols,
and tools for web-based learning tools.
The project has designed a
<url href="https://cssplice.org/slcp/index.html" visual="cssplice.org/slcp">protocol</url>
for an embedded iframe to communicate with its host page.
</p>
<p>
One aspect is the ability of an iframe to ask for a new size.
Below is a test of that capability.
</p>
<p>
These are examples that use the
<url href="https://cssplice.org/slcp/index.html" visual="cssplice.org/slcp">SPLICE</url>
protocol for communicating with a server, such as Runestone.
They are all integrated into this <pretext/> book as an <tag>interactive</tag> that uses an <attr>iframe</attr> attribute to embed an iframe from some other server.
</p>
<p>
This first sample tests the ability of an iframe to ask for a new size.
</p>
<interactive xml:id="splice-resize-example" platform="javascript" width="60%" aspect="2:1" source="splice/splice-resize.js"/>
<p>
The next uses
<url href="https://codecheck.io" visual="codecheck.io">CodeCheck</url>.
</p>
<figure xml:id="horstmann-codecheck">
<caption>CodeCheck <c>iframe</c></caption>
<interactive label="interactive-horstmann-codecheck" iframe="https://codecheck.io/files/wiley/ch-bj4cc-c06_exp_6_105" width="95%" aspect="1:1"/>
</figure>
<p>
And the remaing four are from the
<url href="https://opendsax.cs.vt.edu/" visual="opendsax.cs.vt.edu">OpenDSA</url>
project.
</p>
<figure xml:id="opendsa-slideshow">
<caption>Stack pop slideshow</caption>
<interactive label="opendsa-slideshow-pop" iframe="https://opendsax.cs.vt.edu/embed/astackPopCON" width="95%"/>
</figure>
<figure xml:id="splice-integration-insert">
<caption>A List Insertion Exercise</caption>
<interactive label="OpenDSA-list-insertion" iframe="https://opendsax.cs.vt.edu/OpenDSA/Exercises/List/AlistInsertPRO.html" width="100%"/>
</figure>
<figure xml:id="splice-integration-bs">
<caption>A Binary Search Exercise</caption>
<interactive label="OpenDSA-integration-bs" iframe="https://opendsax.cs.vt.edu/OpenDSA/AV/Searching/binarySearchPRO.html" width="175%" aspect="3:1"/>
</figure>
<figure xml:id="splice-integration-dijkstra">
<caption>Dijkstra's Algorithm Exercise</caption>
<interactive label="OpenDSA-integration-dijkstra" iframe="https://opendsax.cs.vt.edu/OpenDSA/AV/Graph/DijkstraPE.html" width="175%" aspect="1:1"/>
</figure>
<!-- Following exercises should go into their own section, but that -->
<!-- messes up numbering and it is hard to see changes. Wait until -->
<!-- this settles down some, and then split these off. -->
<p>
(2025-11-05) The following two exercises are
<alert>strictly EXPERIMENTAL</alert>.
Do not incorporate them into your projects as they are likely to change dramatically.
</p>
<!-- 2025-11-05: Donated by Matt Boelkins from Active Calculus -->
<!-- where it has @xml:id "doenet-interactive-exercise-1-1-1" -->
<exercise>
<title>Finding the average velocity of a moving object from data (dual, Doenet)</title>
<dynamic>
<statement>
<interactive label="doenet-velocity" platform="doenetml">
<slate surface="doenetml">
<setup>
<math name="a"><selectFromSequence from="0.3" to="0.5" step="0.1"/></math>
<math name="b"><selectFromSequence from="1.3" to="1.8" step="0.1"/></math>
<math name="c"><selectFromSequence from="1" to="3" step="1"/></math>
<function name="s" symbolic="false">
$b*x^2
</function>
</setup>
<!--
<p><m>a=$a</m>, <m>b=$b</m>, <m>c=$c</m></p>
-->
<p> Consider a car whose position <m>s</m> (in feet) at time <m>t</m> (in seconds) is given by the table: </p>
<table suppressTableNameInTitle="true">
<tabular top="minor" bottom="minor" left="minor" right="minor">
<row>
<cell><m>t</m> (sec)</cell>
<cell><m>0</m></cell>
<cell><math simplify>$a</math></cell>
<cell><math simplify>2$a</math></cell>
<cell><math simplify>3$a</math></cell>
<cell><math simplify>4$a</math></cell>
<cell><math simplify>5$a</math></cell>
</row>
<row>
<cell><m>s</m> (feet)</cell>
<cell><math simplify displayDigits="4">$$s(0)</math></cell>
<cell><math simplify displayDigits="4">$$s($a)</math></cell>
<cell><math simplify displayDigits="4">$$s(2$a)</math></cell>
<cell><math simplify displayDigits="4">$$s(3$a)</math></cell>
<cell><math simplify displayDigits="4">$$s(4$a)</math></cell>
<cell><math simplify displayDigits="4">$$s(5$a)</math></cell>
</row>
</tabular>
</table>
<p> <ol marker="a"> <li> <p> What are the units on the average velocity of the car? </p> <answer> <choiceInput name="choice1" inline> <choice>miles per hour</choice> <choice>feet</choice> <choice credit="1">feet per second</choice> <choice>seconds</choice> </choiceInput> </answer> </li> <li> <p>Find the average velocity of the car on the interval <m>0 \le t \le <math simplify>3*$a</math></m>. </p> </li> <answer allowedErrorInNumbers="0.05" allowedErrorIsAbsolute="true"> ($$s(3*$a)-$$s(0*$a))/(3$a) </answer> <!-- <math simplify displayDigits="8"> ($$s(3*$a)-$$s(0*$a))/(3$a) </math>, <math displayDigits="8"> ($$s(3*$a)-$$s(0*$a))/(3$a) </math> --> <li> <p> Find the average velocity of the car on the interval <m>[<math simplify>$c*$a</math>, <math simplify>($c+2)*$a</math>]</m>. </p> </li> <answer allowedErrorInNumbers="0.05" allowedErrorIsAbsolute="true"> ($$s(($c+2)*$a)-$$s($c*$a))/(2$a) </answer> </ol> </p>
</slate>
</interactive>
</statement>
</dynamic>
<static>
<introduction>
<p>
Consider a car whose position <m>s</m>
(in feet)
at time <m>t</m>
(in seconds)
is given by the table:
</p>
<!-- $a = 0.3, $$s(x) = 1.3*x^2 -->
<tabular top="minor" bottom="minor" left="minor" right="minor">
<row>
<cell><m>t</m> (sec)</cell>
<cell><m>0</m></cell>
<cell><m>0.3</m></cell>
<cell><m>0.6</m></cell>
<cell><m>0.9</m></cell>
<cell><m>1.2</m></cell>
<cell><m>1.5</m></cell>
</row>
<row>
<cell><m>s</m> (feet)</cell>
<cell><m>0</m></cell>
<cell><m>0.117</m></cell>
<cell><m>0.468</m></cell>
<cell><m>1.053</m></cell>
<cell><m>1.872</m></cell>
<cell><m>2.925</m></cell>
</row>
</tabular>
</introduction>
<task>
<statement>
<p>
What are the units on the average velocity of the car?
</p>
</statement>
<hint>
<p>
Consider possibilities such as
<q>feet</q>,
<q>seconds</q>,
<q>feet per second</q>, or
<q>seconds per foot</q>.
</p>
</hint>
<answer>
<p>
feet per second
</p>
</answer>
</task>
<task>
<statement>
<p>
Find the average velocity of the car on the interval <m>0 \le t \le 0.9</m>.
</p>
</statement>
<hint>
<p>
Recall that average velocity is
<q>change in position divided by change in time</q>.
</p>
</hint>
<answer>
<p>
The average velocity of the car on the interval
<m>0 \le t \le 0.9</m> is <m>1.17</m> feet per second.
</p>
</answer>
</task>
<task>
<statement>
<p>
<!-- $c = 3 --> Find the average velocity of the car on the interval <m>[0.9, 1.5]</m>.
</p>
</statement>
<answer>
<p>
The average velocity of the car on the interval
<m>[0.9,1.5]</m> is <m>3.12</m> feet per second.
</p>
</answer>
</task>
</static>
</exercise>
<exercise>
<title>OpenDSA List Insertion (Dual)</title>
<dynamic>
<statement>
<p>
Work this following problem.
Note that this is really just a test to see if additional text
(beyond an <tag>interactive</tag>)
will show up.
</p>
<interactive label="OpenDSA-list-insertion-exercise" iframe="https://opendsax.cs.vt.edu/OpenDSA/Exercises/List/AlistInsertPRO.html" width="100%"/>
</statement>
</dynamic>
<static>
<statement>
<p>
An exercise about array-based list insertion goes here.
</p>
</statement>
</static>
</exercise>
<p>
This example recreates the Show-Eval visualization from the Runestone Components,
using a PreTexT <tag>interactive</tag>.
It also records student activity using SPLICE.
</p>
<p>
It demonstrates how the Show-Eval tool can be used to visualize the evaluation of Python expressions step by step.
</p>
<p>
This could also be used for doing similar visualization of mathematical expressions.
Support for MathJax would take some work,
but this example would be a good starting point.
</p>
<figure xml:id="show-eval-visualization1">
<caption>Show-Eval Visualization</caption>
<interactive label="show-eval-visualization" platform="javascript" source="https://runestone.academy/cdn/runestone/showEval-0.10.0.js" width="100%">
<slate surface="html">
<style>
.showEval { font-family: monospace; font-size: 1.5em; }
.showEval span { vertical-align: text-top; }
</style>
<button id="nextStep">Next Step</button>
<button id="reset">Reset</button>
<div class="showEval">eggs = ['dogs', 'cats', 'moose']</div>
<div id="showeval"/>
<script>
document.addEventListener("DOMContentLoaded", function() {
console.log("Document loaded");
// for each step, put the part to replaced in the first set of {{ }}, and the replacement text in the following {{ }}
steps = ["''.join({{eggs}}{{['dogs', 'cats', 'moose']}}).upper().join(eggs)",
"{{''.join(['dogs', 'cats', 'moose'])}}{{'dogscatsmoose'}}.upper().join(eggs)",
"{{'dogscatsmoose'.upper()}}{{'DOGSCATSMOOSE'}}.join(eggs)",
"'DOGSCATSMOOSE'.join({{eggs}}{{['dogs', 'cats', 'moose']}})",
"{{'DOGSCATSMOOSE'.join(['dogs', 'cats', 'moose'])}}{{'dogsDOGSCATSMOOSEcatsDOGSCATSMOOSEmoose'}}"];
s = new SHOWEVAL.ShowEval(document.querySelector('#showeval'), steps, false); });
</script>
</slate>
</interactive>
</figure>
</section>
Section 3.28 SPLICE Integration
View Source for section
SPLICE is a project to supply documentation and infrastructure to help with adopting shared standards, protocols, and tools for web-based learning tools. The project has designed a protocol for an embedded iframe to communicate with its host page.
One aspect is the ability of an iframe to ask for a new size. Below is a test of that capability.
These are examples that use the SPLICE protocol for communicating with a server, such as Runestone. They are all integrated into this PreTeXt book as an
<interactive> that uses an @iframe attribute to embed an iframe from some other server.
This first sample tests the ability of an iframe to ask for a new size.
View Source for figure
<figure xml:id="horstmann-codecheck">
<caption>CodeCheck <c>iframe</c></caption>
<interactive label="interactive-horstmann-codecheck" iframe="https://codecheck.io/files/wiley/ch-bj4cc-c06_exp_6_105" width="95%" aspect="1:1"/>
</figure>
iframeView Source for figure
<figure xml:id="opendsa-slideshow">
<caption>Stack pop slideshow</caption>
<interactive label="opendsa-slideshow-pop" iframe="https://opendsax.cs.vt.edu/embed/astackPopCON" width="95%"/>
</figure>
View Source for figure
<figure xml:id="splice-integration-insert">
<caption>A List Insertion Exercise</caption>
<interactive label="OpenDSA-list-insertion" iframe="https://opendsax.cs.vt.edu/OpenDSA/Exercises/List/AlistInsertPRO.html" width="100%"/>
</figure>
View Source for figure
<figure xml:id="splice-integration-bs">
<caption>A Binary Search Exercise</caption>
<interactive label="OpenDSA-integration-bs" iframe="https://opendsax.cs.vt.edu/OpenDSA/AV/Searching/binarySearchPRO.html" width="175%" aspect="3:1"/>
</figure>
View Source for figure
<figure xml:id="splice-integration-dijkstra">
<caption>Dijkstra's Algorithm Exercise</caption>
<interactive label="OpenDSA-integration-dijkstra" iframe="https://opendsax.cs.vt.edu/OpenDSA/AV/Graph/DijkstraPE.html" width="175%" aspect="1:1"/>
</figure>
(2025-11-05) The following two exercises are strictly EXPERIMENTAL. Do not incorporate them into your projects as they are likely to change dramatically.
Checkpoint 3.28.6. Finding the average velocity of a moving object from data (dual, Doenet).
View Source for exercise
<exercise>
<title>Finding the average velocity of a moving object from data (dual, Doenet)</title>
<dynamic>
<statement>
<interactive label="doenet-velocity" platform="doenetml">
<slate surface="doenetml">
<setup>
<math name="a"><selectFromSequence from="0.3" to="0.5" step="0.1"/></math>
<math name="b"><selectFromSequence from="1.3" to="1.8" step="0.1"/></math>
<math name="c"><selectFromSequence from="1" to="3" step="1"/></math>
<function name="s" symbolic="false">
$b*x^2
</function>
</setup>
<!--
<p><m>a=$a</m>, <m>b=$b</m>, <m>c=$c</m></p>
-->
<p> Consider a car whose position <m>s</m> (in feet) at time <m>t</m> (in seconds) is given by the table: </p>
<table suppressTableNameInTitle="true">
<tabular top="minor" bottom="minor" left="minor" right="minor">
<row>
<cell><m>t</m> (sec)</cell>
<cell><m>0</m></cell>
<cell><math simplify>$a</math></cell>
<cell><math simplify>2$a</math></cell>
<cell><math simplify>3$a</math></cell>
<cell><math simplify>4$a</math></cell>
<cell><math simplify>5$a</math></cell>
</row>
<row>
<cell><m>s</m> (feet)</cell>
<cell><math simplify displayDigits="4">$$s(0)</math></cell>
<cell><math simplify displayDigits="4">$$s($a)</math></cell>
<cell><math simplify displayDigits="4">$$s(2$a)</math></cell>
<cell><math simplify displayDigits="4">$$s(3$a)</math></cell>
<cell><math simplify displayDigits="4">$$s(4$a)</math></cell>
<cell><math simplify displayDigits="4">$$s(5$a)</math></cell>
</row>
</tabular>
</table>
<p> <ol marker="a"> <li> <p> What are the units on the average velocity of the car? </p> <answer> <choiceInput name="choice1" inline> <choice>miles per hour</choice> <choice>feet</choice> <choice credit="1">feet per second</choice> <choice>seconds</choice> </choiceInput> </answer> </li> <li> <p>Find the average velocity of the car on the interval <m>0 \le t \le <math simplify>3*$a</math></m>. </p> </li> <answer allowedErrorInNumbers="0.05" allowedErrorIsAbsolute="true"> ($$s(3*$a)-$$s(0*$a))/(3$a) </answer> <!-- <math simplify displayDigits="8"> ($$s(3*$a)-$$s(0*$a))/(3$a) </math>, <math displayDigits="8"> ($$s(3*$a)-$$s(0*$a))/(3$a) </math> --> <li> <p> Find the average velocity of the car on the interval <m>[<math simplify>$c*$a</math>, <math simplify>($c+2)*$a</math>]</m>. </p> </li> <answer allowedErrorInNumbers="0.05" allowedErrorIsAbsolute="true"> ($$s(($c+2)*$a)-$$s($c*$a))/(2$a) </answer> </ol> </p>
</slate>
</interactive>
</statement>
</dynamic>
<static>
<introduction>
<p>
Consider a car whose position <m>s</m>
(in feet)
at time <m>t</m>
(in seconds)
is given by the table:
</p>
<!-- $a = 0.3, $$s(x) = 1.3*x^2 -->
<tabular top="minor" bottom="minor" left="minor" right="minor">
<row>
<cell><m>t</m> (sec)</cell>
<cell><m>0</m></cell>
<cell><m>0.3</m></cell>
<cell><m>0.6</m></cell>
<cell><m>0.9</m></cell>
<cell><m>1.2</m></cell>
<cell><m>1.5</m></cell>
</row>
<row>
<cell><m>s</m> (feet)</cell>
<cell><m>0</m></cell>
<cell><m>0.117</m></cell>
<cell><m>0.468</m></cell>
<cell><m>1.053</m></cell>
<cell><m>1.872</m></cell>
<cell><m>2.925</m></cell>
</row>
</tabular>
</introduction>
<task>
<statement>
<p>
What are the units on the average velocity of the car?
</p>
</statement>
<hint>
<p>
Consider possibilities such as
<q>feet</q>,
<q>seconds</q>,
<q>feet per second</q>, or
<q>seconds per foot</q>.
</p>
</hint>
<answer>
<p>
feet per second
</p>
</answer>
</task>
<task>
<statement>
<p>
Find the average velocity of the car on the interval <m>0 \le t \le 0.9</m>.
</p>
</statement>
<hint>
<p>
Recall that average velocity is
<q>change in position divided by change in time</q>.
</p>
</hint>
<answer>
<p>
The average velocity of the car on the interval
<m>0 \le t \le 0.9</m> is <m>1.17</m> feet per second.
</p>
</answer>
</task>
<task>
<statement>
<p>
<!-- $c = 3 --> Find the average velocity of the car on the interval <m>[0.9, 1.5]</m>.
</p>
</statement>
<answer>
<p>
The average velocity of the car on the interval
<m>[0.9,1.5]</m> is <m>3.12</m> feet per second.
</p>
</answer>
</task>
</static>
</exercise>
Checkpoint 3.28.7. OpenDSA List Insertion (Dual).
View Source for exercise
<exercise>
<title>OpenDSA List Insertion (Dual)</title>
<dynamic>
<statement>
<p>
Work this following problem.
Note that this is really just a test to see if additional text
(beyond an <tag>interactive</tag>)
will show up.
</p>
<interactive label="OpenDSA-list-insertion-exercise" iframe="https://opendsax.cs.vt.edu/OpenDSA/Exercises/List/AlistInsertPRO.html" width="100%"/>
</statement>
</dynamic>
<static>
<statement>
<p>
An exercise about array-based list insertion goes here.
</p>
</statement>
</static>
</exercise>
Work this following problem. Note that this is really just a test to see if additional text (beyond an
<interactive>) will show up.
This example recreates the Show-Eval visualization from the Runestone Components, using a PreTexT
<interactive>. It also records student activity using SPLICE.
It demonstrates how the Show-Eval tool can be used to visualize the evaluation of Python expressions step by step.
This could also be used for doing similar visualization of mathematical expressions. Support for MathJax would take some work, but this example would be a good starting point.
View Source for figure
<figure xml:id="show-eval-visualization1">
<caption>Show-Eval Visualization</caption>
<interactive label="show-eval-visualization" platform="javascript" source="https://runestone.academy/cdn/runestone/showEval-0.10.0.js" width="100%">
<slate surface="html">
<style>
.showEval { font-family: monospace; font-size: 1.5em; }
.showEval span { vertical-align: text-top; }
</style>
<button id="nextStep">Next Step</button>
<button id="reset">Reset</button>
<div class="showEval">eggs = ['dogs', 'cats', 'moose']</div>
<div id="showeval"/>
<script>
document.addEventListener("DOMContentLoaded", function() {
console.log("Document loaded");
// for each step, put the part to replaced in the first set of {{ }}, and the replacement text in the following {{ }}
steps = ["''.join({{eggs}}{{['dogs', 'cats', 'moose']}}).upper().join(eggs)",
"{{''.join(['dogs', 'cats', 'moose'])}}{{'dogscatsmoose'}}.upper().join(eggs)",
"{{'dogscatsmoose'.upper()}}{{'DOGSCATSMOOSE'}}.join(eggs)",
"'DOGSCATSMOOSE'.join({{eggs}}{{['dogs', 'cats', 'moose']}})",
"{{'DOGSCATSMOOSE'.join(['dogs', 'cats', 'moose'])}}{{'dogsDOGSCATSMOOSEcatsDOGSCATSMOOSEmoose'}}"];
s = new SHOWEVAL.ShowEval(document.querySelector('#showeval'), steps, false); });
</script>
</slate>
</interactive>
</figure>

