{{!
    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_h5pactivity/attempts

    This template will render the report link inside a H5P activity.

    Variables required for this template:
    * attempts - Full attempts list with:
      * timemodified - Attempt timemodified
      * attempt - Attempt number
      * rawscore - Attempt rawscore
      * maxscore - Attempt maxscore
      * duration - Attempt duration
      * completionicon - Completion icon HTML
      * successicon - Success icon HTML
      * reporturl - Attempt report URL

    Variables optional for this template:
    * title - optional selected attempt name
    * scored - The scored attempt

    Example context (json):
    {
        "attempts": [
            {
                "id": 7,
                "h5pactivityid": 1,
                "userid": 5,
                "timecreated": 1587654916,
                "timemodified": 1587654916,
                "attempt": 1,
                "rawscore": 6,
                "maxscore": 6,
                "duration": "14 seconds",
                "durationcompact": "14''",
                "completion": 1,
                "completionicon": "<i class=\"icon fa fa-check-circle fa-fw \"><\/i>",
                "success": 1,
                "successicon": "<i class=\"icon fa fa-check-circle fa-fw \"><\/i>",
                "scaled": 1,
                "reporturl": {},
                "score": "6 out of 6"
            },
            {
                "id": 8,
                "h5pactivityid": 1,
                "userid": 5,
                "timecreated": 1587654927,
                "timemodified": 1587654927,
                "attempt": 2,
                "rawscore": 1,
                "maxscore": 6,
                "duration": "25 seconds",
                "durationcompact": "25''",
                "completion": 1,
                "completionicon": "<i class=\"icon fa fa-check-circle fa-fw \"><\/i>",
                "success": 0,
                "successicon": "<i class=\"icon fa fa-circle-o fa-fw \"><\/i>",
                "scaled": 0,
                "reporturl": {},
                "score": "1 out of 6"
            },
            {
                "id": 9,
                "h5pactivityid": 1,
                "userid": 5,
                "timecreated": 1587654942,
                "timemodified": 1587654942,
                "attempt": 3,
                "rawscore": 3,
                "maxscore": 6,
                "duration": "40 seconds",
                "durationcompact": "40''",
                "completion": 1,
                "completionicon": "<i class=\"icon fa fa-check-circle fa-fw \"><\/i>",
                "success": 0,
                "successicon": "<i class=\"icon fa fa-circle-o fa-fw \"><\/i>",
                "scaled": 0,
                "reporturl": {},
                "score": "3 out of 6"
            }
        ]
    }

}}
<table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">{{#str}} date {{/str}}</th>
      <th scope="col">{{#str}} score, mod_h5pactivity {{/str}}</th>
      <th scope="col" class="d-none d-md-table-cell">{{#str}} maxscore, mod_h5pactivity {{/str}}</th>
      <th scope="col" class="d-none d-sm-table-cell">{{#str}} duration, mod_h5pactivity {{/str}}</th>
      <th scope="col" class="d-none d-sm-table-cell" class="text-center">{{#str}} completion, mod_h5pactivity {{/str}}</th>
      <th scope="col" class="text-center">{{#str}} success {{/str}}</th>
      <th scope="col">{{#str}} report {{/str}}</th>
    </tr>
  </thead>
  <tbody>
    {{#attempts}}
    <tr>
      <th scope="row">{{attempt}}</th>
      <td>
        <span class="d-none d-lg-inline">
          {{#userdate}} {{timemodified}}, {{#str}} strftimedatetime, core_langconfig {{/str}} {{/userdate}}
        </span>
        <span class="d-inline d-lg-none">
          {{#userdate}} {{timemodified}}, {{#str}} strftimedatetimeshort, core_langconfig {{/str}} {{/userdate}}
        </span>
      </td>
      <td>{{rawscore}}<span class="d-inline d-md-none"> / {{maxscore}}</span></td>
      <td class="d-none d-md-table-cell">{{maxscore}}</td>
      <td class="d-none d-sm-table-cell">
        <span class="d-none d-md-inline">{{duration}}</span>
        <span class="d-inline d-md-none">{{durationcompact}}</span>
      </td>
      <td class="text-center d-none d-sm-table-cell">{{{completionicon}}}</td>
      <td class="text-center">{{{successicon}}}</td>
      <td>
        <span class="d-none d-md-inline">
          <a href="{{{reporturl}}}">{{#str}} view_report, mod_h5pactivity {{/str}}</a>
        </span>
        <span class="d-inline d-md-none">
          <a href="{{{reporturl}}}">{{#str}} view {{/str}}</a>
        </span>
      </td>
    </tr>
    {{/attempts}}
  </tbody>
</table>
