<?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 once per CSV import call (round-trip interne Évaluations/Stages,
 * ou l'un des deux fichiers CAPP — compétences/appréciations, distingués
 * par `other.mode`) — jamais par ligne importée.
 */
class csv_imported extends \core\event\base {

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

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

    public function get_description() {
        $domain = $this->other['domain'] ?? '?';
        $itemid = $this->other['itemid'] ?? 0;
        $added = $this->other['added'] ?? 0;
        $errorcount = $this->other['errorcount'] ?? 0;
        return "The user with id '{$this->userid}' imported a CSV file for $domain item '$itemid' " .
            "(added={$added}, errors={$errorcount}).";
    }

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