Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修復 成績查詢功能 #237

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions lib/src/connector/score_connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,25 @@ class ScoreConnector {
}

tagNode = parse(result);
final h3Nodes = tagNode.getElementsByTagName("h3");
final titleNodes = tagNode.querySelectorAll("input[type=submit]");

//依照學期取得課程資料
for (final h3Node in h3Nodes) {
final siblingOfH3 = h3Node.nextElementSibling;
if (siblingOfH3 == null || siblingOfH3.localName != "table") continue;
final tableNode = siblingOfH3;
for (final titleNode in titleNodes) {
final siblingOfTitle = titleNode.parent.localName == "form"
? titleNode.parent.nextElementSibling
: // 當成績單已發布 父元素為form 父元素的旁邊元素才是 分數table
titleNode.nextElementSibling; // 當成績單未發布 父元素為body 原元素旁邊元素就會是 分數table

if (siblingOfTitle == null || siblingOfTitle.localName != "table") continue;
final tableNode = siblingOfTitle;

SemesterCourseScoreJson courseScore = SemesterCourseScoreJson();

SemesterJson semester = SemesterJson();
semester.year = h3Node.text.split(" ")[0];
semester.semester = h3Node.text.split(" ")[3];

String semesterText = titleNode.attributes["value"];
semester.year = semesterText.split(" ")[0];
semester.semester = semesterText.split(" ")[3];
courseScore.semester = semester;
//取得課程名稱與分數
scoreNodes = tableNode.getElementsByTagName("tr");
Expand Down Expand Up @@ -209,6 +216,7 @@ class ScoreConnector {
}
}
}

return courseScoreList;
} catch (e, stack) {
Log.eWithStack(e.toString(), stack);
Expand Down
Loading