{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% if questionStatus != 'finished' %}{% set script_controller = 'homeworkbundle/controller/exercise/do' %}{% endif %}

{% if itemSetResult|default(null) %}{% set itemSet = itemSetResult %}{% endif %}

{% block content %}
  <div class="question-set exercise-set" id="exercise-set">

    <div class="row question-set-heading">
      <div class="col-md-12">
        <div class="panel panel-default">
          <div class="panel-body">
            <div class="question-set-type">练习</div>
            <div class="question-set-title">{{ lesson.title }}</div>

            <div class="question-set-description">
              <p class="text-muted">所属课程 <a href="{{ path('course_show',{id:course.id}) }}">{{ course.title }}</a></p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="row question-set-body">
      <div class="col-md-9 question-set-main">
        <div class="panel panel-default">
          <div class="panel-heading">练习题目 <small class="text-muted">共{{ itemSet.total }}题</small></div>
          <div class="panel-body">
            <div class="question-set-items">
              {% for key,item in itemSet.items %}
                {% if item.subItems|default(null) %}
                  {% include 'TopxiaWebBundle:Question:question-set-item-have-sub.html.twig' %}
                {% else %}
                  {% include 'TopxiaWebBundle:Question:question-set-item.html.twig' %}
                {% endif %}
              {% endfor %}
            </div>
          </div>
        </div>
      </div>
      {% if questionStatus  == 'doing' %}

          <div class="col-md-3 question-set-side">
            <div class="panel panel-default question-set-card" data-spy="affix" data-offset-top="200" data-offset-bottom="200">
                <div class="panel-body">
                  {%- for questionId in itemSet.questionIds -%}
                    <a href="javascript:;" class="question-index for-question-{{ questionId }} " data-anchor="{{questionId}}">{{ loop.index }}</a>
                  {%- endfor -%}
                </div>
                <div class="panel-footer">
                  <button class="btn btn-success btn-block " id="exercise-finish-btn" data-url="{{ path('course_exercise_submit',{courseId:course.id,exerciseId:exercise.id}) }} " data-saving-text="正在保存...">提交练习</button>
                </div>
            </div>
        </div>
      {% endif %}

    </div>

  </div>
{% endblock %}