Skip to content
Snippets Groups Projects
Commit 526b4ceb authored by Otto Visser's avatar Otto Visser
Browse files

Merge branch 'development' into 'master'

Development

See merge request !39
parents 55579385 9d3cb054
No related branches found
Tags
1 merge request!39Development
Showing
with 212 additions and 394 deletions
......@@ -8,7 +8,7 @@ version = "2.0.0"
val javaVersion = JavaVersion.VERSION_11
val labradoorVersion = "1.0.6-SNAPSHOT9"
val labradoorVersion = "1.0.6-SNAPSHOT10"
val libradorVersion = "1.0.3"
val samlVersion = "1.17"
val springBootVersion: String = "2.3.3.RELEASE"
......
......
......@@ -28,9 +28,8 @@ import javax.annotation.PostConstruct;
import nl.tudelft.labracore.api.DbLoaderControllerApi;
import nl.tudelft.labracore.api.dto.*;
import nl.tudelft.submit.model.*;
import nl.tudelft.submit.model.feedback.PersonFeedback;
import nl.tudelft.submit.repository.*;
import nl.tudelft.submit.repository.feedback.FeedbackRepository;
import nl.tudelft.submit.repository.FeedbackRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
......@@ -94,12 +93,13 @@ public class DevDatabaseLoader {
for (int i = 0; i < submissions.size(); i++) {
PersonSummaryDTO person = submissionReviewers.get(i);
if (person != null) {
feedbackRepository.save(PersonFeedback.builder()
feedbackRepository.save(Feedback.builder()
.submissionId(submissions.get(i).getId())
.textualFeedback(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in mi eu arcu blandit maximus id a mauris. Proin convallis non nisl sed dapibus.")
.timestamp(LocalDateTime.now())
.author(SubmitPerson.builder().id(person.getId()).build())
.authorId(person.getId())
.isScriptFeedback(false)
.build());
}
}
......
......
......@@ -48,7 +48,6 @@ public class LibradorConfiguration {
builder.register(ScriptWagonIdDTO.class, ScriptWagon.class);
builder.register(SubmissionNoteIdDTO.class, SubmissionNote.class);
builder.register(SubmitGroupIdDTO.class, SubmitGroup.class);
builder.register(SubmitPersonIdDTO.class, SubmitPerson.class);
builder.register(SwitchEventIdDTO.class, SwitchEvent.class);
builder.register(VersionIdDTO.class, Version.class);
......
......
......@@ -26,10 +26,9 @@ import javax.validation.Valid;
import nl.tudelft.labracore.api.dto.Person;
import nl.tudelft.labracore.api.dto.SubmissionMemberDetailsDTO;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.submit.dto.create.feedback.PersonFeedbackCreateDTO;
import nl.tudelft.submit.dto.id.SubmitPersonIdDTO;
import nl.tudelft.submit.dto.patch.feedback.PersonFeedbackPatchDTO;
import nl.tudelft.submit.dto.view.feedback.FeedbackViewDTO;
import nl.tudelft.submit.dto.create.FeedbackCreateDTO;
import nl.tudelft.submit.dto.patch.FeedbackPatchDTO;
import nl.tudelft.submit.dto.view.FeedbackViewDTO;
import nl.tudelft.submit.service.FeedbackService;
import nl.tudelft.submit.service.SubmissionService;
......@@ -78,15 +77,15 @@ public class FeedbackController {
@PostMapping
@PreAuthorize("@authorizationService.canGiveFeedbackToSubmission(#dto.submissionId)")
public String addPersonFeedback(@AuthenticatedPerson Person person,
@Valid @ModelAttribute("feedbackCreate") PersonFeedbackCreateDTO dto, @RequestParam String page) {
@Valid @ModelAttribute("feedbackCreate") FeedbackCreateDTO dto, @RequestParam String page) {
dto.setAuthor(new SubmitPersonIdDTO(person.getId()));
dto.setAuthorId(person.getId());
dto.setIsScriptFeedback(false);
dto.setTimestamp(LocalDateTime.now());
Long id = feedbackService.addFeedback(dto);
feedbackService.addFeedback(dto);
SubmissionMemberDetailsDTO submission = submissionService
.getSubmissionDetails(dto.getSubmissionId());
SubmissionMemberDetailsDTO submission = submissionService.getSubmissionDetails(dto.getSubmissionId());
if (page.equals("group")) {
return "redirect:/group/" + submission.getGroup().getId();
......@@ -106,10 +105,10 @@ public class FeedbackController {
@Validated
@PatchMapping("/{id}")
@PreAuthorize("@authorizationService.canEditFeedback(#id)")
public String patchFeedback(@PathVariable Long id, @Valid @RequestBody PersonFeedbackPatchDTO patch) {
public String patchFeedback(@PathVariable Long id, @Valid @RequestBody FeedbackPatchDTO patch) {
Long newId = feedbackService.patchFeedback(id, patch);
return "redirect:/submission/" + feedbackService.findSubmissionById(newId);
return "redirect:/submission/" + feedbackService.getFeedbackById(newId).getSubmissionId();
}
}
......@@ -17,6 +17,7 @@
*/
package nl.tudelft.submit.controller;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
......@@ -27,6 +28,9 @@ import javax.validation.constraints.NotNull;
import nl.tudelft.labracore.api.dto.Grade;
import nl.tudelft.labracore.api.dto.GradeCreateDTO;
import nl.tudelft.labracore.api.dto.Person;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.submit.dto.create.grading.GradedFeedbackCreateDTO;
import nl.tudelft.submit.dto.create.grading.SubmitGradeCreateDTO;
import nl.tudelft.submit.dto.patch.grading.GradingFormulaPatchDTO;
import nl.tudelft.submit.dto.view.FormulaTestDTO;
......@@ -35,6 +39,7 @@ import nl.tudelft.submit.model.SubmitAssignment;
import nl.tudelft.submit.model.grading.CalculatedScore;
import nl.tudelft.submit.model.grading.GradingFormula;
import nl.tudelft.submit.service.AssignmentService;
import nl.tudelft.submit.service.FeedbackService;
import nl.tudelft.submit.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -50,15 +55,29 @@ public class GradeController {
@Autowired
private GradeService gradeService;
@Autowired
private FeedbackService feedbackService;
@Autowired
private AssignmentService assignmentService;
@PostMapping("/group/{groupId}")
@PostMapping("/group/{groupId}/{assignmentId}")
@PreAuthorize("@authorizationService.hasStaffRoleForGroup(#groupId)")
public String addGradeForGroup(@PathVariable Long groupId,
@ModelAttribute("gradeCreate") SubmitGradeCreateDTO create) {
gradeService.addGrade(create.getCreateDTO(GradeCreateDTO.SchemeEnum.DUTCH_GRADE)); // TODO
gradeService.updateGradesAfterGradedSubmission(create.getSubmission().getId());
return "redirect:/group/{groupId}";
public String addGradeForGroup(@AuthenticatedPerson Person person, @PathVariable Long groupId,
@PathVariable Long assignmentId,
@ModelAttribute("feedbackCreate") GradedFeedbackCreateDTO create) {
create.setAuthorId(person.getId());
create.setIsScriptFeedback(false);
create.setTimestamp(LocalDateTime.now());
if (create.getGrade() != null) {
Long id = gradeService
.addGrade(create.getGradeCreateDTO(GradeCreateDTO.SchemeEnum.valueOf(assignmentService
.getOrCreateSubmitAssignment(assignmentId).getScoreType().name())));
gradeService.updateGradesAfterGradedSubmission(create.getSubmissionId());
feedbackService.addFeedback(create.getFeedbackCreateDTO(id));
} else {
feedbackService.addFeedback(create.getFeedbackCreateDTO(null));
}
return "redirect:/group/{groupId}?assignment={assignmentId}&submission=" + create.getSubmissionId();
}
@PostMapping("/assignment/{assignmentId}")
......
......
......@@ -22,6 +22,8 @@ import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import javax.validation.Valid;
......@@ -36,9 +38,9 @@ import nl.tudelft.labracore.api.dto.SubmissionCreateDTO;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.submit.dto.create.MailMessageCreateDTO;
import nl.tudelft.submit.dto.create.SubmissionDownloadConfigCreateDTO;
import nl.tudelft.submit.dto.create.feedback.PersonFeedbackCreateDTO;
import nl.tudelft.submit.dto.create.grading.SubmitGradeCreateDTO;
import nl.tudelft.submit.dto.create.grading.GradedFeedbackCreateDTO;
import nl.tudelft.submit.dto.create.note.GroupNoteCreateDTO;
import nl.tudelft.submit.dto.view.labracore.SubmitGroupDetailsDTO;
import nl.tudelft.submit.model.Signature;
import nl.tudelft.submit.security.AuthorizationService;
import nl.tudelft.submit.service.*;
......@@ -110,6 +112,8 @@ public class StudentGroupController {
boolean isTeacher = authorizationService.hasTeacherRoleInModule(moduleId);
model.addAttribute("teacher", isTeacher);
SubmitGroupDetailsDTO group = groupService.getGroupDetails(id, isStaff);
// set up Message Members feature
Map<String, Object> variableMap = new HashMap<>();
variableMap.put("message", "");
......@@ -122,7 +126,7 @@ public class StudentGroupController {
model.addAttribute("createMessageDto", mailDto);
model.addAttribute("group", groupService.getGroupDetails(id, isStaff));
model.addAttribute("group", group);
model.addAttribute("closestAssignmentDeadline", assignmentService
.getClosestDeadlineAssignmentForModule(moduleId));
......@@ -132,14 +136,16 @@ public class StudentGroupController {
model.addAttribute("usersWithoutGroup",
personService.searchByEditionAndUsername(module.getEdition().getId(), ""));
model.addAttribute("feedbackCreate", new PersonFeedbackCreateDTO());
model.addAttribute("createSubmissionDto", new SubmissionCreateDTO()
.group(new StudentGroupIdDTO().id(id)).submitter(new PersonIdDTO().id(person.getId())));
model.addAttribute("submissionDownloadConfigDto", new SubmissionDownloadConfigCreateDTO());
model.addAttribute("grades", group.getSubmissionMap().values().stream()
.flatMap(Collection::stream)
.flatMap(s -> s.getGrades().stream())
.collect(Collectors.toMap(GradeSummaryDTO::getId, Function.identity())));
if (isStaff) {
model.addAttribute("gradeCreate",
SubmitGradeCreateDTO.builder().submission(new SubmissionIdDTO()).build());
model.addAttribute("feedbackCreate", new GradedFeedbackCreateDTO());
} else {
model.addAttribute("finalGrade", gradeService
.getModuleScore(new PersonIdDTO().id(person.getId()), new ModuleIdDTO().id(moduleId))
......
......
......@@ -15,49 +15,56 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.create.feedback;
package nl.tudelft.submit.dto.create;
import java.time.LocalDateTime;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.*;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.librador.dto.create.Create;
import nl.tudelft.librador.dto.id.IdDTO;
import nl.tudelft.submit.model.feedback.Feedback;
import nl.tudelft.submit.repository.feedback.FeedbackRepository;
import nl.tudelft.submit.model.Feedback;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public abstract class FeedbackCreateDTO<D, T extends Feedback<D>, ID extends IdDTO<D, Long>>
extends Create<T> {
public class FeedbackCreateDTO extends Create<Feedback> {
@NotNull
private Long submissionId;
private Role.TypeEnum visibleFor;
@NotBlank
@NotEmpty
private String textualFeedback;
private String fileFeedback;
private ID author;
@NotNull
private Long authorId;
@NotNull
private LocalDateTime timestamp;
public abstract Class<? extends FeedbackRepository<D, T>> repositoryClass();
private Long gradeId;
@NotNull
private Boolean isScriptFeedback;
@Override
public Class<Feedback> clazz() {
return Feedback.class;
}
@Override
protected void configureMapper(ModelMapper mapper) {
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
}
}
/*
* Submit
* Copyright (C) 2020 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.create.feedback;
import java.time.LocalDateTime;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.*;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.librador.SpringContext;
import nl.tudelft.submit.dto.id.SubmitPersonIdDTO;
import nl.tudelft.submit.model.SubmitPerson;
import nl.tudelft.submit.model.feedback.PersonFeedback;
import nl.tudelft.submit.repository.SubmitPersonRepository;
import nl.tudelft.submit.repository.feedback.PersonFeedbackRepository;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class PersonFeedbackCreateDTO
extends FeedbackCreateDTO<SubmitPerson, PersonFeedback, SubmitPersonIdDTO> {
@Builder
public PersonFeedbackCreateDTO(@NotNull Long submissionId, Role.TypeEnum visibleFor,
@NotBlank String textualFeedback, String fileFeedback, @NotNull SubmitPersonIdDTO author,
LocalDateTime timestamp) {
super(submissionId, visibleFor, textualFeedback, fileFeedback, author, timestamp);
}
@Override
public Class<PersonFeedback> clazz() {
return PersonFeedback.class;
}
@Override
public Class<PersonFeedbackRepository> repositoryClass() {
return PersonFeedbackRepository.class;
}
@Override
public PersonFeedback apply() {
SpringContext.getBean(SubmitPersonRepository.class).getOrSave(getAuthor().getId());
return super.apply();
}
}
/*
* Submit
* Copyright (C) 2020 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.create.feedback;
import java.time.LocalDateTime;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.*;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.submit.dto.id.ScriptIdDTO;
import nl.tudelft.submit.model.feedback.ScriptFeedback;
import nl.tudelft.submit.model.script.Script;
import nl.tudelft.submit.repository.feedback.ScriptFeedbackRepository;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ScriptFeedbackCreateDTO extends FeedbackCreateDTO<Script, ScriptFeedback, ScriptIdDTO> {
@Builder
public ScriptFeedbackCreateDTO(@NotNull Long submissionId, Role.TypeEnum visibleFor,
@NotBlank String textualFeedback, String fileFeedback, @NotNull ScriptIdDTO author,
LocalDateTime timestamp) {
super(submissionId, visibleFor, textualFeedback, fileFeedback, author, timestamp);
}
@Override
public Class<ScriptFeedback> clazz() {
return ScriptFeedback.class;
}
@Override
public Class<ScriptFeedbackRepository> repositoryClass() {
return ScriptFeedbackRepository.class;
}
}
......@@ -15,49 +15,79 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.view.feedback;
package nl.tudelft.submit.dto.create.grading;
import java.time.LocalDateTime;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.*;
import nl.tudelft.labracore.api.dto.GradeCreateDTO;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.librador.dto.view.View;
import nl.tudelft.submit.model.feedback.Feedback;
import nl.tudelft.labracore.api.dto.SubmissionIdDTO;
import nl.tudelft.submit.dto.create.FeedbackCreateDTO;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public abstract class FeedbackViewDTO<ID> extends View<Feedback> {
public class GradedFeedbackCreateDTO {
@NotNull
private Long submissionId;
private Role.TypeEnum visibleFor;
@NotEmpty
private String textualFeedback;
private String fileFeedback;
private ID author;
@NotNull
private Long authorId;
@NotNull
private LocalDateTime timestamp;
@NotNull
private Double grade;
@NotNull
private Boolean isScriptFeedback;
/**
* Checks if this feedback is given by person.
* Gets the dto to create a feedback.
*
* @param object the feedback object
* @return true if feedback given by a person
* @param gradeId The id of the grade
* @return The feedback create dto
*/
public static <O extends FeedbackViewDTO> boolean isPersonFeedback(O object) {
return object instanceof PersonFeedbackViewDTO;
public FeedbackCreateDTO getFeedbackCreateDTO(Long gradeId) {
return FeedbackCreateDTO.builder()
.submissionId(submissionId)
.isScriptFeedback(isScriptFeedback)
.authorId(authorId)
.fileFeedback(fileFeedback)
.gradeId(gradeId)
.textualFeedback(textualFeedback)
.timestamp(timestamp)
.visibleFor(visibleFor)
.build();
}
/**
* Checks if this feedback is given by script.
* Gets the dto to create a grade.
*
* @param object the feedback object
* @return true if feedback given by a script
* @param type The type of score for the assignment
* @return The grade create dto
*/
public static <O extends FeedbackViewDTO> boolean isScriptFeedback(O object) {
return object instanceof ScriptFeedbackViewDTO;
public GradeCreateDTO getGradeCreateDTO(GradeCreateDTO.SchemeEnum type) {
return SubmitGradeCreateDTO.builder()
.submission(new SubmissionIdDTO().id(submissionId))
.grade(grade)
.isScriptGraded(isScriptFeedback).build()
.getCreateDTO(type);
}
}
/*
* Submit
* Copyright (C) 2020 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.id;
import nl.tudelft.librador.dto.id.IdDTO;
import nl.tudelft.submit.model.SubmitPerson;
import nl.tudelft.submit.repository.SubmitPersonRepository;
import org.springframework.data.repository.CrudRepository;
public class SubmitPersonIdDTO extends IdDTO<SubmitPerson, Long> {
public SubmitPersonIdDTO() {
super(-1L);
}
public SubmitPersonIdDTO(Long aLong) {
super(aLong);
}
@Override
public Class<? extends CrudRepository<SubmitPerson, Long>> repositoryClass() {
return SubmitPersonRepository.class;
}
@Override
public Class<? extends SubmitPerson> targetClass() {
return null;
}
}
......@@ -15,20 +15,20 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.patch.feedback;
package nl.tudelft.submit.dto.patch;
import java.time.LocalDateTime;
import lombok.*;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.librador.dto.patch.Patch;
import nl.tudelft.submit.model.feedback.Feedback;
import nl.tudelft.submit.repository.feedback.FeedbackRepository;
import nl.tudelft.submit.model.Feedback;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public abstract class FeedbackPatchDTO<D, T extends Feedback<D>> extends Patch<T> {
public class FeedbackPatchDTO extends Patch<Feedback> {
private Role.TypeEnum visibleFor;
......@@ -38,13 +38,7 @@ public abstract class FeedbackPatchDTO<D, T extends Feedback<D>> extends Patch<T
private LocalDateTime timestamp;
public FeedbackPatchDTO(Role.TypeEnum visibleFor, String textualFeedback, String fileFeedback,
LocalDateTime timestamp) {
this.visibleFor = visibleFor;
this.textualFeedback = textualFeedback;
this.fileFeedback = fileFeedback;
this.timestamp = timestamp;
}
private Long gradeId;
@Override
public void applyOneToOne() {
......@@ -52,6 +46,7 @@ public abstract class FeedbackPatchDTO<D, T extends Feedback<D>> extends Patch<T
updateNonNull(textualFeedback, data::setTextualFeedback);
updateNonNull(fileFeedback, data::setFileFeedback);
updateNonNull(timestamp, data::setTimestamp);
updateNonNull(gradeId, data::setGradeId);
}
@Override
......@@ -59,6 +54,4 @@ public abstract class FeedbackPatchDTO<D, T extends Feedback<D>> extends Patch<T
nonEmpty("textualFeedback", textualFeedback);
}
public abstract Class<? extends FeedbackRepository<D, T>> repositoryClass();
}
/*
* Submit
* Copyright (C) 2020 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.patch.feedback;
import java.time.LocalDateTime;
import lombok.*;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.submit.model.SubmitPerson;
import nl.tudelft.submit.model.feedback.PersonFeedback;
import nl.tudelft.submit.repository.feedback.FeedbackRepository;
import nl.tudelft.submit.repository.feedback.PersonFeedbackRepository;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PersonFeedbackPatchDTO extends FeedbackPatchDTO<SubmitPerson, PersonFeedback> {
@Builder
public PersonFeedbackPatchDTO(Role.TypeEnum visibleFor, String textualFeedback, String fileFeedback,
LocalDateTime timestamp) {
super(visibleFor, textualFeedback, fileFeedback, timestamp);
}
@Override
public void applyOneToOne() {
super.applyOneToOne();
}
@Override
public Class<? extends FeedbackRepository<SubmitPerson, PersonFeedback>> repositoryClass() {
return PersonFeedbackRepository.class;
}
}
......@@ -15,22 +15,38 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.view.feedback;
package nl.tudelft.submit.dto.view;
import java.time.LocalDateTime;
import lombok.*;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.submit.dto.id.SubmitPersonIdDTO;
import nl.tudelft.librador.dto.view.View;
import nl.tudelft.submit.model.Feedback;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PersonFeedbackViewDTO extends FeedbackViewDTO<SubmitPersonIdDTO> {
public class FeedbackViewDTO extends View<Feedback> {
private Long id;
private Long submissionId;
private Role.TypeEnum visibleFor;
private String textualFeedback;
private String fileFeedback;
private Long authorId;
private LocalDateTime timestamp;
private Long gradeId;
private Boolean isScriptFeedback;
@Builder
public PersonFeedbackViewDTO(Role.TypeEnum visibleFor, String textualFeedback, String fileFeedback,
SubmitPersonIdDTO author, LocalDateTime timestamp) {
super(visibleFor, textualFeedback, fileFeedback, author, timestamp);
}
}
/*
* Submit
* Copyright (C) 2020 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.dto.view.feedback;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import nl.tudelft.labracore.api.dto.Role;
import nl.tudelft.submit.dto.id.ScriptIdDTO;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ScriptFeedbackViewDTO extends FeedbackViewDTO<ScriptIdDTO> {
@Builder
public ScriptFeedbackViewDTO(Role.TypeEnum visibleFor, String textualFeedback, String fileFeedback,
ScriptIdDTO author, LocalDateTime timestamp) {
super(visibleFor, textualFeedback, fileFeedback, author, timestamp);
}
}
......@@ -20,19 +20,23 @@ package nl.tudelft.submit.dto.view.labracore;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import nl.tudelft.labracore.api.dto.AssignmentSummaryDTO;
import nl.tudelft.labracore.api.dto.Description;
import nl.tudelft.labracore.api.dto.Grade;
@EqualsAndHashCode(callSuper = false)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class SubmitAssignmentSummaryDTO extends WithNoteViewDTO<AssignmentSummaryDTO> {
private Long id;
private String name;
private Description description;
private LocalDateTime deadline;
private Grade.SchemeEnum scoreType;
private Long lateSubmissionLeniency;
private Boolean acceptLateSubmissions;
private String approveScript;
......
......
......@@ -24,7 +24,6 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import nl.tudelft.labracore.api.dto.AssignmentSummaryDTO;
import nl.tudelft.labracore.api.dto.ModuleDivisionSummaryDTO;
import nl.tudelft.labracore.api.dto.StudentGroupDetailsDTO;
......@@ -44,6 +43,6 @@ public class SubmitGroupDetailsDTO extends WithNoteViewDTO<StudentGroupDetailsDT
// private Map<String, Boolean> assignments;
// TODO: Add this field in LC StudentGroup
private SortedMap<AssignmentSummaryDTO, List<SubmitSubmissionViewDTO>> submissionMap;
private SortedMap<SubmitAssignmentSummaryDTO, List<SubmitSubmissionViewDTO>> submissionMap;
}
......@@ -26,7 +26,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import nl.tudelft.labracore.api.dto.*;
import nl.tudelft.submit.dto.view.feedback.FeedbackViewDTO;
import nl.tudelft.submit.dto.view.FeedbackViewDTO;
@Data
@NoArgsConstructor
......
......
......@@ -15,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.model.feedback;
package nl.tudelft.submit.model;
import java.time.LocalDateTime;
......@@ -24,17 +24,17 @@ import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import nl.tudelft.labracore.api.dto.Role;
@Data
@SuperBuilder
@MappedSuperclass
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
public abstract class Feedback<ID> {
public class Feedback {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
......@@ -51,30 +51,15 @@ public abstract class Feedback<ID> {
private String fileFeedback;
@NotNull
@ManyToOne
private ID author;
private Long authorId;
@NotNull
private LocalDateTime timestamp;
/**
* Checks if this feedback is given by person.
*
* @param object the feedback object
* @return true if feedback given by a person
*/
public static <O extends Feedback> boolean isPersonFeedback(O object) {
return object instanceof PersonFeedback;
}
private Long gradeId;
/**
* Checks if this feedback is given by script.
*
* @param object the feedback object
* @return true if feedback given by a script
*/
public static <O extends Feedback> boolean isScriptFeedback(O object) {
return object instanceof ScriptFeedback;
}
@NotNull
@Builder.Default
private Boolean isScriptFeedback = false;
}
/*
* Submit
* Copyright (C) 2020 - Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.submit.model;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;
import lombok.*;
import nl.tudelft.submit.model.feedback.PersonFeedback;
/**
* This entity represents an image of the Person in LabraCORE.
*/
@Data
@Entity
@Embeddable
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SubmitPerson {
@Id
private Long id;
@Builder.Default
@ToString.Exclude
@EqualsAndHashCode.Exclude
@OneToMany(mappedBy = "author")
private List<PersonFeedback> feedbacks = new ArrayList<>();
public SubmitPerson(Long id) {
this.id = id;
feedbacks = new ArrayList<>();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment