diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ca897fc3d..b396b9c84 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -304,6 +304,9 @@ class UsersController < ApplicationController #用户作业列表 def user_homeworks + user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" + homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc") + @homework_commons = paginateHelper homework_commons,10 respond_to do |format| format.html {render :layout => 'new_base_user'} end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7c7f0c63f..709426d41 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2314,7 +2314,27 @@ module ApplicationHelper elsif homework.homework_type == 2 #编程作业不能修改作品 "作品已交".html_safe else - link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit' + link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit c_blue' + end + end + end + + #根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量 + def user_for_homework_common homework,is_teacher + if is_teacher #老师显示作品数量 + link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + else #学生显示提交作品、修改作品等按钮 + work = cur_user_works_for_homework homework + if work.nil? + link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' + else + if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 + link_to "修改作品", "", :class => 'c_blue', :title => "开启匿评后不可修改作品" + elsif homework.homework_type == 2 #编程作业不能修改作品 + link_to "作品已交", "",:class => 'c_blue',:title => "编程作业不可修改作品" + else + link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue' + end end end end diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 763c87c39..a6032a60b 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,101 +1,97 @@ -