Merge branch 'hjq_new_course' into szzh

This commit is contained in:
huang 2015-11-27 14:47:42 +08:00
commit d59c7608cd
29 changed files with 6119 additions and 98 deletions

View File

@ -374,6 +374,9 @@ class FilesController < ApplicationController
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Mailer.run.attachments_added(attachments[:files]) Mailer.run.attachments_added(attachments[:files])
end end
# 更新课程英雄榜得分
update_contributor_score(@course, attachments[:files].first)
# end
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array) if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
params[:course_attachment_type].each do |type| params[:course_attachment_type].each do |type|
tag_name = get_tag_name_by_type_number type tag_name = get_tag_name_by_type_number type
@ -423,6 +426,20 @@ class FilesController < ApplicationController
end end
end end
def update_contributor_score(course, file )
unless file.author.allowed_to?(:as_teacher, course)
course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course.id, file.author.id).first
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course.id, :user_id => file.author.id, :message_num => 0, :message_reply_num => 0,
:news_reply_num => 0, :resource_num => 5, :journal_num => 0, :journal_reply_num => 0, :total_score => 5)
else
score = course_contributor_score.resource_num + 5
total_score = course_contributor_score.total_score + 5
course_contributor_score.update_attributes(:resource_num => score, :total_score => total_score)
end
end
end
def get_tag_name_by_type_number type def get_tag_name_by_type_number type
case type case type
when "1" when "1"

View File

@ -167,6 +167,12 @@ class StudentWorkController < ApplicationController
end end
def create def create
# 提交作品前先判断是否已经提交
if hsd_committed_work?(User.current.id, @homework.id)
flash[:notice] = l(:notice_successful_create)
redirect_to edit_student_work_url(params[:student_work])
return
end
if params[:student_work] if params[:student_work]
@submit_result = true @submit_result = true
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id] student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
@ -499,6 +505,12 @@ class StudentWorkController < ApplicationController
end end
private private
def hsd_committed_work?(user, homework)
sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first
sw.nil? ? result = false : result = true
result
end
#获取作业 #获取作业
def find_homework def find_homework
@homework = HomeworkCommon.find params[:homework] @homework = HomeworkCommon.find params[:homework]

View File

@ -75,6 +75,50 @@ module ApplicationHelper
end end
end end
# 更新课程英雄榜得分
# user传过来必须是学生
def course_member_score(course_id,user_id,type)
course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course_id, user_id).first
case type
when "JournalForMessage"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
:news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0, :total_score => 1)
else
score = course_contributor_score.journal_num + 1
total_score = course_contributor_score.total_score + 1
course_contributor_score.update_attributes(:journal_num => score, :total_score => total_score)
end
when "Message"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 2, :message_reply_num => 0,
:news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 2)
else
score = course_contributor_score.message_num + 2
total_score = course_contributor_score.total_score + 2
course_contributor_score.update_attributes(:message_num => score, :total_score => total_score)
end
when "MessageReply"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 1,
:news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
else
score = course_contributor_score.message_reply_num + 1
total_score = course_contributor_score.total_score + 1
course_contributor_score.update_attributes(:message_reply_num => score, :total_score => total_score)
end
when "NewReply"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
:news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
else
score = course_contributor_score.news_reply_num + 1
total_score = course_contributor_score.total_score + 1
course_contributor_score.update_attributes(:news_reply_num => score, :total_score => total_score)
end
end
end
# Added by young # Added by young
# Define the course menu's link class # Define the course menu's link class
# 不是数组的转化成数组然后判断当前menu_item是否在给定的列表 # 不是数组的转化成数组然后判断当前menu_item是否在给定的列表

View File

@ -25,6 +25,10 @@ module CoursesHelper
# searchTeacherAndAssistant(project).count # searchTeacherAndAssistant(project).count
end end
def show_nav?(count)
count == 0 ? true : false
end
#课程模块需要展示的模块 #课程模块需要展示的模块
def course_model def course_model
@nav_dispaly_course_all_label = 1 @nav_dispaly_course_all_label = 1
@ -733,4 +737,26 @@ module CoursesHelper
end end
desc.html_safe desc.html_safe
end end
# 学生按作业总分排序取前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
AND homework_commons.course_id = #{course.id}
AND student_works.user_id = members.user_id
) AS score
FROM members
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"
homework_scores = Member.find_by_sql(sql_select)
end
def contributor_course_scor(course_id)
ccs = CourseContributorScore.where("course_id =?", course_id).order("total_score desc") .limit(9)
end
end end

