{% extends 'courseset-manage/layout.html.twig' %}

{% block title %}{{'试卷题目管理'|trans}} - {{ parent() }}{% endblock %}

{% set side_nav = 'testpaper' %}

{% do script(['app/js/testpaper-manage/questions/index.js']) %}

{% block main %}

<style>
tr.placeholder {
  display: block;
  background: red;
  position: relative;
  margin: 0;
  padding: 0;
  border: none;
}
tr.placeholder:before {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-left-color: red;
    margin-top: -5px;
    left: -5px;
    border-right: none;
}
</style>
{% set questionTypesDict = getQuestionTypes() %}
<div class="panel panel-default panel-col" id="testpaper-items-manager">
  <div class="panel-heading">{{testpaper.name}}
  </div>
  <div class="panel-body clearfix">
    {% include 'testpaper/manage/form-breadcrumb.html.twig' with {title:'试卷题目管理'} %}
    <div class="clearfix mbm">
      <button data-url="{{ path('course_set_manage_question_picker',{id:courseSet.id, testpaperId:testpaper.id}) }}" class="btn btn-info btn-sm pull-right" data-role="pick-item"><span class="es-icon es-icon-anonymous-iconfont"></span> {{'新增试题'|trans}}</button>
      <ul class="nav nav-pills nav-mini" id="testpaper-question-nav">
        {% for type,count in testpaper['metas']['counts'] if count > 0 %}
          <li {% if loop.index == 1 %}class="active"{% endif %}><a href="javascript:" data-type="{{ type }}" data-name="{{ questionTypesDict[type] }}" class="testpaper-nav-link">{{ questionTypesDict[type] }}</a></li>
        {% endfor %}
      </ul>
    </div>
    <form  method="post" id="question-checked-form" class="form-horizontal" action="{{ path('course_set_manage_testpaper_questions',{courseSetId:courseSet.id, testpaperId:testpaper.id}) }}">
      <div id="testpaper-stats" class="color-success"></div>
      <table class="table table-striped table-hover tab-content" id="testpaper-table">
        <thead>
          <tr>
            <th></th>
            <th><input type="checkbox" data-role="batch-select"></th>
            <th width="8%">{{'题号'|trans}}</th>
            <th width="35%">{{'题干'|trans}}</th>
            <th width="10%">{{'类型'|trans}}</th>
            <th width="10%">{{'难度'|trans}}</th>
            <th width="10%">{{'分值'|trans}}</th>
            <th width="20%">{{'操作'|trans}}</th>
          </tr>
        </thead>
        {% for type,count in testpaper['metas']['counts'] if count > 0 %}
          <tbody data-type="{{ type }}" id="testpaper-items-{{ type }}" class="testpaper-table-tbody {% if loop.index != 1 %}hide{% endif %}" data-role="question-body">
            {% for question in questions[type]|default(null) if question %}
              {% if not question.isDeleted|default(null) %}
                {% include 'question-manage/question-picked-tr.html.twig' %}
                {% if question.subs|default(null) %}
                  {% for question in question.subs %}
                    {% include 'question-manage/question-picked-tr.html.twig' %}
                  {% endfor %}
                {% endif %}
              {% endif %}
            {% endfor %}
          </tbody>
        {% endfor %}
      </table>
      <p>
        <label class="inline-block vertical-top checkbox-inline"><input type="checkbox" data-role="batch-select">{{'全选'|trans}}</label>
        <button type="button" class="btn btn-default btn-sm mlm" data-role="batch-delete-btn"  data-name="{{'题目'|trans}}">{{'删除'|trans}}</button>
      </p>
      <p class="js-subjective-remask {% if hasEssay %} hidden {% endif %}">{{'这是一份纯客观题的试卷, 达到'|trans}}
        <input type="text" name="passedScore" class="form-control width-150 mhs" value="{{ passedScoreDefault }}" data-score-total="0" />{{'分（含）可以自动审阅通过考试。'|trans}}
      </p>
      <p class="text-right"><button type="button" class="btn btn-primary js-request-save">{{'保存试卷'|trans}}</button></p>
      <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
    </form>
  </div>

  <div id="testpaper-confirm-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">{{'确认试卷题目信息'|trans}}</h4>
        </div>
        <div class="modal-body">
          <table class="table table-bordered">
            <thead>
              <tr>
                <th>{{'题目类型'|trans}}</th>
                <th>{{'题目数量'|trans}}</th>
                <th>{{'总分值'|trans}}</th>
              </tr>
            </thead>
            <tbody class="detail-tbody"></tbody>
          </table>

        </div>
        <div class="modal-footer">
          <button class="btn btn-link" data-dismiss="modal" type="button">{{'关闭'|trans}}</button>
          <button type="button" class="btn btn-primary js-confirm-submit" data-loading-text="{{'正在保存'|trans}}...">{{'确定'|trans}}</button>
        </div>
      </div>
    </div>
  </div>

</div>

{% endblock %}