{{ import_javascript({'list':'schedule/schedule-list'}) }}
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" {% if viewType == 'today' %} class="active" {% endif %} data-url="{{ path('class_student_schedule',{classId:classId,userId:app.user.id,viewType:'today'}) }}"><a href="javascript:;">今日课表</a></li>
  <li role="presentation" {% if viewType == 'tomorrow' %} class="active" {% endif %} data-url="{{ path('class_student_schedule',{classId:classId,userId:app.user.id,viewType:'tomorrow'}) }}"><a href="javascript:;">明日课表</a></li>
  <a href="{{ path('class_schedule', {classId:classId}) }}" class="pull-right">全部课表&raquo;</a>
</ul>
<ul class="media-list">
  {% for schedule in schedules %}
    {% if lessons[schedule.lessonId]|default(null) %}
      {% set lessonUrl = path('course_learn', {id:courses[lessons[schedule.lessonId].courseId].id}) ~ '#lesson/' ~ schedule.lessonId%}

      {% set lessonId=schedule.lessonId %}
      {% set courseId=lessons[lessonId].courseId %}
      {% set teacherId=courses[courseId].teacherIds[0]|default(0) %}
      {% set teacher = teachers[teacherId]|default(null) %}

      {# {% set teacher = teachers[courses[lessons[schedule.lessonId].courseId].teacherIds[0]|default(0)]|default(null) %} #}
        <li class="media">
          <a class="pull-left img-a" href="{{ lessonUrl }}" target="_blank">
            {% if schedule.status == 'finished' %}
                <span class="finished-icon"><span class="glyphicon glyphicon-ok text-success"></span></span>
              {% endif %}
            <img class="media-object" src="{{ file_path(courses[lessons[schedule.lessonId].courseId].middlePicture, 'course-large.png') }}" alt="{{ courses[lessons[schedule.lessonId].courseId].title }}">
          </a>
          <div class="media-body" title="{{lessons[schedule.lessonId].title}}">
            <h4 class="media-heading">
              <a class="pull-left img-a" href="{{ lessonUrl }}" target="_blank">{{lessons[schedule.lessonId].title}}
              </a>  
            </h4>
            <span class="name-text">{{ teacher.truename }}</span>
          </div>
        </li>
    {% else %}
      <li class="media">
        <a class="pull-left img-a" href="javascript:;">
          {% if schedule.status == 'finished' %}
              <span class="finished-icon"><span class="glyphicon glyphicon-ok text-success"></span></span>
            {% endif %}
          <img class="media-object" src="{{ file_path('', 'course-large.png') }}" alt="课时已删除!">
        </a>
        <div class="media-body" title="课时已删除">
          <h4 class="media-heading text-danger">课时已删除</h4>
        </div>
      </li>
    {% endif %}  
  {% else %}
    <li class="empty">
      {% if viewType|default('today') == 'today' %}今天{% else %}明天{% endif %}没有排课</li>
  {% endfor %}
</ul>
