From e1db8ae9b9c71fddcd37bb8fcbd355c518932876 Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Wed, 6 Mar 2024 18:15:43 +0800 Subject: [PATCH] no message --- .../lib/common/config/request_config.dart | 9 +- .../model/enum/job_marking_type_enum.dart | 10 + .../lib/common/model/job/job_task_item.dart | 49 +- .../homework_tasks_view_item.dart | 674 +----------------- .../lib/pages/homework_correction/index.dart | 6 +- .../pages/job_list_participate_in_class.dart | 447 ++++++++++++ marking_app/lib/routes/RouterManager.dart | 15 + .../lib/utils/request/rest_client.dart | 5 + marking_app/pubspec.yaml | 2 +- 9 files changed, 555 insertions(+), 662 deletions(-) create mode 100644 marking_app/lib/common/model/enum/job_marking_type_enum.dart create mode 100644 marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart diff --git a/marking_app/lib/common/config/request_config.dart b/marking_app/lib/common/config/request_config.dart index 2073b94..2825ae1 100644 --- a/marking_app/lib/common/config/request_config.dart +++ b/marking_app/lib/common/config/request_config.dart @@ -15,15 +15,16 @@ class RequestConfig { static const devLoginBaseUrl = "http://192.168.2.9:6400"; // 基本请求接口 static const devBaseUrlOfReport = "http://192.168.2.9:4000"; // 获取报告接口*/ - static const devBaseUrl = "https://mk-hw.23544.com"; // 基本请求 - static const devLoginBaseUrl = "https://mk-hw.23544.com"; // 登录接口 - static const devBaseUrlOfReport = "https://dc-api.23544.com"; // 获取报告接口 + static const devBaseUrl = "https://mhw.qwit.top"; // 基本请求 + static const devLoginBaseUrl = "https://mhw.qwit.top"; // 登录接口 + static const devBaseUrlOfReport = "https://mhw.qwit.top"; // 获取报告接口 + static const proBaseUrlOfHomework = "https://mhw.qwit.top/hw"; // 获取作业接口 /* 正式地址 */ static const proBaseUrl = "https://mk-hw.23544.com"; // 基本请求 static const proLoginBaseUrl = "https://mk-hw.23544.com"; // 登录接口 static const proBaseUrlOfReport = "https://dc-api.23544.com"; // 获取报告接口 - static const proBaseUrlOfHomework = "https://mk-hw.23544.com/hw"; // 获取作业接口 + // static const proBaseUrlOfHomework = "https://mk-hw.23544.com/hw"; // 获取作业接口 static const hwProxyKeywords = "/hw"; // 作业代理条件关键字 diff --git a/marking_app/lib/common/model/enum/job_marking_type_enum.dart b/marking_app/lib/common/model/enum/job_marking_type_enum.dart new file mode 100644 index 0000000..0fbc393 --- /dev/null +++ b/marking_app/lib/common/model/enum/job_marking_type_enum.dart @@ -0,0 +1,10 @@ +// 作业类型枚举 +enum JobMarkingTypeEnum { + UNUSED(name: '未使用废弃', indexValue: 0), + JOB(name: '作业', indexValue: 1), + EXAMINATION(name: '考试', indexValue: 2); + + const JobMarkingTypeEnum({required this.name, required this.indexValue}); + final String name; + final int indexValue; +} diff --git a/marking_app/lib/common/model/job/job_task_item.dart b/marking_app/lib/common/model/job/job_task_item.dart index 6d817c9..70ba21c 100644 --- a/marking_app/lib/common/model/job/job_task_item.dart +++ b/marking_app/lib/common/model/job/job_task_item.dart @@ -1,4 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:marking_app/common/model/enum/job_marking_type_enum.dart'; part 'job_task_item.g.dart'; @@ -40,8 +41,8 @@ class JobTaskItem extends Object { @JsonKey(name: 'precision') double precision; - @JsonKey(name: 'markingTasks') - List markingTasks; + // @JsonKey(name: 'markingTasks') + // List markingTasks; @JsonKey(name: 'createTime') String createTime; @@ -49,23 +50,30 @@ class JobTaskItem extends Object { @JsonKey(name: 'progressPercentage') double progressPercentage; // 进度百分比 + @JsonKey(name: 'markingType') + int markingType; // 考试类型 + + @JsonKey(name: 'markingTypeEnum') + JobMarkingTypeEnum markingTypeEnum; // 考试类型 + JobTaskItem( - this.id, - this.title, - this.subjectName, - this.genderName, - this.isFinish, - this.studentCount, - this.commitStudentCount, - this.totalCount, - this.finishCount, - this.objectivePrecision, - this.subjectivePrecision, - this.precision, - this.markingTasks, - this.createTime, { - this.progressPercentage = 0, - }) { + this.id, + this.title, + this.subjectName, + this.genderName, + this.isFinish, + this.studentCount, + this.commitStudentCount, + this.totalCount, + this.finishCount, + this.objectivePrecision, + this.subjectivePrecision, + this.precision, + // this.markingTasks, + this.createTime, + this.markingType, + {this.progressPercentage = 0, + this.markingTypeEnum = JobMarkingTypeEnum.UNUSED}) { try { progressPercentage = (finishCount / totalCount) * 100; if (progressPercentage.isNaN) { @@ -76,6 +84,11 @@ class JobTaskItem extends Object { } catch (e) { progressPercentage = 0; } + try { + markingTypeEnum = JobMarkingTypeEnum.values[this.markingType]; + } catch (e) { + markingTypeEnum = JobMarkingTypeEnum.UNUSED; + } } factory JobTaskItem.fromJson(Map srcJson) => _$JobTaskItemFromJson(srcJson); 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 7d2fc42..a72a37e 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 @@ -46,30 +46,29 @@ class HomeworkTasksViewItem extends StatelessWidget with CommonMixin { /// @param {bool} className 班级名称(不传此参数为主任务;传此参数为子任务) /// @param {bool} submitted 是否已提交(默认未提交) Future showStudents( - BuildContext context, - List taskIds, [ + BuildContext context, [ bool? submitted = false, String? className, ]) async { ToastUtils.showLoading(); List students = []; - try { - RestClient _client = await getClient(); - BaseStructureResult> _result = await _client.getJobWithStudents( - JobConcernedWithStudentParams(taskIds, isCommit: submitted), - ); - if (!_result.success) { - return ToastUtils.showError(_result.message ?? '获取学生列表失败'); - } - if (_result.data?.isEmpty ?? true) { - return ToastUtils.showError('获取到的学生列表为空'); - } - students = _result.data!; - } catch (e) { - return ToastUtils.showError('获取学生列表失败'); - } finally { - ToastUtils.dismiss(); - } + // try { + // RestClient _client = await getClient(); + // BaseStructureResult> _result = await _client.getJobWithStudents( + // JobConcernedWithStudentParams(taskIds, isCommit: submitted), + // ); + // if (!_result.success) { + // return ToastUtils.showError(_result.message ?? '获取学生列表失败'); + // } + // if (_result.data?.isEmpty ?? true) { + // return ToastUtils.showError('获取到的学生列表为空'); + // } + // students = _result.data!; + // } catch (e) { + // return ToastUtils.showError('获取学生列表失败'); + // } finally { + // ToastUtils.dismiss(); + // } showModalBottomSheet( context: context, @@ -125,28 +124,19 @@ class HomeworkTasksViewItem extends StatelessWidget with CommonMixin { ); } - void oneClickReview(int taskId) async { - try { - ToastUtils.showLoading(); - RestClient _client = await getClient(); - BaseStructureResult res = await _client.toJobOneClickReview(taskId); - if (res.success) return call(); - ToastUtils.showError(res.message ?? '操作失败'); - } catch (e) { - } finally { - ToastUtils.dismiss(); - } - } - @override Widget build(BuildContext context) { return completed ? $CompletedHomeworkView(jobTaskItem: jobTaskItem, showStudentsCall: showStudents) - : $UnfinishedHomework( - jobTaskItem: jobTaskItem, - refreshCallback: call, - endReviewCallback: endReview, - oneClickReviewCallback: oneClickReview, + : InkWell( + onTap: () { + String url = + '${RouterManager.jobListParticipateInClassPath}?&jobId=${jobTaskItem.id}&genderName=${Uri.encodeComponent(jobTaskItem.genderName)}&jobName=${Uri.encodeComponent(jobTaskItem.title)}'; + RouterManager.router.navigateTo(context, url, transition: getTransition()).then((value) { + if (value != null && value == true) call(); + }); + }, + child: $UnfinishedHomework(jobTaskItem: jobTaskItem), ); } } @@ -244,7 +234,6 @@ Widget $completedHomeworkView(BuildContext context, precision: jobTaskItem.precision / 100, objectivePrecision: jobTaskItem.objectivePrecision / 100, subjectivePrecision: jobTaskItem.subjectivePrecision / 100, - taskIds: jobTaskItem.markingTasks.map((e) => e.id).toList(), ), InkWell( onTap: () { @@ -277,55 +266,7 @@ Widget $completedHomeworkView(BuildContext context, Expanded(flex: 1, child: SizedBox()), ], ), - ), - SizedBox(height: 10.h), - ExpansionTile( - tilePadding: EdgeInsets.only(right: 10.w, bottom: 0), - title: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - // badges.Badge( - // position: badges.BadgePosition.topEnd(top: -3.r, end: -12.r), - // badgeStyle: BadgeStyle(badgeColor: Theme.of(context).primaryColor.withOpacity(0.7)), - // badgeContent: Text( - // jobTaskItem.markingTasks.length.toString(), - // style: TextStyle(color: Colors.white, fontSize: 10.sp), - // ), - // child: quickText('班级列表 ', size: 17.sp), - // ), - badges.Badge( - badgeStyle: badges.BadgeStyle( - shape: badges.BadgeShape.square, - borderRadius: BorderRadius.circular(5.r), - padding: EdgeInsets.all(2.r), - badgeGradient: badges.BadgeGradient.linear( - colors: [ - Colors.purple, - Colors.blue, - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - ), - position: badges.BadgePosition.topEnd(top: -2.r, end: -8.r), - badgeContent: Text( - jobTaskItem.markingTasks.length.toString(), - style: TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold), - ), - child: quickText('班级列表 ', size: 17.sp), - ), - ], - ), - childrenPadding: EdgeInsets.only(top: 0.h), - children: jobTaskItem.markingTasks.map((e) { - return $CompletedHomeworkChildView( - jobTaskItem: jobTaskItem, - taskItem: e, - showStudentsCall: showStudentsCall, - ); - }).toList(), - ), + ) ], ), ); @@ -364,7 +305,6 @@ Widget $completedHomeworkChildView( submittedQuantity: taskItem.commitStudentCount, unsubmittedQuantity: taskItem.studentCount - taskItem.commitStudentCount, showStudentsCall: showStudentsCall, - taskIds: [taskItem.id], className: taskItem.className, ), ], @@ -375,7 +315,6 @@ Widget $completedHomeworkChildView( @swidget Widget $completedHomeworkBtn( BuildContext context, { - required List taskIds, required int submittedQuantity, required int unsubmittedQuantity, required ShowStudentsCall showStudentsCall, @@ -391,7 +330,7 @@ Widget $completedHomeworkBtn( child: InkWell( onTap: () { if (unsubmittedQuantity <= 0) return ToastUtils.showInfo('没有未提交的作业'); - showStudentsCall(context, taskIds, false, className); + showStudentsCall(context, false, className); }, borderRadius: BorderRadius.circular(8.r), child: Container( @@ -413,7 +352,7 @@ Widget $completedHomeworkBtn( child: InkWell( onTap: () async { if (submittedQuantity <= 0) return ToastUtils.showInfo('没有已提交的作业'); - showStudentsCall(context, taskIds, true, className); + showStudentsCall(context, true, className); }, borderRadius: BorderRadius.circular(8.r), child: Container( @@ -511,7 +450,6 @@ Widget $completedHomeworkProgressBar( @swidget Widget $completedHomeworkInfoBox( BuildContext context, { - required List taskIds, required int unsubmittedQuantity, required int submittedQuantity, required double objectivePrecision, // 客观题正确率 @@ -524,7 +462,6 @@ Widget $completedHomeworkInfoBox( return Column( children: [ $CompletedHomeworkBtn( - taskIds: taskIds, className: className, unsubmittedQuantity: unsubmittedQuantity, submittedQuantity: submittedQuantity, @@ -557,13 +494,7 @@ Widget $completedHomeworkInfoBox( // 未完成作业单个view @swidget -Widget $unfinishedHomework( - BuildContext context, { - required JobTaskItem jobTaskItem, - required VoidCallback refreshCallback, - required EndReviewCall endReviewCallback, - required Function(int) oneClickReviewCallback, -}) { +Widget $unfinishedHomework(BuildContext context, {required JobTaskItem jobTaskItem}) { return Stack( alignment: const FractionalOffset(0.95, 0), children: [ @@ -599,7 +530,9 @@ Widget $unfinishedHomework( alignment: Alignment.center, padding: EdgeInsets.only(left: 2.w), decoration: BoxDecoration( - color: Color.fromRGBO(104, 136, 253, 1), + color: jobTaskItem.markingTypeEnum.name == '作业' + ? const Color.fromRGBO(104, 136, 253, 1) + : const Color.fromRGBO(255, 175, 56, 1), borderRadius: BorderRadius.only( topLeft: Radius.circular(18.r), topRight: Radius.circular(3.r), @@ -608,7 +541,7 @@ Widget $unfinishedHomework( ), ), margin: EdgeInsets.only(right: 4.w), - child: quickText('作业', color: Colors.white, size: 10.sp), + child: quickText(jobTaskItem.markingTypeEnum.name, color: Colors.white, size: 10.sp), ), quickText( jobTaskItem.title, @@ -653,50 +586,6 @@ Widget $unfinishedHomework( ), ], ), - // 未完成按钮 - $UnfinishedBtn( - isChild: false, - jobTaskItem: jobTaskItem, - endCallback: endReviewCallback, - refreshcall: refreshCallback, - ), - SizedBox(height: 20.h), - ExpansionTile( - tilePadding: EdgeInsets.only(right: 10.w), - title: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - badges.Badge( - badgeStyle: badges.BadgeStyle( - shape: badges.BadgeShape.square, - borderRadius: BorderRadius.circular(5.r), - padding: EdgeInsets.all(2.r), - badgeGradient: badges.BadgeGradient.linear( - colors: [Colors.purple, Colors.blue], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - ), - position: badges.BadgePosition.topEnd(top: -2.r, end: -8.r), - badgeContent: Text( - jobTaskItem.markingTasks.length.toString(), - style: TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold), - ), - child: quickText('班级列表 ', size: 17.sp), - ), - ], - ), - children: jobTaskItem.markingTasks.map((e) { - return $UnfinishedClassItem( - jobTaskItem: jobTaskItem, - jobTaskClassItem: e, - endReviewCallback: endReviewCallback, - refreshCallback: refreshCallback, - oneClickReviewCallback: oneClickReviewCallback, - ); - }).toList(), - ), ], ), ), @@ -752,500 +641,9 @@ Widget $unfinishedHomework( ); } -// 未完成作业按钮 (名称和数量) -@swidget -Widget $unfinishedBtn( - BuildContext context, { - required JobTaskItem jobTaskItem, - required VoidCallback refreshcall, - required EndReviewCall endCallback, - MarkingTasks? jobTaskClassItem, - bool isChild = true, -}) { - if (!isChild) { - MarkingTasks? theCanReviewChild = jobTaskItem.markingTasks.firstWhereOrNull((e) => e.canGoReview); - - List canEndTaskChilds = jobTaskItem.markingTasks.where((e) => !e.isFinish && e.canMarking).toList(); - return Container( - margin: EdgeInsets.only(top: 22.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Expanded( - flex: 2, - child: Material( - color: theCanReviewChild != null ? Colors.white : Colors.grey[300], - borderRadius: BorderRadius.circular(30.r), - child: InkWell( - onTap: () { - MarkingTasks? markingTask = - jobTaskItem.markingTasks.firstWhereOrNull((e) => e.canMarking && e.totalCount > 0 && !e.isFinish); - if (markingTask == null) { - ToastUtils.showInfo('没有找到可以批阅的任务'); - // AchievementView( - // elevation: 0.5, - // duration: Duration(seconds: 1), - // title: "提示", - // subTitle: "没有找到可以批阅的任务", - // color: Theme.of(context).primaryColor, - // ).show(context); - return; - } - String url = - '${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(); - }); - }, - borderRadius: BorderRadius.circular(30.r), - child: Container( - height: 36.h, - padding: EdgeInsets.symmetric(vertical: 3.h), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30.r), - border: Border.all(color: Theme.of(context).primaryColor), - ), - child: quickText('批阅', color: Theme.of(context).primaryColor, size: 14.sp), - ), - ), - ), - ), - Expanded( - flex: 1, - child: SizedBox(width: 5.w), - ), - Expanded( - flex: 2, - child: Material( - color: canEndTaskChilds.isNotEmpty ? Color.fromRGBO(104, 136, 253, 1) : Colors.grey, - borderRadius: BorderRadius.circular(30.r), - child: InkWell( - onTap: () async { - List childTasks = - jobTaskItem.markingTasks.where((e) => !e.isFinish && e.canMarking).toList(); - if (childTasks.isEmpty) return ToastUtils.showInfo('没有可以结束的任务'); - - // 未完成批阅任务提示 - List incompleteTasks = childTasks.where((e) => e.finishCount < e.totalCount).toList(); - if (incompleteTasks.isNotEmpty) { - var continueFlag = await showDialog( - context: context, - builder: (BuildContext context1) { - return AlertDialog( - title: Text('未完成批阅提示'), - content: Text('当前批阅任务未完成,请确认需要结束此任务?'), - actions: [ - TextButton( - child: Text('否'), - onPressed: () { - // 在这里处理删除操作 - Navigator.of(context1).pop(false); - }, - ), - TextButton( - child: Text('是'), - onPressed: () { - Navigator.of(context1).pop(true); - }, - ), - ], - ); - }, - ); - if (continueFlag == null || !continueFlag) { - return; - } - } - - showDialog( - context: context, - builder: (BuildContext context1) { - return AlertDialog( - title: Text('提示'), - content: Text('确认完成以下${childTasks.map((e) => e.className).toList().join(",")}的批阅任务?'), - actions: [ - TextButton( - child: Text('否'), - onPressed: () { - // 在这里处理删除操作 - Navigator.of(context1).pop(); - }, - ), - TextButton( - child: Text('确定'), - onPressed: () async { - try { - bool result = await endCallback(childTasks); - if (result) refreshcall(); - } catch (e) { - } finally { - ToastUtils.dismiss(); - Navigator.of(context1).pop(); - } - }, - ), - ], - ); - }, - ); - }, - borderRadius: BorderRadius.circular(30.r), - child: Container( - height: 36.h, - padding: EdgeInsets.symmetric(vertical: 3.5.h), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30.r), - ), - child: quickText('结束批阅', size: 14.sp, color: Colors.white), - ), - ), - ), - ), - ], - ), - ); - } - - if (!jobTaskClassItem!.canMarking) - return Container( - alignment: Alignment.centerRight, - child: jobTaskClassItem.isFinish - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - quickText(jobTaskClassItem.finishTime?.substring(0, 16), - size: 10.sp, color: Color.fromRGBO(170, 170, 170, 1)), - SizedBox(width: 4.w), - quickText('已批阅', size: 10.sp, color: Theme.of(context).primaryColor), - ], - ) - : quickText( - '待批阅', - size: 10.sp, - color: Color.fromRGBO(255, 138, 0, 1), - ), - ); - - return Container( - child: jobTaskClassItem.isFinish - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - quickText(jobTaskClassItem.finishTime?.substring(0, 16), - size: 12.sp, color: Color.fromRGBO(170, 170, 170, 1)), - SizedBox(width: 4.w), - quickText('已批阅', size: 13.sp, color: Theme.of(context).primaryColor), - ], - ) - : Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - flex: 5, - child: Material( - color: jobTaskClassItem.canGoReview ? Colors.white : Colors.grey[300], - borderRadius: BorderRadius.circular(4.r), - child: InkWell( - onTap: () { - if (jobTaskClassItem.totalCount <= 0) { - return ToastUtils.showInfo('没有找到可以批阅的任务'); - } - - if (!jobTaskClassItem.canMarking) { - return AchievementView( - elevation: 0.5, - duration: Duration(seconds: 1), - title: "提示", - subTitle: "此账号无法批阅该任务", - color: Theme.of(context).primaryColor, - ).show(context); - } - - if (jobTaskClassItem.isFinish) { - return AchievementView( - elevation: 0.5, - duration: Duration(seconds: 1), - title: "提示", - subTitle: "此批阅任务已完成", - color: Theme.of(context).primaryColor, - ).show(context); - } - - String url = - '${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(); - }); - }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 6.h), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4.r), - border: Border.all(color: Theme.of(context).primaryColor), - ), - child: quickText('批阅', color: Theme.of(context).primaryColor, size: 12.sp), - ), - ), - )), - Expanded(flex: 1, child: SizedBox()), - Expanded( - flex: 5, - child: Material( - color: !jobTaskClassItem.isFinish && jobTaskClassItem.canMarking - ? Color.fromRGBO(237, 240, 255, 1) - : Colors.grey, - borderRadius: BorderRadius.circular(4.r), - child: InkWell( - onTap: () async { - if (!jobTaskClassItem.canMarking) return ToastUtils.showInfo('此任务非该账号任务'); - if (jobTaskClassItem.isFinish) return ToastUtils.showInfo('此任务已经结束'); - - // 未完成批阅任务提示 - if (jobTaskClassItem.finishCount < jobTaskClassItem.totalCount) { - var continueFlag = await showDialog( - context: context, - builder: (BuildContext context1) { - return AlertDialog( - title: Text('未完成批阅提示'), - content: Text('当前批阅任务未完成,请确认需要结束此任务?'), - actions: [ - TextButton( - child: Text('否'), - onPressed: () { - // 在这里处理删除操作 - Navigator.of(context1).pop(false); - }, - ), - TextButton( - child: Text('是'), - onPressed: () { - Navigator.of(context1).pop(true); - }, - ), - ], - ); - }, - ); - if (continueFlag == null || !continueFlag) { - return; - } - } - - showDialog( - context: context, - builder: (BuildContext context1) { - return AlertDialog( - title: Text('提示'), - content: Text('确认完成当前${jobTaskClassItem.className}批阅任务?'), - actions: [ - TextButton( - child: Text('否'), - onPressed: () { - // 在这里处理删除操作 - Navigator.of(context1).pop(); - }, - ), - TextButton( - child: Text('确定'), - onPressed: () async { - try { - bool result = await endCallback([jobTaskClassItem]); - if (result) refreshcall(); - } catch (e) { - } finally { - ToastUtils.dismiss(); - Navigator.of(context1).pop(); - } - }, - ), - ], - ); - }, - ); - }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 6.h), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4.r), - border: Border.all(color: Color.fromRGBO(130, 156, 255, 1)), - ), - child: quickText('结束批阅', size: 12.sp, color: Color.fromRGBO(104, 136, 253, 1)), - ), - ), - )), - ], - ), - ); -} - -// 未完成作业单个班级view -@swidget -Widget $unfinishedClassItem( - BuildContext context, { - required JobTaskItem jobTaskItem, - required MarkingTasks jobTaskClassItem, - required VoidCallback refreshCallback, - required EndReviewCall endReviewCallback, - required Function(int) oneClickReviewCallback, -}) { - return Container( - padding: EdgeInsets.only(bottom: 14.w), - margin: EdgeInsets.only(bottom: 20.h), - decoration: BoxDecoration(border: Border(bottom: BorderSide(color: Color.fromRGBO(233, 233, 233, 1), width: 1.r))), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - child: quickText(jobTaskItem.genderName + jobTaskClassItem.className, - color: Color.fromRGBO(255, 123, 1, 1), size: 14.sp)), - if (!jobTaskClassItem.isFinish) - Expanded( - child: Container( - child: Row( - children: [ - Expanded( - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10.r), - boxShadow: [ - BoxShadow( - color: Color.fromRGBO(104, 136, 253, 1), - spreadRadius: 0.5, - blurRadius: 1, - offset: Offset(0, 0), - ), - ], - ), - child: LinearPercentIndicator( - padding: EdgeInsets.zero, - animation: true, - lineHeight: 10.h, - animationDuration: 2500, - percent: jobTaskClassItem.progressPercentage / 100, - center: Text( - '${getDoubleRemoveZero(jobTaskClassItem.progressPercentage)}%', - style: TextStyle(color: Colors.white, fontSize: 8.sp), - ), - linearGradient: LinearGradient( - tileMode: TileMode.mirror, - stops: [0.0, 1.0], - colors: [ - Theme.of(context).primaryColor.withOpacity(0.1), - Theme.of(context).primaryColor, - ], - ), - // linearStrokeCap: LinearStrokeCap.butt, - // progressColor: Theme.of(context).primaryColor, - backgroundColor: Colors.white, - barRadius: Radius.circular(10.r), - ), - ), - ), - SizedBox(width: 4.w), - quickText('${getDoubleRemoveZero(jobTaskClassItem.progressPercentage)}%', - size: 10.sp, color: Color.fromRGBO(104, 136, 253, 1)) - ], - ), - ), - ), - ], - ), - SizedBox(height: 14.h), - Container( - child: Row( - children: [ - Expanded( - child: Row(children: [ - quickText('题量:${jobTaskClassItem.totalCount}'), - SizedBox(width: 20.w), - quickText(jobTaskClassItem.teacherName) - ])), - Expanded( - child: $UnfinishedBtn( - jobTaskItem: jobTaskItem, - jobTaskClassItem: jobTaskClassItem, - endCallback: endReviewCallback, - refreshcall: refreshCallback, - ), - ), - ], - ), - ), - if (jobTaskClassItem.canGoReview) SizedBox(height: 6.h), - if (jobTaskClassItem.canGoReview) - Material( - borderRadius: BorderRadius.circular(30.r), - child: InkWell( - onTap: () => easyThrottle('OneClickReview', () async { - var continueFlag = await showDialog( - context: context, - builder: (BuildContext context1) { - return AlertDialog( - title: Text('一键批阅'), - content: Text('一键批阅后,默认学生答题结果全部正确,是否进行此操作?'), - actions: [ - TextButton( - child: Text('否'), - onPressed: () { - // 在这里处理删除操作 - Navigator.of(context1).pop(false); - }, - ), - TextButton( - child: Text('是'), - onPressed: () { - Navigator.of(context1).pop(true); - }, - ), - ], - ); - }, - ); - if (continueFlag == null || !continueFlag) return; - oneClickReviewCallback(jobTaskClassItem.id); - }), - borderRadius: BorderRadius.circular(30.r), - child: Container( - height: 20.h, - constraints: BoxConstraints(minWidth: 50.w, maxWidth: 60.w), - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(30.r), - border: Border.all(color: Color.fromRGBO(76, 199, 147, 1)), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - quickText('一键批阅', color: Color.fromRGBO(76, 199, 147, 1), size: 10.sp), - Padding( - padding: EdgeInsets.only(top: 1.1.h), - child: Icon(Icons.arrow_forward_ios, size: 8.sp, color: Color.fromRGBO(76, 199, 147, 1)), - ), - ], - ), - ), - ), - ), - ], - ), - ); -} - typedef EndReviewCall = Future Function(List markingTasks); typedef ShowStudentsCall = Future Function( - BuildContext context, - List taskIds, [ + BuildContext context, [ bool? submitted, String? className, ]); diff --git a/marking_app/lib/pages/homework_correction/index.dart b/marking_app/lib/pages/homework_correction/index.dart index adcdf12..84b6783 100644 --- a/marking_app/lib/pages/homework_correction/index.dart +++ b/marking_app/lib/pages/homework_correction/index.dart @@ -167,6 +167,7 @@ class _HomeworkCorrectionState extends ConsumerState margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top), padding: EdgeInsets.only(bottom: 9.h, top: 4.h), child: Row( + crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( flex: 1, @@ -254,7 +255,10 @@ class _HomeworkCorrectionState extends ConsumerState ), Expanded( flex: 1, - child: SizedBox(), + child: InkWell( + onTap: () {}, + child: Icon(Icons.settings_outlined, color: Color.fromRGBO(44, 48, 63, 1), size: 24.sp), + ), ), ], ), diff --git a/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart b/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart new file mode 100644 index 0000000..38a3970 --- /dev/null +++ b/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart @@ -0,0 +1,447 @@ +import 'package:achievement_view/achievement_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:marking_app/common/mixin/common.dart'; +import 'package:marking_app/common/model/common/base_structure_result.dart'; +import 'package:marking_app/common/model/job/job_task_item.dart'; +import 'package:marking_app/routes/RouterManager.dart'; +import 'package:marking_app/utils/index.dart'; +import 'package:marking_app/utils/my_future_builder.dart'; +import 'package:marking_app/utils/my_text.dart'; +import 'package:marking_app/utils/request/rest_client.dart'; +import 'package:percent_indicator/linear_percent_indicator.dart'; + +class JobListParticipateInClass extends StatefulWidget { + final int jobId; + final String jobName; + final String genderName; + const JobListParticipateInClass({required this.jobId, required this.jobName, required this.genderName, super.key}); + + @override + State createState() => _JobListParticipateInClassState(); +} + +class _JobListParticipateInClassState extends State with CommonMixin { + late Future?> _future; + + bool isRefresh = false; + + @override + void initState() { + // TODO: implement initState + super.initState(); + _future = getData(); + } + + @override + void dispose() { + // TODO: implement dispose + super.dispose(); + } + + Future?> getData() async { + RestClient _client = await getClient(); + BaseStructureResult> _result = await _client.getJobListParticipateInClass(widget.jobId); + return _result.data; + } + + // 结束批阅方法 + Future endReview(List markingTasks) async { + try { + ToastUtils.showLoading(); + RestClient client = await getClient(); + BaseStructureResult res = await client.toEndReviewJob(markingTasks.map((e) => e.id).toList()); + if (!res.success) ToastUtils.showError('结束失败,请重试'); + return res.success; + } catch (e) { + ToastUtils.showError('结束失败,请重试'); + return false; + } + } + + void oneClickReview(int taskId) async { + try { + ToastUtils.showLoading(); + RestClient _client = await getClient(); + BaseStructureResult res = await _client.toJobOneClickReview(taskId); + if (res.success) { + isRefresh = true; + _future = getData(); + toUpState(setState, () {}, mounted); + return; + } + ToastUtils.showError(res.message ?? '操作失败'); + } catch (e) { + } finally { + ToastUtils.dismiss(); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: const Color.fromRGBO(245, 245, 245, 1), + appBar: AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back_ios, color: Color.fromRGBO(51, 51, 51, 1)), + onPressed: () => Navigator.of(context).pop()), + title: Container( + child: + quickText(widget.jobName, size: 16.sp, color: Color.fromRGBO(51, 51, 51, 1), fontWeight: FontWeight.w500), + alignment: Alignment.center, + ), + backgroundColor: Colors.white, + ), + body: MyFutureBuilder.buildFutureBuilderOfSingleInstance?>(context, _future, (value) { + if (value == null) return Container(); + + return ListView( + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.w), + children: value.map((e) { + return Container( + padding: EdgeInsets.only(top: 11.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadiusDirectional.circular(10.r), + boxShadow: [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.15), + blurRadius: 10, + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: Row( + children: [ + quickText(widget.genderName + e.className, color: Color.fromRGBO(0, 0, 0, 1), size: 14.sp), + Expanded(child: SizedBox()), + quickText('已交:${e.commitStudentCount}', color: Color.fromRGBO(104, 136, 253, 1), size: 12.sp), + SizedBox(width: 16.w), + quickText('未交:${e.studentCount - e.commitStudentCount}', + color: Color.fromRGBO(255, 86, 86, 1), size: 12.sp), + ], + ), + ), + SizedBox(height: 13.h), + Padding( + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 3, + child: Material( + color: Color.fromRGBO(104, 136, 253, 1), + borderRadius: BorderRadius.circular(16.r), + child: InkWell( + onTap: () => easyThrottle('OneClickReview', () async { + var continueFlag = await showDialog( + context: context, + builder: (BuildContext context1) { + return Center( + child: Container( + padding: EdgeInsets.symmetric(vertical: 25.h, horizontal: 18.w), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadiusDirectional.circular(12.r)), + height: 150.h, + width: 280.w, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Expanded( + child: quickText('一键批阅后,默认学生答题结果全部正确,是否进行此操作?', + maxLines: 3, + size: 14.sp, + color: Color.fromRGBO(80, 94, 110, 1))) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + InkWell( + onTap: () { + Navigator.of(context1).pop(false); + }, + child: Container( + padding: EdgeInsetsDirectional.symmetric( + horizontal: 36.w, vertical: 7.h), + decoration: BoxDecoration( + color: Color.fromRGBO(244, 244, 244, 1), + borderRadius: BorderRadius.circular(20.r)), + child: quickText('取消', + size: 14.sp, color: Color.fromRGBO(102, 102, 102, 1)), + ), + ), + InkWell( + onTap: () { + Navigator.of(context1).pop(true); + }, + child: Container( + padding: EdgeInsetsDirectional.symmetric( + horizontal: 36.w, vertical: 7.h), + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: BorderRadius.circular(20.r)), + child: quickText('确认', + size: 14.sp, color: Color.fromRGBO(255, 255, 255, 1)), + ), + ), + ], + ) + ], + ), + )); + }, + ); + if (continueFlag == null || !continueFlag) return; + oneClickReview(e.id); + }), + borderRadius: BorderRadius.circular(8.r), + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 5.h), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20.r), + ), + child: quickText('一键批阅', size: 10.sp, color: Colors.white), + ), + ), + ), + ), + Expanded(flex: 1, child: SizedBox()), + Expanded( + flex: 3, + child: Material( + color: Color.fromRGBO(244, 244, 244, 1), + borderRadius: BorderRadius.circular(20.r), + child: InkWell( + onTap: () async {}, + borderRadius: BorderRadius.circular(8.r), + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 5.h), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)), + child: quickText('数据快查', size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)), + ), + ), + ), + ), + Expanded(flex: 1, child: SizedBox()), + Expanded( + flex: 3, + child: Material( + color: Color.fromRGBO(244, 244, 244, 1), + borderRadius: BorderRadius.circular(20.r), + child: InkWell( + onTap: () async {}, + borderRadius: BorderRadius.circular(8.r), + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 5.h), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)), + child: quickText('收藏夹(2)', size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)), + ), + ), + )), + ], + ), + ), + SizedBox(height: 13.h), + Padding( + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: Row( + children: [ + Expanded( + child: LinearPercentIndicator( + padding: EdgeInsets.zero, + animation: true, + lineHeight: 6.h, + animationDuration: 2500, + + percent: e.progressPercentage / 100, + // center: Text( + // '${getDoubleRemoveZero(jobTaskClassItem.progressPercentage)}%', + // style: TextStyle(color: Colors.white, fontSize: 8.sp), + // ), + linearGradient: LinearGradient( + tileMode: TileMode.mirror, + stops: [0.0, 1.0], + colors: e.progressPercentage / 100 != 1 + ? [Theme.of(context).primaryColor.withOpacity(0.1), Theme.of(context).primaryColor] + : [ + Color.fromRGBO(144, 224, 190, 1).withOpacity(0.1), + Color.fromRGBO(144, 224, 190, 1), + ], + ), + // linearStrokeCap: LinearStrokeCap.butt, + // progressColor: Theme.of(context).primaryColor, + backgroundColor: Color.fromRGBO(232, 232, 232, 1), + barRadius: Radius.circular(10.r), + ), + ), + SizedBox(width: 7.w), + quickText('${getDoubleRemoveZero(e.progressPercentage)}%', + size: 10.sp, color: Color.fromRGBO(70, 70, 70, 1)) + ], + ), + ), + SizedBox(height: 13.h), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(10.r), + bottomRight: Radius.circular(10.r), + ), + color: Colors.white, + boxShadow: [ + BoxShadow( + color: const Color.fromRGBO(0, 0, 0, 0.15), + offset: Offset(0, -0.0001), //阴影y轴偏移量 + blurRadius: 5, //阴影模糊程度 + spreadRadius: 0, //阴影扩散程度 + ) + ], + ), + child: Row( + children: [ + Expanded( + child: InkWell( + onTap: () { + if (e.totalCount <= 0) { + return ToastUtils.showInfo('没有找到可以批阅的任务'); + } + + if (!e.canMarking) { + return AchievementView( + elevation: 0.5, + duration: Duration(seconds: 1), + title: "提示", + subTitle: "此账号无法批阅该任务", + color: Theme.of(context).primaryColor, + ).show(context); + } + + if (e.isFinish) { + return AchievementView( + elevation: 0.5, + duration: Duration(seconds: 1), + title: "提示", + subTitle: "此批阅任务已完成", + color: Theme.of(context).primaryColor, + ).show(context); + } + + String url = + '${RouterManager.markingHomeworkDoPath}?taskId=${e.id}&jobId=${widget.jobId}&taskName=${Uri.encodeComponent(widget.jobName)}&className=${Uri.encodeComponent(widget.genderName + e.className)}'; + RouterManager.router + .navigateTo(context, url, transition: getTransition()) + .then((value) { + if (value == true) { + isRefresh = true; + _future = getData(); + toUpState(setState, () {}, mounted); + } + }); + }, + child: Container( + alignment: Alignment.center, + child: quickText('批阅', color: Color.fromRGBO(79, 79, 79, 1), size: 13.sp), + ), + ), + ), + Container(width: 1.w, height: 32.h, color: Color.fromRGBO(221, 221, 221, 1)), + Expanded( + child: InkWell( + onTap: () async { + if (!e.canMarking) return ToastUtils.showInfo('此任务非该账号任务'); + if (e.isFinish) return ToastUtils.showInfo('此任务已经结束'); + + // 未完成批阅任务提示 + if (e.finishCount < e.totalCount) { + var continueFlag = await showDialog( + context: context, + builder: (BuildContext context1) { + return AlertDialog( + title: Text('未完成批阅提示'), + content: Text('当前批阅任务未完成,请确认需要结束此任务?'), + actions: [ + TextButton( + child: Text('否'), + onPressed: () { + // 在这里处理删除操作 + Navigator.of(context1).pop(false); + }, + ), + TextButton( + child: Text('是'), + onPressed: () { + Navigator.of(context1).pop(true); + }, + ), + ], + ); + }, + ); + if (continueFlag == null || !continueFlag) { + return; + } + } + + showDialog( + context: context, + builder: (BuildContext context1) { + return AlertDialog( + title: Text('提示'), + content: Text('确认完成当前${e.className}批阅任务?'), + actions: [ + TextButton( + child: Text('否'), + onPressed: () { + // 在这里处理删除操作 + Navigator.of(context1).pop(); + }, + ), + TextButton( + child: Text('确定'), + onPressed: () async { + try { + bool result = await endReview([e]); + if (result) { + isRefresh = true; + _future = getData(); + toUpState(setState, () {}, mounted); + } + } catch (e) { + } finally { + ToastUtils.dismiss(); + Navigator.of(context1).pop(); + } + }, + ), + ], + ); + }, + ); + }, + child: Container( + alignment: Alignment.center, + child: quickText('结束批阅', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp), + ), + )), + ], + ), + ), + ], + )); + }).toList(), + ); + }), + ); + } +} diff --git a/marking_app/lib/routes/RouterManager.dart b/marking_app/lib/routes/RouterManager.dart index 20a8f4c..fec4960 100644 --- a/marking_app/lib/routes/RouterManager.dart +++ b/marking_app/lib/routes/RouterManager.dart @@ -15,6 +15,7 @@ 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/pages/job_list_participate_in_class.dart'; import 'package:marking_app/pages/homework_correction/review_job.dart'; import 'package:marking_app/pages/login/index.dart'; @@ -53,6 +54,8 @@ class RouterManager { static const String jobReportPagePath = '/job/report/index'; // 作业 ==> 横屏考试 static const String jobExamPagePath = '/job/exam/index'; + // 作业 ==> 列表 ==> 参与班级 + static const String jobListParticipateInClassPath = '/job/list/participateInClass'; static const String reportClassTeacherPath = 'report/details/reportClassTeacher'; static const String reportSubjectTeacherPath = 'report/details/reportSubjectTeacher'; @@ -239,6 +242,16 @@ class RouterManager { }, ); + static final _jobListParticipateInClassHandler = Handler( + handlerFunc: (BuildContext? context, Map> params) { + int jobId = int.parse(params['jobId']![0]); + String jobName = params['jobName']![0]; + String genderName = params['genderName']![0]; + + return JobListParticipateInClass(jobId: jobId, jobName: jobName, genderName: genderName); + }, + ); + // 开始阅卷页面 // static final _doMarkingPapers = Handler(handlerFunc: (BuildContext? context, Map> params) => MarkingPapers()); @@ -273,6 +286,8 @@ class RouterManager { router.define(reportDetailPath, handler: _reportDetailPath, transitionType: TransitionType.material); router.define(jobReportPagePath, handler: _jobReportPageHandler, transitionType: TransitionType.material); router.define(jobExamPagePath, handler: _jobExamPageHandler, transitionType: TransitionType.material); + router.define(jobListParticipateInClassPath, + handler: _jobListParticipateInClassHandler, 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 53ef6aa..1ef80ca 100644 --- a/marking_app/lib/utils/request/rest_client.dart +++ b/marking_app/lib/utils/request/rest_client.dart @@ -285,4 +285,9 @@ abstract class RestClient { @the_retrofit.GET("/api/jobs/job-report-question-detail") Future>> getJobReportQuestionDetail( @the_retrofit.Query("jobid") int jobId, @the_retrofit.Query("questionid") int questionid); + + // 作业 => 列表 ==> 参与班级列表 + @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task/tasks") + Future>> getJobListParticipateInClass( + @the_retrofit.Query("markingId") int jobId); } diff --git a/marking_app/pubspec.yaml b/marking_app/pubspec.yaml index 57b548e..92c49cc 100644 --- a/marking_app/pubspec.yaml +++ b/marking_app/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.95 +version: 1.0.87 environment: sdk: ">=2.17.1 <3.0.0"