From f1564e64bbd110d342bd95e84ff9d17237124c1b Mon Sep 17 00:00:00 2001 From: Jonathan Putney Date: Tue, 8 Sep 2026 07:52:06 +0000 Subject: [PATCH] fix(scorm2004): honor shared-data default --- .../ims/cp/Scorm2004Organization.java | 14 ++++++-- .../scorm2004/Scorm2004ManifestTest.java | 34 +++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/jcputney/elearning/parser/input/scorm2004/ims/cp/Scorm2004Organization.java b/src/main/java/dev/jcputney/elearning/parser/input/scorm2004/ims/cp/Scorm2004Organization.java index 43fbd978..04a0ca34 100644 --- a/src/main/java/dev/jcputney/elearning/parser/input/scorm2004/ims/cp/Scorm2004Organization.java +++ b/src/main/java/dev/jcputney/elearning/parser/input/scorm2004/ims/cp/Scorm2004Organization.java @@ -85,7 +85,7 @@ public final class Scorm2004Organization implements Serializable { */ @JacksonXmlProperty(isAttribute = true, localName = "sharedDataGlobalToSystem", namespace = ADLCP.NAMESPACE_URI) @JsonProperty("sharedDataGlobalToSystem") - private boolean sharedDataGlobalToSystem = false; + private Boolean sharedDataGlobalToSystem; /** * Metadata associated with this organization, providing details such as creation date, and other @@ -216,7 +216,17 @@ public void setObjectivesGlobalToSystem(boolean objectivesGlobalToSystem) { * @return true if the shared data is global to the system, false otherwise */ public boolean isSharedDataGlobalToSystem() { - return this.sharedDataGlobalToSystem; + return this.sharedDataGlobalToSystem == null || this.sharedDataGlobalToSystem; + } + + /** + * Returns whether the manifest explicitly declared sharedDataGlobalToSystem. + * + * @return true when the attribute was present in the organization element + */ + @JsonIgnore + public boolean isSharedDataGlobalToSystemSpecified() { + return this.sharedDataGlobalToSystem != null; } /** diff --git a/src/test/java/dev/jcputney/elearning/parser/input/scorm2004/Scorm2004ManifestTest.java b/src/test/java/dev/jcputney/elearning/parser/input/scorm2004/Scorm2004ManifestTest.java index b788bbba..3ff63d1b 100644 --- a/src/test/java/dev/jcputney/elearning/parser/input/scorm2004/Scorm2004ManifestTest.java +++ b/src/test/java/dev/jcputney/elearning/parser/input/scorm2004/Scorm2004ManifestTest.java @@ -144,6 +144,40 @@ void objectivesGlobalToSystemPreservesExplicitFalse() assertTrue(organization.isObjectivesGlobalToSystemSpecified()); } + @Test + void sharedDataGlobalToSystemDefaultsToTrueWhenOmitted() + throws IOException, XMLStreamException, ModuleParsingException, ManifestParseException { + String modulePath = + "src/test/resources/modules/scorm2004/ContentPackagingMetadata_SCORM20043rdEdition"; + Scorm2004Manifest manifest = new Scorm2004Parser(new LocalFileAccess(modulePath)) + .parseManifest(Scorm2004Parser.MANIFEST_FILE); + + Scorm2004Organization organization = manifest + .getOrganizations() + .getOrganizationList() + .get(0); + + assertTrue(organization.isSharedDataGlobalToSystem()); + assertFalse(organization.isSharedDataGlobalToSystemSpecified()); + } + + @Test + void sharedDataGlobalToSystemPreservesExplicitFalse() + throws IOException, XMLStreamException, ModuleParsingException, ManifestParseException { + String modulePath = + "src/test/resources/modules/scorm2004/SequencingPostTestRollup4thEd_SCORM20044thEdition"; + Scorm2004Manifest manifest = new Scorm2004Parser(new LocalFileAccess(modulePath)) + .parseManifest(Scorm2004Parser.MANIFEST_FILE); + + Scorm2004Organization organization = manifest + .getOrganizations() + .getOrganizationList() + .get(0); + + assertFalse(organization.isSharedDataGlobalToSystem()); + assertTrue(organization.isSharedDataGlobalToSystemSpecified()); + } + /** * Tests the getGlobalObjectiveIds method with a manifest that contains global objectives. */