diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_number_view.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_number_view.dart index ed0d5c3..af3fc05 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_number_view.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_number_view.dart @@ -38,7 +38,7 @@ class QuestionNumberView extends GetView { var studentQuestions = sateData.studentQuestions.value ?? []; return $QuestionNumberScrollView( - controller:controller, + controller: controller, sateData: sateData, sateZoomData: sateZoomData, studentQuestions: studentQuestions, @@ -141,27 +141,34 @@ Widget $questionNumberScrollView({ // 单道题得分框 @hwidget -Widget $scoringQuestionsView(BuildContext context, List? studentQuestions,StudentQuestions item, HomeworkReviewLogic logic, double scaleRatio, double initScale) { +Widget $scoringQuestionsView(BuildContext context, List? studentQuestions, StudentQuestions item, HomeworkReviewLogic logic, double scaleRatio, double initScale) { var studentScore = useState(item.studentScore); - useValueChanged(studentScore.value, (_, __) { - item.studentScore = studentScore.value; - - // 校验是否自动提交 对于已经批阅过的试题 不重复自动提交 - var annotateTime = logic.state.data.value?.annotateTime; - if (annotateTime == null) { - var noRatingGiven = studentQuestions!.firstWhereOrNull((e) => e.studentScore == null); - if (noRatingGiven == null) logic.submit(context); - } - }); - - useValueChanged(item, (_, __) { + useValueChanged(item.studentScore, (_, __) { studentScore.value = item.studentScore; }); useEffect(() { - return () {}; + /// 学生打分数据 + studentScoreListener() { + item.studentScore = studentScore.value; + if (item.studentScore == null) return; + + // 校验是否自动提交 对于已经批阅过的试题 不重复自动提交 + var annotateTime = logic.state.data.value?.annotateTime; + if (annotateTime == null) { + var noRatingGiven = studentQuestions!.firstWhereOrNull((e) => e.studentScore == null); + if (noRatingGiven == null) logic.submit(context); + } + } + + studentScore.addListener(studentScoreListener); + + return () { + studentScore.removeListener(studentScoreListener); + }; }, []); + var padinVal = item.correctRate > 0 ? EdgeInsets.only(top: 6.4.h) : EdgeInsets.symmetric(vertical: 2.h); return Container( height: item.height! * scaleRatio * initScale, 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 e74e16c..d25c355 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 @@ -13,6 +13,7 @@ import 'package:making_school_asignment_app/common/job/marking_models/do_test_qu import 'package:making_school_asignment_app/common/mixins/event_bus_mixin.dart'; import 'package:making_school_asignment_app/common/utils/anti_shake_throttling.dart'; import 'package:making_school_asignment_app/common/utils/cached_network_img.dart'; +import 'package:making_school_asignment_app/common/utils/toast_utils.dart'; import 'package:making_school_asignment_app/page/global_widget/my_text.dart'; import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/index.dart'; import 'package:zoom_widget/zoom_widget.dart'; @@ -347,7 +348,17 @@ class QuestionImageView extends HookWidget with EventBusMixin logic.submit(Get.context ?? context)); + sateData.data.update((_) { + var theStudentQuestions = sateData.studentQuestions.value; + if (theStudentQuestions?.isNotEmpty ?? false) { + var noMarking = theStudentQuestions?.firstWhereOrNull((e) => e.studentScore == null); + if (noMarking != null) { + ToastUtils.showInfo("未提交!请为第${noMarking.questionNo}题打分,再手动提交"); + return; + } + } + logic.submit(Get.context ?? context); + }); } }, ), diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart index c558de6..7bcb7f9 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart @@ -173,7 +173,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { state.param.value.templateId ??= data.templateId; state.param.value.studentId ??= data.studentId; - + state.data.value = data; } catch (e) { print('获取数据报错了:$e'); @@ -189,28 +189,26 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { void cancelAllRatings() { var studentQuestions = state.studentQuestions.value; if (state.data.value?.studentQuestions.isEmpty ?? true) return; - List data = []; for (var e in studentQuestions!) { - var newe = StudentQuestions.fromJson(e.toJson()); - newe.studentScore = null; - data.add(newe); + if (e.studentScore != null) { + e.studentScore = null; + } } - state.studentQuestions.value = data; - state.data.value?.studentQuestions = data; + // state.studentQuestions.value = data; + // state.data.value?.studentQuestions = data; + state.studentQuestions.update((_) {}); } // 全部统一打分 void allRating(int score) { var studentQuestions = state.studentQuestions.value; if (state.data.value?.studentQuestions.isEmpty ?? true) return; - List data = []; for (var e in studentQuestions!) { - var newe = StudentQuestions.fromJson(e.toJson()); - newe.studentScore = score; - data.add(newe); + e.studentScore = score; } - state.studentQuestions.value = data; - state.data.value?.studentQuestions = data; + // state.studentQuestions.value = data; + // state.data.value?.studentQuestions = data; + state.studentQuestions.update((_) {}); } // 全对评分