diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index ff6463036..6088e2294 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -22,23 +22,10 @@ class HomeworkAttachController < ApplicationController #获取未批作业列表 def get_not_batch_homework 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, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score - FROM homework_attaches WHERE bid_id = #{@bid.id} - ORDER BY #{order_by}) AS table1 - WHERE table1.t_score IS NULL") + get_not_batch_homework_list sort,direction,teachers, @bid.id @cur_page = params[:page] || 1 @cur_type = 1 - @homework_list = paginateHelper all_homework_list,10 @direction = direction == 'asc'? 'desc' : 'asc' respond_to do |format| format.js @@ -57,8 +44,8 @@ class HomeworkAttachController < ApplicationController 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, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score + (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, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1 WHERE table1.t_score IS NOT NULL") @@ -83,8 +70,8 @@ class HomeworkAttachController < ApplicationController 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, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in #{teachers}) AS s_score + (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, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in (#{teachers})) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}") @cur_page = params[:page] || 1 @@ -101,8 +88,8 @@ class HomeworkAttachController < ApplicationController @is_student_batch_homework = true 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, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score, + (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, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score, (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score FROM homework_attaches INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id @@ -120,15 +107,15 @@ class HomeworkAttachController < ApplicationController @is_my_homework = true teachers = find_course_teachers @course all_homework_list = HomeworkAttach.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, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score + (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, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score FROM homework_attaches WHERE homework_attaches.bid_id = #{@bid.id} AND homework_attaches.user_id = #{User.current.id}") #如果我没有创建过作业,就检索我是否参与了某个作业 if all_homework_list.empty? all_homework_list = HomeworkAttach.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, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score + (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, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score FROM homework_attaches INNER JOIN homework_users ON homework_users.homework_attach_id = homework_attaches.id WHERE homework_attaches.bid_id = #{@bid.id} AND homework_users.user_id = #{User.current.id}") @@ -372,11 +359,11 @@ class HomeworkAttachController < ApplicationController def show if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) # 打分统计 - stars_reates = @homework. rates(:quality) + #stars_reates = @homework. rates(:quality) #是否已经进行过评价 temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{@homework.id} AND rater_id = #{User.current.id}").first @m_score = temp.nil? ? 0:temp.stars - @has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0 + @has_evaluation = @homework.has_rated?( User.current,:quality) #@jours留言 is null条件用以兼容历史数据 @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @cur_page = params[:cur_page] || 1 @@ -385,30 +372,35 @@ class HomeworkAttachController < ApplicationController teachers = searchTeacherAndAssistant @course @comprehensive_evaluation = [] + #JourForMessage的is_comprehensive_evaluation字段: + #1:老师评价 + #2:学生评价 + #3 || null:学生留言 teachers.each do|teacher| temp = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first @comprehensive_evaluation << temp if temp end - annymous_users = @homework.homework_evaluations.map(&:user) - unless annymous_users.nil? || annymous_users.count == 0 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + unless annymous_users.nil? || annymous_users == "" + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end - @totle_score = score_for_homework @homework - @teaher_score = teacher_score_for_homework @homework + #@totle_score = score_for_homework @homework + #@teaher_score = teacher_score_for_homework @homework - is_student = is_cur_course_student @homework.bid.courses.first - is_teacher = is_course_teacher User.current,@homework.bid.courses.first + #is_student = is_cur_course_student @homework.bid.courses.first + @is_teacher = is_course_teacher User.current,@homework.bid.courses.first @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 = 2 #匿评 - elsif is_student && !@is_anonymous_comments #是学生未开启匿评 - @is_comprehensive_evaluation = 3 #留言 - elsif is_teacher - @is_comprehensive_evaluation = 1 #教师评论 + #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 + if User.current.member_of_course?(@homework.bid.courses.first) + if @is_teacher + @is_comprehensive_evaluation = 1 #教师评论 + else + if @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + @is_comprehensive_evaluation = 2 #匿评 + else #是学生未开启匿评或者已经进行评分 + @is_comprehensive_evaluation = 3 #留言 + end + end else @is_comprehensive_evaluation = 3 end @@ -433,9 +425,9 @@ class HomeworkAttachController < ApplicationController @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @jour = paginateHelper @jours,5 elsif @is_comprehensive_evaluation == 2 - annymous_users = @homework.homework_evaluations.map(&:user) - unless annymous_users.nil? || annymous_users.count == 0 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + unless annymous_users.nil? || annymous_users.count == "" + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end elsif @is_comprehensive_evaluation == 1 teachers = searchTeacherAndAssistant @course @@ -445,9 +437,6 @@ class HomeworkAttachController < ApplicationController @comprehensive_evaluation << temp if temp end end - - - respond_to do |format| format.js end @@ -456,17 +445,27 @@ class HomeworkAttachController < ApplicationController #添加留言 def addjours @homework = HomeworkAttach.find(params[:jour_id]) - @add_jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,params[:is_comprehensive_evaluation] - if @add_jour.is_comprehensive_evaluation == 3 + #保存评分 + @homework.rate(params[:stars_value],User.current.id,:quality) if params[:stars_value] && params[:stars_value] != "0" + #保存评论 + @cur_is_comprehensive_evaluation = params[:is_comprehensive_evaluation] + if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言 + @homework.addjours User.current.id, params[:new_form][:user_message],0,@cur_is_comprehensive_evaluation + end + + @cur_page = params[:cur_page] || 1 + @cur_type = params[:cur_type] || 5 + teachers = searchTeacherAndAssistant @homework.bid.courses.first + if @cur_is_comprehensive_evaluation == "3" @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") @jour = paginateHelper @jours,5 - elsif @add_jour.is_comprehensive_evaluation == 2 - annymous_users = @homework.homework_evaluations.map(&:user) - unless annymous_users.nil? || annymous_users.count == 0 - @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in #{convert_array(annymous_users)}").order("created_on DESC") + elsif @cur_is_comprehensive_evaluation == "2" + annymous_users = @homework.homework_evaluations.map { |homework_evaluation| homework_evaluation.user.id}.join(',') + unless annymous_users.nil? || annymous_users == "" + @anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2 and user_id in (#{annymous_users})").order("created_on DESC") end - elsif @add_jour.is_comprehensive_evaluation == 1 - teachers = searchTeacherAndAssistant @homework.bid.courses.first + @m_score = params[:stars_value].to_i + elsif @cur_is_comprehensive_evaluation == "1" @comprehensive_evaluation = [] teachers.each do|teacher| temp = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id = #{teacher.user_id}").order("created_on DESC").first @@ -474,35 +473,49 @@ class HomeworkAttachController < ApplicationController end end - - #@limit = 10 - #@feedback_count = @jours.count - #@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - #@offset ||= @feedback_pages.offset - #@jour = @jours[@offset, @limit] - #@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") - - @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 #教师评论 + #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 + if User.current.member_of_course?(@homework.bid.courses.first) + if is_teacher + @is_comprehensive_evaluation = 1 #教师评论 + else + if @is_anonymous_comments && !@has_evaluation #是学生且开启了匿评且未进行评分 + @is_comprehensive_evaluation = 2 #匿评 + else #是学生未开启匿评或者已经进行评分 + @is_comprehensive_evaluation = 3 #留言 + end + end else @is_comprehensive_evaluation = 3 end + #teachers = find_course_teachers @homework.bid.courses.first + teachers_str = teachers.map{|teacher| teacher.user_id}.join(",") + if @cur_type == "1" #如果当前是老师未批列表,需要刷新整个作业列表界面 + @bid = @homework.bid + get_not_batch_homework_list "s_socre","desc",teachers_str,@homework.bid_id + elsif @cur_type == "2" #老师已批列表 + @result_homework = 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_str}) and stars IS NOT NULL) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers_str})) AS s_score + FROM homework_attaches WHERE id = #{@homework.id}").first + elsif @cur_type == "3" #全部作业列表 + @result_homework = 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_str})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id not in (#{teachers_str})) AS s_score + FROM homework_attaches WHERE id = #{@homework.id}").first + elsif @cur_type == "4" #匿评作业列表 + @is_student_batch_homework = true + @result_homework = 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_str})) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers_str})) AS s_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score + FROM homework_attaches + WHERE homework_attaches.id = #{@homework.id}").first + else #其他的不用管 + + end respond_to do |format| format.js @@ -578,16 +591,7 @@ class HomeworkAttachController < ApplicationController #获取课程的老师列表 def find_course_teachers course - teachers = "(" - teacher_members = searchTeacherAndAssistant(course) - teacher_members.each do |member| - if member == teacher_members.last - teachers += member.user_id.to_s + ")" - else - teachers += member.user_id.to_s + "," - end - end - teachers + searchTeacherAndAssistant(course).map{|teacher| teacher.user_id}.join(",") end #获取作业教师评分所占比例 @@ -599,5 +603,22 @@ class HomeworkAttachController < ApplicationController end teacher_proportion end + + def get_not_batch_homework_list sort,direction,teachers,bid_id + 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 + 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, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score + FROM homework_attaches WHERE bid_id = #{bid_id} + ORDER BY #{order_by}) AS table1 + WHERE table1.t_score IS NULL") + @homework_list = paginateHelper all_homework_list,10 + end end diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index a68d12517..b1705c826 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -26,19 +26,19 @@ class StoresController < ApplicationController resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). reorder("created_on DESC") - # result = resultSet.to_a.dup + result = resultSet.to_a.dup - # resultSet.to_a.map { |res| - # if(res.container.nil? || - # (res.container.class.to_s=="Project" && res.container.is_public == false) || - # (res.container.has_attribute?(:project) && res.container.project.is_public == false) || - # (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) || - # false - # ) - # result.delete(res) - # end - # } - # result + resultSet.to_a.map { |res| + if(res.container.nil? || + (res.container.class.to_s=="Project" && res.container.is_public == false) || + (res.container.has_attribute?(:project) && res.container.project.is_public == false) || + (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) || + false + ) || (res.container.is_a?(Course) && res.container.is_public == 0) + result.delete(res) + end + } + result end LIMIT = 12 unless const_defined?(:LIMIT) diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 63332e564..1ab1cb928 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -87,8 +87,8 @@ module HomeworkAttachHelper #获取用户对作业的评分 def get_homework_score user, homework - seems_rateable_rate = HomeworkAttach.find_by_sql("SELECT * FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id} AND rater_id = #{user.id}") - seems_rateable_rate.nil? || seems_rateable_rate.count == 0 ? 0:seems_rateable_rate[0].stars + temp = HomeworkAttach.find_by_sql("SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id} AND rater_id = #{user.id}").first + @m_score = temp.nil? ? 0:temp.stars.to_i end def convert_array array diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 630d7552c..e7b58fefc 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -68,7 +68,7 @@ <% end %> <% end %> - <% if (User.current.admin?||User.current.id==bid.author_id) %> + <% if (User.current.admin?||User.current.allowed_to?(:as_teacher,@course)) %> <% if bid.open_anonymous_evaluation == 1 && bid.homeworks.count >= 2%> <% case bid.comment_status %> diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 7cde4f31d..db1f555d3 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -58,53 +58,53 @@ { hideModal($("#popbox")); // 评了分的则刷新列表 - switch (cur_type) - { - case 1: - $.ajax({ - type: "GET", - url: "<%= get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 2: - $.ajax({ - type: "GET", - url: "<%= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 3: - $.ajax({ - type: "GET", - url: "<%= get_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 4: - $.ajax({ - type: "GET", - url: "<%= get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, - data: 'text', - success: function (data) { - - } - }); - break; - case 5: - break; - default : - break; - } +// switch (cur_type) +// { +// case 1: +// $.ajax({ +// type: "GET", +// url: "<%#= get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 2: +// $.ajax({ +// type: "GET", +// url: "<%#= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 3: +// $.ajax({ +// type: "GET", +// url: "<%#= get_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 4: +// $.ajax({ +// type: "GET", +// url: "<%#= get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, +// data: 'text', +// success: function (data) { +// +// } +// }); +// break; +// case 5: +// break; +// default : +// break; +// } } diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 5b2889b57..79a7711c7 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -50,8 +50,10 @@ } } - function submit1(button) + function submit1(is_teacher) { + if($("#stars_value").val() == "0"){alert("您还没有打分");return;} + if(!is_teacher&&$("#new_form_user_message").val() == ""){alert("您还没有填写评语");return;} $('#jours_submit').parent().submit(); } @@ -61,7 +63,21 @@ :action => 'addjours', :jour_id => homework_attach.id, :is_comprehensive_evaluation => is_comprehensive_evaluation, + :cur_page => cur_page, + :cur_type => cur_type, :sta => sta}) do |f|%> + +
+ <% if @is_comprehensive_evaluation == 3 || User.current == homework_attach.user%> + + <% else @is_comprehensive_evaluation == 2 %> + + <%= l(:label_work_rating) %>: + <%= render :partial => 'show_star',:locals => {start_score:m_score} %> + <% end %> +
+
+
<%= render :partial => 'words/pre_show', :locals => {:content => @content} %> @@ -74,8 +90,9 @@ %> <%= f.text_field :reference_user_id, :style=>"display:none"%>
- <%= l(:label_submit_comments) %> - + + <%= l(:label_submit_comments) %> +
<% else %>
diff --git a/app/views/homework_attach/_histoey_new.html.erb b/app/views/homework_attach/_histoey_new.html.erb index 183eb067d..5912d04cb 100644 --- a/app/views/homework_attach/_histoey_new.html.erb +++ b/app/views/homework_attach/_histoey_new.html.erb @@ -14,7 +14,6 @@
<%= render :partial => 'homework_attach/jour',:locals => {:jours => @jour,:show_score => false,:show_name => true,:is_jour => true} %>
-
<%= render :partial => 'homework_attach/jour',:locals => {:jours => @comprehensive_evaluation,:show_score => true,:show_name => true,:is_jour => false} %>
diff --git a/app/views/homework_attach/_homework.html.erb b/app/views/homework_attach/_homework.html.erb index e14475f9f..802a021a4 100644 --- a/app/views/homework_attach/_homework.html.erb +++ b/app/views/homework_attach/_homework.html.erb @@ -1,3 +1,4 @@ +<% bid = homework.bid%>
  • <% if is_student_batch_homework %> @@ -46,7 +47,7 @@
  • <%= link_to l(:label_work_rating),homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type),:remote => true %> - <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> + <% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>   迟交! <% end %>
  • @@ -54,7 +55,7 @@ <% if is_my_homework %> - <% if @bid.comment_status == 0 || @bid.open_anonymous_evaluation == 0 %> + <% if bid.comment_status == 0 || bid.open_anonymous_evaluation == 0 %>
  • <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> <% if homework.user == User.current || User.current.admin? %> @@ -85,21 +86,21 @@ <% end %> <% elsif is_student_batch_homework%> - <% if @bid.comment_status == 1 %> + <% if bid.comment_status == 1 %>
  • <%= link_to l(:label_anonymous_comments),homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type),:remote => true %> - <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> + <% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>   迟交! <% end %>
  • - <% elsif @bid.comment_status == 2%> + <% elsif bid.comment_status == 2%>
  • <%= l(:label_anonymous_comments) %> - <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> + <% if Time.parse(bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %>   迟交! <% end %>
  • diff --git a/app/views/homework_attach/_jour.html.erb b/app/views/homework_attach/_jour.html.erb index fe2eca8dc..76bc15782 100644 --- a/app/views/homework_attach/_jour.html.erb +++ b/app/views/homework_attach/_jour.html.erb @@ -11,18 +11,22 @@
    <% if show_name %> - <%= link_to jour.user, user_path(jour.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%> + <%= link_to jour.user, user_path(jour.user),:style => " font-weight:bold; color:#15bccf; margin-right:5px; background:none;", :target => "_blank"%> <% else%> - <%= l(:label_anonymous) %> + <%= l(:label_anonymous) %> <% end %> - <%= format_time(jour.created_on) %> - + <%= format_time(jour.created_on) %> + <% if show_score %> <%= l(:label_work_rating) %>: - <%= render :partial => 'homework_attach/show_score', locals: {:stars => get_homework_score(jour.user,@homework ) } %> +
    + <% star = get_homework_score(jour.user,@homework)%> + <%= render :partial => 'homework_attach/show_static_star', :locals => {:start_score => star } %> +
    + <% end %>
    @@ -31,7 +35,7 @@
    <% ids = 'project_respond_form_'+ jour.id.to_s%> - <% if (jour.user==User.current|| User.current.admin?) && show_name %> + <% if (jour.user==User.current|| User.current.admin?) && show_name && !show_score %> <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy_jour', :object_id => jour, :user_id => jour.user,:jour_id =>@homework.id }, :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> <% end %> diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index bf797e441..937c068c1 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -1,52 +1,17 @@ -<% reply_allow = JournalsForMessage.create_by_user? User.current %> - - +<%# reply_allow = JournalsForMessage.create_by_user? User.current %> -<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>

    <%= @homework.name %>

    @@ -111,14 +76,13 @@ <% end%>

    - -
    - <%= render :partial => 'show_star',:locals => {:is_comprehensive_evaluation => @is_comprehensive_evaluation,:totle_score => @totle_score,:has_evaluation => @has_evaluation , - :homework => @homework} %> -
    -
    - <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => @is_comprehensive_evaluation} %> + <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, + :is_comprehensive_evaluation => @is_comprehensive_evaluation, + :m_score => @m_score, + :cur_page => @cur_page, + :cur_type => @cur_type, + :is_teacher => @is_teacher} %>
    diff --git a/app/views/homework_attach/_show_star.html.erb b/app/views/homework_attach/_show_star.html.erb index 0f842a1cd..33279c360 100644 --- a/app/views/homework_attach/_show_star.html.erb +++ b/app/views/homework_attach/_show_star.html.erb @@ -1,16 +1,6 @@ -<% if is_comprehensive_evaluation == 3 || User.current == homework.user%> - -<% elsif is_comprehensive_evaluation == 2 %> - <% if has_evaluation %> - <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: @m_score, class: 'rateable div_inline' %> - <% else %> - <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: 0, class: 'rateable div_inline' %> - <% end %> - -<% elsif @is_comprehensive_evaluation == 1%> - <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: @m_score, class: 'rateable div_inline' %> -<% end %> \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/app/views/homework_attach/_show_static_star.html.erb b/app/views/homework_attach/_show_static_star.html.erb new file mode 100644 index 000000000..7fe3edf22 --- /dev/null +++ b/app/views/homework_attach/_show_static_star.html.erb @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/views/homework_attach/addjours.js.erb b/app/views/homework_attach/addjours.js.erb index 9badfc109..8d32b10c1 100644 --- a/app/views/homework_attach/addjours.js.erb +++ b/app/views/homework_attach/addjours.js.erb @@ -1,19 +1,35 @@ //教师评论 -<% if @add_jour.is_comprehensive_evaluation == 1 %> - HoverLi(4); - $('#jour_count_4').html('<%= @comprehensive_evaluation.count %>'); - $('#tbc_04').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @comprehensive_evaluation,:show_score => true,:show_name => true,:is_jour => false})) %>'); +<% if @cur_is_comprehensive_evaluation == "1" %> + HoverLi(4); + $('#jour_count_4').html('<%= @comprehensive_evaluation.count %>'); + $('#tbc_04').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @comprehensive_evaluation,:show_score => true,:show_name => true,:is_jour => false})) %>'); //匿评 -<% elsif @add_jour.is_comprehensive_evaluation == 2 %> - $('#add_jour').html('<%= escape_javascript(render(:partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => @is_comprehensive_evaluation})) %>'); - HoverLi(5); - $('#jour_count_5').html('<%= @anonymous_comments.count %>'); - $('#tbc_05').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @anonymous_comments,:show_score => true,:show_name => false,:is_jour => false})) %>'); +<% elsif @cur_is_comprehensive_evaluation == "2" %> + $('#add_jour').html('<%= escape_javascript(render(:partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, + :is_comprehensive_evaluation => @is_comprehensive_evaluation, + :cur_type => @cur_type, :cur_page => @cur_page, :m_score => @m_score, :is_teacher => false})) %>'); + HoverLi(5); + $('#jour_count_5').html('<%= @anonymous_comments.count %>'); + $('#tbc_05').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @anonymous_comments,:show_score => true,:show_name => false,:is_jour => false})) %>'); //留言 <% else %> - HoverLi(3); - $('#jour_count_3').html('<%= @jours.count %>'); - $('#tbc_03').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @jour,:show_score => false,:show_name => true,:is_jour => true})) %>'); + HoverLi(3); + $('#jour_count_3').html('<%= @jours.count %>'); + $('#tbc_03').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @jour,:show_score => false,:show_name => true,:is_jour => true})) %>'); <% end %> + $('#new_form_user_message').val(""); -$('#new_form_reference_user_id').val(""); \ No newline at end of file +$('#new_form_reference_user_id').val(""); + +<% if @cur_is_comprehensive_evaluation == "1" || @cur_is_comprehensive_evaluation == "2" %> + <% if @cur_type == "1" %> + $("#tbc_01").html('<%= escape_javascript(render(:partial => 'homework_attach/homeworks_list',:locals => {:homeworks => @homework_list, + :homework_count => @obj_count, + :remote => false,:is_student_batch_homework => false})) %>'); + <% elsif @cur_type == "2" || @cur_type == "3" || @cur_type == "4" %> + <% is_teacher = is_course_teacher(User.current,@homework.bid.courses.first) %> + $("#homework_li_<%= @homework.id%>").html('<%= escape_javascript(render(:partial => 'homework_attach/homework',:locals => {:homework => @result_homework || @homework, + :is_student_batch_homework => @is_student_batch_homework || false, + :is_my_homework => false, :is_teacher => is_teacher})) %>'); + <% end %> +<% end %> diff --git a/app/views/homework_attach/show.js.erb b/app/views/homework_attach/show.js.erb index d63b5fb8f..3f8efb44c 100644 --- a/app/views/homework_attach/show.js.erb +++ b/app/views/homework_attach/show.js.erb @@ -1,11 +1,9 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show',:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show') %>'); showModal('ajax-modal', '513px'); $('#ajax-modal').css('height','569px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + - ""); + ""); $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("alert_box"); diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 9ce2a6edf..7c40173a0 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -117,7 +117,7 @@
    - <% if (User.current.admin?||User.current.id==@bid.author_id) %> + <% if (User.current.admin?||User.current.allowed_to?(:as_teacher,course)) %>
    <% if @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2%> diff --git a/lib/seems_rateable/lib/seems_rateable/model.rb b/lib/seems_rateable/lib/seems_rateable/model.rb index b4ebbb196..83d37d555 100644 --- a/lib/seems_rateable/lib/seems_rateable/model.rb +++ b/lib/seems_rateable/lib/seems_rateable/model.rb @@ -37,9 +37,9 @@ module SeemsRateable def update_users_rating(stars, user_id, dimension=nil) obj = rates(dimension).where(:rater_id => user_id).first - current_record = average(dimension) - current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt) - current_record.save! + #current_record = average(dimension) + #current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt) + #current_record.save! obj.stars = stars obj.save! end diff --git a/public/images/bid/star.png b/public/images/bid/star.png new file mode 100644 index 000000000..507e19020 Binary files /dev/null and b/public/images/bid/star.png differ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 5c21b200e..250ff49a4 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2044,7 +2044,7 @@ width:20%; font-weight:bold; text-align:center; padding:0.6em; -z-index:100; +z-index:100000; opacity: 0.5; } diff --git a/public/stylesheets/css.css b/public/stylesheets/css.css index 17316c095..b6d61c865 100644 --- a/public/stylesheets/css.css +++ b/public/stylesheets/css.css @@ -80,8 +80,7 @@ a.wzan_visited{background:url(images/pic_zan.png) 0 0 no-repeat;} .ping_con p{ color:#777777; font-size:12px; border-bottom:1px dashed #CCC; padding-bottom:5px;} .ping_con p span a{ color:#777777;} .ping_star{ width:160px; color:#333; font-weight:bold; margin-bottom:5px;} -.ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png) -2px 0 no-repeat; margin-right:3px;} -.ping_star span a:hover{background:url(images/star.png) -24px 0 no-repeat;} +.ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png);background-repeat: no-repeat; margin-right:3px;} .ping_con textarea{ height:76px; border:1px solid #15bccf; margin-bottom:5px; color:#666; font-size:12px;} a.ping_sub{ float:right; height:22px; width:60px; margin-right:20px; background:#15bccf; color:#fff; text-align:center;} a.ping_sub1{ float:right; height:22px; width:60px; background:#15bccf; color:#fff; text-align:center;}