Added function to export JSON and extract Metadata#3
Merged
erseco merged 9 commits intoexelearning:mainfrom Jun 17, 2025
Merged
Added function to export JSON and extract Metadata#3erseco merged 9 commits intoexelearning:mainfrom
erseco merged 9 commits intoexelearning:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces two new features for the ElpParser library: exporting parsed data to JSON and retrieving a detailed metadata tree.
- Adds the exportJson() method to output JSON data (either as a string or directly to a file)
- Introduces the getMetadata() method to provide a rich metadata structure including Package, Dublin Core, LOM, and LOM-ES information
- Updates tests and documentation (README.md, docs/index.md, docs/api.md) to cover and explain the new features
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/ElpParserTest.php | Added unit tests verifying the functionality of exportJson() and getMetadata() |
| tests/Fixtures/04_La_Ilustracion.json | New fixture for exported JSON data; includes a placeholder for cloze_text in a ClozeIdevice entry |
| tests/Fixtures/04_La_Ilustracion.expected.json | Added expected JSON structure for testing exportJson() |
| src/ElpParser.php | New methods exportJson() and getMetadata() added along with associated helper functions |
| docs/index.md, docs/api.md, README.md | Updated documents to include usage examples and API details for the new methods |
Comment on lines
+211
to
+212
| // ToDo | ||
| ] |
There was a problem hiding this comment.
A comment is present inside the JSON array for 'cloze_text', which is not valid JSON syntax. Either remove the comment or replace it with valid JSON content (for example, an empty array) to ensure the fixture file is parseable.
Suggested change
| // ToDo | |
| ] | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two key features to the
ElpParserlibrary:Export to JSON:
The new
exportJson()method allows saving parsed ELP data as a JSON file. It supports optional file paths and handles errors on encoding or write failure.Metadata Tree Retrieval:
The new
getMetadata()method returns a detailed metadata tree including Dublin Core, LOM, LOM-ES, and page structure.Docs
README.mdanddocs/index.mdnow include usage examples and updated feature lists.docs/api.mdincludes details on the new methods.Tests
04_La_Ilustracion.*).exportJson()andgetMetadata().Utilities
remove_accentsandseems_utf8helper functions for better metadata handling.