diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 8eaf20716..17a20b0d5 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -514,7 +514,7 @@ class BidsController < ApplicationController
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
- WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1
+ WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
WHERE table1.m_score IS NULL")
@is_student_batch_homework = true
@cur_type = 4
@@ -1004,27 +1004,37 @@ class BidsController < ApplicationController
# 启动匿评
def start_anonymous_comment
@bid = Bid.find(params[:id])
- homeworks = @bid.homeworks
- users = homeworks.map { |h| h.user }
-
- @start_index = rand(homeworks.size)
- while users[0] == homeworks[@start_index].user
- @start_index = rand(homeworks.size)
- end
+ if(@bid.comment_status == 0)
+ homeworks = @bid.homeworks
+ if(homeworks && homeworks.count >= 4)
+ @bid.update_column('comment_status', 1)
+ users = homeworks.map { |h| h.user }
- 3.times do |i|
- homework_start_index = @start_index + i
- users.each_with_index do |user, index|
- actual_index = homework_start_index + index
- actual_index = (actual_index < homeworks.size ? actual_index : actual_index - homeworks.size)
- if user != homeworks[actual_index]
- @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: homeworks[actual_index].id)
- @homework_evaluation.save
+ @start_index = rand(homeworks.size)
+ while users[0] == homeworks[@start_index].user
+ @start_index = rand(homeworks.size)
end
+
+ 3.times do |i|
+ homework_start_index = @start_index + i
+ users.each_with_index do |user, index|
+ actual_index = homework_start_index + index
+ actual_index = (actual_index < homeworks.size ? actual_index : actual_index - homeworks.size)
+ if user != homeworks[actual_index]
+ @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: homeworks[actual_index].id)
+ @homework_evaluation.save
+ end
+ end
+ end
+ # 修改状态为 '启动匿评'
+ #@bid.update_column('comment_status', 1)
+ @statue = 1
+ else
+ @statue = 2
end
+ else
+ @statue = 3
end
- # 修改状态为 '启动匿评'
- @bid.update_column('comment_status', 1)
respond_to do |format|
format.js
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index 72450f2fe..12aa5860f 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -21,8 +21,14 @@ class HomeworkAttachController < ApplicationController
#获取未批作业列表
def get_not_batch_homework
- sort, direction = params[:sort], params[:direction]
- order_by = sort == 'socre'? "s_score #{direction}" : "created_at #{direction}"
+ sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
+ if sort == 't_socre'
+ order_by = "t_score #{direction}"
+ elsif sort == 's_socre'
+ order_by = "s_score #{direction}"
+ elsif sort == 'time'
+ order_by = "created_at #{direction}"
+ end
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
@@ -41,9 +47,14 @@ class HomeworkAttachController < ApplicationController
#获取已评作业列表
def get_batch_homeworks
- sort, direction = params[:sort], params[:direction]
- teacher_proportion = get_teacher_proportion @bid
- order_by = sort == 'socre'? "(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) #{direction}" : "created_at #{direction}"
+ sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
+ if sort == 't_socre'
+ order_by = "t_score #{direction}"
+ elsif sort == 's_socre'
+ order_by = "s_score #{direction}"
+ elsif sort == 'time'
+ order_by = "created_at #{direction}"
+ end
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers} and stars IS NOT NULL) AS t_score,
@@ -62,9 +73,14 @@ class HomeworkAttachController < ApplicationController
#获取所有作业列表
def get_homeworks
- sort, direction = params[:sort], params[:direction]
- teacher_proportion = get_teacher_proportion @bid
- order_by = sort == 'socre'? "(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) #{direction}" : "created_at #{direction}"
+ sort, direction = params[:sort] || "s_socre", params[:direction] || "desc"
+ if sort == 't_socre'
+ order_by = "t_score #{direction}"
+ elsif sort == 's_socre'
+ order_by = "s_score #{direction}"
+ elsif sort == 'time'
+ order_by = "created_at #{direction}"
+ end
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id in #{teachers}) AS t_score,
@@ -90,7 +106,7 @@ class HomeworkAttachController < ApplicationController
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = 3123) AS m_score
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
- WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1
+ WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1
WHERE table1.m_score IS NULL")
@cur_page = params[:page] || 1
@cur_type = 4
@@ -496,6 +512,26 @@ class HomeworkAttachController < ApplicationController
@totle_score = score_for_homework @homework
@teaher_score = teacher_score_for_homework @homework
+ stars_reates = @homework. rates(:quality)
+ is_student = is_cur_course_student @homework.bid.courses.first
+ is_teacher = is_course_teacher User.current,@homework.bid.courses.first
+ @has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0
+ @is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评
+ if !User.current.member_of_course?(@homework.bid.courses.first)
+ @is_comprehensive_evaluation = 3 #留言
+ elsif is_student && @is_anonymous_comments && !@has_evaluation#是学生且开启了匿评且未进行评分
+ @is_comprehensive_evaluation = 2 #匿评
+ elsif is_student && @is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分
+ @is_comprehensive_evaluation = 3 #留言
+ elsif is_student && !@is_anonymous_comments #是学生未开启匿评
+ @is_comprehensive_evaluation = 3 #留言
+ elsif is_teacher
+ @is_comprehensive_evaluation = 1 #教师评论
+ else
+ @is_comprehensive_evaluation = 3
+ end
+
+
respond_to do |format|
format.js
end
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 8797474ec..b4bc52eab 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -56,6 +56,7 @@ class WordsController < ApplicationController
reply_user_id = params[:reference_user_id]
reply_id = params[:reference_message_id] # 暂时不实现
content = params[:user_notes]
+ @show_name = params[:show_name] == "true"
options = {:user_id => author_id,
:status => true,
:m_parent_id => parent_id,
diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb
index d8d418da5..750a71f6a 100644
--- a/app/helpers/homework_attach_helper.rb
+++ b/app/helpers/homework_attach_helper.rb
@@ -96,13 +96,22 @@ module HomeworkAttachHelper
if array.nil? || array.count == 0
return "()"
end
- array.each do |member|
- if member == array.last
- ary += member.id.to_s + ")"
+ array.length.times do |i|
+ if i == array.length - 1
+ ary += array[i].id.to_s + ")"
else
- ary += member.id.to_s + ","
+ if !(array[i].nil? || array[i].id.nil? || array[i].id.to_s == "")
+ ary += array[i].id.to_s + ","
+ end
end
end
+ #array.each do |member|
+ # if member == array.last
+ # ary += member.id.to_s + ")"
+ # else
+ # ary += member.id.to_s + ","
+ # end
+ #end
ary
end
end
\ No newline at end of file
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 166dfd0ec..298331c69 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -99,7 +99,7 @@ module WatchersHelper
# 主讲教师不允许退出课程
return '' if user.id == course.tea_id || course.is_public == 0
joined = user.member_of_course?(course)
- text = joined ? l(:label_exit_course) : l(:label_join_course)
+ text = joined ? l(:label_exit_course) : l(:label_new_join)
url_t = join_path(:object_id => course.id)
url_f = try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post'
diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb
index 0c38335bf..4ed9a9015 100644
--- a/app/views/bids/_bid_homework_show.html.erb
+++ b/app/views/bids/_bid_homework_show.html.erb
@@ -37,9 +37,9 @@
<% case bid.comment_status %>
<% when 0 %>
- <%= link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true %>
+ <%= link_to '启动匿评', start_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, :confirm => "开启匿评后学生将不能对作业进行提交、修改、删除等操作\n是否确定开启匿评?" %>
<% when 1 %>
- <%= link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true %>
+ <%= link_to '关闭匿评', stop_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true, :confirm => "关闭匿评后学生将不能对作业进行评分\n是否确定关闭匿评?" %>
<% when 2 %>
匿评结束
<% end %>
diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb
index 8273c4b04..633037ba9 100644
--- a/app/views/bids/_history.html.erb
+++ b/app/views/bids/_history.html.erb
@@ -62,12 +62,12 @@
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<% if reply_allow %>
+
-<%= f.select :proportion, proportion_option %>
diff --git a/app/views/bids/start_anonymous_comment.js.erb b/app/views/bids/start_anonymous_comment.js.erb index 84cd65a7d..a6e24285b 100644 --- a/app/views/bids/start_anonymous_comment.js.erb +++ b/app/views/bids/start_anonymous_comment.js.erb @@ -1,2 +1,8 @@ -alert('启动成功') -$("#<%= @bid.id %>_start_anonymous_comment").html('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true %>') +<% if @statue == 1%> + alert('启动成功'); + $("#<%= @bid.id %>_start_anonymous_comment").html('<%= link_to "关闭匿评", stop_anonymous_comment_bid_path(@bid), remote: true %>'); +<% elsif @statue == 2 %> + alert('启动失败\n作业总数大于4份时才能启动匿评'); +<% elsif @statue == 3%> + alert("已开启匿评,请务重复开启"); +<% end %> diff --git a/app/views/homework_attach/_history.erb b/app/views/homework_attach/_history.erb index 3376d696f..53de7d33f 100644 --- a/app/views/homework_attach/_history.erb +++ b/app/views/homework_attach/_history.erb @@ -49,12 +49,12 @@ <% ids = 'project_respond_form_'+ journal.id.to_s%> <% if reply_allow %>
- <%= f.text_field :name, :required => true, :name => "homework_name", :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称"%> + <%= f.text_field :name, :required => true, :name => "homework_name", :class => "w430 bo", :maxlength => 254, :placeholder => "作品名称", :onblur => "regexName();"%> +