Have the option of setting question/approval on a per assignment base
Currently the request types allowed are linked to the lab itself by the following code:
@ManyToMany @Valid private List<RequestType> allowedRequestTypes = new ArrayList<>();
However this should be able to vary for different assignments in a lab, but also for an assignment in a different lab session. To make this more concrete:
We have assignments 1 and 2. and two lab sessions A and B. Currently we can have lab A on questions and lab B on submission.
What needs to be possible:
Lab session A: assignment 1: submission assignment 2: questions + submission Lab Session B: assignment 1: questions assignment 2: submission
This means we need to attach the information for what request types are allowed for a lab inside the join table. This can be done by using a "link-entity" as is described here
There is currently also a problem with the existing model. Both Lab and Assignment have the
@ManyToMany annotation, but neither of them is specified to be the non-owning side (this needs to declare mappedBy in the annotation as value). This means we have two tables representing this relation ship in our database.
Assignment_Lab and Lab_assignment, the contents of the tables seem te be out of sync in our test environment and this might also be the case in production? Either way this should be fixed by the link entity since it will become owner of the entire relation ship.
The database migrations in liquibase should create this new table according to the definition hibernate wants and populate this table with the existing data in the database representing the assignments to labs. It is still important to find the proper source of truth for writing this migration. Then both old join tables can be deleted.
Finally there are templates using the
Lab.containsAllowedRequestTypes method that give the users the option to enqueue for a certain request these should be updated to use the new method from the link entity.
Also the request type is never validated on the backend by the
LabController nor the
LabService, either of these should check the request type is allowed before enqueue-ing a student.