From 2f2395bfe20e8e38e871c072355cb1e77fe7e9f0 Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Thu, 13 Mar 2025 14:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=A2=98=E5=8F=B7=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=EF=BC=88=E9=9D=9E?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E5=AD=97=E7=AC=A6=E4=B8=B2=E8=BD=AC=E6=95=B0?= =?UTF-8?q?=E5=AD=97=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/common/utils/utils.dart | 42 +++-- .../job_report/widget/knowledge_point.dart | 166 +++++++++--------- 2 files changed, 117 insertions(+), 91 deletions(-) diff --git a/making_school_asignment_app/lib/common/utils/utils.dart b/making_school_asignment_app/lib/common/utils/utils.dart index 13c0e70..e74e7c2 100644 --- a/making_school_asignment_app/lib/common/utils/utils.dart +++ b/making_school_asignment_app/lib/common/utils/utils.dart @@ -117,13 +117,36 @@ class Utils { for (var stu in data.students) { stu.kgtStu = kgt.where((w) => w.studentId == stu.studentId).toList(); - stu.kgtStu!.sort((a, b) => num.parse(a.questionNo).compareTo(num.parse(b.questionNo))); + // stu.kgtStu!.sort((a, b) => num.parse(a.questionNo).compareTo(num.parse(b.questionNo))); + // stu.kgtStu!.sort((a, b) => num.parse(a.questionNo).compareTo(num.parse(b.questionNo))); + stu.kgtStu!.sort((a, b) { + try { + if (RegExp(r'^\d*\.?\d+$').hasMatch(a.questionNo) && RegExp(r'^\d*\.?\d+$').hasMatch(b.questionNo)) { + return num.parse(a.questionNo).compareTo(num.parse(b.questionNo)); + } else { + throw Exception(); + } + } catch (e) { + return a.questionNo.toLowerCase().compareTo(b.questionNo.toLowerCase()); + } + }); stu.kgtOkCount = stu.kgtStu!.where((w) => w.state == 3).length; stu.kgtErrorCount = stu.kgtStu!.where((w) => w.state == 2).length; stu.kgtAnswerCount = stu.kgtStu!.where((w) => w.state != 0).length; stu.zgtStu = zgt.where((w) => w.studentId == stu.studentId).toList(); - stu.zgtStu!.sort((a, b) => num.parse(a.questionNo).compareTo(num.parse(b.questionNo))); + // stu.zgtStu!.sort((a, b) => num.parse(a.questionNo).compareTo(num.parse(b.questionNo))); + stu.zgtStu!.sort((a, b) { + try { + if (RegExp(r'^\d*\.?\d+$').hasMatch(a.questionNo) && RegExp(r'^\d*\.?\d+$').hasMatch(b.questionNo)) { + return num.parse(a.questionNo).compareTo(num.parse(b.questionNo)); + } else { + throw Exception(); + } + } catch (e) { + return a.questionNo.toLowerCase().compareTo(b.questionNo.toLowerCase()); + } + }); //正确 stu.zgtOkCount = stu.zgtStu!.where((w) => w.state == 3).length; //错误 @@ -167,21 +190,20 @@ class Utils { var stuDtls = data.dtls.where((w) => w.studentId == stu.studentId); var secList = []; - for(var sec in stuDtls){ - if(sec.useTime >= 1){ + for (var sec in stuDtls) { + if (sec.useTime >= 1) { var date = DateTime.parse(sec.lastAnswerTime!); - var lastSec =(date.difference(DateTime(1970)).inSeconds).floor(); + var lastSec = (date.difference(DateTime(1970)).inSeconds).floor(); secList.add(lastSec); secList.add(lastSec - sec.useTime); } } - secList.sort(); - var maxSec = secList.isNotEmpty?secList.last:0; - var minSec = secList.isNotEmpty?secList.first:0; - var secTime = secList.isNotEmpty?maxSec-minSec:0; + secList.sort(); + var maxSec = secList.isNotEmpty ? secList.last : 0; + var minSec = secList.isNotEmpty ? secList.first : 0; + var secTime = secList.isNotEmpty ? maxSec - minSec : 0; stu.ttlSec = second2HMS(secTime); - } data.students.sort((a, b) { diff --git a/making_school_asignment_app/lib/page/home_page/children/job_report/widget/knowledge_point.dart b/making_school_asignment_app/lib/page/home_page/children/job_report/widget/knowledge_point.dart index a1f2277..16eaad1 100644 --- a/making_school_asignment_app/lib/page/home_page/children/job_report/widget/knowledge_point.dart +++ b/making_school_asignment_app/lib/page/home_page/children/job_report/widget/knowledge_point.dart @@ -14,7 +14,8 @@ class KnowledgePoint extends StatefulWidget { final String className; final String homeworkId; final int subject; - KnowledgePoint({Key? key, required this.knowsList, required this.data, required this.className, required this.homeworkId,required this.subject}) : super(key: key); + const KnowledgePoint( + {super.key, required this.knowsList, required this.data, required this.className, required this.homeworkId, required this.subject}); @override State createState() => _KnowledgePointState(); @@ -23,7 +24,7 @@ class KnowledgePoint extends StatefulWidget { class _KnowledgePointState extends State { void goQuickCheckPersonalPath(studentId) { if (studentId != null) { - Get.toNamed(Routes.studentPersonalPage, arguments: {'studentId': studentId, 'homeworkId': widget.homeworkId,'subject':widget.subject}); + Get.toNamed(Routes.studentPersonalPage, arguments: {'studentId': studentId, 'homeworkId': widget.homeworkId, 'subject': widget.subject}); } } @@ -208,89 +209,92 @@ class _KnowledgePointState extends State { child: quickText('知识点掌握情况', color: const Color.fromRGBO(92, 92, 92, 1), size: 14.sp, fontWeight: FontWeight.bold), ), Expanded( - child: widget.knowsList.isNotEmpty? ListView( - children: widget.knowsList.value.map((item) { - return Container( - margin: EdgeInsets.only(bottom: 15.h, left: 15.r, right: 15.r), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Expanded( - flex: 10, - child: Row( + child: widget.knowsList.isNotEmpty + ? ListView( + children: widget.knowsList.value.map((item) { + return Container( + margin: EdgeInsets.only(bottom: 15.h, left: 15.r, right: 15.r), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + quickText(item.knowledgeName, size: 12.sp, color: const Color.fromRGBO(152, 152, 152, 1)), + quickText('${item.okRate!.toStringAsFixed(0)}%', size: 12.sp, color: const Color.fromRGBO(64, 64, 64, 1)), + ], + ), + ), + SizedBox(width: 10.w), + const Expanded(flex: 1, child: SizedBox()), + ], + ), + SizedBox(height: 3.h), + Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - quickText(item.knowledgeName, size: 12.sp, color: const Color.fromRGBO(152, 152, 152, 1)), - quickText('${item.okRate!.toStringAsFixed(0)}%', size: 12.sp, color: const Color.fromRGBO(64, 64, 64, 1)), - ], - ), - ), - SizedBox(width: 10.w), - const Expanded(flex: 1, child: SizedBox()), - ], - ), - SizedBox(height: 3.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 10, - child: LinearPercentIndicator( - padding: EdgeInsets.zero, - animation: true, - lineHeight: 10.h, - animationDuration: 2500, - percent: item.okRate! / 100, - progressColor: Theme.of(context).primaryColor, - backgroundColor: const Color.fromRGBO(219, 224, 243, 1), - barRadius: Radius.circular(10.r), - )), - SizedBox(width: 10.w), - InkWell( - onTap: () { - List ques = - widget.data.questions.where((w) => w.knows.indexWhere((k) => k.knowledgeId == item.knowledgeId) > -1).toList(); - List array2 = [...widget.data.students]; - for (var stu in array2) { - stu.queDtls = widget.data.dtls - .where((w) => - w.studentId == stu.studentId && - ques.indexWhere((q) => w.templateId == q.templateId && w.questionNo == q.questionNo) > -1) - .toList(); - int okCount = stu.queDtls!.where((w) => w.state == 3).length; - int ttlCount = stu.queDtls!.length; - stu.okRate = Utils.calcRate(okCount, ttlCount); - stu.queDtls!.sort((a, b) { - num num1 = num.parse(a.questionNo); - num num2 = num.parse(b.questionNo); - return num1.compareTo(num2); - }); - } + Expanded( + flex: 10, + child: LinearPercentIndicator( + padding: EdgeInsets.zero, + animation: true, + lineHeight: 10.h, + animationDuration: 2500, + percent: item.okRate! / 100, + progressColor: Theme.of(context).primaryColor, + backgroundColor: const Color.fromRGBO(219, 224, 243, 1), + barRadius: Radius.circular(10.r), + )), + SizedBox(width: 10.w), + InkWell( + onTap: () { + List ques = widget.data.questions + .where((w) => w.knows.indexWhere((k) => k.knowledgeId == item.knowledgeId) > -1) + .toList(); + List array2 = [...widget.data.students]; + for (var stu in array2) { + stu.queDtls = widget.data.dtls + .where((w) => + w.studentId == stu.studentId && + ques.indexWhere((q) => w.templateId == q.templateId && w.questionNo == q.questionNo) > -1) + .toList(); + int okCount = stu.queDtls!.where((w) => w.state == 3).length; + int ttlCount = stu.queDtls!.length; + stu.okRate = Utils.calcRate(okCount, ttlCount); + stu.queDtls!.sort((a, b) { + num num1 = num.parse(a.questionNo); + num num2 = num.parse(b.questionNo); + return num1.compareTo(num2); + }); + } - showPeopleListDialog( - context: context, - title: item.knowledgeName, - arr: array2, - ); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - quickText('查看', size: 12.sp, color: const Color.fromRGBO(239, 135, 20, 1)), - Icon(Icons.arrow_forward_ios, size: 11.sp, color: const Color.fromRGBO(239, 135, 20, 1)), + showPeopleListDialog( + context: context, + title: item.knowledgeName, + arr: array2, + ); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + quickText('查看', size: 12.sp, color: const Color.fromRGBO(239, 135, 20, 1)), + Icon(Icons.arrow_forward_ios, size: 11.sp, color: const Color.fromRGBO(239, 135, 20, 1)), + ], + ), + ), ], - ), - ), - ], - ) - ], - ), - ); - }).toList()): MyEmptyWidget(imgWidth: 100.r, imgHeight: 100.r, font: 8.sp), + ) + ], + ), + ); + }).toList()) + : MyEmptyWidget(imgWidth: 100.r, imgHeight: 100.r, font: 8.sp), ), ], ));