Skip to content

Commit

Permalink
Improve access check and include due date
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesStoehr committed May 22, 2024
1 parent 02ac43a commit 07e7d5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,8 @@ public ResponseEntity<Set<CompetencyProgressForLearningPathDTO>> getCompetencyPr
}

private void checkLearningPathAccessElseThrow(Course course, LearningPath learningPath, User user) {
if (authorizationCheckService.isAtLeastStudentInCourse(course, user) && !authorizationCheckService.isAtLeastInstructorInCourse(course, user)) {
if (!user.getId().equals(learningPath.getUser().getId())) {
throw new AccessForbiddenException("You are not allowed to access another users learning path.");
}
}
else if (!authorizationCheckService.isAtLeastInstructorInCourse(course, user)) {
if (authorizationCheckService.isOnlyStudentInCourse(course, user) && !user.getId().equals(learningPath.getUser().getId())
&& !authorizationCheckService.isAtLeastInstructorInCourse(course, user)) {
throw new AccessForbiddenException("You are not allowed to access another users learning path.");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package de.tum.in.www1.artemis.web.rest.dto.competency;

import java.time.ZonedDateTime;

import de.tum.in.www1.artemis.domain.competency.CompetencyProgress;
import de.tum.in.www1.artemis.service.competency.CompetencyProgressService;

public record CompetencyProgressDTO(long id, String title, Double progress, Double confidence, Double mastery) {
public record CompetencyProgressDTO(long id, String title, ZonedDateTime softDueDate, Double progress, Double confidence, Double mastery) {

public static CompetencyProgressDTO of(CompetencyProgress competencyProgress) {
return new CompetencyProgressDTO(competencyProgress.getCompetency().getId(), competencyProgress.getCompetency().getTitle(), competencyProgress.getProgress(),
competencyProgress.getConfidence(), CompetencyProgressService.getMastery(competencyProgress));
return new CompetencyProgressDTO(competencyProgress.getCompetency().getId(), competencyProgress.getCompetency().getTitle(),
competencyProgress.getCompetency().getSoftDueDate(), competencyProgress.getProgress(), competencyProgress.getConfidence(),
CompetencyProgressService.getMastery(competencyProgress));
}
}

0 comments on commit 07e7d5f

Please sign in to comment.