Merge branch 'Homework' of http://repository.trustie.net/xianbo/trustie2 into Homework

This commit is contained in:
sw 2014-11-03 17:20:04 +08:00
commit b625a857e9
10 changed files with 144 additions and 82 deletions

View File

@ -1,7 +1,7 @@
class HomeworkAttachController < ApplicationController
layout "course_base"
include CoursesHelper
include HomeworkAttachHelper
helper :words
###############################
before_filter :can_show_course,except: []
@ -365,18 +365,29 @@ class HomeworkAttachController < ApplicationController
@has_evaluation = stars_reates.where("rater_id = ?",User.current).count > 0
#是否开启互评功能
@is_evaluation = @homework.bid.is_evaluation == 1 || @homework.bid.is_evaluation == nil
@limit = 10
#@limit = 10
#@jours留言 is null条件用以兼容历史数据
@jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@jour = paginateHelper @jours,10
#@feedback_count = @jours.count
#@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
#@offset ||= @feedback_pages.offset
#@jour = @jours[@offset, @limit]
#@comprehensive_evaluation教师评论
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1").order("created_on DESC")
#@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1").order("created_on DESC")
teachers = searchTeacherAndAssistant @course
@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
@comprehensive_evaluation << temp if temp
end
#@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation = 1 and user_id in #{convert_array(teachers)}").order("created_on DESC")
#@anonymous_comments 匿评
@anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2").order("created_on DESC")
#@anonymous_comments = @homework.journals_for_messages.where("is_comprehensive_evaluation = 2").order("created_on DESC")
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")
end
@totle_score = score_for_homework @homework
@teaher_score = teacher_score_for_homework @homework
@ -416,13 +427,29 @@ 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]
@jours = @homework.journals_for_messages.where("is_comprehensive_evaluation is null").order("created_on DESC")
@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")
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")
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")
end
elsif @add_jour.is_comprehensive_evaluation == 1
teachers = searchTeacherAndAssistant @course
@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
@comprehensive_evaluation << temp if temp
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

View File

@ -90,4 +90,19 @@ module HomeworkAttachHelper
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
end
def convert_array array
ary = "("
if array.nil? || array.count == 0
return "()"
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

View File

@ -0,0 +1,25 @@
<div class="ping_list">
<div id="ping_tb_" class="ping_tb_">
<ul>
<li id="ping_tb_4" class="ping_normaltab" onmouseover="i:HoverLi(4);">
<%= l(:label_teacher_comments) %><span class="c_red"><%= @comprehensive_evaluation.nil? ? 0 : @comprehensive_evaluation.count %></span></li>
<li id="ping_tb_5" class="ping_normaltab" onmouseover="i:HoverLi(5);">
<%= l(:label_anonymous_comments) %><span class="c_red"><%= @anonymous_comments.nil? ? 0 : @anonymous_comments.count %></span></li>
<li id="ping_tb_3" class="ping_hovertab" onmouseover="x:HoverLi(3);">
<%= l(:label_responses) %><span class="c_red"><%= @jours.nil? ? 0 : @jours.count %></span></li>
</ul>
</div>
<div class="cl"></div>
<div class="ping_ctt">
<div class="ping_dis" id="tbc_03">
<%= render :partial => 'homework_attach/jour',:locals => {:jours => @jour,:show_score => false,:show_name => true,:is_jour => true} %>
</div>
<div class="ping_undis" id="tbc_04">
<%= render :partial => 'homework_attach/jour',:locals => {:jours => @comprehensive_evaluation,:show_score => true,:show_name => true,:is_jour => false} %>
</div>
<div class="ping_undis" id="tbc_05">
<%= render :partial => 'homework_attach/jour',:locals => {:jours => @anonymous_comments,:show_score => true,:show_name => false,:is_jour => false} %>
</div>
</div>
</div><!---ping_list end--->

View File

