Allow changes to the reflection to be made after it's been submitted #13

Merged
ansv7779 merged 20 commits from 3412-supervisor-edit-reflection into develop 2024-11-21 19:20:48 +01:00
6 changed files with 26 additions and 6 deletions
Showing only changes of commit 32353c0d1f - Show all commits

View File

@ -44,6 +44,10 @@ public class Author {
@Column(name = "reflection_status") @Column(name = "reflection_status")
private ReflectionStatus reflectionStatus = ReflectionStatus.NOT_SUBMITTED; private ReflectionStatus reflectionStatus = ReflectionStatus.NOT_SUBMITTED;
@Basic
@Column(name = "reflection_comment_by_supervisor")
private String reflectionSupervisorComment;
public Project getProject() { public Project getProject() {
return project; return project;
} }
@ -76,6 +80,14 @@ public class Author {
this.reflectionStatus = reflectionStatus; this.reflectionStatus = reflectionStatus;
} }
public void setReflectionSupervisorComment(String reflectionSupervisorComment) {
this.reflectionSupervisorComment = reflectionSupervisorComment;
}
public String getReflectionSupervisorComment() {
return reflectionSupervisorComment;
}
@Embeddable @Embeddable
public static class AuthorPK implements Serializable { public static class AuthorPK implements Serializable {
private Long projectId; private Long projectId;

View File

@ -20,8 +20,9 @@ public interface ReflectionService {
* This is done individually by author. * This is done individually by author.
* *
* @param author the author whose reflection does not meet the minimum requirements. * @param author the author whose reflection does not meet the minimum requirements.
* @param supervisorComment feedback provided by the supervisor so the author knows what to improve.
*/ */
void requestNewReflection(Project project, User author); void requestNewReflection(Project project, User author, String supervisorComment);
Reflection getReflection(Project project, User author); Reflection getReflection(Project project, User author);
} }

View File

@ -57,10 +57,11 @@ class ReflectionServiceImpl implements ReflectionService {
@Override @Override
@Transactional @Transactional
public void requestNewReflection(Project project, User user) { public void requestNewReflection(Project project, User user, String supervisorComment) {
authorRepository.findByProjectAndUser(project, user) authorRepository.findByProjectAndUser(project, user)
.ifPresent(author -> { .ifPresent(author -> {
author.setReflectionStatus(ReflectionStatus.IMPROVEMENTS_NEEDED); author.setReflectionStatus(ReflectionStatus.IMPROVEMENTS_NEEDED);
author.setReflectionSupervisorComment(supervisorComment);
}); });
} }
@ -74,7 +75,9 @@ class ReflectionServiceImpl implements ReflectionService {
private Reflection toReflection(Author author) { private Reflection toReflection(Author author) {
return switch (author.getReflectionStatus()) { return switch (author.getReflectionStatus()) {
case SUBMITTED -> new Reflection.Submitted(author.getReflection()); case SUBMITTED -> new Reflection.Submitted(author.getReflection());
case IMPROVEMENTS_NEEDED -> new Reflection.ImprovementsNeeded(author.getReflection(), ""); case IMPROVEMENTS_NEEDED -> new Reflection.ImprovementsNeeded(
author.getReflection(),
author.getReflectionSupervisorComment());
default -> new Reflection.NotSubmitted(); default -> new Reflection.NotSubmitted();
}; };
} }

View File

@ -0,0 +1 @@
ALTER TABLE `project_user` ADD COLUMN `reflection_comment_by_supervisor` TEXT NULL;

View File

@ -114,7 +114,7 @@ public class ReflectionServiceTest extends IntegrationTest {
assertFalse(reflectionService.hasToFillInReflection(project, author), assertFalse(reflectionService.hasToFillInReflection(project, author),
"After submitting the initial reflection it should no longer be required"); "After submitting the initial reflection it should no longer be required");
reflectionService.requestNewReflection(project, author); reflectionService.requestNewReflection(project, author, "Very bad reflection");
assertTrue(reflectionService.hasToFillInReflection(project, author), assertTrue(reflectionService.hasToFillInReflection(project, author),
"After supervisor requests resubmission the author should now be required to submit a new reflection"); "After supervisor requests resubmission the author should now be required to submit a new reflection");
assertEquals(myReflection, reflectionService.getSubmittedReflection(project, author), assertEquals(myReflection, reflectionService.getSubmittedReflection(project, author),

View File

@ -74,7 +74,9 @@ class ReflectionModalBodyPanel extends Panel {
IModel<String> commentModel = new Model<>(); IModel<String> commentModel = new Model<>();
add(new TextArea<>("comment", commentModel)); TextArea<String> comment = new TextArea<>("comment", commentModel);
comment.setRequired(true);
add(comment);
add(new AjaxSubmitLink("submit") { add(new AjaxSubmitLink("submit") {
@Override @Override
@ -83,7 +85,8 @@ class ReflectionModalBodyPanel extends Panel {
reflectionService.requestNewReflection( reflectionService.requestNewReflection(
projectModel.getObject(), projectModel.getObject(),
authorModel.getObject()); authorModel.getObject(),
commentModel.getObject());
target.add(ReflectionModalBodyPanel.this); target.add(ReflectionModalBodyPanel.this);
} }