diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java index 000153ed..190d425e 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java @@ -417,7 +417,7 @@ public class CoreBaseService { try { String display = ""; - Method methodByName = ReflectUtil.getMethodByName(bean.getClass(), "get" + StrUtil.upperFirst(dict.value())); + Method methodByName = ReflectUtil.getMethodByName(field.getType(), "get" + StrUtil.upperFirst(dict.value())); Assert.notNull(methodByName, field.getName() + " 缺少getter方法"); Object enumValue = ReflectUtil.invoke(field.get(ext), methodByName); if (ObjectUtil.isNotEmpty(enumValue)) { diff --git a/data_base_design/天泽数据大平台.pdb b/data_base_design/天泽数据大平台.pdb index 175e9bbf..bad5aace 100644 --- a/data_base_design/天泽数据大平台.pdb +++ b/data_base_design/天泽数据大平台.pdb @@ -1,5 +1,5 @@ - + @@ -4245,8 +4245,8 @@ Shadow=0 1661873621 1662047569 -((246268,43472), (264930,44072)) -((246268,43775),(262159,43775),(262159,43772),(264930,43772)) +((246268,43682), (266029,44282)) +((246268,43775),(262159,43775),(262159,43982),(266029,43982)) 1 8 16744576 @@ -4266,8 +4266,8 @@ Shadow=0 1661873633 1663942424 -((276082,55755), (276682,70644)) -((276382,70644),(276382,55755)) +((276072,55453), (276672,70644)) +((276372,70644),(276372,55453)) 1 8 16744576 @@ -4287,8 +4287,8 @@ Shadow=0 1661955336 1662048056 -((262886,18534), (281960,23328)) -((262886,18534),(262886,23028),(281960,23028)) +((262886,18534), (283315,23535)) +((262886,18534),(262886,23235),(283315,23235)) 1 8 16744576 @@ -4329,8 +4329,8 @@ Shadow=0 1661960819 1662647010 -((307769,27554), (308637,43057)) -((307769,43057),(307769,35670),(308337,35670),(308337,27554)) +((306801,27571), (307812,43062)) +((307812,43062),(307812,35670),(307101,35670),(307101,27571)) 1 8 16744576 @@ -4391,8 +4391,8 @@ Shadow=0 1662020600 1663511274 -((308526,-926), (328444,24981)) -((328444,-926),(328444,11662),(308826,11662),(308826,24981)) +((307242,-926), (328444,25106)) +((328444,-926),(328444,11662),(307542,11662),(307542,25106)) 1 8 16744576 @@ -4412,8 +4412,8 @@ Shadow=0 1662020790 1662647017 -((284883,31246), (286110,48451)) -((286110,48451),(286110,37421),(285183,37421),(285183,31246)) +((285142,31108), (286521,48461)) +((285142,48461),(285142,37421),(286221,37421),(286221,31108)) 1 8 16744576 @@ -4433,8 +4433,8 @@ Shadow=0 1662045015 1664295296 -((248596,52557), (276561,53260)) -((248596,53260),(262008,53260),(262008,52857),(276561,52857)) +((248596,52379), (276525,53260)) +((248596,53260),(262008,53260),(262008,52679),(276525,52679)) 1 8 16744576 @@ -4454,8 +4454,8 @@ Shadow=0 1662046228 1662647031 -((302015,-1243), (302615,27790)) -((302023,-1243),(302023,15258),(302315,15258),(302315,27790)) +((301371,-1243), (302023,27797)) +((302023,-1243),(302023,15258),(301671,15258),(301671,27797)) 1 8 16744576 @@ -4474,9 +4474,9 @@ Shadow=0 1662047541 -1662047695 -((250779,30697), (297018,31870)) -((250779,31870),(278057,31870),(278057,30997),(297018,30997)) +1664863137 +((250779,30569), (296894,32209)) +((250779,32209),(278057,32209),(278057,30869),(296894,30869)) 1 8 16744576 @@ -4496,8 +4496,8 @@ Shadow=0 1662048005 1662048061 -((230014,25632), (295754,27797)) -((230014,27797),(230014,25932),(295754,25932)) +((230014,25717), (295754,28276)) +((230014,28276),(230014,26017),(295754,26017)) 1 8 16744576 @@ -4517,8 +4517,8 @@ Shadow=0 1662647833 1662647877 -((284029,14785), (284830,27625)) -((284830,14785),(284830,20457),(284329,20457),(284329,27625)) +((284830,14785), (285751,27639)) +((284830,14785),(284830,20457),(285451,20457),(285451,27639)) 1 8 16744576 @@ -4556,8 +4556,8 @@ Shadow=0 1662810688 1663748414 -((296433,28995), (338650,29922)) -((338650,28995),(319044,28995),(319044,29622),(296433,29622)) +((296366,28995), (338650,29852)) +((338650,28995),(319044,28995),(319044,29552),(296366,29552)) 1 8 16744576 @@ -4577,8 +4577,8 @@ Shadow=0 1662865795 1663518168 -((286927,15194), (337794,23674)) -((337794,15194),(319320,15194),(319320,23374),(286927,23374)) +((287794,15194), (337794,23866)) +((337794,15194),(319320,15194),(319320,23566),(287794,23566)) 1 8 16744576 @@ -4598,8 +4598,8 @@ Shadow=0 1664451291 1664451291 -((242400,17940), (284580,26940)) -((242400,17940),(242400,26640),(284580,26640)) +((241808,17898), (285677,26995)) +((241808,17898),(241808,26695),(285677,26695)) 1 8 16744576 @@ -4618,8 +4618,8 @@ Shadow=0 1664451372 1664451372 -((206700,6900), (233940,18540)) -((206700,6900),(206700,18240),(233940,18240)) +((206557,6841), (234162,18485)) +((206557,6841),(206557,18185),(234162,18185)) 1 8 16744576 @@ -4638,8 +4638,8 @@ Shadow=0 1664453932 1664453932 -((234320,-16131), (248051,15668)) -((248051,-16131),(234620,-16131),(234620,15668)) +((234477,-16251), (248093,15721)) +((248093,-16251),(234777,-16251),(234777,15721)) 1 8 16744576 @@ -4658,8 +4658,8 @@ Shadow=0 1664461421 1664461421 -((290881,-26780), (299893,-3621)) -((290881,-26780),(290881,-10490),(299593,-10490),(299593,-3621)) +((290808,-26815), (299893,-3621)) +((290808,-26815),(290808,-10490),(299593,-10490),(299593,-3621)) 1 8 16744576 @@ -4679,7 +4679,7 @@ Shadow=0 1623769194 1664366507 -1 -((-9459,51176), (6463,66472)) +((-8713,51503), (5717,66145)) 12615680 16570034 12632256 @@ -4704,7 +4704,7 @@ LABL 0 新宋体,8,N 1623769937 1662650462 -1 -((-9331,11854), (6591,25350)) +((-8585,12140), (5845,25064)) 12615680 16570034 12632256 @@ -4756,7 +4756,7 @@ LABL 0 新宋体,8,N 1623770338 1662650462 -1 -((-9283,-14307), (6639,89)) +((-8537,-14000), (5893,-218)) 12615680 16570034 12632256 @@ -4835,7 +4835,7 @@ LABL 0 新宋体,8,N 1623826338 1664366507 -1 -((40688,49404), (68722,57500)) +((42066,49567), (67344,57337)) 12615680 16570034 12632256 @@ -4860,7 +4860,7 @@ LABL 0 新宋体,8,N 1623828456 1661907266 -1 -((8540,1660), (34844,17856)) +((9827,2008), (33557,17508)) 12615680 16570034 12632256 @@ -4885,7 +4885,7 @@ LABL 0 新宋体,8,N 1623828633 1661907266 -1 -((10906,-10357), (31586,-461)) +((11900,-10153), (30592,-665)) 12615680 16570034 12632256 @@ -4910,7 +4910,7 @@ LABL 0 新宋体,8,N 1623828682 1661907266 -1 -((10673,-24326), (31353,-14430)) +((11667,-24122), (30359,-14634)) 12615680 16570034 12632256 @@ -4960,7 +4960,7 @@ LABL 0 新宋体,8,N 1623828770 1661907266 -1 -((14749,18471), (33699,35567)) +((15653,18839), (32795,35199)) 12615680 16570034 12632256 @@ -4985,7 +4985,7 @@ LABL 0 新宋体,8,N 1623840859 1661907266 -1 -((32440,-12234), (49660,2162)) +((33254,-11927), (48846,1855)) 12615680 16570034 12632256 @@ -5010,7 +5010,7 @@ LABL 0 新宋体,8,N 1623841366 1661907266 -1 -((32317,-26863), (49537,-12467)) +((33131,-26556), (48723,-12774)) 12615680 16570034 12632256 @@ -5035,7 +5035,7 @@ LABL 0 新宋体,8,N 1623842834 1664366507 -1 -((72334,37006), (96042,69402)) +((73486,37723), (94890,68685)) 12615680 16570034 12632256 @@ -5060,7 +5060,7 @@ LABL 0 新宋体,8,N 1623845173 1664366507 -1 -((96277,49454), (124745,66550)) +((97679,49822), (123343,66182)) 12615680 16570034 12632256 @@ -5085,7 +5085,7 @@ LABL 0 新宋体,8,N 1623845296 1664366507 -1 -((96086,38154), (115036,48050)) +((96990,38358), (114132,47846)) 12615680 16570034 12632256 @@ -5110,7 +5110,7 @@ LABL 0 新宋体,8,N 1623859429 1664366507 -1 -((125031,49262), (151335,67258)) +((126318,49651), (150048,66869)) 12615680 16570034 12632256 @@ -5135,7 +5135,7 @@ LABL 0 新宋体,8,N 1623859834 1664366507 -1 -((125429,37287), (146109,48083)) +((126423,37512), (145115,47858)) 12615680 16570034 12632256 @@ -5187,7 +5187,7 @@ LABL 0 新宋体,8,N 1623860248 1662449601 -1 -((73569,-8788), (94683,8308)) +((74587,-8420), (93665,7940)) 12615680 16570034 12632256 @@ -5212,7 +5212,7 @@ LABL 0 新宋体,8,N 1623860509 1662971416 -1 -((94707,-8538), (111495,7658)) +((95498,-8190), (110704,7310)) 12615680 16570034 12632256 @@ -5237,7 +5237,7 @@ LABL 0 新宋体,8,N 1623861067 1662971416 -1 -((113499,8387), (139803,26383)) +((114786,8776), (138516,25994)) 12615680 16570034 12632256 @@ -5262,7 +5262,7 @@ LABL 0 新宋体,8,N 1623861149 1662971416 -1 -((116611,-4663), (137291,6133)) +((117605,-4438), (136297,5908)) 12615680 16570034 12632256 @@ -5287,7 +5287,7 @@ LABL 0 新宋体,8,N 1623861203 1662449601 -1 -((140356,-5055), (155846,8441)) +((141079,-4769), (155123,8155)) 12615680 16570034 12632256 @@ -5312,7 +5312,7 @@ LABL 0 新宋体,8,N 1623861290 1662971416 -1 -((116311,-17563), (136991,-6767)) +((117305,-17338), (135997,-6992)) 12615680 16570034 12632256 @@ -5364,7 +5364,7 @@ LABL 0 新宋体,8,N 1623862594 1661907266 -1 -((57397,-26488), (70291,-14792)) +((57984,-26243), (69704,-15037)) 12615680 16570034 12632256 @@ -5389,7 +5389,7 @@ LABL 0 新宋体,8,N 1623862978 1662650462 -1 -((-37002,-12538), (-9400,958)) +((-35647,-12252), (-10755,672)) 12615680 16570034 12632256 @@ -5414,7 +5414,7 @@ LABL 0 新宋体,8,N 1623863676 1662650462 -1 -((-43569,-23338), (-30675,-14342)) +((-42982,-23154), (-31262,-14526)) 12615680 16570034 12632256 @@ -5439,7 +5439,7 @@ LABL 0 新宋体,8,N 1623864141 1662650462 -1 -((-29673,-23338), (-9857,-14342)) +((-28723,-23154), (-10807,-14526)) 12615680 16570034 12632256 @@ -5464,7 +5464,7 @@ LABL 0 新宋体,8,N 1623895431 1662650462 -1 -((-57383,-23188), (-44489,-14192)) +((-56796,-23004), (-45076,-14376)) 12615680 16570034 12632256 @@ -5489,7 +5489,7 @@ LABL 0 新宋体,8,N 1625926250 1664366507 -1 -((42339,28637), (66913,46633)) +((43536,29026), (65716,46244)) 12615680 16570034 12632256 @@ -5514,7 +5514,7 @@ LABL 0 新宋体,8,N 1627129933 1664366507 -1 -((97381,67314), (114169,74510)) +((98172,67457), (113378,74367)) 12615680 16570034 12632256 @@ -5589,7 +5589,7 @@ LABL 0 新宋体,8,N 1628340137 1661907266 -1 -((37596,20648), (49954,26044)) +((38210,20750), (49340,25942)) 12615680 16570034 12632256 @@ -5639,7 +5639,7 @@ LABL 0 新宋体,8,N 1631243538 1662650462 -1 -((-7615,-23577), (4413,-15481)) +((-7073,-23414), (3871,-15644)) 12615680 16570034 12632256 @@ -5664,7 +5664,7 @@ LABL 0 新宋体,8,N 1661850632 1662449601 -1 -((295266,51445), (321138,62241)) +((296531,51670), (319873,62016)) 12615680 16570034 12632256 @@ -5689,7 +5689,7 @@ LABL 0 新宋体,8,N 1661872432 1662047569 -1 -((263687,41487), (288693,55883)) +((264907,41794), (287473,55576)) 12615680 16570034 12632256 @@ -5768,7 +5768,7 @@ LABL 0 新宋体,8,N 1661949359 1662042403 -1 -((281953,22110), (309555,33806)) +((283308,22355), (308200,33561)) 12615680 16570034 12632256 @@ -5928,7 +5928,7 @@ LABL 0 新宋体,8,N 1661960474 1662042403 -1 -((288345,38233), (328059,48129)) +((290333,38437), (326071,47925)) 12615680 16570034 12632256 @@ -6059,9 +6059,9 @@ LABL 0 新宋体,8,N 1662046440 -1662047695 +1664863137 -1 -((241466,27842), (260404,39810)) +((241466,28352), (260404,39810)) 0 12615680 16570034 @@ -6086,9 +6086,9 @@ LABL 0 新宋体,8,N 1662047767 -1662048050 +1664863142 -1 -((220545,27765), (239483,38733)) +((220545,28245), (239483,38733)) 0 12615680 16570034 @@ -6358,7 +6358,7 @@ LABL 0 新宋体,8,N 1663937886 1663937955 -1 -((36448,2552), (62752,20548)) +((37735,2941), (61465,20159)) 12615680 16570034 12632256 @@ -6383,7 +6383,7 @@ LABL 0 新宋体,8,N 1664366421 1664451284 -1 -((225695,11532), (246805,22329)) +((226710,11757), (245790,22104)) 12615680 16570034 12632256 @@ -6408,7 +6408,7 @@ LABL 0 新宋体,8,N 1664367261 1664451269 -1 -((240536,-26579), (256458,-11282)) +((241282,-26251), (255712,-11610)) 12615680 16570034 12632256 @@ -6433,7 +6433,7 @@ LABL 0 新宋体,8,N 1664368015 1664451368 -1 -((194875,-1671), (215555,12726)) +((195869,-1364), (214561,12419)) 12615680 16570034 12632256 @@ -6458,7 +6458,7 @@ LABL 0 新宋体,8,N 1664460832 1664461120 -1 -((277146,-42870), (300546,-12273)) +((277563,-42194), (300129,-12949)) 12615680 16570034 12632256 @@ -14619,23 +14619,23 @@ COLLATE = utf8_general_ci E732E580-555A-47D5-864B-E868302C4391 -teacher_open_course_question_log_from_id -teacher_open_course_question_log_from_id +resources_question_snapshot_from_id +resources_question_snapshot_from_id 1661850778 lx -1664375810 -lx +1664863184 +87966 来源ID bigint 7C5AFA02-3CF4-4C0D-9180-02F37466098A -teacher_open_course_question_log_from_type -teacher_open_course_question_log_from_type +resources_question_snapshot_from_type +resources_question_snapshot_from_type 1664294920 lx -1664375810 -lx +1664863184 +87966 来源类型(枚举) varchar(50) 50 @@ -16770,11 +16770,11 @@ COLLATE = utf8_general_ci D00F59E0-A483-453B-B382-AD18F74C0ABB -from_id -from_id +resources_question_snapshot_from_id +resources_question_snapshot_from_id 1563157584 lx -1664174457 +1664507810 87966 来源ID bigint @@ -16787,11 +16787,11 @@ COLLATE = utf8_general_ci 4CD5F796-DD7D-4978-9E99-2F93C55A9DE6 -from_type -from_type +resources_question_snapshot_from_type +resources_question_snapshot_from_type 1663937890 lx -1664174457 +1664507810 87966 来源类型(HOMEWORK...) varchar(100) diff --git a/data_base_design/天泽数据大平台.pdm b/data_base_design/天泽数据大平台.pdm index 9eb38ebc..bad5aace 100644 --- a/data_base_design/天泽数据大平台.pdm +++ b/data_base_design/天泽数据大平台.pdm @@ -1,5 +1,5 @@ - + @@ -4474,9 +4474,9 @@ Shadow=0 1662047541 -1662047695 -((250779,30569), (296894,31870)) -((250779,31870),(278057,31870),(278057,30869),(296894,30869)) +1664863137 +((250779,30569), (296894,32209)) +((250779,32209),(278057,32209),(278057,30869),(296894,30869)) 1 8 16744576 @@ -4496,8 +4496,8 @@ Shadow=0 1662048005 1662048061 -((230014,25717), (295754,27797)) -((230014,27797),(230014,26017),(295754,26017)) +((230014,25717), (295754,28276)) +((230014,28276),(230014,26017),(295754,26017)) 1 8 16744576 @@ -6059,9 +6059,9 @@ LABL 0 新宋体,8,N 1662046440 -1662047695 +1664863137 -1 -((241466,27842), (260404,39810)) +((241466,28352), (260404,39810)) 0 12615680 16570034 @@ -6086,9 +6086,9 @@ LABL 0 新宋体,8,N 1662047767 -1662048050 +1664863142 -1 -((220545,27765), (239483,38733)) +((220545,28245), (239483,38733)) 0 12615680 16570034 @@ -14619,23 +14619,23 @@ COLLATE = utf8_general_ci E732E580-555A-47D5-864B-E868302C4391 -teacher_open_course_question_log_from_id -teacher_open_course_question_log_from_id +resources_question_snapshot_from_id +resources_question_snapshot_from_id 1661850778 lx -1664375810 -lx +1664863184 +87966 来源ID bigint 7C5AFA02-3CF4-4C0D-9180-02F37466098A -teacher_open_course_question_log_from_type -teacher_open_course_question_log_from_type +resources_question_snapshot_from_type +resources_question_snapshot_from_type 1664294920 lx -1664375810 -lx +1664863184 +87966 来源类型(枚举) varchar(50) 50 diff --git a/doc/sql/mysql/tianze-pro.sql b/doc/sql/mysql/tianze-pro.sql index de190a3b..cc15ae39 100644 --- a/doc/sql/mysql/tianze-pro.sql +++ b/doc/sql/mysql/tianze-pro.sql @@ -28622,9 +28622,6 @@ COLLATE = utf8_general_ci; alter table teacher_open_course_homework comment '我的课程-题库作业'; --- ---------------------------- --- Records of teacher_open_course_homework --- ---------------------------- drop table if exists teacher_open_course_question_log; /*==============================================================*/ @@ -28633,8 +28630,8 @@ drop table if exists teacher_open_course_question_log; create table teacher_open_course_question_log ( teacher_open_course_question_log_id bigint not null comment '学生做题日志ID', - teacher_open_course_question_log_from_id bigint comment '来源ID', - teacher_open_course_question_log_from_type varchar(50) comment '来源类型(枚举)', + resources_question_snapshot_from_id bigint comment '来源ID', + resources_question_snapshot_from_type varchar(50) comment '来源类型(枚举)', resources_question_snapshot_id bigint comment '题目快照ID', teacher_open_course_question_log_answer varchar(1000) comment '学生提交的答案', teacher_open_course_question_log_upload_file varchar(1000) comment '附件,学生端上传附件(单文件)', @@ -28652,6 +28649,7 @@ COLLATE = utf8_general_ci; alter table teacher_open_course_question_log comment '我的课程-题库-做题日志'; + drop table if exists teacher_open_course_homework_setting; /*==============================================================*/ diff --git a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java index c238adf2..5ae7234e 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java @@ -24,4 +24,6 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper getByIds(String ids); List getValuesByQuery(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery); + + Integer doCount(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery); } diff --git a/web/src/main/java/com/ibeetl/jlw/service/ResourcesQuestionSnapshotService.java b/web/src/main/java/com/ibeetl/jlw/service/ResourcesQuestionSnapshotService.java index bac39ca9..c1fd5bd0 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/ResourcesQuestionSnapshotService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/ResourcesQuestionSnapshotService.java @@ -132,9 +132,9 @@ public class ResourcesQuestionSnapshotService extends CoreBaseService list = resourcesQuestionSnapshotDao.getValuesByQuery(resourcesQuestionSnapshotQuery); if(null != list && list.size()>0){ return list.get(0); diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHomeworkService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHomeworkService.java index 3528800d..c3bbc875 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHomeworkService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHomeworkService.java @@ -11,13 +11,11 @@ import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao; +import com.ibeetl.jlw.dao.StudentDao; import com.ibeetl.jlw.dao.TeacherOpenCourseHomeworkDao; -import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot; +import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao; import com.ibeetl.jlw.entity.TeacherOpenCourseHomework; -import com.ibeetl.jlw.entity.TeacherOpenCourseHomeworkSetting; -import com.ibeetl.jlw.web.query.ResourcesQuestionSnapshotQuery; import com.ibeetl.jlw.web.query.TeacherOpenCourseHomeworkQuery; -import com.ibeetl.jlw.web.query.TeacherOpenCourseHomeworkSettingQuery; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.SqlId; import org.beetl.sql.core.engine.PageQuery; @@ -29,8 +27,6 @@ import java.util.ArrayList; import java.util.List; import static cn.hutool.json.JSONUtil.toJsonStr; -import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUserId; -import static com.ibeetl.jlw.entity.ResourcesQuestionOptionEntity.shuffleOrderOptions; /** * 开课作业 Service @@ -44,6 +40,8 @@ public class TeacherOpenCourseHomeworkService extends CoreBaseService homeworkDetail(final Long teacherOpenCourseHomeworkId) { - - // 常量 True的Integer表现 - final Integer TRUE_CONST = 1; - List resourcesQuestionSnapshots = new ArrayList<>(); - TeacherOpenCourseHomework homework = getInfo(teacherOpenCourseHomeworkId); - cn.hutool.core.lang.Assert.notNull(homework, "未查询到作业ID对应的题目!"); - - TeacherOpenCourseHomeworkSettingQuery settingQuery = new TeacherOpenCourseHomeworkSettingQuery(); - settingQuery.setTeacherOpenCourseHomeworkId(teacherOpenCourseHomeworkId); - TeacherOpenCourseHomeworkSetting hwSetting = teacherOpenCourseHomeworkSettingService.getInfo(settingQuery); - - ResourcesQuestionSnapshotQuery questionSnapshotQuery = new ResourcesQuestionSnapshotQuery(); - questionSnapshotQuery.setResourcesQuestionSnapshotFromId(teacherOpenCourseHomeworkId); - - // 作答次数 - if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingDoCount())) { - // TODO 逻辑不一定要在这里写 - getUserId(); - } - - // 答卷后显示答案解析 - if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingEndShowQa())) { - // TODO 逻辑不一定要在这里写 - } - - // 答卷后显示答案对错 - if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingEndShowTrueFalse())) { - // TODO 逻辑不一定要在这里写 - } - - // 题目乱序(同一大题内) - if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingQuestionNoOrder())) { - questionSnapshotQuery.setRand(true); - } - - // 选项乱序(限单选、多选) - if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingOptionNoOrder())) { - resourcesQuestionSnapshots = resourcesQuestionSnapshotDao.getValuesByQuery(questionSnapshotQuery); - - // 单题选项排序处理 - resourcesQuestionSnapshots.forEach(value -> { - shuffleOrderOptions(value, "questionAnswer","questionOption", true); - // 屏蔽答案 - value.setQuestionAnswer(null); - }); - } - - - - return resourcesQuestionSnapshots; - } } diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java index 0e68cc7c..a21ec8ad 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java @@ -1,5 +1,7 @@ package com.ibeetl.jlw.service; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.BooleanUtil; import cn.jlw.util.ToolUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -11,11 +13,12 @@ import com.ibeetl.admin.core.web.JsonReturnCode; import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao; import com.ibeetl.jlw.dao.StudentDao; import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionLogDao; -import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot; -import com.ibeetl.jlw.entity.Student; -import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog; +import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; +import com.ibeetl.jlw.web.query.ResourcesQuestionSnapshotQuery; +import com.ibeetl.jlw.web.query.TeacherOpenCourseHomeworkSettingQuery; import com.ibeetl.jlw.web.query.TeacherOpenCourseQuestionLogQuery; +import com.sun.istack.internal.Nullable; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.SqlId; import org.beetl.sql.core.engine.PageQuery; @@ -24,10 +27,14 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; import java.util.*; import static cn.hutool.core.util.ArrayUtil.join; import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser; +import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUserId; +import static com.ibeetl.jlw.entity.ResourcesQuestionOptionEntity.shuffleOrderOptions; +import static java.util.stream.Collectors.groupingBy; /** * 题目日志 Service @@ -41,6 +48,8 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseServicequeryByCondition(PageQuery query){ PageQuery ret = teacherOpenCourseQuestionLogDao.queryByCondition(query); @@ -203,4 +212,101 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService questionDetail(final Long resourcesQuestionSnapshotFromId) { + + // 获取学生ID + final Student student = studentDao.getByUserId(getUserId()); + + // 常量 True的Integer表现 + final Integer TRUE_CONST = 1; + List resourcesQuestionSnapshots = new ArrayList<>(); + TeacherOpenCourseHomework homework = teacherOpenCourseHomeworkService.getInfo(resourcesQuestionSnapshotFromId); + Assert.notNull(homework, "未查询到来源ID对应的题目!"); + + TeacherOpenCourseHomeworkSettingQuery settingQuery = new TeacherOpenCourseHomeworkSettingQuery(); + settingQuery.setTeacherOpenCourseHomeworkId(resourcesQuestionSnapshotFromId); + TeacherOpenCourseHomeworkSetting hwSetting = teacherOpenCourseHomeworkSettingService.getInfo(settingQuery); + + ResourcesQuestionSnapshotQuery questionSnapshotQuery = new ResourcesQuestionSnapshotQuery(); + questionSnapshotQuery.setResourcesQuestionSnapshotFromId(resourcesQuestionSnapshotFromId); + + // 作答次数 + Integer teacherOpenCourseHomeworkSettingDoCount = hwSetting.getTeacherOpenCourseHomeworkSettingDoCount(); + Assert.isTrue(teacherOpenCourseHomeworkSettingDoCount > 1, "作答次数设置有误,请联系管理员!"); + // 数据库查询该学生已经做过的次数 + TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery = new TeacherOpenCourseQuestionLogQuery(); + teacherOpenCourseQuestionLogQuery.setStudentId(student.getStudentId()); + // 作业ID + teacherOpenCourseQuestionLogQuery.setResourcesQuestionSnapshotFromId(resourcesQuestionSnapshotFromId); + Integer doCount = teacherOpenCourseQuestionLogDao.doCount(teacherOpenCourseQuestionLogQuery); + // 断言判断最大作答次数 + Assert.isTrue(doCount < teacherOpenCourseHomeworkSettingDoCount, "已超过最大作答次数!"); + + // 答卷后显示答案解析 + if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingEndShowQa())) { + // TODO 逻辑不要在这里写 + /** 实现 {@link TeacherOpenCourseQuestionLogService#questionAnalysis(TreeSet)} */ + } + + // 答卷后显示答案对错 + if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingEndShowTrueFalse())) { + // TODO 逻辑不要在这里写 + /** 实现 {@link TeacherOpenCourseQuestionLogService#questionAnalysis(TreeSet)} */ + } + + // 题目乱序(同一大题内) + if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingQuestionNoOrder())) { + questionSnapshotQuery.setRand(true); + } + + // 选项乱序(限单选、多选) + if (TRUE_CONST.equals(hwSetting.getTeacherOpenCourseHomeworkSettingOptionNoOrder())) { + resourcesQuestionSnapshots = resourcesQuestionSnapshotDao.getValuesByQuery(questionSnapshotQuery); + + // 单题选项排序处理 + resourcesQuestionSnapshots.forEach(value -> { + shuffleOrderOptions(value, "questionAnswer","questionOption", true); + // 屏蔽答案 + value.setQuestionAnswer(null); + }); + } + + return resourcesQuestionSnapshots; + } + + /** + * 开课相关-考试或者作业,答题提交后,获取问题解析。根据配置获取 + * @param questionSnapshotIds + * @return + */ + public Map> questionAnalysis(@NotEmpty final TreeSet questionSnapshotIds) { + + // 查询题目快照列表 + List questionSnapshots = resourcesQuestionSnapshotDao.getByIds(join(questionSnapshotIds.toArray(), ",")); + + Assert.notEmpty(questionSnapshots, "未查询到题目列表!"); + + TeacherOpenCourseHomeworkSettingQuery settingQuery = new TeacherOpenCourseHomeworkSettingQuery(); + settingQuery.setTeacherOpenCourseHomeworkId(questionSnapshots.get(0).getResourcesQuestionSnapshotFromId()); + @Nullable + final TeacherOpenCourseHomeworkSetting hwSetting = teacherOpenCourseHomeworkSettingService.getInfo(settingQuery); + + // 答卷后显示答案解析 + final Boolean isEndShowQa = BooleanUtil.toBoolean(String.valueOf(hwSetting.getTeacherOpenCourseHomeworkSettingEndShowQa())); + // 答卷后显示答案对错 + final Boolean isEndShowTrueFalse = BooleanUtil.toBoolean(String.valueOf(hwSetting.getTeacherOpenCourseHomeworkSettingEndShowTrueFalse())); + + return questionSnapshots.stream().map(item -> { + ResourcesQuestionSnapshot resourcesQuestionSnapshot = new ResourcesQuestionSnapshot(); + resourcesQuestionSnapshot.setResourcesQuestionSnapshotId(item.getResourcesQuestionSnapshotId()); + resourcesQuestionSnapshot.setQuestionAnswer(isEndShowQa ? item.getQuestionAnswer() : ""); + resourcesQuestionSnapshot.setQuestionAnalysis(isEndShowTrueFalse ? item.getQuestionAnalysis(): ""); + return resourcesQuestionSnapshot; + }).collect(groupingBy(ResourcesQuestionSnapshot::getResourcesQuestionSnapshotId)); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/ResourcesQuestionSnapshotController.java b/web/src/main/java/com/ibeetl/jlw/web/ResourcesQuestionSnapshotController.java index af014307..6985f80b 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/ResourcesQuestionSnapshotController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/ResourcesQuestionSnapshotController.java @@ -93,19 +93,19 @@ public class ResourcesQuestionSnapshotController{ @GetMapping(MODEL + "/edit.do") @Function("resourcesQuestionSnapshot.edit") - public ModelAndView edit(Long fromId) { + public ModelAndView edit(Long resourcesQuestionSnapshotFromId) { ModelAndView view = new ModelAndView("/jlw/resourcesQuestionSnapshot/edit.html"); - ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotService.queryById(fromId); + ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotService.queryById(resourcesQuestionSnapshotFromId); view.addObject("resourcesQuestionSnapshot", resourcesQuestionSnapshot); return view; } @GetMapping(MODEL + "/add.do") @Function("resourcesQuestionSnapshot.add") - public ModelAndView add(Long fromId) { + public ModelAndView add(Long resourcesQuestionSnapshotFromId) { ModelAndView view = new ModelAndView("/jlw/resourcesQuestionSnapshot/add.html"); - if(null != fromId){ - ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotService.queryById(fromId); + if(null != resourcesQuestionSnapshotFromId){ + ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotService.queryById(resourcesQuestionSnapshotFromId); view.addObject("resourcesQuestionSnapshot", resourcesQuestionSnapshot); }else { view.addObject("resourcesQuestionSnapshot", new ResourcesQuestionSnapshot()); @@ -172,8 +172,8 @@ public class ResourcesQuestionSnapshotController{ @GetMapping(MODEL + "/view.json") @Function("resourcesQuestionSnapshot.query") - public JsonResultqueryInfo(Long fromId) { - ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotService.queryById( fromId); + public JsonResultqueryInfo(Long resourcesQuestionSnapshotFromId) { + ResourcesQuestionSnapshot resourcesQuestionSnapshot = resourcesQuestionSnapshotService.queryById( resourcesQuestionSnapshotFromId); return JsonResult.success(resourcesQuestionSnapshot); } diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkController.java index 67f4ca66..7d8cc246 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkController.java @@ -214,15 +214,4 @@ public class TeacherOpenCourseHomeworkController { return JsonResult.success(); } - /** - * 学生端-根绝作业配置信息,获取作业 - * @param teacherOpenCourseHomeworkId 开课作业ID - * @return - */ - @PostMapping(MODEL + "/homeworkDetail.json") - @Function("teacherOpenCourseHomework.query") - public JsonResult homeworkDetail(Long teacherOpenCourseHomeworkId, @SCoreUser CoreUser coreUser) { - return JsonResult.success(teacherOpenCourseHomeworkService.homeworkDetail(teacherOpenCourseHomeworkId)); - } - } diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java index fb3506d5..d56f571c 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogController.java @@ -220,4 +220,37 @@ public class TeacherOpenCourseQuestionLogController{ return JsonResult.success(); } + /** + * 学生端-和题目有关的做题提交方法 + * 支持附件上传。不支持简答题上传, + * 答案集合中,会包含"/"字符串,则代表是路径地址,则是附件类型的答案 + * + * @param questionSnapshotIds [题目快照ID] + * @param coreUser 用来验证用户登录,为了解耦不会传递到Service层 + * @return + */ + @PostMapping(MODEL + "/questionAnalysis.json") + @Function("teacherOpenCourseQuestionLog.query") + @ResponseBody + public JsonResult questionAnalysis( + @RequestBody @NotEmpty(message = "请上传题目快照ID和答案!") + TreeSet questionSnapshotIds, + @SCoreUser + CoreUser coreUser) { + Assert.isTrue(coreUser.isStudent(), "非学生身份,无法获取题目分析!"); + return JsonResult.success(teacherOpenCourseQuestionLogService.questionAnalysis(questionSnapshotIds)); + } + + /** + * 学生端-根绝题目配置信息,获取相关的题目 + * @param resourcesQuestionSnapshotFromId 题目快照来源ID (开课作业ID,开课考试ID) + * @return + */ + @PostMapping(MODEL + "/questionDetail.json") + @Function("teacherOpenCourseQuestionLog.query") + public JsonResult questionDetail(Long resourcesQuestionSnapshotFromId, @SCoreUser CoreUser coreUser) { + Assert.isTrue(coreUser.isStudent(), "非学生身份,无法获取题目!"); + return JsonResult.success(teacherOpenCourseQuestionLogService.questionDetail(resourcesQuestionSnapshotFromId)); + } + } diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/ResourcesQuestionSnapshotQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/ResourcesQuestionSnapshotQuery.java index e2774762..98848ffb 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/ResourcesQuestionSnapshotQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/ResourcesQuestionSnapshotQuery.java @@ -8,9 +8,8 @@ import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import javax.validation.constraints.NotNull; import java.math.BigDecimal; - /** - *题目快照查询 + *ResourcesQuestionSnapshot查询 */ public class ResourcesQuestionSnapshotQuery extends PageParam { @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class) @@ -48,23 +47,19 @@ public class ResourcesQuestionSnapshotQuery extends PageParam { private Long userId; @Query(name = "组织机构ID", display = false) private Long orgId; - - /** - * 同一道大题,是否乱序。SQL处理 - */ - private Boolean rand; - - private String fromIdPlural; + private String resourcesQuestionSnapshotIdPlural; + private String resourcesQuestionSnapshotFromIdPlural; private String courseInfoIdPlural; private String questionTypePlural; private String questionStatusPlural; private String userIdPlural; private String orgIdPlural; - private String resourcesQuestionSnapshotJsonStr;//json格式 - private String _given;//指定更新的特定字段,多个逗号隔开 + // 是否乱序 + private boolean rand; + public Long getResourcesQuestionSnapshotId(){ return resourcesQuestionSnapshotId; } @@ -72,15 +67,15 @@ public class ResourcesQuestionSnapshotQuery extends PageParam { this.resourcesQuestionSnapshotId = resourcesQuestionSnapshotId; } public Long getResourcesQuestionSnapshotFromId(){ - return resourcesQuestionSnapshotFromId; + return resourcesQuestionSnapshotFromId; } - public void setResourcesQuestionSnapshotFromId(Long resourcesQuestionSnapshotFromId){ + public void setResourcesQuestionSnapshotFromId(Long resourcesQuestionSnapshotFromId ){ this.resourcesQuestionSnapshotFromId = resourcesQuestionSnapshotFromId; } public ResourcesQuestionSnapshotFromTypeEnum getResourcesQuestionSnapshotFromType(){ - return resourcesQuestionSnapshotFromType; + return resourcesQuestionSnapshotFromType; } - public void setResourcesQuestionSnapshotFromType(ResourcesQuestionSnapshotFromTypeEnum resourcesQuestionSnapshotFromType){ + public void setResourcesQuestionSnapshotFromType(ResourcesQuestionSnapshotFromTypeEnum resourcesQuestionSnapshotFromType ){ this.resourcesQuestionSnapshotFromType = resourcesQuestionSnapshotFromType; } public Long getCourseInfoId(){ @@ -167,7 +162,6 @@ public class ResourcesQuestionSnapshotQuery extends PageParam { public void setOrgId(Long orgId ){ this.orgId = orgId; } - public ResourcesQuestionSnapshot pojo(){ ResourcesQuestionSnapshot pojo = new ResourcesQuestionSnapshot(); pojo.setResourcesQuestionSnapshotId(this.getResourcesQuestionSnapshotId()); @@ -189,12 +183,17 @@ public class ResourcesQuestionSnapshotQuery extends PageParam { pojo.setOrgId(this.getOrgId()); return pojo; } - - public String getFromIdPlural(){ - return fromIdPlural; + public String getResourcesQuestionSnapshotIdPlural(){ + return resourcesQuestionSnapshotIdPlural; + } + public void setResourcesQuestionSnapshotIdPlural(String resourcesQuestionSnapshotIdPlural){ + this.resourcesQuestionSnapshotIdPlural = resourcesQuestionSnapshotIdPlural; } - public void setFromIdPlural(String fromIdPlural){ - this.fromIdPlural = fromIdPlural; + public String getResourcesQuestionSnapshotFromIdPlural(){ + return resourcesQuestionSnapshotFromIdPlural; + } + public void setResourcesQuestionSnapshotFromIdPlural(String resourcesQuestionSnapshotFromIdPlural){ + this.resourcesQuestionSnapshotFromIdPlural = resourcesQuestionSnapshotFromIdPlural; } public String getCourseInfoIdPlural(){ return courseInfoIdPlural; @@ -239,11 +238,11 @@ public class ResourcesQuestionSnapshotQuery extends PageParam { this._given = _given; } - public Boolean getRand() { - return rand; + public void setRand(boolean rand) { + this.rand = rand; } - public void setRand(Boolean rand) { - this.rand = rand; + public boolean isRand() { + return rand; } -} +} \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java index 32928b9c..144bd58d 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/TeacherOpenCourseQuestionLogQuery.java @@ -141,14 +141,6 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam { this.teacherOpenCourseQuestionLogIdPlural = teacherOpenCourseQuestionLogIdPlural; } - public String getResourcesQuestionSnapshotFromIdPlural() { - return resourcesQuestionSnapshotFromIdPlural; - } - - public void setResourcesQuestionSnapshotFromIdPlural(String resourcesQuestionSnapshotFromIdPlural) { - this.resourcesQuestionSnapshotFromIdPlural = resourcesQuestionSnapshotFromIdPlural; - } - public String getResourcesQuestionSnapshotIdPlural(){ return resourcesQuestionSnapshotIdPlural; } @@ -191,4 +183,12 @@ public class TeacherOpenCourseQuestionLogQuery extends PageParam { public void set_given(String _given) { this._given = _given; } + + public String getResourcesQuestionSnapshotFromIdPlural() { + return resourcesQuestionSnapshotFromIdPlural; + } + + public void setResourcesQuestionSnapshotFromIdPlural(String resourcesQuestionSnapshotFromIdPlural) { + this.resourcesQuestionSnapshotFromIdPlural = resourcesQuestionSnapshotFromIdPlural; + } } diff --git a/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md b/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md index a49d3b46..1eed5eac 100644 --- a/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md +++ b/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md @@ -1,7 +1,6 @@ queryByCondition === * 根据不为空的参数进行分页查询 - select @pageTag(){ t.* @@ -13,11 +12,14 @@ queryByCondition @if(!isEmpty(resourcesQuestionSnapshotId)){ and t.resources_question_snapshot_id =#resourcesQuestionSnapshotId# @} + @if(!isEmpty(resourcesQuestionSnapshotIdPlural)){ + and find_in_set(t.resources_question_snapshot_id,#resourcesQuestionSnapshotIdPlural#) + @} @if(!isEmpty(resourcesQuestionSnapshotFromId)){ and t.resources_question_snapshot_from_id =#resourcesQuestionSnapshotFromId# @} - @if(!isEmpty(fromIdPlural)){ - and find_in_set(t.resources_question_snapshot_from_id,#fromIdPlural#)x + @if(!isEmpty(resourcesQuestionSnapshotFromIdPlural)){ + and find_in_set(t.resources_question_snapshot_from_id,#resourcesQuestionSnapshotFromIdPlural#) @} @if(!isEmpty(resourcesQuestionSnapshotFromType)){ and t.resources_question_snapshot_from_type =#resourcesQuestionSnapshotFromType# @@ -80,11 +82,9 @@ queryByCondition and find_in_set(t.org_id,#orgIdPlural#) @} - queryByConditionQuery === * 根据不为空的参数进行分页查询(无权限) - select @pageTag(){ t.* @@ -94,11 +94,14 @@ queryByConditionQuery @if(!isEmpty(resourcesQuestionSnapshotId)){ and t.resources_question_snapshot_id =#resourcesQuestionSnapshotId# @} + @if(!isEmpty(resourcesQuestionSnapshotIdPlural)){ + and find_in_set(t.resources_question_snapshot_id,#resourcesQuestionSnapshotIdPlural#) + @} @if(!isEmpty(resourcesQuestionSnapshotFromId)){ and t.resources_question_snapshot_from_id =#resourcesQuestionSnapshotFromId# @} - @if(!isEmpty(fromIdPlural)){ - and find_in_set(t.resources_question_snapshot_from_id,#fromIdPlural#) + @if(!isEmpty(resourcesQuestionSnapshotFromIdPlural)){ + and find_in_set(t.resources_question_snapshot_from_id,#resourcesQuestionSnapshotFromIdPlural#) @} @if(!isEmpty(resourcesQuestionSnapshotFromType)){ and t.resources_question_snapshot_from_type =#resourcesQuestionSnapshotFromType# @@ -162,35 +165,25 @@ queryByConditionQuery @} - - deleteResourcesQuestionSnapshotByIds === - * 批量删除 - - delete from resources_question_snapshot where find_in_set(resources_question_snapshot_from_id,#ids#) - - + delete from resources_question_snapshot where find_in_set(resources_question_snapshot_id,#ids#) getByIds === - -select * from resources_question_snapshot where find_in_set(resources_question_snapshot_from_id,#ids#) - + select * from resources_question_snapshot where find_in_set(resources_question_snapshot_id,#ids#) updateGivenByIds === - * 批量更新指定字段,无论此字段是否有值 - update resources_question_snapshot set - @if(contain("resourcesQuestionSnapshotId",_given)){ - @if(isEmpty(resourcesQuestionSnapshotId)){ - resources_question_snapshot_id = null , + @if(contain("resourcesQuestionSnapshotFromId",_given)){ + @if(isEmpty(resourcesQuestionSnapshotFromId)){ + resources_question_snapshot_from_id = null , @}else{ - resources_question_snapshot_id = #resourcesQuestionSnapshotId# , + resources_question_snapshot_from_id = #resourcesQuestionSnapshotFromId# , @} @} @if(contain("resourcesQuestionSnapshotFromType",_given)){ @@ -298,16 +291,13 @@ updateGivenByIds org_id = #orgId# , @} @} - resources_question_snapshot_from_id = resources_question_snapshot_from_id - where find_in_set(resources_question_snapshot_from_id,#fromIdPlural#) - + resources_question_snapshot_id = resources_question_snapshot_id + where find_in_set(resources_question_snapshot_id,#resourcesQuestionSnapshotIdPlural#) getResourcesQuestionSnapshotValues === - * 根据不为空的参数进行查询 - select t.* from resources_question_snapshot t where 1=1 @@ -366,20 +356,21 @@ getResourcesQuestionSnapshotValues getValuesByQuery === - * 根据不为空的参数进行查询 - select t.* from resources_question_snapshot t where 1=1 and #function("resourcesQuestionSnapshot.query")# @if(!isEmpty(resourcesQuestionSnapshotId)){ and t.resources_question_snapshot_id =#resourcesQuestionSnapshotId# @} + @if(!isEmpty(resourcesQuestionSnapshotIdPlural)){ + and find_in_set(t.resources_question_snapshot_id,#resourcesQuestionSnapshotIdPlural#) + @} @if(!isEmpty(resourcesQuestionSnapshotFromId)){ and t.resources_question_snapshot_from_id =#resourcesQuestionSnapshotFromId# @} - @if(!isEmpty(fromIdPlural)){ - and find_in_set(t.resources_question_snapshot_from_id,#fromIdPlural#) + @if(!isEmpty(resourcesQuestionSnapshotFromIdPlural)){ + and find_in_set(t.resources_question_snapshot_from_id,#resourcesQuestionSnapshotFromIdPlural#) @} @if(!isEmpty(resourcesQuestionSnapshotFromType)){ and t.resources_question_snapshot_from_type =#resourcesQuestionSnapshotFromType# diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md index bb178f80..bf9f21c2 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md @@ -356,5 +356,67 @@ getValuesByQuery and find_in_set(t.user_id,#userIdPlural#) @} - - +doCount +=== +* 查询用户做题次数 + @ // 题目快照ID的去重后的数量,就可以计算出做题次数 + select count(distinct (t.resources_question_snapshot_id)) + from teacher_open_course_question_log t + where 1=1 and #function("teacherOpenCourseQuestionLog.query")# + @if(!isEmpty(teacherOpenCourseQuestionLogId)){ + and t.teacher_open_course_question_log_id =#teacherOpenCourseQuestionLogId# + @} + @if(!isEmpty(teacherOpenCourseQuestionLogIdPlural)){ + and find_in_set(t.teacher_open_course_question_log_id,#teacherOpenCourseQuestionLogIdPlural#) + @} + @if(!isEmpty(resourcesQuestionSnapshotFromId)){ + and t.resources_question_snapshot_from_id =#resourcesQuestionSnapshotFromId# + @} + @if(!isEmpty(resourcesQuestionSnapshotFromIdPlural)){ + and find_in_set(t.resources_question_snapshot_from_id,#resourcesQuestionSnapshotFromIdPlural#) + @} + @if(!isEmpty(resourcesQuestionSnapshotFromType)){ + and t.resources_question_snapshot_from_type =#resourcesQuestionSnapshotFromType# + @} + @if(!isEmpty(resourcesQuestionSnapshotId)){ + and t.resources_question_snapshot_id =#resourcesQuestionSnapshotId# + @} + @if(!isEmpty(resourcesQuestionSnapshotIdPlural)){ + and find_in_set(t.resources_question_snapshot_id,#resourcesQuestionSnapshotIdPlural#) + @} + @if(!isEmpty(teacherOpenCourseQuestionLogAnswer)){ + and t.teacher_open_course_question_log_answer =#teacherOpenCourseQuestionLogAnswer# + @} + @if(!isEmpty(teacherOpenCourseQuestionLogUploadFile)){ + and t.teacher_open_course_question_log_upload_file =#teacherOpenCourseQuestionLogUploadFile# + @} + @if(!isEmpty(teacherOpenCourseQuestionLogAddTime)){ + and t.teacher_open_course_question_log_add_time =#teacherOpenCourseQuestionLogAddTime# + @} + @if(isEmpty(teacherOpenCourseQuestionLogStatus) && isEmpty(teacherOpenCourseQuestionLogStatusPlural)){ + and t.teacher_open_course_question_log_status != 2 + @}else{ + @if(!isEmpty(teacherOpenCourseQuestionLogStatus)){ + and t.teacher_open_course_question_log_status =#teacherOpenCourseQuestionLogStatus# + @}else if(!isEmpty(teacherOpenCourseQuestionLogStatusPlural)){ + and find_in_set(t.teacher_open_course_question_log_status,#teacherOpenCourseQuestionLogStatusPlural#) + @} + @} + @if(!isEmpty(studentId)){ + and t.student_id =#studentId# + @} + @if(!isEmpty(studentIdPlural)){ + and find_in_set(t.student_id,#studentIdPlural#) + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} diff --git a/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/add.js b/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/add.js index c93fb0a0..0d4b3d78 100644 --- a/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/add.js +++ b/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/add.js @@ -10,8 +10,8 @@ layui.define([ 'form', 'laydate', 'table','resourcesQuestionSnapshotApi'], funct initSubmit:function(){ $("#addButton").click(function(){ form.on('submit(form)', function(){ - var fromId = $("#addForm input[name='fromId']").val(); - if(!$.isEmpty(fromId)){ + var resourcesQuestionSnapshotFromId = $("#addForm input[name='resourcesQuestionSnapshotFromId']").val(); + if(!$.isEmpty(resourcesQuestionSnapshotFromId)){ resourcesQuestionSnapshotApi.updateResourcesQuestionSnapshot($('#addForm'),function(){ parent.window.dataReload(); Common.info("更新成功"); diff --git a/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/del.js b/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/del.js index 27e5861f..3617c497 100644 --- a/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/del.js +++ b/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/del.js @@ -10,7 +10,7 @@ layui.define(['table', 'resourcesQuestionSnapshotApi'], function(exports) { return ; } Common.openConfirm("确认要删除这些题目快照?",function(){ - var ids =Common.concatBatchId(data,"fromId"); + var ids =Common.concatBatchId(data,"resourcesQuestionSnapshotFromId"); resourcesQuestionSnapshotApi.del(ids,function(){ Common.info("删除成功"); dataReload(); diff --git a/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/index.js b/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/index.js index ffe4bbb1..a2528a92 100644 --- a/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/index.js +++ b/web/src/main/resources/static/js/jlw/resourcesQuestionSnapshot/index.js @@ -42,11 +42,11 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { width : 60, }, { - field : 'fromId', + field : 'resourcesQuestionSnapshotFromId', title : '来源ID', align:"center", hideField :false, - hide:$.isEmpty(sx_['fromId'])?false:sx_['fromId'], + hide:$.isEmpty(sx_['resourcesQuestionSnapshotFromId'])?false:sx_['resourcesQuestionSnapshotFromId'], }, { field : 'fromType', @@ -190,7 +190,7 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { if(data==null){ return ; } - var url = "/jlw/resourcesQuestionSnapshot/add.do?fromId="+data.fromId; + var url = "/jlw/resourcesQuestionSnapshot/add.do?resourcesQuestionSnapshotFromId="+data.resourcesQuestionSnapshotId; Common.openDlg(url,"题目快照管理>"+data.resourcesQuestionSnapshotId+">编辑"); }, del: function () { @@ -218,11 +218,11 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { }, initTableTool: table.on('tool(resourcesQuestionSnapshotTable)', function (obj) { var data = obj.data; if (obj.event === 'edit') { - var url = "/jlw/resourcesQuestionSnapshot/add.do?fromId="+data.fromId; + var url = "/jlw/resourcesQuestionSnapshot/add.do?resourcesQuestionSnapshotFromId="+data.resourcesQuestionSnapshotFromId; Common.openDlg(url,"题目快照管理>"+data.resourcesQuestionSnapshotId+">编辑"); }else if(obj.event === "del"){ layer.confirm('是否确定删除该信息?', function (index) { - var ret = Common.postAjax("/jlw/resourcesQuestionSnapshot/delete.json",{ids:data.fromId}); + var ret = Common.postAjax("/jlw/resourcesQuestionSnapshot/delete.json",{ids:data.resourcesQuestionSnapshotFromId}); layer.msg(ret.code == 0?"删除成功!":ret.msg, { offset: ['50%'], icon: ret.code == 0?1:2, diff --git a/web/src/main/resources/static/js/jlw/teacherOpenCourseQuestionLog/index.js b/web/src/main/resources/static/js/jlw/teacherOpenCourseQuestionLog/index.js index 2ddc598b..55d51cb9 100644 --- a/web/src/main/resources/static/js/jlw/teacherOpenCourseQuestionLog/index.js +++ b/web/src/main/resources/static/js/jlw/teacherOpenCourseQuestionLog/index.js @@ -42,7 +42,7 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { width : 60, }, { - field : 'teacherOpenCourseQuestionLogFromId', + field : 'teacherOpenCourseQuestionLogFromId', title : '来源ID', align:"center", hideField :false, diff --git a/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/add.html b/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/add.html index 0f71d7d0..683fec07 100644 --- a/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/add.html +++ b/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/add.html @@ -130,7 +130,7 @@ - + diff --git a/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/edit.html b/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/edit.html index 3a06ccee..197d0631 100644 --- a/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/edit.html +++ b/web/src/main/resources/templates/jlw/resourcesQuestionSnapshot/edit.html @@ -130,7 +130,7 @@ - + diff --git a/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkControllerTest.java b/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkControllerTest.java index 1a7e7841..fe945499 100644 --- a/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkControllerTest.java +++ b/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseHomeworkControllerTest.java @@ -12,7 +12,6 @@ import com.ibeetl.jlw.dao.TeacherOpenCourseHomeworkDao; import com.ibeetl.jlw.entity.ResourcesQuestion; import com.ibeetl.jlw.entity.SchoolClass; import com.ibeetl.jlw.entity.TeacherOpenCourse; -import com.ibeetl.jlw.entity.TeacherOpenCourseHomework; import com.ibeetl.jlw.enums.TeacherOpenCourseHomeworkFromTypeEnum; import com.ibeetl.jlw.web.query.TeacherOpenCourseHomeworkQuery; import com.ibeetl.jlw.web.query.TeacherOpenCourseHomeworkSettingQuery; @@ -189,31 +188,4 @@ class TeacherOpenCourseHomeworkControllerTest extends BaseTest { System.out.println(result); } - @Test - @Order(2) - public void homeworkDetail() throws Exception { - - // 获取一个状态正常的作业ID - TeacherOpenCourseHomework entity = new TeacherOpenCourseHomework(); - entity.setTeacherOpenCourseHomeworkStatus(1); - List homeworkList = teacherOpenCourseHomeworkDao.template(entity); - // 断言 - Assert.assertTrue(ObjectUtil.isNotEmpty(homeworkList)); - - // 开课作业ID - Long teacherOpenCourseHomeworkId = RandomUtil.randomEle(homeworkList).getTeacherOpenCourseHomeworkId(); - - //构造请求参数 - RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/homeworkDetail.json") - .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) - .param("teacherOpenCourseHomeworkId", String.valueOf(teacherOpenCourseHomeworkId)); - - //发送请求,验证返回结果 - String result = mvc.perform(rb) - .andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0")) - .andReturn().getResponse().getContentAsString(); - - System.out.println(result); - } } \ No newline at end of file diff --git a/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java b/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java index 19e15581..1fbc68ab 100644 --- a/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java +++ b/web/src/test/java/com/ibeetl/jlw/web/TeacherOpenCourseQuestionLogControllerTest.java @@ -3,9 +3,14 @@ package com.ibeetl.jlw.web; import base.BaseTest; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; +import cn.hutool.json.JSONUtil; import com.ibeetl.jlw.dao.ResourcesQuestionSnapshotDao; import com.ibeetl.jlw.dao.StudentDao; +import com.ibeetl.jlw.dao.TeacherOpenCourseHomeworkDao; import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot; +import com.ibeetl.jlw.entity.TeacherOpenCourseHomework; +import org.junit.Assert; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.RequestBuilder; @@ -17,6 +22,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import static cn.hutool.json.JSONUtil.toJsonStr; +import static java.util.stream.Collectors.toList; import static org.apache.commons.lang3.StringUtils.join; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -29,6 +35,8 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest { StudentDao studentDao; @Resource ResourcesQuestionSnapshotDao resourcesQuestionSnapshotDao; + @Resource + TeacherOpenCourseHomeworkDao teacherOpenCourseHomeworkDao; /** * 和题目有关的做题提交方法 @@ -99,4 +107,70 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest { clearEnvLoginInfo(); } } + + @Test + @Order(2) + public void questionDetail() throws Exception { + + // 获取一个状态正常的作业ID + TeacherOpenCourseHomework entity = new TeacherOpenCourseHomework(); + entity.setTeacherOpenCourseHomeworkStatus(1); + List homeworkList = teacherOpenCourseHomeworkDao.template(entity); + // 断言 + Assert.assertTrue(ObjectUtil.isNotEmpty(homeworkList)); + + // 开课作业ID + Long teacherOpenCourseHomeworkId = RandomUtil.randomEle(homeworkList).getTeacherOpenCourseHomeworkId(); + + //构造请求参数 + RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/questionDetail.json") + .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + .param("resourcesQuestionSnapshotFromId", String.valueOf(teacherOpenCourseHomeworkId)); + + //发送请求,验证返回结果 + String result = mvc.perform(rb) + .andExpect(status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0")) + .andReturn().getResponse().getContentAsString(); + + System.out.println(result); + } + + + @Test + @Order(3) + public void questionAnalysis() throws Exception { + + // 随机取一个学生的登录信息 + List questionSnapshots = resourcesQuestionSnapshotDao.execute( + "select t.*\n" + + " from resources_question_snapshot t\n" + + " where t.question_status = 1\n" + + "\tand resources_question_snapshot_from_id = \n" + + "\t\t(select resources_question_snapshot_from_id from resources_question_snapshot ORDER BY RAND() limit 1) \n" + + " order by RAND()"); + // 断言 + Assert.assertTrue(ObjectUtil.isNotEmpty(questionSnapshots)); + + // 开课作业ID + List questionSnapshotIds = RandomUtil.randomEleList(questionSnapshots, 10) + .stream().map(ResourcesQuestionSnapshot::getResourcesQuestionSnapshotId).collect(toList()); + + putStudentLoginInfoToEnv(); + + //构造请求参数 + RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/questionAnalysis.json") + .contentType(MediaType.APPLICATION_JSON_VALUE) + .content(JSONUtil.toJsonStr(questionSnapshotIds)); + + //发送请求,验证返回结果 + String result = mvc.perform(rb) + .andExpect(status().isOk()) + .andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0")) + .andReturn().getResponse().getContentAsString(); + + System.out.println(result); + + clearEnvLoginInfo(); + } } \ No newline at end of file