diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart index 56d5b23..ade8cd1 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -147,8 +148,7 @@ class _BottomAnnotationSwitchJobState extends State with width: double.infinity, height: double.infinity, child: TextButton( - onPressed: () => - easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating(context)), + onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating(context)), child: quickText('全 错', color: Colors.white, size: 12.sp), ), ), @@ -183,7 +183,6 @@ class _BottomAnnotationSwitchJobState extends State with ), ), ), - ], ), ), @@ -212,14 +211,28 @@ class _BottomAnnotationSwitchJobState extends State with height: double.infinity, child: TextButton( onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.submit(context)), - child: quickText('提 交', size: 14.sp, color: Theme.of(context).primaryColor), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Obx(() { + if (_homeworkLogic.state.submitLoading.value) { + return Padding( + padding: EdgeInsets.only(right: 4.w), + child: const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2)), + ); + } + return const SizedBox(); + }), + quickText('提 交', size: 14.sp, color: Theme.of(context).primaryColor), + ], + ), ), ), ), ], ), ), - ], ), ); diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart index b37bbf4..8be037b 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart @@ -61,8 +61,7 @@ class QuestionPaperView extends GetView { return Stack( children: [ // 主图 - QuestionImageView(maxWidth, maxHeight, annotationState, controller, - zoomState: zoomState, sateData: sateData, actualHeight: zoomFileModel.actualHeight!), + QuestionImageView(maxWidth, maxHeight, annotationState, controller, zoomState: zoomState, sateData: sateData, actualHeight: zoomFileModel.actualHeight!), // 继续批阅按钮 // Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)), // 上一题按钮 @@ -262,8 +261,7 @@ class QuestionImageView extends HookWidget with EventBusMixin(List list, T target, [int reciprocal = 2]) { @@ -304,9 +302,7 @@ class QuestionImageView extends HookWidget with EventBusMixin( context: Get.context ?? context, builder: (context1) { - return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: [ - TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), - TextButton(child: quickText("确定", color: Theme.of(context1).primaryColor), onPressed: () => Navigator.pop(context1, true)) - ]); + return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: [TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), TextButton(child: quickText("确定", color: Theme.of(context1).primaryColor), onPressed: () => Navigator.pop(context1, true))]); }, ); if (res == true) vnHandWritings.value = []; @@ -347,11 +340,17 @@ class QuestionImageView extends HookWidget with EventBusMixin Navigator.pop(context1, false)), TextButton( child: quickText("确定", color: Theme.of(context).primaryColor), - onPressed: () { - Navigator.pop(context1, true); - sateData.data.value?.zgtAnnotate = null; - sateData.data.value?.showZgtAnnotate = null; - }, + onPressed: () => easyThrottle( + 'REVOKE_THE_LAST_ANNOTATION_AND_SUBMIT', + () { + Navigator.pop(context1, true); + sateData.data.value?.zgtAnnotate = null; + sateData.data.value?.showZgtAnnotate = null; + if (sateData.data.value != null) { + sateData.data.update((_) => logic.submit(Get.context ?? context)); + } + }, + ), ) ]); }, @@ -458,14 +457,8 @@ class QuestionImageView extends HookWidget with EventBusMixin dataList = RxList(); @@ -234,12 +236,11 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { // 没有图片就上传图片 RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?; if (boundary == null) return null; - // double dpr = MediaQuery.of(context).devicePixelRatio; + double dpr = MediaQuery.of(context).devicePixelRatio; /// 此图片在设备中的像素比例 - // double? pixelRatio = zoomLogic.zoomState.zoomFile.value?.scaleRatio ?? MediaQuery.of(context).devicePixelRatio; - - ui.Image image = await boundary.toImage(); + var pixelRatio = zoomLogic.zoomState.zoomFile.value?.pixelRatio; + ui.Image image = await boundary.toImage(pixelRatio: pixelRatio ?? dpr); ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); if (byteData == null) return null; @@ -266,78 +267,83 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { // 提交打分 /// allPairs Future submit(BuildContext context) async { - var data = state.data.value; - if (data == null) return; + try { + if(state.submitLoading.value) return; + state.submitLoading.value = true; + var data = state.data.value; + if (data == null) return; - if (state.data.value?.studentQuestions.isEmpty ?? true) return; - var studentQuestions = state.data.value!.studentQuestions; - var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null); - if (noRatingElement != null) { - ToastUtils.showInfo('${noRatingElement.questionNo}题请评分'); - return; - } - - // 图片上传 - String? zgtAnnotate = state.data.value?.zgtAnnotate; - String? newzgtAnnotate = await saveImage(context); - if (newzgtAnnotate != null) zgtAnnotate = newzgtAnnotate; - - // TODO 请求提交加载框是否需要 如何防止重复提交 - await getClient() - .reviewSubmission(ReviewSubmissionParams( - homeworkId: state.param.value.homeworkId, - templateId: data.templateId, - studentId: data.studentId, - zgtAnnotate: zgtAnnotate, - studentScores: studentQuestions.map((e) { - var studentScore = e.studentScore!; - return StudentScores( - isCorrect: studentScore == 2, - questionNo: e.questionNo, - studentScore: studentScore, - ); - }).toList())) - .then((e) async { - state.needRefresh = true; - var totalUnAnnotateCount = data.totalUnAnnotateCount; - if (data.needAnnotate) totalUnAnnotateCount -= 1; // 是否需要批阅 - - if (totalUnAnnotateCount <= 0 && !state.lastQuestionPrompt) { - // 批阅完成 - showDialog( - context: context, - builder: (BuildContext context1) { - return AlertDialog( - title: quickText('批阅已完成'), - content: const Text('暂无更多批阅项'), - actions: [ - TextButton( - child: const Text('继续'), - onPressed: () { - state.lastQuestionPrompt = true; - Navigator.of(context1).pop(); - }, - ), - TextButton( - child: const Text('退出批阅'), - onPressed: () { - Navigator.of(context1).pop(); - Get.back(); - }), - ], - ); - }, - ); + if (state.data.value?.studentQuestions.isEmpty ?? true) return; + var studentQuestions = state.data.value!.studentQuestions; + var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null); + if (noRatingElement != null) { + ToastUtils.showInfo('${noRatingElement.questionNo}题请评分'); return; } - var newParams = DoPaperDetailsParam.fromJson(state.param.value.toJson()); - if (totalUnAnnotateCount > 0) { - // 当前批阅任务完成 重复提交后 停留在当前数据位置 - newParams.templateId = null; - newParams.studentId = null; - } - state.param.value = newParams; - }); + + // 图片上传 + String? zgtAnnotate = state.data.value?.zgtAnnotate; + String? newzgtAnnotate = await saveImage(context); + if (newzgtAnnotate != null) zgtAnnotate = newzgtAnnotate; + + await getClient() + .reviewSubmission(ReviewSubmissionParams( + homeworkId: state.param.value.homeworkId, + templateId: data.templateId, + studentId: data.studentId, + zgtAnnotate: zgtAnnotate, + studentScores: studentQuestions.map((e) { + var studentScore = e.studentScore!; + return StudentScores( + isCorrect: studentScore == 2, + questionNo: e.questionNo, + studentScore: studentScore, + ); + }).toList())) + .then((e) async { + state.needRefresh = true; + var totalUnAnnotateCount = data.totalUnAnnotateCount; + if (data.needAnnotate) totalUnAnnotateCount -= 1; // 是否需要批阅 + + if (totalUnAnnotateCount <= 0 && !state.lastQuestionPrompt) { + // 批阅完成 + showDialog( + context: context, + builder: (BuildContext context1) { + return AlertDialog( + title: quickText('批阅已完成'), + content: const Text('暂无更多批阅项'), + actions: [ + TextButton( + child: const Text('继续'), + onPressed: () { + state.lastQuestionPrompt = true; + Navigator.of(context1).pop(); + }, + ), + TextButton( + child: const Text('退出批阅'), + onPressed: () { + Navigator.of(context1).pop(); + Get.back(); + }), + ], + ); + }, + ); + return; + } + var newParams = DoPaperDetailsParam.fromJson(state.param.value.toJson()); + if (totalUnAnnotateCount > 0) { + // 当前批阅任务完成 重复提交后 停留在当前数据位置 + newParams.templateId = null; + newParams.studentId = null; + } + state.param.value = newParams; + }); + } catch (_) {}finally{ + state.submitLoading.value= false; + } } Future toFavorite() async {