{{!
    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 mod_forum/grades/grader/discussion/posts

    Template to render a list of posts for a discussion.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * data-region="posts"

    Example context (json):
    {
    }
}}
<div
    class="{{#experimentaldisplaymode}}nested-v2-display-mode{{/experimentaldisplaymode}}"
    data-region="posts"
    id="post-region-{{uniqid}}"
>
    {{#discussions}}
        <div class="discussion-container">
            <div class="p-4">
                <h3 class="d-inline-block m-0 h6 font-weight-bold">{{#str}} discussionstartedby, mod_forum, {{authorfullname}} {{/str}}</h3>
                <p class="d-inline-block m-0 h6 font-weight-normal text-muted ms-1">
                    {{#userdate}} {{timecreated}}, {{#str}} strftimedate, core_langconfig {{/str}} {{/userdate}}
                </p>
                <h2 class="mb-4 font-weight-bold">{{name}}</h2>

                {{#posts}}
                    <div class="posts-container">
                        {{#parent}}
                            <div class="parent-container">
                                <button
                                    class="btn btn-link show-content-button collapsed"
                                    data-target="#parent-post-content-{{id}}"
                                    aria-expanded="false"
                                    aria-controls="parent-post-content-{{id}}"
                                    data-toggle="collapse"
                                >
                                    {{#str}} viewparentpost, mod_forum {{/str}}
                                </button>
                                <div id="parent-post-content-{{id}}" class="content collapse">
                                    {{#experimentaldisplaymode}}{{> mod_forum/forum_discussion_nested_v2_first_post }}{{/experimentaldisplaymode}}
                                    {{^experimentaldisplaymode}}{{> mod_forum/forum_discussion_nested_post }}{{/experimentaldisplaymode}}
                                </div>
                            </div>
                        {{/parent}}
                        {{#post}}
                            <div class="post-container">
                                {{#experimentaldisplaymode}}{{> mod_forum/forum_discussion_nested_v2_first_post }}{{/experimentaldisplaymode}}
                                {{^experimentaldisplaymode}}{{> mod_forum/forum_discussion_nested_post }}{{/experimentaldisplaymode}}
                            </div>
                            <button
                                class="view-context-button btn btn-link border"
                                type="button"
                                data-action="view-context"
                                data-discussionid="{{discussionid}}"
                                data-postid="{{id}}"
                                data-name="{{name}}"
                                data-experimental-display-mode="{{experimentaldisplaymode}}"
                            >
                                {{#str}} viewconversation, forum {{/str}}
                            </button>
                        {{/post}}
                        <hr class="w-75 mx-auto my-5">
                    </div>
                {{/posts}}
            </div>
            <hr>
        </div>
    {{/discussions}}
    {{^discussions}}
        <div class="no-post-container text-center p-5">
            {{#pix}} no-posts, mod_forum {{/pix}}
            <h2 class="mt-3 font-weight-bold">{{#str}} noposts, mod_forum {{/str}}</h2>
        </div>
    {{/discussions}}
</div>
{{#js}}
    require(['mod_forum/grades/expandconversation'], function(Conversation) {
        Conversation.registerEventListeners(document.querySelector('#post-region-{{uniqid}}'));
    });
{{/js}}
