3144 Suggest a better date when supervisors have to set the grade for problem and method

This commit is contained in:
Andreas Svanberg 2023-10-30 13:48:57 +01:00
parent 9223f53f42
commit 0d95489908

@ -17,6 +17,9 @@ import se.su.dsv.scipro.oauth.OAuth;
import se.su.dsv.scipro.oauth.OAuthService;
import se.su.dsv.scipro.profile.UserLabel;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.reviewing.Decision;
import se.su.dsv.scipro.reviewing.ReviewerApproval;
import se.su.dsv.scipro.reviewing.RoughDraftApprovalService;
import se.su.dsv.scipro.supervisor.pages.AbstractSupervisorProjectDetailsPage;
import se.su.dsv.scipro.system.User;
import se.su.dsv.scipro.util.Either;
@ -24,6 +27,8 @@ import se.su.dsv.scipro.util.Either;
import javax.inject.Inject;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
public class SupervisorGradingPage extends AbstractSupervisorProjectDetailsPage
@ -34,6 +39,8 @@ public class SupervisorGradingPage extends AbstractSupervisorProjectDetailsPage
private OAuthService oAuthService;
@Inject
private GradingService gradingService;
@Inject
private RoughDraftApprovalService roughDraftApprovalService;
public SupervisorGradingPage(final PageParameters pp) {
super(pp);
@ -56,11 +63,25 @@ public class SupervisorGradingPage extends AbstractSupervisorProjectDetailsPage
"nonGraded",
item.getModel(),
nonGradedExaminations,
Model.of(LocalDate.now())));
Model.of(suggestedDateForNonGradedExaminations())));
}
});
}
/**
* @implNote
* The suggested date for non-graded examinations is the date the rough draft approval was sent in.
*/
private LocalDate suggestedDateForNonGradedExaminations() {
return roughDraftApprovalService.findBy(projectModel.getObject())
.map(ReviewerApproval::getCurrentDecision)
.map(Decision::getRequested)
.map(Date::toInstant)
.map(instant -> instant.atZone(ZoneId.systemDefault()))
.map(ZonedDateTime::toLocalDate)
.orElseGet(LocalDate::now);
}
private IModel<List<Examination>> getSpecificExaminations(final IModel<List<Examination>> examinations, final boolean graded) {
return new FilteredListModel<>(examinations) {
@Override