Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for negative score and bonus in hybrid mode #140

Merged
merged 2 commits into from
Oct 23, 2024
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
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
29 changes: 29 additions & 0 deletions src/main/java/fr/istic/service/ImportExportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
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
Loading