{{!
    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 local_learnwise/aiassementassistant

    Renders AI Assessment assistant

    Example context (json):
    {
        "host": "https:\/\/feedback.sandbox.learnwise.dev",
        "feedbacksrc": "https:\/\/feedback.sandbox.learnwise.dev",
        "assistantid": "TEMPID",
        "courseid": "4",
        "cmid": "13",
        "region": "eu",
        "loggedinuser": {
            "id": "2",
            "fullname": "Admin User",
            "email": "admin@test.com"
        }
    }
}}
<script>
    window.learnWiseFeedbacksetup = {
        host: {{#quote}}{{{ host }}}{{/quote}},
        feedbackSrc: {{#quote}}{{{ feedbacksrc }}}{{/quote}},
        assistantId: {{#quote}}{{{ assistantid }}}{{/quote}},
        lmsType: "moodle",
        courseId: {{#quote}}{{{ courseid }}}{{/quote}},
        assignmentId: {{#quote}}{{{ cmid }}}{{/quote}},
        submissionId: null,
        studentId: null,
        region: {{#quote}}{{{ region }}}{{/quote}},

        name: {{#quote}}{{{ loggedinuser.fullname }}}{{/quote}},
        email: {{#quote}}{{{ loggedinuser.email }}}{{/quote}},
        lmsUserId: {{#quote}}{{{ loggedinuser.id }}}{{/quote}},
        roles: null,
    }

    document.addEventListener('initLearnWiseAssessment', function(e) {
        var submission = e.detail;
        if (!submission) {
            return;
        }
        window.learnWiseFeedbacksetup.submissionId = submission.submission.id;
        window.learnWiseFeedbacksetup.studentId = submission.submission.userid;

        var script_fb = document.createElement('script');
        script_fb.src = window.learnWiseFeedbacksetup.host + '/launcher/launcher_moodle.js';
        document.head.appendChild(script_fb);
    });
</script>
{{#js}}
    require(['local_learnwise/aiassessment'], function(amd) {
        amd.init();
    });
{{/js}}