diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 2f6be7611..17dbb5cae 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -403,10 +403,13 @@ class HomeworkAttachController < ApplicationController 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 #是否开启了匿评 + #@is_comprehensive_evaluation 1:教师评论,2:学生匿评,3:学生留言 if !User.current.member_of_course?(@homework.bid.courses.first) @is_comprehensive_evaluation = 3 #留言 - elsif is_student && @is_anonymous_comments#是学生且开启了匿评 + 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 @@ -458,14 +461,17 @@ class HomeworkAttachController < ApplicationController #添加留言 def addjours @homework = HomeworkAttach.find(params[:jour_id]) + #保存评分 + @homework.rate(params[:stars_value],User.current.id,:quality) + #保存评论 @add_jour = @homework.addjours User.current.id, params[:new_form][:user_message],0,params[:is_comprehensive_evaluation] if @add_jour.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") + 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 @@ -476,36 +482,23 @@ 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 #教师评论 + #@has_evaluation = @homework.has_rated?( User.current,:quality) + is_anonymous_comments = @homework.bid.comment_status == 1 #是否开启了匿评 + if User.current.member_of_course?(@homework.bid.courses.first) + if 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 #留言 + else #是老师 + @is_comprehensive_evaluation = 1 #教师评论 + end else @is_comprehensive_evaluation = 3 end - respond_to do |format| format.js end diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index 8d4c1eaf2..a2b0013e0 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -52,6 +52,8 @@ function submit1() { + if($("#stars_value").val() == "0"){alert("您还没有打分");return;} + if($("#new_form_user_message").val() == ""){alert("您还没有填写评语");return;} $('#jours_submit').parent().submit(); } @@ -62,6 +64,18 @@ :jour_id => homework_attach.id, :is_comprehensive_evaluation => is_comprehensive_evaluation, :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} %> @@ -75,7 +89,6 @@ <%= f.text_field :reference_user_id, :style=>"display:none"%>
<%= l(:label_submit_comments) %> -
<% else %>
diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index 416ca4f66..42a5cead5 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -112,20 +112,8 @@ <% end%>

- -
- <% if @is_comprehensive_evaluation == 3 || User.current == homework.user%> - - <% else @is_comprehensive_evaluation == 2 %> - - <%= l(:label_work_rating) %>: - <%= render :partial => 'show_star',:locals => {start_score:@m_score} %> - <% end %> - -
-
- <%= 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} %>
diff --git a/app/views/homework_attach/_show_star.html.erb b/app/views/homework_attach/_show_star.html.erb index d98e35a0e..3b6e23880 100644 --- a/app/views/homework_attach/_show_star.html.erb +++ b/app/views/homework_attach/_show_star.html.erb @@ -3,4 +3,4 @@ - \ No newline at end of file + \ No newline at end of file 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