{{!
    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_casestudy/student_interface

    Student interface for Case Study activity

    Context variables required for this template:
    * cmid - Course module ID
    * cansubmitmore - Boolean, whether user can submit more
    * hassubmissions - Boolean, whether user has submissions
    * submissions - Array of submission objects
    * completionsummary - Object with completion data
    * availabilitymessage - String, message about availability restrictions
    * hasavailabilitymessage - Boolean, whether there is an availability message
    * availabilitystatus - String, status indicator (notopened, closed, maxreached, or empty)
    * preventaccess - Boolean, whether to hide all content (for time restrictions)

    Example context (json):
    {
        "cmid": 123,
        "cansubmitmore": true,
        "hassubmissions": true,
        "submissions": [],
        "completionsummary": {"hascompletion": false},
        "availabilitymessage": "This case study will be available from...",
        "hasavailabilitymessage": true,
        "availabilitystatus": "notopened",
        "preventaccess": true
    }
}}

<div class="casestudy-student-interface">
    {{#hasavailabilitymessage}}
    <div class="alert alert-warning mb-3">
        <i class="fa fa-info-circle"></i> {{{availabilitymessage}}}
    </div>
    {{/hasavailabilitymessage}}

    {{^preventaccess}}
        {{#casestudyinfo.hasinfo}}
        <div class="casestudy-info-panel mb-3">
            <div class="d-flex flex-wrap align-items-center">
                {{#casestudyinfo.items}}
                <div class="info-item mr-4 mb-2">
                    <i class="fa fa-{{icon}} text-muted mr-1"></i>
                    <strong>{{label}}:</strong>
                    <span class="ml-1">{{value}}</span>
                </div>
                {{/casestudyinfo.items}}
            </div>
        </div>
        {{/casestudyinfo.hasinfo}}

        {{#cansubmitmore}}
        <div class="mb-3 text-right">
            <a href="{{{submissionurl}}}" class="btn btn-primary">
                {{#str}}addcasestudy, mod_casestudy{{/str}}
            </a>
        </div>
        {{/cansubmitmore}}

        {{#completionsummary.hascompletion}}
        <div class="casestudy-completion-summary mb-3">

            <h4 class="card-title">{{#str}}completionsummary, mod_casestudy{{/str}}</h4>
            <table class="table generaltable">
            {{#completionsummary.criteria}}
                <tr>
                    <td><span class="mr-2 completion-criteria">{{label}}</span></td>
                    <td> {{current}} </td>
                    <td> <span class="bold"> / {{required}} </span> </td>
                    <td>
                        {{#completed}}
                        <span class="badge badge-success">{{#str}} completed {{/str}}</span>
                        {{/completed}}
                        {{^completed}}
                        <span class="badge badge-secondary">{{#str}} todo, completion {{/str}}</span>
                        {{/completed}}
                    </td>
                </tr>
                {{/completionsummary.criteria}}
                </table>

        </div>
        {{/completionsummary.hascompletion}}

        <div class="casestudy-submissions-section">
            <h4>{{#str}}yourcasestudies, mod_casestudy{{/str}}</h4>

            {{#tableoutput}}
                {{{tableoutput}}}
            {{/tableoutput}}

            {{#nosubmissions}}
            <div class="alert alert-info">
                <p>{{#str}}nosubmissions, mod_casestudy{{/str}}</p>
            </div>
            {{/nosubmissions}}
        </div>
    {{/preventaccess}}
</div>