<?xml version="1.0"?>
<t name="Survey User Input Leaderboard" t-name="survey.user_input_session_leaderboard">
        <div t-if="leaderboard" class="position-relative mb-5" t-attf-style="height: calc(3.8rem * #{len(leaderboard)});">
            <t t-set="max_score" t-value="max(score.get('scoring_total', 1) for score in leaderboard) or 1"/>
            <t t-set="max_updated_score" t-value="max(score.get('updated_score', 1) for score in leaderboard)"/>
            <t t-foreach="leaderboard" t-as="score">
                <div class="o_survey_session_leaderboard_item ms-2 d-flex position-absolute" t-attf-style="top: calc(#{score_index} * 3.8rem);" t-att-data-current-position="str(score_index)" t-att-data-new-position="str(score.get('leaderboard_position', score_index))" t-att-data-question-score="str(round(score.get('question_score', 0)))" t-att-data-current-score="str(round(score.get('scoring_total', 0)))" t-att-data-updated-score="str(round(score.get('updated_score', 0)))" t-att-data-max-question-score="round(score.get('max_question_score', 1))" t-att-data-max-updated-score="round(max_updated_score)">
                    <div class="d-inline-block fw-bold align-top">
                        <div class="d-inline-block me-2 o_survey_session_leaderboard_score" t-esc="'%.0f p' % score['scoring_total']"/>
                    </div>
                    <!-- We keep "18rem" of space to display the points / nickname.
                    Then, the length of the bar is a percentage of the attendee's score compared to the max_score. -->
                    <t t-set="width_ratio" t-value="round(round(score['scoring_total'], 3) / round(max_score, 3), 3)"/>
                    <t t-set="width_ratio_question" t-value="str(round(round(score.get('question_score', 0), 3) / round(score.get('max_question_score', 1), 3), 3))"/>
                    <div class="o_survey_session_leaderboard_bar ms-2 align-top d-inline-block text-end fw-bold" t-att-style="'width: calc(calc(%s - 18rem) * %s)' % ('100%', width_ratio)" t-att-data-width-ratio="width_ratio">
                    </div>
                    <div class="o_survey_session_leaderboard_bar_question me-2 align-top d-inline-block text-end fw-bold position-relative" style="width: 0px;" t-att-data-width-ratio="width_ratio_question" t-att-data-max-question-score="str(score.get('max_question_score', 1))" t-att-data-question-score="str(score.get('question_score', 0))">
                        <div class="o_survey_session_leaderboard_bar_question_score position-absolute"/>
                    </div>
                    <div class="o_survey_session_leaderboard_name d-inline-block">
                        <span t-if="score.get('nickname')" t-esc="score['nickname']"/>
                        <span t-else="">Anonymous</span>
                    </div>
                </div>
            </t>
        </div>
    </t>