View File

@ -560,4 +560,5 @@ class Attachment < ActiveRecord::Base
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id) self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
end end
end end
end end

View File

@ -35,7 +35,7 @@ class Comment < ActiveRecord::Base
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :commented, :author, :comments validates_presence_of :commented, :author, :comments
safe_attributes 'comments' safe_attributes 'comments'
after_create :send_mail, :act_as_system_message after_create :send_mail, :act_as_system_message, :act_as_student_score
def act_as_system_message def act_as_system_message
if self.commented.course if self.commented.course
@ -66,13 +66,24 @@ class Comment < ActiveRecord::Base
def set_notify_id(notify_id) def set_notify_id(notify_id)
@notify_id= notify_id @notify_id= notify_id
end end
def get_notify_id() def get_notify_id()
return @notify_id return @notify_id
end end
def set_notify_is_read(notify_is_read) def set_notify_is_read(notify_is_read)
@notify_is_read = notify_is_read @notify_is_read = notify_is_read
end end
def get_notify_is_read() def get_notify_is_read()
return @notify_is_read return @notify_is_read
end end
# 课程成员得分(英雄榜)
def act_as_student_score
unless self.author.allowed_to?(:as_teacher, self.commented.course)
course_member_score(self.commented.course.id, self.author_id, "NewReply")
end
end
end end

View File

@ -42,6 +42,8 @@ class Course < ActiveRecord::Base
# 课程消息 # 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
has_many :exercises, :dependent => :destroy has_many :exercises, :dependent => :destroy
# 课程贡献榜
has_many :course_contributor_scores, :dependent => :destroy
acts_as_taggable acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy acts_as_nested_set :order => 'name', :dependent => :destroy

View File

@ -0,0 +1,5 @@
class CourseContributorScore < ActiveRecord::Base
attr_accessible :course_id, :journal_num, :journal_reply_num, :message_num, :message_reply_num, :news_reply_num, :resource_num, :user_id, :total_score
belongs_to :course
belongs_to :user
end

View File

@ -64,7 +64,7 @@ class JournalsForMessage < ActiveRecord::Base
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
validates :notes, presence: true, if: :is_homework_jour? validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score
after_create :reset_counters! after_create :reset_counters!
after_destroy :reset_counters! after_destroy :reset_counters!
after_save :be_user_score after_save :be_user_score
@ -263,4 +263,12 @@ class JournalsForMessage < ActiveRecord::Base
end end
end end
# 课程成员得分(英雄榜)
def act_as_student_score
unless self.user.allowed_to?(:as_teacher, self.jour)
course_member_score(self.jour_id, self.user_id, "JournalForMessage")
end
end
end end

View File

@ -74,7 +74,7 @@ class Message < ActiveRecord::Base
after_update :update_messages_board after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score
#before_save :be_user_score #before_save :be_user_score
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
@ -285,4 +285,16 @@ class Message < ActiveRecord::Base
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
end end
# 课程成员得分(英雄榜)
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")
else
# 回帖
course_member_score(self.course.id, self.author_id, "MessageReply")
end
end
end
end end

View File

@ -153,6 +153,8 @@ class User < Principal
# 邮件邀请状态 # 邮件邀请状态
has_many :invite_lists, :dependent => :destroy has_many :invite_lists, :dependent => :destroy
# end # end
# 课程贡献榜
has_many :course_contributor_scores, :dependent => :destroy
######added by nie ######added by nie
has_many :project_infos, :dependent => :destroy has_many :project_infos, :dependent => :destroy

View File

@ -0,0 +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 ml10"%>
<%= 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 ml10" %>
<%= 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 ml10" %>
<% 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 ml10" %>
<%= 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 ml10" %>
<%= 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 ml10"%>
<%= 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 ml10"%>
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
</div>
<% end %>

View File

