Skip to content

Commit

Permalink
add support for negative score and bonus in hybrid mode
Browse files Browse the repository at this point in the history
  • Loading branch information
barais committed Oct 23, 2024
1 parent eaf2779 commit 3046100
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/main/java/fr/istic/domain/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/istic/service/QuestionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/fr/istic/service/dto/QuestionDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import io.quarkus.runtime.annotations.RegisterForReflection;
import jakarta.persistence.Column;
import jakarta.validation.constraints.*;
import java.io.Serializable;

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/istic/web/rest/ExtendedAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/db/migration/V1__Initial_version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3046100

Please sign in to comment.