{{!
    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 auth_lti/local/ltiadvantage/login

    Template which displays a choice screen for instructors on first launch, allowing them to select whether to use an
    existing account in the tool, or to auto provision a new one.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * none

    Context variables required for this template:
    * formaction
    * sesskey
    * info - a notification describing the first launch options
    * cancreateaccounts - whether or not the user is allowed to create auth_lti accounts
    * accountinfo - information about the user, importantly whether they are logged in or not.
    * noauthnotice - a notification telling the user they must be authenticated to link accounts. Only relevant when not logged in.

    Example context (json):
    {
        "formaction": "auth/lti/login.php",
        "sesskey": "1a2b3c4dfg",
        "info": {
            "message": "Looks like this is your first time here...",
            "extraclasses": "",
            "announce": false,
            "closebutton": false,
            "issuccess": true
        },
        "cancreateaccounts": true,
        "accountinfo": {
            "isloggedin": true,
            "firstname": "John",
            "lastname": "Smith",
            "email": "john@example.com",
            "picturehtml": "<img src=\"http://site.example.com/pluginfile.php/5/user/icon/boost/f2?rev=99\" class=\"round\" alt=\"\" width=\"35\" height=\"35\">"
        },
        "noauthnotice": {
            "message": "To link your existing account you must be logged in to the site...",
            "extraclasses": "",
            "announce": false,
            "closebutton": false,
            "iswarning": true
        }
    }
}}
<div id="lti_adv_account_binding_options">
    <form action="{{formaction}}" method="POST">
        <input type="hidden" name="sesskey" value="{{sesskey}}">
        <div class="container-fluid">
            <h2>{{#str}} welcome, auth_lti {{/str}}</h2>
            {{#info}}
                {{> core/notification}}
            {{/info}}
            <div class="row">
                <div class="{{#cancreateaccounts}}col-sm-6{{/cancreateaccounts}}{{^cancreateaccounts}}col-sm-12{{/cancreateaccounts}} d-flex">
                    <div class="card w-100">
                        <div class="card-header">
                            {{#str}} haveexistingaccount, auth_lti {{/str}}
                        </div>
                        <div class="card-body text-center d-flex flex-column">
                            <i class="fa fa-user-circle-o fa-2x link"></i>
                            <h4 class="card-title">{{#str}} useexistingaccount, auth_lti {{/str}}</h4>
                            {{#accountinfo}}
                                {{#isloggedin}}
                                    <p class="card-text mt-2">
                                        <span class="text-muted">
                                            {{#str}} currentlyloggedinas, auth_lti {{/str}}
                                        </span>
                                        <br>
                                        {{{picturehtml}}}
                                        {{firstname}} {{lastname}} ({{email}})
                                    </p>
                                    <input type="submit" class="btn btn-primary mt-auto" name="existing_account" value="{{#str}} linkthisaccount, auth_lti {{/str}}">
                                {{/isloggedin}}
                                {{^isloggedin}}
                                    <p class="card-text text-muted">{{#str}} mustbeloggedin, auth_lti {{/str}}</p>
                                    {{#noauthnotice}}
                                        {{> core/notification}}
                                    {{/noauthnotice}}
                                {{/isloggedin}}
                            {{/accountinfo}}
                        </div>
                    </div>
                </div>
                {{#cancreateaccounts}}
                <div class="col-sm-6 d-flex">
                    <div class="card w-100">
                        <div class="card-header">
                            {{#str}} createnewaccount, auth_lti {{/str}}
                        </div>
                        <div class="card-body text-center d-flex flex-column">
                            <i class="fa fa-user-plus fa-2x"></i>
                            <h4 class="card-title">{{#str}} createaccount, auth_lti {{/str}}</h4>
                            <p class="card-text text-muted">{{#str}} getstartedwithnewaccount, auth_lti {{/str}}</p>
                            <input type="submit" class="btn btn-secondary mt-auto" name="new_account" value="{{#str}} createaccountforme, auth_lti {{/str}}">
                        </div>
                    </div>
                </div>
                {{/cancreateaccounts}}
            </div>
        </div>
    </form>
</div>
