Skip to content

✨ Add backup/restore, view capability and viewed event - #7

Merged
DamienVauchel merged 2 commits into
mainfrom
bugfix/EDFLEX1-15025
Jun 29, 2026
Merged

✨ Add backup/restore, view capability and viewed event#7
DamienVauchel merged 2 commits into
mainfrom
bugfix/EDFLEX1-15025

Conversation

@DamienVauchel

Copy link
Copy Markdown
Collaborator

🎯 Purpose of this Pull Request

The Moodle Marketplace review of mod_edflex (review ticket MMRT-99) returned three approval blockers. This PR addresses all three so the plugin can be resubmitted.

  1. BLOCKER — activity module missing the Backup/Restore API.
  2. HIGH — inadequate capability checking in view.php (require_login present, no require_capability).
  3. HIGH — missing the standard course_module_viewed event.

📝 Summary of Changes

  • Implement the moodle2 Backup/Restore API for the edflex activity (backup/moodle2/: backup + restore task classes and stepslibs), covering the edflex table and intro files.
  • Add a mod/edflex:view capability and enforce it with require_capability() in view.php; set the page url/context/title/heading before output.
  • Add \mod_edflex\event\course_module_viewed and trigger it from view.php.
  • Declare FEATURE_MOD_INTRO, FEATURE_SHOW_DESCRIPTION, FEATURE_BACKUP_MOODLE2 in edflex_supports(); bump version.php to v1.0.2.

✔️ Moodle Plugin Checklist

Code Quality & Standards

  • Code follows Moodle coding guidelines
  • PHPDoc blocks updated where needed
  • No debug statements left
  • Namespace and file structure follow Moodle plugin conventions

Functional Changes

  • New strings added to lang/en/edflex.php (edflex:view)
  • Capabilities added/updated in db/access.php
  • Backup/restore updated

Database & Files

  • Privacy API unchanged — plugin still stores no personal data

🧪 Testing

Manual Tests

  • Back up a course containing an Edflex activity → backup completes without error.
  • Restore that backup into another course → the instance is recreated with its settings.
  • Open the activity view page → access is denied without mod/edflex:view, and a course_module_viewed event is logged.

Automated Tests

  • PHPUnit tests not added in this PR

🔄 Regression Risk

view.php access path (new capability gate + event) and the new backup/restore steps. No change to the SCORM-wrapper flow.


🔗 Additional Notes

  • mod_edflex is a launcher: edflex_add_instance() returns false by design (the form spawns SCORM modules via the Edflex browser), so no standalone edflex instance is persisted. The Backup/Restore API is implemented to satisfy the Marketplace requirement and is correct, but inert until/unless real instances exist.
  • Known follow-up: edflex_scorm rows are not carried through a course restore — preserving them would require a mod_scorm backup subplugin. Out of scope here.

Addresses the Moodle Marketplace review blockers (MMRT-99) before
resubmission:
- implement the Backup/Restore moodle2 API for the edflex activity
- gate view.php behind a new mod/edflex:view capability
- emit the standard course_module_viewed event
- drop the blank line after each class opening brace (PSR12)
- remove the unneeded MOODLE_INTERNAL guard from class-only files
- capitalise the launcher inline comment in lib.php
@DamienVauchel
DamienVauchel marked this pull request as ready for review June 29, 2026 09:51
@DamienVauchel DamienVauchel self-assigned this Jun 29, 2026
@DamienVauchel
DamienVauchel merged commit 7d02bff into main Jun 29, 2026
4 checks passed
@DamienVauchel
DamienVauchel deleted the bugfix/EDFLEX1-15025 branch June 29, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants