2934 PO Inform reviewers if there is nothing to report because the authors have already passed
This commit is contained in:
parent
4a27718711
commit
e28ab15005
view/src
main
java/se/su/dsv/scipro/reviewer
resources/se/su/dsv/scipro/reviewer
test/java/se/su/dsv/scipro/reviewer
@ -26,10 +26,12 @@ import se.su.dsv.scipro.components.InfoPanel;
|
||||
import se.su.dsv.scipro.files.WicketFileUpload;
|
||||
import se.su.dsv.scipro.forum.panels.threaded.SubmitForumReplyPanel;
|
||||
import se.su.dsv.scipro.grading.Examination;
|
||||
import se.su.dsv.scipro.grading.GetGradeError;
|
||||
import se.su.dsv.scipro.grading.Grade;
|
||||
import se.su.dsv.scipro.grading.GradingService;
|
||||
import se.su.dsv.scipro.grading.Name;
|
||||
import se.su.dsv.scipro.grading.ReportGradeError;
|
||||
import se.su.dsv.scipro.grading.Result;
|
||||
import se.su.dsv.scipro.oauth.OAuth;
|
||||
import se.su.dsv.scipro.oauth.OAuthService;
|
||||
import se.su.dsv.scipro.profile.UserLabel;
|
||||
@ -185,7 +187,7 @@ public class RoughDraftApprovalDecisionPage extends ReviewerPage {
|
||||
protected void populateItem(ListItem<User> item) {
|
||||
item.add(new UserLabel("name", item.getModel()));
|
||||
IModel<List<Examination>> examinations = LoadableDetachableModel.of(() ->
|
||||
getPassFailExaminations(item.getModelObject()));
|
||||
getExaminationsToReport(item.getModelObject()));
|
||||
item.add(new AutoHidingListView<>("examinations", examinations) {
|
||||
@Override
|
||||
protected void populateItem(ListItem<Examination> item) {
|
||||
@ -193,6 +195,13 @@ public class RoughDraftApprovalDecisionPage extends ReviewerPage {
|
||||
item.add(new Label("points", item.getModel().map(Examination::points)));
|
||||
}
|
||||
});
|
||||
item.add(new WebMarkupContainer("nothing_to_report") {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(examinations.getObject().isEmpty());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
listView.setReuseItems(true);
|
||||
@ -223,6 +232,22 @@ public class RoughDraftApprovalDecisionPage extends ReviewerPage {
|
||||
});
|
||||
}
|
||||
|
||||
private List<Examination> getExaminationsToReport(User author) {
|
||||
return getPassFailExaminations(author)
|
||||
.stream()
|
||||
.filter(examination -> hasNoGrade(author, examination))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private boolean hasNoGrade(User author, Examination examination) {
|
||||
Either<GetGradeError, Optional<Result>> currentResult = gradingService.getResult(
|
||||
getSession().getMetaData(OAuth.TOKEN),
|
||||
approval.getObject().getProject().getIdentifier(),
|
||||
author.getIdentifier(),
|
||||
examination.id());
|
||||
return currentResult.isRight() && currentResult.right().isEmpty();
|
||||
}
|
||||
|
||||
private List<Examination> getPassFailExaminations(User author) {
|
||||
return gradingService.getExaminations(
|
||||
getSession().getMetaData(OAuth.TOKEN),
|
||||
@ -234,7 +259,7 @@ public class RoughDraftApprovalDecisionPage extends ReviewerPage {
|
||||
}
|
||||
|
||||
private void reportGrade(User author, Project project) {
|
||||
List<Examination> examinations = getPassFailExaminations(author);
|
||||
List<Examination> examinations = getExaminationsToReport(author);
|
||||
for (Examination examination : examinations) {
|
||||
reportGrade(author, project, examination);
|
||||
}
|
||||
|
@ -48,13 +48,18 @@
|
||||
|
||||
<wicket:container wicket:id="authors">
|
||||
<dt wicket:id="name"></dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li wicket:id="examinations">
|
||||
<span wicket:id="name"></span>
|
||||
(<span wicket:id="points"></span> hec)
|
||||
</li>
|
||||
</ul>
|
||||
<wicket:enclosure child="examinations">
|
||||
<dd>
|
||||
<ul>
|
||||
<li wicket:id="examinations">
|
||||
<span wicket:id="name"></span>
|
||||
(<span wicket:id="points"></span> hec)
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</wicket:enclosure>
|
||||
<dd wicket:id="nothing_to_report">
|
||||
Nothing to report (already passed)
|
||||
</dd>
|
||||
</wicket:container>
|
||||
</dl>
|
||||
|
@ -92,6 +92,9 @@ public class RoughDraftApprovalDecisionPageTest extends SciProTest {
|
||||
String feedback = "This is good enough";
|
||||
File attachment = testFile();
|
||||
|
||||
when(gradingService.getResult(anyString(), anyLong(), anyLong(), anyLong()))
|
||||
.thenReturn(Either.right(Optional.empty()));
|
||||
|
||||
tester.executeAjaxEvent(path("decision", "decision_buttons", "approve"), "click");
|
||||
FormTester formTester = tester.newFormTester("decision");
|
||||
formTester.setValue("feedback", feedback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user