{{!
    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 core_courseformat/local/content/cm/activity

    Display the activity content of a cm.

    Example context (json):
    {
        "cmname": {
            "displayvalue" : "<a class=\"aalink\" href=\"#\"><span class=\"instancename\">Activity example</span></a>"
        },
        "hasname": "true",
        "afterlink": "<span class=\"resourcelinkdetails\">24.7&nbsp;KB · Uploaded 26/05/23, 16:29</span>",
        "activitybadge": {
            "badgecontent": "PDF",
            "badgestyle": "badge-none",
            "badgeurl": "http://example.org/help",
            "badgeelementid": "myelementid",
            "badgeextraattributes": [
                {
                    "name": "data-el1name",
                    "value": "el1value"
                },
                {
                    "name": "data-el2name",
                    "value": "el2value"
                }
            ]
        },
        "hasextras": true,
        "extras": ["<span class=\"badge bg-secondary\">[extras]</span>"],
        "activityinfo": {
            "hasmodavailability": true,
            "activityname": "Activity example",
            "hascompletion": true,
            "uservisible": true,
            "hasdates": true,
            "isautomatic": true,
            "istrackeduser": true,
            "activitydates": [
                {
                    "label": "Opens:",
                    "datestring": "6 April 2021, 6:46 PM"
                }
            ],
            "completiondetails": [
                {
                    "statuscomplete": 1,
                    "description": "Viewed"
                },
                {
                    "statusincomplete": 1,
                    "description": "Receive a grade"
                }
            ]
        },
        "visibility": {
            "isInteractive": false,
            "modhiddenfromstudents": true
        }
    }
}}
{{#moveicon}} {{{moveicon}}} {{/moveicon}}
<div class="activity-grid {{^hasname}}noname-grid{{/hasname}}">

    {{! Icon, Name & Badge }}
    {{#hasname}}
        {{#cmname}}
            {{$ core_courseformat/local/content/cm/cmname }}
                {{> core_courseformat/local/content/cm/cmname }}
            {{/ core_courseformat/local/content/cm/cmname }}
        {{/cmname}}
    {{/hasname}}

    {{! Dates }}
    {{#dates}}
        {{#hasdates}}
            <div data-region="activity-dates" class="activity-dates me-sm-2">
                {{#activitydates}}
                    {{$core_course/activity_date}}
                        {{>core_course/activity_date}}
                    {{/core_course/activity_date}}
                {{/activitydates}}
            </div>
        {{/hasdates}}
    {{/dates}}

    {{! Visibility }}
    {{$ core_courseformat/local/content/cm/badges }}
        {{> core_courseformat/local/content/cm/badges }}
    {{/ core_courseformat/local/content/cm/badges }}

    {{! Group mode }}
    {{#groupmodeinfo}}
        <div
            class="activity-groupmode-info align-self-start ms-sm-2"
            data-region="groupmode"
        >
            {{$ core_courseformat/local/content/cm/groupmode}}
                {{> core_courseformat/local/content/cm/groupmode}}
            {{/ core_courseformat/local/content/cm/groupmode}}
        </div>
    {{/groupmodeinfo}}

    {{! Completion }}
    {{#completion}}
        {{#hascompletion}}
            <div class="activity-completion align-self-start ms-sm-2">
                {{$ core_courseformat/local/content/cm/activity_info}}
                    {{> core_courseformat/local/content/cm/activity_info}}
                {{/ core_courseformat/local/content/cm/activity_info}}
            </div>
        {{/hascompletion}}
    {{/completion}}

    {{! Action menu }}
    {{#controlmenu}}
        <div class="activity-actions bulk-hidden align-self-start ms-sm-2">
            {{$ core_courseformat/local/content/cm/controlmenu }}
                {{> core_courseformat/local/content/cm/controlmenu }}
            {{/ core_courseformat/local/content/cm/controlmenu }}
        </div>
    {{/controlmenu}}

    {{! Description }}
    {{#altcontent}}
        <div class="activity-altcontent text-break {{#hasname}}activity-description{{/hasname}}">
            {{{altcontent}}}
        </div>
    {{/altcontent}}

    {{! Availability }}
    {{#modavailability}}
        {{$ core_courseformat/local/content/cm/availability }}
            {{> core_courseformat/local/content/cm/availability }}
        {{/ core_courseformat/local/content/cm/availability }}
    {{/modavailability}}

    {{! Afterlink }}
    {{#afterlink}}
        <div class="activity-afterlink afterlink d-flex align-items-center">
            {{{afterlink}}}
        </div>
    {{/afterlink}}
</div>
