Allow authors to re-submit their reflection on supervisor's request #12

Closed
ansv7779 wants to merge 8 commits from 3213-reflection-resubmission into develop
4 changed files with 156 additions and 1 deletions
Showing only changes of commit fc3bc9e871 - Show all commits

View File

@ -34,6 +34,7 @@ import se.su.dsv.scipro.reflection.ReflectionService;
import se.su.dsv.scipro.report.AbstractGradingCriterion; import se.su.dsv.scipro.report.AbstractGradingCriterion;
import se.su.dsv.scipro.report.GradingCriterion; import se.su.dsv.scipro.report.GradingCriterion;
import se.su.dsv.scipro.report.GradingCriterionPoint; import se.su.dsv.scipro.report.GradingCriterionPoint;
import se.su.dsv.scipro.report.GradingReport;
import se.su.dsv.scipro.report.SupervisorGradingReport; import se.su.dsv.scipro.report.SupervisorGradingReport;
import se.su.dsv.scipro.system.Language; import se.su.dsv.scipro.system.Language;
import se.su.dsv.scipro.system.User; import se.su.dsv.scipro.system.User;
@ -271,7 +272,10 @@ public class CriteriaPanel extends GenericPanel<SupervisorGradingReport> {
modal = new LargeModalWindow("modal"); modal = new LargeModalWindow("modal");
modal.setTitle("Reflection"); modal.setTitle("Reflection");
modal.setContent(id_ -> new MultiLineLabel(id_, new NullReplacementModel(reflection, "No reflection filled in."))); modal.setContent(modalBodyId -> {
IModel<Project> projectModel = CriteriaPanel.this.getModel().map(GradingReport::getProject);
return new ReflectionModalBodyPanel(modalBodyId, projectModel, author);
});
add(modal); add(modal);
WebMarkupContainer showReflection = new WebMarkupContainer("showReflection") { WebMarkupContainer showReflection = new WebMarkupContainer("showReflection") {

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<wicket:enclosure>
<div class="alert alert-info">
<h4 class="alert-heading">
<wicket:message key="improvements_requested">
You've requested improvements to the submitted version.
</wicket:message>
</h4>
<wicket:container class="mb-0" wicket:id="improvements_needed_supervisor_feedback">
[Supervisor feedback on needed improvements]
</wicket:container>
</div>
</wicket:enclosure>
<wicket:container wicket:id="reflection_text">
[Authors submitted reflection]
</wicket:container>
<form wicket:id="request_improvements_form">
<hr>
<p>
<wicket:message key="request_improvements_text">
Please provide feedback on what improvements are needed in the submitted version.
</wicket:message>
</p>
<div class="mb-3">
<label class="form-label" wicket:for="comment">
<wicket:message key="comment">
Comment
</wicket:message>
</label>
<textarea class="form-control" wicket:id="comment" rows="5"></textarea>
</div>
<button class="btn btn-primary" wicket:id="submit">
<wicket:message key="request_improvements">
Request improvements
</wicket:message>
</button>
</form>
</wicket:panel>
</body>
</html>

View File

@ -0,0 +1,99 @@
package se.su.dsv.scipro.grading;
import jakarta.inject.Inject;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import se.su.dsv.scipro.project.Project;
import se.su.dsv.scipro.reflection.Reflection;
import se.su.dsv.scipro.reflection.ReflectionService;
import se.su.dsv.scipro.system.User;
/**
* This is not meant to be a re-usable panel and is made specifically to be used
* as the body of the modal dialog that opens when a supervisor views the
* author's reflection as they're doing their final individual assessment.
*/
class ReflectionModalBodyPanel extends Panel {
@Inject
private ReflectionService reflectionService;
private final IModel<Project> projectModel;
private final IModel<User> authorModel;
ReflectionModalBodyPanel(String id, IModel<Project> projectModel, IModel<User> authorModel) {
super(id);
this.projectModel = projectModel;
this.authorModel = authorModel;
setOutputMarkupPlaceholderTag(true); // enable ajax refreshing of the entire body
IModel<Reflection> reflectionModel = projectModel.combineWith(authorModel, reflectionService::getReflection);
add(new MultiLineLabel("reflection_text", reflectionModel.map(this::getReflectionText)));
add(new MultiLineLabel("improvements_needed_supervisor_feedback", reflectionModel
.as(Reflection.ImprovementsNeeded.class)
.map(Reflection.ImprovementsNeeded::commentBySupervisor)) {
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(!getDefaultModelObjectAsString().isBlank());
}
});
add(new RequestImprovementsForm("request_improvements_form", reflectionModel));
}
private String getReflectionText(Reflection reflection) {
if (reflection instanceof Reflection.Submitted submitted) {
return submitted.reflection();
} else if (reflection instanceof Reflection.ImprovementsNeeded improvementsNeeded) {
return improvementsNeeded.oldReflection();
} else {
return getString("reflection_not_submitted");
}
}
@Override
protected void onDetach() {
this.projectModel.detach();
this.authorModel.detach();
super.onDetach();
}
private class RequestImprovementsForm extends Form<Reflection> {
public RequestImprovementsForm(String id, IModel<Reflection> reflectionModel) {
super(id, reflectionModel);
IModel<String> commentModel = new Model<>();
add(new TextArea<>("comment", commentModel));
add(new AjaxSubmitLink("submit") {
@Override
protected void onSubmit(AjaxRequestTarget target) {
super.onSubmit(target);
reflectionService.requestNewReflection(
projectModel.getObject(),
authorModel.getObject());
target.add(ReflectionModalBodyPanel.this);
}
});
}
@Override
protected void onConfigure() {
super.onConfigure();
setVisible(getModelObject() instanceof Reflection.Submitted);
}
}
}

View File

@ -0,0 +1,7 @@
improvements_requested=You've requested improvements to the submitted version.
request_improvements=Request improvements
comment=Comment
reflection_not_submitted=Reflection not submitted yet
request_improvements_text=If the submitted reflection does not meet the minimum requirements \
you can request improvements from the student. The student will be notified and can submit a new reflection. \
Use the comment field to provide feedback to the student.