1.作业列表增加项目得分显示

2.封装获取指定项目得分的方法,并保留2位有效数字
This commit is contained in:
sw 2014-06-19 20:14:48 +08:00
parent 36fecfc635
commit 09eae9e253
3 changed files with 44 additions and 16 deletions

View File

@ -210,4 +210,29 @@ module CoursesHelper
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars)
end
def project_score project
issue_count = project.issues.count
issue_journal_count = project.issue_changes.count
issue_score = issue_count * 0.2
issue_journal_score = issue_journal_count * 0.1
finall_issue_score = issue_score + issue_journal_score
new_count = project.news.count
new_score = new_count * 0.1
finall_new_score = new_score
document_count = project.documents.count
file_score = document_count * 0.1
finall_file_score = file_score
changeset_count = project.changesets.count
code_submit_score = changeset_count * 0.3
finall_code_submit_score = code_submit_score
board_message_count = 0
project.boards.each do |board|
board_message_count += board.messages_count
end
topic_score = board_message_count * 0.1
#finall_topic_score = topic_score
finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score
format("%.2f",finall_project_score)
end
end

View File

@ -28,7 +28,7 @@
@bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) && cur_user_homework_for_bid(@bid).count == 0 %>
<div class='icon icon-add'>
<%#= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %>
<%= link_to l(:label_course_new_homework),new_homework_attach_path %>
<%= link_to l(:label_course_new_homework),new_homework_attach_path %><strong style="color: #a9a9a9">&nbsp;&nbsp;(每一个作业都可以是一个精美的作品)</strong>
</div>
<% end %>

View File

@ -19,7 +19,9 @@
<%= 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>
</div>
</td>
</tr>
</table>
</div>
@ -92,7 +94,7 @@
<tr>
<td>
<strong>开发项目:</strong>&nbsp;
<strong>开发项目</strong>:&nbsp;
<% if homework.project != nil %>
<%= link_to homework.project.name,project_path(homework.project.id)%>
<% else %>
@ -100,14 +102,15 @@
<% end %>
</td>
<td>
<strong>项目得分:</strong>&nbsp;
<strong>项目得分:&nbsp;
<span style="color: #EC6300;">
<% if homework.project != nil %>
0
<%= project_score homework.project %>
<% else %>
0
0.00
<% end %>
</span>
</strong>
</td>
</tr>