---
title: "Dojo"
date: "2024-01-11"
---

# Le Dojo

* Plateforme d'exercices pour la programmation,
* Outil à la ligne de commande basé sur `gitedu`,
* Correction automatique des exercices,
* Fait maison par Michël Minelli (aller en A403 pour le voir),
* En cours de développement, n'hésitez pas à ouvrir des [\alert{Issues}](https://gitedu.hesge.ch/dojo_project/issues).

# Prérequis

* Installer `docker` et `docker-compose`

```console
sudo apt install docker docker-compose
```

# Installation

* Détails sur [\alert{ce lien}](https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/wikis/UserDocumentation/0-Installation).

## Résumé

\footnotesize

* Naviguer sur la [\alert{page release}](https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases),
* Choisir le package pour l'architecture de son choix [\alert{Ubuntu/Debian}](https://gitedu.hesge.ch/api/v4/projects/12972/packages/generic/dojo_debian-pkg-x64/3.2.0/dojo.deb),
* A la CLI (toujours Debian/Ubuntu)
```console
wget https://gitedu.hesge.ch/api/v4/projects/12972/packages/generic/dojo_debian-pkg-x64/3.2.0/dojo.deb
sudo dpkg -i dojo.deb
```
* Est-ce que ça a marché?
```console
$ dojo
Usage: dojo [options] [command]
CLI of the Dojo application
Options:
  -h, --help           display help for command
  -H, --host <string>  override the Dojo API endpoint (default: "https://rdps.hesge.ch/dojo/api")
  -V, --version        output the version number
```

# Authentification

* Détails sur [\alert{ce lien}](https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/wikis/UserDocumentation/1-Authentification).

## Résumé

* Authentification via `gitedu`
```console
dojo session login
```
* Ouverture de gitedu dans votre navigateur,
* Cliquer sur *autoriser*,
* Est-ce que ça a marché?
```console
$ dojo session test
ℹ Checking Dojo session: 
    ✔ The session is valid
        ✔ Student permissions
        ✔ Teaching staff permissions
        ✔ Admin permissions
ℹ Checking Gitlab token: 
    ✔ Read access
    ✔ Write access
```

# Faire un exercice (1/3)

* Détails sur [\alert{ce lien}](https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/wikis/UserDocumentation/3-Exercise-creation).

## Création de l'exercice

* Création de l'exercice (liste chaînée de strings)
```C
$ dojo exercise create --assignment linked_list_string_stack
...
✔ Exercise successfully created
    ℹ Id: 9016b1ae-77d6-454d-b795-d8bc2770ea05
    ℹ Name: DojoEx - linked_list_string_stack - orestis.malaspin - 2
    ℹ Web URL: https://gitedu.hesge.ch/dojo/exercise/dojo-ex_linked_list_string_stack_9016b1ae-77d6-454d-b795-d8bc2770ea05
    ℹ HTTP Repo: https://gitedu.hesge.ch/dojo/exercise/dojo-ex_linked_list_string_stack_9016b1ae-77d6-454d-b795-d8bc2770ea05.git
    ℹ SSH Repo: ssh://git@ssh.hesge.ch:10572/dojo/exercise/dojo-ex_linked_list_string_stack_9016b1ae-77d6-454d-b795-d8bc2770ea05.git
```

# Faire un exercice (2/3)

## Récupération de l'énoncé

* Clonage de l'exercice

```console
$ git clone ssh://git@ssh.hesge.ch:10572/dojo/exercise/dojo-ex_linked_list_string_stack_9016b1ae-77d6-454d-b795-d8bc2770ea05.git
```
* Astuce on peut aussi faire les 2 en une fois:
```C
$ dojo exercise create --assignment linked_list_string_stack -c .
```

# Faire un exercice (3/3)

## Exécution des tests

* Faire l'exercice

```console
$ cd dojo-ex_linked_list_string_stack_9016b1ae-77d6-454d-b795-d8bc2770ea05
$ dojo exercise run --verbose
```

* Yaka faire l'exercice, commit, et push!