Skip to content

Commit

Permalink
修正绩点计算方式
Browse files Browse the repository at this point in the history
  • Loading branch information
nano71 committed Feb 8, 2025
1 parent f4154cd commit c5fc186
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 101 deletions.
4 changes: 2 additions & 2 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sdk.dir=C:\\sdk\\android-sdk
flutter.sdk=C:\\sdk\\flutter
flutter.buildMode=release
flutter.versionName=1.6.241225
flutter.versionCode=75
flutter.versionName=1.6.250208
flutter.versionCode=76
2 changes: 1 addition & 1 deletion lib/common/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ Future getScore() async {
List scoreRows = [];
for (int i = 1; i < dataList.length; i++) {
List elementColumns = [];
for (int j in [0, 1, 3, 4, 5, 7, 6]) {
for (int j in [0, 1, 3, 4, 5, 7, 6, 11]) {
elementColumns.add(parseData(i, j));
}
scoreRows.add(elementColumns);
Expand Down
75 changes: 4 additions & 71 deletions lib/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,75 +150,8 @@ final List<List<int>> endTimeListRestore = const [
[21, 40]
];

final List<String> excludedCourses = [
"职业发展与就业指导(一)",
"职业发展与就业指导(二)",
"职业发展与就业指导(三)",
"职业发展与就业指导(四)",
"职业发展与就业指导(五)",
"就业指导与创业基础(一)",
"就业指导与创业基础(二)",
"就业指导与创业基础(三)",
"创业基础(一)",
"创业基础(二)",
"创业基础(三)",
"大学生心理健康(一)",
"大学生心理健康(二)",
"形势与政策(一)",
"形势与政策(二)",
"形势与政策(三)",
"形势与政策(四)",
"形势与政策(五)",
"形势与政策(六)",
"形势与政策(七)",
"形势与政策(八)",
"形势与政策",
"体育(一)",
"体育(二)",
"体育(三)",
"体育(四)",
"大学生安全教育(十)",
"大学生安全教育(一)",
"大学生安全教育(二)",
"大学生安全教育(三)",
"大学生安全教育(四)",
"大学生安全教育(五)",
"大学生安全教育(六)",
"大学生安全教育(七)",
"大学生安全教育(八)",
"大学生安全教育(九)",
"职业发展与就业指导(一)",
"职业发展与就业指导(二)",
"职业发展与就业指导(三)",
"职业发展与就业指导(四)",
"职业发展与就业指导(五)",
"就业指导与创业基础(一)",
"就业指导与创业基础(二)",
"就业指导与创业基础(三)",
"创业基础(一)",
"创业基础(二)",
"大学生心理学(一)",
"大学生心理学(二)",
"大学生心理健康教育(一)",
"大学生心理健康教育(二)",
"形势与政策(一)",
"形势与政策(二)",
"形势与政策(三)",
"形势与政策(四)",
"形势与政策(五)",
"形势与政策(六)",
"形势与政策",
"体育(一)",
"体育(二)",
"体育(三)",
"体育(四)",
"大学生安全教育(一)",
"大学生安全教育(二)",
"大学生安全教育(三)",
"大学生安全教育(四)",
"大学生安全教育(五)",
"大学生安全教育(六)",
];

final List<String> containCourseTypes = ["实践教学环节", "专业核心课", "专业基础课"];

final List colorList = const [
Colors.red,
Expand Down Expand Up @@ -297,6 +230,6 @@ bool isLoggedIn() {
return AppData.persistentData["username"] != "";
}

bool isExcludedCourse(String courseName) {
return excludedCourses.contains(courseName);
bool isContainCourse(String courseType) {
return containCourseTypes.contains(courseType);
}
43 changes: 17 additions & 26 deletions lib/pages/queryScore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ class _QueryBodyState extends State<QueryBody> {
process(List list) {
queryScore = list;
// 绩点
double gradePointAverage = 0.0;
double average = 0.0;
double weight = 0.0;
double gradePointSummary = 0.0;
double scoreSummary = 0.0;
//学分*成绩
double weightScoreSummary = 0.0;
double gradePointAverageSummary = 0.0;
double creditSummary = 0.0;

int excluded = 0;

for (int i = 0; i < list.length; i++) {
Expand All @@ -113,15 +109,17 @@ class _QueryBodyState extends State<QueryBody> {
double gradePoint = double.parse(list[i]![6]);
String courseName = list[i]![2].toString();
String teacher = list[i]![3];
String type = list[i]![7];

if ((courseName.contains("慕课") && teacher == "") || isExcludedCourse(courseName)) {
if ((courseName.contains("慕课") && teacher == "")) {
excluded++;
} else {
if (list[i].length > 5) {
print(list[i]);
weightScoreSummary += score * credit;
creditSummary += credit;
gradePointAverageSummary += gradePoint * credit;
if (isContainCourse(type)) {
gradePointSummary += gradePoint * credit;
creditSummary += credit;
}
}
if (list[i].length > 4) {
scoreSummary += score;
Expand All @@ -130,13 +128,14 @@ class _QueryBodyState extends State<QueryBody> {
}

print(scoreSummary);
average = double.parse((scoreSummary / (list.length - excluded)).toStringAsFixed(1));
weight = double.parse((weightScoreSummary / creditSummary).toStringAsFixed(1));
gradePointAverage = double.parse((gradePointAverageSummary / creditSummary).toStringAsFixed(1));
if (average.isNaN) average = 0.0;
if (weight.isNaN) weight = 0.0;
if (gradePointAverage.isNaN) gradePointAverage = 0.0;
scores = [gradePointAverage, average, weight];

double scoreAverage = double.parse((scoreSummary / (list.length - excluded)).toStringAsFixed(2));
double gradePointAverage = double.parse((gradePointSummary / creditSummary).toStringAsFixed(2));

if (gradePointAverage.isNaN) gradePointSummary = 0.0;
if (scoreAverage.isNaN) scoreSummary = 0.0;

scores = [gradePointAverage, scoreAverage];
ScaffoldMessenger.of(context).removeCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(jwSnackBar(1, "数据已更新!", 1));
setState(() {});
Expand Down Expand Up @@ -289,7 +288,7 @@ class _QueryBodyState extends State<QueryBody> {
height: 8,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"平均绩点: ${scores[0]}",
Expand All @@ -302,14 +301,6 @@ class _QueryBodyState extends State<QueryBody> {
Text(
"算术平均分: ${scores[1]}",
style: TextStyle(color: Colors.white),
),
Text(
"|",
style: TextStyle(color: readColor()),
),
Text(
"加权平均分: ${scores[2]}",
style: TextStyle(color: Colors.white),
)
],
)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "https://pub.flutter-io.cn" # Remove this line if you wish to publis
# 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.6.241225+75
version: 1.6.250208+76

environment:
sdk: ">=2.14.0 <4.0.0"
Expand Down

0 comments on commit c5fc186

Please sign in to comment.