{{!
    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.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template tool_lp/evidence_summary

    Moodle template for the the summary of a single piece of evidence.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * none

    Context variables required for this template:
    * actionuser User record from a user_summary_exporter
    * userdate User formatted date this evidence was created
    * grade Raw grade value if set
    * gradename Scale grade item
    * description Description of the evidence
    * url Optional url for the evidence

    Example context (json):
    { "actionuser": { "id": 1, "fullname": "Legend", "profileimageurlsmall": "https://secure.gravatar.com/avatar/78f83716ad197a25e175fbb747cff1ff?s=35&d=mm" },
      "userdate": "Tuesday...",
      "grade": 2,
      "gradename": "Met",
      "description": "The user competency was manually rated in the plan Personal plan A",
      "url": "http://moodle.org/",
      "candelete": true,
      "id": 1
    }
}}
<div class="border rounded p-4 mb-2 evidence d-block relative" data-region="evidence" data-id="{{id}}">

    {{#grade}}
    <p><span class="badge badge-success">{{gradename}}</span></p>
    {{/grade}}

    {{#candelete}}
    <a href="#" class="btn btn-sm btn-danger float-right" data-action="delete-evidence">
        <svg width="22" height="22" fill="none" viewBox="0 0 24 24">
            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.7" d="M6.75 7.75L7.59115 17.4233C7.68102 18.4568 8.54622 19.25 9.58363 19.25H14.4164C15.4538 19.25 16.319 18.4568 16.4088 17.4233L17.25 7.75"></path>
            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.7" d="M9.75 7.5V6.75C9.75 5.64543 10.6454 4.75 11.75 4.75H12.25C13.3546 4.75 14.25 5.64543 14.25 6.75V7.5"></path>
            <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.7" d="M5 7.75H19"></path>
        </svg>
    </a>
    {{/candelete}}


{{#actionuser}}
    <div class="my-2">
        {{> tool_lp/user_summary }}
    </div>
{{/actionuser}}
<small><time datetime="{{userdate}}">{{userdate}}</time></small>
<p class="pt-3 my-3 border-top">{{description}}</p>
{{#grade}}
    <p><span class="badge badge-info">{{gradename}}</span></p>
{{/grade}}
<p>{{description}}</p>
{{#note}}
    <blockquote>{{note}}</blockquote>
{{/note}}
{{#url}}
    <p><a href="{{url}}" target="_blank" rel="noreferrer">{{url}}</a></p>
{{/url}}
</div>

{{#js}}
require(['tool_lp/evidence_delete'], function(EvidenceDelete) {
    EvidenceDelete.register('[data-action="delete-evidence"]', '[data-region="evidence"]');
});
{{/js}}
