<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

/**
 * Renderable/templatable data for the dashboard "Vue d'ensemble" sub-tab.
 *
 * @package    local_kid
 */

namespace local_kid\output;

use local_kid\local\dashboard_repository;

defined('MOODLE_INTERNAL') || die();

class dashboard_overview_page implements \renderable, \templatable {

    protected int $promotionid;

    public function __construct(int $promotionid) {
        $this->promotionid = $promotionid;
    }

    public function export_for_template(\renderer_base $output): array {
        $data = dashboard_repository::overview($this->promotionid);

        return [
            'studentcount' => $data['studentcount'],
            'evalstocomplete' => $data['evalstocomplete'],
            'stagestocomplete' => $data['stagestocomplete'],
            'capptocomplete' => $data['capptocomplete'],
            'cappfinalised' => $data['cappfinalised'],
            'sessioncodes' => $data['sessioncodes'],
            'students' => $data['students'],
            'hasnostudents' => empty($data['students']),
            'exporturl' => (new \moodle_url('/local/kid/pages/dashboard_export.php', [
                'view' => 'overview', 'promotionid' => $this->promotionid,
            ]))->out(false),
        ];
    }
}
