Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
20eeb1a
WIP: add IT test for QuestionsFacade
barna-isaac Nov 28, 2025
e6422ff
WIP: validation works for correct, incorrect answers
barna-isaac Nov 28, 2025
160016b
does this trigger a build?
barna-isaac Nov 28, 2025
049c50f
gentle modifications to QuestionFacadeIT
barna-isaac Nov 28, 2025
297343d
merge main
barna-isaac Dec 1, 2025
783fc11
fix failing integration tests
barna-isaac Dec 1, 2025
558eab8
test that build can be broken
barna-isaac Dec 1, 2025
28fc161
Revert "test that build can be broken"
barna-isaac Dec 1, 2025
f398bb3
add integration test for incorrect dnd answer
barna-isaac Dec 1, 2025
3dd00a0
add integration test for correct dnd answer
barna-isaac Dec 1, 2025
dabefac
cloze validator can return explanation
barna-isaac Dec 1, 2025
6317e33
dnd validator determines correctness based on relevance
barna-isaac Dec 1, 2025
537a4e1
test default feedback not returned for correct
barna-isaac Dec 2, 2025
530c1f3
return correct dropzones, for correct only
barna-isaac Dec 2, 2025
99185f3
test validated dnd answer can have explanation
barna-isaac Dec 2, 2025
ef85342
dnd validation endpoint returns `dropZonesCorrect`
barna-isaac Dec 2, 2025
bee2dba
indicate correct dropzones for incorrect answer
barna-isaac Dec 2, 2025
f9d4f48
dropZonesCorrect for multiple correct answers
barna-isaac Dec 2, 2025
7e3521a
ensure default explanation is returned
barna-isaac Dec 2, 2025
908c3b8
add explanations for no answer, missing items
barna-isaac Dec 3, 2025
11a4719
add error states for unrecognized, too many items
barna-isaac Dec 3, 2025
ab39d23
test invalid answers
barna-isaac Dec 3, 2025
86e7c11
invalid answers message returned as explanation
barna-isaac Dec 4, 2025
ec2b36f
validate and log question having choices
barna-isaac Dec 4, 2025
be59245
test question validation for null, empty choices
barna-isaac Dec 8, 2025
45a0246
use data provider for answer validation test cases
barna-isaac Dec 8, 2025
75959a9
use data provider for question validation
barna-isaac Dec 8, 2025
0fd1b57
refactor, remove unnecessary answer calls
barna-isaac Dec 8, 2025
d72c7bf
check when a question contains invalid items
barna-isaac Dec 8, 2025
6da01ae
ensure question does not contain empty answer
barna-isaac Dec 8, 2025
13250ec
test empty answer (as opposed to null)
barna-isaac Dec 9, 2025
583314d
ensure question contains dnd answers
barna-isaac Dec 9, 2025
0a27a69
check that each question has at least 1 correct answer
barna-isaac Dec 9, 2025
51877cb
check that answers default to incorrect
barna-isaac Dec 9, 2025
46b30d8
on question, check answers have valid id, dropZoneId
barna-isaac Dec 9, 2025
7074521
merge main
barna-isaac Dec 11, 2025
805b95d
merge main
barna-isaac Dec 11, 2025
7e84f8b
data provider for correctness tests
barna-isaac Dec 11, 2025
1d46c31
data provider for explanation tests
barna-isaac Dec 11, 2025
da039f4
data provider for dropZonesCorrect tests
barna-isaac Dec 11, 2025
f35da1e
add integration test for invalid question
barna-isaac Dec 11, 2025
cdc1a93
test that items is not empty
barna-isaac Dec 11, 2025
beb0468
prefer correct answers
barna-isaac Dec 11, 2025
15a1010
extract rule validator
barna-isaac Dec 11, 2025
083c155
refactor, remove redundant DndItemChoice class
barna-isaac Dec 12, 2025
cbb19a2
refactor, DO and DTO should not contain logic
barna-isaac Dec 12, 2025
0d2471e
test that partial match does not return feedback
barna-isaac Dec 12, 2025
1915c3c
allow explanation wildcard matches for incorrect
barna-isaac Dec 12, 2025
2cbae10
test explanation incorrect multimatch
barna-isaac Dec 12, 2025
9dab957
refactor QuestionEx class into QuestionHelpers
barna-isaac Dec 15, 2025
de0f598
refactor ChoiceEx class into ChoiceHelpers
barna-isaac Dec 15, 2025
3a7f89d
test null explanation for incorrect answer
barna-isaac Dec 15, 2025
8830d42
validate that question has dropZones
barna-isaac Dec 15, 2025
6da7eee
support finding dropzones in figures
barna-isaac Dec 15, 2025
d76ecdb
handle figures without regions
barna-isaac Dec 15, 2025
b497951
validate question does not contain duplicate drop zones
barna-isaac Dec 15, 2025
02d4b39
correct answers must use all drop zones
barna-isaac Dec 15, 2025
65d4146
answers must contain valid drop zone references
barna-isaac Dec 15, 2025
3aed1d8
user answers most contain valid drop zone references
barna-isaac Dec 15, 2025
e254ee6
extract constants and resolve code style
barna-isaac Dec 15, 2025
e80b77d
resolve style issues
barna-isaac Dec 15, 2025
6438237
resolve copilot autofix warning
barna-isaac Dec 16, 2025
2e11eb8
a gentle refactor
barna-isaac Dec 16, 2025
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
@@ -0,0 +1,61 @@
/*
* Copyright 2022 James Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.ac.cam.cl.dtg.isaac.dos;

import uk.ac.cam.cl.dtg.isaac.dos.content.Choice;
import uk.ac.cam.cl.dtg.isaac.dos.content.Content;

import java.util.Date;
import java.util.Map;


/**
* Class for providing correctness feedback about drag and drop questions in a submitted Choice.
*/
public class DndValidationResponse extends QuestionValidationResponse {
private Map<String, Boolean> dropZonesCorrect;

/**
* Default constructor for Jackson.
*/
public DndValidationResponse() {
}

/**
* Full constructor.
*
* @param questionId - questionId.
* @param answer - answer.
* @param correct - correct.
* @param dropZonesCorrect - map of correctness status of each submitted item. Key: dropZoneId, value: isCorrect
* @param explanation - explanation.
* @param dateAttempted - dateAttempted.
*/
public DndValidationResponse(final String questionId, final Choice answer,
final Boolean correct, final Map<String, Boolean> dropZonesCorrect,
final Content explanation, final Date dateAttempted) {
super(questionId, answer, correct, explanation, dateAttempted);
this.dropZonesCorrect = dropZonesCorrect;
}

public Map<String, Boolean> getDropZonesCorrect() {
return dropZonesCorrect;
}

public void setDropZonesCorrect(final Map<String, Boolean> itemsCorrect) {
this.dropZonesCorrect = itemsCorrect;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@

import uk.ac.cam.cl.dtg.isaac.dos.content.DTOMapping;
import uk.ac.cam.cl.dtg.isaac.dos.content.JsonContentType;
import uk.ac.cam.cl.dtg.isaac.dto.IsaacClozeQuestionDTO;
import uk.ac.cam.cl.dtg.isaac.dto.IsaacDndQuestionDTO;
import uk.ac.cam.cl.dtg.isaac.quiz.IsaacClozeValidator;
import uk.ac.cam.cl.dtg.isaac.quiz.IsaacDndValidator;
import uk.ac.cam.cl.dtg.isaac.quiz.ValidatesWith;


/**
* Content DO for IsaacDndQuestions.
*
*/
@DTOMapping(IsaacDndQuestionDTO.class)
@JsonContentType("isaacDndQuestion")
@ValidatesWith(IsaacClozeValidator.class)
@ValidatesWith(IsaacDndValidator.class)
public class IsaacDndQuestion extends IsaacItemQuestion {

private Boolean withReplacement;
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/uk/ac/cam/cl/dtg/isaac/dos/content/DndChoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@

import uk.ac.cam.cl.dtg.isaac.dto.content.DndChoiceDTO;

import java.util.List;

/**
* Choice for Dnd Questions, containing a list of DndItems.
* Choice for Item Questions, containing a list of Items.
*
*/
@DTOMapping(DndChoiceDTO.class)
@JsonContentType("dndChoice")
public class DndChoice extends ItemChoice {
public class DndChoice extends Choice {
private List<DndItem> items;

/**
* Default constructor required for mapping.
*/
public DndChoice() {
}
}

public List<DndItem> getItems() {
return items;
}

public void setItems(final List<DndItem> items) {
this.items = items;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@DTOMapping(ItemChoiceDTO.class)
@JsonContentType("itemChoice")
public class ItemChoice extends Choice {

private Boolean allowSubsetMatch;
private List<Item> items;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2022 James Sharkey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package uk.ac.cam.cl.dtg.isaac.dto;

import uk.ac.cam.cl.dtg.isaac.dto.content.ChoiceDTO;
import uk.ac.cam.cl.dtg.isaac.dto.content.ContentDTO;

import java.util.Date;
import java.util.Map;

/**
* Class for providing correctness feedback about drag and drop questions in a submitted Choice.
*/
public class DndValidationResponseDTO extends QuestionValidationResponseDTO {
private Map<String, Boolean> dropZonesCorrect;

/**
* Default constructor for Jackson.
*/
public DndValidationResponseDTO() {
}

/**
* Full constructor.
*
* @param questionId - questionId.
* @param answer - answer.
* @param correct - correct.
* @param dropZonesCorrect - map of correctness status of each submitted item. Key: dropZoneId, value: isCorrect
* @param explanation - explanation.
* @param dateAttempted - dateAttempted.
*/
public DndValidationResponseDTO(final String questionId, final ChoiceDTO answer,
final Boolean correct, final Map<String, Boolean> dropZonesCorrect,
final ContentDTO explanation, final Date dateAttempted) {
super(questionId, answer, correct, explanation, dateAttempted);
this.dropZonesCorrect = dropZonesCorrect;
}

public Map<String, Boolean> getDropZonesCorrect() {
return dropZonesCorrect;
}

public void setDropZonesCorrect(final Map<String, Boolean> dropZonesCorrect) {
this.dropZonesCorrect = dropZonesCorrect;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,26 @@
*/
package uk.ac.cam.cl.dtg.isaac.dto.content;

import java.util.List;

/**
* Choice for Dnd Questions, containing a list of DndItems.
*
*/
public class DndChoiceDTO extends ItemChoiceDTO {
public class DndChoiceDTO extends ChoiceDTO {
private List<DndItemDTO> items;

/**
* Default constructor required for mapping.
*/
public DndChoiceDTO() {
}

public List<DndItemDTO> getItems() {
return items;
}

public void setItems(final List<DndItemDTO> items) {
this.items = items;
}
}
Loading
Loading