Skip to content
This repository was archived by the owner on Apr 25, 2022. It is now read-only.

Commit 2844675

Browse files
committed
修复163图片和判断题
1 parent 19cb4c2 commit 2844675

2 files changed

Lines changed: 43 additions & 6 deletions

File tree

src/mooc/course163/course163.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,22 @@ export class Course163 implements Mooc {
6868
script = "function a(){" + script + ";return s0;}a();";
6969
}
7070
let ret = eval(script);
71+
let u = document.URL.match(/(\?id|cid)=(.*?)($|&)/);
72+
if (u.length <= 0) {
73+
return;
74+
}
7175
let bank = new ToolsQuestionBank("mooc163", {
7276
refer: document.URL,
73-
id: document.URL.match(/(\?id|cid)=(.*?)($|&)/)[2],
77+
id: u[2],
7478
});
7579
let answer = new Array<Answer>();
7680
let options: Array<any>;
77-
if (document.URL.indexOf("quizscore?id=") > 0) {
81+
options = ret.objectiveQList;
82+
if (options == undefined) {
7883
options = ret;
79-
} else {
80-
options = ret.objectiveQList;
84+
}
85+
if (options == undefined) {
86+
return
8187
}
8288
for (let i = 0; i < options.length; i++) {
8389
let topic = options[i];
@@ -91,6 +97,20 @@ export class Course163 implements Mooc {
9197
option: "一", content: topic.stdAnswer,
9298
});
9399
answer.push(tmpAnswer);
100+
} else if (topic.type == 4) {
101+
let tmpAnswer = new PushAnswer();
102+
tmpAnswer.topic = topic.title;
103+
tmpAnswer.type = 3;
104+
tmpAnswer.correct = new Array<Option>();
105+
for (let n = 0; n < topic.optionDtos.length; n++) {
106+
if (topic.optionDtos[n].answer) {
107+
tmpAnswer.correct.push({
108+
option: "正确" == topic.optionDtos[n].content, content: "正确" == topic.optionDtos[n].content,
109+
});
110+
break;
111+
}
112+
}
113+
answer.push(tmpAnswer);
94114
}
95115
continue;
96116
}

src/mooc/course163/question.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export class CourseQueryAnswer implements QueryQuestions {
1414
}
1515

1616
protected createQuestion(el: HTMLElement) {
17-
if (el.querySelector("input[type='radio']") != null) {
17+
if (el.querySelector(".optionCnt span.u-icon-correct")) {
18+
return new JudgeQuestion(el, 3);
19+
} else if (el.querySelector("input[type='radio']") != null) {
1820
return new CourseQuestion(el, 1);
1921
} else if (el.querySelector("input[type='checkbox']") != null) {
2022
return new CourseQuestion(el, 2);
@@ -82,7 +84,7 @@ class CourseQuestion implements Question {
8284

8385
protected dealImgDomain(content: string): string {
8486
//移除域名对比,也不知道还有没有花里胡哨的
85-
return content.replace(/https:\/\/(.*?)\//, "");
87+
return content.replace(/"https:\/\/(.*?)\//, "\"");
8688
}
8789

8890
public Fill(answer: Answer): TopicStatus {
@@ -123,6 +125,21 @@ class FillQuestion extends CourseQuestion {
123125

124126
}
125127

128+
class JudgeQuestion extends CourseQuestion {
129+
130+
public Fill(answer: Answer): TopicStatus {
131+
let el: HTMLElement;
132+
if (answer.correct[0].content) {
133+
el = this.el.querySelector(".u-tbl.f-pr.f-cb .u-icon-correct").parentElement.parentElement;
134+
} else {
135+
el = this.el.querySelector(".u-tbl.f-pr.f-cb .u-icon-wrong").parentElement.parentElement;
136+
}
137+
this.fill(el, this.getContent(el))
138+
return "ok";
139+
}
140+
141+
}
142+
126143
export class CourseTopic extends Topic {
127144

128145
public Init(): Promise<any> {

0 commit comments

Comments
 (0)