{% extends 'bootstrap-modal-layout.html.twig' %}

{% set modal_class = 'modal-lg' %}

{% set replaceFor= replaceFor|default(null) %}

{% do script(['app/js/activity-manage/homework/picker/index.js']) %}

{% block title %}
  {% if replaceFor %}
    {{'course.testpaper_manage.question.replace_modal.select'|trans}}
  {% else %}
    {{'course.testpaper_manage.question.replace_modal.replace'|trans}}
  {% endif %}
{% endblock %}

{% block body %}
<div id="question-picker-body">

  {% include 'homework/manage/picker-search-form.html.twig' with {targetType:'homework'} %}

  <table class="table table-condensed" id="item-picker-table">
    <thead>
    <tr>
      {% if not replace|default(null) %}
        <th><input type="checkbox" data-role="batch-select"></th>
      {% endif %}
      <th width="45%">{{'course.question_manage.stem'|trans}}</th>
      <th>{{'course.question_manage.type'|trans}}</th>
      <th>{{'course.question_manage.operation'|trans}}</th>
    </tr>
    </thead>
    <tbody>
      {% for question in questions if (question.type != 'material' or question.subCount > 0) %}
        {% include 'homework/manage/question-picker-tr.html.twig' %}
      {% else %}
        <tr>
          <td colspan="20"><div class="empty">{{'course.testpaper_manage.question.replace_modal.empty'|trans}}<a class="link-primary" href="{{ path('course_set_manage_question',{id:courseSet.id}) }}">{{'course.testpaper_manage.question.replace_modal.create_btn'|trans}}</a></div>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  {% if not replace %}
    <div id="item-operate">
      <label class="checkbox-inline">
        <input type="checkbox" data-role="batch-select">{{'course.testpaper_manage.question.select_all'|trans}}
      </label>
    </div>
  {% endif %}
  {{ web_macro.paginator(paginator) }}
</div>

{% endblock %}

{% block footer %}
    <span class="color-danger pull-left js-choice-notice" style="display:none;">{{'course.testpaper_manage.question.replace_modal.select_btn'|trans}}</span>
    <button type="button" class="btn btn-primary" type="button" class="btn btn-primary pull-right" data-role="batch-select-save" data-toggle="form-submit" data-target="#block-form" data-url="{{ path('course_set_manage_homework_question_picked', {courseSetId:courseSet.id }) }}">{{'form.btn.confirm'|trans}}
    </button>

    <button type="button" class="btn btn-link pull-right js-close-modal" data-dismiss="modal">{{'form.btn.close'|trans}}</button>
{% endblock %}
