1.作业列表评分结果显示保留2位有效数字

2.互评界面显示最终评分数值
3.增加互评按钮,修改查看学号、按学号排序等功能的条件
4.修改互评界面作业下载信息显示,取消描述
This commit is contained in:
sw 2014-05-22 16:37:39 +08:00
parent 7748704c3a
commit 65c3bb5eb1
6 changed files with 91 additions and 33 deletions

View File

@ -136,4 +136,15 @@ module CoursesHelper
def find_by_extra_from_project extra
Course.find_by_extra(try(extra))
end
#判断制定用户是不是当前课程的老师
def is_course_teacher user,project
is_teacher = false
searchTeacherAndAssistant(project).each do |teacher|
if user == teacher
is_teacher = true
break
end
end
is_teacher
end
end

View File

@ -2,5 +2,5 @@ class HomeworkUser < ActiveRecord::Base
attr_accessible :homework_attach_id, :user_id
belongs_to :homework_attach
has_one :user
belongs_to :user
end

View File

@ -73,7 +73,7 @@ class User < Principal
['none', :label_user_mail_option_none]
]
has_one :homework_user
belongs_to :homework_user
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
:after_remove => Proc.new {|user, group| group.user_removed(user)}

View File

@ -1,4 +1,5 @@
<!-- 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">
@ -6,8 +7,10 @@
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span></td>
<td align="right">
<div class="project-search">
<%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
<%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
<% 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>
@ -25,16 +28,25 @@
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
<td>
<table width="580px" border="0">
<tr>&nbsp;&nbsp;&nbsp;<strong>作业&nbsp;&nbsp; :</strong>&nbsp;
<% filename = "" %>
<% homework.attachments.map do |attachment| %>
<% filename = attachment.filename %>
<% if homework.attachments.count > 1%>
<% filename += "等#{homework.attachments.count}个文件" %>
<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 %>
<% break %>
<% end %>
<%= link_to filename , homework_attach_path(homework)%>
</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;
@ -48,7 +60,7 @@
<% sum = sum + star_reates.stars %>
<% end %>
<% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %>
<%= sum * 1.0 / 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) %>
@ -58,20 +70,20 @@
</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 %>
<% 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 %>
<% 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>

View File

@ -0,0 +1,12 @@
<!-- #wang -->
<% for attachment in attachments %>
<% if attachments.count > 1 && attachment != attachments.first%>
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% end %>
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments', :action => 'show',
:id => attachment, :filename => attachment.filename %>
<% end %>
<% end -%>

View File

@ -18,7 +18,9 @@
<td colspan="2" valign="top"><strong>作业基础信息<%=@count %></strong></td>
</tr>
<tr>
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">发布人员:<%= link_to @homework.user, user_path(@homework.user)%></td>
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
</td>
<td>发布时间:<%=format_time @homework.created_at %></td>
</tr>
@ -26,9 +28,11 @@
<td style="padding-left: 40px">
<span>作业下载:</span>
<% options = {:author => true } %>
<%= render :partial => 'attachments/app_link', :locals => {:attachments => @homework.attachments, :options => options} %>
<%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %>
</td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">
所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%>
</td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%></td>
</tr>
<tr>
@ -49,7 +53,7 @@
<td>
<table width="100%" border="0">
<tr>
<td colspan="2" valign="top"><strong><div style="font-size: 15px;">作业描述:</div></strong></td>
<td colspan="2" valign="top"><div style="font-size: 15px;"><strong>作业描述:</strong></div></td>
</tr>
<% @homework.attachments.map do |attachment| %>
<% if attachment.description != nil && attachment.description != "" %>
@ -67,16 +71,20 @@
<div class="underline-contests_one"></div>
<div style="height: auto; padding-bottom: 10px">
<div style="font-size: 15px;"><strong>作业得分:</strong></div>
<div style="font-size: 15px;">
<strong>作业得分:</strong>
</div>
<div style="overflow: hidden">
<div style="margin-left: 15%; float: left">
<div style="padding-left: 45px; padding-bottom: 5px">得分比例</div>
<div>
<% 100.step(20,-20) do |star| %>
<div data-kls="Softapplication" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled" style="height: 20px; width: 115px; overflow: hidden; z-index: 1; position: relative;">
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
style="height: 20px; width: 115px; overflow: hidden; z-index: 1; position: relative;">
<div class="jRatingColor" style="width: <%=star%>%;"></div>
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
<div class="jStar" style="width: 115px; height: 20px; top: -40px; background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
</div>
</div>
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %>
@ -85,7 +93,11 @@
</div>
</div>
<div style="float: left; padding-left: 100px; padding-top:35px ">
<div style="padding-left: 25px;">最终得分</div>
<div style="text-align: center">最终得分</div>
<div style="padding-top: 1px; font-size: 15px; color: blue;text-align: center">
<%= @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
</div>
<div style="padding-top: 3px">
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
</div>
@ -102,6 +114,18 @@
</div>
<div class="underline-contests_one"></div>
<!--
<div style="height: auto; padding-bottom: 10px">
<div style="font-size: 15px">
<strong>作业综评:</strong>
</div>
<div style="text-align: center;">评分:
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
</div>
</div>
<div class="underline-contests_one"></div>
-->
<div style="height: 50px">
<div style="font-size: 15px"><strong>作业评论:</strong></div>
<div style="text-align: center;">评分:
@ -121,5 +145,4 @@
<%= render :partial => 'showjour', :locals => {:jour => @jours} %>
</div>
<div>
<%#= link_to '返回竞赛页面', show_softapplication_contest_path(@softapplication.contest) %>
</div>