10.25. Multiple Choice Problem

Note

EdX offers full support for this problem type.

The multiple choice problem type is a core problem type that can be added to any course. At a minimum, multiple choice problems include a question or prompt and several answer options. By adding hints, feedback, or both, you can give learners guidance and help when they work on a problem.

For more information about the core problem types, see Working with Problem Components.

10.25.1. Overview

In multiple choice problems, learners select one option from a list of answer options. Unlike dropdown problems, where the answer choices do not appear until the learner selects the dropdown arrow, answer choices for multiple choice problems are immediately visible directly below the question.

Multiple choice problems can also have several advanced options, such as reordering, or shuffling, the set of answer choices for each learner. For more information about these options, see Advanced Options for Multiple Choice Problems.

10.25.1.1. Example Multiple Choice Problem

In the LMS, learners select a single answer option to complete a multiple choice problem. An example of a completed multiple choice problem follows.

An incorrectly answered multiple choice problem shown in the LMS. One of the answer options was incorrectly selected. An explanation appears below the answer options.

To add the example problem illustrated above, you enter the following text and Markdown formatting in the simple editor in Studio.

>>Lateral inhibition, as was first discovered in the horseshoe crab:<<

( ) is a property of touch sensation, referring to the ability of crabs
to detect nearby predators.
( ) is a property of hearing, referring to the ability of crabs to detect
low frequency noises.
(x) is a property of vision, referring to the ability of crabs' eyes to
enhance contrasts.
( ) has to do with the ability of crabs to use sonar to detect fellow
horseshoe crabs nearby.
( ) has to do with a weighting system in the crab's skeleton that allows
it to balance in turbulent water.

[Explanation]
Horseshoe crabs were essential to the discovery of lateral
inhibition, a property of vision present in horseshoe crabs as well as in
humans that enables enhancement of contrast at edges of objects as was
demonstrated in class. In 1967, Haldan Hartline received the Nobel prize
for his research on vision and in particular his research investigating
lateral inhibition using horseshoe crabs.
[Explanation]

The open learning XML (OLX) markup for this example problem follows.

<problem>
  <multiplechoiceresponse>
    <label>Lateral inhibition, as was first discovered in the horseshoe crab:</label>
    <choicegroup type="MultipleChoice">
      <choice correct="false">is a property of touch sensation, referring to
       the ability of crabs to detect nearby predators.</choice>
      <choice correct="false">is a property of hearing, referring to the
       ability of crabs to detect low frequency noises.</choice>
      <choice correct="false">is a property of vision, referring to the
       ability of crabs' eyes to enhance contrasts.</choice>
      <choice correct="true">has to do with the ability of crabs to use
       sonar to detect fellow horseshoe crabs nearby.</choice>
      <choice correct="false">has to do with a weighting system in the
       crab's skeleton that allows it to balance in turbulent water.</choice>
    </choicegroup>
    <solution>
      <div class="detailed-solution">
        <p>Explanation</p>
        <p>Horseshoe crabs were essential to the discovery of lateral
         inhibition, a property of vision present in horseshoe crabs as well
         as humans that enables enhancement of contrast at edges of objects
         as was demonstrated in class. In 1967, Haldan Hartline received the
         Nobel prize for his research on vision and in particular his
         research investigating lateral inhibition using horseshoe crabs.</p>
      </div>
    </solution>
  </multiplechoiceresponse>
</problem>

10.25.1.2. Analyzing Performance on Multiple Choice Problems

For the multiple choice problems in your course, you can use edX Insights to review aggregated learner performance data and examine the submitted answers. For more information, see Using edX Insights.

10.25.1.3. Pedagogical Considerations for Multiple Choice Questions

EdX recommends the use, whenever possible, of authentic assessment rather than multiple choice questions for graded problems. The use of authentic assessment in online courses tends to lead to better learning outcomes. In addition, authentic assessment allows for infinite attempts, mastery learning, and more intellectual risk taking, which lead to substantially better learning outcomes.

Multiple choice questions do have these uses.

  • Ungraded multiple choice questions can help students think about a concept in the context of knowledge transfer.
  • For many subject areas, authentic assessments are either unavailable or prohibitively complex to use. In such courses, multiple choice questions can act as the only available fall back.

