diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 1d328c1e9..61f6118ad 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -764,8 +764,8 @@ class UsersController < ApplicationController
homework_detail_programing.save if homework_detail_programing
homework_detail_group.save if homework_detail_group
if params[:quotes] && !params[:quotes].blank?
- homework = HomeworkCommon.find params[:quotes].to_i
- homework.update_attribute(:quotes, homework.quotes+1)
+ quotes_homework = HomeworkCommon.find params[:quotes].to_i
+ quotes_homework.update_attribute(:quotes, quotes_homework.quotes+1)
end
if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => homework.course_id)
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 6fb9380e7..cbc514df6 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -856,7 +856,9 @@ module CoursesHelper
end
def contributor_course_scor(course_id)
- ccs = CourseContributorScore.where("course_id =?", course_id).order("total_score desc") .limit(9)
+ ccs = CourseContributorScore.find_by_sql("SELECT * FROM `course_contributor_scores` where course_id = #{course_id} order by
+ (message_num*2 + message_reply_num + news_reply_num + news_num +
+ resource_num*5 + journal_num + homework_journal_num ) desc limit 9;")
end
end
diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb
index aedeec5ef..52a971826 100644
--- a/app/views/courses/_tool_expand.html.erb
+++ b/app/views/courses/_tool_expand.html.erb
@@ -8,7 +8,7 @@
<% end %>
<% if show_nav?(@course.news.count) %>
- <%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f12 c_blue02 ml10 fn" %>
+ <%= link_to "通知", course_news_index_path(@course), :class => "f12 c_blue02 ml10 fn" %>
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
<% end %>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index ceb526f44..2a44f2980 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -85,7 +85,7 @@
<% end %>
<% unless show_nav?(@course.news.count) %>
- <%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02" %>
+ <%= link_to "通知", 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( "", new_course_news_path(@course,:is_new=>1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
@@ -142,58 +142,60 @@
<% unless contributor_course_scor(@course.id).count == 0 %>
-
-
-
积分规则
- 资源得分:资源数 x 5
- 发帖得分:发帖数 x 2
- 回帖得分:回复数 x 1
- 通知得分:通知数 x 1
- 课程留言得分:留言数 x 1
- 作业留言得分:留言数 x 1
- 通知回复得分:回复数 x 1
+
课程活跃度
+ 积分规则
+
+
+
积分规则
+ 资源发布:资源数 x 5
+ 问答发布:发帖数 x 2
+ 通知发布:通知数 x 1
+ 问答回复:回复数 x 1
+ 作业留言:留言数 x 1
+ 通知留言:留言数 x 1
+ 课程留言:留言数 x 1
总得分为以上得分之和
<% contributor_course_scor(@course.id).each do |contributor_score| %>
- <% unless contributor_score.total_score ==0 %>
+ <% total_score = contributor_score.resource_num.to_i * 5 + contributor_score.message_num.to_i * 2 +
+ contributor_score.message_reply_num.to_i * 1 + contributor_score.journal_num.to_i * 1 +
+ + contributor_score.homework_journal_num.to_i * 1 + contributor_score.news_reply_num.to_i * 1 +
+ contributor_score.news_num.to_i * 1 %>
+ <% unless total_score ==0 %>
- <%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %>
<%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %>
- <%=total_score = contributor_score.resource_num.to_i * 5 + contributor_score.message_num.to_i * 2 +
- contributor_score.message_reply_num.to_i * 1 + contributor_score.journal_num.to_i * 1 +
- + contributor_score.homework_journal_num.to_i * 1 + contributor_score.news_reply_num.to_i * 1 +
- contributor_score.news_num.to_i * 1 %>
-
-
-
-
-
-
-
-
-
积分计算
+ <%=total_score %>
+
+
积分计算
<%# unless contributor_score.resource_num.to_i == 0 %>
- 课程资源:资源数 x 5 = <%= contributor_score.resource_num.to_i %> x 5 = <%= contributor_score.resource_num.to_i * 5 %>
- <%# end %>
- <%# unless contributor_score.message_num.to_i == 0 %>
- 课程讨论:发帖数 x 2 = <%= contributor_score.message_num.to_i %> x 2 = <%= contributor_score.message_num.to_i * 2 %>
- <%# end %>
- <%# unless contributor_score.message_reply_num.to_i == 0 %>
- 评论回复:回复数 x 1 = <%= contributor_score.message_reply_num.to_i %> x 1 = <%= contributor_score.message_reply_num.to_i %>
- <%# end %>
- <%# unless contributor_score.journal_num.to_i == 0 %>
- 课程留言:留言数 x 1 = <%= contributor_score.journal_num.to_i %> x 1 = <%= contributor_score.journal_num.to_i %>
- <%# end %>
- <%# unless contributor_score.homework_journal_num.to_i == 0 %>
- 作业留言:留言数 x 1 = <%= contributor_score.homework_journal_num.to_i %> x 1 = <%= contributor_score.homework_journal_num.to_i %>
- <%# end %>
- <%# unless contributor_score.news_reply_num.to_i == 0 %>
- 发布通知:通知数 x 1 = <%= contributor_score.news_num.to_i %> x 1 = <%= contributor_score.news_num.to_i %>
- 通知回复:通知数 x 1 = <%= contributor_score.news_reply_num.to_i %> x 1 = <%= contributor_score.news_reply_num.to_i %>
- <%# end %>
- 总得分:<%=total_score %>
+
+ 资源发布数 x 5 = <%= contributor_score.resource_num.to_i %> x 5 = <%= contributor_score.resource_num.to_i * 5 %>
+ <%# end %>
+ <%# unless contributor_score.message_num.to_i == 0 %>
+ 问答发布数 x 2 = <%= contributor_score.message_num.to_i %> x 2 = <%= contributor_score.message_num.to_i * 2 %>
+ 通知发布数 x 1 = <%= contributor_score.news_num.to_i %> x 1 = <%= contributor_score.news_num.to_i %>
+ <%# end %>
+ <%# unless contributor_score.message_reply_num.to_i == 0 %>
+ 问答回帖数 x 1 = <%= contributor_score.message_reply_num.to_i %> x 1 = <%= contributor_score.message_reply_num.to_i %>
+ 作业留言数 x 1 = <%= contributor_score.homework_journal_num.to_i %> x 1 = <%= contributor_score.homework_journal_num.to_i %>
+ 通知留言数 x 1 = <%= contributor_score.news_reply_num.to_i %> x 1 = <%= contributor_score.news_reply_num.to_i %>
+ <%# end %>
+ <%# unless contributor_score.journal_num.to_i == 0 %>
+ 课程留言数 x 1 = <%= contributor_score.journal_num.to_i %> x 1 = <%= contributor_score.journal_num.to_i %>
+ <%# end %>
+ <%# unless contributor_score.homework_journal_num.to_i == 0 %>
+
+ <%# end %>
+ <%# unless contributor_score.news_reply_num.to_i == 0 %>
+
+
+ <%# end %>
+ 总得分:<%=total_score %>
+
+
<% end %>
@@ -205,12 +207,17 @@
<% hero_homework_scores = hero_homework_score(@course, "desc") %>
<% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %>
-
+
+
+
积分规则
+ 英雄榜的得分是每个同学作业的得分总和
+
<% hero_homework_scores.each do |student_score| %>
<% if student_score.score.to_i != 0 %>
- <%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %>
<%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %>
- <%= student_score.score<0 ? 0 : student_score.score.to_i %>
+ <%= student_score.score<0 ? 0 : student_score.score.to_i %>
<% end %>
<% end %>
diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb
index 51cede682..0e056c972 100644
--- a/app/views/organizations/_org_course_homework.html.erb
+++ b/app/views/organizations/_org_course_homework.html.erb
@@ -158,7 +158,7 @@
<%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
- 分数:<%=format("%.1f",score<0 ? 0 : score) %>分
+ 分数:<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分
<% if i == 4 %>
<% break %>
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb
index 7c5aa5e4f..d42dc152d 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -157,7 +157,7 @@
<%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
- 分数:<%=format("%.1f",score<0 ? 0 : score) %>分
+ 分数:<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分
<% if i == 4 %>
<% break %>
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index 8329e8432..0c2856c89 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -161,7 +161,7 @@
<%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
- 分数:<%=format("%.1f",score<0 ? 0 : score) %>分
+ 分数:<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分
<% if i == 4 %>
<% break %>
diff --git a/db/migrate/20160304200639_update_contributor.rb b/db/migrate/20160304234903_uodapte_contributor_course.rb
similarity index 91%
rename from db/migrate/20160304200639_update_contributor.rb
rename to db/migrate/20160304234903_uodapte_contributor_course.rb
index d90699b91..e0f86550d 100644
--- a/db/migrate/20160304200639_update_contributor.rb
+++ b/db/migrate/20160304234903_uodapte_contributor_course.rb
@@ -1,4 +1,4 @@
-class UpdateContributor < ActiveRecord::Migration
+class UodapteContributorCourse < ActiveRecord::Migration
def up
Course.all.each do |course|
if course.course_activities.count > 1
@@ -21,7 +21,7 @@ class UpdateContributor < ActiveRecord::Migration
# 课程留言数
journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.user_id, course.id, "Course").count * 1
# 作业留言
- journal_homework_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.user_id, course.id, "HomeworkCommon").count * 1
+ journal_homework_count = JournalsForMessage.find_by_sql("SELECT jfm.* FROM `journals_for_messages` jfm, homework_commons hc where hc.id = jfm.jour_id and hc.course_id =#{course.id} and jfm.user_id =#{s.user_id} and jfm.jour_type ='HomeworkCommon';").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
diff --git a/db/schema.rb b/db/schema.rb
index c21580c90..76dd8e19c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20160304154643) do
+ActiveRecord::Schema.define(:version => 20160304234903) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -1387,6 +1387,7 @@ ActiveRecord::Schema.define(:version => 20160304154643) do
t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0
+ t.integer "act_num", :default => 0
t.integer "attach_num", :default => 0
t.datetime "commit_time"
end
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index a0bca31b0..8e83f2e18 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1285,3 +1285,8 @@ a.chooseActive {background-color:#269ac9; color:#ffffff;}
.popupClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:10px; top:5px;}
.subjectType {width:70px; text-align:center;}
.subjectCount {width:65px; text-align:center;}
+a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: normal;}
+.contributor_course_innor{font-size: 12px;color: #888;padding-left: 36px;}
+.hero_course_innor{font-size: 12px;color: #888;padding-left:77px;}
+.contributor_course_calculate{padding-left: 54px; font-size: 12px;color: #888}
+.color_888{color: #888}