-
Notifications
You must be signed in to change notification settings - Fork 47
Types of Questions
This documentation is deprecated. For the latest version of the swirlify documentation please visit: http://swirlstats.com/swirlify
The swirlify package supports writing 8 types of questions. As discussed in Adding Questions to a Lesson questions are made up of key-value pairs. Many of these key-value pairs are shared between types of questions. Let's review the shared key-value pair types:
-
Class
- This key-value pair specifies the type of the question. The course author should not modify this.
-
Output
- The value of this key-value pair should be a string of text which is displayed to the student. This string usually asks a question to a student or instructs the student about how to answer the question. It's common to surround this string with quotation marks.
-
CorrectAnswer
- The swirl package provides a function called
skip()
which allows the student to skip a question by having swirl enter the correct answer for that question. ThereforeCorrectAnswer
is an R expression that should correspond to a correct answer to the question. TheCorrectAnswer
expression will be submitted to swirl if a student usesskip()
.
- The swirl package provides a function called
-
AnswerTests
- The value of this key-value pair is an R expression that must evaluate to
TRUE
if the answer to the question is correct orFALSE
is the answer to the question is incorrect. For a comprehensive understanding of how answer testing works executelibrary(swirl);?AnswerTests
in your R console. If you just want to start writing a swirl course as quickly as possible you should emulate the questions in Question Examples.
- The value of this key-value pair is an R expression that must evaluate to
-
Hint
- This key-value pair is very similar to
Output
. The value is a string of text that is only displayed to the student if their answer to the question is incorrect.
- This key-value pair is very similar to
There other key-value pairs that are specific to certain questions types and they will be discussed later in this document.
Examples of each question type can be seen in Question Examples.
Message questions display a string of text in the R console for the student to read. Once the student presses enter, swirl will move on to the next question.
Message questions can be appended to the end of a lesson.yaml
file with the
function wq_message()
which will append the following:
- Class: text
Output: put your text output here
Multiple choice questions (or multiple guess questions as my high school math teacher used to say) display a string of text in the R console for the student to read. The student is then presented with a number of choices where each choice is numbered. The student must enter the correct number into the R console to get the question right. If the student gets the question wrong the numbers and choices are shuffled and the student gets another attempt. There is no limit on the number of choices a course author can present to a student, but we recommend limiting the number of choices to six.
Multiple choice questions can be appended to the end of a lesson.yaml
file
with the function wq_multiple()
which will append the following:
- Class: mult_question
Output: ask the multiple choice question here
AnswerChoices: ANS;2;3
CorrectAnswer: ANS
AnswerTests: omnitest(correctVal= 'ANS')
Hint: hint
The AnswerChoices
key-value pair must be a collection of answer choices with
each choice separated by a semicolon.
This documentation is accurate for swirlify version 0.4.1. If you believe changes should be made to this document please open a new issue. The code contained in this documentation is MIT licensed. The content of this documentation is licensed CC BY 4.0.
- Welcome!
- Creating a New Course
- Creating a New Lesson in an Existing Course
- Resuming Work on a Lesson in an Existing Course
- Checking Which Lesson You're Working On