Fortunately, multiple choice questions are among the best studied in assessment literature. A few guidelines for the creation of such questions follow.

  • Organize the set of answers logically. Use consistent phrasing for the answers, and when possible, parallel structure.
  • Place as many of the words in the stem as possible, and keep the answers as concise as possible.
  • The distractors should not be substantially shorter, longer, or use different structure than the correct answer. The answer options should be as consistent in structure, length, and phrasing as possible.
  • Avoid using negatives (and especially double negatives) in the question and the answers.
  • Test higher order thinking (comprehension and critical thinking). Avoid simple recall.
  • If you specify a finite number of attempts, avoid trick questions and try to keep wording clear and unambiguous.
  • Make all distractors plausible.
  • Use “All of the above” and “None of the above” answer options with caution. If a learner can identify at least two correct answers, it can give away the answer with only partial comprehension.

10.25.2. Adding a Multiple Choice Problem

You add multiple choice problems in Studio by selecting the Problem component type and then using either the simple editor or the advanced editor to specify the prompt and the answer options.

Note

You can begin work on the problem in the simple editor, and then switch to the advanced editor. However, after you save any changes you make in the advanced editor, you cannot switch back to the simple editor.

10.25.2.1. Use the Simple Editor to Add a Multiple Choice Problem

When you add a multiple choice problem, you can choose one of these templates.

  • Multiple Choice
  • Multiple Choice with Hints and Feedback

These templates include the Markdown formatting that you use in the simple editor to add a problem without, or with, hints and feedback.

To use the simple editor to add a problem, follow these steps.

  1. In the unit where you want to create the problem, under Add New Component select Problem.

  2. From the list of Common Problem Types, select the type of problem you want to add. Studio adds a template for the problem to the unit.

  3. Select Edit. The simple editor opens to a template that shows the Markdown formatting that you use for this problem type.

  4. Replace the guidance provided by the template to add your own text for the question or prompt, answer options, explanation, and so on.

    To format equations, you can use MathJax. For more information, see Using MathJax for Mathematics.

  5. Select Settings to provide an identifying Display Name and define settings for the problem. For more information, see Defining Settings for Problem Components.

  6. Select Save.

10.25.2.2. Use the Advanced Editor to Add a Multiple Choice Problem

You can use the advanced editor to identify the elements of a multiple choice problem with OLX. For more information, see Multiple Choice Problem OLX Reference.

To use the advanced editor to add a problem, follow these steps.

  1. Follow steps 1-3 for creating the problem in the simple editor.

  2. Select Advanced Editor. The advanced editor opens the template and shows the OLX markup that you can use for this problem type.

  3. Replace the guidance provided by the template to add your own text. For example, replace the question or prompt, answer options, and explanation.

    To format equations, you can use MathJax. For more information, see Using MathJax for Mathematics.

  4. Update the OLX to add optional elements and attributes required for your problem.

  5. Select Settings to provide an identifying Display Name and define settings for the problem. For more information, see Defining Settings for Problem Components.

  6. Select Save.

10.25.3. Adding Feedback to a Multiple Choice Problem

For an overview of feedback in problems, see Adding Feedback and Hints to a Problem. You can add feedback for each of the answer options you provide in the problem. Use the following guidelines when providing feedback.

  • Add feedback to incorrect answers to target common misconceptions and mistakes.
  • Ensure feedback provides some guidance to the learner about how to arrive at the correct answer.
  • Add feedback for the correct answer to reinforce why the answer is correct. Because learners are able to guess, ensure that feedback provides a reason why the answer is correct for learners who might have selected that answer by chance.

You can add feedback in a multiple choice problem using the simple editor or the advanced editor.

10.25.3.1. Configuring Feedback in the Simple Editor

You can configure feedback in the simple editor. When you add a multiple choice problem, select the template Multiple Choice with Hints and Feedback. This template has example feedback syntax that you can replace.

( ) answer {{Feedback for learners who select this answer.}}

For example, the following problem has feedback for every answer option.

>>Which of the following is an example of a vegetable?||You can select only one option.<<

( ) apple {{An apple is the fertilized ovary that comes from an apple tree
and contains seeds classifying it as a fruit.}}
( ) pumpkin {{A pumpkin is the fertilized ovary of a squash plant and
contains seeds classifying it as a fruit.}}
(x) potato {{A potato is an edible part of a plant in tuber form and is
classified as a vegetable}}
( ) tomato {{Many people mistakenly think a tomato is a vegetable. However,
because a tomato is the fertilized ovary of a tomato plant and contains
seeds it is classified as a fruit.}}

10.25.3.2. Configuring Feedback in the Advanced Editor

In the advanced editor, you configure feedback with the following syntax.

<choice correct="false">Choice Label
  <choicehint>Feedback for when learner selects this answer.</choicehint>
</choice>

For example, the following problem has feedback for each answer.

<problem>
  <multiplechoiceresponse>
    <label>Which of the following is an example of a vegetable?</label>
    <description>You can select only one option.</description>
    <choicegroup type="MultipleChoice">
      <choice correct="false">apple
        <choicehint>An apple is the fertilized ovary that comes from an apple
         tree and contains seeds classifying it as a fruit.</choicehint>
      </choice>
      <choice correct="false">pumpkin
        <choicehint>A pumpkin is the fertilized ovary of a squash plant
         and contains seeds classifying it as a fruit.</choicehint>
      </choice>
      <choice correct="true">potato
        <choicehint>A potato is an edible part of a plant in tuber form and
         is classified as a vegetable.</choicehint>
      </choice>
      <choice correct="false">tomato
        <choicehint>Many people mistakenly think a tomato is a vegetable.
         However, because a tomato is the fertilized ovary of a tomato plant
         and contains seeds it is classified as a fruit.</choicehint>
      </choice>
    </choicegroup>
  </multiplechoiceresponse>
</problem>

10.25.3.3. Customizing Feedback Labels

By default, the feedback labels shown to learners are Correct and Incorrect. If you do not define feedback labels, learners see these terms when they submit an answer, as in the following example.

Incorrect: A pumpkin is the fertilized ovary of a squash plant and contains
seeds classifying it as a fruit.

You can configure the problem to override the default labels. For example, you can configure a custom label for a specific wrong answer.

Not Quite: Many people mistakenly think a tomato is a vegetable. However,
because a tomato is the fertilized ovary of a tomato plant and contains seeds
it is classified as a fruit.

Note

The default labels Correct and Incorrect display in the learner’s requested language. If you provide custom labels, they display as you define them to all learners. They are not translated into different languages.

10.25.3.3.1. Customize Feedback Labels in the Simple Editor

In the simple editor, you configure custom feedback labels with the following syntax.

( ) Answer {{Label:: Feedback for learners who select this answer.}}

That is, you provide the label text, followed by two colon (:) characters, before the feedback text.

For example, the following feedback is configured to use a custom label.

( ) tomato {{Not Quite:: Many people mistakenly think a tomato is a
vegetable. However, because a tomato is the fertilized ovary of a tomato
plant and contains seeds, it is a fruit.}}

10.25.3.3.2. Customize Feedback Labels in the Advanced Editor

In the advanced editor, you configure custom feedback labels with the following syntax.

<choice correct="true or false">Answer
  <choicehint label="Custom Label">Feedback for learners who select this
   answer.</choicehint>
</choice>

For example, the feedback for the following answer option is configured to use a custom label.

<choice correct="false">tomato
  <choicehint label="Not Quite">Many people mistakenly think a tomato is a
   vegetable. However, because a tomato is the fertilized ovary of a tomato
   plant and contains seeds, it is a fruit.</choicehint>
</choice>

10.25.4. Adding Hints to a Multiple Choice Problem

You can add hints to a multiple choice problem using the simple editor or the advanced editor. For an overview of hints in problems, see Adding Feedback and Hints to a Problem.

10.25.4.1. Configure Hints in the Simple Editor

In the simple editor, you configure hints with the following syntax.

||Hint 1||
||Hint 2||
||Hint n||

Note

