Merge branch 'develop' into hjq_new_course

This commit is contained in:
huang 2016-03-08 16:17:18 +08:00
commit f022950408
10 changed files with 71 additions and 56 deletions

View File

@ -764,8 +764,8 @@ class UsersController < ApplicationController
homework_detail_programing.save if homework_detail_programing homework_detail_programing.save if homework_detail_programing
homework_detail_group.save if homework_detail_group homework_detail_group.save if homework_detail_group
if params[:quotes] && !params[:quotes].blank? if params[:quotes] && !params[:quotes].blank?
homework = HomeworkCommon.find params[:quotes].to_i quotes_homework = HomeworkCommon.find params[:quotes].to_i
homework.update_attribute(:quotes, homework.quotes+1) quotes_homework.update_attribute(:quotes, quotes_homework.quotes+1)
end end
if params[:is_in_course] == "1" if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => homework.course_id) redirect_to homework_common_index_path(:course => homework.course_id)

View File

@ -856,7 +856,9 @@ module CoursesHelper
end end
def contributor_course_scor(course_id) 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
end end

View File

@ -8,7 +8,7 @@
<% end %> <% end %>
<% if show_nav?(@course.news.count) %> <% if show_nav?(@course.news.count) %>
<div class="subNav"> <div class="subNav">
<%= 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 %> <%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
</div> </div>
<% end %> <% end %>

View File

@ -85,7 +85,7 @@
<% end %> <% end %>
<% unless show_nav?(@course.news.count) %> <% 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 "通知", 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( "", new_course_news_path(@course,:is_new=>1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %> <%= link_to( "", new_course_news_path(@course,:is_new=>1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
</div> </div>
@ -142,59 +142,61 @@
<div class="cl"></div> <div class="cl"></div>
<% unless contributor_course_scor(@course.id).count == 0 %> <% unless contributor_course_scor(@course.id).count == 0 %>
<ul class="rankList"> <ul class="rankList">
<h4>课程活跃度<a style="float: right; color: #7f7f7f; font-size: 12px;" onmouseover ="message_titile_show2($(this),event)" onmouseout ="message_titile_hide2($(this))">积分规则</a></h4> <h4>课程活跃度
<div style="display: none" class="numIntro"> <a class="contributor_course" onmouseover ="message_titile_show2($(this),event)" onmouseout ="message_titile_hide2($(this))">积分规则</a>
<div style="padding-left: 35px; font-size: 14px;color: #3b3b3b">积分规则</div> </h4>
资源得分:资源数 x 5 </br> <div style="display: none;padding: 5px;" class="numIntro color_888">
发帖得分:发帖数 x 2 </br> <div class="contributor_course_innor">积分规则</div>
回帖得分:回复数 x 1 </br> 资源发布:资源数 x 5 </br>
通知得分:通知数 x 1 </br> 问答发布:发帖数 x 2 </br>
课程留言得分:留言数 x 1 </br> 通知发布:通知数 x 1 </br>
作业留言得分:留言数 x 1 </br> 问答回复:回复数 x 1 </br>
通知回复得分:回复数 x 1 </br> 作业留言:留言数 x 1 </br>
通知留言:留言数 x 1 </br>
课程留言:留言数 x 1 </br>
总得分为以上得分之和 总得分为以上得分之和
</div> </div>
<% contributor_course_scor(@course.id).each do |contributor_score| %> <% 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 %>
<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> <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.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p> <p><a href="javascript:void:(0);"><%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p>
<p><span class="c_green" style="cursor:pointer"> <p><span class="c_green" style="cursor:pointer">
<a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"> <a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green">
<%=total_score = contributor_score.resource_num.to_i * 5 + contributor_score.message_num.to_i * 2 + <%=total_score %></a></span></p>
contributor_score.message_reply_num.to_i * 1 + contributor_score.journal_num.to_i * 1 + <div style="display: none" class="numIntro color_888">
+ contributor_score.homework_journal_num.to_i * 1 + contributor_score.news_reply_num.to_i * 1 + <div class="contributor_course_calculate">积分计算</div>
contributor_score.news_num.to_i * 1 %></a></span></p>
<div style="display: none" class="numIntro">
<!--<div style="display: none" class="message_title_red system_message_style">-->
<!--<p><strong>评论对象:</strong><%#= ma.course_message.commented.title %></p>-->
<!--<%# unless ma.course_message.comments.nil? %>-->
<!--<div class="fl"><strong>评论内容:</strong></div>-->
<!--<div class="ml60"><%#= ma.course_message.comments.html_safe %></div>-->
<!--<%# end %>-->
<!--</div>-->
<div style="padding-left: 65px; font-size: 14px;color: #3b3b3b">积分计算</div>
<%# unless contributor_score.resource_num.to_i == 0 %> <%# 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 %></br> <div style="padding-left: 2px;padding-bottom: 2px;padding-right: 2px">
资源发布数 x 5 = <%= contributor_score.resource_num.to_i %> x 5 = <%= contributor_score.resource_num.to_i * 5 %></br>
<%# end %> <%# end %>
<%# unless contributor_score.message_num.to_i == 0 %> <%# 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 %></br> 问答发布数 x 2 = <%= contributor_score.message_num.to_i %> x 2 = <%= contributor_score.message_num.to_i * 2 %></br>
通知发布数 x 1 = <%= contributor_score.news_num.to_i %> x 1 = <%= contributor_score.news_num.to_i %></br>
<%# end %> <%# end %>
<%# unless contributor_score.message_reply_num.to_i == 0 %> <%# 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 %></br> 问答回帖数 x 1 = <%= contributor_score.message_reply_num.to_i %> x 1 = <%= contributor_score.message_reply_num.to_i %></br>
作业留言数 x 1 = <%= contributor_score.homework_journal_num.to_i %> x 1 = <%= contributor_score.homework_journal_num.to_i %></br>
通知留言数 x 1 = <%= contributor_score.news_reply_num.to_i %> x 1 = <%= contributor_score.news_reply_num.to_i %></br>
<%# end %> <%# end %>
<%# unless contributor_score.journal_num.to_i == 0 %> <%# unless contributor_score.journal_num.to_i == 0 %>
课程留言:留言数 x 1 = <%= contributor_score.journal_num.to_i %> x 1 = <%= contributor_score.journal_num.to_i %></br> 课程留言数 x 1 = <%= contributor_score.journal_num.to_i %> x 1 = <%= contributor_score.journal_num.to_i %></br>
<%# end %> <%# end %>
<%# unless contributor_score.homework_journal_num.to_i == 0 %> <%# 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 %></br>
<%# end %> <%# end %>
<%# unless contributor_score.news_reply_num.to_i == 0 %> <%# 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 %></br>
通知回复:通知数 x 1 = <%= contributor_score.news_reply_num.to_i %> x 1 = <%= contributor_score.news_reply_num.to_i %></br>
<%# end %> <%# end %>
总得分:<%=total_score %> 总得分:<%=total_score %>
</div> </div>
</div>
</li> </li>
<% end %> <% end %>
<% end %> <% end %>
@ -205,12 +207,17 @@
<% hero_homework_scores = hero_homework_score(@course, "desc") %> <% hero_homework_scores = hero_homework_score(@course, "desc") %>
<% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %> <% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %>
<ul class="rankList"> <ul class="rankList">
<h4><span>课程英雄榜</span><a style="float: right; color: #7f7f7f; font-size: 12px;" title="英雄榜的得分是每个同学作业的得分总和">积分规则</a></h4> <h4><span>课程英雄榜</span>
<a class="contributor_course" onmouseover ="message_titile_show2($(this),event)" onmouseout ="message_titile_hide2($(this))">积分规则</a></h4>
<div style="display: none" class="numIntro color_888">
<div class="hero_course_innor">积分规则</div>
英雄榜的得分是每个同学作业的得分总和
</div>
<% hero_homework_scores.each do |student_score| %> <% hero_homework_scores.each do |student_score| %>
<% if student_score.score.to_i != 0 %> <% if student_score.score.to_i != 0 %>
<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> <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.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p> <p><a href="javascript:void:(0);"><%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p>
<p><span class="c_red" style="cursor:pointer" title="英雄榜的得分是每个同学作业的得分总和"><%= student_score.score<0 ? 0 : student_score.score.to_i %></span></p> <p><span class="c_red" style="cursor:pointer" ><%= student_score.score<0 ? 0 : student_score.score.to_i %></span></p>
</li> </li>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -158,7 +158,7 @@
<p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p> <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p>
</a> </a>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
<p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分</span></p>
</div> </div>
<% if i == 4 %> <% if i == 4 %>
<% break %> <% break %>

View File

@ -157,7 +157,7 @@
<p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p> <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p>
</a> </a>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
<p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分</span></p>
</div> </div>
<% if i == 4 %> <% if i == 4 %>
<% break %> <% break %>

View File

@ -161,7 +161,7 @@
<p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%></p> <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%></p>
</a> </a>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
<p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分</span></p>
</div> </div>
<% if i == 4 %> <% if i == 4 %>
<% break %> <% break %>

View File

@ -1,4 +1,4 @@
class UpdateContributor < ActiveRecord::Migration class UodapteContributorCourse < ActiveRecord::Migration
def up def up
Course.all.each do |course| Course.all.each do |course|
if course.course_activities.count > 1 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_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_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 # 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 total = board_count + message_reply_count + common_reply_count + attachment_count + journal_count

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 => 20160304154643) do ActiveRecord::Schema.define(:version => 20160304234903) 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
@ -1387,6 +1387,7 @@ ActiveRecord::Schema.define(:version => 20160304154643) do
t.integer "changeset_num", :default => 0 t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0 t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0 t.integer "board_num", :default => 0
t.integer "act_num", :default => 0
t.integer "attach_num", :default => 0 t.integer "attach_num", :default => 0
t.datetime "commit_time" t.datetime "commit_time"
end end

View File

@ -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;} .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;} .subjectType {width:70px; text-align:center;}
.subjectCount {width:65px; 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}