Skip to main content

Lists and sets

You can have answers with lists and sets. There are multiple forms understood as lists; you can configure it in the Input options and Validation options sections.

Example 1: Compare as lists

Let us create an essential question asking to sort a set of integers:

lists_sets_statement.png

By default,

  • Lists are allowed, but elements need to be enclosed within curly brackets.

  • The comma is used as a separator.

  • The student's answer is compared as a list (taking into account order and repetition).

In this example, we check the option Lists without enclosers.

lists_sets_validation.png

Thus, the following answers will be validated as specified in the table below.

Student answer

Validation

-7,-4,1,5

tic_green.png

{-7,-4,1,5}

tic_green.png

-7-415

tic_green.png

-7-415

cross.png

Example 2: Compare as sets

By default, to be accepted, lists in student and correct answers must have equivalent items and be in the same order. That is, the order is important, and repetition has sense. In contrast, sets are lists without order nor duplicated items.

As an example, we can ask for the roots of a given polynomial, and we might be interested in accepting any answer with the correct values.

lists_sets_compare_as_sets_statement.png

Thus, we can set the lists to be understood as sets in Validation options > Comparison with student answer. That is, ignore repetition and order in the comparison.

lists_sets_compare_as_sets.png

Besides, we can also define these lists to be understood as sets where repetition matters, but order does not. The grading will behave as you can see below.

Student answer

Validation

{1,2,2}\{1,2,2\}

tic_green.png

1,2,21,2,2

tic_green.png

1,21,2

tic_green.png

1,2,2,2,11,2,2,2,1

tic_green.png

1221\;2\;2

cross.png