From ea250d0c62d3ff3e0dff5e7667c5174d021b3080 Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Tue, 5 Mar 2024 13:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + marking_app/lib/components/TestPaperItem.dart | 40 ++++++------- .../components/jobPictureOverview.dart | 49 +++++++++++----- .../homework_tasks_view_item.dart | 4 +- .../homework_correction/do_papers_job.dart | 50 ++++++++++++++--- .../do_papers_job_exam.dart | 56 +++++++++++++++++++ .../use_switch_student_and_type.dart | 22 ++++++++ marking_app/lib/routes/RouterManager.dart | 17 +++++- .../lib/utils/request/rest_client.dart | 10 ++++ 9 files changed, 204 insertions(+), 45 deletions(-) create mode 100644 marking_app/lib/pages/homework_correction/do_papers_job_exam.dart diff --git a/.gitignore b/.gitignore index 3ca6f9a..e6fa9ab 100644 --- a/.gitignore +++ b/.gitignore @@ -199,3 +199,4 @@ marking_app/lib/common/model/report/report_marking_detail.g.dart marking_app/lib/common/model/job/job_report_knowledge_model.g.dart marking_app/lib/common/model/job/job_report_question_deatil_model.g.dart marking_app/lib/common/model/job/job_do_marking_status_info.g.dart +marking_app/lib/common/model/report/small_question.g.dart diff --git a/marking_app/lib/components/TestPaperItem.dart b/marking_app/lib/components/TestPaperItem.dart index 7e18c09..813c8f1 100644 --- a/marking_app/lib/components/TestPaperItem.dart +++ b/marking_app/lib/components/TestPaperItem.dart @@ -327,8 +327,7 @@ class TestPaperItem extends ConsumerWidget with CommonMixin { ), ), onPressed: () { - goToReviewHomework(markingItem: markingItem, ref: ref, context: context, call: () => call!()); - // goToReviewHomework(markingItem: markingItem, ref: ref, context: context); + // goToReviewHomework(markingItem: markingItem, ref: ref, context: context, call: () => call!()); }, child: Text( '已完成', @@ -460,8 +459,9 @@ class TestPaperItem extends ConsumerWidget with CommonMixin { ).show(context); } isHomeworkCorrection - ? goToReviewHomework( - markingItem: markingItem, ref: ref, context: context, call: () => call!()) + // ? goToReviewHomework( + // markingItem: markingItem, ref: ref, context: context, call: () => call!()) + ? () => {} : goToReviewTestPaper( markingtype: markingtype!, markingItem: markingItem, @@ -512,22 +512,22 @@ class TestPaperItem extends ConsumerWidget with CommonMixin { } // 批阅作业 - Future goToReviewHomework({ - required MarkingItem markingItem, - required WidgetRef ref, - required BuildContext context, - required VoidCallback call, - }) async { - int taskId = markingItem.markingUserId; - toPrint(val: '批阅作业.........'); - // ref.read(currentTaskIdProvider.notifier).setDoTaskEntity(CurrentReviewTask(taskId: taskId)); - // DetailId 回评需要传DetailId,正常阅卷不需要;PageOper(0:下一题,1:上一题,2:当前题) 回评需要传2 ;IsReview 是否会评 0否 1是 - RouterManager.router - .navigateTo(context, '${RouterManager.markingHomeworkDoPath}?taskId=$taskId', transition: getTransition()) - .then((value) { - call(); - }); - } + // Future goToReviewHomework({ + // required MarkingItem markingItem, + // required WidgetRef ref, + // required BuildContext context, + // required VoidCallback call, + // }) async { + // int taskId = markingItem.markingUserId; + // toPrint(val: '批阅作业.........'); + // // ref.read(currentTaskIdProvider.notifier).setDoTaskEntity(CurrentReviewTask(taskId: taskId)); + // // DetailId 回评需要传DetailId,正常阅卷不需要;PageOper(0:下一题,1:上一题,2:当前题) 回评需要传2 ;IsReview 是否会评 0否 1是 + // RouterManager.router + // .navigateTo(context, '${RouterManager.markingHomeworkDoPath}?taskId=$taskId', transition: getTransition()) + // .then((value) { + // call(); + // }); + // } // 批阅试卷 Future goToReviewTestPaper({ diff --git a/marking_app/lib/pages/homework_correction/components/jobPictureOverview.dart b/marking_app/lib/pages/homework_correction/components/jobPictureOverview.dart index ac579f0..30e5048 100644 --- a/marking_app/lib/pages/homework_correction/components/jobPictureOverview.dart +++ b/marking_app/lib/pages/homework_correction/components/jobPictureOverview.dart @@ -451,6 +451,18 @@ class _ExamPaperDrawingState extends ConsumerState with EventB int activePointers = 0; + /// 获取数组指定倒数具体值的下标 + int _findTargetIndex(List list, T target, [int reciprocal = 2]) { + List indexs = []; + for (int i = list.length - 1; i >= 0; i--) { + if (list[i] == target) { + indexs.add(i); + if (indexs.length == reciprocal) return i; + } + } + return -1; + } + @override void initState() { points = widget.points ?? []; @@ -464,22 +476,29 @@ class _ExamPaperDrawingState extends ConsumerState with EventB if (points.isEmpty) { return ToastUtils.getFluttertoast(context: context, msg: '已经没有批注了', gravity: ToastGravity.BOTTOM); } - var index = pointsPureData.toList().lastIndexOf(null); + // var index = pointsPureData.toList().lastIndexOf(null); + var index = _findTargetIndex(pointsPureData, null); if (index != -1) { - if (index + 1 == pointsPureData.length) { - pointsPureData = pointsPureData.sublist(0, index); - points.sublist(0, index); - index = pointsPureData.toList().lastIndexOf(null); - index == -1 ? -1 : index + 1; - } - if (index != -1) { - pointsPureData = pointsPureData.sublist(0, index); - points = points.sublist(0, index); - ref.read(jobHomeWorkProvider.notifier).setVal(points); - // toUpState(setState, () {}, mounted); - } else { - item.cleanAll = true; - } + pointsPureData = pointsPureData.sublist(0, index + 1); + points = points.sublist(0, index + 1); + ref.read(jobHomeWorkProvider.notifier).setVal(points); + toUpState(setState, () {}, mounted); + + // var _nullVal = points[index]; // 需要在最后一笔 + // if (index + 1 == pointsPureData.length) { + // pointsPureData = pointsPureData.sublist(0, index); + // points.sublist(0, index); + // index = pointsPureData.toList().lastIndexOf(null); + // index == -1 ? -1 : index + 1; + // } + // if (index != -1) { + // pointsPureData = pointsPureData.sublist(0, index); + // points = points.sublist(0, index); + // ref.read(jobHomeWorkProvider.notifier).setVal(points..add(_nullVal)); + // // toUpState(setState, () {}, mounted); + // } else { + // item.cleanAll = true; + // } } else { item.cleanAll = true; } diff --git a/marking_app/lib/pages/homework_correction/components/new_version_of_homework/homework_tasks_view_item.dart b/marking_app/lib/pages/homework_correction/components/new_version_of_homework/homework_tasks_view_item.dart index 0505607..7d2fc42 100644 --- a/marking_app/lib/pages/homework_correction/components/new_version_of_homework/homework_tasks_view_item.dart +++ b/marking_app/lib/pages/homework_correction/components/new_version_of_homework/homework_tasks_view_item.dart @@ -792,7 +792,7 @@ Widget $unfinishedBtn( return; } String url = - '${RouterManager.markingHomeworkDoPath}?taskId=${markingTask.id}&taskName=${Uri.encodeComponent(jobTaskItem.title)}&className=${Uri.encodeComponent(jobTaskItem.genderName + markingTask.className)}'; + '${RouterManager.markingHomeworkDoPath}?taskId=${markingTask.id}&jobId=${jobTaskItem.id}&taskName=${Uri.encodeComponent(jobTaskItem.title)}&className=${Uri.encodeComponent(jobTaskItem.genderName + markingTask.className)}'; RouterManager.router.navigateTo(context, url, transition: getTransition()).then((value) { if (value != null && value == true) refreshcall(); }); @@ -977,7 +977,7 @@ Widget $unfinishedBtn( } String url = - '${RouterManager.markingHomeworkDoPath}?taskId=${jobTaskClassItem.id}&taskName=${Uri.encodeComponent(jobTaskItem.title)}&className=${Uri.encodeComponent(jobTaskItem.genderName + jobTaskClassItem.className)}'; + '${RouterManager.markingHomeworkDoPath}?taskId=${jobTaskClassItem.id}&jobId=${jobTaskItem.id}&taskName=${Uri.encodeComponent(jobTaskItem.title)}&className=${Uri.encodeComponent(jobTaskItem.genderName + jobTaskClassItem.className)}'; RouterManager.router.navigateTo(context, url, transition: getTransition()).then((value) { if (value == true) refreshcall(); }); diff --git a/marking_app/lib/pages/homework_correction/do_papers_job.dart b/marking_app/lib/pages/homework_correction/do_papers_job.dart index 2e985b8..ce19639 100644 --- a/marking_app/lib/pages/homework_correction/do_papers_job.dart +++ b/marking_app/lib/pages/homework_correction/do_papers_job.dart @@ -44,9 +44,10 @@ part 'do_papers_job.g.dart'; // 作业批阅 class DoPapersJob extends HookWidget with EventBusMixin { final int taskId; // 任务ID + final int jobId; final String taskName; final String className; // 班级ID - DoPapersJob({required this.taskId, required this.taskName, required this.className, super.key}); + DoPapersJob({required this.taskId, required this.jobId, required this.taskName, required this.className, super.key}); bool refresh = false; @override @@ -88,6 +89,7 @@ class DoPapersJob extends HookWidget with EventBusMixin { // 下拉切换 $DropdownBoxSwitchStudentsOrTypeView( taskId: taskId, + jobId: jobId, exitCallback: () => Navigator.of(context).pop(refresh), ), SizedBox(height: 1.h), @@ -142,7 +144,7 @@ class ReviewStatusInfo extends HookWidget with CommonMixin { // 切换下拉框 (学生和试卷状态) @hwidget Widget $dropdownBoxSwitchStudentsOrTypeView(BuildContext context, - {required Function() exitCallback, required int taskId}) { + {required Function() exitCallback, required int taskId, required int jobId}) { UseSwitchStudentAndType _useSwitchStudentAndType = UseSwitchStudentAndType.use(); // 学生和试卷状态 // 当前tab改变时 @@ -335,6 +337,41 @@ Widget $dropdownBoxSwitchStudentsOrTypeView(BuildContext context, ), ], ), + // InkWell( + // onTap: () => easyThrottle( + // 'prioritize_homework_review', + // () => !_useSwitchStudentAndType.isFirst.value + // ? _useSwitchStudentAndType.jobPriorityReviewJoin(jobId) + // : _useSwitchStudentAndType.jobPriorityReviewCancel(jobId)), + // child: + // Row( + // crossAxisAlignment: CrossAxisAlignment.center, + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // Stack( + // alignment: const FractionalOffset(0.52, 0.24), + // children: [ + // Icon( + // const IconData(0xe63d, fontFamily: "AlibabaIcon"), + // size: 12.sp, + // color: _useSwitchStudentAndType.isFirst.value + // ? Color.fromRGBO(76, 199, 147, 1) + // : Color.fromRGBO(164, 164, 164, 1), + // ), + // quickText('优先', size: 4.sp, color: Colors.white), + // ], + // ), + // SizedBox(width: 1.2.w), + // quickText( + // '优先批阅', + // size: 10.sp, + // color: _useSwitchStudentAndType.isFirst.value + // ? Color.fromRGBO(76, 199, 147, 1) + // : Color.fromRGBO(164, 164, 164, 1), + // ), + // ], + // ), + // ), ), ], ), @@ -658,9 +695,8 @@ Widget $examPaperAndScoringKeyboardView( width: double.infinity, alignment: Alignment.center, padding: EdgeInsets.symmetric(vertical: 8.h), - decoration: BoxDecoration( - border: Border(bottom: BorderSide(width: 0.2.r, color: Colors.white)), - ), + decoration: + BoxDecoration(border: Border(bottom: BorderSide(width: 0.2.r, color: Colors.white))), child: Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, @@ -762,7 +798,7 @@ Widget $examPaperAndScoringKeyboardView( borderRadius: BorderRadius.circular(2.r), onTap: () => easyThrottle('homework_review_submission_callback', () { _useDoScoring.goToScoringShortcut(enumMode: ToScoringShortcut.ALL_PAIRS); - // toSubmit(); + toSubmit(); }, duration: Duration(milliseconds: 500)), child: Container( width: double.infinity, @@ -786,7 +822,7 @@ Widget $examPaperAndScoringKeyboardView( borderRadius: BorderRadius.circular(2.r), onTap: () => easyThrottle('homework_review_submission_callback', () { _useDoScoring.goToScoringShortcut(enumMode: ToScoringShortcut.ALL_WRONG); - // toSubmit(); + toSubmit(); }, duration: Duration(milliseconds: 500)), child: Container( width: double.infinity, diff --git a/marking_app/lib/pages/homework_correction/do_papers_job_exam.dart b/marking_app/lib/pages/homework_correction/do_papers_job_exam.dart new file mode 100644 index 0000000..40b1852 --- /dev/null +++ b/marking_app/lib/pages/homework_correction/do_papers_job_exam.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:marking_app/utils/my_text.dart'; + +/// 作业考试横屏批阅 +class DoPapersJobExam extends StatefulHookWidget { + final int taskId; // 任务ID + final int jobId; + final String taskName; + final String className; // 班级ID + const DoPapersJobExam( + {required this.taskId, required this.jobId, required this.taskName, required this.className, super.key}); + + @override + State createState() => _DoPapersJobExamState(); +} + +class _DoPapersJobExamState extends State { + bool refresh = false; // 刷新外部列表(批阅试题后就需要刷新) + + @override + void initState() { + super.initState(); + + Future.delayed(Duration.zero, () { + SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); + }); + } + + @override + void dispose() { + SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); // 强制竖屏 + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + // titleSpacing: 0, + leading: IconButton(icon: Icon(Icons.arrow_back_ios), onPressed: () => Navigator.of(context).pop(refresh)), + iconTheme: IconThemeData(color: Colors.black), + title: quickText(widget.taskName + '(${widget.className})'), + backgroundColor: Colors.white, + elevation: 0, + // actions: [ + // FavoriteWidget(), + + // ], + ), + body: Container(), + ); + } +} diff --git a/marking_app/lib/pages/homework_correction/hooks/do_papers_job/use_switch_student_and_type.dart b/marking_app/lib/pages/homework_correction/hooks/do_papers_job/use_switch_student_and_type.dart index 0366fb6..28b139b 100644 --- a/marking_app/lib/pages/homework_correction/hooks/do_papers_job/use_switch_student_and_type.dart +++ b/marking_app/lib/pages/homework_correction/hooks/do_papers_job/use_switch_student_and_type.dart @@ -172,6 +172,28 @@ class UseSwitchStudentAndType with CommonMixin, EventBusMixin { if (indexLocated == null) return null; return indexLocated == 0 ? null : tabs.value[indexLocated - 1].pageIndex; } + + /// 优先批阅 ==> 取消优先批阅 + Future jobPriorityReviewCancel(int jobId) async { + RestClient _client = await getClient(); + var studentId = currentStudent.value?.studentId; + if (studentId == null) return ToastUtils.showInfo('无法获取到学生ID,请重试'); + BaseStructureResult result = await _client.jobPriorityReviewCancel(jobId, studentId); + if (result.success) { + isFirst.value = !isFirst.value; + } + } + + /// 优先批阅 ==> 添加优先批阅 + Future jobPriorityReviewJoin(int jobId) async { + RestClient _client = await getClient(); + var studentId = currentStudent.value?.studentId; + if (studentId == null) return ToastUtils.showInfo('无法获取到学生ID,请重试'); + BaseStructureResult result = await _client.jobPriorityReviewJoin(jobId, studentId); + if (result.success) { + isFirst.value = !isFirst.value; + } + } } class ExamStatus extends Object { diff --git a/marking_app/lib/routes/RouterManager.dart b/marking_app/lib/routes/RouterManager.dart index 65926cf..20a8f4c 100644 --- a/marking_app/lib/routes/RouterManager.dart +++ b/marking_app/lib/routes/RouterManager.dart @@ -13,6 +13,7 @@ import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; import 'package:marking_app/common/model/enum/marking_list_type.dart'; import 'package:marking_app/pages/common/startUpPage.dart'; +import 'package:marking_app/pages/homework_correction/do_papers_job_exam.dart'; import 'package:marking_app/pages/homework_correction/job_report.dart'; import 'package:marking_app/pages/homework_correction/review_job.dart'; @@ -50,6 +51,8 @@ class RouterManager { // 作业 static const String jobReportPagePath = '/job/report/index'; + // 作业 ==> 横屏考试 + static const String jobExamPagePath = '/job/exam/index'; static const String reportClassTeacherPath = 'report/details/reportClassTeacher'; static const String reportSubjectTeacherPath = 'report/details/reportSubjectTeacher'; @@ -158,9 +161,10 @@ class RouterManager { Handler(handlerFunc: (BuildContext? context, Map> params) { try { int taskId = int.parse(params['taskId']![0]); + int jobId = int.parse(params['jobId']![0]); String taskName = params['taskName']![0]; String className = params['className']![0]; - return DoPapersHomework.DoPapersJob(taskId: taskId, taskName: taskName, className: className); + return DoPapersHomework.DoPapersJob(taskId: taskId, jobId: jobId, taskName: taskName, className: className); } catch (e) { toPrint(val: '进入跳转报错啦,$e'); } @@ -171,6 +175,16 @@ class RouterManager { String title = params['title']![0]; return JobReport(id: id, title: title); }); + + // 作业报告页面 + static final _jobExamPageHandler = Handler(handlerFunc: (BuildContext? context, Map> params) { + int taskId = int.parse(params['taskId']![0]); + int jobId = int.parse(params['JobId']![0]); + String taskName = params['taskName']![0]; + String className = params['className']![0]; + return DoPapersJobExam(taskId: taskId, jobId: jobId, taskName: taskName, className: className); + }); + static final _agreementPageHandler = Handler(handlerFunc: (BuildContext? context, Map> params) { AGREEMENT_KEY key = AGREEMENT_KEY.values.byName(params['type']![0]); return AgreementPage(type: key); @@ -258,6 +272,7 @@ class RouterManager { router.define(userMinePath, handler: _userMinePageHandler, transitionType: TransitionType.material); router.define(reportDetailPath, handler: _reportDetailPath, transitionType: TransitionType.material); router.define(jobReportPagePath, handler: _jobReportPageHandler, transitionType: TransitionType.material); + router.define(jobExamPagePath, handler: _jobExamPageHandler, transitionType: TransitionType.material); // getTransition() diff --git a/marking_app/lib/utils/request/rest_client.dart b/marking_app/lib/utils/request/rest_client.dart index a604f15..53ef6aa 100644 --- a/marking_app/lib/utils/request/rest_client.dart +++ b/marking_app/lib/utils/request/rest_client.dart @@ -245,6 +245,16 @@ abstract class RestClient { Future> getJobCollect( @the_retrofit.Query("taskId") int taskId, @the_retrofit.Query("studentId") int studentId); + // 作业 => 作业优先批阅取消 + @the_retrofit.POST("/api/read/cancel-job-read-level") + Future> jobPriorityReviewCancel( + @the_retrofit.Field("jobId") int jobId, @the_retrofit.Field("studentId") int studentId); + + // 作业 => 作业优先批阅加入 + @the_retrofit.POST("/api/read/join-read-level") + Future jobPriorityReviewJoin( + @the_retrofit.Field("jobId") int jobId, @the_retrofit.Field("studentId") int studentId); + // 作业 => 查询作业是否收藏 @the_retrofit.POST("${RequestConfig.hwProxyKeywords}/api/Dpc/collect") Future> toJobFavoriteCancel(@the_retrofit.Body() JobCollectParams params);