xAPI-vle / moodle-logstore_xapi

A Moodle plugin to send xAPI statements to an LRS using events in the Moodle logstore.
GNU General Public License v3.0
75 stars 85 forks source link

Bug in events related to subchapters #776

Closed gmoger-jisc closed 4 months ago

gmoger-jisc commented 3 years ago

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:

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.