@ -1,11 +1,22 @@
<% jours.nil? || jours.count == 0 || jours.each do |jour| %>
<div class="ping_C">
<div class="ping_dispic"><a target="_blank" href="#"><%= image_tag(url_to_avatar(jour.user)) %></a></div>
<div class="ping_dispic">
<% if show_name %>
<%= link_to image_tag(url_to_avatar(jour.user)) , user_path(jour.user), :target =>"_blank" %>
<% else %>
<a><%= image_tag(url_to_avatar(nil))%></a>
<a><%= l(:label_anonymous) %></a>
<% end %>
</div>
<div class="ping_discon">
<div class="ping_distop">
<span><%= link_to jour.user, user_path(jour.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%></span>
<span style="color:#a6a6a6; margin-right:40px; margin-left:30px;"><%= jour.created_on %></span><span style="font-weight:bold; color:#a6a6a6; ">
<%= l(:label_work_rating) %>
<%= render :partial => 'show_score', locals: {:stars => get_homework_score(jour.user,@homework ) } %>
<span style="color:#a6a6a6; margin-right:40px; margin-left:30px;"><%= jour.created_on %></span>
<span style="font-weight:bold; color:#a6a6a6; ">
<% if show_score %>
<%= l(:label_work_rating) %>
<%= render :partial => 'show_score', locals: {:stars => get_homework_score(jour.user,@homework ) } %>
<% end %>
</span>
<div class="cl"></div>
<p><%= textilizable jour.notes%></p>
@ -25,4 +36,8 @@
</div>
<div class="cl"></div>
</div>
</div>
<% end %>
<% if is_jour%>
<ul class="wlist"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true%></ul>
<% end %>

View File

@ -50,23 +50,9 @@
</span>
</p>
<div class="ping_star">
<% if @is_comprehensive_evaluation == 3 %>
<%= l(:label_work_rating) %>
<%= render :partial => 'show_score', locals: {:stars => @totle_score} %>
<% elsif @is_comprehensive_evaluation == 2 %>
<%= l(:label_work_rating) %>
<% if @has_evaluation || !can_anonymous_comments %>
<%= render :partial => 'show_score', locals: {:stars => @totle_score} %>
<% else %>
<%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %>
<% end %>
<% elsif @is_comprehensive_evaluation == 1%>
<%= l(:label_work_rating) %>
<%= rating_for @homework, dimension: :quality, class: 'rateable div_inline' %>
<% end %>
<div class="ping_star" id="star_score">
<%= render :partial => 'show_star',:locals => {:is_comprehensive_evaluation => @is_comprehensive_evaluation,:totle_score => @totle_score,:has_evaluation => @has_evaluation ,
:can_anonymous_comments=>can_anonymous_comments,:homework => @homework} %>
</div>
<div class="cl"></div>
<%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => @is_comprehensive_evaluation} %>
@ -75,40 +61,7 @@
<div class="cl"></div>
</div><!---ping_con end--->
<div class="ping_list">
<div id="ping_tb_" class="ping_tb_">
<ul>
<li id="ping_tb_4" class="ping_normaltab" onmouseover="i:HoverLi(4);">
<%= l(:label_teacher_comments) %><span class="c_red"><%= @comprehensive_evaluation.count == 0 ? 0:1 %></span></li>
<li id="ping_tb_5" class="ping_normaltab" onmouseover="i:HoverLi(5);">
<%= l(:label_anonymous_comments) %><span class="c_red"><%= @anonymous_comments.count %></span></li>
<li id="ping_tb_3" class="ping_hovertab" onmouseover="x:HoverLi(3);">
<%= l(:label_responses) %><span class="c_red"><%= @jours.count %></span></li>
</ul>
</div>
<div class="cl"></div>
<div class="ping_ctt">
<div class="ping_dis" id="tbc_03">
<% @jours.each do |jour| %>
<%= render :partial => 'homework_attach/jour',:locals => {:jour => jour} %>
<% end %>
</div><!--全部评论end-->
<div class="ping_undis" id="tbc_04">
<% if @comprehensive_evaluation.count > 0 %>
<%= render :partial => 'homework_attach/jour',:locals => {:jour => @comprehensive_evaluation.first} %>
<% end %>
</div>
<div class="ping_undis" id="tbc_05">
<%= @anonymous_comments.each do |jour| %>
<%= render :partial => 'homework_attach/jour',:locals => {:jour => jour} %>
<% end %>
</div>
</div>
<%= render :partial => 'histoey_new' %>
</div>
</div><!---ping_list end--->
</div>

View File

@ -0,0 +1,15 @@
<% if is_comprehensive_evaluation == 3 %>
<%= l(:label_work_rating) %>
<%= render :partial => 'show_score', locals: {:stars => totle_score} %>
<% elsif is_comprehensive_evaluation == 2 %>
<%= l(:label_work_rating) %>
<% if has_evaluation || !can_anonymous_comments %>
<%= render :partial => 'show_score', locals: {:stars => totle_score} %>
<% else %>
<%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %>
<% end %>
<% elsif @is_comprehensive_evaluation == 1%>
<%= l(:label_work_rating) %>
<%= rating_for homework, dimension: :quality, class: 'rateable div_inline' %>
<% end %>

View File

@ -1,9 +1,19 @@
//教师评论
<% if @add_jour.is_comprehensive_evaluation == 1 %>
$('#comprehensive_evaluation').html('<%= escape_javascript(render(:partial => 'comprehensive_evaluation',
:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework,:teaher_score => @teaher_score} )) %>');
//$('#comprehensive_evaluation').html('<#%= escape_javascript(render(:partial => 'comprehensive_evaluation',
//:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework,:teaher_score => @teaher_score} )) %>');
HoverLi(4);
$('#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 %>
// $('#message').html('<#%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false,:homework => @homework} )) %>');
// $('#pre_show').html('<#%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>');
HoverLi(5);
$('#tbc_05').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @anonymous_comments,:show_score => true,:show_name => false,:is_jour => false})) %>')
//留言
<% else %>
$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false,:homework => @homework} )) %>');
$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>');
$('#new_form_user_message').val("");
$('#new_form_reference_user_id').val("");
<% end %>
HoverLi(3);
$('#tbc_03').html('<%= escape_javascript(render(:partial => 'homework_attach/jour',:locals => {:jours => @jours,:show_score => false,:show_name => true,:is_jour => true})) %>')
<% end %>
$('#new_form_user_message').val("");
$('#new_form_reference_user_id').val("");

View File

@ -1,4 +1,4 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show',:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score,:can_anonymous_comments => false}) %>');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show',:locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score,:can_anonymous_comments => true}) %>');
showModal('ajax-modal', '503px');
$('#ajax-modal').css('height','569px');

View File

@ -1849,4 +1849,5 @@ en:
label_participation_person: The participation of personnel
label_homework_without_description: The homework without any description!
label_teacher_comments: Teacher comments
label_anonymous_comments: Anonymous comments
label_anonymous_comments: Anonymous comments
label_anonymous: Anonymous

View File

@ -2181,4 +2181,5 @@ zh:
label_homework_without_description: 该作业无任何描述!
label_sure_exit_homework: 是否确认退出该作业
label_teacher_comments: 教师评论
label_anonymous_comments: 匿评
label_anonymous_comments: 匿评
label_anonymous: 匿名