You can configure any number of hints. The learner views one hint at a time and views the next one by selecting Hint again.

For example, the following problem has two hints.

||A fruit is the fertilized ovary from a flower.||
||A fruit contains seeds of the plant.||

10.25.4.2. Configure Hints in the Advanced Editor

In the advanced editor, you add the <demandhint> element immediately before the closing </problem> tag, and then configure each hint using the <hint> element.

.
.
.
<demandhint>
  <hint>Hint 1</hint>
  <hint>Hint 2</hint>
  <hint>Hint 3</hint>
</demandhint>
</problem>

For example, the following OLX for a multiple choice problem shows two hints.

.
.
.
</multiplechoiceresponse>
<demandhint>
  <hint>A fruit is the fertilized ovary from a flower.</hint>
  <hint>A fruit contains seeds of the plant.</hint>
</demandhint>
</problem>

10.25.5. Awarding Partial Credit in a Multiple Choice Problem

You can configure a multiple choice problem so that specific incorrect answers award learners partial credit for the problem. You must use the advanced editor to configure partial credit.

In the following example, the learner selected a wrong answer and received partial credit.

A multiple choice problem with partial credit for an incorrect answer.

You can specify what percentage of the points for the problem a learner receives for an incorrect answer. If you do not specify the percentage, the system uses the default of 50%.

For an overview of partial credit in problems, see Awarding Partial Credit for a Problem.

10.25.5.1. Configure a Multiple Choice Problem to Award Partial Credit

To configure a multiple choice problem to award partial credit for a specific answer, you add the following attributes to the problem OLX.

  • Add the partial_credit="points" attribute to the <multiplechoiceresponse> element.
  • For each answer that you intend to award partial credit, in the <choice> element set the value of the correct attribute to "partial".
  • Optionally, define the percentage of the problem score to award for each answer. Add the point_value attribute to the <choice> element, and enter its value as a decimal. For example, add point_value="0.25" to award 25% of the points to learners who select that answer. The percentage awarded should reflect how close the learner has gotten to a full understanding of the concept. If you do not add the point_value attribute, the system uses the default of 50%.

For example, the following OLX shows a multiple choice problem that provides partial credit of 25% for an answer option.

<problem>
  <multiplechoiceresponse partial_credit="points">
    <label>Which of the following is a vegetable?</label>
    <choicegroup type="MultipleChoice">
      .
      .
      .
      <choice correct="partial" point_value="0.25">tomato </choice>
    </choicegroup>
  </multiplechoiceresponse>
</problem>

10.25.6. Multiple Choice Problem OLX Reference

Note

You can also set attributes and options by adding a <script> element. For more information, see Using the Script Element.

10.25.6.1. Template

<problem>
  <multiplechoiceresponse>
    <label>Question or prompt text</label>
    <description>Optional information about how to answer the question</description>
    <choicegroup type="MultipleChoice">
      <choice correct="false" name="a">Incorrect choice
        <choicehint>Hint for incorrect choice.</choicehint>
      </choice>
      <choice correct="true" name="b">Correct choice
        <choicehint>Hint for correct choice.</choicehint>
      </choice>
    </choicegroup>
    <solution>
      <div class="detailed-solution">
        <p>Optional header for the explanation or solution</p>
        <p>Optional explanation or solution text</p>
      </div>
    </solution>
  </multiplechoiceresponse>
<demandhint>
  <hint>Hint 1</hint>
  <hint>Hint 2</hint>
</demandhint>
</problem>

10.25.6.2. Elements

For multiple choice problems, the <problem> element can include this hierarchy of child elements.

<multiplechoiceresponse>
    <label>
    <description>
    <choicegroup>
          <choice>
              <choicehint>
    <solution>
<demandhint>
    <hint>

In addition, standard HTML tags can be used to format text.

10.25.6.2.1. <multiplechoiceresponse>

Required. Indicates that the problem is a multiple choice problem.

10.25.6.2.1.1. Attributes
Attribute Description
partial_credit Optional. Specifies that the problem can award partial credit. If used, must be set to "points".
10.25.6.2.1.2. Children
  • <label>
  • <description>
  • <choicegroup>
  • <solution>

10.25.6.2.2. <label>

Required. Identifies the question or prompt. You can include HTML tags within this element.

10.25.6.2.2.1. Attributes

None.

10.25.6.2.2.2. Children

None.

10.25.6.2.3. <description>

Optional. Provides clarifying information about how to answer the question. You can include HTML tags within this element.

10.25.6.2.3.1. Attributes

None.

10.25.6.2.3.2. Children

None.

10.25.6.2.4. <choicegroup>

Required. Indicates the beginning of the list of answer options.

10.25.6.2.4.1. Attributes
Attribute Description
type Required. Must be set to "MultipleChoice".

Additional attributes are available to support advanced options.

10.25.6.2.4.2. Children

<choice>

10.25.6.2.5. <choice>

Required. Lists an answer option.

10.25.6.2.5.1. Attributes
Attribute Description
correct

Indicates a correct, incorrect, or partially correct answer.

  • When set to "true", the choice is a correct answer. At least one required.
  • When set to "false", the choice is an incorrect answer.
  • When set to "partial", the learner receives partial credit for selecting the answer.

You can specify more than one correct or partially correct answer, but learners can select only one choice to submit as their answer.

point_value When correct="partial", indicates the percentage, as a decimal, of the points the learner receives for selecting this option. If point_value is not specified for a partial credit answer, 50% is used by default.
name A unique name that is used internally to refer to the choice.

Additional attributes are available to support advanced options.

10.25.6.2.5.2. Children

<choicehint>

10.25.6.2.6. <choicehint>

Optional. Specifies feedback for the answer.

10.25.6.2.6.1. Attributes

None.

10.25.6.2.6.2. Children

None.

10.25.6.2.7. <solution>

Optional. Identifies the explanation or solution for the problem, or for one of the questions in a problem that includes multiple questions.

This element contains an HTML division <div>. The division contains one or more paragraphs <p> of explanatory text.

10.25.6.2.8. <demandhint>

Optional. Specifies hints for the learner. For problems that include multiple questions, the hints apply to the entire problem.

10.25.6.2.8.1. Attributes

None.

10.25.6.2.8.2. Children

<hint>

10.25.6.2.9. <hint>

Required. Specifies additional information that learners can access if needed.

10.25.6.2.9.1. Children

None.

10.25.7. Advanced Options for Multiple Choice Problems

Multiple choice problems have several advanced options. You can change the order of answers in the problem, include explanations that appear when a learner selects a specific incorrect answer, or present a random set of choices to each learner. For more information, see the following sections.

10.25.7.1. Shuffle Answers in a Multiple Choice Problem

Optionally, you can configure a multiple choice problem so that it shuffles the order of possible answers.

For example, one view of a problem could be as follows.

What Apple device competed with the portable CD player?

( ) The iPad
( ) Napster
( ) The iPod
( ) The vegetable peeler

Another view of the same problem, for a different learner or for the same learner on a subsequent view of the unit, could be as follows.

What Apple device competed with the portable CD player?

( ) The iPad
( ) The iPod
( ) The vegetable peeler
( ) Napster

You can also shuffle some answers, but not others. For example, you might want to include the answer “All of the above” and have it always appear at the end of the list, but shuffle the other answers.

You can configure the problem to shuffle answers using the simple editor or advanced editor. To shuffle the answers, you also edit the problem to set Randomization to a value other than Never. For more information, see Randomization.

10.25.7.1.1. Use the Simple Editor to Shuffle Answers

You can configure the problem to shuffle answers in the simple editor. To add shuffling to this problem, you add an exclamation point character ! between the parentheses formatting for the first answer option.

>>What Apple device competed with the portable CD player?<<
    (!) The iPad
    ( ) Napster
    (x) The iPod
    ( ) The vegetable peeler

To make the location of an answer fixed in a shuffled list, add @ between the parentheses formatting for that answer.

>>What Apple device competed with the portable CD player?<<
    (!) The iPad
    ( ) Napster
    (x) The iPod
    ( ) The vegetable peeler
    (@) All of the above