@ -136,50 +136,125 @@
</div> </div>
<div class="subNavBox"> <div class="subNavBox">
<% unless show_nav?(@course.course_activities.count) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %> <%= 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"%> <%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
</div> </div>
<% end %>
<% unless show_nav?(@course.homework_commons.count) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%> <%= 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 "(#{@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> </div>
<% end %>
<% unless show_nav?(@course.news.count) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02" %> <%= 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 "(#{@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> </div>
<% end %>
<% unless show_nav?(course_file_num) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02" %> <%= 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' %> <%= 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)) %> <% 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')--> <!--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 %> <% end %>
</div> </div>
<% end %>
<% unless show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %> <%= 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 "(#{@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> </div>
<% end %>
<% unless show_nav?(course_feedback_count) %>
<div class="subNav"> <div class="subNav">
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %> <%= 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_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_course_feedback)}", :id => "course_jour_count"%>
</div> </div>
<% end %>
<% unless show_nav?(course_poll_count) %>
<div class="subNav"> <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 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 "(#{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> </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"> <div class="subNav">
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02"%> <%= 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 "(#{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> </div>
<% end %>
<%# 工具栏展开 %>
<% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 ||
course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 %>
<div class="subNav subNav_jiantou" id="expand_tools_expand" nhtype="toggle4cookie" data-id="expand_tool_more" data-target="#navContentCourse" data-val="retract"><%= l(:label_project_more) %></div>
<ul class="navContent" id="navContentCourse">
<%= render 'courses/tool_expand', :locals => {:is_teacher => is_teacher, :course_file_num => course_file_num} %>
</ul>
<% end %>
</div><!--项目侧导航 end--> </div><!--项目侧导航 end-->
<%# 课程贡献榜 %>
<div class="cl"></div> <div class="cl"></div>
<% unless contributor_course_scor(@course.id).count == 0 %>
<ul class="rankList">
<h4>课程贡献榜</h4>
<% contributor_course_scor(@course.id).each do |contributor_score| %>
<% unless contributor_score.total_score ==0 %>
<li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a>
<p><a href="javascript:void:(0);"><%=link_to contributor_score.user, user_path(contributor_score.user), :title => contributor_score.user %></a></p>
<p><span class="c_green" style="cursor:pointer">
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"><%= contributor_score.total_score.to_i %></a></span></p>
<div style="display: none" class="numIntro">
<% unless contributor_score.resource_num == 0 %>
课程资源:<%= contributor_score.resource_num %><br />
<% end %>
<% unless contributor_score.message_num == 0 %>
课程讨论:<%= contributor_score.message_num %><br />
<% end %>
<% unless contributor_score.message_reply_num == 0 %>
评论回复:<%= contributor_score.message_reply_num %><br />
<% end %>
<% unless contributor_score.journal_num == 0 %>
课程留言:<%= contributor_score.journal_num %><br />
<% end %>
<% unless contributor_score.news_reply_num == 0 %>
课程通知:<%= contributor_score.news_reply_num %><br />
<% end %>
</div>
</li>
<% end %>
<% end %>
<div class="cl"></div>
</ul>
<% end %>
<% hero_homework_scores = hero_homework_score(@course, "desc") %>
<% unless hero_homework_scores.map(&:score).detect{|s| s != nil}.nil? %>
<ul class="rankList">
<h4>课程英雄榜</h4>
<% hero_homework_scores.each do |student_score| %>
<% unless student_score.score.nil? %>
<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), :title => student_score.user %></a></p>
<p><span class="c_red" style="cursor:pointer" title="作业总分:<%= student_score.score %>"><%= student_score.score.to_i %></span></p>
</li>
<% end %>
<% end %>
<div class="cl"></div>
</ul>
<% end %>
<div class="project_intro"> <div class="project_intro">
<div id="course_description" class="course_description"> <div id="course_description" class="course_description">
<h4 ><%= l(:label_course_brief_introduction)%></h4> <h4 ><%= l(:label_course_brief_introduction)%></h4>
@ -278,6 +353,16 @@
$('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls"); $('#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> </script>

View File

@ -95,3 +95,5 @@ zh:
#setting end #setting end
label_course_poll: 课程问卷 label_course_poll: 课程问卷
label_homework_committed: 你已经提交过作品,如果你想修改作品的话,可以在作品列表页面对作品信息进行修改。

View File

@ -1,25 +1,25 @@
class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration
def up def up
# count = CourseActivity.all.count/30 + 1 count = CourseActivity.all.count/30 + 1
# for i in 1 ... count do for i in 1 ... count do
# transaction do transaction do
# CourseActivity.page(i).per(30).each do |course_act| CourseActivity.page(i).per(30).each do |course_act|
# if course_act.course_act_type == 'Message' && !course_act.course_act.parent_id.nil? if course_act.course_act_type == 'Message' && !course_act.course_act.parent_id.nil?
# org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{course_act.course_act.parent.id}").first org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{course_act.course_act.parent.id}").first
# org_activity.created_at = course_act.created_at org_activity.created_at = course_act.created_at
# org_activity.save org_activity.save
# else else
# OrgActivity.create(:user_id => course_act.user_id, OrgActivity.create(:user_id => course_act.user_id,
# :org_act_id => course_act.course_act_id, :org_act_id => course_act.course_act_id,
# :org_act_type => course_act.course_act_type, :org_act_type => course_act.course_act_type,
# :container_id => course_act.course_id, :container_id => course_act.course_id,
# :container_type => 'Course', :container_type => 'Course',
# :created_at => course_act.created_at, :created_at => course_act.created_at,
# :updated_at => course_act.updated_at) :updated_at => course_act.updated_at)
# end end
# end end
# end end
# end end
end end
def down def down

View File

@ -0,0 +1,9 @@
class ChangecolumnOfExerciseQuestion < ActiveRecord::Migration
def up
change_column :exercise_questions, :question_title, :text
change_column :exercises, :exercise_name, :text
end
def down
end
end

View File

@ -0,0 +1,16 @@
class CreateCourseContributorScores < ActiveRecord::Migration
def change
create_table :course_contributor_scores do |t|
t.integer :course_id
t.integer :user_id
t.integer :message_num
t.integer :message_reply_num
t.integer :news_reply_num
t.integer :resource_num
t.integer :journal_num
t.integer :journal_reply_num
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
class AddTotalScoreToCourseContributorScore < ActiveRecord::Migration
def change
add_column :course_contributor_scores, :total_score, :integer
end
end

View File

@ -0,0 +1,36 @@
class AddCourseContributorTotalScore < 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_score => total)
end
end
end
end
# end
# end
end
def down
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151120134208) do ActiveRecord::Schema.define(:version => 20151127011351) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -241,6 +241,58 @@ ActiveRecord::Schema.define(:version => 20151120134208) do
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
create_table "code_review_assignments", :force => true do |t|
t.integer "issue_id"
t.integer "change_id"
t.integer "attachment_id"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.string "action_type"
t.integer "changeset_id"
end
create_table "code_review_project_settings", :force => true do |t|
t.integer "project_id"
t.integer "tracker_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "updated_by"
t.boolean "hide_code_review_tab", :default => false
t.integer "auto_relation", :default => 1
t.integer "assignment_tracker_id"
t.text "auto_assign"
t.integer "lock_version", :default => 0, :null => false
t.boolean "tracker_in_review_dialog", :default => false
end
create_table "code_review_user_settings", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.integer "mail_notification", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "code_reviews", :force => true do |t|
t.integer "project_id"
t.integer "change_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "line"
t.integer "updated_by_id"
t.integer "lock_version", :default => 0, :null => false
t.integer "status_changed_from"
t.integer "status_changed_to"
t.integer "issue_id"
t.string "action_type"
t.string "file_path"
t.string "rev"
t.string "rev_to"
t.integer "attachment_id"
t.integer "file_count", :default => 0, :null => false
t.boolean "diff_all"
end
create_table "comments", :force => true do |t| create_table "comments", :force => true do |t|
t.string "commented_type", :limit => 30, :default => "", :null => false t.string "commented_type", :limit => 30, :default => "", :null => false
t.integer "commented_id", :default => 0, :null => false t.integer "commented_id", :default => 0, :null => false
@ -330,6 +382,20 @@ ActiveRecord::Schema.define(:version => 20151120134208) do
t.integer "container_id", :default => 0 t.integer "container_id", :default => 0
end end
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
t.integer "message_num"
t.integer "message_reply_num"
t.integer "news_reply_num"
t.integer "resource_num"
t.integer "journal_num"
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| create_table "course_groups", :force => true do |t|
t.string "name" t.string "name"
t.integer "course_id" t.integer "course_id"

