11.34. Text Input Problem#

Note

EdX offers full support for this problem type.

The text input problem type is a simple problem type that can be added to any course. At a minimum, text input problems include a question or prompt and a response field for free form answer text. By adding hints, feedback, or both, you can give learners guidance and help when they work on a problem.

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

11.34.1. Overview#

In text input problems, learners enter text into a response field. The response can include numbers, letters, and special characters such as punctuation marks. Because the text that the learner enters must match the instructor’s specified answer exactly, including spelling and punctuation, edX recommends that you specify more than one correct answer for text input problems to allow for differences in capitalization and typographical errors.

11.34.1.1. Example Text Input Problem#

In the LMS, learners enter a value into a response field to complete a text input problem. An example of a completed text input problem follows.

A correctly answered text input problem shown in the LMS. The text entered by the learner exactly matches one of the acceptable answer options, which appear below the response along with the explanation.

11.34.2. Adding a Text Input Problem#

You add text input problems in Studio by selecting the Problem component. In the problem editor, select the Text Input option. Fill in the fields on this screen to create your problem.

An image of the problem editor in Studio. The various inputs and sections are labeled, and are referenced below.

Creating a text input problem is as simple as:

  1. Editing the Display Name. Click the pen symbol to edit.

  2. Filling in the Question field.

  3. Filling in the Explanation field. When this is shown to learners is based on the selection in the Show answer panel on the right.

  4. Filling in the Answer fields. Select the correct answer(s) by ticking off the checkbox(es). Additional answers can be added by clicking the Add answer button. Answers can be deleted by clicking the trash can icon. Feedback can be provided for each answer. More information on feedback can be found in the following section.

  5. Selecting and filling in any desired settings on the right.

If you have any questions on the specifics of using the simple editor, please check out The Simple Editor and Defining Settings for Problem Components.

11.34.2.1. Adding Feedback#

For an overview of feedback in problems, see Adding Feedback and Hints to a Problem. In text input problems, you can provide feedback for the correct answer or for a specified incorrect answer. Use feedback on incorrect answers as an opportunity to address common learner misconceptions. Feedback for text input questions should also provide guidance to the learner on how to arrive at the correct answer.

If you define multiple correct responses for the question, you can define feedback for each response.

You can add answer-specific feedback for each answer in a text input problem. You can access the feedback panel shown below by clicking the button to the right of the answer text.

an image of the feedback section. There are options for when the student's answer is selected.

Simply enter your feedback message in this text field. It will display when the learner submits this answer.

11.34.2.2. Adding Hints#

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

In the settings panels on the right of the editor, you’ll find a Hints panel.

An example of the hints settings panel.

Click the Add hint button to add a new hint text field. To delete any hints you’ve added, click the trash can icon next to its respective hint field.

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.

11.34.3. Editing Text Input Problems using the Advanced Editor#

If the simple editor is not enough to meet your needs, you can switch over to the advanced editor. In the setting panels on the right of the editor, click Show advanced settings, then scroll down and click Switch to advanced editor.

You can use the advanced editor to identify the elements of a text input problem with OLX. For more information, see Text Input Problem XML Reference. To format equations, you can use MathJax. For more information, see MathJax for Mathematics.

You can see the OLX for the example problem from the Overview section below.

<problem>
<stringresponse answer="Nanjing University" type="ci">
  <label>What was the first post-secondary school in China to allow both
   male and female students?</label>
  <description>Answer with a name from the modern period.</description>
  <additional_answer answer="National Central University"/>
  <additional_answer answer="Nanjing Higher Normal Institute"/>
  <additional_answer answer="Nanking University"/>
  <textline size="20"/>
  <solution>
    <div class="detailed-solution">
      <p>Explanation</p>
      <p>Nanjing University first admitted female students in 1920.</p>
    </div>
  </solution>
</stringresponse>
</problem>

Note

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

11.34.3.1. Adding Feedback#

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

<problem>
  <stringresponse answer="Correct Answer" type="ci">
    <label>Question text</label>
    <correcthint>Feedback for the correct answer</correcthint>
    <stringequalhint answer="Incorrect Answer">Hint for the incorrect answer</stringequalhint>
    <textline size="20"/>
  </stringresponse>
</problem>

For example, the following problem has feedback for the correct answer and two common incorrect answers.

<problem>
  <stringresponse answer="Alaska" type="ci">
    <label>What is the largest state in the U.S. in terms of land area?</label>
    <correcthint>Alaska is the largest state in the U.S. in terms of not
    only land area, but also total area and water area. Alaska is 576,400
    square miles, more than double the land area of the second largest
    state, Texas.</correcthint>
    <stringequalhint answer="Texas">While many people think Texas is the
    largest state in terms of land area, it is actually the second
    largest and contains 261,797 square miles.</stringequalhint>
    <stringequalhint answer="California">California is the third largest
    state and contains 155,959 square miles.</stringequalhint>
    <textline size="20"/>
  </stringresponse>
</problem>

11.34.3.1.1. 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.

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>

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.

11.34.3.2. Adding Hints#

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

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

For example, the following OLX for a single select problem shows two hints.

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

11.34.3.3. Adding Text after the Response Field#

You might want to include a word, phrase, or sentence after the response field in a text input problem to help guide your learners or resolve ambiguity.

Text input problem with the word "Institute" after the response field.

To do this, you use the advanced editor.

In the problem, locate the textline element. This element creates the response field for the problem and is a child of the stringresponse element.

To add text after the response field, add the trailing_text attribute together with the text that you want to use inside the textline element. An example follows.

<problem>
  <stringresponse answer="Ashmun" type="ci">
    <label>What Pennsylvania school was founded in 1854 to provide
      educational opportunities for African-Americans?</label>
    <textline size="20" trailing_text="Institute"/>
  </stringresponse>
</problem>

11.34.3.4. Case Sensitivity and Text Input Problems#

By default, text input problems do not require a case sensitive response. You can change this default to require a case sensitive answer.

To make a text input response case sensitive, you use the advanced editor.

In the advanced editor, the stringresponse element has a type attribute. By default, the value for this attribute is set to ci, for “case insensitive”. An example follows.

<problem>
  <stringresponse answer="Paris" type="ci">
  .
  .
  .
  </stringresponse>
</problem>

Learners who submit an answer of either “Paris” or “paris” are scored as correct.

To make the response case sensitive, change the value of the type attribute to cs.

<problem>
  <stringresponse answer="Paris" type="cs">
  .
  .
  .
  </stringresponse>
</problem>

Learners who submit an answer of “Paris” are scored as correct, but learners who submit an answer of “PARIS” are scored as incorrect.

11.34.3.5. Response Field Length in Text Input Problems#

You should preview the unit to ensure that the length of the response input field accommodates the correct answer, and provides extra space for possible incorrect answers.

If the default response field is not long enough, you can change it using the advanced editor.

In the advanced editor, the textline element has a size attribute. By default, the value for this attribute is set to 20. An example follows.

<problem>
  <stringresponse answer="Democratic Republic of the Congo" type="ci">
    .
    .
    .
    <textline size="20"/>
  </stringresponse>
</problem>

To change the response field length, change the value of the size attribute.

<problem>
  <stringresponse answer="Democratic Republic of the Congo" type="ci">
    .
    .
    .
    <textline size="40" />
  </stringresponse>
</problem>

11.34.3.6. Allowing Regular Expressions as Answers for Text Input Problems#

You can configure a text input problem to allow a regular expression as an answer. Allowing learners to answer with a regular expression can minimize the number of distinct correct responses that you need to define for the problem: if a learner responds with the correct answer formed as a plural instead of a singular noun, or a verb in the past tense instead of the present tense, the answer is marked as correct.

To do this, you use the advanced editor.

In the advanced editor, the stringresponse element has a type attribute. You can set the value for this attribute to regexp, with or without also including ci or cs for a case insensitive or case sensitive answer. An example follows.

<problem>
  <stringresponse answer="string pattern" type="regexp ci">
    .
    .
    .
  </stringresponse>
</problem>

The regular expression that the learner enters must contain, in whole or in part, the answer that you specify.

In this example, learners who submit an answer of “string pattern”, “String Patterns”, “string patterned”, or “STRING PATTERNING” are all scored as correct, but learners who submit an answer of “Strings Pattern” or “string patern” are scored as incorrect.

11.34.3.7. Disable MathJax rendering#

You can configure a text input problem to accept raw expressions which could resemble functions that are processed by MathJax by default. Sometimes this might not be the expected behaviour, i.e., you want to accept raw expression as well as display (show answer) it in its raw form. You can do this by simply enclosing <stringresponse> element in <annotation-xml> tag. All elements inside this tag will be ignored by MathJax processor. An example follows.