You can combine symbols within the parentheses as necessary. For example, to show the correct answer in a fixed location, you can use both x and @.

(x@) The iPod

After you complete problem setup in the simple editor, select Edit and then Settings to specify an option other than Never for the Randomization setting.

10.25.7.1.2. Use the Advanced Editor to Shuffle Answers

You can configure the problem to shuffle answers by editing the OLX in the advanced editor.

To add shuffling to a problem, you add shuffle="true" to the <choicegroup> element.

<problem>
  <multiplechoiceresponse>
    <label>What Apple device competed with the portable CD player?</label>
    <choicegroup type="MultipleChoice" shuffle="true">
      <choice correct="false">The iPad</choice>
      <choice correct="false">Napster</choice>
      <choice correct="true">The iPod</choice>
      <choice correct="false">The vegetable peeler</choice>
    </choicegroup>
  </multiplechoiceresponse>
</problem>

To make the location of an answer fixed in a shuffled list, add fixed="true" to the choice element for the answer.

<problem>
  <multiplechoiceresponse>
    <label>What Apple device competed with the portable CD player?</label>
    <choicegroup type="MultipleChoice" shuffle="true">
      .
      .
      .
      <choice correct="false" fixed="true">All of the above</choice>
    </choicegroup>
  </multiplechoiceresponse>
</problem>

Then, you select Settings to specify an option other than Never for the Randomization setting.

10.25.7.2. Targeted Feedback in a Multiple Choice Problem

You can configure a multiple choice problem so that explanations for specific answers are automatically shown to learners. You can use these explanations to guide learners towards the right answer. Therefore, targeted feedback is most useful for multiple choice problems for which learners are allowed multiple attempts.

10.25.7.2.1. Use the Advanced Editor to Configure Targeted Feedback

You configure the problem to provide targeted feedback by editing the OLX in the advanced editor.

  • Add a targeted-feedback attribute to the <multiplechoiceresponse> element, with no value: <multiplechoiceresponse targeted-feedback="">.
  • Add an explanation-id attribute with a unique value to each of the <choice> elements: <choice correct="false" explanation-id="feedback1">.
  • You can use the <solution> element for the correct answer.
  • Add a <targetedfeedbackset> element after the <multiplechoiceresponse> element.
  • Within <targetedfeedbackset>, add one or more <targetedfeedback> elements.
  • Within each <targetedfeedback> element, add one of the unique identifying explanation-id attributes to map that feedback to a specific answer choice.
  • Within each <targetedfeedback> element use HTML formatting, such as <p></p> tags, to enter your explanation for the specified answer option.

For example, the OLX for a multiple choice problem follows, showing a unique ID for each answer choice. This is immediately followed by OLX that defines the targeted feedback.

<problem>
  <multiplechoiceresponse targeted-feedback="">
    <label>What Apple device competed with the portable CD player?</label>
    <choicegroup type="MultipleChoice">
      <choice correct="false" explanation-id="feedback1">The iPad</choice>
      <choice correct="false" explanation-id="feedback2">Napster</choice>
      <choice correct="true" explanation-id="correct">The iPod</choice>
      <choice correct="false" explanation-id="feedback3">The vegetable peeler</choice>
    </choicegroup>
    <solution explanation-id="correct">
      <div class="detailed-solution">
        <p>The iPod directly competed with portable CD players.</p>
      </div>
    </solution>
  </multiplechoiceresponse>
  <targetedfeedbackset>
    <targetedfeedback explanation-id="feedback1">
      <div class="detailed-targeted-feedback">
        <p>Targeted Feedback</p>
        <p>The iPad came out later and did not directly compete with
         portable CD players.</p>
       </div>
    </targetedfeedback>
    <targetedfeedback explanation-id="feedback2">
      <div class="detailed-targeted-feedback">
        <p>Targeted Feedback</p>
        <p>Napster was not an Apple product.</p>
      </div>
    </targetedfeedback>
    <targetedfeedback explanation-id="feedback3">
      <div class="detailed-targeted-feedback">
        <p>Targeted Feedback</p>
        <p>Vegetable peelers do not play music.</p>
      </div>
    </targetedfeedback>
  </targetedfeedbackset>
