<div class="syllabus_category">
  <% if @type.to_i  == 2 %>
      <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %>
  <% else %>
      <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "sortdownbtn  sort_no fr", :style => "margin-right: 5px;", :remote => true %>
  <% end %>
  <%= link_to "人气", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type,  :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %>
  <% if @type.to_i == 1 %>
      <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %>
  <% else %>
      <%= link_to "", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "sortdownbtn  sort_no fr", :remote => true %>
  <% end %>
  <%= link_to "时间", {:controller => 'users', :action => 'sort_syllabus_list', :id =>@user,:list_type => list_type, :type => @type,  :sort => @c_sort, :order => 1 }, :class => "sortTxt fr", :remote => true %>
  <span class="grayTxt fl "><%=@user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "加入"%>的课程</span>
  <div class="cl"></div>
</div>

<% if syllabuses.any? %>
    <% syllabuses.each_with_index do |syllabus, index|%>
        <div class="syllabus_courses_box">
          <% course_count = syllabus.courses.not_deleted.count %>
          <div class="syllabus_courses_list" id="syllabus_courses_list_<%= syllabus.id %>">
            <div class="<%=index == 0 ? 'sy_courses_open' : 'sy_courses_close' %>">
              <span onclick="expand_courses(<%=syllabus.id %>,<%=course_count %>);" class="<%=index == 0 && course_count != 0 ? 'icons_sy_open' : 'icons_sy_close' %> fl mr5" title="点击展开/收起班级列表"></span>
              <%=link_to syllabus.title, syllabus_path(syllabus.id), :class => 'syllabus_courses_title fl', :target => '_blank' %>
            </div>
            <p class="fl sy_p_grey">更新时间：<%=format_date syllabus.updated_at %>
              <span class="mr10"></span>创建老师：<%=syllabus.user.show_name %>
              <span class="mr10"></span>班级：<%=course_count %>
            </p>
            <div class="cl"></div>
          </div>

          <div class="syllabus_class_box <%=index == 0 ? '' : 'none' %>">
            <ul id="syllabus_course_ul_<%=syllabus.id %>">
              <% if index == 0 %>
                <% courses = syllabus.courses.not_deleted.select("courses.*,(SELECT MAX(updated_at)  FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") %>
                <%= render :partial => 'users/courses_list', :locals => {:courses => courses, :syllabus => syllabus}%>
              <% end %>
            </ul>
          </div><!--syllabus_class_box end-->

          <div class="homepagePostSetting">
            <ul>
              <li class="icons_sy_setting">
                <ul class="homepagePostSettiongText">
                  <li>
                    <%=link_to '查看课程', syllabus_path(syllabus.id), :class => 'postOptionLink',:target =>'_blank', :title => '查看课程' %>
                  </li>
                  <% if User.current == syllabus.user %>
                      <li><%=link_to '删除课程', delete_syllabus_syllabus_path(syllabus), :class => 'postOptionLink', :remote => 'true'%></li>
                  <% end %>
                </ul>
              </li>
            </ul>
          </div>
        </div>
    <% end %>
<% else %>
    <p class="nodata"><%= l(:label_no_data) %></p>
<% end %>