From 3f0e5b95ec0df2e52434c25d67624cbb3e86f3ff Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 09:58:07 +0800
Subject: [PATCH 01/68] 1
---
app/models/shixun.rb | 3 +++
.../subjects/data_statistic_service.rb | 22 +++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 app/services/subjects/data_statistic_service.rb
diff --git a/app/models/shixun.rb b/app/models/shixun.rb
index d8a41ba6a..b77038a78 100644
--- a/app/models/shixun.rb
+++ b/app/models/shixun.rb
@@ -59,6 +59,9 @@ class Shixun < ApplicationRecord
# Jupyter数据集,附件
has_many :data_sets, ->{where(attachtype: 2)}, class_name: 'Attachment', as: :container, dependent: :destroy
+ # 试卷的实训题
+ has_many :exercise_questions
+
scope :search_by_name, ->(keyword) { where("name like ? or description like ? ",
"%#{keyword}%", "%#{keyword}%") }
diff --git a/app/services/subjects/data_statistic_service.rb b/app/services/subjects/data_statistic_service.rb
new file mode 100644
index 000000000..9311953ca
--- /dev/null
+++ b/app/services/subjects/data_statistic_service.rb
@@ -0,0 +1,22 @@
+class Subjects::DataStatisticService < ApplicationService
+ attr_reader :subject, :user
+ def initialize(subject, user)
+ @subject = subject
+ @user = user
+ @shixuns = subject.shixuns
+ end
+
+ # 学习总人数
+ def study_count
+ @shixuns.includes(:myshixuns).map{|shixun| shixun.myshixuns.pluck(:user_id)}.uniq
+ end
+
+ # 课堂学习人数
+ def course_study_count
+ # 实训作业
+ sw_user_ids = StudentWork.where.not(myshixun_id: nil).pluck(:user_id)
+ # 试卷的实训题
+ esa_user_ids = ExerciseShixunAnswer.where()
+ end
+
+end
From a165d895c3ec1739dd9e16b2bb504d909da4169e Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 10:59:32 +0800
Subject: [PATCH 02/68] =?UTF-8?q?=E5=AE=9E=E8=AE=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/services/subjects/data_statistic_service.rb | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/services/subjects/data_statistic_service.rb b/app/services/subjects/data_statistic_service.rb
index 9311953ca..29696cf15 100644
--- a/app/services/subjects/data_statistic_service.rb
+++ b/app/services/subjects/data_statistic_service.rb
@@ -3,7 +3,7 @@ class Subjects::DataStatisticService < ApplicationService
def initialize(subject, user)
@subject = subject
@user = user
- @shixuns = subject.shixuns
+ @shixun_ids = subject.shixuns.pluck(:id)
end
# 学习总人数
@@ -14,9 +14,11 @@ class Subjects::DataStatisticService < ApplicationService
# 课堂学习人数
def course_study_count
# 实训作业
- sw_user_ids = StudentWork.where.not(myshixun_id: nil).pluck(:user_id)
+ sw_user_ids = StudentWork.where.not(myshixun_id: nil).joins(homework_common: :homework_commons_shixuns)
+ .where(homework_commons_shixuns: {shixun_id: @shixun_ids}).pluck("student_works.user_id")
# 试卷的实训题
- esa_user_ids = ExerciseShixunAnswer.where()
+ esa_user_ids = ExerciseShixunAnswer.joins(exercise_shixun_challenge: :shixun)
+ .where(shixuns: {id: @shixun_ids}).pluck("exercise_shixun_answers.user_id")
end
end
From 908dbb87cae041b39b3ca95c10312bbd0faec907 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 11:39:51 +0800
Subject: [PATCH 03/68] =?UTF-8?q?=E6=95=8F=E6=84=9F=E8=AF=8D=E6=B1=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../chinese_dictionary.txt | 136 +-----------------
config/harmonious_dictionary/harmonious.hash | Bin 48913 -> 46347 bytes
2 files changed, 2 insertions(+), 134 deletions(-)
diff --git a/config/harmonious_dictionary/chinese_dictionary.txt b/config/harmonious_dictionary/chinese_dictionary.txt
index 3040d9d0e..ce247eb45 100644
--- a/config/harmonious_dictionary/chinese_dictionary.txt
+++ b/config/harmonious_dictionary/chinese_dictionary.txt
@@ -10,26 +10,21 @@
李源潮
李干成
戴秉国
-黄镇
刘延东
刘瑞龙
俞正声
-黄敬
薄熙来
薄一波
周小川
周建南
温云松
-徐明
江绵康
李小鹏
李小琳
朱云来
让国人愤怒的第二代身份证
-第二代身份证
文化大革命
胡海峰
-六四
陈良宇
老丁
莱仕德事件
@@ -68,11 +63,9 @@ PK黑社会
反华
官商勾结
升达毕业证
-手机复制
戴海静
自杀指南
自杀手册
-张小平
佳静安定片
蒙汗药粉
古方迷香
@@ -105,7 +98,6 @@ PK黑社会
反政府
禁书
特码
-成人
国民党
贪污
骚妇
@@ -154,7 +146,6 @@ PK黑社会
AV
十八禁
性虐待
-激情
耽美
金瓶梅
藏春阁
@@ -181,15 +172,13 @@ AV
政府无能
九评
十七大代表
-办证
暴力拆迁
轮暴致死
-人民报
暴力镇压
高干子弟名单
性免费电影
全裸
-偷 拍
+偷拍
中共十七大
徐和柴学友
修炼之歌
@@ -250,7 +239,6 @@ A集中营
中共特务
乙醚
党内分裂
-新生网
圆明网
和平修炼
放下生死
@@ -303,10 +291,6 @@ A集中营
明慧周刊
九评共产党
江泽民其人
-秘密文件
-机密文件
-红头文件
-政府文件
破网软件
无界浏览
亲共来源
@@ -341,7 +325,6 @@ H漫画
香港GHB水
色空寺
周容重
-朱蒙
汕頭頻傳擄童割器官
法輪功
六决不
@@ -371,15 +354,12 @@ H漫画
敢坐飞机吗
韩国身份证
台湾身份证
-广电总局
学生暴动
镇压学生
广安第二人民医院
-山不过来
胡新宇
趙紫陽
自由亚州
-明慧
践踏中国女性
拉凳
南京大学法学院
@@ -389,7 +369,6 @@ H漫画
崔英杰
松花江污染
火药制作
-江氏
第十六次代表
仁寿警方
愈快乐愈堕落
@@ -433,7 +412,6 @@ H漫画
二奶
2奶
纪股票市场五卅惨案
-这年头就这样
代开普通发票
代开商品发票
代开国税发票
@@ -487,7 +465,6 @@ H漫画
死刑过程
学生与警察
鬼村
-周容
重题工
先烈的电电
身份证生成
@@ -509,17 +486,14 @@ H漫画
生成身份证
华国锋
叶剑英
-陈云
李先念
汪东兴
韦国清
乌兰夫
-方毅
刘伯承
许世友
纪登奎
苏振华
-吴德
余秋里
张廷发
陈永贵
@@ -528,15 +502,12 @@ H漫画
聂荣臻
倪志福
徐向前
-彭冲
-王震
邓颖超
杨尚昆
杨得志
宋任穷
胡乔木
胡耀邦
-彭真
廖承志
秦基伟
陈慕华
@@ -549,21 +520,16 @@ H漫画
芮杏文
杨白冰
邹家华
-谢非
谭绍文
王汉斌
任建新
于永波
傅全有
-吴仪
-王克
王乐泉
王兆国
-刘淇
刘云山
张立昌
张德江
-王刚
隐形耳机
隐形摄像头
裸聊
@@ -629,11 +595,7 @@ a级情片
藏独
曹长青
曹刚川
-柴玲
-常劲
陈炳基
-陈军
-陈蒙
陈破空
陈希同
陈小同
@@ -641,17 +603,13 @@ a级情片
陈一谘
陈总统
程铁军
-程真
迟浩田
持不同政见
赤匪
赤化
达赖
大参考
-大法
大纪园
-大家论坛
-大史记
大史纪
戴相龙
弹劾
@@ -663,7 +621,6 @@ a级情片
电视流氓
钓鱼岛
丁关根
-丁元
丁子霖
东北独立
东社
@@ -702,7 +659,6 @@ a级情片
炼功
李总统
李登辉
-李鹏
李瑞环
吐血
18禁
@@ -828,7 +784,6 @@ A片
薄格
調教
乱伦
-偷拍
更衣
無修正
虐待
@@ -854,16 +809,12 @@ A片
伊東
武藤蘭
叶子楣
-舒淇
-麻衣
櫻井
風花
星野桃
-宝来
桜田
藤井彩
小森美王
-平井
桃井望
榊彩弥
桜井
@@ -876,7 +827,6 @@ A片
長瀬愛
中野千夏
春菜
-望月
岡崎美女
宮下杏奈
加藤
@@ -884,24 +834,12 @@ A片
北島優
一本道
夜勤病栋
-三个代表
-一党
-多党
-民主
-专政
避孕套
你妈逼
大鸡巴
政治
-洪志
-红志
-洪智
-红智
-民运
-王丹
卖春
买春
-天安门
朱容基
朱镕基
温家宝
@@ -915,14 +853,12 @@ A片
黑社会
夜总会
妈个
-公款
坐台
腐败
城管
暴动
李远哲
司法警官
-高干
尉健行
李岚清
黄丽满
@@ -938,19 +874,10 @@ A片
吴邦国
曾庆红
黄菊
-罗干
吴官正
贾庆林
专制
-三個代表
-一黨
-多黨
-專政
大紀元
-紅志
-紅智
-李鵬
-天安門
江澤民
朱鎔基
李長春
@@ -963,9 +890,7 @@ A片
溫家寶
吳邦國
曾慶紅
-黃菊
賈慶林
-專制
反人类
反社会
方励之
@@ -984,12 +909,10 @@ A片
付申奇
傅申奇
傅志寰
-高官
高文谦
高薪养廉
高瞻
高自联
-戈扬
鸽派
个人崇拜
工自联
@@ -1000,10 +923,8 @@ A片
共军
关卓中
贯通两极法
-广闻
郭伯雄
郭罗基
-郭平
郭岩华
国家安全
国家机密
@@ -1017,13 +938,11 @@ A片
红色恐怖
宏法
洪传
-洪吟
洪哲胜
胡紧掏
胡锦滔
胡锦淘
胡景涛
-胡平
胡总书记
护法
花花公子
@@ -1046,9 +965,7 @@ A片
江core
江八点
江流氓
-江罗
江绵恒
-江青
江戏子
江则民
江泽慧
@@ -1064,9 +981,7 @@ A片
教养院
揭批书
金尧如
-锦涛
禁看
-经文
开放杂志
抗议
邝锦文
@@ -1079,8 +994,6 @@ A片
李洪宽
李继耐
李兰菊
-李录
-李禄
李少民
李淑娴
李旺阳
@@ -1099,16 +1012,13 @@ A片
林长盛
林樵清
林慎立
-凌锋
刘宾深
刘宾雁
-刘刚
刘国凯
刘华清
刘俊国
刘凯中
刘千石
-刘青
刘山青
刘士贤
刘文胜
@@ -1153,17 +1063,12 @@ A片
潘国平
泡沫经济
迫害
-祁建
-齐墨
-钱达
钱国梁
钱其琛
抢粮记
-乔石
亲美
钦本立
情妇
-庆红
热比娅
热站政论网
人民内情真相
@@ -1174,11 +1079,8 @@ A片
上海帮
邵家健
神通加持法
-沈彤
升天
盛华仁
-盛雪
-石戈
时代论坛
时事论坛
世界经济导报
@@ -1191,7 +1093,6 @@ A片
司徒华
斯诺
四川独立
-宋平
宋书元
苏绍智
苏晓康
@@ -1204,11 +1105,9 @@ A片
太子党
汤光中
唐柏桥
-唐捷
滕文生
天怒
天葬
-童屹
统独
统独论坛
统战
@@ -1216,10 +1115,8 @@ A片
外交与方略
万润南
万晓东
-汪岷
王宝森
王炳章
-王策
王超华
王辅臣
王涵万
@@ -1246,11 +1143,9 @@ A片
吴学璨
吾尔开希
五不
-伍凡
洗脑
项怀诚
项小吉
-肖强
邪恶
谢长廷
谢选骏
@@ -1269,10 +1164,7 @@ A片
徐匡迪
徐水良
许家屯
-薛伟
学潮
-学联
-学运
学自联
雪山狮子
严家其
@@ -1282,13 +1174,9 @@ A片
央视内部晚会
杨怀安
杨建利
-杨巍
杨月清
-杨周
姚月谦
一中一台
-义解
-亦凡
异见人士
异议人士
易丹轩
@@ -1296,38 +1184,27 @@ A片
尹庆民
由喜贵
游行
-幼齿
于大海
于浩成
余英时
舆论反制
宇明网
远志明
-岳武
-则民
-择民
-泽民
贼民
曾培炎
张伯笠
-张钢
张宏堡
-张健
-张林
张万年
张伟国
张昭富
张志清
赵海青
-赵南
赵品潞
赵晓微
赵紫阳
-哲民
镇压
争鸣论坛
正见网
-郑义
正义党论坛
换妻
真木加美
@@ -1350,12 +1227,9 @@ A片
东京热
菅野亚梨沙
吉岡美穗
-红音
原千寻
熟女
轮奸
-朱琳
-朱毛
朱溶剂
猪聋畸
猪毛
@@ -1373,7 +1247,6 @@ A片
fa轮
亲日
汉奸
-政权
政治反对派
政治犯
支那
@@ -1392,9 +1265,7 @@ fa轮
周锋锁
周天法
陈水扁
-周旋
朱嘉明
-阿扁
二逼
小鸡鸡
卖逼
@@ -1436,7 +1307,6 @@ fa轮
喷你
操逼
淫水
-他妈
操比
杂种
他母亲
@@ -1499,13 +1369,11 @@ B样
北美自由论坛
博讯
蔡崇国
-程凯
大纪元新闻网
大众真人真事
东南西北论谈
封杀
-何勇
江猪媳
酱猪媳
枪支
-毒品
+毒品
\ No newline at end of file
diff --git a/config/harmonious_dictionary/harmonious.hash b/config/harmonious_dictionary/harmonious.hash
index 9ce3b2f93690dda331a3df2e4e06990a362ffef1..456a8254b258a810b2e661f5130946a71a39a915 100644
GIT binary patch
delta 1259
zcmXX_X-rgC810>f_a3t%LmUPjEZVZqAf>c`LL>zOA~IBLLW-!Q2(pukB%o0S5b8E~
zrc|sf!XT7Ew#!n6rD&U&YJW88V%q8tBil5Tk|s7yTbjOk@aN{sx18^sbMI~bPjvZL
zkyOG~i{5UQT8XUr*87ZGvLEZbbQN(eUZ^x{5J+^&wrg%NuNekORLDo
z1Utkv=oOpLA1Q}yLWwZRr$mcyBnkLuN{$ez3MtaJ(9|x6T^dMVNFzk5#m1Wgmd1rO
zJ%MMV-qyPx1`8cQwVzl-=S7v8iWB$lHAk*nLhmYOaLhz!4X>9%7thBCkcO>#Nk
z+>l(zpMNAr(ae-2f_GC>h&%dH)2Q^2S;8&OS%e809>`{CqiJ1+m!%%CpHgBqfTP{n
zUlGD0KPO1MFw;pNzEDmz2>
zRMd;O<$(bq<%R>deq>+z=1@rHAa`<}I+WHAZ2zv5s4`j0wvX=x*4D
zwT4-gHKok5;AJa^GgN8{V_%DJ*^xhUFJ`d$p-oHs_c5LyS1Lo?)$qeEHPc%4-U?`ybO
zsIr(pXvN6T2}BmE#S7CH>EU5JpSp3+Oi6^uW*<)YQqvJ6|yfQWe
zGNI*G#>WLD4zEu7;_zfT9FuQQ_Vd3aNSO8E7N%RaX!y_Su|BJ#IkS5SGQu^ygwx@A
ISmrMN56iLGQUCw|
delta 2573
zcmZuzeNa@_74Lg*VRvD_kOkkmfDvg{Rt$c`IFw{YF`(Abpe8XS5hd|EXv8*(wbccM
zT}0*M$4B^b6=5O3igJm3tbn$*owVaPolerm)K;ha-m;E0nNB*>KWfwa-rFwgv@^`|
z?mg$8^EkOdNPYk47#=L;@m!Rh3wWFG(97eD
z$w+oZSy)@pcUsofNnjhDk>|w5f$$P{p6@WYK9<+BCB(k#_%4aZ<0u^-IgGfewsPW#
z6L-~{SywAoWt*`;a}qDQOn5mqR{BqVp($i|VX`*tPW)J5Kw=BiKb+8t*W9wu3VVz<
zNhY+dQh^}3Z0l6MCG~G&)^p<38j=}1i!#|T64GvfjvpO;hA+&e?WpKZsvV3PxGn;pkGPnUufZ1@GpS6^
zV(9iwdmcMjhN9QZM8EJQ23v>CDz${RcsKkq3xpuekM&BA?+4wjuJob?#UPhVZb;P2h$L@lLJJo8Km2$dC>wMf~8q&RYtn(CEphvkf(NabSXKGn&a>BIJg8B@zBvO{VH88G}xL#84
z8dki7J-^e&+>_(ZafYGh1?&GD7QFW*N8@347tazZo@p0BUoZ0W%vhPKB0t%k%Fx@=vF9sJ7&(XHy|mBN^}@OL
z)|{~^8JwgP9b>=Lh%A@{cOkqymvR>TH2yWddHwFd*;4
zW4QNW8R;)cQ!SgGY6&9}#%73&BvrV2Ev!TJQA~Jp_oD;`JCozk>(;@s(*QkfV5XyA
zP#yzEOF401l58m*RV|S!U*+q1CwWDYOXD#(qJx5<$ih4iwQIlr$Di`MhVQXAnY>qNuJ
zUmGTr{v@NT9KsS$f-ywY6=n8l@xCKV?rF7-TBMfe>y?6&vKZ{RfD4^Gw)N$alJdVr
zaiV(|PtAOqFgh9zPB=3ZhC$B+dKJ4G>~W>w6^~XM^5+~R$6PO{Xf-}O8xP-E0~ef_
zA`@o|nM4WQ^kj&8MV(Gbl6pR*)p@?B#N9xv5#w3B0b(>58op@}E;O>-Dd
zY;VI8nzVuDO&lMXP%fn$``8Rf3|>yb)7EWkg{w+$meUoHB8gkq^=E<_R&pVm`ro_0
zv2BD4`c7ex;}O-KP7by2V2q+mu`b`{ssY^Y_?pH(eBlT9DA|Z77gA~7gw)lM?s
z{SPKN*q~el`M`B$mPi#Nk?Ox=u|p!
z$V{+a;aDoK>B&iXCMR{j!THA;P@~~d(rv^2!&Xde(cohDX0&?VqadGpQc{9#eUUx_
zZW4A+<0QtOe#X!r>Z_99Yh%RQo6Q*gH$u-JY14TLfBIxUTi#Sx$fL8b*f`x3ijqqG
zH{4+R@7n!i${>-uQ_tl{um15Ff~Ya_%lPY1(L)Fw|AK_cxvW-K)sV+c~wz1zpqJlEoa;ls*_MMT9x;a
Y{788+l!D(3S&5A-W^m_-78ox54+d+N761SM
From 2949271f86a6e37ef17b095429fb92e3a172f53f Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 15:21:12 +0800
Subject: [PATCH 04/68] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/myshixun.rb | 1 +
.../subjects/data_statistic_service.rb | 57 +++++++++++++++++--
2 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb
index 1a89c755e..54d068be6 100644
--- a/app/models/myshixun.rb
+++ b/app/models/myshixun.rb
@@ -5,6 +5,7 @@ class Myshixun < ApplicationRecord
has_one :shixun_modify, :dependent => :destroy
belongs_to :user
+ belongs_to :user_extension
belongs_to :shixun, counter_cache: true
has_one :last_executable_task, -> { where(status: [0, 1]).reorder(created_at: :asc) }, class_name: 'Game'
diff --git a/app/services/subjects/data_statistic_service.rb b/app/services/subjects/data_statistic_service.rb
index 29696cf15..4ab7488c6 100644
--- a/app/services/subjects/data_statistic_service.rb
+++ b/app/services/subjects/data_statistic_service.rb
@@ -3,15 +3,20 @@ class Subjects::DataStatisticService < ApplicationService
def initialize(subject, user)
@subject = subject
@user = user
- @shixun_ids = subject.shixuns.pluck(:id)
+ @shixuns = subject.shixuns
+ @shixun_ids = @shixuns.pluck(:id)
end
- # 学习总人数
+ # 学习总人数:
+ # 文案解释:学习该课程的全部人数(学习总人数=课堂学习人数+自主学习人数)
+ # 开发备注:只要点击该课程的任何一个实训(生成了tpi),都算一个学习人数;(去重,一个人数计算1次)
def study_count
- @shixuns.includes(:myshixuns).map{|shixun| shixun.myshixuns.pluck(:user_id)}.uniq
+ @shixuns.joins(:myshixuns).select("myshixuns.user_id").distinct.size
end
- # 课堂学习人数
+ # 课堂学习人数:
+ # 文案解释:通过课堂学习该课程的人数
+ # 开发备注:只要通过课堂进入,并点击了实训(生成了tpi),则算一个可以学习人数;(去重,一个人数计算1次)
def course_study_count
# 实训作业
sw_user_ids = StudentWork.where.not(myshixun_id: nil).joins(homework_common: :homework_commons_shixuns)
@@ -19,6 +24,50 @@ class Subjects::DataStatisticService < ApplicationService
# 试卷的实训题
esa_user_ids = ExerciseShixunAnswer.joins(exercise_shixun_challenge: :shixun)
.where(shixuns: {id: @shixun_ids}).pluck("exercise_shixun_answers.user_id")
+ (sw_user_ids + esa_user_ids).uniq.size
end
+ # 自主学习人数:
+ # 文案解释:通过自主学习该课程的人数
+ # 开发备注:非课程进入,生成了实训的tpi(去重。一个人数计算1次
+ def initiative_study
+ study_count - course_study_count
+ end
+
+ # 通关总人数:
+ # 文案解释:
+ # 通关该课程所有实训的人数(去重。一个人数计算1次)
+ def passed_count
+ @shixuns.includes(:myshixuns).where(myshixuns: {status: 1}).select("myshixuns.user_id").distinct.size
+ end
+
+ # 使用课堂数:
+ # 文案解释:使用该课程的课堂数量
+ # 开发备注:课堂加入该课程的实训到自己课堂,则算一个使用课堂数。(去重,一个课堂计算1次)
+ def course_used_count
+ hc_course_ids =
+ HomeworkCommon.joins(:homework_commons_shixun)
+ .where(homework_type: %i[practice])
+ .where(homework_commons_shixuns: {shixun_id: @shixun_ids}).pluck("homework_commons.course_id").uniq
+ ex_course_ids =
+ Exercise.joins(:exercise_questions)
+ .where(exercise_questions: {question_type: 5, shixun_id: @shixun_ids}).pluck("exercises.course_id").uniq
+
+ (hc_course_ids + ex_course_ids).uniq.size
+ end
+
+ # 使用单位数:
+ # 文案解释:使用该课程的单位数量(包括自主学习者所在单位)
+ # 开发备注:凡事该单位有使用该课程的实训(自主学习+课堂使用)都算;(去重,一个单位计算一次)
+ def school_used_count
+ school_ids.size
+ end
+
+
+ private
+ def school_ids
+ @shixuns.joins(myshixuns: :user_extension).select("user_extensions.school_id").distinct
+ end
+
+
end
From 024da3edf644a84f14b79cf676b84aa090220daa Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 16:51:44 +0800
Subject: [PATCH 05/68] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E4=BD=BF=E7=94=A8?=
=?UTF-8?q?=E6=83=85=E5=86=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../subjects/course_used_info_service.rb | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 app/services/subjects/course_used_info_service.rb
diff --git a/app/services/subjects/course_used_info_service.rb b/app/services/subjects/course_used_info_service.rb
new file mode 100644
index 000000000..188a96fd7
--- /dev/null
+++ b/app/services/subjects/course_used_info_service.rb
@@ -0,0 +1,42 @@
+class Subjects::CourseUsedInfoService < ApplicationService
+ attr_reader :subject, :user
+ def initialize(subject, user)
+ @subject = subject
+ @user = user
+ @shixuns = subject.shixuns
+ @shixun_ids = @shixuns.pluck(:id)
+ end
+
+ def call
+ return if subject.blank?
+ homework_commons =
+ HomeworkCommon.joins(:homework_commons_shixun)
+ .where(homework_type: %i[practice])
+ .where(homework_commons_shixuns: {shixun_id: @shixun_ids})
+ course_ids = homework_commons.pluck(:course_id)
+ homework_common_ids = homework_commons.pluck("homework_commons.id")
+ schools = School.joins(courses: [:course_members, :homework_commons])
+
+ # name:将该课程使用到课堂的单位
+ # course_count: 将该课程使用到课堂的数量
+ # student_count: 课堂的学生总数(去掉重复)
+ # choice_shixun_num: 选用该课程实训的个数(去重)
+ # choice_shixun_frequency: 选用该课程实训的次数
+ course_info =
+ schools.map do |school|
+ name = school.name
+ course_count = school.where(courses: {id: course_ids}).count
+ student_count = school.where(course_members: {role: 4}).select("course_members.user_id").distinct.size
+ homework_commons = school.where(homework_commons: {id: homework_common_ids})
+ .select("homework_commons.id")
+ choice_shixun_num = homework_commons.distinct.size
+ choice_shixun_frequency = homework_commons.size
+ {name: name, course_count: course_count, student_count: student_count, choice_shixun_num: choice_shixun_num,
+ choice_shixun_frequency: choice_shixun_frequency}
+ end
+ # 默认按照选用实训的次数作为排序
+ course_info.sort{|x,y| y['choice_shixun_frequency'] <=> x['choice_shixun_frequency']}
+ end
+
+end
+
From dc0e45c0ed535a5a3e0bc3273265e556cbae23fe Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 18:51:53 +0800
Subject: [PATCH 06/68] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../subjects/course_used_info_service.rb | 8 ++---
.../subjects/data_statistic_service.rb | 5 ++-
.../subjects/shixun_used_info_service.rb | 31 +++++++++++++++++++
3 files changed, 36 insertions(+), 8 deletions(-)
create mode 100644 app/services/subjects/shixun_used_info_service.rb
diff --git a/app/services/subjects/course_used_info_service.rb b/app/services/subjects/course_used_info_service.rb
index 188a96fd7..f60c4a6ca 100644
--- a/app/services/subjects/course_used_info_service.rb
+++ b/app/services/subjects/course_used_info_service.rb
@@ -1,10 +1,8 @@
class Subjects::CourseUsedInfoService < ApplicationService
- attr_reader :subject, :user
- def initialize(subject, user)
+ attr_reader :subject
+ def initialize(subject)
@subject = subject
- @user = user
- @shixuns = subject.shixuns
- @shixun_ids = @shixuns.pluck(:id)
+ @shixun_ids = subject.shixuns.pluck(:id)
end
def call
diff --git a/app/services/subjects/data_statistic_service.rb b/app/services/subjects/data_statistic_service.rb
index 4ab7488c6..9dc2db09a 100644
--- a/app/services/subjects/data_statistic_service.rb
+++ b/app/services/subjects/data_statistic_service.rb
@@ -1,8 +1,7 @@
class Subjects::DataStatisticService < ApplicationService
- attr_reader :subject, :user
- def initialize(subject, user)
+ attr_reader :subject
+ def initialize(subject)
@subject = subject
- @user = user
@shixuns = subject.shixuns
@shixun_ids = @shixuns.pluck(:id)
end
diff --git a/app/services/subjects/shixun_used_info_service.rb b/app/services/subjects/shixun_used_info_service.rb
new file mode 100644
index 000000000..1dda483d4
--- /dev/null
+++ b/app/services/subjects/shixun_used_info_service.rb
@@ -0,0 +1,31 @@
+class Subjects::ShixunUsedInfoService < ApplicationService
+ attr_reader :subject, :stages
+ def initialize(subject)
+ @subject = subject
+ @stages = subject.stages.includes(shixuns: [myshixuns: :games, homework_commons_shixuns: [homework_common: :course]])
+ end
+
+ def call
+ shixun_infos = []
+ stages.each do |stage|
+ position = stage.position
+ stage.shixuns.each_with_index do |shixun, index|
+ stage = "#{position}-#{index+1}"
+ name = shixun.name
+ challenge_count = shixun.challenges_count
+ course_count = shixun.homework_commons_shixuns.select{|hcs| hcs.homework_common.course_id}.uniq.size
+ school_count = shixun.homework_commons_shixuns.select{|hcs| hcs.homework_common.course.school_id}.uniq.size
+ used_count = shixun.myshixuns_count
+ passed_count = shixun.myshixuns.select{|m| m.status == 1}.size
+ evaluate_count = shixun.myshixuns.map{|m| m.games.sum(:evaluate_count).to_i}.sum
+ passed_ave_time = (passed_count > 0) ?
+ (shixun.myshixuns.map{|m| m.status == 1 && m.games.sum(:cost_time).to_i}.sum / passed_count) : 0
+ shixun_infos << {stage: stage, name: name, challenge_count: challenge_count, course_count: course_count,
+ school_count: school_count, used_count: used_count, passed_count: passed_count,
+ evaluate_count: evaluate_count, passed_ave_time: passed_ave_time}
+ end
+ shixun_infos
+ end
+ end
+
+end
From 11155590fa5f397d682577c8f41874d394dfcea5 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Wed, 8 Jan 2020 20:09:05 +0800
Subject: [PATCH 07/68] =?UTF-8?q?=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/user.rb | 1 +
.../subjects/user_used_info_service.rb | 30 +++++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100644 app/services/subjects/user_used_info_service.rb
diff --git a/app/models/user.rb b/app/models/user.rb
index 54aa8d85e..dd606f7bc 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -43,6 +43,7 @@ class User < ApplicationRecord
has_many :shixun_members, :dependent => :destroy
has_many :shixuns, :through => :shixun_members
has_many :myshixuns, :dependent => :destroy
+ has_many :games, :dependent => :destroy
has_many :study_shixuns, through: :myshixuns, source: :shixun # 已学习的实训
has_many :course_messages
has_many :courses, foreign_key: 'tea_id', dependent: :destroy
diff --git a/app/services/subjects/user_used_info_service.rb b/app/services/subjects/user_used_info_service.rb
new file mode 100644
index 000000000..4d5f54f9e
--- /dev/null
+++ b/app/services/subjects/user_used_info_service.rb
@@ -0,0 +1,30 @@
+class Subject::UserUsedInfoService < ApplicationService
+ attr_reader :subject, :shixun_ids
+
+ def initialize(subject)
+ @subject = subject
+ @shixun_ids = subject.shixuns.pluck(:id)
+
+ end
+
+ def call
+ users = User.joins(:myshixuns).where(myshixuns: {shixun_id: shixun_ids}).group(:user_id)
+
+ users_info = []
+ users.includes(:myshixuns, :games).each do |user|
+ games = user.games
+ name = "#{user.lastname}#{user.firstname}"
+ passed_myshixun_count = user.myshixuns.select{|m| m.status == 1}.size
+ passed_games_count = games.select{|g| g.status == 2}.size
+ code_line_count = "未完成"
+ evaluate_count = games.sum(evaluate_count)
+ cost_time = games.sum(:cost_time)
+ user_login = user.login
+ users_info << {login: user_login, name: name, passed_myshixun_count: passed_myshixun_count,
+ passed_games_count: passed_games_count, code_line_count: code_line_count,
+ evaluate_count: evaluate_count, cost_time: cost_time}
+ end
+ users_info
+ end
+
+end
From 3848ab142ae5e834d9910a1eb7af729299501111 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 9 Jan 2020 11:53:06 +0800
Subject: [PATCH 08/68] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../shixun_work/shixun_work.html.erb | 32 ++++++++++---------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb
index 76a269f3f..04ba5e038 100644
--- a/app/templates/shixun_work/shixun_work.html.erb
+++ b/app/templates/shixun_work/shixun_work.html.erb
@@ -240,25 +240,27 @@
window.onload = function() {
console.debug("window.onload");
- <% @games.map(&:id).each do |game_id| %>
+ <% if @games %>
+ <% @games.map(&:id).each do |game_id| %>
var ele = document.getElementById("content_show_<%= game_id %>");
if (ele) {
- var ide = CodeMirror.fromTextArea(ele, {
- lineNumbers: true,
- theme: "default",
- // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
- indentUnit: 4, //代码缩进为一个tab的距离
- matchBrackets: true,
- autoRefresh: true,
- smartIndent: true,//智能换行
- styleActiveLine: true,
- lineWrapping: true,
- lint: true,
- readOnly: "nocursor"
- });
+ var ide = CodeMirror.fromTextArea(ele, {
+ lineNumbers: true,
+ theme: "default",
+ // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
+ indentUnit: 4, //代码缩进为一个tab的距离
+ matchBrackets: true,
+ autoRefresh: true,
+ smartIndent: true,//智能换行
+ styleActiveLine: true,
+ lineWrapping: true,
+ lint: true,
+ readOnly: "nocursor"
+ });
- ide.setSize("auto", ide.lineCount() * 18);
+ ide.setSize("auto", ide.lineCount() * 18);
}
+ <% end %>
<% end %>
From 1159fa72ab1fa15174d338e97f4daf4863e2571b Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 9 Jan 2020 11:56:12 +0800
Subject: [PATCH 09/68] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/templates/shixun_work/shixun_work.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb
index 04ba5e038..fa2ad8101 100644
--- a/app/templates/shixun_work/shixun_work.html.erb
+++ b/app/templates/shixun_work/shixun_work.html.erb
@@ -240,7 +240,7 @@
window.onload = function() {
console.debug("window.onload");
- <% if @games %>
+ <% if @games.present? %>
<% @games.map(&:id).each do |game_id| %>
var ele = document.getElementById("content_show_<%= game_id %>");
if (ele) {
From c0eb4c9e87b82eb114dd0bb6f3e68604cc83aa7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 9 Jan 2020 12:23:04 +0800
Subject: [PATCH 10/68] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/AppConfig.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js
index 1c626a12c..535b19a94 100644
--- a/public/react/src/AppConfig.js
+++ b/public/react/src/AppConfig.js
@@ -42,7 +42,7 @@ if (isDev) {
// 老师
//debugType="teacher";
// 学生
-debugType="student";
+//debugType="student";
function railsgettimes(proxy) {
From 94496499c8a95afa226950a436d53a5fd80ccd3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 9 Jan 2020 12:29:02 +0800
Subject: [PATCH 11/68] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E6=88=AA=E6=AD=A2?=
=?UTF-8?q?=E6=89=8D=E6=98=BE=E7=A4=BA=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/exercise/Testpapersettinghomepage.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js
index 47f42405d..ccf29a225 100644
--- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js
+++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js
@@ -356,7 +356,7 @@ class Testpapersettinghomepage extends Component{
{this.props.isAdmin()===true?
From 7c10000ce7ab7e4444fdc78ef8fbd9dea371c69d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 9 Jan 2020 12:56:03 +0800
Subject: [PATCH 12/68] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/exercise/Testpapersettinghomepage.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js
index ccf29a225..63bdbd170 100644
--- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js
+++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js
@@ -356,7 +356,7 @@ class Testpapersettinghomepage extends Component{
{this.props.isAdmin()===true?
@@ -364,7 +364,8 @@ class Testpapersettinghomepage extends Component{
}
From a60c0636c1fcd3f05506412ec28a33b4c43fbe78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com>
Date: Thu, 9 Jan 2020 13:38:53 +0800
Subject: [PATCH 13/68] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/modules/tpm/TPMIndexHOC.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js
index f46835959..aa88d7ea7 100644
--- a/public/react/src/modules/tpm/TPMIndexHOC.js
+++ b/public/react/src/modules/tpm/TPMIndexHOC.js
@@ -35,14 +35,14 @@ if (!window['indexHOCLoaded']) {
// $('head').append($('')
// .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`));
$('head').append($('')
- .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?2021`));
+ .attr('href', `${_url_origin}/stylesheets/css/edu-common.css?2`));
$('head').append($('')
- .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?2021`));
+ .attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?2`));
// index.html有加载
$('head').append($('')
- .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?2021`));
+ .attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?2`));
// $('head').append($('')
From ab02572d066816a0c3074ad277a85c82ce404362 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 9 Jan 2020 13:39:07 +0800
Subject: [PATCH 14/68] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/subjects_controller.rb | 19 +++++++++++++++
app/models/myshixun.rb | 4 ++--
.../subjects/course_used_info_service.rb | 12 +++++-----
.../subjects/data_statistic_service.rb | 8 +++----
.../subjects/shixun_used_info_service.rb | 13 +++++++---
.../subjects/user_used_info_service.rb | 24 +++++++++----------
config/routes.rb | 1 +
7 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb
index 7df9aae89..eb12c4f0d 100644
--- a/app/controllers/subjects_controller.rb
+++ b/app/controllers/subjects_controller.rb
@@ -456,6 +456,25 @@ class SubjectsController < ApplicationController
end
end
+ def statistics_new
+ # data = Subjects::DataStatisticService.new(@subject)
+ # Rails.logger.info("study_count: #{data.study_count}")
+ # Rails.logger.info("course_study_count: #{ data.course_study_count}")
+ # Rails.logger.info("passed_count: #{data.passed_count}")
+ # Rails.logger.info("course_used_count: #{data.course_used_count}")
+ # Rails.logger.info("school_used_count: #{data.school_used_count}")
+
+ # data_1 = Subjects::CourseUsedInfoService.call(@subject)
+ # Rails.logger.info("study_count: #{data_1}")
+
+ # data_2 = Subjects::ShixunUsedInfoService.call(@subject)
+ # Rails.logger.info("study_count: #{data_2}")
+
+ data_3 = Subjects::UserUsedInfoService.call(@subject)
+ Rails.logger.info("study_count: #{data_3}")
+ render_ok()
+ end
+
def shixun_report
end
diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb
index 54d068be6..8d2012381 100644
--- a/app/models/myshixun.rb
+++ b/app/models/myshixun.rb
@@ -5,7 +5,7 @@ class Myshixun < ApplicationRecord
has_one :shixun_modify, :dependent => :destroy
belongs_to :user
- belongs_to :user_extension
+ belongs_to :user_extension, foreign_key: :user_id
belongs_to :shixun, counter_cache: true
has_one :last_executable_task, -> { where(status: [0, 1]).reorder(created_at: :asc) }, class_name: 'Game'
@@ -22,7 +22,7 @@ class Myshixun < ApplicationRecord
end
def output_times
- games.pluck(:evaluate_count).sum.to_i
+ games.map(&:evaluate_count).sum.to_i
end
def repo_path
diff --git a/app/services/subjects/course_used_info_service.rb b/app/services/subjects/course_used_info_service.rb
index f60c4a6ca..5553c7222 100644
--- a/app/services/subjects/course_used_info_service.rb
+++ b/app/services/subjects/course_used_info_service.rb
@@ -13,7 +13,7 @@ class Subjects::CourseUsedInfoService < ApplicationService
.where(homework_commons_shixuns: {shixun_id: @shixun_ids})
course_ids = homework_commons.pluck(:course_id)
homework_common_ids = homework_commons.pluck("homework_commons.id")
- schools = School.joins(courses: [:course_members, :homework_commons])
+ schools = School.joins(:courses).where(courses: {id: course_ids}).select("schools.*, count(courses.id) course_count")
# name:将该课程使用到课堂的单位
# course_count: 将该课程使用到课堂的数量
@@ -23,11 +23,11 @@ class Subjects::CourseUsedInfoService < ApplicationService
course_info =
schools.map do |school|
name = school.name
- course_count = school.where(courses: {id: course_ids}).count
- student_count = school.where(course_members: {role: 4}).select("course_members.user_id").distinct.size
- homework_commons = school.where(homework_commons: {id: homework_common_ids})
- .select("homework_commons.id")
- choice_shixun_num = homework_commons.distinct.size
+ course_count = school.course_count
+ student_count = school.courses.joins(:course_members).where(course_members: {role: 4, course_id: course_ids})
+ homework_commons = school.courses.joins(:homework_commons).where(homework_commons: {id: homework_common_ids})
+ .pluck("homework_commons.id")
+ choice_shixun_num = homework_commons.uniq.size
choice_shixun_frequency = homework_commons.size
{name: name, course_count: course_count, student_count: student_count, choice_shixun_num: choice_shixun_num,
choice_shixun_frequency: choice_shixun_frequency}
diff --git a/app/services/subjects/data_statistic_service.rb b/app/services/subjects/data_statistic_service.rb
index 9dc2db09a..25a83aa26 100644
--- a/app/services/subjects/data_statistic_service.rb
+++ b/app/services/subjects/data_statistic_service.rb
@@ -10,7 +10,7 @@ class Subjects::DataStatisticService < ApplicationService
# 文案解释:学习该课程的全部人数(学习总人数=课堂学习人数+自主学习人数)
# 开发备注:只要点击该课程的任何一个实训(生成了tpi),都算一个学习人数;(去重,一个人数计算1次)
def study_count
- @shixuns.joins(:myshixuns).select("myshixuns.user_id").distinct.size
+ @shixuns.joins(:myshixuns).pluck("myshixuns.user_id").uniq.size
end
# 课堂学习人数:
@@ -18,7 +18,7 @@ class Subjects::DataStatisticService < ApplicationService
# 开发备注:只要通过课堂进入,并点击了实训(生成了tpi),则算一个可以学习人数;(去重,一个人数计算1次)
def course_study_count
# 实训作业
- sw_user_ids = StudentWork.where.not(myshixun_id: nil).joins(homework_common: :homework_commons_shixuns)
+ sw_user_ids = StudentWork.where.not(myshixun_id: nil).joins(homework_common: :homework_commons_shixun)
.where(homework_commons_shixuns: {shixun_id: @shixun_ids}).pluck("student_works.user_id")
# 试卷的实训题
esa_user_ids = ExerciseShixunAnswer.joins(exercise_shixun_challenge: :shixun)
@@ -37,7 +37,7 @@ class Subjects::DataStatisticService < ApplicationService
# 文案解释:
# 通关该课程所有实训的人数(去重。一个人数计算1次)
def passed_count
- @shixuns.includes(:myshixuns).where(myshixuns: {status: 1}).select("myshixuns.user_id").distinct.size
+ @shixuns.includes(:myshixuns).where(myshixuns: {status: 1}).pluck("myshixuns.user_id").uniq.size
end
# 使用课堂数:
@@ -65,7 +65,7 @@ class Subjects::DataStatisticService < ApplicationService
private
def school_ids
- @shixuns.joins(myshixuns: :user_extension).select("user_extensions.school_id").distinct
+ @shixuns.joins(myshixuns: :user_extension).pluck("user_extensions.school_id").uniq
end
diff --git a/app/services/subjects/shixun_used_info_service.rb b/app/services/subjects/shixun_used_info_service.rb
index 1dda483d4..f1c4a373d 100644
--- a/app/services/subjects/shixun_used_info_service.rb
+++ b/app/services/subjects/shixun_used_info_service.rb
@@ -17,15 +17,22 @@ class Subjects::ShixunUsedInfoService < ApplicationService
school_count = shixun.homework_commons_shixuns.select{|hcs| hcs.homework_common.course.school_id}.uniq.size
used_count = shixun.myshixuns_count
passed_count = shixun.myshixuns.select{|m| m.status == 1}.size
- evaluate_count = shixun.myshixuns.map{|m| m.games.sum(:evaluate_count).to_i}.sum
- passed_ave_time = (passed_count > 0) ?
- (shixun.myshixuns.map{|m| m.status == 1 && m.games.sum(:cost_time).to_i}.sum / passed_count) : 0
+ evaluate_count = shixun.myshixuns.map{|m| m.output_times }.sum
+ passed_ave_time = passed_count > 0 ? shixun.myshixuns.map{|m| m.total_cost_time}.sum : 0
+ #evaluate_count = shixun.myshixuns.joins(:games).select("SUM(games.evaluate_count) evaluate_count").first.evaluate_count
+ # passed_ave_time = (passed_count > 0) ?
+ # (shixun.myshixuns.joins(:games)
+ # .where(myshixuns: {status: 1})
+ # .select("SUM(games.cost_time) cost_time").first.cost_time / passed_count) : 0
+
shixun_infos << {stage: stage, name: name, challenge_count: challenge_count, course_count: course_count,
school_count: school_count, used_count: used_count, passed_count: passed_count,
evaluate_count: evaluate_count, passed_ave_time: passed_ave_time}
end
shixun_infos
end
+
+
end
end
diff --git a/app/services/subjects/user_used_info_service.rb b/app/services/subjects/user_used_info_service.rb
index 4d5f54f9e..6e3738f42 100644
--- a/app/services/subjects/user_used_info_service.rb
+++ b/app/services/subjects/user_used_info_service.rb
@@ -1,4 +1,4 @@
-class Subject::UserUsedInfoService < ApplicationService
+class Subjects::UserUsedInfoService < ApplicationService
attr_reader :subject, :shixun_ids
def initialize(subject)
@@ -8,21 +8,19 @@ class Subject::UserUsedInfoService < ApplicationService
end
def call
- users = User.joins(:myshixuns).where(myshixuns: {shixun_id: shixun_ids}).group(:user_id)
-
users_info = []
- users.includes(:myshixuns, :games).each do |user|
- games = user.games
- name = "#{user.lastname}#{user.firstname}"
- passed_myshixun_count = user.myshixuns.select{|m| m.status == 1}.size
- passed_games_count = games.select{|g| g.status == 2}.size
+ users = User.includes(myshixuns: :games).where(myshixuns: {shixun_id: shixun_ids}, games: {status: 2})
+ users.each do |user|
+ myshixuns = user.myshixuns.select{|m| shixun_ids.include?(m.shixun_id)}
+ name = "#{user.lastname}#{user.firstname}"
+ passed_myshixun_count = myshixuns.select{|m| m.status == 1}.size
+ passed_games_count = myshixuns.map{|m| m.games.select{|g| g.status == 2}.size }.size
code_line_count = "未完成"
- evaluate_count = games.sum(evaluate_count)
- cost_time = games.sum(:cost_time)
- user_login = user.login
- users_info << {login: user_login, name: name, passed_myshixun_count: passed_myshixun_count,
+ evaluate_count = myshixuns.map{|m| m.output_times }.sum
+ cost_time = myshixuns.map{|m|m.total_cost_time }.sum
+ users_info << {login: user.login, name: name, passed_myshixun_count: passed_myshixun_count,
passed_games_count: passed_games_count, code_line_count: code_line_count,
- evaluate_count: evaluate_count, cost_time: cost_time}
+ evaluate_count: evaluate_count, cost_time: cost_time}
end
users_info
end
diff --git a/config/routes.rb b/config/routes.rb
index a65a7f4c1..39e9aca18 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -394,6 +394,7 @@ Rails.application.routes.draw do
get 'cancel_publish'
get 'cancel_has_publish'
get 'statistics'
+ get 'statistics_new'
get 'shixun_report'
get 'school_report'
post 'update_attr'
From df07530fe42e42314a3d8defd9315034bc313148 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 9 Jan 2020 13:52:20 +0800
Subject: [PATCH 15/68] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../shixun_work/shixun_work.html.erb | 215 +++++++++---------
1 file changed, 108 insertions(+), 107 deletions(-)
diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb
index fa2ad8101..9a8481f94 100644
--- a/app/templates/shixun_work/shixun_work.html.erb
+++ b/app/templates/shixun_work/shixun_work.html.erb
@@ -178,20 +178,21 @@
实训详情
<%#= ApplicationController.helpers.javascript_include_tag "/codemirror/lib/codemirror", "/codemirror/mode/javascript/javascript", "/codemirror/addon/hint/show-hint", "/codemirror/addon/hint/javascript-hint", "/codemirror/addon/selection/active-line", "/codemirror/addon/lint/javascript-lint", "/codemirror/addon/lint/css-lint", "/codemirror/addon/lint/lint", "/codemirror/addon/lint/json-lint", "/editormd/lib/codemirror/addon/lint/css-lint" %>
- <% @games.each_with_index do |game, index| %>
+ <% @challenges.each_with_index do |challenge, index| %>
+ <% game = @games.select{|game| game.challenge_id == challenge.id}.first if @games %>
- <% if game.challenge.st == 1 %>
+ <% if challenge.st == 1 %>
<% else %>
<% end %>
- 第<%= index+1 %>关<%= game.challenge.subject %>
+ 第<%= index+1 %>关<%= challenge.subject %>
- <% if game.outputs.present? %>
+ <% if game.present? && game.outputs.present? %>
<% end %>
- <% if game.try(:lastest_code).present? && game.challenge.st == 0 %>
+ <% if game.present? && game.try(:lastest_code).present? && challenge.st == 0 %>
最近通过的代码
@@ -261,110 +262,108 @@
ide.setSize("auto", ide.lineCount() * 18);
}
<% end %>
- <% end %>
+ // 基于准备好的dom,初始化echarts实例
+ if(document.getElementById('shixun_skill_chart')){
+ var effChart = echarts.init(document.getElementById('shixun_skill_chart'));
+ // 指定图表的配置项和数据
+ var option = {
+ grid: {
+ left: '3%',
+ right: '9%',
+ bottom: '3%',
+ containLabel: true
+ },
+ tooltip : {},
+ xAxis : [
+ {
+ type : 'value',
+ name: '学生序号',
+ scale:true,
+ axisLabel : {
+ formatter: ' '
+ },
+ axisTick:{
+ show:false
+ },
+ splitLine: {
+ show: false
+ }
+ }
+ ],
+ yAxis : [
+ {
+ type : 'value',
+ name : '工作效率',
+ scale:true,
+ axisLabel : {
+ formatter: '{value} '
+ },
+ splitLine: {
+ show: false
+ }
+ }
+ ],
+ series : [
+ {
+ name:'',
+ type:'scatter',
+ data: <%= @echart_data[:efficiency_list] %>,
+ itemStyle:{
+ normal:{color:'#2e65ad'}
+ },
+ markArea: {
+ silent: true,
+ itemStyle: {
+ normal: {
+ color: 'transparent',
+ borderWidth: 1,
+ borderType: 'dashed'
+ }
+ }
+ },
+ markPoint : {
+ data : [
+ {
+ name: 'daiao',
+ xAxis:<%= @myself_eff[0] %>,
+ yAxis:<%= @myself_eff[1] %>
+ }
+ ],
+ itemStyle: {
+ normal:{
+ color:'#c23531'
+ }
+ }
+ },
+ markLine : {
+ lineStyle: {
+ normal: {
+ type: 'solid',
+ color:'#c23531'
+ }
+ },
+ data : [
+ {type : 'average', name: '中位值'}
+ ]
+ }
+ },
+ {
+ name:'二班',
+ type:'scatter',
+ data: [<%= @myself_eff %>],
+ itemStyle:{
+ color:'#c23531'
+ }
+ }
+ ]
+ };
+ // 使用刚指定的配置项和数据显示图表
+ effChart.setOption(option);
+ console.debug(<%= @myself_consume %>);
+ }
- // 基于准备好的dom,初始化echarts实例
- if(document.getElementById('shixun_skill_chart')){
- var effChart = echarts.init(document.getElementById('shixun_skill_chart'));
- // 指定图表的配置项和数据
- var option = {
- grid: {
- left: '3%',
- right: '9%',
- bottom: '3%',
- containLabel: true
- },
- tooltip : {},
- xAxis : [
- {
- type : 'value',
- name: '学生序号',
- scale:true,
- axisLabel : {
- formatter: ' '
- },
- axisTick:{
- show:false
- },
- splitLine: {
- show: false
- }
- }
- ],
- yAxis : [
- {
- type : 'value',
- name : '工作效率',
- scale:true,
- axisLabel : {
- formatter: '{value} '
- },
- splitLine: {
- show: false
- }
- }
- ],
- series : [
- {
- name:'',
- type:'scatter',
- data: <%= @echart_data[:efficiency_list] %>,
- itemStyle:{
- normal:{color:'#2e65ad'}
- },
- markArea: {
- silent: true,
- itemStyle: {
- normal: {
- color: 'transparent',
- borderWidth: 1,
- borderType: 'dashed'
- }
- }
- },
- markPoint : {
- data : [
- {
- name: 'daiao',
- xAxis:<%= @myself_eff[0] %>,
- yAxis:<%= @myself_eff[1] %>
- }
- ],
- itemStyle: {
- normal:{
- color:'#c23531'
- }
- }
- },
- markLine : {
- lineStyle: {
- normal: {
- type: 'solid',
- color:'#c23531'
- }
- },
- data : [
- {type : 'average', name: '中位值'}
- ]
- }
- },
- {
- name:'二班',
- type:'scatter',
- data: [<%= @myself_eff %>],
- itemStyle:{
- color:'#c23531'
- }
- }
- ]
- };
- // 使用刚指定的配置项和数据显示图表
- effChart.setOption(option);
- console.debug(<%= @myself_consume %>);
- }
-
- if(document.getElementById('shixun_skill_chart')) {
+ if(document.getElementById('shixun_overall_ablility_chart')) {
var ablChart = echarts.init(document.getElementById('shixun_overall_ablility_chart'));
var dataBJ = <%= @echart_data[:consume_list] %>;
var schema = [
@@ -479,6 +478,8 @@
// 使用刚指定的配置项和数据显示图表。
ablChart.setOption(option1);
}
+ <% end %>
+
}