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

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

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

{% block title %}{% if replaceFor %}替换{% else %}选择{% endif %}题目{% endblock %}

{% block body %}
<div id="homework-item-picker-body">
  <form id="homework-item-picker-form" class="form-inline well well-sm" action="{{ path('course_manage_homework_item_picker', {courseId:course.id}) }}" novalidate>
    <div class="form-group">
      <select class="form-control" name="target" style="width:200px;height:32px;">
        {{ select_options(targetChoices, app.request.query.get('target'), '--按从属--') }}
      </select>
    </div>

    <div class="form-group">
      <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}" placeholder="关键词">
    </div>

    <input type="hidden" name="excludeIds" value="{{ conditions.excludeIds|join(',')|default(null) }}">
    <input type="hidden" name="type" value="{{ conditions.type|default(null)}}">

    <button class="btn btn-primary btn-sm">搜索</button>

  </form>

  <table class="table table-condensed" id="homework-item-picker-table">
    <thead>
    <tr>
      {% if not replace %}
    <th><input type="checkbox" data-role="item-batch-select"></th>
      {% endif %}
      <th width="45%">题干</th>
      <th>类型</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
      {% for question in questions if (question.type != 'material' or question.subCount > 0) %}
        {% include 'HomeworkBundle:CourseHomeworkManage:homework-item-pick-tr.html.twig' %}
      {% else %}
        <tr><td colspan="20"><div class="empty">无题目记录,请先去<a href="{{ path('course_manage_question',{courseId:course.id}) }}">创建题目</a></div></td></tr>
      {% endfor %}
    </tbody>
  </table>
  {% if not replace %}
  <div id="homework-item-operate">
    <label class="checkbox-inline"><input type="checkbox" data-role="item-batch-select"> 全选</label>
    
  </div>
  {% endif %}
  {{ web_macro.paginator(paginator) }}
</div>
  <script>app.load('homeworkbundle/controller/course-manage/homework-item-picker')</script>

{% endblock %}

{% block footer %}
    <button type="button" class="btn btn-primary" type="submit" class="btn btn-primary pull-right" data-role="batch-select-save" data-toggle="form-submit" data-target="#block-form" >确定</button>

    <button type="button" class="btn btn-link pull-right" data-dismiss="modal">关闭</button>
{% endblock %}