{{!
    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_courserating/course_rating_block

    Example context (json):
    {
    }

}}
<div class="tool_courserating-widget w-100 {{extraclasses}}">
    <div data-for="tool_courserating-cfield-wrapper" data-courseid="{{courseid}}" class="rating-summary">
        {{>tool_courserating/summary_for_cfield}}
    </div>
    {{#canrate}}
        <div class="add-rating-link">
            <a href="#" data-action="tool_courserating-addrating" data-courseid="{{courseid}}">
                {{#hasrating}}
                    {{#str}}editrating, tool_courserating{{/str}}
                {{/hasrating}}
                {{^hasrating}}
                    {{#str}}addrating, tool_courserating{{/str}}
                {{/hasrating}}
            </a>
        </div>
    {{/canrate}}
</div>
{{#parentelement}}
    {{#js}}
        /* Move the widget to the header area */
        const widget = document.querySelector(".tool_courserating-widget");
        const parents = "{{parentelement}}".split(',');
        for (let i in parents) {
            const header = document.querySelector(parents[i]);
            if (header) {
                header.appendChild(widget);
                break;
            }
        }
    {{/js}}
{{/parentelement}}
