From 9b96db5bca107c2acfef4cb6e4c9cf7226ae5d08 Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Tue, 12 Mar 2024 18:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=BE=99=E8=80=81=E5=B8=88?= =?UTF-8?q?=E6=8F=90=E5=87=BA=E6=94=B6=E8=97=8F=E5=92=8C=E5=9C=A8=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=B7=B2=E9=98=85=E6=95=B0=E9=87=8F=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=BD=93=E5=89=8D=E4=B9=9F=E5=96=82=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=AD=A6=E7=94=9F=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/model/job/job_collect_params.dart | 4 + .../favorite_widget.dart | 15 +- .../homework_correction/do_papers_job.dart | 166 +++++++++++++++--- 3 files changed, 150 insertions(+), 35 deletions(-) diff --git a/marking_app/lib/common/model/job/job_collect_params.dart b/marking_app/lib/common/model/job/job_collect_params.dart index 3ec0fa6..f5d80af 100644 --- a/marking_app/lib/common/model/job/job_collect_params.dart +++ b/marking_app/lib/common/model/job/job_collect_params.dart @@ -4,6 +4,9 @@ part 'job_collect_params.g.dart'; @JsonSerializable() class JobCollectParams extends Object { + @JsonKey(name: 'paperId') + int paperId; + @JsonKey(name: 'taskId') int taskId; @@ -14,6 +17,7 @@ class JobCollectParams extends Object { bool isCollect; JobCollectParams( + this.paperId, this.taskId, this.studentId, this.isCollect, diff --git a/marking_app/lib/pages/homework_correction/components/new_version_of_homework/favorite_widget.dart b/marking_app/lib/pages/homework_correction/components/new_version_of_homework/favorite_widget.dart index 73f3491..138ad8f 100644 --- a/marking_app/lib/pages/homework_correction/components/new_version_of_homework/favorite_widget.dart +++ b/marking_app/lib/pages/homework_correction/components/new_version_of_homework/favorite_widget.dart @@ -19,12 +19,13 @@ class FavoriteWidget extends StatefulWidget { class _FavoriteState extends State with EventBusMixin, CommonMixin { Future? _future; // 考试试卷 - + JobQuestionsSwitch? _eventModel; @override void initState() { super.initState(); eventOn(callback: (JobQuestionsSwitch eventModel) { - _future = getData(eventModel.taskId, eventModel.studentId); + _eventModel = eventModel; + _future = getData(eventModel.taskId, eventModel.studentId, eventModel.paperId); toUpState(setState, () {}, mounted); }); } @@ -35,11 +36,11 @@ class _FavoriteState extends State with EventBusMixin getData(int taskId, int studentId) async { + Future getData(int taskId, int studentId, int paperId) async { try { RestClient _client = await getClient(); BaseStructureResult res = await _client.getJobCollect(taskId, studentId); - if (res.success) return JobCollectParams(taskId, studentId, res.data ?? false); + if (res.success) return JobCollectParams(paperId, taskId, studentId, res.data ?? false); } catch (e) {} return null; @@ -47,12 +48,13 @@ class _FavoriteState extends State with EventBusMixin toFavorite(JobCollectParams favoriteVal) async { try { + if (_eventModel?.paperId == null) return; ToastUtils.showLoading(); RestClient _client = await getClient(); favoriteVal.isCollect = !favoriteVal.isCollect; BaseStructureResult res = await _client.toJobFavoriteCancel(favoriteVal); if (res.success) { - _future = getData(favoriteVal.taskId, favoriteVal.studentId); + _future = getData(favoriteVal.taskId, favoriteVal.studentId, _eventModel!.paperId); toUpState(setState, () {}, mounted); } else { ToastUtils.showError(res.message ?? '操作失败,请重试'); @@ -97,6 +99,7 @@ class _FavoriteState extends State with EventBusMixin { exitCallback: () => Navigator.of(context).pop(refresh), ), SizedBox(height: 1.h), - Expanded(child: ExamPaperAndScoringView(taskId: taskId)), + Expanded(child: ExamPaperAndScoringView(taskId: taskId, className: className)), $BottomOperationBar() ], ), @@ -108,7 +109,17 @@ class DoPapersJob extends HookWidget with EventBusMixin { class ReviewStatusInfo extends HookWidget with CommonMixin { final int taskId; final int pageIndex; - const ReviewStatusInfo({required this.taskId, required this.pageIndex, super.key}); + // final int schoolId; + // final int gradeId; + final String className; + const ReviewStatusInfo({ + required this.taskId, + required this.pageIndex, + // required this.schoolId, + // required this.gradeId, + required this.className, + super.key, + }); Future getData() async { var _client = await getClient(); @@ -116,6 +127,21 @@ class ReviewStatusInfo extends HookWidget with CommonMixin { return result.data; } + /// 获取未提交 + Future?> getStudents() async { + try { + ToastUtils.showLoading(); + var _client = await getClient(); + var _result = await _client + .getJobWithStudents(JobConcernedWithStudentParams([taskId], isCommit: false, pageIndex: pageIndex)); + if (_result.success) return _result.data; + } catch (e) { + ToastUtils.showError('获取数据失败,请重试'); + } finally { + ToastUtils.dismiss(); + } + } + @override Widget build(BuildContext context) { var doMarkingInfo = useState(null); @@ -125,17 +151,77 @@ class ReviewStatusInfo extends HookWidget with CommonMixin { }, []); if (doMarkingInfo.value == null) return Container(); - return Container( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - quickText('已阅', color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp), - quickText(doMarkingInfo.value!.finishCount, - color: Color.fromRGBO(76, 199, 147, 1), size: 12.sp, fontWeight: FontWeight.bold), - quickText('/', color: Color.fromRGBO(117, 117, 117, 1), size: 12.sp), - quickText(doMarkingInfo.value!.surplusNo, color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp), - ], + return InkWell( + onTap: () async { + print('点击了...'); + List? students = await getStudents(); + if (students == null) return; + showModalBottomSheet( + context: context, + elevation: 10, + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10.r), + topRight: Radius.circular(10.r), + ), + ), + builder: (BuildContext context) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 2.w), + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 14.h), + child: quickText( + '当前页未提交作业学生名单', + size: 15.sp, + fontWeight: FontWeight.bold, + color: Color.fromRGBO(60, 60, 60, 1), + ), + ), + SizedBox(height: 10.h), + Expanded( + child: ListView( + padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 4.w), + children: [ + Wrap( + spacing: 6.0, // 主轴(水平)方向间距 + runSpacing: 4.0, // 纵轴(垂直)方向间距 + alignment: WrapAlignment.spaceAround, //沿主轴方向居中 + children: students.map((e) { + return Chip( + backgroundColor: Color.fromRGBO(239, 242, 255, 1), + avatar: CircleAvatar( + backgroundColor: Colors.white, + child: quickText(e.studentName.substring(0, 1), + size: 12.sp, color: Theme.of(context).primaryColor), + ), + label: quickText(e.studentName, color: Color.fromRGBO(80, 94, 110, 1), size: 12.sp), + ); + }).toList(), + ), + ], + ), + ) + ], + ), + ); + }, + ); + }, + child: Container( + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + quickText('已阅', color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp), + quickText(doMarkingInfo.value!.finishCount, + color: Color.fromRGBO(76, 199, 147, 1), size: 12.sp, fontWeight: FontWeight.bold), + quickText('/', color: Color.fromRGBO(117, 117, 117, 1), size: 12.sp), + quickText(doMarkingInfo.value!.surplusNo, color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp), + ], + ), ), ); } @@ -381,7 +467,8 @@ Widget $dropdownBoxSwitchStudentsOrTypeView(BuildContext context, // 试卷和打分键盘栏 class ExamPaperAndScoringView extends StatefulHookConsumerWidget { final int taskId; - const ExamPaperAndScoringView({required this.taskId, super.key}); + final String className; + const ExamPaperAndScoringView({required this.taskId, required this.className, super.key}); @override _EexamPaperAndScoringViewState createState() => _EexamPaperAndScoringViewState(); @@ -444,7 +531,7 @@ class _EexamPaperAndScoringViewState extends ConsumerState _useDoScoring.goToScoringShortcut( - scoring: ScoringMethodEnum.CORRECT, - questionNo: question.questionNo, - ), + onTap: () { + _useDoScoring.goToScoringShortcut( + scoring: ScoringMethodEnum.CORRECT, + questionNo: question.questionNo, + ); + var noAnswerQuestion = + _useDoScoring.submittedData.value.questions.firstWhereOrNull((e) => e.score == null); + if (noAnswerQuestion == null) toSubmit(); + }, child: Container( padding: EdgeInsets.symmetric(vertical: 12.r), alignment: Alignment.center, @@ -736,10 +834,15 @@ Widget $examPaperAndScoringKeyboardView( SizedBox(width: 0.2.w), Expanded( child: $MaterialBtn( - onTap: () => _useDoScoring.goToScoringShortcut( - scoring: ScoringMethodEnum.CORRECT_HALF, - questionNo: question.questionNo, - ), + onTap: () { + _useDoScoring.goToScoringShortcut( + scoring: ScoringMethodEnum.CORRECT_HALF, + questionNo: question.questionNo, + ); + var noAnswerQuestion = + _useDoScoring.submittedData.value.questions.firstWhereOrNull((e) => e.score == null); + if (noAnswerQuestion == null) toSubmit(); + }, bgc: Color.fromRGBO(237, 237, 237, 1), child: Container( padding: EdgeInsets.symmetric(vertical: 12.r), @@ -758,10 +861,15 @@ Widget $examPaperAndScoringKeyboardView( SizedBox(width: 0.2.w), Expanded( child: $MaterialBtn( - onTap: () => _useDoScoring.goToScoringShortcut( - scoring: ScoringMethodEnum.WRONG, - questionNo: question.questionNo, - ), + onTap: () { + _useDoScoring.goToScoringShortcut( + scoring: ScoringMethodEnum.WRONG, + questionNo: question.questionNo, + ); + var noAnswerQuestion = + _useDoScoring.submittedData.value.questions.firstWhereOrNull((e) => e.score == null); + if (noAnswerQuestion == null) toSubmit(); + }, bgc: Color.fromRGBO(237, 237, 237, 1), child: Container( padding: EdgeInsets.symmetric(vertical: 12.r),