<problem>
  <annotation-xml>
    <stringresponse class="tex2jax_ignore" answer="\s*n\s**?\s*x\[\s*n\s*\]\s*" type="ci">
      <div>Question</div>
      <additional_answer class="tex2jax_ignore" answer="or \s*x\[\s*n\s*\]\s**?\s*n\s*"></additional_answer>
      <textline size="20"></textline>
    </stringresponse>
  </annotation-xml>
</problem>

11.34.4. Text Input Problem XML Reference#

11.34.4.1. Template#

<problem>
  <stringresponse answer="Correct answer 1" type="ci regexp">
    <label>Question text</label>
    <description>Optional tip</description>
    <correcthint>Provides feedback when learners submit the correct
     response.</correcthint>
    <additional_answer answer="Correct answer 2"/>
    <additional_answer answer="Correct answer 3"/>
    <stringequalhint answer="Incorrect answer 1">Provides feedback when
     learners submit the specified incorrect response.</stringequalhint>
    <stringequalhint answer="Incorrect answer 2">Provides feedback when
     learners submit the specified incorrect response.</stringequalhint>
    <textline size="20" />
  </stringresponse>
  <demandhint>
    <hint>The first text string to display when learners request a hint.</hint>
    <hint>The second text string to display when learners request a hint.</hint>
  </demandhint>
</problem>

11.34.4.2. Elements#

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

<stringresponse>
    <label>
    <description>
    <additional_answer>
    <correcthint>
    <stringequalhint>
    <textline>
    <solution>
<demandhint>
    <hint>

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

11.34.4.2.1. <stringresponse>#

Required. Indicates that the problem is a text input problem.

11.34.4.2.1.1. Attributes#

Attribute

Description

answer (required)

Specifies the correct answer.

Note that if you do not also add the type attribute and set it to regexp, the learner’s answer must match the value for this attribute exactly.

type (optional)

Specifies whether the problem requires a case sensitive response and if it allows regular expressions.

  • If type="ci", the problem is not case sensitive.

  • If type="cs", the problem is case sensitive.

  • If type="regexp", the problem allows regular expressions.

You can also combine these values in a space separated list. For example, <stringresponse type="regexp cs"> specifies that the problem allows regular expressions and is case sensitive.

11.34.4.2.1.2. Children#
  • <label>

  • <description>

  • <textline>

  • <additional_answer>

  • <correcthint>

  • <stringequalhint>

  • <solution>

11.34.4.2.2. <label>#

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

11.34.4.2.2.1. Attributes#

None.

11.34.4.2.2.2. Children#

None.

11.34.4.2.3. <description>#

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

11.34.4.2.3.1. Attributes#

None.

11.34.4.2.3.2. Children#

None.

11.34.4.2.4. <textline>#

Required. Creates a response field in the LMS where the learner enters a text string.

11.34.4.2.4.1. Attributes#

Attribute

Description

size

Optional. Specifies the size, in characters, of the response field in the LMS. Defaults to 20.

hidden

Optional. If set to “true”, learners cannot see the response field.

correct_answer

Optional. Lists the correct answer to the problem.

trailing_text

Optional. Specifies text to appear immediately after the response field.

11.34.4.2.4.2. Children#

None.

11.34.4.2.5. <additional_answer>#

Optional. Specifies an additional correct answer for the problem. A problem can contain an unlimited number of additional answers.

11.34.4.2.5.1. Attributes#

Attribute

Description

answer

Required. The text of the alternative correct answer.

11.34.4.2.5.2. Children#

<correcthint>

11.34.4.2.6. <correcthint>#

Optional. Specifies feedback to appear after the learner submits a correct answer.

11.34.4.2.6.1. Attributes#

Attribute

Description

label

Optional. The text of the custom feedback label.

11.34.4.2.6.2. Children#

None.

11.34.4.2.7. <stringequalhint>#

Optional. Specifies feedback to appear after the learner submits an incorrect answer.

11.34.4.2.7.1. Attributes#

Attribute

Description

answer

Required. The text of the incorrect answer.

label

Optional. The text of the custom feedback label.

11.34.4.2.7.2. Children#

None.

11.34.4.2.8. <solution>#

Optional. Identifies the explanation or solution for the problem, or for one of the questions in a problem that contains more than one question.

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

11.34.4.2.9. <demandhint>#

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

11.34.4.2.9.1. Attributes#

None.

11.34.4.2.9.2. Children#

<hint>

11.34.4.2.10. <hint>#

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

11.34.4.2.10.1. Attributes#

None.

11.34.4.2.10.2. Children#

None.