Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<properties-maven-plugin.version>1.0.0</properties-maven-plugin.version>
<quarkus-plugin.version>3.19.2</quarkus-plugin.version>
<quarkus-plugin.version>3.25.4</quarkus-plugin.version>
<quarkus.logManager>org.jboss.logmanager.LogManager</quarkus.logManager>
<quarkus.platform.version>3.19.2</quarkus.platform.version>
<quarkus.platform.version>3.25.4</quarkus.platform.version>
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
</properties>
<dependencyManagement>
Expand All @@ -58,7 +58,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.4</version>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.quarkus/quarkus-awt -->
<dependency>
Expand All @@ -76,7 +76,7 @@
<dependency>
<groupId>io.quarkiverse.minio</groupId>
<artifactId>quarkus-minio</artifactId>
<version>3.7.7</version>
<version>3.8.4</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -123,7 +123,7 @@
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.6</version>
<version>9.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -171,7 +171,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
Expand All @@ -193,13 +193,13 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.5.1</version>
<version>5.5.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.1</version>
<version>3.27.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/fr/istic/domain/Answer2HybridGradedComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import io.quarkus.hibernate.orm.panache.PanacheQuery;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.io.Serializable;
import java.util.Set;

import jakarta.json.bind.annotation.JsonbTransient;
import jakarta.persistence.*;
import org.hibernate.annotations.Cache;
Expand Down Expand Up @@ -124,6 +126,12 @@ public static long deleteAllAnswerHybridGradedCommentByCommentId(long commentId
public static long deleteAllAnswerHybridGradedCommentByAnswerId(long responseId){
return delete("studentResponse.id", responseId);
}
public static long deleteAllByQIds( Set<Long> qids){
return delete("delete from Answer2HybridGradedComment ar where ar.studentResponse.question.id in ?1", qids);
}
public static long deleteAllAnswerHybridGradedCommentByCommentIds(Set<Long> commentIds){
return delete("delete from Answer2HybridGradedComment ar where ar.hybridcomments.id in ?1", commentIds);
}



Expand Down
1 change: 1 addition & 0 deletions src/main/java/fr/istic/domain/Comments.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import jakarta.json.bind.annotation.JsonbTransient;
import io.quarkus.hibernate.orm.panache.PanacheQuery;
import io.quarkus.logging.Log;
import io.quarkus.runtime.annotations.RegisterForReflection;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/fr/istic/domain/HybridGradedComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import io.quarkus.hibernate.orm.panache.PanacheQuery;
import io.quarkus.logging.Log;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.io.Serializable;
import java.util.HashSet;
Expand Down Expand Up @@ -47,7 +48,7 @@ public class HybridGradedComment extends PanacheEntityBase implements Serializab
@JsonbTransient
public Question question;

@OneToMany(mappedBy = "hybridcomments")
@OneToMany(mappedBy = "hybridcomments", cascade = CascadeType.REMOVE, orphanRemoval = true)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public Set<Answer2HybridGradedComment> valueAnswers = new HashSet<>();

Expand Down Expand Up @@ -133,6 +134,10 @@ public static HybridGradedComment persistOrUpdate(HybridGradedComment hybridGrad
public static PanacheQuery<HybridGradedComment> findByQuestionId( long qid) {
return find("select hybridGradedComment from HybridGradedComment hybridGradedComment where hybridGradedComment.question.id =?1", qid);
}
public static PanacheQuery<HybridGradedComment> findByExamId( long qid) {
return find("select hybridGradedComment from HybridGradedComment hybridGradedComment where hybridGradedComment.question.exam.id =?1", qid);
}


public static PanacheQuery<HybridGradedComment> canAccess(long commentId, String login) {
return find("select ex from HybridGradedComment ex join ex.question.exam.course.profs as u where ex.id =?1 and u.login =?2", commentId, login);
Expand Down
30 changes: 27 additions & 3 deletions src/main/java/fr/istic/service/CourseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.stream.Collectors;

@ApplicationScoped
@Transactional
public class CourseService {

private final Logger log = LoggerFactory.getLogger(CourseService.class);
Expand All @@ -50,12 +49,37 @@ public CourseDTO persistOrUpdate(CourseDTO courseDTO) {
*
* @param id the id of the entity.
*/
@Transactional
protected void prepareDelete(Long id) {
Course.findByIdOptional(id).ifPresent(course -> {
List<Exam> exams = new ArrayList<>();
exams.addAll(Exam.findExambyCourseId(id).list());
exams.forEach(exam-> this.examService.delete(exam.id));
});
}



/**
* Delete the Course by id.
*
* @param id the id of the entity.
*/
public void delete(Long id) {
log.debug("Request to delete Course : {}", id);
this.prepareDelete(id);
this.deleteinternal(id);
}


/**
* Delete the Course by id.
*
* @param id the id of the entity.
*/
@Transactional
protected void deleteinternal(Long id) {

Course.findByIdOptional(id).ifPresent(course -> {
Exam.findExambyCourseId(id).list().forEach(exam-> this.examService.delete(exam.id));
Course c = Course.findById(id);
c.groups.forEach(g -> {
g.students.forEach(st -> {
Expand Down
60 changes: 42 additions & 18 deletions src/main/java/fr/istic/service/ExamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import fr.istic.domain.FinalResult;
import fr.istic.domain.GradedComment;
import fr.istic.domain.HybridGradedComment;
import fr.istic.domain.Prediction;
import fr.istic.domain.Question;
import fr.istic.domain.QuestionType;
import fr.istic.domain.Scan;
Expand Down Expand Up @@ -76,20 +77,29 @@ public ExamDTO persistOrUpdate(ExamDTO examDTO) {
*
* @param id the id of the entity.
*/
@Transactional
public void delete(Long id) {
log.debug("Request to delete Exam : {}", id);
Exam.findByIdOptional(id).ifPresent(exam -> {
StudentResponse.getAll4ExamIdEvenOrphan(id).list().forEach(sr -> {
this.prepareDeleteExam(id);
this.deleteExam(id);


}

@Transactional
public void prepareDeleteExam(long id){
Exam.findByIdOptional(id).ifPresent(exam -> {
ExamSheet.getAll4ExamIdEvenOrphan(id).list().forEach(sr -> sr.cleanBeforDelete());
/*StudentResponse.getAll4ExamIdEvenOrphan(id).list().forEach(sr -> {
sr.clearComments();
Answer2HybridGradedComment.deleteAllAnswerHybridGradedCommentByAnswerId(sr.id);
});

ExamSheet.getAll4ExamIdEvenOrphan(id).list().forEach(sr -> sr.cleanBeforDelete());
StudentResponse.getAll4ExamIdEvenOrphan(id).list().forEach(sr -> sr.delete());
FinalResult.getAll4ExamId(id).list().forEach(f -> f.delete());
var s = HybridGradedComment.deleteByQIds(e.questions.stream().map(q -> q.id).collect(Collectors.toSet()));
log.error("to remove" + s);*/
this.deleteQuestionCommentAndZone(id);
Exam e = Exam.findById(id);
HybridGradedComment.deleteByQIds(e.questions.stream().map(q -> q.id).collect(Collectors.toSet()));

if (e.scanfile != null && this.fichierS3Service.isObjectExist("scan/" + e.scanfile.id + ".pdf")) {
try {
Expand All @@ -109,11 +119,18 @@ public void delete(Long id) {
e1.printStackTrace();
}
}
exam.delete();
Comments.deleteCommentByExamId("" + id);

this.cacheService.deleteFile(id);
});

}


@Transactional
protected void deleteExam(long id){
var e = Exam.findById(id);
e.delete();

}

@Transactional
Expand Down Expand Up @@ -169,11 +186,18 @@ protected void cleanExamZone(Set<Long> zoneids) {

@Transactional
protected void cleanQuestion(long examId, Set<Long> qids) {
StudentResponse.deleteByQIds(qids);
TextComment.deleteByQIds(qids);
GradedComment.deleteByQIds(qids);
var s = Answer2HybridGradedComment.deleteAllByQIds(qids);
Set<Long> cids = HybridGradedComment.findByExamId(examId).list().stream().map(ex -> ex.id).collect(Collectors.toSet());
s = Answer2HybridGradedComment.deleteAllAnswerHybridGradedCommentByCommentIds(cids);
s= StudentResponse.deleteByQIds(qids);
s= TextComment.deleteByQIds(qids);
s= GradedComment.deleteByQIds(qids);
s= HybridGradedComment.deleteByQIds(qids);
s=Prediction.deleteByQIds(qids);
}
@Transactional
protected void removeQuestion(long examId, Set<Long> qids) {
Question.deleteAllExamId(examId);

}

@Transactional
Expand All @@ -187,16 +211,16 @@ protected void cleanFinalResult(long id) {
*
* @param id the id of the entity.
*/
@Transactional
public void deleteQuestionCommentAndZone(Long id) {
log.debug("Request to delete Exam : {}", id);
Set<Long> qids = Question.findQuestionbyExamId(id).list().stream().map(ex -> ex.id).collect(Collectors.toSet());
public void deleteQuestionCommentAndZone(Long examid) {
log.debug("Request to delete Exam : {}", examid);
Set<Long> qids = Question.findQuestionbyExamId(examid).list().stream().map(ex -> ex.id).collect(Collectors.toSet());

this.cleanFinalResult(id);
Set<Long> zonesids = this.cleanExamZone(id);
this.cleanFinalResult(examid);
Set<Long> zonesids = this.cleanExamZone(examid);
this.cleanExamZone(zonesids);
// this.cleanStudentRssponse(id);
this.cleanQuestion(id, qids);
this.cleanQuestion(examid, qids);
this.removeQuestion(examid, qids);

}

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/fr/istic/service/FichierS3Service.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package fr.istic.service;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,14 @@ quarkus.native.additional-build-args=\
quarkus.http.limits.max-body-size=10G
upload.directory= /tmp/files

quarkus.minio.url=http://localhost:9000
quarkus.minio.host=localhost
quarkus.minio.port=9000

quarkus.minio.access-key=admin
quarkus.minio.secret-key=minioadmin
quarkus.minio.secure=false
quarkus.minio.devservices.enabled=false


# quarkus.minio.allow-empty=false

Expand Down