Skip to main content
How to create (parameterised) graphs in my exercise?
V
Written by Victoria Hobdale
Updated over a week ago

Two-dimensional line charts can be a great way to illustrate concepts and enable you to ask a wide array of questions. And by using parameters in the definition it is possible to create multiple exercises on the same concept without the need to create many charts by hand.


Even more interesting is to use the answer of the student to plot a line in a chart to provide visual feedback


In this article we explain how you can create these line charts.

What can you achieve?

With generated line charts you can achieve the following:

  • add charts to your exercise by simply typing math

  • create a parameterised chart by using parameterised functions

  • use the student's answer in charts to generate specific feedback based on the student's specific answer

  • add these charts in the description, question or feedback of an exercise

Below you can read more on how to create these graphs and what the options are.

How to add a graph to an exercise

A chart can be added in any editor field by following these steps

  1. Click at the location you want to add the chart (note: charts can only be added on a new empty line)

  2. Click on the floating "+ button" on the on the left side of the screen near the start of the line

  3. Click the line-chart icon in the menu

Available options

After you've added a chart you can configure the chart by adding lines or points, and defining labels and plot ranges. To do this, press the button to configure the graph contents:

This will show a modal which allows you to configure the graph:

Configuration options

At this moment the following options are available to configure the graph:

  • add / remove multiple items in the chart, available items are:

    • lines based on a formula

    • lines based on discrete data

    • points

    • parameterized lines based on formulas

  • change the colour of an item (available for all types)

  • change the line-style of an item (available for line / parameterized line items)

  • change the marker style of an item (available for line items and points)

  • define the label for each item (default the formula itself for lines, empty otherwise)

  • hide or show the item in the legend of the chart

On a chart level, the following options are available:

  • define the range of the x-axis and y-axis

  • define the label for each axes (default 'x' and 'y')

  • define the 'ticks' for both axes. These are the steps which are visible on the axis. Ticks can be defined in two ways:

    • a single number, which considered to be the step-size. For an axis ranging from -10 to 10, a step-size of 2 will mean ticks on [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10].

    • a list of ticks, which will be shown verbatim on the axis

  • whether to show either axis at all

  • hide or show the legend for items with a label

  • hide or show the grid in the chart

  • hide or show the origin lines in the chart

  • define the aspect ratio of the axis of the chart

    • a strict ratio of 1 means that each unit on the x-axis has the same number of pixels as a unit of the y-axis. Use this value to ensure that a circle is completely round

    • by default the ratio

  • set a caption for the chart, which will be shown underneath the chart

  • set an alternative text for the chart. This text is not visible, but is used by (for example) screenreader technology to explain what is shown on the chart.

Example configuration

In the example below we added two lines, label for the lines and changed the axis limits.


If you preview the exercise, you can see how the graph will look like when students will practice the exercise:

It is important to note that the line’s formula at the line settings must be written in terms of x. This means that if in your exercise, you want to present how position changes in terms of time for an object in constant velocity (v), and decide to have distance in the y-axis and time in the x-axis, the formula in the line settings should be v*x, and not v*t.

Size and position of the graph

To position the graph inside your exercise, there are several size and alignment options available:

  • specify whether the chart should be positioned on the left, in the middle, or on the right of the element in which you added the chart.

  • specify the width to be 50% (default) or 100% of the exercise

You can configure these options using the buttons in the top right corner of the graph:

Deleting a graph

You can only delete a graph by clicking the button "remove graph" in the top right corner. You can't delete a graph by using Backspace or Delete button.

Plotting the student's answer in a graph for feedback

You can plot the student's answer in the feedback, alongside other lines. To create such visual feedback, you have to use answer rules. Read more about how answer rules work here.


An example of this is shown below, where the green line is based on the student's answer.

To create a chart with the student's answer in the feedback, please take the following steps:

  1. Click "edit answers and specific feedback" at the bottom of the answer input field. This will open the specific feedback and answer rules options.

  2. Add a rule (see answer rules article for more detail) to determine when to show the feedback. In the example below the rule specifies "if the answer is not equivalent to 4" (but is defined)

  3. Add a chart as you've done in the exercise itself and configure it as you want.

  4. Use the answer parameter "student.answerX" to plot the answer of the student.

  5. Close the specific feedback window and save the exercise.

For the example exercise the answer rule and the feedback is shown below:

Where the graph would be configured as:

Do you want configure additional options?

At this point we are collecting feedback on this feature. If you have any questions about or feedback on this functionality, just let us know via the chat or email!

Did this answer your question?