{% load i18n %}

<div class="lti-wrapper">
    <h3 class="hd hd-3 problem-header">
        {# Translators:  "External resource" means that this learning module is hosted on a platform external to the edX LMS #}
        {{display_name}} ({% trans 'External resource' %})
    </h3>
    
    {% if has_score and weight %}
        <div class="problem-progress">
            {% if module_score is not None %}
                {# Translators: "points" is the student's achieved score on this LTI unit, and "total_points" is the maximum number of points achievable. #}
                {% trans "points" as points_trans %}
                {% trans "{points} / {total_points} points" as score_trans %}
                ({{ module_score }} / {{ weight }} {{ points_trans }})
            {% else %}
                {# Translators: "total_points" is the maximum number of points achievable on this LTI unit #}
                {% trans "total_points" as total_points_trans %}
                ({{ weight }} {{ total_points_trans }} possible)
            {% endif %}
        </div>
    {% endif %}
    
    <div
        id="{{ element_id }}"
        class="{{ element_class }}"
        data-ask-to-send-username="{{ ask_to_send_username }}"
        data-ask-to-send-email="{{ ask_to_send_email }}"
        data-package-name="xblocks-contrib"
    >
    
    {% if launch_url and launch_url !=  'http://www.example.com' and not hide_launch %}
        {% if open_in_a_new_page %}
            <div class="wrapper-lti-link">
                {% if description %}
                    <div class="lti-description">{{ description }}</div>
                {% endif %}
                <p class="lti-link external">
                    <a target="_blank" class="link_lti_new_window" rel="noopener" href="{{ form_url }}">
                        {{ button_text|default:_('View resource in a new window') }}
                        <span class="icon fa fa-external-link" aria-hidden="true"></span>
                    </a>
                </p>
            </div>
        {% else %}
            {# The result of the form submit will be rendered here. #}
            <iframe
                title="Form Result"
                class="ltiLaunchFrame"
                name="ltiFrame-{{ element_id }}"
                src="{{ form_url }}"
                allowfullscreen="true"
                webkitallowfullscreen="true"
                mozallowfullscreen="true"
                allow="microphone *; camera *; midi *; geolocation *; encrypted-media *"
            ></iframe>
        {% endif %}
    {% elif not hide_launch %}
        <h4 class="hd hd-4 error_message">
            {{ _('Please provide launch_url. Click "Edit", and fill in the required fields.') }}
        </h4>
    {% endif %}
    
    {% if has_score and comment %}
        <h4 class="hd hd-4 problem-feedback-label">${_("Feedback on your work from the grader:")}</h4>
        <div class="problem-feedback">
            {# sanitized with nh3 in view #}
            {{ comment|safe }}
        </div>
    {% endif %}
    
    </div>
</div>
