Allow changes to the reflection to be made after it's been submitted #13
@ -22,4 +22,6 @@ public interface ReflectionService {
|
||||
* @param author the author whose reflection does not meet the minimum requirements.
|
||||
*/
|
||||
void requestNewReflection(Project project, User author);
|
||||
|
||||
Reflection getReflection(Project project, User author);
|
||||
}
|
||||
|
@ -63,4 +63,19 @@ class ReflectionServiceImpl implements ReflectionService {
|
||||
author.setReflectionStatus(ReflectionStatus.IMPROVEMENTS_NEEDED);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reflection getReflection(Project project, User author) {
|
||||
return authorRepository.findByProjectAndUser(project, author)
|
||||
.map(this::toReflection)
|
||||
.orElseGet(Reflection.NotSubmitted::new);
|
||||
}
|
||||
|
||||
private Reflection toReflection(Author author) {
|
||||
return switch (author.getReflectionStatus()) {
|
||||
case SUBMITTED -> new Reflection.Submitted(author.getReflection());
|
||||
case IMPROVEMENTS_NEEDED -> new Reflection.ImprovementsNeeded(author.getReflection(), "");
|
||||
default -> new Reflection.NotSubmitted();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
ALTER TABLE `project_user`
|
||||
ADD COLUMN `reflection_status` VARCHAR(32) NOT NULL DEFAULT 'NOT_SUBMITTED';
|
||||
|
||||
UPDATE `project_user` SET `reflection_status` = 'SUBMITTED' WHERE `reflection` IS NOT NULL;
|
@ -38,7 +38,30 @@
|
||||
<div wicket:id="current_thesis_file"></div>
|
||||
</div>
|
||||
</wicket:enclosure>
|
||||
<p wicket:id="old_reflection"></p>
|
||||
<wicket:enclosure child="old_reflection">
|
||||
<div class="alert alert-info">
|
||||
<h4 class="alert-heading">
|
||||
<wicket:message key="reflection_improvements_needed_heading">
|
||||
Reflection improvements needed
|
||||
</wicket:message>
|
||||
</h4>
|
||||
<p>
|
||||
<wicket:message key="reflection_improvements_needed">
|
||||
Your supervisor has requested that you improve and resubmit your reflection.
|
||||
See their comments below about what changes are necessary.
|
||||
</wicket:message>
|
||||
</p>
|
||||
<p wicket:id="supervisor_comment">
|
||||
[You need to reflect more on the methods you used.]
|
||||
</p>
|
||||
</div>
|
||||
<h4>
|
||||
<wicket:message key="old_reflection">
|
||||
Your previous reflection
|
||||
</wicket:message>
|
||||
</h4>
|
||||
<p wicket:id="old_reflection"></p>
|
||||
</wicket:enclosure>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" wicket:for="reflection">
|
||||
<wicket:message key="reflection">[Reflection]</wicket:message>
|
||||
|
@ -2,7 +2,6 @@ package se.su.dsv.scipro.project.panels;
|
||||
|
||||
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.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
@ -47,17 +46,20 @@ public class FinalStepsPanel extends GenericPanel<Project> {
|
||||
|
||||
add(new FencedFeedbackPanel("feedback", this));
|
||||
|
||||
IModel<String> reflection = LoadableDetachableModel.of(() ->
|
||||
reflectionService.getSubmittedReflection(projectModel.getObject(), SciProSession.get().getUser()));
|
||||
add(new MultiLineLabel("reflection", reflection) {
|
||||
IModel<Reflection> currentReflection = LoadableDetachableModel.of(() ->
|
||||
reflectionService.getReflection(projectModel.getObject(), SciProSession.get().getUser()));
|
||||
IModel<String> reflectionText = currentReflection
|
||||
.as(Reflection.Submitted.class)
|
||||
.map(Reflection.Submitted::reflection);
|
||||
add(new MultiLineLabel("reflection", reflectionText) {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(getDefaultModelObject() != null);
|
||||
setVisible(!getDefaultModelObjectAsString().isBlank());
|
||||
}
|
||||
});
|
||||
|
||||
add(new FinalStepsForm("submit_reflection", projectModel));
|
||||
add(new FinalStepsForm("submit_reflection", projectModel, currentReflection));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,27 +71,40 @@ public class FinalStepsPanel extends GenericPanel<Project> {
|
||||
private class FinalStepsForm extends Form<Project> {
|
||||
private final FinalThesisUploadComponent thesisFileUpload;
|
||||
private final IModel<PublicationMetadata> publicationMetadataModel;
|
||||
private final IModel<Reflection> currentReflection;
|
||||
private IModel<String> reflectionModel;
|
||||
private IModel<PublishingConsentService.Level> levelModel;
|
||||
|
||||
public FinalStepsForm(String id, IModel<Project> projectModel) {
|
||||
public FinalStepsForm(String id, IModel<Project> projectModel, IModel<Reflection> currentReflection) {
|
||||
super(id, projectModel);
|
||||
|
||||
IModel<Reflection> reflectionLoadableDetachableModel = LoadableDetachableModel.of(() -> null);
|
||||
this.currentReflection = currentReflection;
|
||||
|
||||
IModel<Reflection.ImprovementsNeeded> i = reflectionLoadableDetachableModel.as(Reflection.ImprovementsNeeded.class);
|
||||
IModel<Reflection.ImprovementsNeeded> i = this.currentReflection.as(Reflection.ImprovementsNeeded.class);
|
||||
|
||||
IModel<String> labelModel = i.map(Reflection.ImprovementsNeeded::oldReflection);
|
||||
add(new Label("old_reflection", labelModel));
|
||||
IModel<String> oldReflection = i.map(Reflection.ImprovementsNeeded::oldReflection);
|
||||
add(new MultiLineLabel("old_reflection", oldReflection) {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(!getDefaultModelObjectAsString().isBlank());
|
||||
}
|
||||
});
|
||||
|
||||
add(new Label("supervisor_comment", i.map(Reflection.ImprovementsNeeded::commentBySupervisor)));
|
||||
add(new MultiLineLabel("supervisor_comment", i.map(Reflection.ImprovementsNeeded::commentBySupervisor)) {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(!getDefaultModelObjectAsString().isBlank());
|
||||
}
|
||||
});
|
||||
|
||||
reflectionModel = new Model<>();
|
||||
TextArea<String> reflectionTextArea = new TextArea<>("reflection", reflectionModel) {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(reflectionLoadableDetachableModel.getObject().isSubmittable());
|
||||
setVisible(FinalStepsForm.this.currentReflection.getObject().isSubmittable());
|
||||
}
|
||||
};
|
||||
reflectionTextArea.setRequired(true);
|
||||
@ -141,7 +156,7 @@ public class FinalStepsPanel extends GenericPanel<Project> {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(reflectionService.hasToFillInReflection(getModelObject(), SciProSession.get().getUser()));
|
||||
setVisibilityAllowed(currentReflection.getObject().isSubmittable());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,3 +9,7 @@ current_final_thesis=Final thesis
|
||||
publication_metadata_why=Please provide the following metadata.
|
||||
englishTitle=English title
|
||||
swedishTitle=Swedish title
|
||||
reflection_improvements_needed_heading=Reflection improvements needed
|
||||
reflection_improvements_needed=Your supervisor has requested that you improve and resubmit your reflection. \
|
||||
See their comments below about what changes are necessary.
|
||||
old_reflection=Your previous reflection
|
||||
|
Loading…
x
Reference in New Issue
Block a user