There are roughly 5 exercise types available to you as an author on DataCamp Mobile:
|Select Output||What is the output of this code? Console output|
|Select Table||What is the output of this code? Formatted table output|
|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:
- distractor_output -> Select Output
- distractor_table -> Select Table
- distractor_code -> Select Code
- distractor_blanks -> Tap
- distractor_text -> Multiple Choice
The only exercise type that does not require a distractor field is the Reorder exercise.
Let's dig into each of the blocks...
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.
This is a unique UUID for the exercise. You can find some tips for working with/generating UUIDs here.
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!
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.
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.
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.
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
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.
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
Other available blocks
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
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".
You can insert an image block into your exercise simply by specifying the path to a PNG file. 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.
context block can be more complex than a simple string. Sometimes you need
to introduce a table, image, multi-line code snippet, or output in the context,
before the question block. This really starts to stretch the limits of what
can be displayed on a single screen, so simple text context should always be
For example, to include an image such as a plot:
context: text: Study the plot below to answer the following question. image: assets/images/my-cool-plot.png
To include a table:
context: text: Study the table below to answer the following question. table: |- foo, bar, baz 1 ,2 ,3 4 ,5 ,6
feedback field is the message that is displayed when a student gets the
exercise correct. These aren't required. In fact, you should never put any
critical pedagogical information here. If you want to put in a message of
encouragement or jubilation however, feel free!
feedback_wrong: "Don't forget that R is 1-indexed, not 0-indexed like Python."
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.
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
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
table are supported.
Summary of available blocks
|Block||Reorder||Tap||Select Code||Select Output||Select Table||Multiple Choice|