Mobile exercises

There are roughly 5 exercise types available to you as an author on DataCamp Mobile:

Type Description
Select Output What is the output of this code?
Select Table What is the output of this code? (When the output is a table, eg for SQL)
Select Code Select the code to return the output.
Tap Complete the code to return the output.
Multiple Choice Answer the multiple choice question.
Reorder Reorder the code to return the output.

...but they all share a similar structure. In general, you can think of an exercise as a short code vignette comprising various blocks in the following sequence:

# print()
-  key: # generate me!
  context: "`print()` outputs to the screen. Whatever you put between the parentheses will be output! E.g. `print(5)` will output `5`!"
  question: "What is the output of this code?" # this is the default
  code: "print(42)"
  output: "42"
  distractor_output:
    - option: "4"
      feedback: "`print()` will output all of whatever is between the parentheses, not just the first part."
    - option: "2"
      feedback: "`print()` will output all of whatever is between the parentheses, not just the last part."

In the example above, the use of the distractor_output field indicates this exercise will be a Select Output exercise. Other distractor types will result in different exercise types:

The only exercise type that does not require a distractor field is the Reorder exercise.

Let's dig into each of the blocks...

topic

# print()

Even though it's not part of the exercise itself, it's a good idea to comment your exercises so you can quickly remind yourself what each exercise is designed to teach or test. In fact, it can be helpful to start by outlining a whole lesson with a scaffolding of comments before expanding the exercises.

key

key: c11dbdf1-49c9-408a-a1e4-885431af2196

This is a unique UUID for the exercise. You can find some tips for working with/generating UUIDs here.

context

context: "`print()` outputs to the screen. Whatever you put between the parentheses will be output! E.g. `print(5)` will output `5`!"

This is where you can provide exposition necessary to introduce a new concept. It should be kept as minimal as possible (no longer than 150 characters). It's good to shoot for a lighter, more informal feel here than on desktop. This field supports markdown elements like inline code and emboldening. Emojis are not just supported, they're encouraged!

Guideline Min Reco Min Reco Max Max
Characters in an context block 0 0 100 150

question

question: "" # this is the default

This field is always optional. It will override the default question for the relevant exercise type. You can see the default question for each exercise type in the table above. Don't change this unless you absolutely need to for an exercise to make sense.

code

code: "print(42)"

This is the code! Anything you here should be syntactically correct, executable code. The format of the code block can vary slightly for different exercise types, for example reorder and tap exercises. See the documentation for those exercise types to get the details.

Guideline Min Reco Min Reco Max Max
Characters in a code block 0 0 30 60
Characters in one line of code block 1 1 30 40
Lines in a code block 1 1 6 8

output

output: "42"

This is the output generated by the code in a code block. That means anything that would get printed to the console in an interactive Python or R terminal session.

Guideline Min Reco Min Reco Max Max
Characters in one line of an output block 1 1 30 40
Lines in an output block 1 1 4 6

distractors

distractor_output:
  - option: "4"
    feedback: "`print()` will output all of whatever is between the parentheses, not just the first part."
  - option: "2"
    feedback: "`print()` will output all of whatever is between the parentheses, not just the last part."

Regardless of the exercise type, the distractor field is always a list of distractors (AKA wrong answers). Each individual distractor in the list has two elements: option, the incorrect answer itself, and feedback, the feedback message that students will see if they incorrectly choose that distractor. Try not to ask questions or use exclamation marks in feedback messages - they should be clear but not aggressive.

Note

The distractors are one of the most important pieces of a mobile exercise. Not only does the distractors block determine the rendered exercise type, but an effective mobile exercise predicts the mistakes that a student is likely to make, and then provides useful feedback explaining why that distractor is wrong!

Reorder and Tap exercises in particular have special requirements. Refer to the documentation pages of those exercise types for more information.

Other available blocks

table

table:
  data: |-
    name,birthdate
    50 Cent,1975-07-06
    Aaliyah,1979-01-16
    Aaron Yoo,1979-05-12
  message: "Showing 3 out of 537 rows"

You can opt to use a table block instead of an output block, for example when displaying the output of a SQL query, which is more appropriate as a table. A table field has two subfields. First is data, which contains the actual table data as comma separated values. They needn't be aligned, but they can be and sometimes this improves readability. The second is message, which contains a short string of text that is displayed in the footer of the table. The most common use for the table message is to indicate row truncation, because tables should not be displayed with more than 5 rows as a general rule. If you are truncating the result, the message field is mandatory, otherwise it is not. The standard format for indicating truncation is the one featured in the example above: "Showing n out of N rows".

Guideline Min Reco Min Reco Max Max
Number of rows in a table block 1 1 5 5
Sum of the maximum number of characters in each column of a table block 0 0 10 10

image

image: assets/images/my-cool-plot.png

You can insert an image block into your exercise simply by specifying the path to a PNG file. The image will be placed below the question. This is useful when teaching things like plotting. Be mindful of image asset size, because these images will be downloaded to students' phones, often over a cellular data connection.

Example image

context image

context:
  text: "Below is a line plot of life expectancy for different countries against their GDP per capita."
  image: assets/gdp-life-line.png

If you want your image to appear above the question, you can use a multi-part context block rather than a simple text one. To do so, put the text of your context into a subfield called text, and then add nest image field into context as well, as demonstrated above.

Example context image

feedback_wrong

feedback_wrong: "Don't forget that R is 1-indexed, not 0-indexed like Python."

The feedback_wrong field is the fallback feedback message when a particular distractor hasn't been supplied with one. Usually, you should be giving specific feedback for each individual distractor, because specific, enlightening feedback messages are one of the most effective ways of teaching on DataCamp for Mobile. If you find that the same feedback message is appropriate for multiple distrators, however, this field is provided for convenience.

An example of a feedback message

Guideline Min Reco Min Reco Max Max
Characters in feedback 1 1 30 60

tabs

tabs:
  - key: people
    type: table

Tabs appear in the top right of the exercise and serve as a way to display datasets or files. The appropriate asset must be defined in the assets section of the course manifest. A tab field has two subfields: key, which is the alias for the asset as defined in the manifest, and type, which specifies how to render the asset. Currently only file and table are supported.

An example of a dataset rendered as a table:

A tab from the exercise screen Opened dataset tab

An example of a rendered file tab:

Opened file tab

Guideline Min Reco Min Reco Max Max
Tabs in an exercise 0 0 2 3

Summary of available blocks

:ok: Allowed

:heavy_check_mark: Required

:x: Not Allowed

Block Reorder Tap Select Code Select Output Select Table Multiple Choice
key :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
tabs :ok: :ok: :ok: :ok: :ok: :ok:
context :ok: :ok: :ok: :ok: :ok: :ok:
question :ok: :ok: :ok: :ok: :ok: :heavy_check_mark:
image :ok: :ok: :ok: :ok: :ok: :ok:
code :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :ok: :ok: :ok:
output :ok: :ok: :ok: :heavy_check_mark: :ok: :ok:
table :ok: :ok: :ok: :ok: :heavy_check_mark: :ok:
distractor_blanks :x: :heavy_check_mark: :x: :x: :x: :x:
distractor_code :x: :x: :heavy_check_mark: :x: :x: :x:
distractor_output :x: :x: :x: :heavy_check_mark: :x: :x:
distractor_table :x: :x: :x: :x: :heavy_check_mark: :x:
distractor_text :x: :x: :x: :x: :x: :heavy_check_mark:
feedback :ok: :ok: :ok: :ok: :ok: :ok:
feedback_wrong :ok: :ok: :ok: :ok: :ok: :ok:

results matching ""

    No results matching ""