3231 Show warning if there's a probable problem reporting the grades

This commit is contained in:
Andreas Svanberg 2023-11-29 13:38:13 +01:00
parent d63ed58330
commit 172ddbe27f
3 changed files with 52 additions and 14 deletions
view/src/main

@ -178,13 +178,22 @@ public class RoughDraftApprovalDecisionPage extends ReviewerPage {
IModel<List<User>> authors = approval.map(ReviewerApproval::getProject)
.map(Project::getProjectParticipants)
.map(ArrayList::new);
IModel<Boolean> gradingServiceAvailable = LoadableDetachableModel.of(() -> isGradingServiceAvailable(authors));
ListView<User> listView = new ListView<>("authors", authors) {
@Override
protected void populateItem(ListItem<User> item) {
item.add(new UserLabel("name", item.getModel()));
IModel<List<Examination>> examinations = LoadableDetachableModel.of(() ->
getExaminationsToReport(item.getModelObject()));
item.add(new AutoHidingListView<>("examinations", examinations) {
WebMarkupContainer gradingServiceAvailableContainer = new WebMarkupContainer("grading_service_available") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(gradingServiceAvailable.getObject());
}
};
item.add(gradingServiceAvailableContainer);
gradingServiceAvailableContainer.add(new AutoHidingListView<>("examinations", examinations) {
@Override
protected void populateItem(ListItem<Examination> item) {
item.add(new Label("name", item.getModel().map(Examination::name).map(Name::english)));
@ -192,19 +201,41 @@ public class RoughDraftApprovalDecisionPage extends ReviewerPage {
item.add(new Label("examination_date", DecisionForm.this::getExaminationDate));
}
});
item.add(new WebMarkupContainer("nothing_to_report") {
gradingServiceAvailableContainer.add(new WebMarkupContainer("nothing_to_report") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(examinations.getObject().isEmpty());
}
});
item.add(new WebMarkupContainer("grading_service_unavailable") {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(!gradingServiceAvailable.getObject());
}
});
}
};
listView.setReuseItems(true);
add(listView);
}
private Boolean isGradingServiceAvailable(IModel<List<User>> authors) {
for (User author : authors.getObject()) {
try {
List<Examination> examinations = getPassFailExaminations(author);
if (examinations.isEmpty()) {
// an empty list is returned if there's an error from the grading service
return false;
}
} catch (RuntimeException e) {
return false;
}
}
return true;
}
private List<Examination> getExaminationsToReport(User author) {
return getPassFailExaminations(author)
.stream()

@ -9,5 +9,5 @@ report_halfway_explanation=If you choose to approve the rough draft of this proj
the appropriate passing grade(s) for the author(s) according to the following.
failed_to_report_phase_two_grade=Could not report all the grades, please contact the supervisor and let them know \
they will have to report it themselves.
error_while_reporting_phase_two_grades=Failed to report the grades so the approval was not accepted, \
error_while_reporting_phase_two_grades=Failed to report the grades to Daisy, so the approval was not accepted, \
please try again later. If the problem persists, contact the support.

@ -35,18 +35,25 @@
<dl>
<wicket:container wicket:id="authors">
<dt wicket:id="name"></dt>
<wicket:enclosure child="examinations">
<dd>
<ul>
<li wicket:id="examinations">
<span wicket:id="name"></span>
(<span wicket:id="points"></span> hec), examination date: <span wicket:id="examination_date"></span>
</li>
</ul>
<wicket:container wicket:id="grading_service_available">
<wicket:enclosure child="examinations">
<dd>
<ul>
<li wicket:id="examinations">
<span wicket:id="name"></span>
(<span wicket:id="points"></span> hec), examination date: <span wicket:id="examination_date"></span>
</li>
</ul>
</dd>
</wicket:enclosure>
<dd wicket:id="nothing_to_report">
Nothing to report (already passed)
</dd>
</wicket:enclosure>
<dd wicket:id="nothing_to_report">
Nothing to report (already passed)
</wicket:container>
<dd wicket:id="grading_service_unavailable">
There appears to be a problem with contacting Daisy to report the grades.
You can still try to approve the rough draft, but if the grades cannot be reported,
the approval will not be accepted, and you will have to do it at a later time.
</dd>
</wicket:container>
</dl>