{{!
    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=\"badge badge-primary\">30 unread messages</span>",
        "hasextras": true,
        "extras": ["<span class=\"badge badge-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"
                }
            ]
        },
        "modstealth": true
    }
}}
{{#ismoodle42minus}}
    {{>format_tiles/local/content/cm/activity42}}
{{/ismoodle42minus}}
{{^ismoodle42minus}}
    {{#moveicon}} {{{moveicon}}} {{/moveicon}}
    <div class="activity-grid {{^hasname}}noname-grid{{/hasname}} tiles-activity-container"
        {{#clickable}}data-cmid="{{cmid}}" data-modinstance="{{modinstance}}" data-title="{{{activityname}}}"{{/clickable}}>
        {{! Icon, Name & Badge }}
        {{#hasname}}
            {{#cmname}}
                {{$ format_tiles/local/content/cm/cmname }}
                    {{> format_tiles/local/content/cm/cmname }}
                {{/ format_tiles/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}}
            {{! In Moodle 4.5+, if this is a delegated section then this is a container for a <ul> of course modules }}
            <div class="activity-altcontent {{#issubsection}}delegated-section-content{{/issubsection}}{{^isdelegatedsection}}d-flex{{/isdelegatedsection}} 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>
{{/ismoodle42minus}}
