Skip to content

Conversation

@erseco
Copy link
Collaborator

@erseco erseco commented Jun 10, 2025

This PR adds two key features to the ElpParser library:

  • 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.md and docs/index.md now include usage examples and updated feature lists.
  • docs/api.md includes details on the new methods.

Tests

  • Added test fixtures for metadata and JSON export (04_La_Ilustracion.*).
  • New unit tests cover exportJson() and getMetadata().

Utilities

  • Introduced remove_accents and seems_utf8 helper functions for better metadata handling.

@erseco erseco requested a review from Copilot June 10, 2025 12:00
@erseco erseco self-assigned this Jun 10, 2025
@erseco erseco added the enhancement New feature or request label Jun 10, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
]
Copy link

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
]
]

Copilot uses AI. Check for mistakes.
@erseco erseco merged commit 6e7cabb into exelearning:main Jun 17, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant