moodle-logstore_xapi
moodle-logstore_xapi copied to clipboard
Bug in events related to subchapters
This is the code I believe has an error: https://github.com/xAPI-vle/moodle-logstore_xapi/blob/30d7b73750d35c9b4ef3a2adb328d387cc809866/src/transformer/events/mod_book/chapter_viewed.php#L62
The subchapter value is only ever 0 or 1, but the code here assumes this is the parent chapter id. If there is no chapter in mdl_book_chapters with an id of 1 we get the failed transform errors.
I created a sample book with the following structure:
- chapter 1
- chapter 1.1
- chapter 1.2
- chapter 2
- chapter 2.1
On viewing chapter 2.1, the LRS was sent the attached. You can see it is incorrectly marked as having the parent of chapter 1. I then deleted chapter 1, viewed chapter 2.1 again and ran the emit task. This time it failed to transform as it was looking for the chapter with id 1.