效果实现
This commit is contained in:
parent
aca7684414
commit
061a1f602a
|
@ -737,11 +737,10 @@ module CoursesHelper
|
|||
end
|
||||
desc.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
# 学生按作业总分排序,取前8个
|
||||
def hero_homework_score(course, score_sort_by)
|
||||
sql_select = "SELECT members.*,(
|
||||
# 学生按作业总分排序,取前8个
|
||||
def hero_homework_score(course, score_sort_by)
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(student_works.final_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
|
@ -752,8 +751,15 @@ def hero_homework_score(course, score_sort_by)
|
|||
JOIN students_for_courses
|
||||
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
|
||||
WHERE members.course_id = #{course.id} ORDER BY score #{score_sort_by} limit 9"
|
||||
sql = ActiveRecord::Base.connection()
|
||||
homework_scores = Member.find_by_sql(sql_select)
|
||||
sql.close()
|
||||
homework_scores
|
||||
sql = ActiveRecord::Base.connection()
|
||||
homework_scores = Member.find_by_sql(sql_select)
|
||||
sql.close()
|
||||
homework_scores
|
||||
end
|
||||
|
||||
def contributor_course_scor(course)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -73,10 +73,11 @@ class Attachment < ActiveRecord::Base
|
|||
cattr_accessor :thumbnails_storage_path
|
||||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location,:act_as_course_activity
|
||||
after_create :office_conver, :be_user_score,:act_as_forge_activity, :act_as_student_score
|
||||
before_save :files_to_final_location,:act_as_course_activity, :act_as_student_score
|
||||
after_create :office_conver, :be_user_score,:act_as_forge_activity
|
||||
after_update :office_conver, :be_user_score
|
||||
after_destroy :delete_from_disk,:down_user_score
|
||||
# after_save :act_as_student_score
|
||||
|
||||
# add by nwb
|
||||
# 获取所有可公开的资源文件列表
|
||||
|
@ -563,13 +564,14 @@ class Attachment < ActiveRecord::Base
|
|||
|
||||
# 课程成员得分(英雄榜)
|
||||
def act_as_student_score
|
||||
unless self.author.allowed_to?(:as_teacher, self.course)
|
||||
if self.parent_id.nil?
|
||||
# 发帖
|
||||
course_member_score(self.course.id, self.author_id, "Message")
|
||||
unless self.author.allowed_to?(:as_teacher, self.container)
|
||||
course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", self.container_id, self.author_id).first
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => self.container_id, :user_id => self.author_id, :message_num => 0, :message_reply_num => 0,
|
||||
:news_reply_num => 0, :resource_num => 5, :journal_num => 0, :journal_reply_num => 0)
|
||||
else
|
||||
# 回帖
|
||||
course_member_score(self.course.id, self.author_id, "MessageReply")
|
||||
score = course_contributor_score.news_reply_num + 5
|
||||
course_contributor_score.update_attributes(:resource_num => score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,60 +1,47 @@
|
|||
<% course_file_num = visable_attachemnts_incourse(@course).count%>
|
||||
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
|
||||
<% if show_nav?(@course.course_activities.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %>
|
||||
<!--暂时不显示课程动态数,优化后在显示-->
|
||||
<%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(@course.homework_commons.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
|
||||
<%= link_to "(#{@course.homework_commons.count})", homework_common_index_path(:course => @course.id), :class => "subnav_num c_orange"%>
|
||||
<%= link_to( "+#{l(:label_course_homework_new)}", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(@course.news.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.news.count})", course_news_index_path(@course), :class => "subnav_num c_orange"%>
|
||||
<%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_file_num) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{course_file_num})", course_files_path(@course), :class => "subnav_num c_orange",:id=>'courses_files_count_nav' %>
|
||||
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
|
||||
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
|
||||
<a class="subnav_green ml95 c_white" href="javascript:void(0);" onclick="course_files_upload();">+上传资源 </a>
|
||||
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.boards.first ? @course.boards.first.topics.count : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_message_new)}",course_boards_path(@course, :flag => true, :is_new => 1),:class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_feedback_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{course_feedback_count})", course_feedback_path(@course), :class => "subnav_num c_orange", :id => "course_jour_count"%>
|
||||
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}", :id => "course_jour_count"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(course_poll_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02"%>
|
||||
<%= link_to "(#{course_poll_count})", poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_new_poll)}", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02"%>
|
||||
<%= link_to "(#{User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count})", exercise_index_path(:course_id => @course.id), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+新建试卷", new_exercise_path(:course_id => @course.id), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -147,14 +147,14 @@
|
|||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
|
||||
<%= link_to "(#{@course.homework_commons.count})", homework_common_index_path(:course => @course.id), :class => "subnav_num c_orange"%>
|
||||
<%= link_to( "+#{l(:label_course_homework_new)}", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(@course.news.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.news.count})", course_news_index_path(@course), :class => "subnav_num c_orange"%>
|
||||
<%= link_to( "+#{l(:label_course_news_new)}", new_course_news_path(@course), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(course_file_num) %>
|
||||
|
@ -163,7 +163,7 @@
|
|||
<%= link_to "(#{course_file_num})", course_files_path(@course), :class => "subnav_num c_orange",:id=>'courses_files_count_nav' %>
|
||||
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
|
||||
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
|
||||
<a class="subnav_green ml95 c_white" href="javascript:void(0);" onclick="course_files_upload();">+上传资源 </a>
|
||||
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -171,27 +171,28 @@
|
|||
<div class="subNav">
|
||||
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{@course.boards.first ? @course.boards.first.topics.count : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_message_new)}",course_boards_path(@course, :flag => true, :is_new => 1),:class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(course_feedback_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %>
|
||||
<%= link_to "(#{course_feedback_count})", course_feedback_path(@course), :class => "subnav_num c_orange", :id => "course_jour_count"%>
|
||||
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}", :id => "course_jour_count"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(course_poll_count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02"%>
|
||||
<%= link_to "(#{course_poll_count})", poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+#{l(:label_new_poll)}", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02"%>
|
||||
<%= link_to "(#{User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count})", exercise_index_path(:course_id => @course.id), :class => "subnav_num c_orange" %>
|
||||
<%= link_to( "+新建试卷", new_exercise_path(:course_id => @course.id), :class => 'subnav_green c_white') if is_teacher %>
|
||||
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%# 工具栏展开 %>
|
||||
|
@ -204,40 +205,25 @@
|
|||
<div class="cl"></div>
|
||||
<ul class="rankList">
|
||||
<p class="fontGrey2 f14">课程贡献榜</p>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">jack_nudt</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">6598</span></p>
|
||||
<div class="numIntro">发帖:650<br />
|
||||
评论:98</div>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">linchun</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">5421</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">junjie</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">3675</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">timtang</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">2775</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">xiaoting</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">1986</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">zanle</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">1327</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">huang</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">1143</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">guangge</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">999</span></p>
|
||||
<% hero_homework_score(@course, "desc").each do |student_score| %>
|
||||
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a>
|
||||
<p><a href="javascript:void:(0);"><%=link_to student_score.user, user_path(student_score.user) %></a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">
|
||||
<%#= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id },
|
||||
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
|
||||
:onmouseover =>"message_titile_show($(this),event)",
|
||||
:onmouseout => "message_titile_hide($(this))" %>
|
||||
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))"><%= student_score.score.to_i %></a></span></p>
|
||||
<div style="display: none" class="numIntro">
|
||||
资源:2<br />
|
||||
评论:98<br />
|
||||
留言:12<br />
|
||||
通知:8<br />
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<ul class="rankList">
|
||||
|
@ -350,6 +336,16 @@
|
|||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("popbox_polls");
|
||||
}
|
||||
// 鼠标经过的时候显示内容
|
||||
function message_titile_show(obj,e)
|
||||
{
|
||||
obj.parent().parent().next("div").show();
|
||||
obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute");
|
||||
}
|
||||
function message_titile_hide(obj)
|
||||
{
|
||||
obj.parent().parent().next("div").hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue