private static function analytics_prediction_actions_user_sql($userid, $modelids, $contextsql = false) {
        global $DB;

        list($insql, $params) = $DB->get_in_or_equal($modelids, SQL_PARAMS_NAMED);
        $sql = " FROM {analytics_predictions} ap
                  JOIN {context} ctx ON ctx.id = ap.contextid
                  JOIN {analytics_prediction_actions} apa ON apa.predictionid = ap.id
                  JOIN {analytics_models} am ON ap.modelid = am.id
                 WHERE apa.userid = :userid AND ap.modelid {$insql}";
        $params['userid'] = $userid;

        if ($contextsql) {
            $sql .= " AND ap.contextid $contextsql";
        }

        return [$sql, $params];
    }
private static function analytics_prediction_actions_user_sql($userid, $modelids, $contextsql = false) {
        global $DB;

        list($insql, $params) = $DB->get_in_or_equal($modelids, SQL_PARAMS_NAMED);
        $sql = " FROM {analytics_predictions} ap
                  JOIN {context} ctx ON ctx.id = ap.contextid
                  JOIN {analytics_prediction_actions} apa ON apa.predictionid = ap.id
                  JOIN {analytics_models} am ON ap.modelid = am.id
                 WHERE apa.userid = :userid AND ap.modelid {$insql}";
        $params['userid'] = $userid;

        if ($contextsql) {
            $sql .= " AND ap.contextid $contextsql";
        }

        return [$sql, $params];
    }
private static function analytics_prediction_actions_user_sql ( $ userid , $ modelids , $ contextsql = false ) { global $ DB ; list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ modelids , SQL_PARAMS_NAMED ) ; $ sql = " FROM {analytics_predictions} ap
                  JOIN {context} ctx ON ctx.id = ap.contextid
                  JOIN {analytics_prediction_actions} apa ON apa.predictionid = ap.id
                  JOIN {analytics_models} am ON ap.modelid = am.id
                 WHERE apa.userid = :userid AND ap.modelid {$insql}" ; $ params [ 'userid' ] = $ userid ; if ( $ contextsql ) { $ sql .= " AND ap.contextid $contextsql" ; } return [ $ sql , $ params ] ; }
Returns the sql query to query analytics_prediction_actions table by user ID.

@param int $userid The user ID of the analytics prediction.
@param int[] $modelids Model IDs to include in the SQL.
@param string $contextsql Optional "in or equal" SQL to also query by context ID(s).
@return array sql string in [0] and params in [1].
Returns the sql query to query analytics_prediction_actions table by user ID .