打分BUG处理

This commit is contained in:
DESKTOP-I3JPKHK\wy 2025-04-22 18:01:28 +08:00
parent 6011f52a19
commit 08cf62a845
3 changed files with 45 additions and 29 deletions

View File

@ -38,7 +38,7 @@ class QuestionNumberView extends GetView<HomeworkReviewLogic> {
var studentQuestions = sateData.studentQuestions.value ?? []; var studentQuestions = sateData.studentQuestions.value ?? [];
return $QuestionNumberScrollView( return $QuestionNumberScrollView(
controller:controller, controller: controller,
sateData: sateData, sateData: sateData,
sateZoomData: sateZoomData, sateZoomData: sateZoomData,
studentQuestions: studentQuestions, studentQuestions: studentQuestions,
@ -141,11 +141,18 @@ Widget $questionNumberScrollView({
// //
@hwidget @hwidget
Widget $scoringQuestionsView(BuildContext context, List<StudentQuestions>? studentQuestions,StudentQuestions item, HomeworkReviewLogic logic, double scaleRatio, double initScale) { Widget $scoringQuestionsView(BuildContext context, List<StudentQuestions>? studentQuestions, StudentQuestions item, HomeworkReviewLogic logic, double scaleRatio, double initScale) {
var studentScore = useState<int?>(item.studentScore); var studentScore = useState<int?>(item.studentScore);
useValueChanged<int?, void>(studentScore.value, (_, __) { useValueChanged<int?, void>(item.studentScore, (_, __) {
studentScore.value = item.studentScore;
});
useEffect(() {
///
studentScoreListener() {
item.studentScore = studentScore.value; item.studentScore = studentScore.value;
if (item.studentScore == null) return;
// //
var annotateTime = logic.state.data.value?.annotateTime; var annotateTime = logic.state.data.value?.annotateTime;
@ -153,15 +160,15 @@ Widget $scoringQuestionsView(BuildContext context, List<StudentQuestions>? stude
var noRatingGiven = studentQuestions!.firstWhereOrNull((e) => e.studentScore == null); var noRatingGiven = studentQuestions!.firstWhereOrNull((e) => e.studentScore == null);
if (noRatingGiven == null) logic.submit(context); if (noRatingGiven == null) logic.submit(context);
} }
}); }
useValueChanged<StudentQuestions, void>(item, (_, __) { studentScore.addListener(studentScoreListener);
studentScore.value = item.studentScore;
});
useEffect(() { return () {
return () {}; studentScore.removeListener(studentScoreListener);
};
}, []); }, []);
var padinVal = item.correctRate > 0 ? EdgeInsets.only(top: 6.4.h) : EdgeInsets.symmetric(vertical: 2.h); var padinVal = item.correctRate > 0 ? EdgeInsets.only(top: 6.4.h) : EdgeInsets.symmetric(vertical: 2.h);
return Container( return Container(
height: item.height! * scaleRatio * initScale, height: item.height! * scaleRatio * initScale,

View File

@ -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/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/anti_shake_throttling.dart';
import 'package:making_school_asignment_app/common/utils/cached_network_img.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/global_widget/my_text.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/index.dart'; import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/index.dart';
import 'package:zoom_widget/zoom_widget.dart'; import 'package:zoom_widget/zoom_widget.dart';
@ -347,7 +348,17 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
sateData.data.value?.zgtAnnotate = null; sateData.data.value?.zgtAnnotate = null;
sateData.data.value?.showZgtAnnotate = null; sateData.data.value?.showZgtAnnotate = null;
if (sateData.data.value != null) { if (sateData.data.value != null) {
sateData.data.update((_) => 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);
});
} }
}, },
), ),

View File

@ -189,28 +189,26 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
void cancelAllRatings() { void cancelAllRatings() {
var studentQuestions = state.studentQuestions.value; var studentQuestions = state.studentQuestions.value;
if (state.data.value?.studentQuestions.isEmpty ?? true) return; if (state.data.value?.studentQuestions.isEmpty ?? true) return;
List<StudentQuestions> data = [];
for (var e in studentQuestions!) { for (var e in studentQuestions!) {
var newe = StudentQuestions.fromJson(e.toJson()); if (e.studentScore != null) {
newe.studentScore = null; e.studentScore = null;
data.add(newe);
} }
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) { void allRating(int score) {
var studentQuestions = state.studentQuestions.value; var studentQuestions = state.studentQuestions.value;
if (state.data.value?.studentQuestions.isEmpty ?? true) return; if (state.data.value?.studentQuestions.isEmpty ?? true) return;
List<StudentQuestions> data = [];
for (var e in studentQuestions!) { for (var e in studentQuestions!) {
var newe = StudentQuestions.fromJson(e.toJson()); e.studentScore = score;
newe.studentScore = score;
data.add(newe);
} }
state.studentQuestions.value = data; // state.studentQuestions.value = data;
state.data.value?.studentQuestions = data; // state.data.value?.studentQuestions = data;
state.studentQuestions.update((_) {});
} }
// //