2984 PO 9) Fix NPE when trying to submit a plagiarism check without upload the text matching report

This commit is contained in:
Andreas Svanberg 2023-09-13 10:45:14 +02:00
parent 8a0529e98a
commit e8f0f9a131
3 changed files with 17 additions and 2 deletions
view/src/main

@ -2,6 +2,7 @@ package se.su.dsv.scipro.grading;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.feedback.FencedFeedbackPanel;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
@ -15,6 +16,7 @@ import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
import se.su.dsv.scipro.file.FileDescription;
import se.su.dsv.scipro.file.FileReference;
import se.su.dsv.scipro.file.FileService;
@ -77,15 +79,21 @@ public class UploadTextMatchingPanel extends GenericPanel<Project> {
public UploadPlagiarismAnalysisForm(String id, IModel<FinalThesis> finalThesisModel) {
super(id, finalThesisModel);
add(new FencedFeedbackPanel("feedback", this));
IModel<FileDescription> finalThesisDocument = finalThesisModel.map(FinalThesis::getDocument).map(FileReference::getFileDescription);
add(new ViewAttachmentPanel("final_thesis_document", finalThesisDocument));
add(new UrkundSubmissionPanel("text_matching_report", finalThesisDocument));
this.textMatchingDocumentField = new FileUploadField("textMatchingDocument");
this.textMatchingDocumentField.setRequired(true);
this.textMatchingDocumentField.setLabel(new ResourceModel("label_text_matching_document"));
add(this.textMatchingDocumentField);
this.commentField = new TextArea<>("comment", new Model<>());
this.commentField.setRequired(true);
this.commentField.setLabel(new ResourceModel("label_comment"));
add(this.commentField);
WebMarkupContainer buttons = new WebMarkupContainer("buttons");

@ -1 +1,3 @@
minor_plagiarism_forum_subject=Minor plagiarism issues to address
label_text_matching_document=Text matching document
label_comment=Comment

@ -19,6 +19,7 @@
</div>
</wicket:enclosure>
<form wicket:id="form">
<div class="mb-3" wicket:id="feedback"></div>
<div class="mb-3">
<label class="col-form-label">Final thesis document</label>
<p class="form-control-plaintext" wicket:id="final_thesis_document"></p>
@ -28,11 +29,15 @@
<p class="form-control-plaintext" wicket:id="text_matching_report"></p>
</div>
<div class="mb-3">
<label class="col-form-label" wicket:for="textMatchingDocument">Text matching document</label>
<label class="col-form-label" wicket:for="textMatchingDocument">
<wicket:label for="textMatchingDocument"/>
</label>
<input required type="file" class="form-control" wicket:id="textMatchingDocument">
</div>
<div class="mb-3">
<label class="col-form-label" wicket:for="comment">Comment</label>
<label class="col-form-label" wicket:for="comment">
<wicket:label for="comment"/>
</label>
<textarea required class="form-control" wicket:id="comment"></textarea>
</div>
<div wicket:id="buttons">