处理龙老师提出收藏和在作业已阅数量点击查看当前也喂提交学生名单

This commit is contained in:
1147192855@qq.com 2024-03-12 18:15:52 +08:00
parent 82befc0088
commit 9b96db5bca
3 changed files with 150 additions and 35 deletions

View File

@ -4,6 +4,9 @@ part 'job_collect_params.g.dart';
@JsonSerializable()
class JobCollectParams extends Object {
@JsonKey(name: 'paperId')
int paperId;
@JsonKey(name: 'taskId')
int taskId;
@ -14,6 +17,7 @@ class JobCollectParams extends Object {
bool isCollect;
JobCollectParams(
this.paperId,
this.taskId,
this.studentId,
this.isCollect,

View File

@ -19,12 +19,13 @@ class FavoriteWidget extends StatefulWidget {
class _FavoriteState extends State<FavoriteWidget> with EventBusMixin<JobQuestionsSwitch>, CommonMixin {
Future<JobCollectParams?>? _future; //
JobQuestionsSwitch? _eventModel;
@override
void initState() {
super.initState();
eventOn(callback: (JobQuestionsSwitch eventModel) {
_future = getData(eventModel.taskId, eventModel.studentId);
_eventModel = eventModel;
_future = getData(eventModel.taskId, eventModel.studentId, eventModel.paperId);
toUpState(setState, () {}, mounted);
});
}
@ -35,11 +36,11 @@ class _FavoriteState extends State<FavoriteWidget> with EventBusMixin<JobQuestio
eventCancel();
}
Future<JobCollectParams?> getData(int taskId, int studentId) async {
Future<JobCollectParams?> getData(int taskId, int studentId, int paperId) async {
try {
RestClient _client = await getClient();
BaseStructureResult<bool> res = await _client.getJobCollect(taskId, studentId);
if (res.success) return JobCollectParams(taskId, studentId, res.data ?? false);
if (res.success) return JobCollectParams(paperId, taskId, studentId, res.data ?? false);
} catch (e) {}
return null;
@ -47,12 +48,13 @@ class _FavoriteState extends State<FavoriteWidget> with EventBusMixin<JobQuestio
Future<void> toFavorite(JobCollectParams favoriteVal) async {
try {
if (_eventModel?.paperId == null) return;
ToastUtils.showLoading();
RestClient _client = await getClient();
favoriteVal.isCollect = !favoriteVal.isCollect;
BaseStructureResult<bool> res = await _client.toJobFavoriteCancel(favoriteVal);
if (res.success) {
_future = getData(favoriteVal.taskId, favoriteVal.studentId);
_future = getData(favoriteVal.taskId, favoriteVal.studentId, _eventModel!.paperId);
toUpState(setState, () {}, mounted);
} else {
ToastUtils.showError(res.message ?? '操作失败,请重试');
@ -97,6 +99,7 @@ class _FavoriteState extends State<FavoriteWidget> with EventBusMixin<JobQuestio
class JobQuestionsSwitch extends Object {
final int taskId;
final int studentId;
final int paperId;
JobQuestionsSwitch(this.taskId, this.studentId);
JobQuestionsSwitch(this.taskId, this.studentId, this.paperId);
}

View File

@ -11,6 +11,7 @@ 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/event_bus/jobs/job_do_papers_student_bus.dart';
import 'package:marking_app/common/model/job/job_concerned_with_student.dart';
import 'package:marking_app/common/model/job/job_concerned_with_student_params.dart';
import 'package:marking_app/common/model/job/job_do_marking_status_info.dart';
import 'package:marking_app/common/model/job/job_page_tab.dart';
import 'package:marking_app/common/model/job/job_review_submission.dart';
@ -93,7 +94,7 @@ class DoPapersJob extends HookWidget with EventBusMixin<DoPapersJobRefreshBus> {
exitCallback: () => Navigator.of(context).pop(refresh),
),
SizedBox(height: 1.h),
Expanded(child: ExamPaperAndScoringView(taskId: taskId)),
Expanded(child: ExamPaperAndScoringView(taskId: taskId, className: className)),
$BottomOperationBar()
],
),
@ -108,7 +109,17 @@ class DoPapersJob extends HookWidget with EventBusMixin<DoPapersJobRefreshBus> {
class ReviewStatusInfo extends HookWidget with CommonMixin {
final int taskId;
final int pageIndex;
const ReviewStatusInfo({required this.taskId, required this.pageIndex, super.key});
// final int schoolId;
// final int gradeId;
final String className;
const ReviewStatusInfo({
required this.taskId,
required this.pageIndex,
// required this.schoolId,
// required this.gradeId,
required this.className,
super.key,
});
Future<JobDoMarkingStatusInfo?> getData() async {
var _client = await getClient();
@ -116,6 +127,21 @@ class ReviewStatusInfo extends HookWidget with CommonMixin {
return result.data;
}
///
Future<List<JobConcernedWithStudent>?> getStudents() async {
try {
ToastUtils.showLoading();
var _client = await getClient();
var _result = await _client
.getJobWithStudents(JobConcernedWithStudentParams([taskId], isCommit: false, pageIndex: pageIndex));
if (_result.success) return _result.data;
} catch (e) {
ToastUtils.showError('获取数据失败,请重试');
} finally {
ToastUtils.dismiss();
}
}
@override
Widget build(BuildContext context) {
var doMarkingInfo = useState<JobDoMarkingStatusInfo?>(null);
@ -125,17 +151,77 @@ class ReviewStatusInfo extends HookWidget with CommonMixin {
}, []);
if (doMarkingInfo.value == null) return Container();
return Container(
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
quickText('已阅', color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp),
quickText(doMarkingInfo.value!.finishCount,
color: Color.fromRGBO(76, 199, 147, 1), size: 12.sp, fontWeight: FontWeight.bold),
quickText('/', color: Color.fromRGBO(117, 117, 117, 1), size: 12.sp),
quickText(doMarkingInfo.value!.surplusNo, color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp),
],
return InkWell(
onTap: () async {
print('点击了...');
List<JobConcernedWithStudent>? students = await getStudents();
if (students == null) return;
showModalBottomSheet(
context: context,
elevation: 10,
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.r),
topRight: Radius.circular(10.r),
),
),
builder: (BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 2.w),
child: Column(
children: [
Container(
margin: EdgeInsets.only(top: 14.h),
child: quickText(
'当前页未提交作业学生名单',
size: 15.sp,
fontWeight: FontWeight.bold,
color: Color.fromRGBO(60, 60, 60, 1),
),
),
SizedBox(height: 10.h),
Expanded(
child: ListView(
padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 4.w),
children: [
Wrap(
spacing: 6.0, // ()
runSpacing: 4.0, //
alignment: WrapAlignment.spaceAround, //沿
children: students.map((e) {
return Chip(
backgroundColor: Color.fromRGBO(239, 242, 255, 1),
avatar: CircleAvatar(
backgroundColor: Colors.white,
child: quickText(e.studentName.substring(0, 1),
size: 12.sp, color: Theme.of(context).primaryColor),
),
label: quickText(e.studentName, color: Color.fromRGBO(80, 94, 110, 1), size: 12.sp),
);
}).toList(),
),
],
),
)
],
),
);
},
);
},
child: Container(
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
quickText('已阅', color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp),
quickText(doMarkingInfo.value!.finishCount,
color: Color.fromRGBO(76, 199, 147, 1), size: 12.sp, fontWeight: FontWeight.bold),
quickText('/', color: Color.fromRGBO(117, 117, 117, 1), size: 12.sp),
quickText(doMarkingInfo.value!.surplusNo, color: Color.fromRGBO(117, 117, 117, 1), size: 10.sp),
],
),
),
);
}
@ -381,7 +467,8 @@ Widget $dropdownBoxSwitchStudentsOrTypeView(BuildContext context,
//
class ExamPaperAndScoringView extends StatefulHookConsumerWidget {
final int taskId;
const ExamPaperAndScoringView({required this.taskId, super.key});
final String className;
const ExamPaperAndScoringView({required this.taskId, required this.className, super.key});
@override
_EexamPaperAndScoringViewState createState() => _EexamPaperAndScoringViewState();
@ -444,7 +531,7 @@ class _EexamPaperAndScoringViewState extends ConsumerState<ExamPaperAndScoringVi
ref.read(jobHomeWorkProvider.notifier).setVal([]);
} catch (e) {}
eventFire(model: JobQuestionsSwitch(jobDetails.taskId, jobDetails.studentId));
eventFire(model: JobQuestionsSwitch(jobDetails.taskId, jobDetails.studentId, jobDetails.paperId));
eventFire(
model: JobDoPapersStudentBus(
jobDetails.studentId, jobDetails.studentName, jobDetails.pageIndex, jobDetails.isFirst));
@ -522,7 +609,7 @@ class _EexamPaperAndScoringViewState extends ConsumerState<ExamPaperAndScoringVi
if (jobData == null) return Container(); //
print('容器宽度:${containerWidth};容器高度:${containerHeight}');
// print('容器宽度:${containerWidth};容器高度:${containerHeight}');
return Stack(
children: [
JobPictureOverview(
@ -567,7 +654,13 @@ class _EexamPaperAndScoringViewState extends ConsumerState<ExamPaperAndScoringVi
),
///
ReviewStatusInfo(taskId: widget.taskId, pageIndex: jobData!.pageIndex)
ReviewStatusInfo(
taskId: widget.taskId,
pageIndex: jobData!.pageIndex,
className: widget.className,
// gradeId: null,
// schoolId: null,
)
],
),
),
@ -715,10 +808,15 @@ Widget $examPaperAndScoringKeyboardView(
Expanded(
child: $MaterialBtn(
bgc: Color.fromRGBO(237, 237, 237, 1),
onTap: () => _useDoScoring.goToScoringShortcut(
scoring: ScoringMethodEnum.CORRECT,
questionNo: question.questionNo,
),
onTap: () {
_useDoScoring.goToScoringShortcut(
scoring: ScoringMethodEnum.CORRECT,
questionNo: question.questionNo,
);
var noAnswerQuestion =
_useDoScoring.submittedData.value.questions.firstWhereOrNull((e) => e.score == null);
if (noAnswerQuestion == null) toSubmit();
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 12.r),
alignment: Alignment.center,
@ -736,10 +834,15 @@ Widget $examPaperAndScoringKeyboardView(
SizedBox(width: 0.2.w),
Expanded(
child: $MaterialBtn(
onTap: () => _useDoScoring.goToScoringShortcut(
scoring: ScoringMethodEnum.CORRECT_HALF,
questionNo: question.questionNo,
),
onTap: () {
_useDoScoring.goToScoringShortcut(
scoring: ScoringMethodEnum.CORRECT_HALF,
questionNo: question.questionNo,
);
var noAnswerQuestion =
_useDoScoring.submittedData.value.questions.firstWhereOrNull((e) => e.score == null);
if (noAnswerQuestion == null) toSubmit();
},
bgc: Color.fromRGBO(237, 237, 237, 1),
child: Container(
padding: EdgeInsets.symmetric(vertical: 12.r),
@ -758,10 +861,15 @@ Widget $examPaperAndScoringKeyboardView(
SizedBox(width: 0.2.w),
Expanded(
child: $MaterialBtn(
onTap: () => _useDoScoring.goToScoringShortcut(
scoring: ScoringMethodEnum.WRONG,
questionNo: question.questionNo,
),
onTap: () {
_useDoScoring.goToScoringShortcut(
scoring: ScoringMethodEnum.WRONG,
questionNo: question.questionNo,
);
var noAnswerQuestion =
_useDoScoring.submittedData.value.questions.firstWhereOrNull((e) => e.score == null);
if (noAnswerQuestion == null) toSubmit();
},
bgc: Color.fromRGBO(237, 237, 237, 1),
child: Container(
padding: EdgeInsets.symmetric(vertical: 12.r),