课程活跃度中添加作业留言得分
This commit is contained in:
parent
fee7cc4b2c
commit
085729f91b
|
@ -115,6 +115,15 @@ module ApplicationHelper
|
|||
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 "HomeworkCommon"
|
||||
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 => 0, :journal_reply_num => 0, :homework_journal_num => 1 , :total_score => 1)
|
||||
else
|
||||
score = course_contributor_score.homework_journal_num + 1
|
||||
total_score = course_contributor_score.total_score + 1
|
||||
course_contributor_score.update_attributes(:homework_journal_num => score, :total_score => total_score)
|
||||
end
|
||||
when "JournalForMessage"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
|
||||
|
|
|
@ -1,5 +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
|
||||
attr_accessible :course_id, :journal_num, :journal_reply_num, :message_num, :message_reply_num, :news_reply_num, :resource_num, :user_id, :total_score, :homework_journal_num
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
|
@ -285,8 +285,10 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
# 课程成员得分(英雄榜)
|
||||
def act_as_student_score
|
||||
if !self.user.allowed_to?(:as_teacher, self.jour) && self.jour_type == "Course"
|
||||
if self.jour_type == "Course"
|
||||
course_member_score(self.jour_id, self.user_id, "JournalForMessage")
|
||||
elsif self.jour_type == "HomeworkCommon"
|
||||
course_member_score(self.jour_id, self.user_id, "HomeworkCommon")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddHomeworkJournalToCourseContributorScores < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :course_contributor_scores, :homework_journal_num, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||
ActiveRecord::Schema.define(:version => 20160303103231) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -432,9 +432,10 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
|||
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.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "total_score"
|
||||
t.integer "homework_journal_num", :default => 0
|
||||
end
|
||||
|
||||
create_table "course_groups", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue