 Build and Share Interactive Content - Maple Help

Home : Support : Online Help : System : Information : Updates : Maple 2022 : Build and Share Interactive Content

 Build and Share Interactive Content

Maple 2022 provides additional tools for creating documents and interactive applications programmatically. These tools can be used to develop Maple Learn content or to create applications to be used in Maple.  Maple Learn is a new online environment designed specifically for teaching and learning mathematics. Canvas Scripting

Maple 2022 greatly extends the tools for creating Canvas-based documents and interactive applications programmatically.

The Canvas package provides a framework for Maple users to easily build applications that can be used both in Maple and also shared on the web through Maple Learn.  These applications can gather user input and compute using standard Maple commands in either environment. Canvas Package The DocumentTools[Canvas] package builds on DocumentTools component primitives to provide a simple way to generate a grid layout of text and math.  It provides an easy mechanism to programmatically generate a page of math text and other elements.  New in Maple 2022 is the ability to add Sliders, 3-D Plots, Images, Hyperlinks, Line-Drawings, and many new options for controlling the display of math and text. 3-D Plot Example

 > with(DocumentTools:-Canvas):
 > cv := NewCanvas([      Text("Volume of Revolution",fontsize=24),      "This solid of revolution is created by rotating",      f(x) = cos(x) + 1,      Text("about the y=0 axis on the interval %1",(0 <= x) and (x <= 4*Pi)),      Plot3D( "Student:-Calculus1:-VolumeOfRevolution(cos(x) + 1, x = 0 .. 4*Pi, output = plot, caption=)"  )  ]):
 > ShowCanvas(cv);  Image Example

In this example we embed an image in the canvas.
Note: To execute this code you must be logged into the MapleCloud; see the Image command's help page for details.

 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Canvas}\right):$
 > $\mathrm{file}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/antennas.jpg"\right):$
 > $\mathrm{cv}≔\mathrm{NewCanvas}\left(\left["Sample Image",\mathrm{Image}\left(\mathrm{file}\right)\right]\right):$
 > $\mathrm{ShowCanvas}\left(\mathrm{cv}\right)$ The ShareCanvas command sends the canvas to Maple Learn and gives you a link to your document.

 > $\mathrm{ShareCanvas}\left(\mathrm{cv}\right)$ Interactive Example

In this example, we will define an application that allows user input and provides feedback.  The UpdateStats procedure will run when a button is pressed.  It will use the new GetElements command to extract specific pieces of the canvas, including an array of points as input to analyze, and named elements so they can be replaced with updated values.

 > $\mathrm{ShowCanvas}\left(\mathrm{cv}\right)$   To try this on the web using Maple Learn, execute:

 > ShareCanvas(cv); On-Click Events

The Plot element has a new "onclick" option, and the Button element has a new "onmoved" option.  These can be used to react to events such as clicking on a plot or moving an image on a canvas.  There is also a new hidden State element, which can be used to record behind the scenes values that don't need to be visible in the canvas.

In this example the user is asked to click on a plot to add points.  When 2 or more points are set, the application will find a polynomial curve fit approximation and draw that on the plot too.

 > $\mathrm{ShowCanvas}\left(\mathrm{cv},\mathrm{entrybox}=\mathrm{false}\right);$ > ShareCanvas(cv); Help with Math Problems

The new IntPractice and DiffPractice commands extend the algorithm behind SolveFeedback to handle integrals and derivatives.

 > $\mathrm{with}\left(\mathrm{Grading}\right):$
 >  This interactive example can also be shared via Maple Learn: Canvas-based Quizzes

The Quiz command now has an option to supply a solution.  The quiz question, verifier, new-problem generator and solution can return a canvas, which can be deployed to Maple Learn.

 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Canvas}\right):$
 >   > $\mathrm{ShareCanvas}\left(\mathrm{cv}\right);$