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

feat:增加领航大学英语综合教程1和2的支持 #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/projects/welearn/exercise/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const DATA_SOLUTION = [
"New Advanced College English-Integrated Course 2", // 所以如果只是后端添加catalog,只有第一个页面有效
"New Advanced College English-Integrated Course 3",
"New Advanced College English-Integrated Course 4",
"Pioneer College English Integrated Course 1", // 领航大学英语综合教程1
"Pioneer College English Integrated Course 2", // 领航大学英语综合教程2
];

/**et类型(url中包含data)理论上可以直接在原始页面上找(Demcorazy就是这么做的),不过也可以统一通过ajax请求获取*/
Expand Down
19 changes: 16 additions & 3 deletions src/projects/welearn/exercise/dataSolution/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ function parseAnswer(element: HTMLElement) {
answerType = "blank";
} else {
//选择题
answerType = "choice";
try {
answerText = element.firstElementChild!.textContent;
if (!answerText) answerText = element.textContent;
let Nodechild = element.firstElementChild!;
let NodeSibling = element.nextElementSibling;
if (Nodechild) {
answerText = Nodechild.textContent;
} else if (NodeSibling) {
// 适配领航大学英语中部分填空题的答案位置(被相邻节点包含)
if (NodeSibling.hasChildNodes()) {
NodeSibling.childNodes.forEach(node => answerText += node.textContent?.trim() + " " || "")
} else {
answerText = NodeSibling.textContent?.trim() || answerText
}
answerType = "blank";
} else {
answerText = element.textContent;
}
} catch (error) {
answerText = element.textContent;
}
answerType = "choice";
}

return {
Expand Down