public static function get_entry($entryid, $returncontents = false) {
        global $PAGE, $DB;

        $params = array('entryid' => $entryid, 'returncontents' => $returncontents);
        $params = self::validate_parameters(self::get_entry_parameters(), $params);
        $warnings = array();

        $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST);
        list($database, $course, $cm, $context) = self::validate_database($record->dataid);

        // Check database is open in time.
        $canmanageentries = has_capability('mod/data:manageentries', $context);
        data_require_time_available($database, $canmanageentries);

        if ($record->groupid != 0) {
            if (!groups_group_visible($record->groupid, $course, $cm)) {
                throw new moodle_exception('notingroup');
            }
        }

        // Check correct record entry. Group check was done before.
        if (!data_can_view_record($database, $record, $record->groupid, $canmanageentries)) {
            throw new moodle_exception('notapproved', 'data');
        }

        $related = array('context' => $context, 'database' => $database, 'user' => null);
        if ($params['returncontents']) {
            $related['contents'] = $DB->get_records('data_content', array('recordid' => $record->id));
        } else {
            $related['contents'] = null;
        }
        $exporter = new record_exporter($record, $related);
        $entry = $exporter->export($PAGE->get_renderer('core'));

        $result = array(
            'entry' => $entry,
            'ratinginfo' => \core_rating\external\util::get_rating_info($database, $context, 'mod_data', 'entry', array($record)),
            'warnings' => $warnings
        );
        // Check if we should return the entry rendered.
        if ($params['returncontents']) {
            $records = [$record];
            $result['entryviewcontents'] = data_print_template('singletemplate', $records, $database, '', 0, true);
        }

        return $result;
    }