1856
db/schema.rb.BASE.rb Normal file

File diff suppressed because it is too large Load Diff

1862
db/schema.rb.LOCAL.rb Normal file

File diff suppressed because it is too large Load Diff

1810
db/schema.rb.REMOTE.rb Normal file

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,9 @@ module Trustie
def add_gitlab_member def add_gitlab_member
if isGitlabProject? if isGitlabProject?
@g ||= ::Gitlab.client @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 ) @g.add_team_member(project.gpid, self.member.user.gid, self.role.to_gitlab_role )
end end
end end

View File

@ -11,7 +11,7 @@ module Trustie
base.class_eval { base.class_eval {
#before_create :add_gitlab_user #before_create :add_gitlab_user
#before_destroy :delete_gitlab_user #before_destroy :delete_gitlab_user
before_save :change_gitlab_user #before_save :change_gitlab_user
} }
end end
@ -22,10 +22,10 @@ module Trustie
def delete_gitlab_user def delete_gitlab_user
del_user(self) del_user(self)
end end
#
def change_gitlab_user #def change_gitlab_user
change_password(self.gid, self.hashed_password, self.salt) # change_password(self.gid, self.hashed_password, self.salt)
end #end
def g def g
@g ||= ::Gitlab.client @g ||= ::Gitlab.client

