diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index b8c6a4a0a..b5d55df28 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -58,10 +58,9 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current - @is_in_course = params[:is_in_course] + @hw_status = params[:hw_status].to_i @is_manage = params[:is_manage] - @course_activity = params[:course_activity].to_i - if @is_in_course.to_i == 1 || @course_activity == 1 + if @hw_status != 1 @left_nav_type = 3 respond_to do |format| format.html{render :layout => 'base_courses'} @@ -160,18 +159,17 @@ class HomeworkCommonController < ApplicationController create_works_list @homework end + @hw_status = params[:hw_status].to_i if params[:is_manage] == "1" redirect_to manage_or_receive_homeworks_user_path(User.current.id) elsif params[:is_manage] == "2" redirect_to my_homeworks_user_path(User.current.id) - elsif params[:is_in_course] == "1" - redirect_to homework_common_index_path(:course => @course.id) - elsif params[:is_in_course] == "0" - redirect_to user_homeworks_user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + elsif @hw_status == 1 redirect_to user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + elsif @hw_status == 2 redirect_to course_path(@course.id) + else + redirect_to homework_common_index_path(:course => @course.id) end end end @@ -181,14 +179,13 @@ class HomeworkCommonController < ApplicationController if @homework.destroy respond_to do |format| format.html { - if params[:is_in_course] == "1" - redirect_to homework_common_index_path(:course => @course.id) - elsif params[:is_in_course] == "0" - redirect_to user_homeworks_user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" - redirect_to user_path(User.current.id) - elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" - redirect_to course_path(@course.id) + @hw_status = params[:hw_status].to_i + if @hw_status == 1 + redirect_to user_path(User.current.id) + elsif @hw_status == 2 + redirect_to course_path(@course.id) + else + redirect_to homework_common_index_path(:course => @course.id) end } end @@ -246,8 +243,7 @@ class HomeworkCommonController < ApplicationController @statue = 3 end @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end #关闭匿评 @@ -265,8 +261,7 @@ class HomeworkCommonController < ApplicationController send_message_anonymous_comment(@homework, m_status = 3) Mailer.send_mail_anonymous_comment_close(@homework).deliver @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -294,8 +289,7 @@ class HomeworkCommonController < ApplicationController end @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -307,8 +301,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] if params[:is_in_course] - @course_activity = params[:course_activity] if params[:course_Activity] + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -321,8 +314,7 @@ class HomeworkCommonController < ApplicationController @homework.update_column('is_open', 0) end @user_activity_id = params[:user_activity_id] - @is_in_course = params[:is_in_course] if params[:is_in_course] - @course_activity = params[:course_activity] if params[:course_Activity] + @hw_status = params[:hw_status].to_i end def alert_open_student_works @@ -331,8 +323,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] if params[:is_in_course] - @course_activity = params[:course_activity] if params[:course_Activity] + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -363,8 +354,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end #设置匿评参数 @@ -381,8 +371,7 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.evaluation_num = params[:evaluation_num] @homework_detail_manual.save @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end end @@ -393,8 +382,7 @@ class HomeworkCommonController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course] - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end private diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index f6a97e66c..b259737a1 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1012,8 +1012,7 @@ class StudentWorkController < ApplicationController redirect_to student_work_index_url(:homework => @homework.id) else @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -1035,8 +1034,7 @@ class StudentWorkController < ApplicationController student_work.save end @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i end def revise_attachment @@ -1058,8 +1056,7 @@ class StudentWorkController < ApplicationController def new_student_work_project @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -1078,8 +1075,7 @@ class StudentWorkController < ApplicationController @project.is_leader = 1 if @project.save @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end @@ -1129,8 +1125,7 @@ class StudentWorkController < ApplicationController relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first if relate_pro.destroy @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i respond_to do |format| format.js end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bdbaf1738..87dc127a0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -115,8 +115,7 @@ class UsersController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i when 'JournalsForMessage' @reply = JournalsForMessage.find params[:reply_id] @user_activity_id = params[:user_activity_id] @@ -1123,11 +1122,8 @@ class UsersController < ApplicationController quotes_homework = HomeworkCommon.find params[:quotes].to_i quotes_homework.update_column(:quotes, quotes_homework.quotes+1) end - if params[:is_in_course] == "1" - redirect_to homework_common_index_path(:course => homework.course_id) - else - redirect_to user_homeworks_user_path(User.current.id) - end + + redirect_to homework_common_index_path(:course => homework.course_id) end end else @@ -3573,8 +3569,7 @@ class UsersController < ApplicationController obj = HomeworkCommon.where('id = ?', params[:id].to_i).first @type = 'HomeworkCommon' @journals = obj.journals_for_messages.reorder("created_on desc") - @is_in_course = params[:is_in_course].to_i if params[:is_in_course] - @course_activity = params[:course_activity].to_i if params[:course_activity] + @hw_status = params[:hw_status].to_i if params[:hw_status] @is_teacher = User.current.allowed_to?(:as_teacher,obj.course) @user_activity_id = params[:user_activity_id].to_i if params[:user_activity_id] end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 499272706..f1bfc7a31 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -110,8 +110,7 @@ class WordsController < ApplicationController else @user_activity_id = -1 end - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i elsif @journal_destroyed.jour_type == 'Syllabus' @syllabus = Syllabus.find @journal_destroyed.jour_id @count = @syllabus.journals_for_messages.count @@ -308,9 +307,8 @@ class WordsController < ApplicationController update_org_activity(@homework_common.class,@homework_common.id) respond_to do |format| format.js{ - @user_activity_id = params[:user_activity_id] - @is_in_course = params[:is_in_course] - @course_activity = params[:course_activity] + @user_activity_id = params[:user_activity_id].to_i + @hw_status = params[:hw_status].to_i @homework_common_id = params[:homework_common_id] } end @@ -344,8 +342,7 @@ class WordsController < ApplicationController respond_to do |format| format.js{ @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i + @hw_status = params[:hw_status].to_i } end else diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d3b28fb20..d9a694eaa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2689,15 +2689,15 @@ module ApplicationHelper end #获取匿评相关连接代码 - def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1) + def homework_anonymous_comment (homework, hw_status, user_activity_id = -1) if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评" elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2 case homework.homework_detail_manual.comment_status when 1 - link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?is_in_course=" + is_in_course.to_s + "&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' + link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' when 2 - link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?is_in_course=" + is_in_course.to_s + "&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' + link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' when 3 # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" end diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index 2d3c72c20..d79a7a432 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -57,12 +57,12 @@ module HomeworkCommonHelper end #根据传入作业确定跳转到开启匿评还是关闭匿评功能 - def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,is_in_course,course_activity + def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,hw_status link = "" if homework_detail_manual.comment_status == 1 - link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity + link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:hw_status=>hw_status elsif homework_detail_manual.comment_status == 2 - link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity + link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:hw_status=>hw_status end link end diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index c71e5ade4..a7f99f2b0 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -60,7 +60,7 @@ <% act = activity.course_act %> <% case activity.course_act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id, :course_activity => 1} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id, :hw_status => 2} %> <% when 'News' %> <%= render :partial => 'users/course_news', :locals => {:activity => act, :user_activity_id => activity.id} %> <% when 'Message' %> diff --git a/app/views/courses/_user_homework_search_list.html.erb b/app/views/courses/_user_homework_search_list.html.erb index 750e7537c..ecc0d1d7e 100644 --- a/app/views/courses/_user_homework_search_list.html.erb +++ b/app/views/courses/_user_homework_search_list.html.erb @@ -26,7 +26,7 @@ } } - <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => homework_common,:user_activity_id => homework_common.id, :hw_status => 3} %> <% end%> <% if homework_commons.count == 10%> <%= link_to "点击展开更多",homework_search_course_path(course_id,:page => page,:search=>search),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> diff --git a/app/views/courses/homework_search.js.erb b/app/views/courses/homework_search.js.erb index 3c644ad9e..5e2f81f01 100644 --- a/app/views/courses/homework_search.js.erb +++ b/app/views/courses/homework_search.js.erb @@ -1,5 +1,5 @@ <% if @page == 0 %> - $("#user_homework_list").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id,:search=>@search} )%>"); + $("#user_homework_list").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :course_id => @course.id,:search=>@search} )%>"); <% else %> - $("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id,:search=>@search} )%>"); + $("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'courses/user_homework_search_list',:locals => {:homework_commons => @homeworks, :page => @page, :course_id => @course.id,:search=>@search} )%>"); <% end %> \ No newline at end of file diff --git a/app/views/homework_common/_alert_anonyoms.html.erb b/app/views/homework_common/_alert_anonyoms.html.erb index 79840cb35..8834d6746 100644 --- a/app/views/homework_common/_alert_anonyoms.html.erb +++ b/app/views/homework_common/_alert_anonyoms.html.erb @@ -32,7 +32,7 @@
<% end %>