protected function status($versionid, $row) {
        $onbehalf = false;
        $versions = $versionid ? [$versionid => $this->versionids[$versionid]] : $this->versionids; // List of versions.
        $accepted = []; // List of versionids that user has accepted.
        $declined = [];

        foreach ($versions as $v => $name) {
            if ($row->{'status' . $v} !== null) {
                if (empty($row->{'status' . $v})) {
                    $declined[] = $v;
                } else {
                    $accepted[] = $v;
                }
                $agreedby = $row->{'usermodified' . $v};
                if ($agreedby && $agreedby != $row->id) {
                    $onbehalf = true;
                }
            }
        }

        $ua = new user_agreement($row->id, $accepted, $declined, $this->get_return_url(), $versions, $onbehalf, $row->canaccept);

        if ($this->is_downloading()) {
            return $ua->export_for_download();

        } else {
            return $this->output->render($ua);
        }
    }