Merge branch 'hjq_new_course' into szzh
This commit is contained in:
commit
d59c7608cd
|
@ -374,6 +374,9 @@ class FilesController < ApplicationController
|
|||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||
Mailer.run.attachments_added(attachments[:files])
|
||||
end
|
||||
# 更新课程英雄榜得分
|
||||
update_contributor_score(@course, attachments[:files].first)
|
||||
# end
|
||||
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
|
||||
params[:course_attachment_type].each do |type|
|
||||
tag_name = get_tag_name_by_type_number type
|
||||
|
@ -423,6 +426,20 @@ class FilesController < ApplicationController
|
|||
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
|
||||
case type
|
||||
when "1"
|
||||
|
|
|
@ -167,6 +167,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
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]
|
||||
@submit_result = true
|
||||
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
|
||||
|
@ -499,6 +505,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
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
|
||||
@homework = HomeworkCommon.find params[:homework]
|
||||
|
|
|
@ -75,6 +75,50 @@ module ApplicationHelper
|
|||
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
|
||||
# Define the course menu's link class
|
||||
# 不是数组的转化成数组,然后判断当前menu_item是否在给定的列表
|
||||
|
|
|
@ -25,6 +25,10 @@ module CoursesHelper
|
|||
# searchTeacherAndAssistant(project).count
|
||||
end
|
||||
|
||||
def show_nav?(count)
|
||||
count == 0 ? true : false
|
||||
end
|
||||
|
||||
#课程模块需要展示的模块
|
||||
def course_model
|
||||
@nav_dispaly_course_all_label = 1
|
||||
|
@ -733,4 +737,26 @@ module CoursesHelper
|
|||
end
|
||||
desc.html_safe
|
||||
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
|
||||
|
||||
|
|
|
@ -560,4 +560,5 @@ class Attachment < ActiveRecord::Base
|
|||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ class Comment < ActiveRecord::Base
|
|||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :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
|
||||
if self.commented.course
|
||||
|
@ -66,13 +66,24 @@ class Comment < ActiveRecord::Base
|
|||
def set_notify_id(notify_id)
|
||||
@notify_id= notify_id
|
||||
end
|
||||
|
||||
def get_notify_id()
|
||||
return @notify_id
|
||||
end
|
||||
|
||||
def set_notify_is_read(notify_is_read)
|
||||
@notify_is_read = notify_is_read
|
||||
end
|
||||
|
||||
def get_notify_is_read()
|
||||
return @notify_is_read
|
||||
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
|
||||
|
|
|
@ -40,8 +40,10 @@ class Course < ActiveRecord::Base
|
|||
|
||||
has_many :course_activities
|
||||
# 课程消息
|
||||
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 :course_contributor_scores, :dependent => :destroy
|
||||
|
||||
acts_as_taggable
|
||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||
|
|
|
@ -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
|
|
@ -64,7 +64,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
|
||||
|
||||
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_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
@ -263,4 +263,12 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
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
|
||||
|
|
|
@ -74,7 +74,7 @@ class Message < ActiveRecord::Base
|
|||
after_update :update_messages_board
|
||||
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
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -285,4 +285,16 @@ class Message < ActiveRecord::Base
|
|||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
|
||||
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
|
||||
|
|
|
@ -153,6 +153,8 @@ class User < Principal
|
|||
# 邮件邀请状态
|
||||
has_many :invite_lists, :dependent => :destroy
|
||||
# end
|
||||
# 课程贡献榜
|
||||
has_many :course_contributor_scores, :dependent => :destroy
|
||||
|
||||
######added by nie
|
||||
has_many :project_infos, :dependent => :destroy
|
||||
|
|
|
@ -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 %>
|
|
@ -136,50 +136,125 @@
|
|||
</div>
|
||||
|
||||
<div class="subNavBox">
|
||||
<% unless 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 %>
|
||||
<% unless 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 %>
|
||||
<% 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) %>
|
||||
<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 %>
|
||||
<% unless 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 %>
|
||||
<% 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_course_feedback)}", :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 %>
|
||||
<%# 工具栏展开 %>
|
||||
<% 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 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 id="course_description" class="course_description">
|
||||
<h4 ><%= l(:label_course_brief_introduction)%>:</h4>
|
||||
|
@ -278,6 +353,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>
|
||||
|
||||
|
|
|
@ -94,4 +94,6 @@ zh:
|
|||
label_user_name: "用户名称"
|
||||
#setting end
|
||||
|
||||
label_course_poll: 课程问卷
|
||||
label_course_poll: 课程问卷
|
||||
|
||||
label_homework_committed: 你已经提交过作品,如果你想修改作品的话,可以在作品列表页面对作品信息进行修改。
|
|
@ -1,25 +1,25 @@
|
|||
class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration
|
||||
def up
|
||||
# count = CourseActivity.all.count/30 + 1
|
||||
# for i in 1 ... count do
|
||||
# transaction do
|
||||
# CourseActivity.page(i).per(30).each do |course_act|
|
||||
# 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.created_at = course_act.created_at
|
||||
# org_activity.save
|
||||
# else
|
||||
# OrgActivity.create(:user_id => course_act.user_id,
|
||||
# :org_act_id => course_act.course_act_id,
|
||||
# :org_act_type => course_act.course_act_type,
|
||||
# :container_id => course_act.course_id,
|
||||
# :container_type => 'Course',
|
||||
# :created_at => course_act.created_at,
|
||||
# :updated_at => course_act.updated_at)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
count = CourseActivity.all.count/30 + 1
|
||||
for i in 1 ... count do
|
||||
transaction do
|
||||
CourseActivity.page(i).per(30).each do |course_act|
|
||||
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.created_at = course_act.created_at
|
||||
org_activity.save
|
||||
else
|
||||
OrgActivity.create(:user_id => course_act.user_id,
|
||||
:org_act_id => course_act.course_act_id,
|
||||
:org_act_type => course_act.course_act_type,
|
||||
:container_id => course_act.course_id,
|
||||
:container_type => 'Course',
|
||||
:created_at => course_act.created_at,
|
||||
:updated_at => course_act.updated_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
class AddTotalScoreToCourseContributorScore < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :course_contributor_scores, :total_score, :integer
|
||||
end
|
||||
end
|
|
@ -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
|
68
db/schema.rb
68
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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|
|
||||
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
|
||||
|
||||
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|
|
||||
t.string "commented_type", :limit => 30, :default => "", :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
|
||||
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|
|
||||
t.string "name"
|
||||
t.integer "course_id"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,60 +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
|
||||
@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
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ module Trustie
|
|||
base.class_eval {
|
||||
#before_create :add_gitlab_user
|
||||
#before_destroy :delete_gitlab_user
|
||||
before_save :change_gitlab_user
|
||||
#before_save :change_gitlab_user
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -22,10 +22,10 @@ module Trustie
|
|||
def delete_gitlab_user
|
||||
del_user(self)
|
||||
end
|
||||
|
||||
def change_gitlab_user
|
||||
change_password(self.gid, self.hashed_password, self.salt)
|
||||
end
|
||||
#
|
||||
#def change_gitlab_user
|
||||
# change_password(self.gid, self.hashed_password, self.salt)
|
||||
#end
|
||||
|
||||
def g
|
||||
@g ||= ::Gitlab.client
|
||||
|
|
|
@ -1306,3 +1306,60 @@ function cancel_org_course_relation(id, courseId){
|
|||
// 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();
|
||||
});
|
|
@ -1166,4 +1166,13 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
|
|||
.questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;}
|
||||
.fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;}
|
||||
.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;}
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CourseContributorScore, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue