diff --git a/.gitignore b/.gitignore index 62d7c41..2c3d1f0 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.g.dart making_school_asignment_app/lib/common/api/retrofit_client.g.dart making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.g.dart +.vscode/settings.json diff --git a/making_school_asignment_app/lib/common/api/retrofit_client.dart b/making_school_asignment_app/lib/common/api/retrofit_client.dart index 1858341..f8c0ad6 100644 --- a/making_school_asignment_app/lib/common/api/retrofit_client.dart +++ b/making_school_asignment_app/lib/common/api/retrofit_client.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart' hide Headers; 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/favor_param.dart'; +import 'package:making_school_asignment_app/common/job/marking_models/review_submission_params.dart'; import 'package:retrofit/retrofit.dart'; import 'package:making_school_asignment_app/common/job/annotated_class.dart'; import 'package:making_school_asignment_app/common/job/class_item.dart'; @@ -113,10 +114,13 @@ abstract class RetrofitClient { //收藏夹列表 @GET("/api/hms/FavStudent/GetList") - Future> getFavList( - @Query('HomeworkName') String homeworkName, @Query('ClassId') String classId); + Future> getFavList(@Query('HomeworkName') String homeworkName, @Query('ClassId') String classId); //一键批阅 (默认未批阅的题目全部正确) @POST("/api/hms/Annotate/AllCorrect") - Future getAllCorrect(@Field() String homeworkId,@Field() String classId); + Future getAllCorrect(@Field() String homeworkId, @Field() String classId); + + // 批阅提交 + @POST("/api/hms/Annotate/AnnotateSubmit") + Future reviewSubmission(@Body() ReviewSubmissionParams param); } diff --git a/making_school_asignment_app/lib/common/job/marking_models/review_submission_params.dart b/making_school_asignment_app/lib/common/job/marking_models/review_submission_params.dart new file mode 100644 index 0000000..7f45794 --- /dev/null +++ b/making_school_asignment_app/lib/common/job/marking_models/review_submission_params.dart @@ -0,0 +1,55 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'review_submission_params.g.dart'; + +@JsonSerializable(includeIfNull: false) +class ReviewSubmissionParams extends Object { + @JsonKey(name: 'homeworkId') + String homeworkId; + + @JsonKey(name: 'templateId') + int templateId; + + @JsonKey(name: 'studentId') + int studentId; + + @JsonKey(name: 'studentScores') + List studentScores; + + @JsonKey(name: 'pictureBytes') + String? zgtAnnotate; + + ReviewSubmissionParams({ + required this.homeworkId, + required this.templateId, + required this.studentId, + required this.studentScores, + this.zgtAnnotate, + }); + + factory ReviewSubmissionParams.fromJson(Map srcJson) => _$ReviewSubmissionParamsFromJson(srcJson); + + Map toJson() => _$ReviewSubmissionParamsToJson(this); +} + +@JsonSerializable() +class StudentScores extends Object { + @JsonKey(name: 'questionNo') + int questionNo; + + @JsonKey(name: 'studentScore') + int studentScore; + + @JsonKey(name: 'isCorrect') + bool isCorrect; + + StudentScores({ + required this.questionNo, + required this.studentScore, + required this.isCorrect, + }); + + factory StudentScores.fromJson(Map srcJson) => _$StudentScoresFromJson(srcJson); + + Map toJson() => _$StudentScoresToJson(this); +} diff --git a/making_school_asignment_app/lib/page/home_page/children/annotate_class/widget/annotate_item.dart b/making_school_asignment_app/lib/page/home_page/children/annotate_class/widget/annotate_item.dart index afe1712..121f266 100644 --- a/making_school_asignment_app/lib/page/home_page/children/annotate_class/widget/annotate_item.dart +++ b/making_school_asignment_app/lib/page/home_page/children/annotate_class/widget/annotate_item.dart @@ -23,12 +23,11 @@ class AnnotateItem extends StatefulWidget { } class _AnnotateItemState extends State { - Future confirmDialog() async { return await showDialog( context: context, builder: (context) => AlertDialog( - shape: RoundedRectangleBorder( + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), // 设置圆角大小 ), actionsPadding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 10.r), @@ -51,9 +50,9 @@ class _AnnotateItemState extends State { ), child: const Center( child: Text( - '确定', - style: TextStyle(color: Colors.white), - ))), + '确定', + style: TextStyle(color: Colors.white), + ))), onTap: () { // 执行操作 Get.back(result: true); @@ -72,9 +71,9 @@ class _AnnotateItemState extends State { ), child: const Center( child: Text( - '取消', - style: TextStyle(color: Color(0xFF666666)), - ))), + '取消', + style: TextStyle(color: Color(0xFF666666)), + ))), ), ], ), @@ -129,10 +128,15 @@ class _AnnotateItemState extends State { Expanded( flex: 4, child: ItemBtn( - title: "收藏夹${widget.item.homeworkFavs.isNotEmpty?'(${ widget.item.homeworkFavs.length})':''}", + title: "收藏夹${widget.item.homeworkFavs.isNotEmpty ? '(${widget.item.homeworkFavs.length})' : ''}", font: widget.font - 2.sp, clickFunction: () { - Get.toNamed(Routes.favStudentPage,arguments: {'homeworkName':widget.name,'classId':widget.item.classId,'homeworkId':widget.logic.state.homeworkId.value,'grade':widget.item.grade}); + Get.toNamed(Routes.favStudentPage, arguments: { + 'homeworkName': widget.name, + 'classId': widget.item.classId, + 'homeworkId': widget.logic.state.homeworkId.value, + 'grade': widget.item.grade + }); }, ), ), @@ -147,12 +151,10 @@ class _AnnotateItemState extends State { child: ItemBtn( title: "一键批阅", font: widget.font - 2.sp, - clickFunction: () async{ - var confim = - await confirmDialog(); + clickFunction: () async { + var confim = await confirmDialog(); if (confim) { - widget.logic.getAllCorrect( - widget.item.classId); + widget.logic.getAllCorrect(widget.item.classId); } }, ), @@ -178,10 +180,15 @@ class _AnnotateItemState extends State { Expanded( flex: 4, child: ItemBtn( - title: "收藏夹${widget.item.homeworkFavs.isNotEmpty?'(${ widget.item.homeworkFavs.length})':''}", + title: "收藏夹${widget.item.homeworkFavs.isNotEmpty ? '(${widget.item.homeworkFavs.length})' : ''}", font: widget.font - 2.sp, clickFunction: () { - Get.toNamed(Routes.favStudentPage,arguments: {'homeworkName':widget.name,'classId':widget.item.classId,'homeworkId':widget.logic.state.homeworkId.value,'grade':widget.item.grade}); + Get.toNamed(Routes.favStudentPage, arguments: { + 'homeworkName': widget.name, + 'classId': widget.item.classId, + 'homeworkId': widget.logic.state.homeworkId.value, + 'grade': widget.item.grade + }); }, ), ), @@ -287,6 +294,7 @@ class _AnnotateItemState extends State { Expanded( child: InkWell( onTap: () { + print('批阅..........'); Get.toNamed(Routes.reviewHomework, arguments: { 'homeworkId': widget.homeworkId, 'homeworkName': widget.name, 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 25c9d2a..dbfa22d 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 @@ -18,6 +18,7 @@ class BottomAnnotationSwitch extends StatefulWidget { class _BottomAnnotationSwitchJobState extends State with SingleTickerProviderStateMixin { late AnimationController _animationController; // 动画 + final _homeworkLogic = Get.find(); final _logicControl = Get.find().annotationState; StreamSubscription? _opControllisten; @@ -124,7 +125,7 @@ class _BottomAnnotationSwitchJobState extends State with height: double.infinity, child: TextButton( child: quickText('全 对', color: Colors.white, size: 12.sp), - onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () {}), + onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating()), ), ), ), @@ -164,7 +165,7 @@ class _BottomAnnotationSwitchJobState extends State with width: double.infinity, height: double.infinity, child: TextButton( - onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () {}), + onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allPairs()), child: quickText('全 错', color: Colors.white, size: 12.sp), ), ), @@ -185,7 +186,7 @@ class _BottomAnnotationSwitchJobState extends State with width: double.infinity, height: double.infinity, child: TextButton( - onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () {}), + onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.cancelAllRatings()), child: quickText('取 消', size: 12.sp, color: Colors.white), ), ), @@ -196,7 +197,7 @@ class _BottomAnnotationSwitchJobState extends State with width: double.infinity, height: double.infinity, child: TextButton( - onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () {}), + onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.submit()), child: quickText('提 交', size: 12.sp, color: const Color.fromRGBO(76, 199, 147, 1)), ), ), 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 84ed6c7..9fff9e8 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 @@ -140,7 +140,8 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) { child: Obx(() { var imageVal = sateData.imageScale.value; if (imageVal == null) return const SizedBox(); - var studentQuestions = sateData.data.value?.studentQuestions; + var studentQuestions = sateData.studentQuestions.value; + print('书哈哈哈...'); return Padding( padding: EdgeInsets.only(top: imageVal.remainingHeight > 0 ? imageVal.remainingHeight / 2 : 0), child: Column( @@ -160,6 +161,15 @@ Widget $scoringQuestionsView(BuildContext context, StudentQuestions item, double useValueChanged(studentScore.value, (_, __) { item.studentScore = studentScore.value; }); + + useValueChanged(item, (_, __) { + studentScore.value = item.studentScore; + }); + + useEffect(() { + return () {}; + }, []); + return Container( alignment: Alignment.topCenter, height: item.height * scaleRatio, @@ -254,9 +264,6 @@ Widget $questionImageView(double maxWidth, double maxHeight, HomeworkReviewState ImageStream? imageStream; ImageStreamListener imageStreamListener = ImageStreamListener((ImageInfo info, bool _) { - print('屏幕宽高:宽:${maxWidth}, 高:${maxHeight}'); - print('图片的宽高:width:${info.image.width.toDouble()};高:${info.image.height.toDouble()}'); - WidgetsBinding.instance.addPostFrameCallback((_) { sateData.imageScale.value = TestQuestionsImageInfo( boxWidth: maxWidth, 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 d45eff0..6660b47 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 @@ -1,9 +1,11 @@ import 'dart:async'; +import 'dart:convert'; import 'package:get/get.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_test_questions_image_info.dart'; +import 'package:making_school_asignment_app/common/job/marking_models/review_submission_params.dart'; import 'package:making_school_asignment_app/common/mixins/request_tool_mixin.dart'; import 'package:making_school_asignment_app/common/utils/toast_utils.dart'; @@ -15,6 +17,7 @@ class HomeworkReviewState { // late String homeworkName; late Rx param; late Rx data; + late Rx?> studentQuestions; late Rx slide; // 滑动位置 late Rx imageScale; @@ -57,6 +60,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { subject: Get.arguments['subject'], ).obs; state.data = Rx(null); + state.studentQuestions = Rx?>(null); state.imageScale = Rx(null); state.slide = 0.0.obs; getData(); @@ -85,10 +89,82 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { // item.topHeight = itemPre.height; // } state.data.value = data; + state.studentQuestions.value = data.studentQuestions; } finally { if (timerControl.isActive) timerControl.cancel(); ToastUtils.dismiss(); } } + + // 取消全部评分 + 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); + } + state.studentQuestions.value = data; + state.data.value?.studentQuestions = data; + } + + // 全对评分 + void allPairs([int score = 2]) async { + 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); + } + state.studentQuestions.value = data; + state.data.value?.studentQuestions = data; + await submit(); + } + + // 全错评分 + void allWrongRating([int score = 0]) async { + 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); + } + state.studentQuestions.value = data; + state.data.value?.studentQuestions = data; + await submit(); + } + + // 提交打分 + /// allPairs + Future submit() async { + 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; + } + // TODO 请求提交加载框是否需要 如何防止重复提交 + await getClient().reviewSubmission(ReviewSubmissionParams( + homeworkId: state.param.value.homeworkId, + templateId: data.templateId, + studentId: data.studentId, + studentScores: studentQuestions.map((e) { + var studentScore = e.studentScore!; + return StudentScores( + isCorrect: studentScore == 2, + questionNo: e.questionNo, + studentScore: studentScore, + ); + }).toList())); + } }