@@ -13,27 +13,27 @@ import {CreateNoteLine} from "./utils";
13
13
14
14
//TODO: 优化
15
15
export class CxQuestionFactory {
16
- public static CreateCourseQuestion ( el : HTMLElement ) : Question {
16
+ public static CreateCourseQuestion ( context : any , el : HTMLElement ) : Question {
17
17
let ret = SwitchTopicType ( substrex ( el . innerText , '【' , '】' ) ) ;
18
- return this . CreateCourseQuestionByTopicType ( ret , el ) ;
18
+ return this . CreateCourseQuestionByTopicType ( context , ret , el ) ;
19
19
}
20
20
21
- public static CreateExamQuestion ( type : TopicType , el : HTMLElement ) : Question {
21
+ public static CreateExamQuestion ( context : any , type : TopicType , el : HTMLElement ) : Question {
22
22
let processor = new ExamQuestionProcessor ( ) ;
23
23
let ret : Question = null ;
24
24
this . RemoveNotice ( el ) ;
25
25
switch ( type ) {
26
26
case 1 :
27
27
case 2 : {
28
- ret = new cxExamSelectQuestion ( el , type , processor ) ;
28
+ ret = new cxExamSelectQuestion ( context , el , type , processor ) ;
29
29
break ;
30
30
}
31
31
case 3 : {
32
- ret = new cxExamJudgeQuestion ( el , type , processor ) ;
32
+ ret = new cxExamJudgeQuestion ( context , el , type , processor ) ;
33
33
break ;
34
34
}
35
35
case 4 : {
36
- ret = new cxExamFillQuestion ( el , type , processor ) ;
36
+ ret = new cxExamFillQuestion ( context , el , type , processor ) ;
37
37
break ;
38
38
}
39
39
default : {
@@ -44,22 +44,22 @@ export class CxQuestionFactory {
44
44
return ret ;
45
45
}
46
46
47
- public static CreateCourseQuestionByTopicType ( type : TopicType , el : HTMLElement ) : Question {
47
+ public static CreateCourseQuestionByTopicType ( context : any , type : TopicType , el : HTMLElement ) : Question {
48
48
let ret : Question = null ;
49
49
let processor = new CourseQuestionProcessor ( ) ;
50
50
this . RemoveNotice ( el ) ;
51
51
switch ( type ) {
52
52
case 1 :
53
53
case 2 : {
54
- ret = new cxSelectQuestion ( el , type , processor ) ;
54
+ ret = new cxSelectQuestion ( context , el , type , processor ) ;
55
55
break ;
56
56
}
57
57
case 3 : {
58
- ret = new cxJudgeQuestion ( el , type , processor ) ;
58
+ ret = new cxJudgeQuestion ( context , el , type , processor ) ;
59
59
break ;
60
60
}
61
61
case 4 : {
62
- ret = new cxFillQuestion ( el , type , processor ) ;
62
+ ret = new cxFillQuestion ( context , el , type , processor ) ;
63
63
break ;
64
64
}
65
65
default : {
@@ -81,34 +81,34 @@ export class CxQuestionFactory {
81
81
return null ;
82
82
}
83
83
84
- public static CreateHomeWorkQuestion ( el : HTMLElement ) : Question {
84
+ public static CreateHomeWorkQuestion ( context : any , el : HTMLElement ) : Question {
85
85
let ret = CxQuestionFactory . getBeforeType ( el ) ;
86
- return this . CreateCourseQuestionByTopicType ( SwitchTopicType ( substrex ( ret . innerText , "." , "(" ) ) , el ) ;
86
+ return this . CreateCourseQuestionByTopicType ( context , SwitchTopicType ( substrex ( ret . innerText , "." , "(" ) ) , el ) ;
87
87
}
88
88
89
89
//TODO:写的什么玩意啊
90
- public static CreateExamCollectQuestion ( el : HTMLElement ) : Question {
90
+ public static CreateExamCollectQuestion ( context : any , el : HTMLElement ) : Question {
91
91
let ret = CxQuestionFactory . getBeforeType ( el . parentElement ) ;
92
92
let txt = ret . innerText . match ( / 、 ( .* ?) [ \s | ( ] / ) [ 1 ] ;
93
- return this . CreateExamQuestionByTopicType ( SwitchTopicType ( txt ) , el ) ;
93
+ return this . CreateExamQuestionByTopicType ( context , SwitchTopicType ( txt ) , el ) ;
94
94
}
95
95
96
- public static CreateExamQuestionByTopicType ( type : TopicType , el : HTMLElement ) : Question {
96
+ public static CreateExamQuestionByTopicType ( context : any , type : TopicType , el : HTMLElement ) : Question {
97
97
let ret : Question = null ;
98
98
let processor = new CourseQuestionProcessor ( ) ;
99
99
this . RemoveNotice ( el ) ;
100
100
switch ( type ) {
101
101
case 1 :
102
102
case 2 : {
103
- ret = new cxSelectQuestion ( el , type , processor ) ;
103
+ ret = new cxSelectQuestion ( context , el , type , processor ) ;
104
104
break ;
105
105
}
106
106
case 3 : {
107
- ret = new cxJudgeQuestion ( el , type , processor ) ;
107
+ ret = new cxJudgeQuestion ( context , el , type , processor ) ;
108
108
break ;
109
109
}
110
110
case 4 : {
111
- ret = new cxExamFillQuestion ( el , type , processor ) ;
111
+ ret = new cxExamFillQuestion ( context , el , type , processor ) ;
112
112
break ;
113
113
}
114
114
default : {
@@ -168,8 +168,10 @@ abstract class cxQuestion implements Question {
168
168
protected el : HTMLElement ;
169
169
protected type : TopicType ;
170
170
protected processor : QuestionProcessor ;
171
+ protected context : Window ;
171
172
172
- constructor ( el : HTMLElement , type : TopicType , processor : QuestionProcessor ) {
173
+ constructor ( context : Window , el : HTMLElement , type : TopicType , processor : QuestionProcessor ) {
174
+ this . context = context ;
173
175
this . el = el ;
174
176
this . type = type ;
175
177
this . processor = processor ;
@@ -400,12 +402,12 @@ class cxFillQuestion extends cxQuestion implements Question {
400
402
flag ++ ;
401
403
let el = < HTMLInputElement > options [ j ] . querySelector ( "input.inp" ) ;
402
404
if ( ! el ) {
403
- let uedit = ( < any > window ) . $ ( options [ j ] ) . find ( 'textarea' ) ;
405
+ let uedit = ( < any > this . context ) . $ ( options [ j ] ) . find ( 'textarea' ) ;
404
406
if ( uedit . length <= 0 ) {
405
407
this . AddNotice ( this . getOption ( options [ j ] ) + "空发生了一个错误" ) ;
406
408
continue ;
407
409
}
408
- ( < any > window ) . UE . getEditor ( uedit . attr ( 'name' ) ) . setContent ( answer . correct [ i ] . content ) ;
410
+ ( < any > this . context ) . UE . getEditor ( uedit . attr ( 'name' ) ) . setContent ( answer . correct [ i ] . content ) ;
409
411
this . AddNotice ( this . getOption ( options [ j ] ) + ":" + answer . correct [ i ] . content ) ;
410
412
} else {
411
413
el . value = removeHTMLTag ( answer . correct [ i ] . content ) ;
0 commit comments