From 65f81eb14fb9fbce6881494f9031fe3fa0488851 Mon Sep 17 00:00:00 2001 From: Alex Lewin Date: Tue, 11 Aug 2026 11:30:55 +0100 Subject: [PATCH 1/3] Add content error for unset sig fig bounds --- .../java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java b/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java index ea8533f3ac..859b56ebaf 100644 --- a/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java +++ b/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java @@ -1073,8 +1073,13 @@ && flattenContentObjects(content).stream() } // Verify that significant figure bounds are correct if (!q.getDisregardSignificantFigures()) { - if (null == q.getSignificantFiguresMin() ^ null == q.getSignificantFiguresMax()) { - // Both bounds need to be present, or both not present + // If not 'exact answers only', s.f. bounds should be set + if (null == q.getSignificantFiguresMin() && null == q.getSignificantFiguresMax()) { + this.registerContentProblem(content, "Numeric Question: " + q.getId() + " has no " + + "significant figure bounds set. If this question does not use significant figures then " + + "'exact answers only' should be set.", indexProblemCache); + } else if (null == q.getSignificantFiguresMin() || null == q.getSignificantFiguresMax()) { + // Both bounds need to be present this.registerContentProblem(content, "Numeric Question: " + q.getId() + " has only one " + "significant figure bound, and may be unanswerable as a result. Please add both upper " + "and lower significant figure bounds, or omit both.", indexProblemCache); From f5cef4d38f07f9f0a0d06a030c1133956105cf2a Mon Sep 17 00:00:00 2001 From: Alex Lewin Date: Fri, 14 Aug 2026 16:08:20 +0100 Subject: [PATCH 2/3] Apply duplicate ID error to questions without titles If two title-less questions on the same page are given the same ID, the content flattener cannot distinguish between them so only one copy is in the Set of flattened content that is checked for duplicate IDs. By giving the questions distinct titles, both questions are included in the flattened content Set and the duplicate ID content error is applied. --- .../java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java b/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java index 90242a9303..acd2116f3f 100644 --- a/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java +++ b/src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java @@ -61,6 +61,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -251,7 +252,7 @@ private synchronized void buildGitContentIndex(final String sha, // add children (and parent) from flattened Set to // cache if they have ids - for (Content flattenedContent : this.flattenContentObjects(content)) { + for (Content flattenedContent : flattenContentObjects(content)) { if (flattenedContent.getId() == null) { continue; } @@ -386,6 +387,12 @@ private Content augmentChildContent(final Content content, final String canonica log.debug("Found question without id '{}' in {}", content.getTitle(), canonicalSourceFile); } + // Give title-less questions unique titles so they remain distinct in Set-based flattening, even if they have + // the same id. + if (content instanceof Question && content.getTitle() == null) { + content.setTitle("untitled-question-" + UUID.randomUUID()); + } + // Try to figure out the parent ids. String newParentId; if (null == parentId && content.getId() != null) { From cd22e56627f4b8ee2c3fed1100977cfe94a85f93 Mon Sep 17 00:00:00 2001 From: Alex Lewin Date: Fri, 14 Aug 2026 16:46:55 +0100 Subject: [PATCH 3/3] Update test for new content error --- .../java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexerTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexerTest.java b/src/test/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexerTest.java index 7449cb2001..0fd2addefd 100644 --- a/src/test/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexerTest.java +++ b/src/test/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexerTest.java @@ -197,7 +197,7 @@ public void flattenContentObjects_flattenMultiTierObject_checkCorrectObjectRetur } /** - * Test that recordContentTypeSpecificError does not add an error message to indexProblemCache when neither + * Test that recordContentTypeSpecificError adds an error message to indexProblemCache when neither * significant figure is set whilst disregardSignificantFigures is not set * * @throws Exception as reflection may not find method @@ -217,7 +217,9 @@ public void recordContentTypeSpecificError_noSigFigSet_checkNoError() // ASSERT for (Content key : indexProblemCache.keySet()) { - assertTrue(indexProblemCache.get(key).isEmpty()); + for (String problem : indexProblemCache.get(key)) { + assertTrue(problem.contains("has no significant figure bounds set.")); + } } }