Marking.Client.Moblie/marking_app/lib/common/model/progress/progress_item.dart

57 lines
1.4 KiB
Dart

/*
* @Author: wangyang 1147192855@qq.com
* @Date: 2022-07-20 15:06:38
* @LastEditors: wangyang 1147192855@qq.com
* @LastEditTime: 2022-07-28 18:59:16
* @FilePath: \marking_app\lib\common\model\progress\progress_item.dart
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import 'package:json_annotation/json_annotation.dart';
part 'progress_item.g.dart';
@JsonSerializable()
class ProgressItem extends Object {
@JsonKey(name: 'teacherName')
String teacherName;
@JsonKey(name: 'avgScore')
double avgScore;
@JsonKey(name: 'schoolName')
String schoolName;
@JsonKey(name: 'totalCount')
int totalCount;
@JsonKey(name: 'finishCount')
int finishCount;
// 完成比例
@JsonKey(name: 'completionRate')
double completionRate;
@JsonKey(name: 'completionRateStr')
String completionRateStr;
ProgressItem(
this.teacherName,
this.finishCount,
this.totalCount,
this.avgScore,
this.schoolName, {
this.completionRate = 0,
this.completionRateStr = '0.0',
}) {
if (totalCount != 0) {
completionRate = finishCount / totalCount;
completionRateStr = (completionRate * 100).toStringAsFixed(2);
}
}
factory ProgressItem.fromJson(Map<String, dynamic> srcJson) =>
_$ProgressItemFromJson(srcJson);
Map<String, dynamic> toJson() => _$ProgressItemToJson(this);
}