Compare commits
No commits in common. "9517df9b0e880243459f2dd2414893f3f6e229a4" and "d62560184d4d3edf7542136446af6e82afa67773" have entirely different histories.
9517df9b0e
...
d62560184d
|
|
@ -1,5 +1,3 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart' hide Headers;
|
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_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_paper_details_result.dart';
|
||||||
|
|
@ -125,13 +123,4 @@ abstract class RetrofitClient {
|
||||||
// 批阅提交
|
// 批阅提交
|
||||||
@POST("/api/hms/Annotate/AnnotateSubmit")
|
@POST("/api/hms/Annotate/AnnotateSubmit")
|
||||||
Future reviewSubmission(@Body() ReviewSubmissionParams param);
|
Future reviewSubmission(@Body() ReviewSubmissionParams param);
|
||||||
|
|
||||||
// OSS 上传key
|
|
||||||
@GET("/api/infra/Oss/GetPresignedUri")
|
|
||||||
Future getOssPresignedUri(@Query('key') String key);
|
|
||||||
|
|
||||||
// OSS 图片上传
|
|
||||||
@PUT('{theUrl}')
|
|
||||||
@Headers(<String, dynamic>{'Content-Type': ''})
|
|
||||||
Future<void> uploadImag(@Path() String theUrl, @Part() File file);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
|
||||||
|
|
||||||
part 'do_paper_bus.g.dart';
|
|
||||||
|
|
||||||
// 批阅页面底部操作栏BUG
|
|
||||||
@JsonSerializable()
|
|
||||||
class BottomOperationBar extends Object {
|
|
||||||
@JsonKey(name: 'revoke_pre_step') // 撤销上一步
|
|
||||||
bool revokePreStep;
|
|
||||||
|
|
||||||
@JsonKey(name: 'revoke_all') // 撤销全部
|
|
||||||
bool revokeAll;
|
|
||||||
|
|
||||||
BottomOperationBar({
|
|
||||||
required this.revokePreStep,
|
|
||||||
required this.revokeAll,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory BottomOperationBar.fromJson(Map<String, dynamic> srcJson) => _$BottomOperationBarFromJson(srcJson);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => _$BottomOperationBarToJson(this);
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:get/get_connect/http/src/request/request.dart';
|
import 'package:get/get_connect/http/src/request/request.dart';
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
import 'package:making_school_asignment_app/common/config/request_config.dart';
|
|
||||||
|
|
||||||
part 'do_paper_details_result.g.dart';
|
part 'do_paper_details_result.g.dart';
|
||||||
|
|
||||||
|
|
@ -40,19 +39,12 @@ class DoPaperDetailsResult extends Object {
|
||||||
@JsonKey(name: 'zgtAnswer') // 主观题作答图片
|
@JsonKey(name: 'zgtAnswer') // 主观题作答图片
|
||||||
String zgtAnswer;
|
String zgtAnswer;
|
||||||
|
|
||||||
@JsonKey(name: 'showZgtAnnotate') // 主观题老师批注图片
|
@JsonKey(name: 'zgtAnnotate') // 主观题批注图片
|
||||||
String? showZgtAnnotate;
|
|
||||||
|
|
||||||
@JsonKey(name: 'zgtAnnotate') // 主观题老师批注图片
|
|
||||||
String? zgtAnnotate;
|
String? zgtAnnotate;
|
||||||
|
|
||||||
@JsonKey(name: 'lastAnswerTime') // 学生提交作答试题时间
|
@JsonKey(name: 'lastAnswerTime')
|
||||||
String lastAnswerTime;
|
String lastAnswerTime;
|
||||||
|
|
||||||
// 批注时间
|
|
||||||
@JsonKey(name: 'annotateTime')
|
|
||||||
String? annotateTime;
|
|
||||||
|
|
||||||
@JsonKey(name: 'isFav')
|
@JsonKey(name: 'isFav')
|
||||||
bool isFav;
|
bool isFav;
|
||||||
|
|
||||||
|
|
@ -86,8 +78,6 @@ class DoPaperDetailsResult extends Object {
|
||||||
this.templateIdKeys,
|
this.templateIdKeys,
|
||||||
this.templateIdKeyMap,
|
this.templateIdKeyMap,
|
||||||
this.priority,
|
this.priority,
|
||||||
this.annotateTime,
|
|
||||||
this.showZgtAnnotate,
|
|
||||||
) {
|
) {
|
||||||
if (templateIds.keys.isNotEmpty) {
|
if (templateIds.keys.isNotEmpty) {
|
||||||
templateIdKeys = templateIds.keys.map((e) => int.parse(e)).toList();
|
templateIdKeys = templateIds.keys.map((e) => int.parse(e)).toList();
|
||||||
|
|
@ -104,15 +94,6 @@ class DoPaperDetailsResult extends Object {
|
||||||
var currentStudent = students.firstWhereOrNull((e) => e.id == studentId);
|
var currentStudent = students.firstWhereOrNull((e) => e.id == studentId);
|
||||||
if (currentStudent != null) priority = currentStudent.isPriority;
|
if (currentStudent != null) priority = currentStudent.isPriority;
|
||||||
}
|
}
|
||||||
zgtAnswer = '${RequestConfig.imgUrl}$zgtAnswer?$lastAnswerTime';
|
|
||||||
|
|
||||||
if (zgtAnnotate?.isNotEmpty ?? false) {
|
|
||||||
showZgtAnnotate = RequestConfig.imgUrl + zgtAnnotate!; // 批注图片地址赋值
|
|
||||||
if (annotateTime != null) showZgtAnnotate = '${showZgtAnnotate!}?$annotateTime';
|
|
||||||
}
|
|
||||||
|
|
||||||
print('学生作答图片:${zgtAnswer}');
|
|
||||||
print('老师批注图片:${showZgtAnnotate}');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
factory DoPaperDetailsResult.fromJson(Map<String, dynamic> srcJson) => _$DoPaperDetailsResultFromJson(srcJson);
|
factory DoPaperDetailsResult.fromJson(Map<String, dynamic> srcJson) => _$DoPaperDetailsResultFromJson(srcJson);
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@ part 'do_test_questions_image_info.g.dart';
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class TestQuestionsImageInfo extends Object {
|
class TestQuestionsImageInfo extends Object {
|
||||||
@JsonKey(name: 'templateId')
|
|
||||||
int? templateId;
|
|
||||||
|
|
||||||
@JsonKey(name: 'boxHeight')
|
@JsonKey(name: 'boxHeight')
|
||||||
double boxHeight;
|
double boxHeight;
|
||||||
|
|
||||||
|
|
@ -31,12 +28,6 @@ class TestQuestionsImageInfo extends Object {
|
||||||
@JsonKey(name: 'remainingHeight') // 视图剩余高度 实际展示图片展示高度下 剩余高度.(若伟负数就是超出视图的高度值)
|
@JsonKey(name: 'remainingHeight') // 视图剩余高度 实际展示图片展示高度下 剩余高度.(若伟负数就是超出视图的高度值)
|
||||||
double remainingHeight;
|
double remainingHeight;
|
||||||
|
|
||||||
@JsonKey(name: 'imageHeightOffsetStart') // 顶部坐标Y
|
|
||||||
double imageHeightOffsetStart;
|
|
||||||
|
|
||||||
@JsonKey(name: 'imageHeightOffsetend') // 底部坐标Y
|
|
||||||
double imageHeightOffsetend;
|
|
||||||
|
|
||||||
// 基准
|
// 基准
|
||||||
@JsonKey(name: 'scaleRatio')
|
@JsonKey(name: 'scaleRatio')
|
||||||
double scaleRatio;
|
double scaleRatio;
|
||||||
|
|
@ -51,22 +42,17 @@ class TestQuestionsImageInfo extends Object {
|
||||||
required this.boxHeight,
|
required this.boxHeight,
|
||||||
required this.imageWidth,
|
required this.imageWidth,
|
||||||
required this.imageHeight,
|
required this.imageHeight,
|
||||||
this.templateId,
|
|
||||||
this.scaleRatio = 1,
|
this.scaleRatio = 1,
|
||||||
this.zoom = 1,
|
this.zoom = 1,
|
||||||
this.actualImgWidth = 0,
|
this.actualImgWidth = 0,
|
||||||
this.actualImgHeight = 0,
|
this.actualImgHeight = 0,
|
||||||
this.remainingHeight = 0,
|
this.remainingHeight = 0,
|
||||||
this.imageHeightOffsetStart = 0,
|
|
||||||
this.imageHeightOffsetend = 0,
|
|
||||||
}) {
|
}) {
|
||||||
// 图片已视图宽为基准,高度自适应可滑动 图片的实际宽高都需要乘此基准值
|
// 图片已视图宽为基准,高度自适应可滑动 图片的实际宽高都需要乘此基准值
|
||||||
scaleRatio = boxWidth / imageWidth;
|
scaleRatio = boxWidth / imageWidth;
|
||||||
actualImgWidth = imageWidth * scaleRatio;
|
actualImgWidth = imageWidth * scaleRatio;
|
||||||
actualImgHeight = imageHeight * scaleRatio;
|
actualImgHeight = imageHeight * scaleRatio;
|
||||||
remainingHeight = boxHeight - actualImgHeight;
|
remainingHeight = boxHeight - actualImgHeight;
|
||||||
imageHeightOffsetStart = remainingHeight / 2;
|
|
||||||
imageHeightOffsetend = imageHeightOffsetStart + actualImgHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
factory TestQuestionsImageInfo.fromJson(Map<String, dynamic> srcJson) => _$TestQuestionsImageInfoFromJson(srcJson);
|
factory TestQuestionsImageInfo.fromJson(Map<String, dynamic> srcJson) => _$TestQuestionsImageInfoFromJson(srcJson);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class ReviewSubmissionParams extends Object {
|
||||||
@JsonKey(name: 'studentScores')
|
@JsonKey(name: 'studentScores')
|
||||||
List<StudentScores> studentScores;
|
List<StudentScores> studentScores;
|
||||||
|
|
||||||
@JsonKey(name: 'zgtAnnotate')
|
@JsonKey(name: 'pictureBytes')
|
||||||
String? zgtAnnotate;
|
String? zgtAnnotate;
|
||||||
|
|
||||||
ReviewSubmissionParams({
|
ReviewSubmissionParams({
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
// event_bus 混入类
|
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:event_bus/event_bus.dart';
|
|
||||||
import 'package:making_school_asignment_app/common/utils/event_bus_utils.dart';
|
|
||||||
|
|
||||||
mixin EventBusMixin<T> {
|
|
||||||
StreamSubscription? _subscription;
|
|
||||||
static final EventBusUtils _exampleUtil = EventBusUtils();
|
|
||||||
static final EventBus _eBus = _exampleUtil.getEventBus();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 发起事件总线监听
|
|
||||||
* @param {Function} callback 回调函数
|
|
||||||
*/
|
|
||||||
/// 发起事件总线监听 @param {Function} callback 回调函数
|
|
||||||
StreamSubscription eventOn<T>({required void Function(T) callback}) {
|
|
||||||
_subscription = _eBus.on<T>().listen(callback);
|
|
||||||
return _subscription!;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 触发事件总线
|
|
||||||
void eventFire({required T model}) {
|
|
||||||
_exampleUtil.toFire<T>(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭监听总线事件
|
|
||||||
void eventCancel() {
|
|
||||||
_subscription?.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
import 'package:event_bus/event_bus.dart';
|
|
||||||
|
|
||||||
//订阅者回调签名
|
|
||||||
typedef EventCallback = void Function(dynamic arg);
|
|
||||||
|
|
||||||
///事件总线
|
|
||||||
class EventBusUtils {
|
|
||||||
late final EventBus _eventBus;
|
|
||||||
|
|
||||||
// 单例模式
|
|
||||||
static final EventBusUtils _instance = EventBusUtils._internal();
|
|
||||||
factory EventBusUtils() => _instance;
|
|
||||||
EventBusUtils._internal() {
|
|
||||||
_eventBus = EventBus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取实例
|
|
||||||
EventBus getEventBus() {
|
|
||||||
return _eventBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发起事件
|
|
||||||
void toFire<T>(T model) {
|
|
||||||
_eventBus.fire(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import '../mixins/request_tool_mixin.dart';
|
|
||||||
|
|
||||||
// OSS 图片上传
|
|
||||||
class UploadOssImgUtils with RequestToolMixin {
|
|
||||||
static UploadOssImgUtils? _singleton;
|
|
||||||
static UploadOssImgUtils getInstance() => _singleton ??= UploadOssImgUtils._internal();
|
|
||||||
|
|
||||||
UploadOssImgUtils._internal();
|
|
||||||
|
|
||||||
Future<void> getPresignedUri(String key) async {
|
|
||||||
var res = await getClient().getOssPresignedUri(key);
|
|
||||||
print(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
String setImgKey(String homeworkId, String studentId, String templateId) {
|
|
||||||
// $"hms-annotate/{input.HomeworkId}/{input.StudentId}/{input.TemplateId}.png"6月12日 13:54
|
|
||||||
return 'hms-annotate/$homeworkId/$studentId/$templateId.png';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,8 +2,6 @@ import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.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/utils.dart';
|
import 'package:making_school_asignment_app/common/utils/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';
|
||||||
|
|
@ -18,7 +16,7 @@ class BottomAnnotationSwitch extends StatefulWidget {
|
||||||
State<BottomAnnotationSwitch> createState() => _BottomAnnotationSwitchJobState();
|
State<BottomAnnotationSwitch> createState() => _BottomAnnotationSwitchJobState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with SingleTickerProviderStateMixin, EventBusMixin<BottomOperationBar> {
|
class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with SingleTickerProviderStateMixin {
|
||||||
late AnimationController _animationController; // 动画
|
late AnimationController _animationController; // 动画
|
||||||
final _homeworkLogic = Get.find<HomeworkReviewLogic>();
|
final _homeworkLogic = Get.find<HomeworkReviewLogic>();
|
||||||
final _logicControl = Get.find<HomeworkReviewLogic>().annotationState;
|
final _logicControl = Get.find<HomeworkReviewLogic>().annotationState;
|
||||||
|
|
@ -41,7 +39,6 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
|
||||||
_animationController.reverse();
|
_animationController.reverse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,8 +48,6 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
|
||||||
..removeListener(toUp)
|
..removeListener(toUp)
|
||||||
..dispose();
|
..dispose();
|
||||||
_opControllisten?.cancel();
|
_opControllisten?.cancel();
|
||||||
|
|
||||||
eventCancel();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,7 +132,7 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(width: double.infinity, color: Colors.white, height: 0.35.h),
|
Container(width: double.infinity, color: Colors.white, height: 0.5.h),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -147,26 +142,19 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () => easyThrottle(
|
onPressed: () => easyThrottle('homework_bottom_action_bar_annotations', () {}),
|
||||||
'homework_bottom_action_bar_annotations',
|
|
||||||
() => eventFire(model: BottomOperationBar(revokeAll: false, revokePreStep: true)),
|
|
||||||
),
|
|
||||||
icon: Icon(const IconData(0xe638, fontFamily: "AlibabaIcon"), size: iconSize, color: defaultColor),
|
icon: Icon(const IconData(0xe638, fontFamily: "AlibabaIcon"), size: iconSize, color: defaultColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(width: 0.3.w, height: double.infinity, color: Colors.white),
|
Container(width: 0.3.w, height: double.infinity, color: Colors.white),
|
||||||
// 全部撤销
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(const IconData(0xe637, fontFamily: "AlibabaIcon"), size: iconSize, color: defaultColor),
|
icon: Icon(const IconData(0xe637, fontFamily: "AlibabaIcon"), size: iconSize, color: defaultColor),
|
||||||
onPressed: () => easyThrottle(
|
onPressed: () => easyThrottle('homework_bottom_action_bar_annotations', () {}),
|
||||||
'homework_bottom_action_bar_annotations',
|
|
||||||
() => eventFire(model: BottomOperationBar(revokeAll: true, revokePreStep: false)),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,9 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
|
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:making_school_asignment_app/common/config/request_config.dart';
|
import 'package:making_school_asignment_app/common/config/request_config.dart';
|
||||||
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.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_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_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/do_test_questions_image_info.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/page/global_widget/my_text.dart';
|
import 'package:making_school_asignment_app/page/global_widget/my_text.dart';
|
||||||
|
|
@ -32,7 +30,6 @@ class QuestionPaperView extends StatefulWidget {
|
||||||
class _QuestionPaperViewState extends State<QuestionPaperView> {
|
class _QuestionPaperViewState extends State<QuestionPaperView> {
|
||||||
final logic = Get.find<HomeworkReviewLogic>();
|
final logic = Get.find<HomeworkReviewLogic>();
|
||||||
final sateData = Get.find<HomeworkReviewLogic>().state;
|
final sateData = Get.find<HomeworkReviewLogic>().state;
|
||||||
final annotationState = Get.find<HomeworkReviewLogic>().annotationState;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -47,7 +44,7 @@ class _QuestionPaperViewState extends State<QuestionPaperView> {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
// 主图
|
// 主图
|
||||||
QuestionImageView(maxWidth, maxHeight, sateData, annotationState, logic),
|
$QuestionImageView(maxWidth, maxHeight, sateData),
|
||||||
// 继续批阅按钮
|
// 继续批阅按钮
|
||||||
Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)),
|
Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)),
|
||||||
// 上一题按钮
|
// 上一题按钮
|
||||||
|
|
@ -57,6 +54,7 @@ class _QuestionPaperViewState extends State<QuestionPaperView> {
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
LastPage? lastPageVal = sateData.data.value?.lastPage;
|
LastPage? lastPageVal = sateData.data.value?.lastPage;
|
||||||
if (lastPageVal == null) return const SizedBox();
|
if (lastPageVal == null) return const SizedBox();
|
||||||
|
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
heroTag: '点击前往上一题',
|
heroTag: '点击前往上一题',
|
||||||
tooltip: '点击前往上一题',
|
tooltip: '点击前往上一题',
|
||||||
|
|
@ -80,6 +78,7 @@ class _QuestionPaperViewState extends State<QuestionPaperView> {
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
NextPage? nextPageVal = sateData.data.value?.nextPage;
|
NextPage? nextPageVal = sateData.data.value?.nextPage;
|
||||||
if (nextPageVal == null) return const SizedBox();
|
if (nextPageVal == null) return const SizedBox();
|
||||||
|
|
||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
heroTag: '点击前往下一题',
|
heroTag: '点击前往下一题',
|
||||||
tooltip: '点击前往下一题',
|
tooltip: '点击前往下一题',
|
||||||
|
|
@ -112,13 +111,9 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) {
|
||||||
final scrollControllerNum = useScrollController(); // 试题题号区域
|
final scrollControllerNum = useScrollController(); // 试题题号区域
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
scrollControllerNum.addListener(() {
|
StreamSubscription listenVal = sateData.slide.listen((e) => scrollControllerNum.jumpTo(e));
|
||||||
if (sateData.panQuestView == false) sateData.slide.value = scrollControllerNum.offset;
|
|
||||||
});
|
|
||||||
var listenVal = sateData.slide.listen((e) {
|
|
||||||
if (e != scrollControllerNum.offset && sateData.panQuestView == true) scrollControllerNum.jumpTo(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// 返回一个清理函数,在组件销毁时移除监听
|
||||||
return () {
|
return () {
|
||||||
listenVal.cancel();
|
listenVal.cancel();
|
||||||
};
|
};
|
||||||
|
|
@ -137,8 +132,6 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: GestureDetector(
|
|
||||||
onPanDown: (_) => sateData.panQuestView = false,
|
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: scrollControllerNum,
|
controller: scrollControllerNum,
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
|
|
@ -148,12 +141,8 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) {
|
||||||
var imageVal = sateData.imageScale.value;
|
var imageVal = sateData.imageScale.value;
|
||||||
if (imageVal == null) return const SizedBox();
|
if (imageVal == null) return const SizedBox();
|
||||||
var studentQuestions = sateData.studentQuestions.value;
|
var studentQuestions = sateData.studentQuestions.value;
|
||||||
|
print('书哈哈哈...');
|
||||||
var boxHeight = imageVal.boxHeight;
|
return Padding(
|
||||||
var actualImgHeight = imageVal.actualImgHeight; // 实际图片高度
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
height: boxHeight > actualImgHeight ? boxHeight : actualImgHeight,
|
|
||||||
padding: EdgeInsets.only(top: imageVal.remainingHeight > 0 ? imageVal.remainingHeight / 2 : 0),
|
padding: EdgeInsets.only(top: imageVal.remainingHeight > 0 ? imageVal.remainingHeight / 2 : 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|
@ -161,7 +150,7 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +177,9 @@ Widget $scoringQuestionsView(BuildContext context, StudentQuestions item, double
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: const FractionalOffset(0, 0),
|
alignment: const FractionalOffset(0, 0),
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Container(
|
||||||
|
color: Colors.yellow,
|
||||||
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// 对
|
// 对
|
||||||
|
|
@ -259,9 +250,8 @@ Widget $scoringQuestionsView(BuildContext context, StudentQuestions item, double
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
IgnorePointer(
|
),
|
||||||
// 事件穿透
|
Row(
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(width: 1.1.w),
|
SizedBox(width: 1.1.w),
|
||||||
|
|
@ -280,53 +270,20 @@ Widget $scoringQuestionsView(BuildContext context, StudentQuestions item, double
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 试题图片视图
|
// 试题图片视图
|
||||||
class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar> {
|
@hwidget
|
||||||
final double maxWidth;
|
Widget $questionImageView(double maxWidth, double maxHeight, HomeworkReviewState sateData) {
|
||||||
final double maxHeight;
|
|
||||||
final HomeworkReviewLogic logic;
|
|
||||||
final HomeworkReviewState sateData;
|
|
||||||
final HomeworkReviewAnnotationsControlState annotationState;
|
|
||||||
QuestionImageView(this.maxWidth, this.maxHeight, this.sateData, this.annotationState, this.logic, {super.key});
|
|
||||||
|
|
||||||
/// 获取数组指定倒数具体值的下标
|
|
||||||
int _findTargetIndex<T>(List<T> list, T target, [int reciprocal = 2]) {
|
|
||||||
List<int> 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
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final scrollControllerQuestion = useScrollController(); // 试题图片区域
|
final scrollControllerQuestion = useScrollController(); // 试题图片区域
|
||||||
var vnHandWritings = useValueNotifier<List<dynamic>>([]);
|
var vnHandWritings = useValueNotifier<List<dynamic>>([]);
|
||||||
|
|
||||||
useEffect(() {
|
|
||||||
var listenStream = sateData.data.listen((e) {
|
|
||||||
// 数据清空
|
|
||||||
sateData.handwritings = [];
|
|
||||||
vnHandWritings.value = sateData.handwritings;
|
|
||||||
});
|
|
||||||
return () => listenStream.cancel();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
ImageStream? imageStream;
|
ImageStream? imageStream;
|
||||||
var imageStreamListener = useState<ImageStreamListener>(ImageStreamListener((ImageInfo info, bool _) {
|
var imageStreamListener = useState<ImageStreamListener>(ImageStreamListener((ImageInfo info, bool _) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
sateData.imageScale.value = TestQuestionsImageInfo(
|
sateData.imageScale.value = TestQuestionsImageInfo(
|
||||||
templateId: sateData.data.value?.templateId,
|
|
||||||
boxWidth: maxWidth,
|
boxWidth: maxWidth,
|
||||||
boxHeight: maxHeight,
|
boxHeight: maxHeight,
|
||||||
imageWidth: info.image.width.toDouble(),
|
imageWidth: info.image.width.toDouble(),
|
||||||
|
|
@ -338,170 +295,67 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
|
||||||
|
|
||||||
// 可选:添加滚动监听
|
// 可选:添加滚动监听
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
eventOn(callback: (BottomOperationBar e) async {
|
|
||||||
var annotationsData = vnHandWritings.value; // 批注数据
|
|
||||||
if (e.revokeAll) {
|
|
||||||
// 情况全部
|
|
||||||
if (annotationsData.isNotEmpty) {
|
|
||||||
bool? res = await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (context1) {
|
|
||||||
return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: <Widget>[
|
|
||||||
TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)),
|
|
||||||
TextButton(child: quickText("确定", color: Theme.of(context).primaryColor), onPressed: () => Navigator.pop(context1, true))
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (res == true) vnHandWritings.value = [];
|
|
||||||
} else {
|
|
||||||
// 数据已经是空了 检查是否有上次批注图片 如果有就弹框询问清除
|
|
||||||
if (sateData.data.value?.showZgtAnnotate != null) {
|
|
||||||
await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (context1) {
|
|
||||||
return AlertDialog(content: quickText("是否撤销上次批阅批注痕迹?"), actions: <Widget>[
|
|
||||||
TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)),
|
|
||||||
TextButton(
|
|
||||||
child: quickText("确定", color: Theme.of(context).primaryColor),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context1, true);
|
|
||||||
sateData.data.value?.zgtAnnotate = null;
|
|
||||||
sateData.data.value?.showZgtAnnotate = null;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回上一步
|
|
||||||
if (annotationsData.isEmpty) {
|
|
||||||
// 数据已经是空了 检查是否有上次批注图片 如果有就弹框询问清除
|
|
||||||
if (sateData.data.value?.showZgtAnnotate != null) {
|
|
||||||
await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (context1) {
|
|
||||||
return AlertDialog(content: quickText("是否撤销上次批阅批注痕迹?"), actions: <Widget>[
|
|
||||||
TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)),
|
|
||||||
TextButton(
|
|
||||||
child: quickText("确定", color: Theme.of(context).primaryColor),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context1, true);
|
|
||||||
sateData.data.value?.zgtAnnotate = null;
|
|
||||||
sateData.data.value?.showZgtAnnotate = null;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var index = _findTargetIndex(annotationsData, null);
|
|
||||||
if (index != -1) {
|
|
||||||
annotationsData = annotationsData.sublist(0, index + 1);
|
|
||||||
annotationsData = List.from(annotationsData);
|
|
||||||
} else {
|
|
||||||
annotationsData = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vnHandWritings.value = annotationsData;
|
|
||||||
});
|
|
||||||
|
|
||||||
scrollControllerQuestion.addListener(() {
|
scrollControllerQuestion.addListener(() {
|
||||||
|
// 执行滚动相关的逻辑,例如打印滚动位置
|
||||||
sateData.slide.value = scrollControllerQuestion.offset;
|
sateData.slide.value = scrollControllerQuestion.offset;
|
||||||
}); // 执行滚动相关的逻辑,例如打印滚动位置
|
|
||||||
|
|
||||||
var listenVal = sateData.slide.listen((e) {
|
|
||||||
if (e != scrollControllerQuestion.offset && sateData.panQuestView == false) scrollControllerQuestion.jumpTo(e);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 返回一个清理函数,在组件销毁时移除监听
|
// 返回一个清理函数,在组件销毁时移除监听
|
||||||
return () {
|
return () {
|
||||||
listenVal.cancel();
|
|
||||||
imageStream?.removeListener(imageStreamListener.value);
|
imageStream?.removeListener(imageStreamListener.value);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
print('这里是加载了..............');
|
||||||
return Container(
|
return Container(
|
||||||
height: maxHeight,
|
height: maxHeight,
|
||||||
// padding: EdgeInsets.only(bottom: 2.h, top: 2.h),
|
// padding: EdgeInsets.only(bottom: 2.h, top: 2.h),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Obx(() {
|
|
||||||
var imageUrl = sateData.data.value?.zgtAnswer;
|
|
||||||
var showZgtAnnotate = sateData.data.value?.showZgtAnnotate;
|
|
||||||
if (imageUrl == null) return const SizedBox();
|
|
||||||
|
|
||||||
return GestureDetector(
|
|
||||||
onPanDown: (_) => sateData.panQuestView = true,
|
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: scrollControllerQuestion,
|
controller: scrollControllerQuestion,
|
||||||
physics: !annotationState.pen.value ? const BouncingScrollPhysics() : const NeverScrollableScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
scrollDirection: Axis.vertical, // 设置垂直滚动
|
||||||
child: Container(
|
child: Obx(() {
|
||||||
decoration: BoxDecoration(
|
var imageUrl = sateData.data.value?.zgtAnswer;
|
||||||
boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), offset: Offset(-6.r, 1.r), blurRadius: 10.r, spreadRadius: 8.r)]),
|
if (imageUrl == null) return const SizedBox();
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.grey.withOpacity(0.2),
|
||||||
|
offset: Offset(-6.r, 1.r), //阴影x轴偏移量
|
||||||
|
blurRadius: 10.r, //阴影模糊程度
|
||||||
|
spreadRadius: 8.r //阴影扩散程度
|
||||||
|
)
|
||||||
|
]),
|
||||||
child: Listener(
|
child: Listener(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onPointerUp: (PointerUpEvent details) {
|
onPointerUp: (PointerUpEvent details) {},
|
||||||
// 处理单个触摸点抬起的逻辑
|
onPointerMove: (PointerMoveEvent details) {},
|
||||||
// activePointers--;
|
child: RepaintBoundary(
|
||||||
// globalPosition = null;
|
child: CustomPaint(
|
||||||
var imageScale = sateData.imageScale.value;
|
foregroundPainter: DrawingPainter(ctrl: vnHandWritings),
|
||||||
if (imageScale == null || !annotationState.pen.value) return;
|
child: RepaintBoundary(
|
||||||
vnHandWritings.value.add(null); // 增加空点以分隔不同的线段
|
child: $TheCachedNetworkImage(
|
||||||
sateData.handwritings = vnHandWritings.value; // 添加笔迹数据
|
|
||||||
},
|
|
||||||
onPointerMove: (PointerMoveEvent event) {
|
|
||||||
var imageScale = sateData.imageScale.value;
|
|
||||||
if (imageScale == null || !annotationState.pen.value) return;
|
|
||||||
Offset localPosition = event.localPosition;
|
|
||||||
var dy = localPosition.dy;
|
|
||||||
if (dy > imageScale.actualImgHeight || dy < 0) return; // 检查笔记是否超出图片范围
|
|
||||||
|
|
||||||
vnHandWritings.value = List.from(vnHandWritings.value)..add(localPosition);
|
|
||||||
sateData.handwritings = vnHandWritings.value;
|
|
||||||
},
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
$TheCachedNetworkImage(
|
|
||||||
imageUrl: imageUrl,
|
|
||||||
(context, imageProvider) {
|
(context, imageProvider) {
|
||||||
|
print('图片加载了..............');
|
||||||
Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth);
|
Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth);
|
||||||
imageStream?.removeListener(imageStreamListener.value);
|
imageStream?.removeListener(imageStreamListener.value);
|
||||||
imageStream = imageWidget.image.resolve(const ImageConfiguration())..addListener(imageStreamListener.value);
|
imageStream = imageWidget.image.resolve(const ImageConfiguration())..addListener(imageStreamListener.value);
|
||||||
|
|
||||||
return imageWidget;
|
return imageWidget;
|
||||||
},
|
},
|
||||||
|
imageUrl: RequestConfig.imgUrl + imageUrl,
|
||||||
),
|
),
|
||||||
RepaintBoundary(
|
|
||||||
key: logic.pictureOverviewKey,
|
|
||||||
child: CustomPaint(
|
|
||||||
foregroundPainter: DrawingPainter(ctrl: vnHandWritings),
|
|
||||||
size: Size(
|
|
||||||
sateData.imageScale.value?.actualImgWidth ?? 0,
|
|
||||||
sateData.imageScale.value?.actualImgHeight ?? 0,
|
|
||||||
),
|
|
||||||
child: showZgtAnnotate != null
|
|
||||||
? $TheCachedNetworkImage(
|
|
||||||
imageUrl: showZgtAnnotate,
|
|
||||||
(_, imageProvider) => Image(image: imageProvider, fit: BoxFit.fitWidth),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 批注框
|
// 批注框
|
||||||
class DrawingPainter extends CustomPainter {
|
class DrawingPainter extends CustomPainter {
|
||||||
|
|
@ -509,23 +363,23 @@ class DrawingPainter extends CustomPainter {
|
||||||
final Paint paintBrush = Paint()
|
final Paint paintBrush = Paint()
|
||||||
..color = Colors.red
|
..color = Colors.red
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..strokeWidth = 0.6.r;
|
..strokeWidth = 1.5.r;
|
||||||
DrawingPainter({required this.ctrl}) : super(repaint: ctrl);
|
DrawingPainter({required this.ctrl}) : super(repaint: ctrl);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
var points = ctrl.value;
|
var points = ctrl.value;
|
||||||
var pointsLength = points.length;
|
var pointsLength = points.length;
|
||||||
for (int i = 0; i < pointsLength; i++) {
|
// for (int i = 0; i < pointsLength; i++) {
|
||||||
Offset? offsetData = points[i];
|
// GestureRecording item = points[i];
|
||||||
Offset? nextOffsetData = pointsLength - 1 == i ? null : points[i + 1];
|
// Offset? offsetData = item.data;
|
||||||
if (offsetData != null && nextOffsetData != null) canvas.drawLine(offsetData, nextOffsetData, paintBrush);
|
// Offset? nextOffsetData = pointsLength - 1 == i ? null : points[i + 1].data;
|
||||||
}
|
// if (offsetData != null && nextOffsetData != null) {
|
||||||
|
// canvas.drawLine(offsetData, nextOffsetData, paintBrush);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRebuildSemantics(CustomPainter oldDelegate) => false;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:get/get.dart';
|
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_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_paper_details_result.dart';
|
||||||
|
|
@ -14,7 +9,6 @@ import 'package:making_school_asignment_app/common/job/marking_models/do_test_qu
|
||||||
import 'package:making_school_asignment_app/common/job/marking_models/review_submission_params.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/mixins/request_tool_mixin.dart';
|
||||||
import 'package:making_school_asignment_app/common/utils/toast_utils.dart';
|
import 'package:making_school_asignment_app/common/utils/toast_utils.dart';
|
||||||
import 'package:making_school_asignment_app/common/utils/upload_oss_img_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';
|
||||||
|
|
||||||
// 数据
|
// 数据
|
||||||
|
|
@ -27,9 +21,7 @@ class HomeworkReviewState {
|
||||||
late Rx<DoPaperDetailsResult?> data;
|
late Rx<DoPaperDetailsResult?> data;
|
||||||
late Rx<List<StudentQuestions>?> studentQuestions;
|
late Rx<List<StudentQuestions>?> studentQuestions;
|
||||||
late Rx<double> slide; // 滑动位置
|
late Rx<double> slide; // 滑动位置
|
||||||
late bool? panQuestView;
|
|
||||||
late Rx<TestQuestionsImageInfo?> imageScale;
|
late Rx<TestQuestionsImageInfo?> imageScale;
|
||||||
List<dynamic> handwritings = [];
|
|
||||||
|
|
||||||
// late String dateEnd = '';
|
// late String dateEnd = '';
|
||||||
// late int knowledgeId = 0;
|
// late int knowledgeId = 0;
|
||||||
|
|
@ -55,7 +47,6 @@ class HomeworkReviewBinding extends Bindings {
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeworkReviewLogic extends GetxController with RequestToolMixin {
|
class HomeworkReviewLogic extends GetxController with RequestToolMixin {
|
||||||
final GlobalKey pictureOverviewKey = GlobalKey();
|
|
||||||
late StreamSubscription<DoPaperDetailsParam> _paramListen;
|
late StreamSubscription<DoPaperDetailsParam> _paramListen;
|
||||||
late StreamSubscription<DoPaperDetailsResult?> _dataListen;
|
late StreamSubscription<DoPaperDetailsResult?> _dataListen;
|
||||||
final HomeworkReviewState state = HomeworkReviewState();
|
final HomeworkReviewState state = HomeworkReviewState();
|
||||||
|
|
@ -100,7 +91,6 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
|
||||||
// item.topHeight = itemPre.height;
|
// item.topHeight = itemPre.height;
|
||||||
// }
|
// }
|
||||||
state.data.value = data;
|
state.data.value = data;
|
||||||
state.handwritings = [];
|
|
||||||
state.studentQuestions.value = data.studentQuestions;
|
state.studentQuestions.value = data.studentQuestions;
|
||||||
} finally {
|
} finally {
|
||||||
if (timerControl.isActive) timerControl.cancel();
|
if (timerControl.isActive) timerControl.cancel();
|
||||||
|
|
@ -149,63 +139,11 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
|
||||||
await submit(context);
|
await submit(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传图片
|
|
||||||
Future<String?> saveImage(context) async {
|
|
||||||
if (state.handwritings.isEmpty) return null;
|
|
||||||
try {
|
|
||||||
var data = state.data.value;
|
|
||||||
var param = state.param.value;
|
|
||||||
if (data == null) return null;
|
|
||||||
|
|
||||||
// 获取OSS 图片url
|
|
||||||
String imgKey = UploadOssImgUtils.getInstance().setImgKey(param.homeworkId, data.studentId.toString(), data.templateId.toString());
|
|
||||||
var resUrl = await getClient().getOssPresignedUri(imgKey);
|
|
||||||
if (resUrl == null) return null;
|
|
||||||
|
|
||||||
// 没有图片就上传图片
|
|
||||||
RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?;
|
|
||||||
if (boundary == null) return null;
|
|
||||||
// double dpr = MediaQuery.of(context).devicePixelRatio;
|
|
||||||
|
|
||||||
double pixelRatio = MediaQuery.of(context).devicePixelRatio;
|
|
||||||
var imageScale = state.imageScale.value;
|
|
||||||
if (imageScale != null) {
|
|
||||||
// 还原图片原始比例
|
|
||||||
pixelRatio = imageScale.imageWidth / imageScale.boxWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
|
|
||||||
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
|
|
||||||
if (byteData == null) return null;
|
|
||||||
|
|
||||||
Dio dio = Dio();
|
|
||||||
dio.options.contentType = null;
|
|
||||||
List<int> bytes = byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);
|
|
||||||
await dio.put(
|
|
||||||
resUrl,
|
|
||||||
data: Stream.fromIterable(bytes.map((e) => [e])),
|
|
||||||
options: Options(contentType: null, headers: {Headers.contentLengthHeader: bytes.length}),
|
|
||||||
);
|
|
||||||
|
|
||||||
// var res = await getClient().uploadImag(resUrl, file);
|
|
||||||
|
|
||||||
return imgKey;
|
|
||||||
} catch (e) {
|
|
||||||
print('图片上传失败');
|
|
||||||
print(e.toString());
|
|
||||||
ToastUtils.getFluttertoast(msg: '图片上传失败', context: context);
|
|
||||||
} finally {
|
|
||||||
// ToastUtils.dismiss();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 提交打分
|
// 提交打分
|
||||||
/// allPairs
|
/// allPairs
|
||||||
Future<void> submit(BuildContext context) async {
|
Future<void> submit(BuildContext context) async {
|
||||||
var data = state.data.value;
|
var data = state.data.value;
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
if (state.data.value?.studentQuestions.isEmpty ?? true) return;
|
if (state.data.value?.studentQuestions.isEmpty ?? true) return;
|
||||||
var studentQuestions = state.data.value!.studentQuestions;
|
var studentQuestions = state.data.value!.studentQuestions;
|
||||||
var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null);
|
var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null);
|
||||||
|
|
@ -213,19 +151,12 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
|
||||||
ToastUtils.showInfo('${noRatingElement.questionNo}题请评分');
|
ToastUtils.showInfo('${noRatingElement.questionNo}题请评分');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图片上传
|
|
||||||
String? zgtAnnotate = state.data.value?.zgtAnnotate;
|
|
||||||
String? newzgtAnnotate = await saveImage(context);
|
|
||||||
if (newzgtAnnotate != null) zgtAnnotate = newzgtAnnotate;
|
|
||||||
|
|
||||||
// TODO 请求提交加载框是否需要 如何防止重复提交
|
// TODO 请求提交加载框是否需要 如何防止重复提交
|
||||||
await getClient()
|
await getClient()
|
||||||
.reviewSubmission(ReviewSubmissionParams(
|
.reviewSubmission(ReviewSubmissionParams(
|
||||||
homeworkId: state.param.value.homeworkId,
|
homeworkId: state.param.value.homeworkId,
|
||||||
templateId: data.templateId,
|
templateId: data.templateId,
|
||||||
studentId: data.studentId,
|
studentId: data.studentId,
|
||||||
zgtAnnotate: zgtAnnotate,
|
|
||||||
studentScores: studentQuestions.map((e) {
|
studentScores: studentQuestions.map((e) {
|
||||||
var studentScore = e.studentScore!;
|
var studentScore = e.studentScore!;
|
||||||
return StudentScores(
|
return StudentScores(
|
||||||
|
|
@ -259,10 +190,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newParams = DoPaperDetailsParam.fromJson(state.param.value.toJson());
|
state.param.value = DoPaperDetailsParam.fromJson(state.param.value.toJson());
|
||||||
newParams.templateId = null;
|
|
||||||
newParams.studentId = null;
|
|
||||||
state.param.value = newParams;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class _HomeworkReviewState extends State<HomeworkReview> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
// SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown]);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,6 @@ dependencies:
|
||||||
easy_debounce: ^2.0.3 # 防抖节流
|
easy_debounce: ^2.0.3 # 防抖节流
|
||||||
flutter_hooks: ^0.20.5
|
flutter_hooks: ^0.20.5
|
||||||
flutter_spinkit: ^5.2.1
|
flutter_spinkit: ^5.2.1
|
||||||
event_bus: ^2.0.0
|
|
||||||
path_provider: ^2.1.3
|
|
||||||
uuid: ^3.0.7
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue