🚧 Individualization

Learn how Divekit helps you create individualized programming assignments.

Overview

Divekit allows you to create individualized programming assignments for each student. This is done by defining variables that are populated with random values during the repository generation.

Variable Types

There are three types of variables:

1. Object Variables

Object variables are used to randomize entities and value objects. They are defined in the configuration file {ORIGIN_REPO}/.divekit/variables/variations.json:

{
  "ids": "Vehicle",
  "objectVariations": [
    {
      "id": "Car",
      "Class": "Car", 
      "RepoClass": "CarRepository",
      "SetToOne": "setCar",
      "SetToMany": "setCars"
    },
    {
      "id": "Truck",
      "Class": "Truck",
      "RepoClass": "TruckRepository",
      "SetToOne": "setTruck", 
      "SetToMany": "setTrucks"
    }
  ],
  "variableExtensions": ["Getter"]
}

2. Relation Variables

Relation variables define relationships between entities. They are defined by two components:

  1. Relationship types in {ORIGIN_REPO}/.divekit/variables/relations.json:
{
  "id": "OneToOne",
  "Umlet": "lt=-\nm1=1\nm2=1",
  "Short": "1 - 1",
  "Description": "one to one"
}
  1. Concrete relationships in the variations.json:
{
  "relationShips": [
    {
      "id": "Rel1",
      "relationType": "OneToOne"
    }
  ],
  "relationObjects": [
    {
      "id": "RelVehicleWheel",
      "Obj1": "Vehicle",
      "Obj2": "Wheel" 
    }
  ]
}

3. Logic Variables

Logic variables allow the definition of different business logic variants. Files can be suffixed with _LogicId and will only be included if this logic variant is selected:

{
  "id": "VehicleLogic",
  "logicVariations": [
    {
      "id": "VehicleCrash",
      "Description": "Implementieren Sie die Crash-Logik..."
    },
    {
      "id": "VehicleShop", 
      "Description": "Implementieren Sie die Shop-Logik..."
    }
  ]
}

Using Variables

Variables can be referenced in files with a configurable delimiter (default: $):

public class $VehicleClass$ {
    // ...
}

For each variable, three variants are automatically generated:

  • Original: VehicleClass -> MonsterTruck
  • First letter lowercase: vehicleClass -> monsterTruck
  • All lowercase: vehicleclass -> monstertruck

Persistence

The generated individual variables are stored in the distribution under {ORIGIN_REPO}/.divekit/{DISTRIBUTION_NAME}/individual_repositories.json and can be reused if needed.

Quality Assurance

Divekit can issue warnings if suspicious values remain after variable replacement (e.g., “Car” in a Truck variant). This helps to identify accidentally unmodified variables.

Last modified January 17, 2025: refactor for cli rewrite (dfb706b)