<div class="homepagePostPortrait">
<%=link_to image_tag(url_to_avatar(homework.user),width:"50px", height: "50px"), user_activities_path(homework.user_id)%>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word mt-4">
  <%= link_to homework.user.show_name, user_activities_path(homework.user_id), :class => "newsBlue mr15"%>
  TO
  <%=link_to homework.course.syllabus.title, syllabus_path(homework.course.syllabus_id), :class => 'newsBlue ml15', :target => '_blank' %>
  <span class="fb" style="color: #269ac9"> • </span>
  <%= link_to homework.course.name, course_path(homework.course_id), :class => "newsBlue"%>
</div>
<div class="homepagePostTitle hidden fl m_w505">
  <% index = get_hw_index(homework, is_teacher) %>
  <%= link_to "<span class='fontBlue2'>作业#{index + 1}：</span>".html_safe + homework.name,student_work_index_path(:homework => homework.id),:class => "postGrey"%>
</div>
<%=get_hw_status(homework).html_safe %>
<div class="cl"></div>
<% if homework.homework_type == 3 && homework.homework_detail_group.base_on_project == 1%>
    <span class="c_red">系统提示：该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>，组成员加入项目，然后由组长关联项目。谢谢配合！</span>
<% elsif homework.homework_type == 3 && homework.homework_detail_group.base_on_project == 0%>
    <span class="c_red">系统提示：该作业要求各组长提交作品，提交作品时请添加组成员。谢谢配合！</span>
<% end %>

<% is_pro = homework.homework_type == 2 && is_teacher %>
<% is_base_group = homework.homework_type == 3 && (homework.homework_detail_group.base_on_project == 1 || !(cur_user_works_for_homework(homework).nil?)) && !is_teacher %>
<div class="mt8 mb5">
  <%= render :partial => 'users/homework_opr', :locals => {:activity => homework, :is_teacher => is_teacher, :hw_status => 5, :user_activity_id => homework.id} %>
  <% if is_pro || is_base_group %>
      <div class="cl"></div>
  <% end %>
  <% if !homework.publish_time.nil? %>
      <div class="homepagePostDeadline <%= (is_pro || is_base_group) ? 'mt8' : '' %>">
        <%= l(:label_publish_time)%>：<%= homework.publish_time%>&nbsp;00:00
      </div>
  <% end %>
  <% if homework.homework_detail_manual && homework.homework_detail_manual.comment_status < 2 %>
      <div class="homepagePostDeadline ml15 <%= (is_pro || is_base_group) ? 'mt8' : '' %>">提交截止时间：<%= homework.end_time.to_s %>&nbsp;23:59</div>
  <% elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status >= 2 && homework.anonymous_comment == 0%>
      <div class="homepagePostDeadline ml15 <%= (is_pro || is_base_group) ? 'mt8' : '' %>">匿评截止时间：<%= homework.homework_detail_manual.evaluation_end.to_s %>&nbsp;23:59</div>
  <% end %>
  <div class="cl"></div>
</div>
<div class="homeworkInfo" id="homeworkInformation">
  <div class="">
    <div class="homeworkDetail upload_img break_word list_style" id="homeworkDetail">
      <div id="homework_description">
        <%= homework.description.html_safe %>
      </div>
    </div>
    <% if is_pro %>
        <div class="mt10"> <span class="fontGrey3">测试集：<%=homework.homework_tests.count %>组</span>
          <table class="mt5 test-set-table">
            <tr>
              <th width="25">&nbsp;</th>
              <th width="290" style="max-width:290px;">测试集输入</th>
              <th width="290" style="max-width:290px;">测试集输出</th>
            </tr>
            <% homework.homework_tests.each_with_index do |test, i| %>
                <tr>
                  <td class="test_td_min"><%=i+1 %></td>
                  <td><pre style="max-width:290px; word-wrap:break-word; white-space:pre-wrap;"><%=test.input %></pre></td>
                  <td><pre style="max-width:290px; word-wrap:break-word; white-space:pre-wrap;"><%=test.output %></pre></td>
                </tr>
            <% end %>
          </table>
        </div>
    <% end %>
    <div class="cl"></div>
    <div class="mt5">
      <% if homework.homework_detail_manual%>
          <% if homework.homework_detail_manual.comment_status == 1%>
              <% end_time = homework.end_time.to_time.to_i + 24*60*60 - 1 %>
              <% if end_time >= Time.now.to_i %>
                  <div class="fontGrey2 db fr">提交剩余时间： <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
                    <span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
                    <span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
              <% else %>
                  <div class="fontGrey2 db fr c_red">提交已截止</div>
              <% end %>
          <% elsif homework.homework_detail_manual.comment_status == 2%>
              <% end_time = homework.homework_detail_manual.evaluation_end.to_time.to_i + 24*60*60 - 1 %>
              <% if end_time >= Time.now.to_i %>
                  <div class="fontGrey2 db fr">匿评剩余时间： <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60)%></span> 天
                    <span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
                    <span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
              <% else %>
                  <div class="fontGrey2 db fr c_red">匿评已截止</div>
              <% end %>
          <% end%>
      <% end%>
      <div class="cl"></div>
    </div>
  </div>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
  <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework} %>
</div>

<%= render :partial => "users/homework_base_info", :locals =>{:activity => homework, :user_activity_id =>homework.id, :is_teacher => is_teacher, :hw_status => 5} %>
</div>
<div class="cl"></div>