Skip to content

Commit

Permalink
Merge pull request #130 from correctexam/develop
Browse files Browse the repository at this point in the history
update timestamp also for hybrid comment
  • Loading branch information
barais authored Mar 6, 2024
2 parents 78427dc + 6cd4664 commit b72155a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/main/java/fr/istic/service/StudentResponseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import jakarta.transaction.Transactional;

import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -145,4 +144,16 @@ public Optional<StudentResponseDTO> partialeNoteUpdate(StudentResponseNote noted

}

@Transactional
public void updateCorrectedBy(long id,User updatedBy) {
Optional<StudentResponse> sr = StudentResponse.findByIdOptional(id);
if (sr.isPresent()){
StudentResponse sr1 = sr.get();
sr1.lastModifiedDate = Instant.now();
sr1.correctedBy = updatedBy;
StudentResponse.persistOrUpdate(sr1);
}

}

}
9 changes: 8 additions & 1 deletion src/main/java/fr/istic/web/rest/ExtendedAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import fr.istic.service.QuestionService;
import fr.istic.service.ScanService;
import fr.istic.service.SecurityService;
import fr.istic.service.StudentResponseService;

import org.apache.commons.io.IOUtils;
import org.eclipse.microprofile.config.inject.ConfigProperty;
Expand Down Expand Up @@ -126,6 +127,10 @@ public class ExtendedAPI {

private final Logger log = LoggerFactory.getLogger(ExtendedAPI.class);


@Inject
StudentResponseService studentResponseService;

@Inject
CourseGroupService courseGroupService;

Expand Down Expand Up @@ -669,7 +674,7 @@ public Response sendResultToStudent(MailResultDTO dto, @PathParam("examId") long

} else {
if (count > 0 && sheet == null){
mailService.sendEmail("[email protected]", " FinalResult but no sheet for studentId: " + student.id + ", studentname: " + student.name + ", exam.id: " +ex.id, "[CorrectExam] strange behavior", "[email protected]");
// mailService.sendEmail("[email protected]", " FinalResult but no sheet for studentId: " + student.id + ", studentname: " + student.name + ", exam.id: " +ex.id, "[CorrectExam] strange behavior", "[email protected]");
}
if (dto.isMailabi() && dto.getSheetuuid() == null) {
String body = dto.getBodyabi();
Expand Down Expand Up @@ -2652,6 +2657,7 @@ public Response updateAnswerHybridCommentWithStepValue(@PathParam("responseId")
if (!securityService.canAccess(ctx, responseId, StudentResponse.class)) {
return Response.status(403, "Current user cannot access this ressource").build();
}
this.studentResponseService.updateCorrectedBy(responseId,this.securityService.getCurrentLoggedUser(ctx));
Answer2HybridGradedCommentDTO result = this.answer2HybridGradedCommentService
.setStepValueWithResponseIdAndHybridCommentId(responseId, hybridCommentId, stepValue);
return Response.ok().entity(result).build();
Expand All @@ -2669,6 +2675,7 @@ public Response updateAnswerHybridCommentWith(@PathParam("responseId") final lon
if (!securityService.canAccess(ctx, responseId, StudentResponse.class)) {
return Response.status(403, "Current user cannot access this ressource").build();
}
this.studentResponseService.updateCorrectedBy(responseId,this.securityService.getCurrentLoggedUser(ctx));
Answer2HybridGradedCommentDTO result = this.answer2HybridGradedCommentService
.incrementWithResponseIdAndHybridCommentId(responseId, hybridCommentId);
return Response.ok().entity(result).build();
Expand Down

0 comments on commit b72155a

Please sign in to comment.