mcy_new #1

Merged
wangyang merged 179 commits from mcy_new into master 2025-08-28 10:10:45 +08:00
3 changed files with 114 additions and 102 deletions
Showing only changes of commit 3f9661436d - Show all commits

View File

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -147,8 +148,7 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
child: TextButton( child: TextButton(
onPressed: () => onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating(context)),
easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating(context)),
child: quickText('全 错', color: Colors.white, size: 12.sp), child: quickText('全 错', color: Colors.white, size: 12.sp),
), ),
), ),
@ -183,7 +183,6 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
), ),
), ),
), ),
], ],
), ),
), ),
@ -212,14 +211,28 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
height: double.infinity, height: double.infinity,
child: TextButton( child: TextButton(
onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.submit(context)), 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),
],
),
), ),
), ),
), ),
], ],
), ),
), ),
], ],
), ),
); );

View File

@ -61,8 +61,7 @@ class QuestionPaperView extends GetView<HomeworkReviewLogic> {
return Stack( return Stack(
children: [ children: [
// //
QuestionImageView(maxWidth, maxHeight, annotationState, controller, QuestionImageView(maxWidth, maxHeight, annotationState, controller, zoomState: zoomState, sateData: sateData, actualHeight: zoomFileModel.actualHeight!),
zoomState: zoomState, sateData: sateData, actualHeight: zoomFileModel.actualHeight!),
// //
// Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)), // Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)),
// //
@ -262,8 +261,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
final ZoomState zoomState; final ZoomState zoomState;
final HomeworkReviewState sateData; final HomeworkReviewState sateData;
final HomeworkReviewAnnotationsControlState annotationState; final HomeworkReviewAnnotationsControlState annotationState;
QuestionImageView(this.maxWidth, this.maxHeight, this.annotationState, this.logic, QuestionImageView(this.maxWidth, this.maxHeight, this.annotationState, this.logic, {required this.actualHeight, required this.zoomState, required this.sateData, super.key});
{required this.actualHeight, required this.zoomState, required this.sateData, super.key});
/// ///
int _findTargetIndex<T>(List<T> list, T target, [int reciprocal = 2]) { int _findTargetIndex<T>(List<T> list, T target, [int reciprocal = 2]) {
@ -304,9 +302,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
}); });
var streamSubscriptionSlide = sateData.slide.listen((e) { var streamSubscriptionSlide = sateData.slide.listen((e) {
if (sateData.panQuestView != null && if (sateData.panQuestView != null && sateData.panQuestView == false && initPosition.value?.dy.abs().toInt().toDouble() != sateData.slide.value) {
sateData.panQuestView == false &&
initPosition.value?.dy.abs().toInt().toDouble() != sateData.slide.value) {
if (sateData.zoomOffset != null) { if (sateData.zoomOffset != null) {
sateData.zoomOffset = Offset(sateData.zoomOffset!.dx, -sateData.slide.value); sateData.zoomOffset = Offset(sateData.zoomOffset!.dx, -sateData.slide.value);
} }
@ -330,10 +326,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
bool? res = await showDialog<bool>( bool? res = await showDialog<bool>(
context: Get.context ?? context, context: Get.context ?? context,
builder: (context1) { builder: (context1) {
return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: <Widget>[ return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: <Widget>[TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), TextButton(child: quickText("确定", color: Theme.of(context1).primaryColor), onPressed: () => Navigator.pop(context1, true))]);
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 = []; if (res == true) vnHandWritings.value = [];
@ -347,11 +340,17 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)),
TextButton( TextButton(
child: quickText("确定", color: Theme.of(context).primaryColor), child: quickText("确定", color: Theme.of(context).primaryColor),
onPressed: () { onPressed: () => easyThrottle(
Navigator.pop(context1, true); 'REVOKE_THE_LAST_ANNOTATION_AND_SUBMIT',
sateData.data.value?.zgtAnnotate = null; () {
sateData.data.value?.showZgtAnnotate = null; 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<BottomOperationBar
var zoomWtdthSpaceVal = zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1); var zoomWtdthSpaceVal = zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1);
localPosition = Offset( localPosition = Offset(
(localPosition.dx - (localPosition.dx - zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1) + ((zoomWtdthSpaceVal <= 0.1) ? (sateData.zoomOffset?.dx.abs() ?? 0) : 0)) / theScale,
zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1) + (dy - max(0, imageHeightOffsetStart) + ((zoomFile.imageHeightOffsetStart == null || zoomFile.imageHeightOffsetStart! <= 0.1) ? (sateData.zoomOffset?.dy.abs() ?? 0) : 0)) / theScale,
((zoomWtdthSpaceVal <= 0.1) ? (sateData.zoomOffset?.dx.abs() ?? 0) : 0)) /
theScale,
(dy -
max(0, imageHeightOffsetStart) +
((zoomFile.imageHeightOffsetStart == null || zoomFile.imageHeightOffsetStart! <= 0.1) ? (sateData.zoomOffset?.dy.abs() ?? 0) : 0)) /
theScale,
); );
print("最终位置 $localPosition"); print("最终位置 $localPosition");

View File

@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_rx/get_rx.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_result.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_result.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_test_questions_image_info.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_test_questions_image_info.dart';
@ -44,6 +45,7 @@ class HomeworkReviewState {
Offset? zoomOffset; Offset? zoomOffset;
RxBool favorite = false.obs; // RxBool favorite = false.obs; //
RxBool submitLoading = false.obs; //
// late String dateEnd = ''; // late String dateEnd = '';
// late int knowledgeId = 0; // late int knowledgeId = 0;
// late RxList<KnowledgeReportDetail> dataList = RxList(); // late RxList<KnowledgeReportDetail> dataList = RxList();
@ -234,12 +236,11 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
// //
RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?; RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?;
if (boundary == null) return null; 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; var pixelRatio = zoomLogic.zoomState.zoomFile.value?.pixelRatio;
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio ?? dpr);
ui.Image image = await boundary.toImage();
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData == null) return null; if (byteData == null) return null;
@ -266,78 +267,83 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
// //
/// allPairs /// allPairs
Future<void> submit(BuildContext context) async { Future<void> submit(BuildContext context) async {
var data = state.data.value; try {
if (data == null) return; 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; if (state.data.value?.studentQuestions.isEmpty ?? true) return;
var studentQuestions = state.data.value!.studentQuestions; var studentQuestions = state.data.value!.studentQuestions;
var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null); var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null);
if (noRatingElement != null) { if (noRatingElement != null) {
ToastUtils.showInfo('${noRatingElement.questionNo}题请评分'); 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: <Widget>[
TextButton(
child: const Text('继续'),
onPressed: () {
state.lastQuestionPrompt = true;
Navigator.of(context1).pop();
},
),
TextButton(
child: const Text('退出批阅'),
onPressed: () {
Navigator.of(context1).pop();
Get.back();
}),
],
);
},
);
return; return;
} }
var newParams = DoPaperDetailsParam.fromJson(state.param.value.toJson());
if (totalUnAnnotateCount > 0) { //
// String? zgtAnnotate = state.data.value?.zgtAnnotate;
newParams.templateId = null; String? newzgtAnnotate = await saveImage(context);
newParams.studentId = null; if (newzgtAnnotate != null) zgtAnnotate = newzgtAnnotate;
}
state.param.value = newParams; 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: <Widget>[
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<void> toFavorite() async { Future<void> toFavorite() async {