</problem>

10.25.7.3. Answer Pools in a Multiple Choice Problem

You can configure a multiple choice problem so that a random subset of choices are shown to each learner. For example, you can add 10 possible choices to the problem, and each learner views a set of five choices.

The answer pool must have at least one correct answer. It can have more than one correct answer. In each set of choices shown to a learner, one correct answer is included. For example, you can configure two correct answers in the set of choices. One of the two correct answers is included in each set that a learner views.

10.25.7.3.1. Use the Advanced Editor to Configure Answer Pools

You configure the problem to provide answer pools by editing the OLX for the problem in the advanced editor.

  • In the <choicegroup> element, add the answer-pool attribute, with the numerical value indicating the number of answer options to show to learners. For example, <choicegroup answer-pool="4">.
  • If you include more than one correct answer among the options, for each correct answer add an explanation-id attribute with a unique value to the <choice> element: <choice correct="false" explanation-id="correct1">.
  • If you include more than one correct answer among the options, for each <solution> element, add an explanation-id attribute and a value that maps back to a specific correct answer. For example, <solution explanation-id="correct1">.
  • Place the <solution> elements within a <solutionset> element.

Note

If the choices include only one correct answer, you do not have to use the explanation-id in either the <choice> or <solution> element. You do still use the <solutionset> element to wrap the <solution> element.

For example, for the following multiple choice problem, a learner will see four choices. In each set, one of the choices will be one of the two correct choices. The explanation shown for the correct answer is the one with the same explanation ID.

<problem>
  <multiplechoiceresponse>
    <label>What Apple devices let you carry your digital music library in your pocket?</label>
    <description>You can select only one option.</description>
    <choicegroup type="MultipleChoice" answer-pool="4">
      <choice correct="false">The iPad</choice>
      <choice correct="false">Napster</choice>
      <choice correct="true" explanation-id="iPod">The iPod</choice>
      <choice correct="false">The vegetable peeler</choice>
      <choice correct="false">The iMac</choice>
      <choice correct="true" explanation-id="iPhone">The iPhone</choice>
    </choicegroup>
    <solutionset>
      <solution explanation-id="iPod">
        <div class="detailed-solution">
          <p>Explanation</p>
          <p>The iPod is Apple's portable digital music player.</p>
        </div>
      </solution>
      <solution explanation-id="iPhone">
        <div class="detailed-solution">
          <p>Explanation</p>
          <p>In addition to being a cell phone, the iPhone can store and play
           your digital music.</p>
        </div>
      </solution>
    </solutionset>
  </multiplechoiceresponse>
</problem>

10.25.7.4. Using the Script Element

You can use the <script> element to programmatically set attributes and options for your multiple choice problems. You could use this feature to display different questions/answers depending on variable factors, like time of day, or randomly generated numbers.

10.25.7.4.1. Use the Advanced Editor to Configure the Script Element

You must use the advanced editor to configure a <script> element.

The contents of the <script> element must be enclosed in <![CDATA[]]> markers, to indicate that the enclosed code should not be interpreted as XML.

The code in the <script> element is run on the server before the problem is shown to learners. Note that only Python script types are supported.

The following OLX example uses random numbers to generate different answer choices for each learner, and mathematical operators to determine each choice’s correctness.

<problem>
    <script type="text/python">
    <![CDATA[
    random.seed(anonymous_student_id)  # Use different random numbers for each student.
    a = random.randint(1,10)
    b = random.randint(1,10)
    c = a + b

    ok0 = c % 2 == 0 # check remainder modulo 2
    text0 = "$a + $b is even"

    ok1 = c % 2 == 1 #check remainder modulo 2
    text1 = "$a + $b is odd"
    ]]>
    </script>
    <multiplechoiceresponse>
      <label>Is $a+$b even or odd? Select the true statement.</label>
      <choicegroup type="MultipleChoice">
        <choice correct="$ok0">$text0 ... (should be $ok0)</choice>
        <choice correct="$ok1">$text1 ... (should be $ok1)</choice>
      </choicegroup>
    </multiplechoiceresponse>
</problem>