Skip to main content

Graphs

Assignment precedence

Activities have a built-in graph system that can be used for more advanced patterns.

A simple example of such a pattern would be activites that force a particular order to be followed. For example, say we want our students to complete hello_world before simple_maths, which then unlocks fibo. Finally, once completing fibo, students should have access to all IO-based exercises.

On the intranet, this is done using assignment groups. Assignment groups are groups of assignments that can:

  • Depend on other assignment groups
  • Contain other assignment groups
  • Contain assignments

In this example, we could represent the activity as follows:

In this example, when a student validates hello_world_group, they will unlock simple_maths_group automatically.

Here's what our hello_world_group and simple_maths_group would look like in YAML:

assignmentGroups:
- name: Hello World Group
slug: hello_world_group
validationMode: ALL
assignments:
- name: Hello World
slug: hello_world
# ...
- name: Simple Maths Group
slug: simple_maths_group
validationMode: ALL
precedence: [hello_world_group] # This is the line that defines precedence
assignments:
- name: Simple Maths
slug: simple_maths
# ...

Where:

  • name is the name of the assignment group, as it will appear on the intranet.
  • required is used for validation of the parent group, which we'll describe later.
  • validationMode is the validation mode for the assignments and assignment groups within this group.
info

You can mix both assignment groups and assignments at the root of an activity, they are not mutually exclusive.

Requirement-based validation

Now that we've touched a bit on graphs, let's talk about an additional (and very useful!) validation mode: NODES.

An activity or an assignment group with the NODES validation mode is considred validated if all of its direct children that are marked as required: true are validated.

Let's say that, from our previous example, we'll want to add additional, extra exercises that are not required for students to complete:

Parts in blue should be optional.

In this case, we'll need to:

  • use the NODES validation mode on io_group, with cat_file and grep_file marked as required: true. This will ensure that students can only validate io_group if they validate cat_file and grep_file, while touch_file does not impact validation.
  • use the NODES validation mode on the activity and mark hello_world_group, simple_maths_group, fibo_group and io_group as required: true.

We can use the ALL validation mode everywhere else. This will give us the following activity:

# NOTE: this example omits a *lot* of fields for the sake of brevity.
assignmentGroups:
- slug: hello_world_group
validationMode: ALL
required: true
assignments:
- slug: hello_world
# ...
- slug: simple_maths_group
validationMode: ALL
required: true
precedence: [hello_world_group]
assignments:
- slug: simple_maths
# ...
- slug: fibo_group
validationMode: ALL
required: true
precedence: [simple_maths_group]
assignments:
- slug: fibo
# ...
- slug: io_group
validationMode: NODES
required: true
assignments:
- slug: cat_file
required: true
# ...
- slug: grep_file
required: true
# ...
- slug: touch_file
required: false
# ...
- slug: advanced_io
required: false
validationMode: ALL
assignments:
- slug: find_file
# ...
- slug: advanced_io
# ...

More advanced graphs

Assignment groups can contain other assignment groups, meaning that hierarchies like this can be used on the intranet:

# NOTE: this example omits a *lot* of fields for the sake of brevity.
assignmentGroups:
- slug: chapter-1
assignmentGroups:
- slug: basics
assignments:
- slug: hello_world
# ...
- slug: for_loops
# ...
- slug: lists
precedence: [basics]
assignments:
- slug: count_items
# ...
- slug: is_fibo_list
# ...
- slug: chapter-2
precedence: [chapter-1]
assignmentGroups:
- slug: io-basics
assignments:
- slug: cat_file
# ...
- slug: write_file
# ...
- slug: io-advanced
precedence: [io-basics]
assignments:
- slug: find_file
# ...
- slug: batch_rename
# ...