<?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.

namespace local_kid\event;

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

/**
 * Fired for every fiche/dashboard file generated for download —
 * `other.format` distinguishes docx/pdf/xlsx/zip, `other.studentid` is set
 * for a single-student fiche, `other.count` for a bulk zip. Does not cover
 * the ADESI export, which already has its own dedicated `adesi_exported`.
 */
class export_generated extends \core\event\base {

    protected function init() {
        $this->data['crud'] = 'r';
        $this->data['edulevel'] = self::LEVEL_OTHER;
    }

    public static function get_name() {
        return get_string('event_export_generated', 'local_kid');
    }

    public function get_description() {
        $format = $this->other['format'] ?? '?';
        $studentid = $this->other['studentid'] ?? null;
        $count = $this->other['count'] ?? null;
        $target = $studentid ? "student entry '$studentid'" : ($count ? "$count student(s)" : 'a dashboard view');
        return "The user with id '{$this->userid}' generated a $format export for $target.";
    }

    public function get_url() {
        return new \moodle_url('/local/kid/pages/dashboard.php');
    }
}
