How to perform an exercise
Tutorial on exercise creation.
In this tutorial we quickly explain the workflow for performing an exercise by a student (or a professor). The exercise is based on the c_hello_world
assignment created in assignment creation tutorial.
Exercise "creation"
To perform an exercise the student must first create the exercise. Under the hood, this operation consist in making a fork of a published assignment in the student's namespace.
This is performed by the following dojo
command:
dojo exercise create --assignment c_hello_world
Please wait while we verify and retrieve data...
ℹ Checking Dojo session:
✔ The session is valid
✔ Student permissions
ℹ Checking assignment:
✔ Assignment "c_hello_world" exists
✔ Assignment "c_hello_world" is published
Please wait while we are creating the exercise (approximately 10 seconds)...
✔ Exercise successfully created
ℹ Id: 7c39a375-68a0-415d-9335-6298e1bde4a4
ℹ Name: DojoEx - c_hello_world - student.malaspin
ℹ Web URL: https://gitedu.hesge.ch/dojo/exercise/dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4
ℹ HTTP Repo: https://gitedu.hesge.ch/dojo/exercise/dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4.git
ℹ SSH Repo: ssh://git@ssh.hesge.ch:10572/dojo/exercise/dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4.git
Please wait while we are cloning the repository...
To perform the exercise
The exercise is nothing else than a git repository so the workflow is pretty straightforward.
- Clone the repository (see the repo link above)
git clone ssh://git@ssh.hesge.ch:10572/dojo/exercise/dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4.git
Cloning into 'dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 59 (delta 13), reused 24 (delta 11), pack-reused 30
Receiving objects: 100% (59/59), 12.73 KiB | 6.36 MiB/s, done.
Resolving deltas: 100% (18/18), done.
- Read the
README.md
file to understand what is expected by the teacher. - Modify/create the appropriate code.
- (Optional but recommended) Execute the pipeline locally
dojo exercise run --verbose
Please wait while we are checking and creating dependencies...
ℹ Checking exercise content:
✔ The exercise folder contains all the needed files
✔ The dojo_assignment.json file is valid
✔ The Docker daemon is running
Please wait while we are running the exercise...
ℹ Running Docker Compose file
Starting tests.
Output is wrong:
1c1
< (null)
\ No newline at end of file
---
> Hello world!
\ No newline at end of file
✔ Docker Compose file run successfully
✔ Linked services logs acquired
✔ Containers stopped and removed
✔ Dangling images removed
Please wait while we are checking the results...
✔ Results file not found
✔ Results file sanitized
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Results ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Global result: ❌ Failure ┃
┃ ┃
┃ Execution exit code: 1 ┃
┃ ┃
┃ Execution results folder: /home/student/DojoExecutions/dojo_execLogs_2024-02-25T14_59_42_158Z ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Here we ran the dojo exercise run
with the --verbose
option, which outputs everything that our pipeline write to stdout
. In particular we see that the Output is wrong since we do not write Hello world!
.
Currently the exercise is a failure which is sad but expected since there was no modification in any file. One can see that we have access to a results
folder in /home/student/DojoExecutions/dojo_execLogs_2024-01-25T08_26_22_701Z/
. This directory contains the output of the pipeline execution
/home/student/DojoExecutions/dojo_execLogs_2024-01-25T08_26_22_701Z
├── Dojo
│ ├── dockerComposeLogs.txt
│ └── results.json
└── Exercise
└── diff_output.txt
2 directories, 3 files
In particular one can find the output the teacher wanted us (students) to see in the Exercise
folder. It contains any output file that can be used for debugging for example. In this case it contains
< ./hello_world
< (null)
\ No newline at end of file
---
> Hello world!
\ No newline at end of file
One can see that there is an Hello world!
expected and that no Hello world!
was provided by our program. One can also see the complete logs of the docker compose
command in Dojo/dockerComposeLogs.txt
which may (or may not) provide additional informations.
In order to complete this assignment we have to modify the src/function.c
file such that it becomes
#include "function.h"
char *hello_world() {
return "Hello world!";
}
Rerunning the pipeline now yields
dojo exercise run
Please wait while we are checking and creating dependencies...
ℹ Checking exercise content:
✔ The exercise folder contains all the needed files
✔ The dojo_assignment.json file is valid
✔ The Docker daemon is running
Please wait while we are running the exercise...
✔ Docker Compose file run successfully
✔ Linked services logs acquired
✔ Containers stopped and removed
✔ Dangling images removed
Please wait while we are checking the results...
✔ Results file not found
✔ Results file sanitized
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Results ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Global result: ✅ Success ┃
┃ ┃
┃ Execution exit code: 0 ┃
┃ ┃
┃ Execution results folder: /home/student/DojoExecutions/dojo_execLogs_2024-02-25T14_53_11_267Z ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
- Now that we are happy with the state of our exercise, we can commit and push our modifications.
$ git commit -am "finished"
[main 45b42a1] finished
1 file changed, 2 insertions(+), 4 deletions(-)
$ git push
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 16 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.01 KiB | 1.01 MiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
To ssh://ssh.hesge.ch:10572/dojo/exercise/dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4.git
1cf5b99..45b42a1 main -> main
The exercise will be run through the Gitlab CI pipeline and one can see the "official" result of our exercise.
It is not necessary to have a successful pipeline to commit and push the code. We can do it at any time which is particularly useful when doing long assignments that take many iterations to finish.
Assignment correction
This exercise can now be tagged as an assignment correction.
Exercise correction
It is possible to see the available corrections of an exercise by using the command
dojo exercise correction -a c_hello_world
✔ Here are corrections of the assignment 'c_hello_world':
- orestis.malaspin
https://gitedu.hesge.ch/dojo/exercise/dojo-ex_c_hello_world_7c39a375-68a0-415d-9335-6298e1bde4a4/-/tree/45b42a129c5732d476bfd17182fc506d88472e9a
which will return a list of correction of the c_hello_world
assignment.