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
76 stars 84 forks source link

Transforming event having userid=0 creates exception #606

Open Callustian opened 5 years ago

Callustian commented 5 years ago

Description

Version

Steps to reproduce the bug

  1. I am using Moodle, and I am unsure of how it is generating the event as guest, at the moment. This feature is not checked.

Expected behaviour

Actual behaviour

Server information

Client information

Thank you.

davidpesce commented 4 years ago

@Callustian - which version of the plugin are you using?

Callustian commented 4 years ago

@davidpesce Thank you for your reply.

I am using v4.2.5.

mlynn-lp commented 4 years ago

@Callustian @davidpesce @gordonmacqueen-lp @Patches- @lzabo Suggested code change in these methods:

    // Get a valid user for guest.
    $guest = false;
    if ($event->userid == 0) {
        $guest = true;
        if (isset($CFG->siteguest)) {
            $event->userid = $CFG->siteguest;
        }
    }
    $user = $repo->read_record_by_id('user', $event->userid);

    // Reset userid so it is the same as in logstore_standard_log.
    if ($guest == true) {
        $event->userid = 0;
    }

Would it be possible to create a branch and put this in for code review in the following files: course_viewed.php user_created.php