diff --git a/pom-dependency-tree.txt b/pom-dependency-tree.txt index e40a461bb..c71d92ea4 100644 --- a/pom-dependency-tree.txt +++ b/pom-dependency-tree.txt @@ -1,5 +1,5 @@ -ai.elimu:webapp:war:2.6.107-SNAPSHOT -+- ai.elimu:model:jar:model-2.0.114:compile +ai.elimu:webapp:war:2.6.108-SNAPSHOT ++- ai.elimu:model:jar:model-2.0.117:compile | \- com.google.code.gson:gson:jar:2.13.1:compile | \- com.google.errorprone:error_prone_annotations:jar:2.38.0:compile +- org.springframework:spring-context:jar:6.0.11:compile diff --git a/pom.xml b/pom.xml index 4bdc0bb30..abb73ce06 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 17 UTF-8 - 2.0.114 + 2.0.117 6.1.7.Final 11.0.24 6.0.11 diff --git a/src/main/java/ai/elimu/entity/analytics/LetterSoundLearningEvent.java b/src/main/java/ai/elimu/entity/analytics/LetterSoundLearningEvent.java index e4c825903..b9cf07546 100644 --- a/src/main/java/ai/elimu/entity/analytics/LetterSoundLearningEvent.java +++ b/src/main/java/ai/elimu/entity/analytics/LetterSoundLearningEvent.java @@ -1,8 +1,13 @@ package ai.elimu.entity.analytics; +import java.util.List; + import ai.elimu.entity.content.LetterSound; +import ai.elimu.entity.converters.StringListConverter; +import jakarta.persistence.Convert; import jakarta.persistence.Entity; import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; @@ -11,13 +16,27 @@ @Entity public class LetterSoundLearningEvent extends LearningEvent { - /** - * This field might not be included, e.g. if the letter-sound correspondence was learned - * in a 3rd-party app that did not load the content from the elimu.ai Content Provider. - * In this case, the {@link #letterSoundId} will be {@code null}. - */ - private Long letterSoundId; + /** + * The sequence of letters. E.g. ["s","h"]. + */ + @NotNull + @Convert(converter = StringListConverter.class) + private List letterSoundLetters; + + /** + * The sequence of sounds (IPA values). E.g. ["ʃ"]. + */ + @NotNull + @Convert(converter = StringListConverter.class) + private List letterSoundSounds; + + /** + * This field might not be included, e.g. if the assessment task was done in a + * 3rd-party app that did not load the content from the elimu.ai Content Provider. + * In that case, this field will be {@code null}. + */ + private Long letterSoundId; - @ManyToOne - private LetterSound letterSound; + @ManyToOne + private LetterSound letterSound; } diff --git a/src/main/java/ai/elimu/entity/converters/StringListConverter.java b/src/main/java/ai/elimu/entity/converters/StringListConverter.java new file mode 100644 index 000000000..5960795e9 --- /dev/null +++ b/src/main/java/ai/elimu/entity/converters/StringListConverter.java @@ -0,0 +1,21 @@ +package ai.elimu.entity.converters; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import jakarta.persistence.AttributeConverter; + +public class StringListConverter implements AttributeConverter, String> { + private static final String SPLIT_CHAR = ";"; + + @Override + public String convertToDatabaseColumn(List stringList) { + return stringList != null ? String.join(SPLIT_CHAR, stringList) : ""; + } + + @Override + public List convertToEntityAttribute(String string) { + return string != null ? Arrays.asList(string.split(SPLIT_CHAR)) : Collections.emptyList(); + } +} diff --git a/src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java b/src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java index 0ed36990f..520f7bc20 100644 --- a/src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java +++ b/src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java @@ -181,9 +181,9 @@ public static List extractLetterSoundLearningEvents(Fi } } - // TODO: letterSoundLetters + // TODO: letter_sound_letters - // TODO: letterSoundSounds + // TODO: letter_sound_sounds Long letterSoundId = Long.valueOf(csvRecord.get("letter_sound_id")); letterSoundLearningEvent.setLetterSoundId(letterSoundId); diff --git a/src/main/java/ai/elimu/web/servlet/CustomDispatcherServlet.java b/src/main/java/ai/elimu/web/servlet/CustomDispatcherServlet.java index 3b2baef9d..97eda0b8f 100644 --- a/src/main/java/ai/elimu/web/servlet/CustomDispatcherServlet.java +++ b/src/main/java/ai/elimu/web/servlet/CustomDispatcherServlet.java @@ -380,6 +380,8 @@ private void populateDatabase(WebApplicationContext webApplicationContext) { letterSoundLearningEvent.setResearchExperiment(ResearchExperiment.EXP_0_WORD_EMOJIS); letterSoundLearningEvent.setExperimentGroup(ExperimentGroup.values()[(int) (Math.random() * 2)]); } + letterSoundLearningEvent.setLetterSoundLetters(letterSoundM.getLetters().stream().map(Letter::getText).toList()); + letterSoundLearningEvent.setLetterSoundSounds(letterSoundM.getSounds().stream().map(Sound::getValueIpa).toList()); letterSoundLearningEvent.setLetterSoundId(letterSoundM.getId()); letterSoundLearningEventDao.create(letterSoundLearningEvent); } diff --git a/src/main/resources/META-INF/jpa-schema-export.sql b/src/main/resources/META-INF/jpa-schema-export.sql index 53d0fa424..608eb2a60 100644 --- a/src/main/resources/META-INF/jpa-schema-export.sql +++ b/src/main/resources/META-INF/jpa-schema-export.sql @@ -672,6 +672,8 @@ researchExperiment smallint, timestamp datetime, letterSoundId bigint, + letterSoundLetters varchar(255), + letterSoundSounds varchar(255), application_id bigint, letterSound_id bigint, primary key (id) diff --git a/src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp b/src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp index b975f9602..4c74cb98c 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp @@ -227,7 +227,8 @@ timestamp package_name - letter_sound_id + letter_sound_letters + letter_sound_sounds ℹ️ @@ -241,7 +242,10 @@ ${letterSoundLearningEvent.packageName} - ${letterSoundLearningEvent.letterSoundId} + ${letterSoundLearningEvent.letterSoundLetters} + + + ${letterSoundLearningEvent.letterSoundSounds} ${letterSoundLearningEvent.additionalData}