parent
85515befc4
commit
c8b1cae947
|
@ -738,3 +738,22 @@ module CoursesHelper
|
|||
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"
|
||||
sql = ActiveRecord::Base.connection()
|
||||
homework_scores = Member.find_by_sql(sql_select)
|
||||
sql.close()
|
||||
homework_scores
|
||||
end
|
||||
|
|
|
@ -42,6 +42,8 @@ class Course < ActiveRecord::Base
|
|||
# 课程消息
|
||||
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
|
||||
belongs_to :course
|
||||
belongs_to :user
|
||||
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
|
||||
|
|
|
@ -200,7 +200,58 @@
|
|||
<%= render 'courses/tool_expand', :locals => {:is_teacher => is_teacher, :course_file_num => course_file_num} %>
|
||||
</ul>
|
||||
</div><!--项目侧导航 end-->
|
||||
<%# 课程贡献榜 %>
|
||||
<div class="cl"></div>
|
||||
<ul class="rankList">
|
||||
<p class="fontGrey2 f14">课程贡献榜</p>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">jack_nudt</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">6598</span></p>
|
||||
<div class="numIntro">发帖:650<br />
|
||||
评论:98</div>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">linchun</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">5421</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">junjie</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">3675</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">timtang</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">2775</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">xiaoting</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">1986</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">zanle</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">1327</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">huang</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">1143</span></p>
|
||||
</li>
|
||||
<li> <a href="javascript:void:(0);"><img src="images/homepageProfileImage.png" width="35" height="35" alt="jack_nudt" class="rankPortrait" /></a>
|
||||
<p><a href="javascript:void:(0);">guangge</a></p>
|
||||
<p><span class="c_green" style="cursor:pointer">999</span></p>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<ul class="rankList">
|
||||
<p class="fontGrey2 f14">课程英雄榜</p>
|
||||
<% hero_homework_score(@course, "desc").each do |student_score| %>
|
||||
<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) %></a></p>
|
||||
<p><span class="c_red" style="cursor:pointer" title="作业总分:<%= student_score.score %>"><%= student_score.score.to_i %></span></p>
|
||||
<!--<div class="numIntro">作业总分:<%#= student_score.score %><br />-->
|
||||
<!--测验:98</div>-->
|
||||
</li>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<div class="project_intro">
|
||||
<div id="course_description" class="course_description">
|
||||
<h4 ><%= l(:label_course_brief_introduction)%>:</h4>
|
||||
|
|
|
@ -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
|
67
db/schema.rb
67
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 => 20151125064914) 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,19 @@ 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
|
||||
end
|
||||
|
||||
create_table "course_groups", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "course_id"
|
||||
|
|
|
@ -1173,6 +1173,6 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
|
|||
.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:5px 0px; text-align:center; float:left; position:relative;}
|
||||
.rankList li p {width:100%; overflow:hidden; white-space:normal; text-overflow:ellipsis; color:#585858;}
|
||||
.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; width:65px; color:#585858;}
|
|
@ -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