班级统计功能(暂未完成)

This commit is contained in:
cxt 2017-01-20 10:16:51 +08:00
parent 479a347672
commit ac80805932
13 changed files with 265 additions and 50 deletions

View File

@ -1362,9 +1362,25 @@ class CoursesController < ApplicationController
end
#统计
def statistics_course
def course_statistics
@left_nav_type = 10
# @order = params[:order] ? params[:order] : 'desc'
# if !params[:tab] || params[:tab] == "activity"
# @type = params[:type] ? params[:type] : 'act_score'
# sql = "SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + resource_num*5 + journal_num*1 + homework_journal_num*1) AS act_score,
# message_num, message_reply_num, news_reply_num, news_num, resource_num, journal_num, homework_journal_num, ccs.user_id FROM course_contributor_scores ccs
# JOIN students_for_courses ON students_for_courses.course_id = ccs.course_id AND students_for_courses.student_id = ccs.user_id
# WHERE ccs.course_id = #{@course.id} HAVING act_score != 0 ORDER BY #{@type} #{@order}, act_score #{@order}"
# @members = CourseContributorScore.find_by_sql(sql)
# end
#
# @limit = 20
# @page = params[:page].nil? ? 1 : params['page'].to_i
# @members_count = @members.count
# @mem_pages = Paginator.new @members_count, @limit, @page
# @members = paginateHelper @members, @limit
respond_to do |format|
format.js
format.html {render :layout => 'base_courses'}
end
end

View File

@ -55,6 +55,7 @@ class Course < ActiveRecord::Base
has_many :student_works, :through => :homework_commons, :dependent => :destroy
has_many :course_groups, :dependent => :destroy
#has_many :course_homework_statistics, :dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy

View File

@ -9,8 +9,8 @@ class StudentsForCourse < ActiveRecord::Base
validates_presence_of :course_id, :student_id
validates_uniqueness_of :student_id, :scope => :course_id
after_destroy :delete_student_works
after_create :recovery_student_works, :create_student_works
after_destroy :delete_student_works, :delete_course_homework_statistic
after_create :recovery_student_works, :create_student_works, :create_course_homework_statistic
#退出班级或删除学生时隐藏学生的作品
def delete_student_works
@ -37,4 +37,41 @@ class StudentsForCourse < ActiveRecord::Base
end
end
end
#加入班级时创建一条记录
def create_course_homework_statistic
# if CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).count == 0
# course = self.course
# user = self.student
# hw_count = course.homework_commons.count
# homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
# student_works = StudentWork.where("homework_common_id in #{homework_ids}")
# is_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 2")
# is_eva_student_works = StudentWork.where(:homework_common_id => is_eva_homeworks.map{|hw| hw.id})
# has_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 3")
# has_eva_student_works = StudentWork.where(:homework_common_id => has_eva_homeworks.map{|hw| hw.id})
# course.student.each do |student|
# user = student.student
# if user
# committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
# un_commit_work_num = hw_count - committed_work_num
# late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
# absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
# user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
# un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
# user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
# appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
# average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
# total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
# CourseHomeworkStatistic.create(:course_id => course.id, :user_id => user.id, :committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
# :late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
# :appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
# end
# end
# end
end
def delete_course_homework_statistic
#CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).destroy_all
end
end

View File

@ -183,6 +183,8 @@ class User < Principal
# 课程贡献榜
has_many :course_contributor_scores, :dependent => :destroy
#has_many :course_homework_statistics, :dependent => :destroy
######added by nie
has_many :project_infos, :dependent => :destroy
has_one :user_status, :dependent => :destroy

View File

