blob: fa3e6d1585d347dcaefe42d8d112ac81f4c6bba0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
var that = this;
var result = {
componentInit: function() {
if (!this.question) {
console.warn('Aborting because of no question received.');
return that.CoreQuestionHelperProvider.showComponentError(that.onAbort);
}
const div = document.createElement('div');
div.innerHTML = this.question.html;
// Get question questiontext.
const questiontext = div.querySelector('.qtext');
// Get question input.
const input = div.querySelector('input[type="text"][name*=answer]');
if (div.querySelector('.readonly') !== null) {
this.question.readonly = true;
}
if (div.querySelector('.feedback') !== null) {
this.question.feedback = div.querySelector('.feedback');
this.question.feedbackHTML = true;
}
this.question.text = questiontext.innerHTML;
this.question.input = input;
if (typeof this.question.text == 'undefined') {
this.logger.warn('Aborting because of an error parsing question.', this.question.name);
return this.CoreQuestionHelperProvider.showComponentError(this.onAbort);
}
// Check if question is marked as correct.
if (input.classList.contains('incorrect')) {
this.question.input.correctClass = 'qtype-algebra question-incorrect';
} else if (input.classList.contains('correct')) {
this.question.input.correctClass = 'qtype-algebra question-correct';
} else if (input.classList.contains('partiallycorrect')) {
this.question.input.correctClass = 'qtype-algebra question-partiallycorrect';
}
// @codingStandardsIgnoreStart
// Wait for the DOM to be rendered.
setTimeout(() => {
});
// @codingStandardsIgnoreEnd
return true;
}
};
result;
|