课程英雄榜数据
This commit is contained in:
parent
061a1f602a
commit
8c83bbfff3
|
@ -757,8 +757,8 @@ module CoursesHelper
|
|||
homework_scores
|
||||
end
|
||||
|
||||
def contributor_course_scor(course)
|
||||
|
||||
def contributor_course_scor(course_id)
|
||||
ccs = CourseContributorScore.where("course_id =?", course_id).limit(9)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,47 +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.homework_commons.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
|
||||
<%= 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( "", 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" %>
|
||||
<% 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="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_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_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( "", 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( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% 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.homework_commons.count) %>
|
||||
<div class="subNav">
|
||||
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
|
||||
<%= 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( "", 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" %>
|
||||
<% 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="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_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_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( "", 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( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -205,7 +205,7 @@
|
|||
<div class="cl"></div>
|
||||
<ul class="rankList">
|
||||
<p class="fontGrey2 f14">课程贡献榜</p>
|
||||
<% hero_homework_score(@course, "desc").each do |student_score| %>
|
||||
<% contributor_course_scor(@course.id).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">
|
||||
|
@ -213,7 +213,7 @@
|
|||
: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>
|
||||
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))"><%= student_score.total_score.to_i %></a></span></p>
|
||||
<div style="display: none" class="numIntro">
|
||||
资源:2<br />
|
||||
评论:98<br />
|
||||
|
|
|
@ -1,30 +1,36 @@
|
|||
class AddCourseContributorScore < ActiveRecord::Migration
|
||||
def up
|
||||
# course_count = Course.all.count / 30 + 1
|
||||
# transaction do
|
||||
# for i in 1 ... course_count do i
|
||||
Course.all.each do |course|
|
||||
if course.course_activities.count > 1
|
||||
course.student.each do |s|
|
||||
puts course.id
|
||||
puts course.name
|
||||
puts s.student_id
|
||||
board_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?",s.student_id, course.id, "Message").count * 2
|
||||
message_reply_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is not null;").count * 1
|
||||
common_reply_count = Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.student_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count * 1
|
||||
attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5
|
||||
journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.student_id, course.id, "Course").count * 1
|
||||
# journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1
|
||||
# journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1
|
||||
CourseContributorScore.create(:course_id => course.id, :user_id => s.student_id, :message_num => board_count, :message_reply_num => message_reply_count,
|
||||
:news_reply_num => common_reply_count, :resource_num => attachment_count, :journal_num => journal_count, :journal_reply_num => 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
class AddCourseContributorScore < ActiveRecord::Migration
|
||||
def up
|
||||
# course_count = Course.all.count / 30 + 1
|
||||
# transaction do
|
||||
# for i in 1 ... course_count do i
|
||||
Course.all.each do |course|
|
||||
if course.course_activities.count > 1
|
||||
course.student.each do |s|
|
||||
puts course.id
|
||||
puts course.name
|
||||
puts s.student_id
|
||||
# board_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?",s.student_id, course.id, "Message").count * 2
|
||||
board_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is null;").count * 2
|
||||
message_reply_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is not null").count * 1
|
||||
common_reply_count = Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.student_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count * 1
|
||||
# attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5
|
||||
attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id};").count * 5
|
||||
journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.student_id, course.id, "Course").count * 1
|
||||
# journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1
|
||||
# journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1
|
||||
total = board_count + message_reply_count + common_reply_count + attachment_count + journal_count
|
||||
if total !=0
|
||||
CourseContributorScore.create(:course_id => course.id, :user_id => s.student_id, :message_num => board_count, :message_reply_num => message_reply_count,
|
||||
:news_reply_num => common_reply_count, :resource_num => attachment_count, :journal_num => journal_count, :journal_reply_num => 0, :total => total)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddTotalScoreToCourseContributorScore < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :course_contributor_scores, :total_score, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20151125072235) do
|
||||
ActiveRecord::Schema.define(:version => 20151126160252) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -393,6 +393,7 @@ ActiveRecord::Schema.define(:version => 20151125072235) do
|
|||
t.integer "journal_reply_num"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "total_score"
|
||||
end
|
||||
|
||||
create_table "course_groups", :force => true do |t|
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
#coding=utf-8
|
||||
#
|
||||
#
|
||||
module Trustie
|
||||
module Gitlab
|
||||
|
||||
module ManageMember
|
||||
def self.included(base)
|
||||
base.class_eval {
|
||||
before_create :add_gitlab_member
|
||||
before_destroy :delete_gitlab_member
|
||||
after_save :change_gitlab_member
|
||||
}
|
||||
end
|
||||
|
||||
def change_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
@g.edit_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def add_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
if self.member.user.gid.nil?
|
||||
add_user(self.member.user)
|
||||
end
|
||||
@g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def delete_gitlab_member
|
||||
if isGitlabProject?
|
||||
if member.roles.count <=1
|
||||
@g ||= ::Gitlab.client
|
||||
@g.remove_team_member(project.gpid, self.member.user.gid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def project
|
||||
self.member.project
|
||||
end
|
||||
|
||||
def repository
|
||||
unless project.nil?
|
||||
project.repository
|
||||
end
|
||||
end
|
||||
|
||||
def isGitlabProject?
|
||||
unless repository.nil?
|
||||
repository && repository.gitlab?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
#coding=utf-8
|
||||
#
|
||||
#
|
||||
module Trustie
|
||||
module Gitlab
|
||||
|
||||
module ManageMember
|
||||
def self.included(base)
|
||||
base.class_eval {
|
||||
before_create :add_gitlab_member
|
||||
before_destroy :delete_gitlab_member
|
||||
after_save :change_gitlab_member
|
||||
}
|
||||
end
|
||||
|
||||
def change_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
@g.edit_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def add_gitlab_member
|
||||
if isGitlabProject?
|
||||
@g ||= ::Gitlab.client
|
||||
if self.member.user.gid.nil?
|
||||
add_user(self.member.user)
|
||||
end
|
||||
@g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
|
||||
end
|
||||
end
|
||||
|
||||
def delete_gitlab_member
|
||||
if isGitlabProject?
|
||||
if member.roles.count <=1
|
||||
@g ||= ::Gitlab.client
|
||||
@g.remove_team_member(project.gpid, self.member.user.gid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def project
|
||||
self.member.project
|
||||
end
|
||||
|
||||
def repository
|
||||
unless project.nil?
|
||||
project.repository
|
||||
end
|
||||
end
|
||||
|
||||
def isGitlabProject?
|
||||
unless repository.nil?
|
||||
repository && repository.gitlab?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue