3144 Allow supervisors to change the examination date when sending suggestion to the examiner
This commit is contained in:
parent
12104cc6c8
commit
9bcad9df40
view/src
main/java/se/su/dsv/scipro/grading
test/java/se/su/dsv/scipro/grading
@ -2,9 +2,20 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org" lang="en">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<wicket:enclosure child="send">
|
||||
<wicket:enclosure child="form">
|
||||
<div wicket:id="feedback"></div>
|
||||
<button type="button" class="btn btn-success scrollSneak" wicket:id="send">Send thesis for examination</button>
|
||||
<form wicket:id="form">
|
||||
<div class="mb-3">
|
||||
<label for="examinationDate" class="form-label">Examination date</label>
|
||||
<input type="text" class="form-control" id="examinationDate" wicket:id="examinationDate" required>
|
||||
<small class="form-text">
|
||||
The examination date is suggested based on the last student activity (submitted final thesis,
|
||||
opposition, or active participation). You should only change this date if the last activity was at a
|
||||
different date.
|
||||
</small>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success scrollSneak" wicket:id="send">Send thesis for examination</button>
|
||||
</form>
|
||||
</wicket:enclosure>
|
||||
<p class="card-text" wicket:id="already_sent">
|
||||
<span class="fa fa-check text-success"></span>
|
||||
|
@ -2,10 +2,13 @@ package se.su.dsv.scipro.grading;
|
||||
|
||||
import org.apache.wicket.feedback.FencedFeedbackPanel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.GenericPanel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import se.su.dsv.scipro.components.ConfirmationLink;
|
||||
import org.apache.wicket.model.Model;
|
||||
import se.su.dsv.scipro.components.BootstrapDatePicker;
|
||||
import se.su.dsv.scipro.daisyExternal.http.DaisyAPI;
|
||||
import se.su.dsv.scipro.file.FileDescription;
|
||||
import se.su.dsv.scipro.file.FileService;
|
||||
@ -33,6 +36,7 @@ import se.su.dsv.scipro.system.Language;
|
||||
import se.su.dsv.scipro.system.ResearchArea;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
import se.su.dsv.scipro.util.Either;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.LocalDate;
|
||||
@ -75,10 +79,16 @@ public class SendToExaminer extends GenericPanel<Project> {
|
||||
super(id, projectModel);
|
||||
|
||||
needsSending = LoadableDetachableModel.of(() -> hasGradedExaminationWithoutSuggestion(authorModel.getObject()));
|
||||
add(new ConfirmationLink<>("send", authorModel, confirmationMessage) {
|
||||
|
||||
IModel<LocalDate> examinationDate = new Model<>();
|
||||
FinalThesis finalThesis = finalThesisService.findByProject(projectModel.getObject());
|
||||
examinationDate.setObject(getExaminationDate(authorModel.getObject(), projectModel.getObject(), finalThesis));
|
||||
|
||||
Form<Void> form = new Form<>("form") {
|
||||
@Override
|
||||
public void onClick() {
|
||||
sendToExaminer(getModelObject());
|
||||
protected void onSubmit() {
|
||||
super.onSubmit();
|
||||
sendToExaminer(authorModel.getObject(), examinationDate.getObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,7 +96,20 @@ public class SendToExaminer extends GenericPanel<Project> {
|
||||
super.onConfigure();
|
||||
setVisible(needsSending.getObject());
|
||||
}
|
||||
});
|
||||
};
|
||||
add(form);
|
||||
|
||||
WebMarkupContainer sendButton = new WebMarkupContainer("send");
|
||||
if (confirmationMessage.getObject() != null) {
|
||||
sendButton.add(new JavascriptEventConfirmation("click", confirmationMessage));
|
||||
}
|
||||
form.add(sendButton);
|
||||
|
||||
TextField<LocalDate> examinationDateField = new TextField<>("examinationDate", examinationDate, LocalDate.class);
|
||||
examinationDateField.setRequired(true);
|
||||
examinationDateField.add(new BootstrapDatePicker());
|
||||
form.add(examinationDateField);
|
||||
|
||||
add(new WebMarkupContainer("already_sent") {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
@ -112,7 +135,7 @@ public class SendToExaminer extends GenericPanel<Project> {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendToExaminer(User author) {
|
||||
private void sendToExaminer(User author, LocalDate examinationDate) {
|
||||
checkStepsMissing();
|
||||
if (hasErrorMessage()) {
|
||||
// some steps have not been completed
|
||||
@ -138,7 +161,7 @@ public class SendToExaminer extends GenericPanel<Project> {
|
||||
} else if (gradedExaminations.isEmpty()) {
|
||||
getSession().info("Nothing to report on " + author.getFullName());
|
||||
} else {
|
||||
sendSuggestion(project, author, gradedExaminations.get(0));
|
||||
sendSuggestion(project, author, gradedExaminations.get(0), examinationDate);
|
||||
}
|
||||
needsSending.detach();
|
||||
}
|
||||
@ -176,7 +199,7 @@ public class SendToExaminer extends GenericPanel<Project> {
|
||||
return missing;
|
||||
}
|
||||
|
||||
private void sendSuggestion(Project project, User author, Examination examination) {
|
||||
private void sendSuggestion(Project project, User author, Examination examination, LocalDate examinationDate) {
|
||||
String token = getSession().getMetaData(OAuth.TOKEN);
|
||||
|
||||
Either<GetGradeError, Optional<Result>> currentResult
|
||||
@ -197,7 +220,6 @@ public class SendToExaminer extends GenericPanel<Project> {
|
||||
GradeCalculator gradeCalculator = gradeCalculatorService.getSupervisorCalculator(project);
|
||||
SupervisorGradingReport supervisorGradingReport = gradingReportService.getSupervisorGradingReport(getModelObject(), author);
|
||||
GradingReport.Grade grade = gradeCalculator.getGrade(supervisorGradingReport);
|
||||
LocalDate examinationDate = getExaminationDate(author, project, finalThesis);
|
||||
Either<ReportGradeError, Void> reported =
|
||||
gradingService.reportGrade(
|
||||
token,
|
||||
|
@ -1,5 +1,6 @@
|
||||
package se.su.dsv.scipro.grading;
|
||||
|
||||
import org.apache.wicket.util.tester.FormTester;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import se.su.dsv.scipro.SciProTest;
|
||||
import se.su.dsv.scipro.file.FileDescription;
|
||||
@ -144,8 +145,9 @@ public class SendToExaminerTest extends SciProTest {
|
||||
.thenReturn(Either.right(null));
|
||||
|
||||
tester.startComponentInPage(new SendToExaminer("id", () -> project, () -> biden, () -> null));
|
||||
FormTester formTester = tester.newFormTester(path("id", "form"));
|
||||
|
||||
tester.clickLink(path("id", "send"));
|
||||
formTester.submit();
|
||||
|
||||
verify(gradingService).reportGrade(TOKEN, project.getIdentifier(), biden.getIdentifier(), gw.id(), grade.name(), finalThesis.getUploadDate());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user