<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %>
<%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%>
<%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> TO <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue"%>
<%=get_hw_status(homework_common).html_safe %>
<% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1%> 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! <% elsif homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 0%> 系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合! <% end %>
<% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(homework_common.course) %> <% projects = cur_user_projects_for_homework homework_common %> <% works = cur_user_works_for_homework homework_common %> <% if works.nil? && projects.nil? %>
<%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1),remote: true,:class=> 'c_blue', :title=> '请各组长关联作业项目' %> <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %>
<% elsif works.nil? %>
<%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %>
<% end %> <% end %>
<%= user_for_homework_common homework_common,is_teacher %>
<% work = cur_user_works_for_homework homework_common %> <% if !is_teacher && !work.nil? && homework_common.end_time < Date.today && work.user == User.current %>
<%=link_to "追加附件", student_work_index_url_in_org(homework_common.id, 2, 1), :class => 'c_blue', :title => "可追加作品修订附件" %>
<% end %> <% if homework_common.homework_type == 2 && is_teacher%>
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
<% if homework_common.homework_detail_manual.comment_status != 0 %>
<%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: homework_common.id, course_id: homework_common.course_id), class: 'c_blue test-program-btn',:remote => true %>
<% end %> <% end %> <% if homework_common.homework_type == 2%>
语言: <%= homework_common.language_name%>
<% end %> <% if homework_common.homework_type == 3 && homework_common.homework_detail_group%>
分组人数:<%=homework_common.homework_detail_group.min_num %>-<%=homework_common.homework_detail_group.max_num %> 人
<% end %> <% if homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status < 2 && !homework_common.publish_time.nil? %>
提交截止时间:<%= homework_common.end_time.to_s %> 23:59
<% elsif homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status >= 2 && !homework_common.publish_time.nil? && homework_common.anonymous_comment == 0 %>
匿评截止时间:<%= homework_common.homework_detail_manual.evaluation_end.to_s %> 23:59
<% end %> <% if homework_common.homework_detail_manual.comment_status == 0 && !homework_common.publish_time.nil? %>
<%= l(:label_publish_time)%>:<%= homework_common.publish_time%> 00:00
<% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>homework_common.id, :content=>homework_common.description} %>
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework_common} %>
迟交扣分:<%= homework_common.late_penalty%>分
<% if homework_common.anonymous_comment == 0 && !homework_common.publish_time.nil?%>
匿评开启时间:<%= homework_common.homework_detail_manual.evaluation_start%> 00:00
<% end %>
<% if homework_common.anonymous_comment == 0 %>
缺评扣分:<%= homework_common.homework_detail_manual.absence_penalty%>分/作品
<% end %> <% if homework_common.anonymous_comment == 0 && !homework_common.publish_time.nil?%>
匿评关闭时间:<%= homework_common.homework_detail_manual.evaluation_end%> 23:59
<% end %>
<% if homework_common.student_works.has_committed.count != 0 %> <% sw = homework_common.student_works.has_committed.reorder("commit_time desc").first %>
# <%=time_from_now sw.commit_time %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
<% end %>
<% if homework_common.student_works.count != 0 %> <% sw_id = "("+homework_common.student_works.map{|sw| sw.id}.join(",")+")" %> <%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> <% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %>

# <%=time_from_now last_score.created_at %> <%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行:

<% end %>
<% if homework_common.homework_type != 2 %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> <% student_works = homework_common.student_works.has_committed.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %> <% else %> <% student_works = homework_common.student_works.has_committed.select("student_works.*,student_works.work_score as score").order("score desc") %> <% end %> <% student_works.includes(:user).each_with_index do |sw, i| %> <% if i == 4 %> <% break %> <% end %> <% end %> <% if student_works.count > 5%> <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> <% end %>
<% end %> <% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 %> <% projects = homework_common.student_work_projects.where("is_leader = 1 and project_id != -1") %> <% unless projects.empty? %> <% sort_projects = project_sort_update projects %>
<% first_pro = Project.find sort_projects.first.project_id %> <% commit_time = first_pro.project_score.commit_time %> <% one_forge_time=ForgeActivity.where("project_id=?",first_pro.id).last.updated_at if ForgeActivity.where("project_id=?",first_pro.id).last %> # <%=time_from_now !commit_time.nil? && format_time(commit_time) > format_time(one_forge_time) ? commit_time : one_forge_time %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% sort_projects.each_with_index do |pro, i| %> <% project = Project.find pro.project_id %>
<% com_time = project.project_score.commit_time %> <% forge_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %> <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius relatePImage"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s+"_"+homework_common.id.to_s,:alt =>"项目头像", :target => '_blank' %> <% update_time = time_from_now !com_time.nil? && format_time(com_time) > format_time(forge_time) ? com_time : forge_time %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius relatePImage",:id=>"project_img_"+project.id.to_s+"_"+homework_common.id.to_s,:alt =>"项目头像",:title => "私有项目不可访问") %> <% end %>
项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
更新时间:<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(forge_time) ? com_time : forge_time %>
<% if i == 9 && projects.count > 10 %> 更多>> <% end %> <% if i > 9 && i == (projects.count - 1) %> 收回<< <% end %> <% end %>
<% end %> <% end %>
<% if is_teacher%> <% comment_status = homework_common.homework_detail_manual.comment_status%>
    • <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1), :class => "postOptionLink"%>
    • <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
    • <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true) %>
    • <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%>
    • <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true)%>
    • <% end %> <% if homework_common.anonymous_comment == 0%>
    • <%= homework_anonymous_comment(homework_common, is_in_course) %>
    • <% end %> <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
    • <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
    • <% end %> <% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %>
    • <%= link_to("公开作品", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
    • <% elsif homework_common.is_open == 1 %>
    • <%= link_to("取消公开", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
    • <% end %>
<% end%>
<% count=homework_common.journals_for_messages.count %>
<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => homework_common, :user_activity_id => homework_common.id, :is_in_course => is_in_course,:course_activity=>-1} %> <% comments = homework_common.journals_for_messages.reorder("created_on desc").limit(3) %> <% if count > 0 %>
<%=render :partial => 'users/news_replies', :locals => {:comments => comments, :type => 'HomeworkCommon', :is_in_course => is_in_course,:course_activity=>-1, :is_teacher => is_teacher, :user_activity_id => -1, :activity_id => homework_common.id} %>
<% end %>
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
<% if User.current.logged? %>
<%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => homework_common.id},:method => "post", :remote => true) do |f|%> <%= hidden_field_tag 'homework_common_id',params[:homework_common_id],:value =>homework_common.id %> <%= hidden_field_tag 'is_in_course',params[:is_in_course],:value =>is_in_course %>

<% end%>
<% else %> <%= render :partial => "users/show_unlogged" %> <% end %>