@ -0,0 +1,137 @@
<% if @members.count != 0 %>
<table class="muban_table clearfix mb15 t-center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="table-td-w20" >姓名</th>
<th class="table-td-w10">
<%= link_to '发布资源', course_statistics_course_path(@course, :type => 'resource_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "resource_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "resource_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '发布帖子', course_statistics_course_path(@course, :type => 'message_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "message_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "message_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '帖子回复', course_statistics_course_path(@course, :type => 'message_reply_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "message_reply_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "message_reply_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '发布通知', course_statistics_course_path(@course, :type => 'news_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "news_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "news_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '通知回复', course_statistics_course_path(@course, :type => 'news_reply_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "news_reply_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "news_reply_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '作业回复', course_statistics_course_path(@course, :type => 'homework_journal_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "homework_journal_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "homework_journal_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '班级留言', course_statistics_course_path(@course, :type => 'journal_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "journal_num" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "journal_num" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
<th class="table-td-w10">
<%= link_to '活跃度', course_statistics_course_path(@course, :type => 'act_score', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
<% if @type == "act_score" && @order == 'desc' %>
<a href="javascript:" class= "sy_sortupbtn"></a>
<% elsif @type == "act_score" && @order == 'asc' %>
<a href="javascript:" class= "sy_sortdownbtn"></a>
<% end %>
</th>
</tr>
</thead>
<tbody>
<% @members.each do |member| %>
<tr>
<td><%= link_to member.user.show_name, user_path(member.user), :class => 'course_class_users_st_name' %></td>
<td><%= member.resource_num %></td>
<td><%= member.message_num %></td>
<td><%= member.message_reply_num %></td>
<td><%= member.news_num %></td>
<td><%= member.news_reply_num %></td>
<td><%= member.homework_journal_num %></td>
<td><%= member.journal_num %></td>
<td class="pr">
<span><%= member.act_score %></span>
<div class="st_tips_box_inner undis" style="text-align:left;">
<em></em>
<span></span>
<p>资源发布数*5=<%= member.resource_num %>*5=<%= member.resource_num.to_i * 5 %><br/>
帖子发布数*2=<%= member.message_num %>*2=<%= member.message_num.to_i * 2 %><br/>
帖子回复数*1=<%= member.message_reply_num %>*1=<%= member.message_reply_num.to_i * 1 %><br/>
通知发布数*1=<%= member.news_num %>*1=<%= member.news_num.to_i * 1 %><br/>
通知回复数*1=<%= member.news_reply_num %>*1=<%= member.news_reply_num.to_i * 1 %><br/>
作业留言数*1=<%= member.homework_journal_num %>*1=<%= member.homework_journal_num.to_i * 1 %><br/>
班级留言数*1=<%= member.journal_num %>*1=<%= member.journal_num.to_i * 1 %><br/>
总得分:<%= member.act_score %>
</p>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @mem_pages, @members_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% else%>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
<script>
$(".muban_table tbody tr").each(function(){
$(this).mouseenter(function(){
$(".st_tips_box_inner").hide();
$(this).children().eq(8).children().eq(1).stop();
$(this).children().eq(8).children().eq(1).show();
});
$(this).mouseleave(function(){
$(this).children().eq(8).children().eq(1).delay(500).hide(0);
});
});
$(".st_tips_box_inner").each(function(){
$(this).mouseover(function(){
$(this).stop();
$(this).show();
});
$(this).mouseout(function(){
$(this).delay(500).hide(0);
});
});
</script>

View File

@ -67,6 +67,6 @@
<% end %>
<% if show_nav?(0) %>
<li>
<a href="<%=statistics_course_course_path(@course) %>">统计</a>
<a href="<%=course_statistics_course_path(@course) %>">统计</a>
</li>
<% end %>

View File

@ -0,0 +1,5 @@
<div class="sy_class_r ml10">
<div class="icons_tishi"><img src="../../images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">统计功能即将上线,届时我们一起享受教育大数据的红利吧!</p>
<div style="height:400px;"></div>
</div><!--sy_class_r end-->

View File

@ -0,0 +1,5 @@
<% if !params[:tab] || params[:tab] == "activity" %>
$("#act_table_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'act_table')%>");
<% else %>
<% end %>

View File

@ -127,7 +127,7 @@
<% statistics_count = 0 %>
<% unless show_nav?(statistics_count) %>
<li id="sy_10" class="sy_icons_st">
<a href="<%=statistics_course_course_path(@course) %>">统计<span></span></a>
<a href="<%=course_statistics_course_path(@course) %>">统计<span></span></a>
<!--<a href="javascript:void(0);" class="sy_class_add"></a>-->
</li>
<% end %>

View File

@ -1352,7 +1352,7 @@ RedmineApp::Application.routes.draw do
get 'search_public_orgs_not_in_course'
get "homework_search"
get "show_comparecode"
get "statistics_course"
get "course_statistics"
get "switch_role"
get 'search_not_group_member'
post 'add_members'

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20170111030006) do
ActiveRecord::Schema.define(:version => 20170119084333) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -350,16 +350,14 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
create_table "changesets", :force => true do |t|
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.string "committer"
t.datetime "committed_on", :null => false
t.datetime "committed_on", :null => false
t.text "comments"
t.date "commit_date"
t.string "scmid"
t.integer "user_id"
t.integer "project_id"
t.integer "type", :default => 0
end
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
@ -630,6 +628,20 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
t.integer "container_id", :default => 0
end
create_table "course_class_post", :id => false, :force => true do |t|
t.integer "班级id", :default => 0, :null => false
t.string "班级名"
t.integer "帖子id", :default => 0, :null => false
t.integer "主贴id"
t.string "帖子标题", :default => "", :null => false
t.text "帖子内容"
t.integer "帖子用户id"
t.integer "帖子回复数", :default => 0, :null => false
t.integer "最后回帖id"
t.datetime "发帖时间", :null => false
t.datetime "帖子更新时间", :null => false
end
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -657,6 +669,21 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
add_index "course_groups", ["course_id"], :name => "index_course_groups_on_course_id"
create_table "course_homework_statistics", :force => true do |t|
t.integer "user_id"
t.integer "course_id"
t.integer "committed_work_num", :default => 0
t.integer "un_commit_work_num", :default => 0
t.integer "late_commit_work_num", :default => 0
t.integer "absence_evaluation_work_num", :default => 0
t.integer "un_evaluation_work_num", :default => 0
t.integer "appeal_num", :default => 0
t.float "average_score", :default => 0.0
t.float "total_score", :default => 0.0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "course_infos", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -804,21 +831,6 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "delayed_jobs_20161218", :id => false, :force => true do |t|
t.integer "id", :default => 0, :null => false
t.integer "priority", :default => 0, :null => false
t.integer "attempts", :default => 0, :null => false
t.text "handler", :null => false
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -944,11 +956,13 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
t.integer "exercise_status"
t.integer "user_id"
t.integer "time"
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.datetime "publish_time"
t.datetime "end_time"
t.integer "show_result"
t.integer "question_random", :default => 0
t.integer "choice_random", :default => 0
end
create_table "first_pages", :force => true do |t|
@ -1138,23 +1152,6 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
t.datetime "updated_at", :null => false
end
create_table "ii", :force => true do |t|
t.integer "project_id"
t.string "author_login"
t.string "rep_identifier"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "sonar_version", :default => 0
t.string "path"
t.string "branch"
t.string "language"
t.string "sonar_name"
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -2082,9 +2079,10 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
t.integer "score"
t.text "comment"
t.integer "reviewer_role"
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 "appeal_status", :default => 0
t.boolean "is_hidden", :default => false
end
add_index "student_works_scores", ["student_work_id"], :name => "student_work_id"

View File

@ -629,4 +629,18 @@ a.banner-course-notice {position: absolute; font-size: 12px; line-height: 20px;
.banner-course-avatar:hover .banner-course-notice { top: 20px;}
.course_setting_org_fl {width: 49%; border-right: 1px solid #e5e5e5;}
.course_setting_org_fr {width: 49%;}
.course_setting_org_fr {width: 49%;}
/*20161222班级统计*/
.game-setting-h3{ width: 100%; height: 40px; line-height: 40px; font-size: 14px; color: #666; font-weight: normal; background: #fff; border-bottom: 10px solid #eaebec;}
.t-center{ text-align: center;}
.table-td-w20{ width: 18%;}
.table-td-w10{ width: 10%;}
.table-td-w30{ width: 30%;}
.new_project_title_width {font-size: 14px;color: #666; max-width: 180px;font-weight: normal;white-space: nowrap;overflow: hidden; text-overflow: ellipsis;}
.syllabus_class_property { font-size: 12px; padding: 0 5px;border-radius: 3px;line-height: 14px;}
.syllabus_class_private {color: #ff4a1b;border: 1px solid #ff4a1b;}
.syllabus_class_open { color: #7dd26c; border: 1px solid #7dd26c;}
.st_tips_box_inner{ position: absolute;line-height: 2.0;padding: 5px 10px; white-space: nowrap; background-color: #fff; left:100px; top: -5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
.st_tips_box_inner span { display: block; border-width: 10px;position: absolute;top: 15px; left: -18px; border-style: dashed solid dashed dashed;border-color: transparent #fff transparent transparent;font-size: 0;line-height: 0;}
.course_class_users_st_name{ display: inline-block;width:120px; overflow:hidden;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}

View File

@ -14,7 +14,7 @@ input.radio-width90{ width: 90px; }
.muban_table thead tr{ height:40px; line-height:40px;}
.muban_table thead tr th{ border-bottom:1px solid #e5e5e5;}
.muban_table tbody tr:hover{ background:#f5f5f5;}
.muban_table tbody tr th{ height:40px; line-height:40px; border-bottom:1px solid #e5e5e5; font-weight:normal; color:#888;}
.muban_table tbody tr td{ height:40px; border-bottom:1px solid #e5e5e5; font-weight:normal; color:#888;}
/*模板icons 20161013byLB*/
.muban_icons_orange{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #ff4a1b;border: 1px solid #ff4a1b;}
.muban_icons_blue{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #3b94d6;border: 1px solid #3b94d6;}