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
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import java.util.Date;
import java.util.List;

@JsonIgnoreProperties({"marksAwarded"})
@DTOMapping(LLMFreeTextQuestionValidationResponseDTO.class)
public class LLMFreeTextQuestionValidationResponse extends QuestionValidationResponse {
private List<LLMFreeTextMarkSchemeEntry> markBreakdown;
private Integer marksAwarded;

public LLMFreeTextQuestionValidationResponse() {
}
Expand All @@ -30,7 +30,4 @@ public List<LLMFreeTextMarkSchemeEntry> getMarkBreakdown() {
public void setMarkBreakdown(List<LLMFreeTextMarkSchemeEntry> markBreakdown) {
this.markBreakdown = markBreakdown;
}

public Integer getMarksAwarded() { return marksAwarded; }
public void setMarksAwarded(Integer marksAwarded) { this.marksAwarded = marksAwarded; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import java.util.List;

@JsonIgnoreProperties({"marksAwarded"})
public class LLMFreeTextQuestionValidationResponseDTO extends QuestionValidationResponseDTO {
private List<LLMFreeTextMarkSchemeEntryDTO> markBreakdown;
private Integer marksAwarded;

public LLMFreeTextQuestionValidationResponseDTO() {
}
Expand All @@ -18,7 +18,4 @@ public List<LLMFreeTextMarkSchemeEntryDTO> getMarkBreakdown() {
public void setMarkBreakdown(List<LLMFreeTextMarkSchemeEntryDTO> markBreakdown) {
this.markBreakdown = markBreakdown;
}

public Integer getMarksAwarded() { return marksAwarded; }
public void setMarksAwarded(Integer marksAwarded) { this.marksAwarded = marksAwarded; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ private LLMFreeTextQuestionValidationResponse generateQuestionValidationResponse

LLMFreeTextQuestionValidationResponse validationResponse = new LLMFreeTextQuestionValidationResponse(
question.getId(), answer, isConsideredCorrect, null, new Date());
// TODO: Remove marksAwarded field once database migration has occurred to remove it from question_attempts JSON
// (both fields are currently required for backwards compatibility)
validationResponse.setMarks(markTotal);
validationResponse.setMarksAwarded(markTotal);
validationResponse.setMarkBreakdown(markBreakdown);
return validationResponse;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
UPDATE question_attempts
SET question_attempt =
jsonb_set(
question_attempt - 'marksAwarded',
'{marks}',
question_attempt->'marksAwarded'
)
WHERE question_attempt ? 'marksAwarded';
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,17 @@ public static LLMFreeTextQuestionValidationResponse validate(Question question,
* @param response - response from the validator, the object we examine by performing assertions.
* @param isCorrect - whether the response should be marked as correct or incorrect. Use provided constants
* CORRECT, INCORRECT.
* @param marksAwarded - how many marks should be awarded in total for the question. This is calculated from
* @param marks - how many marks should be awarded in total for the question. This is calculated from
* the breakdown specified during the act part. Use provided constants NO_MARKS,
* ONE_MARK, TWO_MARKS.
* @param expectedMarks - double check that the breakdown is returned in the expected format
*/
public static void expectMark(LLMFreeTextQuestionValidationResponse response,
boolean isCorrect,
int marksAwarded,
int marks,
List<LLMFreeTextMarkSchemeEntry> expectedMarks) {
assertEquals(isCorrect, response.isCorrect());
assertEquals(marksAwarded, (long) response.getMarks());
assertEquals(marks, (long) response.getMarks());
assertTrue(expectedMarks.containsAll(response.getMarkBreakdown()));
assertTrue(response.getMarkBreakdown().containsAll(expectedMarks));
}
Expand Down
Loading