View File

@ -1306,3 +1306,60 @@ function cancel_org_course_relation(id, courseId){
// alert('<%= @course.id%>') // alert('<%= @course.id%>')
// }) // })
//}) //})
//项目点击展开
function expand_tools_expand(content) {
if (content == "invit") {
$("#expand_tools_expand_invit").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
$("#expand_tools_expand_invit").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
$("#expand_tools_expand_invit").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
}
else {
// $("#expand_tools_expand").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd");
// $("#expand_tools_expand").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt");
// $("#expand_tools_expand").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500);
$("#navContent").toggle(500);
}
// 修改数字控制速度, slideUp(500)控制卷起速度
}
//通过cookie存储伸开形式
$(function(){
var personalized_expand_key = "personalized_expand";
function personalized_init(){
var personalized_map = cookieget(personalized_expand_key);
if(personalized_map!=false){
personalized_map = JSON.parse(personalized_map);
$("*[nhtype='toggle4cookie']").each(function(){
var personalized_id=$(this).data('id');
var val = personalized_map[personalized_id];
if(val!=undefined && val!=$(this).data('val')){
personalized_click($(this),0);
}
});
}
}
function personalized_click(obj,timeout){
var target = $(obj.data('target'));
var oldval = obj.data('val');
var val='';
if(oldval=='expand'){val='retract';}else{val='expand';}
obj.data('val',val);
var personalized_map = cookieget(personalized_expand_key);
if(personalized_map == false){
personalized_map={};
}else{
personalized_map = JSON.parse(personalized_map);
}
var personalized_id=obj.data('id');
personalized_map[personalized_id]=val;
cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
target.toggle(timeout);
}
$("*[nhtype='toggle4cookie']").on('click',function(){
personalized_click($(this),500);
});
personalized_init();
});

View File

@ -1167,3 +1167,12 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
.fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;} .fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;}
.mr130 {margin-right:130px;} .mr130 {margin-right:130px;}
.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } .ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; }
/*20151123课程排行榜Tim*/
.courseMenuSetting {background:url(../images/homepage_icon2.png) -190px -365px no-repeat; width:15px; height:15px; margin-top:3px; float:right; margin-right:5px;}
.courseMenuSetting:hover {background:url(../images/homepage_icon2.png) -190px -407px no-repeat;}
.rankList {width:220px; padding:10px; background-color:#ffffff; margin-top:10px;}
.rankList li {width:73px; padding:8px 0px 0px 0px; text-align:center; float:left; position:relative;}
.rankList li p {width:100%; overflow:hidden; white-space:normal; text-overflow:ellipsis; color:#585858;word-wrap: normal; word-break: normal;}
.rankPortrait {border-radius:50%; width:35px; height:35px;}
.numIntro {position:absolute; text-align:left; z-index:999; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); border:1px solid #eaeaea; background-color:#ffffff; padding:3px 5px; left:15px; color:#585858; white-space: nowrap;}

View File

@ -0,0 +1,13 @@
FactoryGirl.define do
factory :course_contributor_score do
course_id 1
user_id 1
message_num 1
message_reply_num 1
news_reply_num 1
resource_num 1
journal_num 1
journal_reply_num 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CourseContributorScore, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end