parent
f5b1cbcfe4
commit
9a61354328
|
@ -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#是学生且开启了匿评且未进行评分
|
||||
#@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 #是学生且开启了匿评,但已评分
|
||||
elsif is_student && is_anonymous_comments && @has_evaluation #是学生且开启了匿评,但已评分
|
||||
@is_comprehensive_evaluation = 3 #留言
|
||||
elsif is_student && !@is_anonymous_comments #是学生未开启匿评
|
||||
elsif is_student && !is_anonymous_comments #是学生未开启匿评
|
||||
@is_comprehensive_evaluation = 3 #留言
|
||||
elsif is_teacher
|
||||
else #是老师
|
||||
@is_comprehensive_evaluation = 1 #教师评论
|
||||
end
|
||||
else
|
||||
@is_comprehensive_evaluation = 3
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
</script>
|
||||
|
@ -62,6 +64,18 @@
|
|||
:jour_id => homework_attach.id,
|
||||
:is_comprehensive_evaluation => is_comprehensive_evaluation,
|
||||
:sta => sta}) do |f|%>
|
||||
<!-- 打分 -->
|
||||
<div class="ping_star" id="star_score">
|
||||
<% 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 %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<!-- 打分js结束 -->
|
||||
|
||||
<div id = 'pre_show'>
|
||||
<%= render :partial => 'words/pre_show', :locals => {:content => @content} %>
|
||||
|
@ -75,7 +89,6 @@
|
|||
<%= f.text_field :reference_user_id, :style=>"display:none"%>
|
||||
<div style="float:right">
|
||||
<a href="#" class="ping_sub1" id="jours_submit" onclick="submit1();"><%= l(:label_submit_comments) %></a>
|
||||
|
||||
</div>
|
||||
<% else %>
|
||||
<div style="font-size: 14px;margin:10px;text-align: center">
|
||||
|
|
|
@ -112,20 +112,8 @@
|
|||
<% end%>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div class="ping_star" id="star_score">
|
||||
<% 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 %>
|
||||
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div id="add_jour">
|
||||
<%= 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} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!---ping_con end--->
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
<span><a href="#" id="star03" onclick="ChoseStars(3)" style="background-position:<%= start_score>=3 ? '-24px 0px;':'-2px 0'%>"></a></span>
|
||||
<span><a href="#" id="star02" onclick="ChoseStars(2)" style="background-position:<%= start_score>=2 ? '-24px 0px;':'-2px 0'%>"></a></span>
|
||||
<span><a href="#" id="star01" onclick="ChoseStars(1)" style="background-position:<%= start_score>=1 ? '-24px 0px;':'-2px 0'%>"></a></span>
|
||||
<input type="hidden" value="0" id="stars_value"/>
|
||||
<input type="hidden" value="0" id="stars_value" name="stars_value"/>
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue