Skip to content
Snippets Groups Projects
Commit 16f4a485 authored by Ruben Backx's avatar Ruben Backx :coffee:
Browse files

Merge branch '698-leave-edition-as-a-teacher' into 'development'

Resolve "Leave edition as a teacher"

Closes #698

See merge request !772
parents 1fb74353 e72164a6
Branches
Tags
2 merge requests!774Deploy,!772Resolve "Leave edition as a teacher"
......@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Feedbacks are now soft deleted correctly. [@hpage](https://gitlab.ewi.tudelft.nl/hpage)
- Teachers that are the only teacher for an edition now can't leave the edition. [@aturgut](https://gitlab.ewi.tudelft.nl/aturgut)
## [2.3.1]
......
......@@ -101,6 +101,9 @@ public class PermissionService {
@Lazy
private RequestService rs;
@Autowired
private RoleDTOService rds;
/**
* Gets the Person associated to the currently authenticated entity and passes it to the given callback.
* If no API Key with user could be found, this function just outputs {@code false}.
......@@ -451,10 +454,15 @@ public class PermissionService {
* @return Whether the authenticated user can remove themselves from an edition. A user may not
* leave the course they are in if their role in the course is already linked to a
* student group, as this means they might have requests, submissions, or even grades in
* the course that cannot be disassociated with the user.
* the course that cannot be disassociated with the user. A user that is the only
* teacher of the edition can't leave the edition.
*/
public boolean canLeaveEdition(Long editionId) {
return withRole(editionId, (person, role) -> STAFF_ROLES.contains(role) ||
return withRole(editionId, (person, role) -> (STAFF_ROLES.contains(role) &&
withEdition(editionId, edition -> {
return !rds.isTheOnlyTeacherInEdition(person.getId(), edition);
}))
||
(role == STUDENT && withEdition(editionId, edition -> {
var groups = sgCache.getByPerson(person.getId());
var modules = edition.getModules().stream()
......@@ -566,11 +574,6 @@ public class PermissionService {
* @param editionId The id of an edition
* @return Whether the authenticated user can manage the questions of an edition
*/
/**
* @param editionId The id of the edition the user wants to manage.
* @return Whether the authenticated user can change some values within the settings of the
* edition.
*/
public boolean canManageQuestions(Long editionId) {
return isAdmin() || withRole(editionId, (person, role) -> TEACHER == role || HEAD_TA == role);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment