Get the analytics predictions for a specific user within the Moodle database

Get the analytics predictions for a specific user within the Moodle database

by JULIETA DIANA RIVERO -
Number of replies: 2
Hello! I need to be able to map the predictions of the Analytics models with the specific users (userid).
Do you know if there's a way of doing that by quering the Moodle database?
I've been trying to join the 'prefix_analytics_predictions' table with others tables to get the user id target of the prediction but I didn't succeed

I hope you can help me! Thanks!
Average of ratings: -
In reply to JULIETA DIANA RIVERO

Re: Get the analytics predictions for a specific user within the Moodle database

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Try something like:

SELECT *
FROM {analytics_predictions} ap
JOIN {context} cx on cx.id = ap.contextid
JOIN {course} c on (c.id = cx.instanceid AND cx.contextlevel = 50)
JOIN {user_enrolments} ue on ue.id = ap.sampleid
JOIN {user} u on u.id = ue.userid

In reply to Dan Marsden

Re: Get the analytics predictions for a specific user within the Moodle database

by JULIETA DIANA RIVERO -
That works perfectly!
I was missing the fact that the sampleid matches the user_enrolments id
Thank you so much!