封装获取一个作业参与人员方法

This commit is contained in:
sw 2014-06-20 09:40:12 +08:00
parent 600ec536b3
commit 5277eddb95
2 changed files with 14 additions and 7 deletions

View File

@ -236,4 +236,17 @@ module CoursesHelper
finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score
format("%.2f",finall_project_score)
end
#获取指定作业的参与人员
#返回结果:张三、李四、王五
def homework_user_of_homework homework,is_teacher
homework_users = ""
homework.users.each do |user|
homework_users = homework_users + (is_teacher ? user.realname : user.name)
if user != homework.users.last
homework_users = homework_users + ""
end
end
return homework_users
end
end

View File

@ -72,13 +72,7 @@
</td>
<td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<strong>合作成员:&nbsp;</strong>
<% homework_users = "" %>
<% homework.users.each do |user| %>
<% homework_users = homework_users + (is_teacher ? user.realname : user.name) %>
<% if user != homework.users.last %>
<% homework_users = homework_users + "、" %>
<% end %>
<% end %>
<% homework_users = homework_user_of_homework(homework,is_teacher) %>
<% if homework.users.count == 0 %>
<% else %>