diff --git a/src/main/java/fr/istic/domain/Question.java b/src/main/java/fr/istic/domain/Question.java index 264314c..3a5b854 100644 --- a/src/main/java/fr/istic/domain/Question.java +++ b/src/main/java/fr/istic/domain/Question.java @@ -54,6 +54,16 @@ public class Question extends PanacheEntityBase implements Serializable { @Column(name = "randomhorizontalcorrection") public Boolean randomHorizontalCorrection; + @Column(name = "canexceedthemax") + public Boolean canExceedTheMax; + + @Column(name = "canbenegative") + public Boolean canBeNegative; + + @Column(name = "mustbeignoreinglobalscale") + public Boolean mustBeIgnoreInGlobalScale; + + @OneToOne(cascade = CascadeType.REMOVE) @JoinColumn(unique = true) @@ -140,6 +150,9 @@ public static Question update(Question question) { entity.type = question.type; entity.exam = question.exam; entity.randomHorizontalCorrection = question.randomHorizontalCorrection; + entity.canBeNegative = question.canBeNegative; + entity.canExceedTheMax = question.canExceedTheMax; + entity.mustBeIgnoreInGlobalScale =question.mustBeIgnoreInGlobalScale; } return entity; } diff --git a/src/main/java/fr/istic/service/HybridGradedCommentService.java b/src/main/java/fr/istic/service/HybridGradedCommentService.java index e323afb..f952c8b 100644 --- a/src/main/java/fr/istic/service/HybridGradedCommentService.java +++ b/src/main/java/fr/istic/service/HybridGradedCommentService.java @@ -77,9 +77,9 @@ public HybridGradedCommentDTO persistOrUpdate(HybridGradedCommentDTO hybridGrade } var point = st.question.quarterpoint !=null ? st.question.quarterpoint.doubleValue(): 0.0; currentNote = (point * pourcentage) / 400.0 + absoluteNote2Add; - if (currentNote > point) { + if (currentNote > point && !st.question.canExceedTheMax) { currentNote = point; - } else if (currentNote < 0) { + } else if (currentNote < 0 && !st.question.canBeNegative) { currentNote = 0; } st.quarternote = Double.valueOf(currentNote*100).intValue(); diff --git a/src/main/java/fr/istic/service/ImportExportService.java b/src/main/java/fr/istic/service/ImportExportService.java index ef84dae..601fd95 100644 --- a/src/main/java/fr/istic/service/ImportExportService.java +++ b/src/main/java/fr/istic/service/ImportExportService.java @@ -245,6 +245,12 @@ public JsonObject export(long courseId, boolean includeStudentData, long eid) { questionJ.addProperty("libelle", question.libelle); questionJ.addProperty("gradeType", question.gradeType.name()); questionJ.addProperty("type", question.type.algoName); + questionJ.addProperty("randomHorizontalCorrection", question.randomHorizontalCorrection); + questionJ.addProperty("canExceedTheMax", question.canExceedTheMax); + questionJ.addProperty("canBeNegative", question.canBeNegative); + questionJ.addProperty("mustBeIgnoreInGlobalScale", question.mustBeIgnoreInGlobalScale); + + if (question.zone != null) { Zone zone = Zone.findById(question.zone.id); @@ -1008,6 +1014,29 @@ public Course importCourse(JsonObject _course, User user, boolean includeStudent .findQuestionTypebyAlgoName(gr.getAsJsonObject().get("type").getAsString()) .firstResult(); } + if (gr.getAsJsonObject().get("randomHorizontalCorrection") != null) { + question.randomHorizontalCorrection = gr.getAsJsonObject().get("randomHorizontalCorrection").getAsBoolean(); + } else { + question.randomHorizontalCorrection =false; + } + if (gr.getAsJsonObject().get("canExceedTheMax") != null) { + question.canExceedTheMax = gr.getAsJsonObject().get("canExceedTheMax").getAsBoolean(); + } else { + question.canExceedTheMax =false; + } + if (gr.getAsJsonObject().get("canBeNegative") != null) { + question.canBeNegative = gr.getAsJsonObject().get("canBeNegative").getAsBoolean(); + } else { + question.canBeNegative =false; + } + if (gr.getAsJsonObject().get("mustBeIgnoreInGlobalScale") != null) { + question.mustBeIgnoreInGlobalScale = gr.getAsJsonObject().get("mustBeIgnoreInGlobalScale").getAsBoolean(); + } else { + question.mustBeIgnoreInGlobalScale =false; + } + + + question.persistAndFlush(); uuidId.put(gr.getAsJsonObject().get("uuid").getAsString(), question.id); }); diff --git a/src/main/java/fr/istic/service/QuestionService.java b/src/main/java/fr/istic/service/QuestionService.java index fd5a63a..c9d1feb 100644 --- a/src/main/java/fr/istic/service/QuestionService.java +++ b/src/main/java/fr/istic/service/QuestionService.java @@ -81,9 +81,9 @@ public QuestionDTO persistOrUpdate(QuestionDTO questionDTO) { } var point = question.quarterpoint !=null ? question.quarterpoint.doubleValue(): 0.0; currentNote = (point * pourcentage) / 400.0 + absoluteNote2Add; - if (currentNote > point) { + if (currentNote > point && !st.question.canExceedTheMax) { currentNote = point; - } else if (currentNote < 0) { + } else if (currentNote < 0 && !st.question.canBeNegative) { currentNote = 0; } st.quarternote = Double.valueOf(currentNote*100).intValue(); diff --git a/src/main/java/fr/istic/service/dto/QuestionDTO.java b/src/main/java/fr/istic/service/dto/QuestionDTO.java index 31dd0b8..e9ee9c1 100644 --- a/src/main/java/fr/istic/service/dto/QuestionDTO.java +++ b/src/main/java/fr/istic/service/dto/QuestionDTO.java @@ -2,7 +2,6 @@ import io.quarkus.runtime.annotations.RegisterForReflection; -import jakarta.persistence.Column; import jakarta.validation.constraints.*; import java.io.Serializable; @@ -38,6 +37,10 @@ public class QuestionDTO implements Serializable { public Long examId; public String examName; public Boolean randomHorizontalCorrection; + public Boolean canExceedTheMax; + public Boolean canBeNegative; + public Boolean mustBeIgnoreInGlobalScale; + @Override public boolean equals(Object o) { diff --git a/src/main/java/fr/istic/web/rest/ExtendedAPI.java b/src/main/java/fr/istic/web/rest/ExtendedAPI.java index 666d56d..c5818c5 100644 --- a/src/main/java/fr/istic/web/rest/ExtendedAPI.java +++ b/src/main/java/fr/istic/web/rest/ExtendedAPI.java @@ -2242,10 +2242,10 @@ private void computeNote4Hybrid(StudentResponse resp) { currentNote = ((point * pourcentage) / 400.0) + absoluteNote2Add; - if (currentNote > point) { + if (currentNote > point && !resp.question.canExceedTheMax) { // log.error("currentNote " + currentNote + " " + point + " " + resp.question.numero); currentNote = point; - } else if (currentNote < 0) { + } else if (currentNote < 0 && !resp.question.canBeNegative) { currentNote = 0; } // log.error("question " + resp.question.numero+ " currentNote " + Double.valueOf(currentNote /4)); diff --git a/src/main/resources/db/migration/V1__Initial_version.sql b/src/main/resources/db/migration/V1__Initial_version.sql index 9cf104a..a5950ac 100644 --- a/src/main/resources/db/migration/V1__Initial_version.sql +++ b/src/main/resources/db/migration/V1__Initial_version.sql @@ -955,6 +955,12 @@ INSERT INTO `jhi_user_authority` (`user_id`, `authority_name`) VALUES alter table question add column randomhorizontalcorrection bit default 0; +alter table question add column canexceedthemax bit(1) NOT NULL default 0; + +alter table question add column canbenegative bit(1) NOT NULL default 0; + +alter table question add column mustbeignoreinglobalscale bit(1) NOT NULL default 0; + COMMIT;