- {
- ec_course_evaluation_lists===undefined?
}/>:ec_course_evaluation_lists.map((list,m)=>{
+
+
+
+ 项
+ 名称
+ 考核次数
+ 支撑关系
+ 考核分项名称
+
+ {/* 操作 */}
+ {ecmanager===false?"":
+
+
+ }
+
+
+
+ 成绩导入状态
+
+
+ 成绩来源
+
+
+ 平均成绩导入模板
+
+
+ 明细成绩导入模板
+
+
+
} spinning={this.state.listSpin}>
+
+ {
+ ec_course_evaluation_lists && ec_course_evaluation_lists.map((list,m)=>{
+
+ return(
+
+ {m+1}
+
+ {list.name}
+
+
+ {list.evluation_count}
+
+
+ {list.status===1?"总成绩支撑":list.status===2?"分项成绩支撑":list.status}
+
+
+
+ {
+ list.subitems.map((listchild,mk)=>{
+ return (
+
+ {listchild.name}
+
+
+ )
+ })
- return(
-
- {m+1}
-
- {list.name}
-
-
- {list.evluation_count}
-
-
- {list.status===1?"总成绩支撑":list.status===2?"分项成绩支撑":list.status}
-
-
-
- {
- list.subitems.map((listchild,mk)=>{
- return (
-
- {listchild.name}
-
-
- )
- })
-
- }
-
-
-
- {/*style={{display:list.is_course_type===false?'inline-block':'none'}}*/}
- {/* editSubentry 编辑的 */}
-
-
-
-
-
-
-
- 模板下载
-
-
-
-
-
-
-
-
- 模板下载
-
-
-
-
-
-
-
-
+
+
+ {/*style={{display:list.is_course_type===false?'inline-block':'none'}}*/}
+ {/* editSubentry 编辑的 */}
+
+
+
+
+
+
+
- {ecmanager===false?成绩导入:成绩导入}
-
-
+
+
+
+
+
+
-
+
+
+
+
+ 模板下载
+
+
- {ecmanager===false?""
- :
- {list.import_status===true||list.is_course_type?"已导入":"未导入"}
- }
+
+
+
+
+ 模板下载
+
+
-
+
+
+
+
+
+ {ecmanager===false?成绩导入:成绩导入}
+
+
+
+
+
- {
- params===" " ? " " : params.map((item,key)=>{
+ {ecmanager===false?""
+ :
+ {list.import_status===true||list.is_course_type?"已导入":"未导入"}
+ }
- return (
-
-
-
-
- 名称
-
-
- 考核次数
-
-
-
-
- 由单次考核总成绩支撑课程目标
-
- 由单次考核的某分项成绩支撑课程目标
-
-
-
-
- {
- item.subitems.map((i,k)=>{
- return(
-
- )
- })
- }
+
-
+ {
-
-
保存
-
取消
+ params===" " ? " " : params.map((item,key)=>{
+
+ return (
+
-
{Modallist}
-
- )
- })
- }
+ )
+ })
+ }
-
+
-
- )
- })
- }
+
+ )
+ })
+ }
- {ecmanager===false?"":
+ {ecmanager===false?"":
- {
+ {
- params===" " ? " " : params.map((item,key)=>{
+ params===" " ? " " : params.map((item,key)=>{
- return (
-
-
+ return (
+
+
-
-
名称
-
+
+ 名称
+
- 考核次数
-
+ 考核次数
+
+
+
+
+ 由单次考核总成绩支撑课程目标
+
+ 由单次考核的某分项成绩支撑课程目标
+
+
+
-
-
- 由单次考核总成绩支撑课程目标
- 由单次考核的某分项成绩支撑课程目标
-
-
+ {
+ item.subitems.map((i,k)=>{
+ return(
+
+
考核分项名称
+
+
+
+
-
-
- {
- item.subitems.map((i,k)=>{
- return(
-
- )
- })
- }
-
- {/* 新建 */}
-
保存
-
取消
+
+
+ )
+ })
+ }
+
+ {Modallist}
-
{Modallist}
-
-
- )
- })
- }
-
- }
-
+
+ )
+ })
+ }
+
+ }
+
+
-
-
-
-
+
{/**/}
-
-
+
);
}
From a37f92531e26ff9cf78a4325424d27393b1ab854 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Sat, 17 Aug 2019 10:31:49 +0800
Subject: [PATCH 10/41] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E8=AE=A4=E8=AF=81-?=
=?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=93=E7=B3=BB-=E5=AF=BC=E5=85=A5?=
=?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=99=84=E4=BB=B6=E6=97=B6=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=95=88=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/javascripts/attachments.js | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 0275558c..ba201074 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -502,8 +502,11 @@ function imageAddInputFiles(inputEl){
addInputFiles(inputEl)
}
-function addInputFiles(inputEl,btnId) {
+function addInputFiles(inputEl,btnId) {
// var clearedFileInput = $(inputEl).clone().val('');
+ if($("#ajax-indicator").length>0){
+ $("#ajax-indicator").show();
+ }
if (inputEl.files) {
// if(inputEl.files.length >= 5){
// alert('一次选择的文件不能超过5个')
@@ -527,6 +530,9 @@ function addInputFiles(inputEl,btnId) {
if (count <= 0) count = 1;
$('#upload_file_count').html("
" + count + "" + $(inputEl).data('fileCount'));
}
+ if($("#ajax-indicator").length>0){
+ $("#ajax-indicator").hide();
+ }
}
//clearedFileInput.insertAfter('#attachments_fields');
@@ -605,6 +611,9 @@ function uploadAndAttachFiles(files, inputEl,btnId) {
addFile(inputEl, this, true,btnId);
});
}
+ if($("#ajax-indicator").length>0){
+ $("#ajax-indicator").hide();
+ }
}
function uploadAndAttachFiles_board(files, inputEl, id,btnId) {
From 9ca131d16088b1ef1d536e8813d54f4606ea87d0 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Sat, 17 Aug 2019 11:04:28 +0800
Subject: [PATCH 11/41] =?UTF-8?q?=E7=AB=9E=E8=B5=9B-=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E6=A0=87=E6=B3=A8=E7=BB=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../competitions/_gq_second_code_competition.html.erb | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/app/views/competitions/_gq_second_code_competition.html.erb b/app/views/competitions/_gq_second_code_competition.html.erb
index 4e6ecdd5..7cba08a8 100644
--- a/app/views/competitions/_gq_second_code_competition.html.erb
+++ b/app/views/competitions/_gq_second_code_competition.html.erb
@@ -76,13 +76,13 @@
extra_data = [
{
name: 'C++项目',
- description: "本项目的paddle/fluid/operators/optimizers目录中包含了常见的优化器(如,Momentum,Adam等等)的c++实现。",
+ description: "飞桨(PaddlePaddle)由百度公司开发,是目前国内唯一功能完备的端到端开源深度学习平台,集深度学习训练和预测框架、模型库、工具组件、服务平台为一体,其兼具灵活和效率的开发机制、工业级应用效果的模型、超大规模并行深度学习能力、推理引擎一体化设计以及系统化的服务支持,致力于让深度学习技术的创新与应用更简单。
本项目的paddle/fluid/operators/optimizers目录中包含了常见的优化器(如,Momentum,Adam等等)的c++实现。",
task: '标注../fluid/operators/optimizers/目录下的所有代码文件',
link_name: '官方,优化器',
link_url: 'https://www.paddlepaddle.org.cn/documentation/docs/zh/1.5/api_guides/low_level/optimizer.html'
},{
name: 'Python项目',
- description: "本项目的python/paddle/fluid/layers/nn.py中包含了神经网络中大量常见层和操作符的python实现,如fc、conv、gru等等。",
+ description: "飞桨(PaddlePaddle)由百度公司开发,是目前国内唯一功能完备的端到端开源深度学习平台,集深度学习训练和预测框架、模型库、工具组件、服务平台为一体,其兼具灵活和效率的开发机制、工业级应用效果的模型、超大规模并行深度学习能力、推理引擎一体化设计以及系统化的服务支持,致力于让深度学习技术的创新与应用更简单。
本项目的python/paddle/fluid/layers/nn.py中包含了神经网络中大量常见层和操作符的python实现,如fc、conv、gru等等。",
task: '标注../paddle/fluid/layers/nn.py代码文件',
link_name: '官方,nn',
link_url: 'https://www.paddlepaddle.org.cn/documentation/docs/zh/1.5/api_cn/layers_cn/nn_cn.html'
@@ -152,10 +152,6 @@
<% if index == 4 %>
-
- 飞桨(PaddlePaddle)由百度公司开发,是目前国内唯一功能完备的端到端开源深度学习平台,集深度学习训练和预测框架、模型库、工具组件、服务平台为一体,其兼具灵活和效率的开发机制、工业级应用效果的模型、超大规模并行深度学习能力、推理引擎一体化设计以及系统化的服务支持,致力于让深度学习技术的创新与应用更简单。
-
-
<% first_section.competition_entries.offset(3).each_with_index do |entry, j| %>
<% row_data = extra_data[j] %>
@@ -174,7 +170,7 @@
<% if row_data.present? %>
项目简介
- <%= raw row_data[:description] %>
+ <%= raw row_data[:description] %>
标注任务
<% if index ==2 %>
<%= row_data[:task] %>
From c3d4176b5b6c0bd5d928bf6bc3d7205ddd42da29 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Sat, 17 Aug 2019 11:07:10 +0800
Subject: [PATCH 12/41] =?UTF-8?q?=E7=AB=9E=E8=B5=9B-=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/stylesheets/educoder/edu-all.css | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css
index e768d86d..c3a76385 100644
--- a/public/stylesheets/educoder/edu-all.css
+++ b/public/stylesheets/educoder/edu-all.css
@@ -673,7 +673,7 @@ a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important;
.second_code_2{min-height: 436px;}
.second_code_3{min-height: 1460px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_code_4{min-height: 1459px;padding-top: 190px;box-sizing: border-box;position: relative}
-.second_code_5{min-height: 2314px;padding-top: 190px;box-sizing: border-box;position: relative}
+.second_code_5{min-height: 2384px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_code_6{min-height: 1060px;}
.second_code_7{min-height: 1116px;}
.second_code_8{min-height: 711px;}
From 08322e989bc39b175c061934e666fb32ce002e99 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 19 Aug 2019 09:05:00 +0800
Subject: [PATCH 13/41] =?UTF-8?q?=E5=86=B3=E8=B5=9B=E5=92=8C=E6=80=BB?=
=?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/competitions_controller.rb | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb
index 57ff871c..cd3a9ef6 100644
--- a/app/controllers/competitions_controller.rb
+++ b/app/controllers/competitions_controller.rb
@@ -327,9 +327,9 @@ class CompetitionsController < ApplicationController
elsif @type == "决赛"
# '92b7vt8x','a7fxenvc','wt2xfzny','xa4m9cng','tng6heyf','am5o73er','9fla2zry','fzp3iu4w','qlsy6xb4'
# 预赛的实训id 第一阶段:1289,1373,1256 第二阶段:1488, 1453, 1487 第三阶段:1470, 1473, 1408
- shixun1_id = Shixun.where(:identifier => ['92b7vt8x','a7fxenvc','wt2xfzny']).pluck(:id)
- shixun2_id = Shixun.where(:identifier => ['xa4m9cng','tng6heyf','am5o73er']).pluck(:id)
- shixun3_id = Shixun.where(:identifier => ['9fla2zry','fzp3iu4w','qlsy6xb4']).pluck(:id)
+ shixun1_id = Shixun.where(:identifier => ['ftlc4x38']).pluck(:id)
+ shixun2_id = Shixun.where(:identifier => ['y9npgih2','ucqt7fw3','2p7ouzwk']).pluck(:id)
+ shixun3_id = Shixun.where(:identifier => ['fj49r7xv','gf2cvxfh','cmoxhtbs']).pluck(:id)
end
if @competition.competition_scores.where(:competition_stage_id => @stage.id).count == 0
@@ -385,7 +385,7 @@ class CompetitionsController < ApplicationController
f_score = team.competition_scores.where(:competition_stage_id => final_stage.try(:id)).first
# 预赛记录
p_score = team.competition_scores.where(:competition_stage_id => pre_stage.try(:id)).first
- team[:s_score] = (f_score.try(:score).to_f * 0.85 + p_score.try(:score).to_f * 0.15).try(:round, 2)
+ team[:s_score] = (f_score.try(:score).to_f * 0.80 + p_score.try(:score).to_f * 0.20).try(:round, 2)
team[:s_spend_time] = f_score.try(:cost_time).to_i + p_score.try(:cost_time).to_i
end
end
From 405def5313c4cf3f2fd199f35521e52a5d7c88a7 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Mon, 19 Aug 2019 16:22:07 +0800
Subject: [PATCH 14/41] add filesize to video applies
---
app/views/managements/video_applies/_video_apply_list.html.erb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/views/managements/video_applies/_video_apply_list.html.erb b/app/views/managements/video_applies/_video_apply_list.html.erb
index d3cfc50d..e5faf854 100644
--- a/app/views/managements/video_applies/_video_apply_list.html.erb
+++ b/app/views/managements/video_applies/_video_apply_list.html.erb
@@ -22,6 +22,7 @@
-
<%= video.title %>
+ <%= number_to_human_size(video.filesize) %>
<% if apply.pending? %>
From 8cf704f1fcf002cb3efaef93abe4f5e9f9d6cf1b Mon Sep 17 00:00:00 2001
From: p31729568
Date: Tue, 20 Aug 2019 08:47:15 +0800
Subject: [PATCH 15/41] add confirm modal to video apply
---
.../video_applies/_video_apply_list.html.erb | 22 ++++++++++---------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/app/views/managements/video_applies/_video_apply_list.html.erb b/app/views/managements/video_applies/_video_apply_list.html.erb
index e5faf854..b79cabc4 100644
--- a/app/views/managements/video_applies/_video_apply_list.html.erb
+++ b/app/views/managements/video_applies/_video_apply_list.html.erb
@@ -59,20 +59,22 @@
\ No newline at end of file
From 6846d6b775114bf8a6384f8f8013cd153c31959a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Tue, 20 Aug 2019 14:56:09 +0800
Subject: [PATCH 16/41] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=B6=E9=83=A8?=
=?UTF-8?q?=E7=A9=BA=E7=99=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/base_projects.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 7baa3d3b..e0834667 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -23,7 +23,7 @@
-
+
<%= render :partial => 'layouts/base_project_top' %>
From 58bdbe44a8f5d7247d9a989737656bd49cb05f78 Mon Sep 17 00:00:00 2001
From: p31729568
Date: Tue, 20 Aug 2019 16:05:37 +0800
Subject: [PATCH 17/41] optimize college statistics page
---
app/controllers/colleges_controller.rb | 227 +++++++++---------
app/models/tag_repertoire.rb | 2 +-
.../colleges/_course_statistics.html.erb | 12 +-
app/views/colleges/_student_shixun.html.erb | 17 +-
app/views/colleges/_teacher_ranking.html.erb | 17 ++
app/views/colleges/statistics.html.erb | 60 ++---
app/views/colleges/teachers.js.erb | 1 +
app/views/welcome/_no_data.html.erb | 3 +-
config/routes.rb | 5 +
9 files changed, 178 insertions(+), 166 deletions(-)
create mode 100644 app/views/colleges/_teacher_ranking.html.erb
create mode 100644 app/views/colleges/teachers.js.erb
diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb
index d95fd848..ebf33df3 100644
--- a/app/controllers/colleges_controller.rb
+++ b/app/controllers/colleges_controller.rb
@@ -1,7 +1,9 @@
# encoding: utf-8
class CollegesController < ApplicationController
- before_filter :find_department, :only => [:statistics, :course_statistics, :student_shixun, :engineering_capability, :student_eval]
+ before_filter :find_department, :only => [:statistics, :course_statistics, :student_shixun, :engineering_capability,
+ :student_eval, :shixun_time, :shixun_report_count, :teachers, :shixun_chart_data,
+ :student_hot_evaluations]
before_filter :manager_auth, :except => [:home, :get_home_data]
include ApplicationHelper
@@ -42,143 +44,128 @@ class CollegesController < ApplicationController
end
def statistics
- logger.info("#########################{params}")
- @teachers_count = User.find_by_sql("SELECT COUNT(users.`id`) AS teacher_count FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE
- user_extensions.`school_id` = #{@school.id} AND user_extensions.`identity` = 0").first.try(:teacher_count)
- @students_count = User.find_by_sql("SELECT COUNT(users.`id`) AS student_count FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE
- user_extensions.`school_id` = #{@school.id} AND user_extensions.`identity` = 1").first.try(:student_count)
- # Redo:这样做内存会卡死的
- # user_ids = User.find_by_sql("SELECT users.id FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{@school.id}").map(&:id)
- # Redo:是否直接使用count会更好
- all_course_ids = Course.where("id != 1309 and is_delete = 0 and school_id = #{@school.id}")
- @courses_count = all_course_ids.size
-
- # Redo:对于量比较大的尽量不使用笛卡尔积
- # @shixuns_count = Shixun.where(:status => [2, 3], :user_id => user_ids).size
- @shixuns_count = Shixun.find_by_sql("select count(s.id) as shixun_count from users u right join shixuns s on u.id=s.user_id and s.status in (2, 3) inner join user_extensions ue on
- u.id=ue.user_id and ue.school_id=#{@school.id}").first.try(:shixun_count)
- # @shixun_time_sum = (Game.where(:user_id => user_ids).pluck(:cost_time).sum / (24*60*60.0)).ceil
- @shixun_time_sum = (Game.find_by_sql("select sum(g.cost_time) cost_time from users u RIGHT join games g on u.id=g.user_id inner join user_extensions ue on
- u.id=ue.user_id and ue.school_id=#{@school.id}").first.try(:cost_time).to_i / (24 * 60 * 60.0)).ceil
-
- # select count(sw.id) from users u left join student_works sw on u.id=sw.user_id and sw.myshixun_id is not null and sw.work_status !=0 inner join user_extensions ue on u.id=ue.user_id and ue.school_id=117 ;
- # @shixun_report_count = StudentWork.where("work_status != 0 and user_id in (#{user_ids.join(',').strip == "" ? -1 : user_ids.join(',')}) and myshixun_id is not null").count
- @shixun_report_count = StudentWork.find_by_sql("SELECT count(*) as sw_count FROM `student_works` where user_id in (SELECT users.id FROM users RIGHT JOIN user_extensions ON users.id=user_extensions.user_id WHERE
- user_extensions.`school_id`=#{@school.id}) and work_status between 1 and 2 and myshixun_id !=0").first.try(:sw_count)
+ # 教师、学生总数
+ count_statistic = UserExtensions.where(school_id: @school.id).select('SUM(IF(identity=0, 1, 0)) AS teachers_count, SUM(IF(identity=1, 1, 0)) AS students_count').first
+ @teachers_count = count_statistic['teachers_count']
+ @students_count = count_statistic['students_count']
+ # 课堂总数
+ @courses_count = Course.where(school_id: @school.id, is_delete: 0).where('id != 1309').count
+ # 实训总数
+ @shixuns_count = Shixun.visible.joins('left join user_extensions on user_extensions.user_id = shixuns.user_id').where(user_extensions: { school_id: @school.id }).count
+
+ respond_to do |format|
+ format.html {render :layout => "base_edu"}
+ end
+ end
+
+ def shixun_time
+ time_sum = Game.joins('left join user_extensions on user_extensions.user_id = games.user_id').where(user_extensions: { school_id: @school.id }).sum(:cost_time)
+ shixun_time_sum = (time_sum / (24 * 60 * 60.0)).ceil
+
+ render json: { shixun_time: shixun_time_sum }
+ end
+
+ def shixun_report_count
+ shixun_report_count = StudentWork.where(work_status: [1, 2]).where('myshixun_id != 0')
+ .joins('left join user_extensions on user_extensions.user_id = student_works.user_id')
+ .where(user_extensions: { school_id: @school.id }).count
+ render json: { shixun_report_count: shixun_report_count }
+ end
+
+ def teachers
@teachers = User.find_by_sql("SELECT users.id, users.login, users.lastname, users.firstname, users.nickname, IFNULL((SELECT count(shixuns.id) FROM shixuns where shixuns.user_id =users.id group by shixuns.user_id), 0) AS publish_shixun_count,
(SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) and c.school_id = #{@school.id} AND m.user_id=users.id AND c.is_delete = 0) as course_count
FROM `users`, user_extensions ue where users.id=ue.user_id and ue.identity=0 and ue.school_id=#{@school.id} ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10")
# ).order("publish_shixun_count desc, experience desc").limit(10)
@teachers =
- @teachers.map do |teacher|
- course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{teacher.id} AND c.is_delete = 0 and c.school_id = #{@school.id}")
- course_count = course_ids.size
- homeworks = HomeworkCommon.where(:homework_type => 4, :course_id => course_ids.map(&:id))
- un_shixun_work_count = homeworks.where("publish_time > '#{Time.now}' or publish_time is null").count
- shixun_work_count = homeworks.size - un_shixun_work_count
- student_count = StudentsForCourse.where(:course_id => course_ids.map(&:id)).count
- myshixun_ids = StudentWork.select("myshixun_id").where("homework_common_id in (#{homeworks.map(&:id).join(',').strip == "" ? -1 : homeworks.map(&:id).join(',')}) and myshixun_id is not null")
- complete_myshixun = Myshixun.select("id").where(:status => 1, :id => myshixun_ids.map(&:myshixun_id)).size
- all_myshixun = Myshixun.select("id").where(:id => myshixun_ids.map(&:myshixun_id)).size
- complete_rate = all_myshixun == 0 ? 0 : ((complete_myshixun * 100) / all_myshixun).try(:round, 2).to_f
- real_name = teacher.show_real_name
- teacher = teacher.attributes.dup.merge({
- real_name: real_name,
- course_count: course_count,
- shixun_work_count: shixun_work_count,
- un_shixun_work_count: un_shixun_work_count,
- student_count: student_count,
- complete_rate: complete_rate
- }).to_json
- JSON.parse(teacher)
- end
-
- shixun_ids = HomeworkCommonsShixuns.find_by_sql("SELECT hcs.shixun_id FROM homework_commons_shixuns hcs, homework_commons hc
- WHERE hc.course_id in (#{all_course_ids.map(&:id).join(',').strip == "" ? -1 : all_course_ids.map(&:id).join(',')})
- AND hcs.homework_common_id = hc.id").map(&:shixun_id)
- shixun_tags = TagRepertoire.find_by_sql("SELECT tr.`name`, COUNT(str.shixun_id) as shixun_count FROM tag_repertoires tr,
- shixun_tag_repertoires str WHERE tr.id = str.tag_repertoire_id AND str.shixun_id
- IN (#{shixun_ids.join(',').strip == "" ? -1 : shixun_ids.join(',')}) GROUP BY tr.id
- order by shixun_count desc")
- all_shixun_count = shixun_tags.map(&:shixun_count).sum
- other_count = all_shixun_count.to_i - shixun_tags[0..8].map(&:shixun_count).sum.to_i
- @shixun_tags_name = []
- @shixun_tags_data = []
- shixun_tags[0..8].each do |tag|
- @shixun_tags_name << tag.name
- @shixun_tags_data << {value: tag.shixun_count, name: tag.name}
- end
- if shixun_tags.size > 9
- @shixun_tags_name << 'Others'
- @shixun_tags_data << {value: other_count, name: 'Others'}
+ @teachers.map do |teacher|
+ course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{teacher.id} AND c.is_delete = 0 and c.school_id = #{@school.id}")
+ course_count = course_ids.size
+ homeworks = HomeworkCommon.where(:homework_type => 4, :course_id => course_ids.map(&:id))
+ un_shixun_work_count = homeworks.where("publish_time > '#{Time.now}' or publish_time is null").count
+ shixun_work_count = homeworks.size - un_shixun_work_count
+ student_count = StudentsForCourse.where(:course_id => course_ids.map(&:id)).count
+ myshixun_ids = StudentWork.select("myshixun_id").where("homework_common_id in (#{homeworks.map(&:id).join(',').strip == "" ? -1 : homeworks.map(&:id).join(',')}) and myshixun_id is not null")
+ complete_myshixun = Myshixun.select("id").where(:status => 1, :id => myshixun_ids.map(&:myshixun_id)).size
+ all_myshixun = Myshixun.select("id").where(:id => myshixun_ids.map(&:myshixun_id)).size
+ complete_rate = all_myshixun == 0 ? 0 : ((complete_myshixun * 100) / all_myshixun).try(:round, 2).to_f
+ real_name = teacher.show_real_name
+ teacher = teacher.attributes.dup.merge({
+ real_name: real_name,
+ course_count: course_count,
+ shixun_work_count: shixun_work_count,
+ un_shixun_work_count: un_shixun_work_count,
+ student_count: student_count,
+ complete_rate: complete_rate
+ }).to_json
+ JSON.parse(teacher)
+ end
+ end
+
+ def shixun_chart_data
+ shixun_ids = HomeworkCommonsShixuns.joins(homework_common: :course).where(courses: {school_id: @school.id, is_delete: 0}).where('courses.id != 1309').pluck('distinct shixun_id')
+ shixun_count_map = ShixunTagRepertoire.joins(:tag_repertoire).where(shixun_id: shixun_ids).group('tag_repertoires.name').order('count_shixun_id desc').count(:shixun_id)
+
+ names = []
+ data = []
+ shixun_count_map.each do |name, count|
+ break if names.size == 9
+
+ names << name
+ data << { value: count, name: name }
end
- respond_to do |format|
- format.html {render :layout => "base_edu"}
+ if shixun_count_map.keys.size > 9
+ other_count = shixun_count_map.values[9..-1].reduce(:+)
+ names << 'Others'
+ data << { name: 'Others', value: other_count }
end
+
+ render json: { names: names, data: data }
end
# 在线课堂
def course_statistics
- @courses = Course.find_by_sql("SELECT c.id, (select concat(lastname,firstname) from users u where u.id=c.tea_id) as username,
- (select count(sfc.id) from students_for_courses sfc where c.id=sfc.course_id group by c.id) as student_count,
- (select count(hc.id) from homework_commons hc where c.id=hc.course_id and hc.homework_type=4 group by c.id) as hcm_count,
- (select count(hc.id) from homework_commons hc where c.id=hc.course_id and hc.homework_type in (1,3) group by c.id) as hcm_nonshixun_count,
- (select count(e.id) from exercises e where c.id=e.course_id group by c.id) as exercises_count,
- (select count(p.id) from polls p where c.id=p.course_id group by c.id) as polls_count,
- (select count(a.id) from attachments a where c.id=a.container_id and a.container_type='Course' group by c.id) as attachments_count,
- (select count(m.id) from messages m inner join boards b on b.id=m.board_id and b.parent_id=0 where b.course_id=c.id group by c.id) as messages_count,
- c.tea_id, c.name, c.is_end,
- (SELECT MAX(created_at) FROM `course_activities` ca WHERE ca.course_id = c.id) AS update_time
- FROM `courses` c WHERE c.school_id = #{@school.id} and c.is_delete = 0")
-
- @courses.each do |course|
- course[:evaluating_count] = Output.find_by_sql("select sum(g.evaluate_count) as evaluating_count from games g inner join
- (select myshixun_id from student_works sw inner join homework_commons hc on sw.homework_common_id=hc.id and
- sw.myshixun_id !=0 and hc.course_id=#{course.id} and homework_type=4) aa on g.myshixun_id=aa.myshixun_id").first.try(:evaluating_count).to_i
- course[:task_count] = course.hcm_count.to_i + course.attachments_count.to_i + course.messages_count.to_i + course.hcm_nonshixun_count.to_i + course.exercises_count.to_i + course.polls_count.to_i
- end
- @courses = @courses.sort{|x,y| [y[:evaluating_count], y[:task_count]] <=> [x[:evaluating_count], x[:task_count]] }
- @courses = @courses.sort_by { |course| course.is_end ? 1 : 0 }
-
- # SELECT c.id, (select concat(firstname,lastname) from users u where u.id=c.tea_id) as username,
- # (select count(sfc.id) from students_for_courses sfc where c.id=sfc.course_id group by c.id) as student_count,
- # (select count(hc.id) from homework_commons hc where c.id=hc.course_id and hc.homework_type=4 group by c.id) as hcm_count,
- # c.tea_id, c.name, c.is_end,
- # (SELECT MAX(created_at) FROM `course_activities` ca WHERE ca.course_id = c.id) AS update_time
- # FROM `courses` c WHERE (c.school_id = 117 and c.is_delete = 0) ORDER BY update_time desc LIMIT 8 OFFSET 0
-
- # @courses = Course.where("courses.school_id = #{@department.school_id} and courses.is_delete = 0").select("courses.id, courses.tea_id, courses.name, courses.is_end,
- # (SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS update_time").order("update_time desc")
- @courses = paginateHelper @courses, 8
- # @courses = @courses.includes(:student, :boards, :exercises, :polls, :attachments, :homework_commons, :teacher => [:user_extensions])
+ courses = Course.where(school_id: @school.id, is_delete: 0)
+
+ @obj_count = courses.count
+
+ courses = courses.joins(shixun_homework_commons: :student_works)
+ .joins('join games on games.myshixun_id = student_works.myshixun_id')
+ .select('courses.id, courses.name, courses.is_end, sum(games.evaluate_count) evaluating_count')
+ .group('courses.id').order('is_end asc, evaluating_count desc')
+
+ @obj_pages = Paginator.new @obj_count, 8, params['page']
+ @courses = courses.limit(@obj_pages.per_page).offset(@obj_pages.offset)
+
+ course_ids = @courses.map(&:id)
+ @student_count = StudentsForCourse.where(course_id: course_ids).group(:course_id).count
+ @shixun_work_count = HomeworkCommon.where(homework_type: 4, course_id: course_ids).group(:course_id).count
+ @attachment_count = Attachment.where(container_id: course_ids, container_type: 'Course').group(:container_id).count
+ @message_count = Message.joins(:board).where(boards: { parent_id: 0, course_id: course_ids }).group('boards.course_id').count
+ @active_time = CourseActivity.where(course_id: course_ids).group(:course_id).maximum(:created_at)
+ @exercise_count = Exercise.where(course_id: course_ids).group(:course_id).count
+ @poll_count = Poll.where(course_id: course_ids).group(:course_id).count
+ @other_work_count = HomeworkCommon.where(homework_type: [1,3], course_id: course_ids).group(:course_id).count
end
# 学生实训
def student_shixun
- user_ids = User.find_by_sql("SELECT users.id FROM users, user_extensions WHERE users.id=user_extensions.user_id AND user_extensions.`school_id` = #{@school.id}").map(&:id)
- @students = User.find_by_sql("SELECT users.id, users.login, users.lastname, users.firstname, users.nickname, users.grade,
- users.experience, ue.student_id, (SELECT COUNT(myshixuns.id) FROM `myshixuns` WHERE myshixuns.user_id
- = users.id AND myshixuns.status = 1 GROUP BY users.id) AS myshixun_count FROM users join user_extensions ue on
- users.id = ue.user_id where ue.school_id = #{@school.id} AND ue.identity = 1 AND `users`.`type` IN ('User', 'AnonymousUser') ORDER BY experience DESC, myshixun_count DESC LIMIT 10")
-
- ## outputs基数过大,用inner join有奇效
- @shixun_tags = TagRepertoire.find_by_sql(%Q{
- select name, COUNT(outputs.id) AS test_count from outputs inner join (
- SELECT tr.id as trid, tr.`name` as name, games.id as id
- FROM tag_repertoires tr, shixun_tag_repertoires str, games, myshixuns
- WHERE tr.id = str.tag_repertoire_id
- AND str.shixun_id = myshixuns.`shixun_id`
- AND myshixuns.id = games.`myshixun_id`
- AND myshixuns.`user_id` IN (
- SELECT users.id FROM users, user_extensions WHERE users.id=user_extensions.user_id AND user_extensions.`school_id` = #{@school.id}
- )
- ) a on a.id = outputs.game_id and outputs.`test_set_position` = 1 group by trid
- ORDER BY test_count DESC
- LIMIT 10
- })
+ @students = User.joins(:user_extensions).where(user_extensions: { school_id: @school.id, identity: 1 }).includes(:user_extensions).order('experience desc').limit(10)
+
+ student_ids = @students.map(&:id)
+ @shixun_count = Myshixun.where(user_id: student_ids).group(:user_id).count
+ @study_shixun_count = Myshixun.where(user_id: student_ids, status: 0).group(:user_id).count
+ end
+
+ def student_hot_evaluations
+ games = Game.unscoped().joins(:myshixun).joins('join shixun_tag_repertoires str on str.shixun_id = myshixuns.shixun_id')
+ games = games.joins('join tag_repertoires tr on tr.id = str.tag_repertoire_id')
+ games = games.joins("join user_extensions ue on ue.user_id = myshixuns.user_id and ue.school_id = #{@school.id}")
+ evaluate_count_map = games.group('tr.name').reorder('sum_games_evaluate_count desc').limit(10).sum('games.evaluate_count')
+ render json: { names: evaluate_count_map.keys, values: evaluate_count_map.values }
end
# 工程能力
diff --git a/app/models/tag_repertoire.rb b/app/models/tag_repertoire.rb
index c33faa5c..7b7891e7 100644
--- a/app/models/tag_repertoire.rb
+++ b/app/models/tag_repertoire.rb
@@ -1,8 +1,8 @@
class TagRepertoire < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :sub_repertoire
- has_many :shixuns, :through => :shixun_tag_repertoires
has_many :shixun_tag_repertoires, :dependent => :destroy
+ has_many :shixuns, :through => :shixun_tag_repertoires
has_many :memos, :through => :memo_tag_repertoires
has_many :memo_tag_repertoires, :dependent => :destroy
diff --git a/app/views/colleges/_course_statistics.html.erb b/app/views/colleges/_course_statistics.html.erb
index 67e989f3..b8608dc0 100644
--- a/app/views/colleges/_course_statistics.html.erb
+++ b/app/views/colleges/_course_statistics.html.erb
@@ -20,13 +20,13 @@
<%= course_managers course.teachers %>
<%= course.evaluating_count %> |
- <%= course.student_count.to_i %> |
- <%= course.hcm_count.to_i %> |
- <%= course.attachments_count.to_i %> |
- <%= course.messages_count.to_i %> |
- <%= course.hcm_nonshixun_count.to_i + course.exercises_count.to_i + course.polls_count.to_i %> |
+ <%= @student_count.fetch(course.id, 0) %> |
+ <%= @shixun_work_count.fetch(course.id, 0) %> |
+ <%= @attachment_count.fetch(course.id, 0) %> |
+ <%= @message_count.fetch(course.id, 0) %> |
+ <%= @exercise_count.fetch(course.id, 0) + @poll_count.fetch(course.id, 0) + @other_work_count.fetch(course.id, 0) %> |
"><%= course.is_end ? "已结束" : "正在进行" %> |
- <%= format_time course.update_time %> |
+ <%= format_time @active_time[course.id] %> |
<% end %>
diff --git a/app/views/colleges/_student_shixun.html.erb b/app/views/colleges/_student_shixun.html.erb
index f0999075..5fd310d1 100644
--- a/app/views/colleges/_student_shixun.html.erb
+++ b/app/views/colleges/_student_shixun.html.erb
@@ -21,8 +21,8 @@
<%= student.show_real_name %>
<%= student.student_id %> |
- <%= student.myshixun_count %> |
- <%= student.myshixuns.where(:status => 0).count %> |
+ <%= @shixun_count.fetch(student.id, 0) %> |
+ <%= @study_shixun_count.fetch(student.id, 0) %> |
<%= student.grade %> |
<%= student.experience %> |
@@ -32,14 +32,15 @@
\ No newline at end of file
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index 106d720a..f8c686bd 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -3,7 +3,7 @@
<%= javascript_include_tag 'create_kindeditor'%>
<% end %>