bigdir/app/views/bids/_homework_list.html.erb

97 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- fq -->
<% is_teacher = is_course_teacher User.current,@bid.courses.first.project %>
<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
<div class="project-search-block">
<table width="100%" valign="center">
<tr>
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
User.current.admin? ||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
(Rails.env.development?) %>
</td>
<td align="right">
<div class="project-search">
<% if is_teacher %>
<%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
<%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
<% end %>
</div></td>
</tr>
</table>
</div>
<% end %>
<% display_id = im_watching_student_id? @bid%>
<% @homework_list.each do |homework|%>
<% if homework.attachments.any?%>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
<td>
<table width="580px" border="0">
<tr>
<td style="width: 300px">
&nbsp;&nbsp;<strong>作业&nbsp;&nbsp; :</strong>&nbsp;
<% attachments = homework.attachments.map %>
<% for attachment in attachments %>
<% if attachments.count > 1 && attachment != attachments.first %>
<br/>
<% for item in 1..7 %>
&nbsp;
<% end %>
<% end %>
<%= link_to_attachment attachment , :download => true -%>
<% end %>
</td>
<td style="vertical-align: top">
<% if display_id %>
<%= link_to "互评>>" , homework_attach_path(homework)%>
<% end %>
</td>
</tr>
<tr>
<td colspan="1" valign="top" style="width: 300px">&nbsp;
<strong>发布人:&nbsp; <%= link_to (display_id ? homework.user.realname : homework.user ), user_path(homework.user)%></strong>
</td>
<td>
<strong>作业评分:</strong>
<% stars_reates = homework.rates(:quality) %>
<% sum = 0 %>
<% stars_reates.each do |star_reates| %>
<% sum = sum + star_reates.stars %>
<% end %>
<% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %>
<%= format("%.2f", sum * 1.0 / stars_reates_count) %>
</td>
<td valign="top" align="right">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %>
<span class="required">迟交</span>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" valign="top">&nbsp;
<% if display_id %>
<strong><%= l(:label_bidding_user_studentcode) %>&nbsp; &nbsp;<%= homework.user.user_extensions.student_id%></strong>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" width="580px" >
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
<p class="font_description">
<% options = {:author => true, :deletable => attach_delete(homework)} %>
<%= render :partial => 'attachments/links',
:locals => {:attachments => homework.attachments, :options => options} %>
</p>
<% end %>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="line_under"></div>
<% end %>
<% end %>