2984 PO 11) Add ability to remove plagiarism analysis if no student has been submitted for examination.

This commit is contained in:
Andreas Svanberg 2023-10-04 10:06:29 +02:00
parent 206dd24d4c
commit b2af1906d5
5 changed files with 58 additions and 5 deletions
core/src/main/java/se/su/dsv/scipro/finalthesis
view/src/main

@ -21,6 +21,10 @@ public interface FinalThesisService extends GenericService<FinalThesis, Long>,
FinalThesis findByProject(Project project);
Date getRejectedDate(Project project);
boolean canRemovePlagiarismAnalysis(FinalThesis finalThesis);
void removePlagiarismAnalysis(FinalThesis finalThesis);
class Filter implements Serializable {
private FinalThesis.Status status;

@ -18,6 +18,8 @@ import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
import se.su.dsv.scipro.notifications.dataobject.ProjectEvent;
import se.su.dsv.scipro.plagiarism.PlagiarismControl;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.report.GradingReportService;
import se.su.dsv.scipro.report.SupervisorGradingReport;
import se.su.dsv.scipro.system.AbstractServiceImpl;
import javax.inject.Inject;
@ -32,6 +34,7 @@ public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Lon
private final FileService fileService;
private final EventBus eventBus;
private final PlagiarismControl plagiarismControl;
private final GradingReportService gradingReportService;
@Inject
public FinalThesisServiceImpl(
@ -40,7 +43,8 @@ public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Lon
ProjectFileService projectFileService,
final FileService fileService,
final EventBus eventBus,
final PlagiarismControl plagiarismControl)
final PlagiarismControl plagiarismControl,
GradingReportService gradingReportService)
{
super(em, FinalThesis.class, QFinalThesis.finalThesis);
this.notificationController = notificationController;
@ -48,6 +52,7 @@ public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Lon
this.fileService = fileService;
this.eventBus = eventBus;
this.plagiarismControl = plagiarismControl;
this.gradingReportService = gradingReportService;
}
@Override
@ -103,6 +108,23 @@ public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Lon
return findLatestFinalThesis(project).getDateRejected();
}
@Override
public boolean canRemovePlagiarismAnalysis(FinalThesis finalThesis) {
return gradingReportService.getSupervisorGradingReports(finalThesis.getProject())
.stream()
.noneMatch(SupervisorGradingReport::isSubmitted);
}
@Override
@Transactional
public void removePlagiarismAnalysis(FinalThesis finalThesis) {
FileReference textMatchingDocument = finalThesis.getTextMatchingDocument();
finalThesis.setTextMatchingDocument(null);
finalThesis.setTextMatchingAnalysis(null);
fileService.delete(textMatchingDocument);
save(finalThesis);
}
@Override
@Transactional
public void approve(Project project, final String englishTitle, final String swedishTitle) {

@ -5,6 +5,7 @@ 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.Button;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.StatelessForm;
@ -12,6 +13,7 @@ import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.upload.FileUpload;
import org.apache.wicket.markup.html.form.upload.FileUploadField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
@ -53,13 +55,32 @@ public class UploadTextMatchingPanel extends GenericPanel<Project> {
}
};
add(new FencedFeedbackPanel("feedback", this));
add(new UploadPlagiarismAnalysisForm("form", finalThesisModel));
IModel<FileReference> textMatchingDocument = finalThesisModel.map(FinalThesis::getTextMatchingDocument);
add(new ViewAttachmentPanel(
"textMatchingDocument",
finalThesisModel.map(FinalThesis::getTextMatchingDocument).map(FileReference::getFileDescription)));
textMatchingDocument.map(FileReference::getFileDescription)));
add(new Label("text_matching_analysis", finalThesisModel.map(FinalThesis::getTextMatchingAnalysis)));
add(new Link<>("remove", finalThesisModel) {
@Override
public void onClick() {
finalThesisService.removePlagiarismAnalysis(getModelObject());
success(getString("plagiarism_analysis_removed"));
}
@Override
protected void onConfigure() {
super.onConfigure();
boolean canRemovePlagiarismAnalysis = finalThesisService.canRemovePlagiarismAnalysis(getModelObject());
setVisibilityAllowed(canRemovePlagiarismAnalysis);
setVisible(textMatchingDocument.isPresent().getObject());
}
});
add(new WebMarkupContainer("help") {
@Override
protected void onConfigure() {
@ -79,8 +100,6 @@ 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));
@ -161,6 +180,7 @@ public class UploadTextMatchingPanel extends GenericPanel<Project> {
finalThesis.setTextMatchingDocument(textMatchingDocument);
finalThesis.setTextMatchingAnalysis(comment);
finalThesisService.save(finalThesis);
success(getString("plagiarism_analysis_submitted"));
}
private void minorPlagiarismDetected() {

@ -1,3 +1,5 @@
minor_plagiarism_forum_subject=Minor plagiarism issues to address
label_text_matching_document=Text matching document
label_comment=Comment
plagiarism_analysis_removed=Plagiarism analysis removed
plagiarism_analysis_submitted=Plagiarism analysis submitted

@ -8,6 +8,7 @@
Once the text matching is done the report will be made available, and you should read it and determine if
the authors have plagiarised. Submit the text matching report and your analysis of its findings below.
</small>
<div wicket:id="feedback"></div>
<wicket:enclosure child="textMatchingDocument">
<div class="mb-3">
<label class="col-form-label">Text matching document</label>
@ -17,9 +18,13 @@
<label class="col-form-label">Text matching analysis</label>
<p class="form-control-plaintext" wicket:id="text_matching_analysis">[only references]</p>
</div>
<div class="mb-3">
<button type="button" wicket:id="remove" class="btn btn-danger">
Remove
</button>
</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>