Wp-Pro-Quiz - Version 0.37

Version Description

  • New frontend init structure
  • Added gulp support
  • Fix #7 - compatibility with All In One WP Security (https://github.com/xeno010/Wp-Pro-Quiz/issues/7)
  • Fix #5 - order of questions changes (https://github.com/xeno010/Wp-Pro-Quiz/issues/5)
  • Merge pull request #6 - escape double quotes that breaks tag (https://github.com/xeno010/Wp-Pro-Quiz/pull/6)
  • Translation for polish have been added (Thanks Behrooz N.)
Download this release

Release Info

Developer xeno010
Plugin Icon 128x128 Wp-Pro-Quiz
Version 0.37
Comparing to
See all releases

Code changes from version 0.36 to 0.37

Files changed (80) hide show
  1. .gitignore +2 -1
  2. README.md +10 -14
  3. css/wpProQuiz_front.css +610 -525
  4. css/wpProQuiz_front.min.css +1 -1
  5. gulpfile.js +40 -0
  6. js/wpProQuiz_admin.js +3392 -3335
  7. js/wpProQuiz_admin.min.js +2 -83
  8. js/wpProQuiz_front.js +2219 -2003
  9. js/wpProQuiz_front.min.js +1 -48
  10. js/wpProQuiz_toplist.js +72 -67
  11. js/wpProQuiz_toplist.min.js +1 -2
  12. languages/wp-pro-quiz-ar.mo +0 -0
  13. languages/wp-pro-quiz-ar.po +4 -3
  14. languages/wp-pro-quiz-cs_CZ.mo +0 -0
  15. languages/wp-pro-quiz-cs_CZ.po +3 -3
  16. languages/wp-pro-quiz-da_DK.mo +0 -0
  17. languages/wp-pro-quiz-da_DK.po +4 -3
  18. languages/wp-pro-quiz-de_DE.mo +0 -0
  19. languages/wp-pro-quiz-de_DE.po +3 -3
  20. languages/wp-pro-quiz-el.mo +0 -0
  21. languages/wp-pro-quiz-el.po +3 -3
  22. languages/wp-pro-quiz-es_ES.mo +0 -0
  23. languages/wp-pro-quiz-es_ES.po +7 -5
  24. languages/wp-pro-quiz-fa_IR.mo +0 -0
  25. languages/wp-pro-quiz-fa_IR.po +4 -3
  26. languages/wp-pro-quiz-fi.mo +0 -0
  27. languages/wp-pro-quiz-fi.po +4 -3
  28. languages/wp-pro-quiz-fr_FR.mo +0 -0
  29. languages/wp-pro-quiz-fr_FR.po +4 -3
  30. languages/wp-pro-quiz-hu_HU.mo +0 -0
  31. languages/wp-pro-quiz-hu_HU.po +4 -3
  32. languages/wp-pro-quiz-id_ID.mo +0 -0
  33. languages/wp-pro-quiz-id_ID.po +4 -3
  34. languages/wp-pro-quiz-it_IT.mo +0 -0
  35. languages/wp-pro-quiz-it_IT.po +4 -3
  36. languages/wp-pro-quiz-ko_KR.mo +0 -0
  37. languages/wp-pro-quiz-ko_KR.po +4 -3
  38. languages/wp-pro-quiz-nb_NO.mo +0 -0
  39. languages/wp-pro-quiz-nb_NO.po +4 -3
  40. languages/wp-pro-quiz-nl_NL.mo +0 -0
  41. languages/wp-pro-quiz-nl_NL.po +7 -5
  42. languages/wp-pro-quiz-pl_PL.mo +0 -0
  43. languages/wp-pro-quiz-pl_PL.po +2977 -0
  44. languages/wp-pro-quiz-pt_BR.mo +0 -0
  45. languages/wp-pro-quiz-pt_BR.po +4 -3
  46. languages/wp-pro-quiz-ru_RU.mo +0 -0
  47. languages/wp-pro-quiz-ru_RU.po +4 -3
  48. languages/wp-pro-quiz-sk_SK.mo +0 -0
  49. languages/wp-pro-quiz-sk_SK.po +3 -3
  50. languages/wp-pro-quiz-sv_SE.mo +0 -0
  51. languages/wp-pro-quiz-sv_SE.po +4 -3
  52. languages/wp-pro-quiz-tr_TR.mo +0 -0
  53. languages/wp-pro-quiz-tr_TR.po +7 -5
  54. languages/wp-pro-quiz-zh_TW.mo +0 -0
  55. languages/wp-pro-quiz-zh_TW.po +5 -3
  56. languages/wp-pro-quiz.pot +5 -3
  57. lib/controller/WpProQuiz_Controller_Admin.php +202 -275
  58. lib/controller/WpProQuiz_Controller_Ajax.php +86 -73
  59. lib/controller/WpProQuiz_Controller_Category.php +52 -46
  60. lib/controller/WpProQuiz_Controller_Controller.php +20 -17
  61. lib/controller/WpProQuiz_Controller_Front.php +257 -241
  62. lib/controller/WpProQuiz_Controller_GlobalSettings.php +65 -65
  63. lib/controller/WpProQuiz_Controller_ImportExport.php +104 -95
  64. lib/controller/WpProQuiz_Controller_InfoAdaptation.php +16 -12
  65. lib/controller/WpProQuiz_Controller_Preview.php +68 -63
  66. lib/controller/WpProQuiz_Controller_Question.php +585 -704
  67. lib/controller/WpProQuiz_Controller_Quiz.php +865 -979
  68. lib/controller/WpProQuiz_Controller_QuizCompleted.php +0 -231
  69. lib/controller/WpProQuiz_Controller_Request.php +42 -35
  70. lib/controller/WpProQuiz_Controller_Statistics.php +443 -794
  71. lib/controller/WpProQuiz_Controller_StyleManager.php +24 -20
  72. lib/controller/WpProQuiz_Controller_Template.php +33 -29
  73. lib/controller/WpProQuiz_Controller_Toplist.php +288 -282
  74. lib/controller/WpProQuiz_Controller_WpqSupport.php +16 -12
  75. lib/helper/WpProQuiz_Helper_Captcha.php +92 -75
  76. lib/helper/WpProQuiz_Helper_DbUpgrade.php +1136 -1098
  77. lib/helper/WpProQuiz_Helper_Export.php +63 -53
  78. lib/helper/WpProQuiz_Helper_ExportXml.php +340 -293
  79. lib/helper/WpProQuiz_Helper_Form.php +116 -102
  80. lib/helper/WpProQuiz_Helper_Import.php +0 -125
.gitignore CHANGED
@@ -1 +1,2 @@
1
- .idea
 
1
+ .idea
2
+ node_modules
README.md CHANGED
@@ -1,14 +1,8 @@
1
- Wp-Pro-Quiz
2
- ==============
3
 
4
  A powerful and beautiful quiz plugin for WordPress.
5
- --------------
6
 
7
- **Description**
8
-
9
- A powerful and beautiful quiz plugin for WordPress.
10
-
11
- **Functions**
12
  - Single Choice
13
  - Multiple Choice
14
  - "Sorting" Choice
@@ -42,7 +36,7 @@ A powerful and beautiful quiz plugin for WordPress.
42
  - Fully compatible with cache plugins (e.g. WP-Super-Cache or W3 Total Cache)
43
 
44
 
45
- **Translations**
46
  - Arabic / عربي (Thanks Abuhassan)
47
  - Brazilian Portuguese / Português do Brasil (Thanks Gabriel V.)
48
  - Chinese (Traditional) (Thanks Dinno Lin)
@@ -56,27 +50,29 @@ A powerful and beautiful quiz plugin for WordPress.
56
  - Greek / ελληνικά (Thanks Ζαχαρίας Σ.)
57
  - Hungarian / magyar (Thanks Webstar Csoport Kft.)
58
  - Indonesian / Bahasa Indonesia (Thanks dieka91 and Creative Computer Club)
59
- - Italian / Italiano (Thanks Pacaldi)
60
  - Korean / 한국어 (Thanks Kyeong Choi)
61
  - Norwegian / norsk (Thanks Stein Ivar J.)
62
  - Persian / فارسی (Thanks Behrooz N.)
 
63
  - Russian / русский (Thanks Sergei B. and Alex A.)
 
64
  - Spanish / español (Thanks Carlos R.)
65
  - Swedish / svenska (Thanks Martin J.)
66
  - Turkish / Türkçe (Thanks Nsaral)
67
 
68
- **Live Demo**
69
  http://www.it-gecko.de/wp-pro-quiz-quiz-plugin-fuer-wordpress.html (scroll to "Demo")
70
 
71
- **Special**
72
  - Support for "User Role Editor" etc.
73
  - Support for BuddyPress achievements 3.x.x
74
 
75
- **Support**
76
  - English: http://wordpress.org/support/plugin/wp-pro-quiz
77
  - German/Deutsch: http://www.it-gecko.de/kontakt
78
 
79
- **Installation**
80
 
81
  1. Upload the wp-pro-quiz folder to the /wp-content/plugins/ directory
82
  2. Activate the plugin through the 'Plugins' menu in WordPress
1
+ #Wp-Pro-Quiz
 
2
 
3
  A powerful and beautiful quiz plugin for WordPress.
 
4
 
5
+ ##Functions
 
 
 
 
6
  - Single Choice
7
  - Multiple Choice
8
  - "Sorting" Choice
36
  - Fully compatible with cache plugins (e.g. WP-Super-Cache or W3 Total Cache)
37
 
38
 
39
+ ##Translations
40
  - Arabic / عربي (Thanks Abuhassan)
41
  - Brazilian Portuguese / Português do Brasil (Thanks Gabriel V.)
42
  - Chinese (Traditional) (Thanks Dinno Lin)
50
  - Greek / ελληνικά (Thanks Ζαχαρίας Σ.)
51
  - Hungarian / magyar (Thanks Webstar Csoport Kft.)
52
  - Indonesian / Bahasa Indonesia (Thanks dieka91 and Creative Computer Club)
53
+ - Italian / Italiano (Thanks Pacaldi and Fabio)
54
  - Korean / 한국어 (Thanks Kyeong Choi)
55
  - Norwegian / norsk (Thanks Stein Ivar J.)
56
  - Persian / فارسی (Thanks Behrooz N.)
57
+ - Polish / polski (Thanks Piotr Sz. BaGGietka)
58
  - Russian / русский (Thanks Sergei B. and Alex A.)
59
+ - Slovak / slovenščina (Thanks Martin D.)
60
  - Spanish / español (Thanks Carlos R.)
61
  - Swedish / svenska (Thanks Martin J.)
62
  - Turkish / Türkçe (Thanks Nsaral)
63
 
64
+ ##Live Demo
65
  http://www.it-gecko.de/wp-pro-quiz-quiz-plugin-fuer-wordpress.html (scroll to "Demo")
66
 
67
+ ##Special
68
  - Support for "User Role Editor" etc.
69
  - Support for BuddyPress achievements 3.x.x
70
 
71
+ ##Support
72
  - English: http://wordpress.org/support/plugin/wp-pro-quiz
73
  - German/Deutsch: http://www.it-gecko.de/kontakt
74
 
75
+ ##Installation
76
 
77
  1. Upload the wp-pro-quiz folder to the /wp-content/plugins/ directory
78
  2. Activate the plugin through the 'Plugins' menu in WordPress
css/wpProQuiz_front.css CHANGED
@@ -1,526 +1,611 @@
1
- .wpProQuiz_answerCorrect {
2
- background: #6DB46D !important;
3
- font-weight: bold !important;
4
- }
5
- .wpProQuiz_answerCorrect label {
6
- font-weight: bold !important;
7
- }
8
-
9
- .wpProQuiz_answerIncorrect {
10
- background: #FF9191 !important;
11
- font-weight: bold !important;
12
- }
13
- .wpProQuiz_content {
14
- margin-top: 10px !important;
15
- margin-bottom: 10px !important;
16
- }
17
-
18
- .wpProQuiz_content h2 {
19
- margin-bottom: 10px !important;
20
- }
21
- *+html .wpProQuiz_button, *+html .wpProQuiz_button:hover {
22
- padding: 3px 0 !important;
23
- }
24
- .wpProQuiz_button, .wpProQuiz_button:hover {
25
- margin: 0 !important;
26
- padding: 5px 10px !important;
27
- background: #13455B !important;
28
- border-radius: 11px !important;
29
- color: white !important;
30
- font-weight: bold !important;
31
- border: 1px solid #13455B !important;
32
- box-shadow: 1px 1px 1px #333 !important;
33
- text-shadow: none !important;
34
- filter: none !important;
35
- float: none;
36
- }
37
-
38
- .wpProQuiz_question_page {
39
- margin-bottom: 10px !important;
40
- }
41
-
42
- .wpProQuiz_question_page span {
43
- font-weight: bold !important;
44
- }
45
-
46
- .wpProQuiz_questionListItem:last-child, .wpProQuiz_questionListItemLastChildIE {
47
- padding: 3px !important;
48
- margin-bottom: 0 !important;
49
- }
50
-
51
- .wpProQuiz_questionListItem {
52
- padding: 3px !important;
53
- margin-bottom: 5px !important;
54
- background-image: none !important;
55
- margin-left: 0 !important;
56
- list-style: none !important;
57
- border: 0 !important;
58
- }
59
-
60
- .wpProQuiz_questionListItem > table {
61
- border-collapse: collapse !important;
62
- margin: 0 !important;
63
- padding: 0 !important;
64
- width: 100%;
65
- border: none !important;
66
- text-align: left !important;
67
- }
68
- .wpProQuiz_questionListItem > table .alt {
69
- background: inherit !important;
70
- }
71
-
72
- .wpProQuiz_questionListItem > table td {
73
- text-align: left !important;
74
- }
75
-
76
- .wpProQuiz_list, .wpProQuiz_listItem, .wpProQuiz_questionList, .wpProQuiz_sortStringList, .wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion, .wpProQuiz_resultsList, .wpProQuiz_catOverview ol {
77
- list-style: none !important;
78
- padding: 0 !important;
79
- margin: 0 !important;
80
- }
81
- .wpProQuiz_list {
82
- border: 0 !important;
83
- }
84
- .wpProQuiz_questionList {
85
- margin-bottom: 10px !important;
86
- background: #F8FAF5 !important;
87
- border: 1px solid #C3D1A3 !important;
88
- padding: 5px !important;
89
- list-style: none !important;
90
- }
91
- .wpProQuiz_listItem {
92
- position: relative !important;
93
- border: 0 !important;
94
- background-image: none !important;
95
- }
96
- .wpProQuiz_response {
97
- background: #F8FAF5 !important;
98
- border: 1px solid #C4C4C4 !important;
99
- padding: 5px !important;
100
- margin-bottom: 15px !important;
101
- box-shadow: 1px 1px 2px #AAA !important;
102
- }
103
- .wpProQuiz_response span {
104
- font-weight: bold !important;
105
- }
106
- .wpProQuiz_sort {
107
- width: 25px !important;
108
- }
109
- .wpProQuiz_results h3 {
110
- margin-bottom: 10px !important;
111
- }
112
- .wpProQuiz_sort_correct_answer {
113
- font-weight: bold !important;
114
- margin-right: 5px !important;
115
- display: none !important;
116
- }
117
- .wpProQuiz_sortable, .wpProQuiz_sortStringItem {
118
- padding: 5px !important;
119
- border: 1px solid lightGrey !important;
120
- box-shadow: 2px 2px 1px #EEE;
121
- background-color: #F8FAF5 !important;
122
- cursor: move;
123
- }
124
- .wpProQuiz_time_limit .time {
125
- font-weight: bold !important;
126
- margin-top: 5px !important;
127
- margin-bottom: 5px !important;
128
- }
129
- .wpProQuiz_time_limit .wpProQuiz_progress {
130
- height: 10px !important;
131
- background-color: blue !important;
132
- margin-bottom: 5px !important;
133
- }
134
- .wpProQuiz_time_limit_expired {
135
- font-weight: bold !important;
136
- font-size: 15px !important;
137
- text-align: center !important;
138
- }
139
- .wpProQuiz_question_text {
140
- margin-bottom: 10px !important;
141
- }
142
- .wpProQuiz_tipp > div {
143
- padding: 10px !important;
144
- background-color: #DDECFF !important;
145
- border: 1px dotted #363636 !important;
146
- border-radius: 10px !important;
147
- position: absolute !important;
148
- bottom: 5px !important;
149
- left: 5px !important;
150
- right: 5px !important;
151
- box-shadow: 2px 2px 5px 0 #313131 !important;
152
- z-index: 99999 !important;
153
- }
154
- .wpProQuiz_matrixSortString, .wpProQuiz_matrixSortString > h3{
155
- margin-bottom: 10px !important;
156
- margin-top: 0 !important;
157
- }
158
- .wpProQuiz_matrixSortString {
159
- background: #F8FAF5 !important;
160
- border: 1px solid #C3D1A3 !important;
161
- padding: 5px !important;
162
- }
163
- .wpProQuiz_sortStringList {
164
- padding: 10px !important;
165
- border: 0 !important;
166
- }
167
- .wpProQuiz_sortStringList > li {
168
- float: left !important;
169
- margin-left: 5px !important;
170
- margin-right: 5px !important;
171
- margin-bottom: 5px !important;
172
- }
173
- .wpProQuiz_sortStringItem {
174
- margin: 0 !important;
175
- background-image: none !important;
176
- list-style: none !important;
177
- }
178
- .wpProQuiz_maxtrixSortCriterion {
179
- padding: 5px !important;
180
- }
181
- .wpProQuiz_placehold {
182
- background-color: #FFFFC2 !important;
183
- list-style: none !important;
184
- background-image: none !important;
185
- padding: 5px !important;
186
- height: 30px !important;
187
- min-width: 50px !important;
188
- margin: 0 !important;
189
- }
190
- .wpProQuiz_maxtrixSortText {
191
- padding: 5px !important;
192
- }
193
- .wpProQuiz_mextrixTr > td {
194
- border: 1px solid #D1D1D1 !important;
195
- padding: 5px !important;
196
- vertical-align: middle !important;
197
- }
198
- .wpProQuiz_points {
199
- font-weight: bold !important;
200
- text-align: center !important;
201
- margin-bottom: 20px !important;
202
- }
203
- .wpProQuiz_cloze input[type="text"] {
204
- background: transparent;
205
- border: 0 !important;
206
- border-bottom: 1px solid !important;
207
- height: 18px !important;
208
- margin: 0 !important;
209
- padding: 0 4px 0 4px !important;
210
- color: black !important;
211
- border-radius: 0 !important;
212
- box-shadow: 0 0 !important;
213
- }
214
- .wpProQuiz_cloze input:focus {
215
- outline: none !important;
216
- }
217
- .wpProQuiz_questionListItem input, .wpProQuiz_questionListItem label {
218
- margin: 0 !important;
219
- font-weight: normal;
220
- display: inline;
221
- }
222
- .wpProQuiz_questionListItem label {
223
- float: none;
224
- }
225
- .wpProQuiz_questionListItem input {
226
- float: none !important;
227
- display: inline !important;
228
- }
229
- .wpProQuiz_resultsList {
230
- border: 0 !important;
231
- }
232
- .wpProQuiz_resultsList > li {
233
- background-image: none !important;
234
- padding: 0 !important;
235
- margin: 0 !important;
236
- list-style-type: none !important;
237
- border: 0 !important;
238
- }
239
- .wpProQuiz_lock, .wpProQuiz_prerequisite, .wpProQuiz_startOnlyRegisteredUser, .wpProQuiz_loadQuiz {
240
- border: 1px dotted #FFC3C3 !important;
241
- background-color: #FFF7F7 !important;
242
- }
243
- .wpProQuiz_lock p, .wpProQuiz_prerequisite p, .wpProQuiz_startOnlyRegisteredUser p, .wpProQuiz_loadQuiz p {
244
- margin: 20px !important;
245
- font-weight: bold !important;
246
- }
247
- .wpProQuiz_toplistTable {
248
- width: 100% !important;
249
- border: 1px solid #C3D1A3 !important;
250
- border-collapse: collapse !important;
251
- margin: 0 !important;
252
- }
253
- .wpProQuiz_toplistTable caption {
254
- caption-side:top !important;
255
- text-align: right !important;
256
- padding-bottom: 2px !important;
257
- color: gray !important;
258
- margin: 0 !important;
259
- font-size: 11px !important;
260
- }
261
- .wpProQuiz_toplistTable thead tr {
262
- background: rgb(155,187,89) !important;
263
- padding: 5px !important;
264
- color: white !important;
265
- font-weight: bold !important;
266
- }
267
- .wpProQuiz_toplistTable tbody td:FIRST-CHILD{
268
- font-weight: bold !important;
269
- }
270
- .wpProQuiz_toplistTable td, .wpProQuiz_toplistTable th {
271
- padding: 5px !important;
272
- text-align: center !important;
273
- border: 0 !important;
274
- }
275
- .wpProQuiz_toplistTable th {
276
- background: #9BBB59 !important;
277
- }
278
- .wpProQuiz_toplistTrOdd {
279
- background-color: #EBF1DE !important;
280
- }
281
- .wpProQuiz_addToplist {
282
- margin-top: 10px !important;
283
- background-color: #F5FAEA !important;
284
- padding: 10px !important;
285
- border: 1px solid #C3D1A3 !important;
286
- }
287
- .wpProQuiz_addToplistMessage {
288
- border: 1px solid rgb(160, 160, 160) !important;
289
- background-color: #FCFFB3 !important;
290
- margin-bottom: 5px !important;
291
- border-radius: 5px !important;
292
- padding: 5px !important;
293
- font-weight: bold !important;
294
- color: dimGray !important;
295
- }
296
- .wpProQuiz_resultTable {
297
- margin: 15px auto !important;
298
- width: 400px !important;
299
- border: 1px solid #C4C4C4 !important;
300
- padding: 15px !important;
301
- font-weight: bold !important;
302
- }
303
- .wpProQuiz_resultTable table {
304
- width: 100% !important;
305
- border-collapse: collapse !important;
306
- margin: 0 !important;
307
- border: 0 !important;
308
- text-align: left !important;
309
- }
310
- .wpProQuiz_resultTable table td {
311
- text-align: left !important;
312
- }
313
- .wpProQuiz_resultTable .alt {
314
- background: inherit !important;
315
- }
316
- .wpProQuiz_resultName {
317
- width: 100px !important;
318
- border-right: 1px solid rgb(134, 134, 134) !important;
319
- padding: 10px 0 !important;
320
- border-bottom: 0 !important;
321
- border-top: 0 !important;
322
- border-left: 0 !important;
323
- }
324
- .wpProQuiz_resultValue {
325
- padding: 0 !important;
326
- border: 0 !important;
327
- }
328
- .wpProQuiz_resultValue div {
329
- color: black !important;
330
- text-align: right !important;
331
- box-shadow: 1px 1px 3px 1px #C4C4C4 !important;
332
- display: inline-block !important;
333
- height: 18px !important;
334
- zoom: 1 !important;
335
- *display: inline !important;
336
- margin-right: 3px !important;
337
- vertical-align: middle !important;
338
- }
339
- .wpProQuiz_addBox label {
340
- display: inline !important;
341
- }
342
- .wpProQuiz_addBox input[type="text"] {
343
- margin: 0 !important;
344
- }
345
- .wpProQuiz_reviewQuestion {
346
- max-height: 100px;
347
- overflow: hidden;
348
- border: 1px solid #C3D1A3;
349
- background-color: #F8FAF5;
350
- position: relative;
351
- }
352
- .wpProQuiz_box {
353
- border: 1px solid #C3D1A3;
354
- background-color: #F8FAF5;
355
- }
356
- .wpProQuiz_checkPage h3 {
357
- margin: 10px 0 10px 0;
358
- }
359
- .wpProQuiz_reviewQuestion ol, .wpProQuiz_checkPage ol {
360
- list-style-type: none !important;
361
- margin: 0 !important;
362
- padding: 5px 12px 0 5px !important;
363
- zoom: 1 !important;
364
- position: relative !important;
365
- border: 0 !important;
366
- }
367
- .wpProQuiz_reviewQuestion ol:after {
368
- content: ".";
369
- display: block;
370
- height: 0;
371
- clear: both;
372
- visibility: hidden;
373
- }
374
- .wpProQuiz_reviewQuestionTarget {
375
- font-weight: bold;
376
- border-color: #7DB1D3 !important;
377
- box-shadow: 0 0 2px 1px #C4C4C4;
378
- }
379
- .wpProQuiz_reviewQuestion li, .wpProQuiz_checkPage li {
380
- float: left !important;
381
- margin: 0 5px 5px 0 !important;
382
- border: 1px solid #CFCFCF;
383
- padding: 5px 0 5px 0 !important;
384
- width: 30px !important;
385
- text-align: center !important;
386
- background-color: white;
387
- cursor: pointer !important;
388
- list-style-type: none !important;
389
- background-image: none !important;
390
- }
391
-
392
- .wpProQuiz_reviewQuestion div {
393
- position: absolute;
394
- right: 0;
395
- background-color: #B8B8B8;
396
- top: 0;
397
- height: 20px;
398
- width: 10px;
399
- border: 0;
400
- border-radius: 10px;
401
- cursor: move;
402
- }
403
- .wpProQuiz_reviewLegend {
404
- padding: 5px !important;
405
- margin-bottom: 8px !important;
406
- }
407
- .wpProQuiz_reviewLegend ol {
408
- list-style-type: none !important;
409
- padding: 0 !important;
410
- margin: 0 !important;
411
- border: 0 !important;
412
- }
413
- .wpProQuiz_reviewLegend li {
414
- float: left !important;
415
- padding-right: 5px !important;
416
- list-style-type: none !important;
417
- margin: 0 !important;
418
- border: 0 !important;
419
- background-image: none !important;
420
- }
421
- .wpProQuiz_reviewColor {
422
- height: 10px !important;
423
- width: 10px !important;
424
- display: inline-block !important;
425
- margin-right: 2px !important;
426
- }
427
- .wpProQuiz_button2 {
428
- border: 1px solid #DADADA !important;
429
- background: whiteSmoke !important;
430
- color: #303030 !important;
431
- border-radius: 4px !important;
432
- padding: 3px 5px !important;
433
- box-shadow: 1px 1px 1px #A7A7A7 !important;
434
- text-shadow: none !important;
435
- filter: none !important;
436
- margin: 0 !important;
437
- font-weight: normal !important;
438
- }
439
- .wpProQuiz_button2:hover {
440
- background: #EBEBEB !important;
441
- }
442
- .wpProQuiz_reviewDiv {
443
- margin: 20px 0 20px 0 !important;
444
- }
445
- .wpProQuiz_header {
446
- margin: 0 !important;
447
- }
448
- .wpProQuiz_catOverview {
449
- margin-top: 10px;
450
- margin-bottom: 20px;
451
- }
452
- .wpProQuiz_catOverview li {
453
- list-style: none !important;
454
- padding: 0 !important;
455
- clear: left !important;
456
- border-bottom: 1px dashed #aaa;
457
- height: 1.05em !important;
458
- margin: 10px 0 0 0 !important;
459
- position: relative !important;
460
- }
461
- .wpProQuiz_catOverview span {
462
- background:#fff !important;
463
- padding:0 3px 0 0 !important;
464
- float:left !important;
465
- position:absolute !important;
466
- text-decoration:none !important;
467
- }
468
- span.wpProQuiz_catPercent {
469
- font-weight: bold !important;
470
- padding-left: 5px !important;
471
- color: #000 !important;
472
- right: 0 !important;
473
- }
474
- .wpProQuiz_forms {
475
- margin: 20px 0 20px 0 !important;
476
- }
477
- .wpProQuiz_required {
478
- color: #F00 !important;
479
- font-weight: bold !important;
480
- }
481
- .wpProQuiz_invalidate {
482
- border: 1px solid #FFCFCF !important;
483
- background: #FFEBE8 !important;
484
- padding: 4px !important;
485
- margin: 4px 0 4px 0 !important;
486
- display: none;
487
- }
488
-
489
- .wpProQuiz_forms table {
490
- width: auto !important;
491
- border-collapse: separate !important;
492
- border-spacing: 2px !important;
493
- border: 0;
494
- text-align: left !important;
495
- }
496
- .wpProQuiz_forms table .alt {
497
- background: inherit !important;
498
- }
499
- .wpProQuiz_forms table td {
500
- text-align: left !important;
501
- }
502
-
503
- .wpProQuiz_forms td {
504
- vertical-align: top !important;
505
- padding: 0 0 8px 0 !important;
506
- margin: 0 !important;
507
- border: 0 !important;
508
- background: none !important;
509
- }
510
- .wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms label, .wpProQuiz_forms select {
511
- margin: 0 !important;
512
- float: none !important;
513
- display: inline !important;
514
- }
515
- .wpProQuiz_forms select {
516
- width: auto !important;
517
- }
518
- .wpProQuiz_resultForm {
519
- display: none;
520
- }
521
- .wpProQuiz_quiz input[type="checkbox"] {
522
- -webkit-appearance: checkbox;
523
- }
524
- .wpProQuiz_quiz input[type="radio"] {
525
- -webkit-appearance: radio;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  }
1
+ .wpProQuiz_answerCorrect {
2
+ background: #6DB46D !important;
3
+ font-weight: bold !important;
4
+ }
5
+
6
+ .wpProQuiz_answerCorrect label {
7
+ font-weight: bold !important;
8
+ }
9
+
10
+ .wpProQuiz_answerIncorrect {
11
+ background: #FF9191 !important;
12
+ font-weight: bold !important;
13
+ }
14
+
15
+ .wpProQuiz_content {
16
+ margin-top: 10px !important;
17
+ margin-bottom: 10px !important;
18
+ }
19
+
20
+ .wpProQuiz_content h2 {
21
+ margin-bottom: 10px !important;
22
+ }
23
+
24
+ * + html .wpProQuiz_button, * + html .wpProQuiz_button:hover {
25
+ padding: 3px 0 !important;
26
+ }
27
+
28
+ .wpProQuiz_button, .wpProQuiz_button:hover {
29
+ margin: 0 !important;
30
+ padding: 5px 10px !important;
31
+ background: #13455B !important;
32
+ border-radius: 11px !important;
33
+ color: white !important;
34
+ font-weight: bold !important;
35
+ border: 1px solid #13455B !important;
36
+ box-shadow: 1px 1px 1px #333 !important;
37
+ text-shadow: none !important;
38
+ filter: none !important;
39
+ float: none;
40
+ }
41
+
42
+ .wpProQuiz_question_page {
43
+ margin-bottom: 10px !important;
44
+ }
45
+
46
+ .wpProQuiz_question_page span {
47
+ font-weight: bold !important;
48
+ }
49
+
50
+ .wpProQuiz_questionListItem:last-child, .wpProQuiz_questionListItemLastChildIE {
51
+ padding: 3px !important;
52
+ margin-bottom: 0 !important;
53
+ }
54
+
55
+ .wpProQuiz_questionListItem {
56
+ padding: 3px !important;
57
+ margin-bottom: 5px !important;
58
+ background-image: none !important;
59
+ margin-left: 0 !important;
60
+ list-style: none !important;
61
+ border: 0 !important;
62
+ }
63
+
64
+ .wpProQuiz_questionListItem > table {
65
+ border-collapse: collapse !important;
66
+ margin: 0 !important;
67
+ padding: 0 !important;
68
+ width: 100%;
69
+ border: none !important;
70
+ text-align: left !important;
71
+ }
72
+
73
+ .wpProQuiz_questionListItem > table .alt {
74
+ background: inherit !important;
75
+ }
76
+
77
+ .wpProQuiz_questionListItem > table td {
78
+ text-align: left !important;
79
+ }
80
+
81
+ .wpProQuiz_list, .wpProQuiz_listItem, .wpProQuiz_questionList, .wpProQuiz_sortStringList, .wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion, .wpProQuiz_resultsList, .wpProQuiz_catOverview ol {
82
+ list-style: none !important;
83
+ padding: 0 !important;
84
+ margin: 0 !important;
85
+ }
86
+
87
+ .wpProQuiz_list {
88
+ border: 0 !important;
89
+ }
90
+
91
+ .wpProQuiz_questionList {
92
+ margin-bottom: 10px !important;
93
+ background: #F8FAF5 !important;
94
+ border: 1px solid #C3D1A3 !important;
95
+ padding: 5px !important;
96
+ list-style: none !important;
97
+ }
98
+
99
+ .wpProQuiz_listItem {
100
+ position: relative !important;
101
+ border: 0 !important;
102
+ background-image: none !important;
103
+ }
104
+
105
+ .wpProQuiz_response {
106
+ background: #F8FAF5 !important;
107
+ border: 1px solid #C4C4C4 !important;
108
+ padding: 5px !important;
109
+ margin-bottom: 15px !important;
110
+ box-shadow: 1px 1px 2px #AAA !important;
111
+ }
112
+
113
+ .wpProQuiz_response span {
114
+ font-weight: bold !important;
115
+ }
116
+
117
+ .wpProQuiz_sort {
118
+ width: 25px !important;
119
+ }
120
+
121
+ .wpProQuiz_results h3 {
122
+ margin-bottom: 10px !important;
123
+ }
124
+
125
+ .wpProQuiz_sort_correct_answer {
126
+ font-weight: bold !important;
127
+ margin-right: 5px !important;
128
+ display: none !important;
129
+ }
130
+
131
+ .wpProQuiz_sortable, .wpProQuiz_sortStringItem {
132
+ padding: 5px !important;
133
+ border: 1px solid lightGrey !important;
134
+ box-shadow: 2px 2px 1px #EEE;
135
+ background-color: #F8FAF5 !important;
136
+ cursor: move;
137
+ }
138
+
139
+ .wpProQuiz_time_limit .time {
140
+ font-weight: bold !important;
141
+ margin-top: 5px !important;
142
+ margin-bottom: 5px !important;
143
+ }
144
+
145
+ .wpProQuiz_time_limit .wpProQuiz_progress {
146
+ height: 10px !important;
147
+ background-color: blue !important;
148
+ margin-bottom: 5px !important;
149
+ }
150
+
151
+ .wpProQuiz_time_limit_expired {
152
+ font-weight: bold !important;
153
+ font-size: 15px !important;
154
+ text-align: center !important;
155
+ }
156
+
157
+ .wpProQuiz_question_text {
158
+ margin-bottom: 10px !important;
159
+ }
160
+
161
+ .wpProQuiz_tipp > div {
162
+ padding: 10px !important;
163
+ background-color: #DDECFF !important;
164
+ border: 1px dotted #363636 !important;
165
+ border-radius: 10px !important;
166
+ position: absolute !important;
167
+ bottom: 5px !important;
168
+ left: 5px !important;
169
+ right: 5px !important;
170
+ box-shadow: 2px 2px 5px 0 #313131 !important;
171
+ z-index: 99999 !important;
172
+ }
173
+
174
+ .wpProQuiz_matrixSortString, .wpProQuiz_matrixSortString > h3 {
175
+ margin-bottom: 10px !important;
176
+ margin-top: 0 !important;
177
+ }
178
+
179
+ .wpProQuiz_matrixSortString {
180
+ background: #F8FAF5 !important;
181
+ border: 1px solid #C3D1A3 !important;
182
+ padding: 5px !important;
183
+ }
184
+
185
+ .wpProQuiz_sortStringList {
186
+ padding: 10px !important;
187
+ border: 0 !important;
188
+ }
189
+
190
+ .wpProQuiz_sortStringList > li {
191
+ float: left !important;
192
+ margin-left: 5px !important;
193
+ margin-right: 5px !important;
194
+ margin-bottom: 5px !important;
195
+ }
196
+
197
+ .wpProQuiz_sortStringItem {
198
+ margin: 0 !important;
199
+ background-image: none !important;
200
+ list-style: none !important;
201
+ }
202
+
203
+ .wpProQuiz_maxtrixSortCriterion {
204
+ padding: 5px !important;
205
+ }
206
+
207
+ .wpProQuiz_placehold {
208
+ background-color: #FFFFC2 !important;
209
+ list-style: none !important;
210
+ background-image: none !important;
211
+ padding: 5px !important;
212
+ height: 30px !important;
213
+ min-width: 50px !important;
214
+ margin: 0 !important;
215
+ }
216
+
217
+ .wpProQuiz_maxtrixSortText {
218
+ padding: 5px !important;
219
+ }
220
+
221
+ .wpProQuiz_mextrixTr > td {
222
+ border: 1px solid #D1D1D1 !important;
223
+ padding: 5px !important;
224
+ vertical-align: middle !important;
225
+ }
226
+
227
+ .wpProQuiz_points {
228
+ font-weight: bold !important;
229
+ text-align: center !important;
230
+ margin-bottom: 20px !important;
231
+ }
232
+
233
+ .wpProQuiz_cloze input[type="text"] {
234
+ background: transparent;
235
+ border: 0 !important;
236
+ border-bottom: 1px solid !important;
237
+ height: 18px !important;
238
+ margin: 0 !important;
239
+ padding: 0 4px 0 4px !important;
240
+ color: black !important;
241
+ border-radius: 0 !important;
242
+ box-shadow: 0 0 !important;
243
+ }
244
+
245
+ .wpProQuiz_cloze input:focus {
246
+ outline: none !important;
247
+ }
248
+
249
+ .wpProQuiz_questionListItem input, .wpProQuiz_questionListItem label {
250
+ margin: 0 !important;
251
+ font-weight: normal;
252
+ display: inline;
253
+ }
254
+
255
+ .wpProQuiz_questionListItem label {
256
+ float: none;
257
+ }
258
+
259
+ .wpProQuiz_questionListItem input {
260
+ float: none !important;
261
+ display: inline !important;
262
+ }
263
+
264
+ .wpProQuiz_resultsList {
265
+ border: 0 !important;
266
+ }
267
+
268
+ .wpProQuiz_resultsList > li {
269
+ background-image: none !important;
270
+ padding: 0 !important;
271
+ margin: 0 !important;
272
+ list-style-type: none !important;
273
+ border: 0 !important;
274
+ }
275
+
276
+ .wpProQuiz_lock, .wpProQuiz_prerequisite, .wpProQuiz_startOnlyRegisteredUser, .wpProQuiz_loadQuiz {
277
+ border: 1px dotted #FFC3C3 !important;
278
+ background-color: #FFF7F7 !important;
279
+ }
280
+
281
+ .wpProQuiz_lock p, .wpProQuiz_prerequisite p, .wpProQuiz_startOnlyRegisteredUser p, .wpProQuiz_loadQuiz p {
282
+ margin: 20px !important;
283
+ font-weight: bold !important;
284
+ }
285
+
286
+ .wpProQuiz_toplistTable {
287
+ width: 100% !important;
288
+ border: 1px solid #C3D1A3 !important;
289
+ border-collapse: collapse !important;
290
+ margin: 0 !important;
291
+ }
292
+
293
+ .wpProQuiz_toplistTable caption {
294
+ caption-side: top !important;
295
+ text-align: right !important;
296
+ padding-bottom: 2px !important;
297
+ color: gray !important;
298
+ margin: 0 !important;
299
+ font-size: 11px !important;
300
+ }
301
+
302
+ .wpProQuiz_toplistTable thead tr {
303
+ background: rgb(155, 187, 89) !important;
304
+ padding: 5px !important;
305
+ color: white !important;
306
+ font-weight: bold !important;
307
+ }
308
+
309
+ .wpProQuiz_toplistTable tbody td:FIRST-CHILD {
310
+ font-weight: bold !important;
311
+ }
312
+
313
+ .wpProQuiz_toplistTable td, .wpProQuiz_toplistTable th {
314
+ padding: 5px !important;
315
+ text-align: center !important;
316
+ border: 0 !important;
317
+ }
318
+
319
+ .wpProQuiz_toplistTable th {
320
+ background: #9BBB59 !important;
321
+ }
322
+
323
+ .wpProQuiz_toplistTrOdd {
324
+ background-color: #EBF1DE !important;
325
+ }
326
+
327
+ .wpProQuiz_addToplist {
328
+ margin-top: 10px !important;
329
+ background-color: #F5FAEA !important;
330
+ padding: 10px !important;
331
+ border: 1px solid #C3D1A3 !important;
332
+ }
333
+
334
+ .wpProQuiz_addToplistMessage {
335
+ border: 1px solid rgb(160, 160, 160) !important;
336
+ background-color: #FCFFB3 !important;
337
+ margin-bottom: 5px !important;
338
+ border-radius: 5px !important;
339
+ padding: 5px !important;
340
+ font-weight: bold !important;
341
+ color: dimGray !important;
342
+ }
343
+
344
+ .wpProQuiz_resultTable {
345
+ margin: 15px auto !important;
346
+ width: 400px !important;
347
+ border: 1px solid #C4C4C4 !important;
348
+ padding: 15px !important;
349
+ font-weight: bold !important;
350
+ }
351
+
352
+ .wpProQuiz_resultTable table {
353
+ width: 100% !important;
354
+ border-collapse: collapse !important;
355
+ margin: 0 !important;
356
+ border: 0 !important;
357
+ text-align: left !important;
358
+ }
359
+
360
+ .wpProQuiz_resultTable table td {
361
+ text-align: left !important;
362
+ }
363
+
364
+ .wpProQuiz_resultTable .alt {
365
+ background: inherit !important;
366
+ }
367
+
368
+ .wpProQuiz_resultName {
369
+ width: 100px !important;
370
+ border-right: 1px solid rgb(134, 134, 134) !important;
371
+ padding: 10px 0 !important;
372
+ border-bottom: 0 !important;
373
+ border-top: 0 !important;
374
+ border-left: 0 !important;
375
+ }
376
+
377
+ .wpProQuiz_resultValue {
378
+ padding: 0 !important;
379
+ border: 0 !important;
380
+ }
381
+
382
+ .wpProQuiz_resultValue div {
383
+ color: black !important;
384
+ text-align: right !important;
385
+ box-shadow: 1px 1px 3px 1px #C4C4C4 !important;
386
+ display: inline-block !important;
387
+ height: 18px !important;
388
+ zoom: 1 !important;
389
+ *display: inline !important;
390
+ margin-right: 3px !important;
391
+ vertical-align: middle !important;
392
+ }
393
+
394
+ .wpProQuiz_addBox label {
395
+ display: inline !important;
396
+ }
397
+
398
+ .wpProQuiz_addBox input[type="text"] {
399
+ margin: 0 !important;
400
+ }
401
+
402
+ .wpProQuiz_reviewQuestion {
403
+ max-height: 100px;
404
+ overflow: hidden;
405
+ border: 1px solid #C3D1A3;
406
+ background-color: #F8FAF5;
407
+ position: relative;
408
+ }
409
+
410
+ .wpProQuiz_box {
411
+ border: 1px solid #C3D1A3;
412
+ background-color: #F8FAF5;
413
+ }
414
+
415
+ .wpProQuiz_checkPage h3 {
416
+ margin: 10px 0 10px 0;
417
+ }
418
+
419
+ .wpProQuiz_reviewQuestion ol, .wpProQuiz_checkPage ol {
420
+ list-style-type: none !important;
421
+ margin: 0 !important;
422
+ padding: 5px 12px 0 5px !important;
423
+ zoom: 1 !important;
424
+ position: relative !important;
425
+ border: 0 !important;
426
+ }
427
+
428
+ .wpProQuiz_reviewQuestion ol:after {
429
+ content: ".";
430
+ display: block;
431
+ height: 0;
432
+ clear: both;
433
+ visibility: hidden;
434
+ }
435
+
436
+ .wpProQuiz_reviewQuestionTarget {
437
+ font-weight: bold;
438
+ border-color: #7DB1D3 !important;
439
+ box-shadow: 0 0 2px 1px #C4C4C4;
440
+ }
441
+
442
+ .wpProQuiz_reviewQuestion li, .wpProQuiz_checkPage li {
443
+ float: left !important;
444
+ margin: 0 5px 5px 0 !important;
445
+ border: 1px solid #CFCFCF;
446
+ padding: 5px 0 5px 0 !important;
447
+ width: 30px !important;
448
+ text-align: center !important;
449
+ background-color: white;
450
+ cursor: pointer !important;
451
+ list-style-type: none !important;
452
+ background-image: none !important;
453
+ }
454
+
455
+ .wpProQuiz_reviewQuestion div {
456
+ position: absolute;
457
+ right: 0;
458
+ background-color: #B8B8B8;
459
+ top: 0;
460
+ height: 20px;
461
+ width: 10px;
462
+ border: 0;
463
+ border-radius: 10px;
464
+ cursor: move;
465
+ }
466
+
467
+ .wpProQuiz_reviewLegend {
468
+ padding: 5px !important;
469
+ margin-bottom: 8px !important;
470
+ }
471
+
472
+ .wpProQuiz_reviewLegend ol {
473
+ list-style-type: none !important;
474
+ padding: 0 !important;
475
+ margin: 0 !important;
476
+ border: 0 !important;
477
+ }
478
+
479
+ .wpProQuiz_reviewLegend li {
480
+ float: left !important;
481
+ padding-right: 5px !important;
482
+ list-style-type: none !important;
483
+ margin: 0 !important;
484
+ border: 0 !important;
485
+ background-image: none !important;
486
+ }
487
+
488
+ .wpProQuiz_reviewColor {
489
+ height: 10px !important;
490
+ width: 10px !important;
491
+ display: inline-block !important;
492
+ margin-right: 2px !important;
493
+ }
494
+
495
+ .wpProQuiz_button2 {
496
+ border: 1px solid #DADADA !important;
497
+ background: whiteSmoke !important;
498
+ color: #303030 !important;
499
+ border-radius: 4px !important;
500
+ padding: 3px 5px !important;
501
+ box-shadow: 1px 1px 1px #A7A7A7 !important;
502
+ text-shadow: none !important;
503
+ filter: none !important;
504
+ margin: 0 !important;
505
+ font-weight: normal !important;
506
+ }
507
+
508
+ .wpProQuiz_button2:hover {
509
+ background: #EBEBEB !important;
510
+ }
511
+
512
+ .wpProQuiz_reviewDiv {
513
+ margin: 20px 0 20px 0 !important;
514
+ }
515
+
516
+ .wpProQuiz_header {
517
+ margin: 0 !important;
518
+ }
519
+
520
+ .wpProQuiz_catOverview {
521
+ margin-top: 10px;
522
+ margin-bottom: 20px;
523
+ }
524
+
525
+ .wpProQuiz_catOverview li {
526
+ list-style: none !important;
527
+ padding: 0 !important;
528
+ clear: left !important;
529
+ border-bottom: 1px dashed #aaa;
530
+ height: 1.05em !important;
531
+ margin: 10px 0 0 0 !important;
532
+ position: relative !important;
533
+ }
534
+
535
+ .wpProQuiz_catOverview span {
536
+ background: #fff !important;
537
+ padding: 0 3px 0 0 !important;
538
+ float: left !important;
539
+ position: absolute !important;
540
+ text-decoration: none !important;
541
+ }
542
+
543
+ span.wpProQuiz_catPercent {
544
+ font-weight: bold !important;
545
+ padding-left: 5px !important;
546
+ color: #000 !important;
547
+ right: 0 !important;
548
+ }
549
+
550
+ .wpProQuiz_forms {
551
+ margin: 20px 0 20px 0 !important;
552
+ }
553
+
554
+ .wpProQuiz_required {
555
+ color: #F00 !important;
556
+ font-weight: bold !important;
557
+ }
558
+
559
+ .wpProQuiz_invalidate {
560
+ border: 1px solid #FFCFCF !important;
561
+ background: #FFEBE8 !important;
562
+ padding: 4px !important;
563
+ margin: 4px 0 4px 0 !important;
564
+ display: none;
565
+ }
566
+
567
+ .wpProQuiz_forms table {
568
+ width: auto !important;
569
+ border-collapse: separate !important;
570
+ border-spacing: 2px !important;
571
+ border: 0;
572
+ text-align: left !important;
573
+ }
574
+
575
+ .wpProQuiz_forms table .alt {
576
+ background: inherit !important;
577
+ }
578
+
579
+ .wpProQuiz_forms table td {
580
+ text-align: left !important;
581
+ }
582
+
583
+ .wpProQuiz_forms td {
584
+ vertical-align: top !important;
585
+ padding: 0 0 8px 0 !important;
586
+ margin: 0 !important;
587
+ border: 0 !important;
588
+ background: none !important;
589
+ }
590
+
591
+ .wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms label, .wpProQuiz_forms select {
592
+ margin: 0 !important;
593
+ float: none !important;
594
+ display: inline !important;
595
+ }
596
+
597
+ .wpProQuiz_forms select {
598
+ width: auto !important;
599
+ }
600
+
601
+ .wpProQuiz_resultForm {
602
+ display: none;
603
+ }
604
+
605
+ .wpProQuiz_quiz input[type="checkbox"] {
606
+ -webkit-appearance: checkbox;
607
+ }
608
+
609
+ .wpProQuiz_quiz input[type="radio"] {
610
+ -webkit-appearance: radio;
611
  }
css/wpProQuiz_front.min.css CHANGED
@@ -1 +1 @@
1
- .wpProQuiz_answerCorrect{background:#6db46d!important;font-weight:bold!important}.wpProQuiz_answerCorrect label{font-weight:bold!important}.wpProQuiz_answerIncorrect{background:#ff9191!important;font-weight:bold!important}.wpProQuiz_content{margin-top:10px!important;margin-bottom:10px!important}.wpProQuiz_content h2{margin-bottom:10px!important}*+html .wpProQuiz_button,*+html .wpProQuiz_button:hover{padding:3px 0!important}.wpProQuiz_button,.wpProQuiz_button:hover{margin:0!important;padding:5px 10px!important;background:#13455b!important;border-radius:11px!important;color:white!important;font-weight:bold!important;border:1px solid #13455b!important;box-shadow:1px 1px 1px #333!important;text-shadow:none!important;filter:none!important;float:none}.wpProQuiz_question_page{margin-bottom:10px!important}.wpProQuiz_question_page span{font-weight:bold!important}.wpProQuiz_questionListItem:last-child,.wpProQuiz_questionListItemLastChildIE{padding:3px!important;margin-bottom:0!important}.wpProQuiz_questionListItem{padding:3px!important;margin-bottom:5px!important;background-image:none!important;margin-left:0!important;list-style:none!important;border:0!important}.wpProQuiz_questionListItem>table{border-collapse:collapse!important;margin:0!important;padding:0!important;width:100%;border:none!important;text-align:left!important}.wpProQuiz_questionListItem>table .alt{background:inherit!important}.wpProQuiz_questionListItem>table td{text-align:left!important}.wpProQuiz_list,.wpProQuiz_listItem,.wpProQuiz_questionList,.wpProQuiz_sortStringList,.wpProQuiz_sortStringList,.wpProQuiz_maxtrixSortCriterion,.wpProQuiz_resultsList,.wpProQuiz_catOverview ol{list-style:none!important;padding:0!important;margin:0!important}.wpProQuiz_list{border:0!important}.wpProQuiz_questionList{margin-bottom:10px!important;background:#f8faf5!important;border:1px solid #c3d1a3!important;padding:5px!important;list-style:none!important}.wpProQuiz_listItem{position:relative!important;border:0!important;background-image:none!important}.wpProQuiz_response{background:#f8faf5!important;border:1px solid #c4c4c4!important;padding:5px!important;margin-bottom:15px!important;box-shadow:1px 1px 2px #AAA!important}.wpProQuiz_response span{font-weight:bold!important}.wpProQuiz_sort{width:25px!important}.wpProQuiz_results h3{margin-bottom:10px!important}.wpProQuiz_sort_correct_answer{font-weight:bold!important;margin-right:5px!important;display:none!important}.wpProQuiz_sortable,.wpProQuiz_sortStringItem{padding:5px!important;border:1px solid lightGrey!important;box-shadow:2px 2px 1px #EEE;background-color:#f8faf5!important;cursor:move}.wpProQuiz_time_limit .time{font-weight:bold!important;margin-top:5px!important;margin-bottom:5px!important}.wpProQuiz_time_limit .wpProQuiz_progress{height:10px!important;background-color:blue!important;margin-bottom:5px!important}.wpProQuiz_time_limit_expired{font-weight:bold!important;font-size:15px!important;text-align:center!important}.wpProQuiz_question_text{margin-bottom:10px!important}.wpProQuiz_tipp>div{padding:10px!important;background-color:#ddecff!important;border:1px dotted #363636!important;border-radius:10px!important;position:absolute!important;bottom:5px!important;left:5px!important;right:5px!important;box-shadow:2px 2px 5px 0 #313131!important;z-index:99999!important}.wpProQuiz_matrixSortString,.wpProQuiz_matrixSortString>h3{margin-bottom:10px!important;margin-top:0!important}.wpProQuiz_matrixSortString{background:#f8faf5!important;border:1px solid #c3d1a3!important;padding:5px!important}.wpProQuiz_sortStringList{padding:10px!important;border:0!important}.wpProQuiz_sortStringList>li{float:left!important;margin-left:5px!important;margin-right:5px!important;margin-bottom:5px!important}.wpProQuiz_sortStringItem{margin:0!important;background-image:none!important;list-style:none!important}.wpProQuiz_maxtrixSortCriterion{padding:5px!important}.wpProQuiz_placehold{background-color:#ffffc2!important;list-style:none!important;background-image:none!important;padding:5px!important;height:30px!important;min-width:50px!important;margin:0!important}.wpProQuiz_maxtrixSortText{padding:5px!important}.wpProQuiz_mextrixTr>td{border:1px solid #d1d1d1!important;padding:5px!important;vertical-align:middle!important}.wpProQuiz_points{font-weight:bold!important;text-align:center!important;margin-bottom:20px!important}.wpProQuiz_cloze input[type="text"]{background:transparent;border:0!important;border-bottom:1px solid!important;height:18px!important;margin:0!important;padding:0 4px 0 4px!important;color:black!important;border-radius:0!important;box-shadow:0 0!important}.wpProQuiz_cloze input:focus{outline:none!important}.wpProQuiz_questionListItem input,.wpProQuiz_questionListItem label{margin:0!important;font-weight:normal;display:inline}.wpProQuiz_questionListItem label{float:none}.wpProQuiz_questionListItem input{float:none!important;display:inline!important}.wpProQuiz_resultsList{border:0!important}.wpProQuiz_resultsList>li{background-image:none!important;padding:0!important;margin:0!important;list-style-type:none!important;border:0!important}.wpProQuiz_lock,.wpProQuiz_prerequisite,.wpProQuiz_startOnlyRegisteredUser,.wpProQuiz_loadQuiz{border:1px dotted #ffc3c3!important;background-color:#fff7f7!important}.wpProQuiz_lock p,.wpProQuiz_prerequisite p,.wpProQuiz_startOnlyRegisteredUser p,.wpProQuiz_loadQuiz p{margin:20px!important;font-weight:bold!important}.wpProQuiz_toplistTable{width:100%!important;border:1px solid #c3d1a3!important;border-collapse:collapse!important;margin:0!important}.wpProQuiz_toplistTable caption{caption-side:top!important;text-align:right!important;padding-bottom:2px!important;color:gray!important;margin:0!important;font-size:11px!important}.wpProQuiz_toplistTable thead tr{background:#9bbb59!important;padding:5px!important;color:white!important;font-weight:bold!important}.wpProQuiz_toplistTable tbody td:FIRST-CHILD{font-weight:bold!important}.wpProQuiz_toplistTable td,.wpProQuiz_toplistTable th{padding:5px!important;text-align:center!important;border:0!important}.wpProQuiz_toplistTable th{background:#9bbb59!important}.wpProQuiz_toplistTrOdd{background-color:#ebf1de!important}.wpProQuiz_addToplist{margin-top:10px!important;background-color:#f5faea!important;padding:10px!important;border:1px solid #c3d1a3!important}.wpProQuiz_addToplistMessage{border:1px solid #a0a0a0!important;background-color:#fcffb3!important;margin-bottom:5px!important;border-radius:5px!important;padding:5px!important;font-weight:bold!important;color:dimGray!important}.wpProQuiz_resultTable{margin:15px auto!important;width:400px!important;border:1px solid #c4c4c4!important;padding:15px!important;font-weight:bold!important}.wpProQuiz_resultTable table{width:100%!important;border-collapse:collapse!important;margin:0!important;border:0!important;text-align:left!important}.wpProQuiz_resultTable table td{text-align:left!important}.wpProQuiz_resultTable .alt{background:inherit!important}.wpProQuiz_resultName{width:100px!important;border-right:1px solid #868686!important;padding:10px 0!important;border-bottom:0!important;border-top:0!important;border-left:0!important}.wpProQuiz_resultValue{padding:0!important;border:0!important}.wpProQuiz_resultValue div{color:black!important;text-align:right!important;box-shadow:1px 1px 3px 1px #c4c4c4!important;display:inline-block!important;height:18px!important;zoom:1!important;*display:inline!important;margin-right:3px!important;vertical-align:middle!important}.wpProQuiz_addBox label{display:inline!important}.wpProQuiz_addBox input[type="text"]{margin:0!important}.wpProQuiz_reviewQuestion{max-height:100px;overflow:hidden;border:1px solid #c3d1a3;background-color:#f8faf5;position:relative}.wpProQuiz_box{border:1px solid #c3d1a3;background-color:#f8faf5}.wpProQuiz_checkPage h3{margin:10px 0 10px 0}.wpProQuiz_reviewQuestion ol,.wpProQuiz_checkPage ol{list-style-type:none!important;margin:0!important;padding:5px 12px 0 5px!important;zoom:1!important;position:relative!important;border:0!important}.wpProQuiz_reviewQuestion ol:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wpProQuiz_reviewQuestionTarget{font-weight:bold;border-color:#7db1d3!important;box-shadow:0 0 2px 1px #c4c4c4}.wpProQuiz_reviewQuestion li,.wpProQuiz_checkPage li{float:left!important;margin:0 5px 5px 0!important;border:1px solid #cfcfcf;padding:5px 0 5px 0!important;width:30px!important;text-align:center!important;background-color:white;cursor:pointer!important;list-style-type:none!important;background-image:none!important}.wpProQuiz_reviewQuestion div{position:absolute;right:0;background-color:#b8b8b8;top:0;height:20px;width:10px;border:0;border-radius:10px;cursor:move}.wpProQuiz_reviewLegend{padding:5px!important;margin-bottom:8px!important}.wpProQuiz_reviewLegend ol{list-style-type:none!important;padding:0!important;margin:0!important;border:0!important}.wpProQuiz_reviewLegend li{float:left!important;padding-right:5px!important;list-style-type:none!important;margin:0!important;border:0!important;background-image:none!important}.wpProQuiz_reviewColor{height:10px!important;width:10px!important;display:inline-block!important;margin-right:2px!important}.wpProQuiz_button2{border:1px solid #dadada!important;background:whiteSmoke!important;color:#303030!important;border-radius:4px!important;padding:3px 5px!important;box-shadow:1px 1px 1px #a7a7a7!important;text-shadow:none!important;filter:none!important;margin:0!important;font-weight:normal!important}.wpProQuiz_button2:hover{background:#ebebeb!important}.wpProQuiz_reviewDiv{margin:20px 0 20px 0!important}.wpProQuiz_header{margin:0!important}.wpProQuiz_catOverview{margin-top:10px;margin-bottom:20px}.wpProQuiz_catOverview li{list-style:none!important;padding:0!important;clear:left!important;border-bottom:1px dashed #aaa;height:1.05em!important;margin:10px 0 0 0!important;position:relative!important}.wpProQuiz_catOverview span{background:#fff!important;padding:0 3px 0 0!important;float:left!important;position:absolute!important;text-decoration:none!important}span.wpProQuiz_catPercent{font-weight:bold!important;padding-left:5px!important;color:#000!important;right:0!important}.wpProQuiz_forms{margin:20px 0 20px 0!important}.wpProQuiz_required{color:#F00!important;font-weight:bold!important}.wpProQuiz_invalidate{border:1px solid #ffcfcf!important;background:#ffebe8!important;padding:4px!important;margin:4px 0 4px 0!important;display:none}.wpProQuiz_forms table{width:auto!important;border-collapse:separate!important;border-spacing:2px!important;border:0;text-align:left!important}.wpProQuiz_forms table .alt{background:inherit!important}.wpProQuiz_forms table td{text-align:left!important}.wpProQuiz_forms td{vertical-align:top!important;padding:0 0 8px 0!important;margin:0!important;border:0!important;background:none!important}.wpProQuiz_forms input,.wpProQuiz_forms textarea,.wpProQuiz_forms label,.wpProQuiz_forms select{margin:0!important;float:none!important;display:inline!important}.wpProQuiz_forms select{width:auto!important}.wpProQuiz_resultForm{display:none}.wpProQuiz_quiz input[type="checkbox"]{-webkit-appearance:checkbox}.wpProQuiz_quiz input[type="radio"]{-webkit-appearance:radio}
1
+ .wpProQuiz_content,.wpProQuiz_content h2{margin-bottom:10px!important}.wpProQuiz_answerCorrect,.wpProQuiz_answerCorrect label,.wpProQuiz_answerIncorrect,.wpProQuiz_question_page span{font-weight:700!important}.wpProQuiz_answerCorrect{background:#6DB46D!important}.wpProQuiz_answerIncorrect{background:#FF9191!important}.wpProQuiz_content{margin-top:10px!important}*+html .wpProQuiz_button,*+html .wpProQuiz_button:hover{padding:3px 0!important}.wpProQuiz_button,.wpProQuiz_button:hover{margin:0!important;padding:5px 10px!important;background:#13455B!important;border-radius:11px!important;color:#fff!important;font-weight:700!important;border:1px solid #13455B!important;box-shadow:1px 1px 1px #333!important;text-shadow:none!important;filter:none!important;float:none}.wpProQuiz_question_page{margin-bottom:10px!important}.wpProQuiz_questionListItem:last-child,.wpProQuiz_questionListItemLastChildIE{padding:3px!important;margin-bottom:0!important}.wpProQuiz_questionListItem{padding:3px!important;margin-bottom:5px!important;background-image:none!important;margin-left:0!important;list-style:none!important;border:0!important}.wpProQuiz_questionListItem>table{border-collapse:collapse!important;margin:0!important;padding:0!important;width:100%;border:none!important;text-align:left!important}.wpProQuiz_questionListItem>table .alt{background:inherit!important}.wpProQuiz_questionListItem>table td{text-align:left!important}.wpProQuiz_points,.wpProQuiz_time_limit_expired{font-weight:700!important;text-align:center!important}.wpProQuiz_catOverview ol,.wpProQuiz_list,.wpProQuiz_listItem,.wpProQuiz_maxtrixSortCriterion,.wpProQuiz_questionList,.wpProQuiz_resultsList,.wpProQuiz_sortStringList{list-style:none!important;padding:0!important;margin:0!important}.wpProQuiz_list{border:0!important}.wpProQuiz_questionList{margin-bottom:10px!important;background:#F8FAF5!important;border:1px solid #C3D1A3!important;padding:5px!important;list-style:none!important}.wpProQuiz_listItem{position:relative!important;border:0!important;background-image:none!important}.wpProQuiz_response{background:#F8FAF5!important;border:1px solid #C4C4C4!important;padding:5px!important;margin-bottom:15px!important;box-shadow:1px 1px 2px #AAA!important}.wpProQuiz_response span{font-weight:700!important}.wpProQuiz_sort{width:25px!important}.wpProQuiz_results h3{margin-bottom:10px!important}.wpProQuiz_sort_correct_answer{font-weight:700!important;margin-right:5px!important;display:none!important}.wpProQuiz_sortStringItem,.wpProQuiz_sortable{padding:5px!important;border:1px solid #d3d3d3!important;box-shadow:2px 2px 1px #EEE;background-color:#F8FAF5!important;cursor:move}.wpProQuiz_time_limit .time{font-weight:700!important;margin-top:5px!important;margin-bottom:5px!important}.wpProQuiz_time_limit .wpProQuiz_progress{height:10px!important;background-color:#00f!important;margin-bottom:5px!important}.wpProQuiz_time_limit_expired{font-size:15px!important}.wpProQuiz_question_text{margin-bottom:10px!important}.wpProQuiz_tipp>div{padding:10px!important;background-color:#DDECFF!important;border:1px dotted #363636!important;border-radius:10px!important;position:absolute!important;bottom:5px!important;left:5px!important;right:5px!important;box-shadow:2px 2px 5px 0 #313131!important;z-index:99999!important}.wpProQuiz_matrixSortString,.wpProQuiz_matrixSortString>h3{margin-bottom:10px!important;margin-top:0!important}.wpProQuiz_matrixSortString{background:#F8FAF5!important;border:1px solid #C3D1A3!important;padding:5px!important}.wpProQuiz_sortStringList{padding:10px!important;border:0!important}.wpProQuiz_maxtrixSortCriterion,.wpProQuiz_maxtrixSortText,.wpProQuiz_placehold{padding:5px!important}.wpProQuiz_sortStringList>li{float:left!important;margin-left:5px!important;margin-right:5px!important;margin-bottom:5px!important}.wpProQuiz_placehold,.wpProQuiz_sortStringItem{background-image:none!important;margin:0!important;list-style:none!important}.wpProQuiz_placehold{background-color:#FFFFC2!important;height:30px!important;min-width:50px!important}.wpProQuiz_mextrixTr>td{border:1px solid #D1D1D1!important;padding:5px!important;vertical-align:middle!important}.wpProQuiz_points{margin-bottom:20px!important}.wpProQuiz_cloze input[type=text]{background:0 0;border:0!important;border-bottom:1px solid!important;height:18px!important;margin:0!important;padding:0 4px!important;color:#000!important;border-radius:0!important;box-shadow:0 0!important}.wpProQuiz_cloze input:focus{outline:0!important}.wpProQuiz_questionListItem input,.wpProQuiz_questionListItem label{margin:0!important;font-weight:400;display:inline}.wpProQuiz_questionListItem label{float:none}.wpProQuiz_questionListItem input{float:none!important;display:inline!important}.wpProQuiz_resultsList{border:0!important}.wpProQuiz_resultsList>li{background-image:none!important;padding:0!important;margin:0!important;list-style-type:none!important;border:0!important}.wpProQuiz_loadQuiz,.wpProQuiz_lock,.wpProQuiz_prerequisite,.wpProQuiz_startOnlyRegisteredUser{border:1px dotted #FFC3C3!important;background-color:#FFF7F7!important}.wpProQuiz_loadQuiz p,.wpProQuiz_lock p,.wpProQuiz_prerequisite p,.wpProQuiz_startOnlyRegisteredUser p{margin:20px!important;font-weight:700!important}.wpProQuiz_toplistTable{width:100%!important;border:1px solid #C3D1A3!important;border-collapse:collapse!important;margin:0!important}.wpProQuiz_toplistTable caption{caption-side:top!important;text-align:right!important;padding-bottom:2px!important;color:gray!important;margin:0!important;font-size:11px!important}.wpProQuiz_toplistTable thead tr{background:#9bbb59!important;padding:5px!important;color:#fff!important;font-weight:700!important}.wpProQuiz_toplistTable tbody td:FIRST-CHILD{font-weight:700!important}.wpProQuiz_toplistTable td,.wpProQuiz_toplistTable th{padding:5px!important;text-align:center!important;border:0!important}.wpProQuiz_toplistTable th{background:#9BBB59!important}.wpProQuiz_toplistTrOdd{background-color:#EBF1DE!important}.wpProQuiz_addToplist{margin-top:10px!important;background-color:#F5FAEA!important;padding:10px!important;border:1px solid #C3D1A3!important}.wpProQuiz_addToplistMessage{border:1px solid #a0a0a0!important;background-color:#FCFFB3!important;margin-bottom:5px!important;border-radius:5px!important;padding:5px!important;font-weight:700!important;color:#696969!important}.wpProQuiz_resultTable{margin:15px auto!important;width:25pc!important;border:1px solid #C4C4C4!important;padding:15px!important;font-weight:700!important}.wpProQuiz_resultTable table{width:100%!important;border-collapse:collapse!important;margin:0!important;border:0!important;text-align:left!important}.wpProQuiz_resultTable table td{text-align:left!important}.wpProQuiz_resultTable .alt{background:inherit!important}.wpProQuiz_resultName{width:75pt!important;border-right:1px solid #868686!important;padding:10px 0!important;border-bottom:0!important;border-top:0!important;border-left:0!important}.wpProQuiz_resultValue{padding:0!important;border:0!important}.wpProQuiz_box,.wpProQuiz_reviewQuestion{border:1px solid #C3D1A3;background-color:#F8FAF5}.wpProQuiz_resultValue div{color:#000!important;text-align:right!important;box-shadow:1px 1px 3px 1px #C4C4C4!important;display:inline-block!important;height:18px!important;zoom:1!important;*display:inline!important;margin-right:3px!important;vertical-align:middle!important}.wpProQuiz_addBox label{display:inline!important}.wpProQuiz_addBox input[type=text]{margin:0!important}.wpProQuiz_reviewQuestion{max-height:75pt;overflow:hidden;position:relative}.wpProQuiz_checkPage h3{margin:10px 0}.wpProQuiz_checkPage ol,.wpProQuiz_reviewQuestion ol{list-style-type:none!important;margin:0!important;padding:5px 9pt 0 5px!important;zoom:1!important;position:relative!important;border:0!important}.wpProQuiz_reviewQuestion ol:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wpProQuiz_reviewQuestionTarget{font-weight:700;border-color:#7DB1D3!important;box-shadow:0 0 2px 1px #C4C4C4}.wpProQuiz_checkPage li,.wpProQuiz_reviewQuestion li{float:left!important;margin:0 5px 5px 0!important;border:1px solid #CFCFCF;padding:5px 0!important;width:30px!important;text-align:center!important;background-color:#fff;cursor:pointer!important;list-style-type:none!important;background-image:none!important}.wpProQuiz_forms table,.wpProQuiz_forms table td{text-align:left!important}.wpProQuiz_reviewQuestion div{position:absolute;right:0;background-color:#B8B8B8;top:0;height:20px;width:10px;border:0;border-radius:10px;cursor:move}.wpProQuiz_reviewLegend{padding:5px!important;margin-bottom:8px!important}.wpProQuiz_reviewLegend li,.wpProQuiz_reviewLegend ol{list-style-type:none!important;margin:0!important;border:0!important}.wpProQuiz_reviewLegend ol{padding:0!important}.wpProQuiz_reviewLegend li{float:left!important;padding-right:5px!important;background-image:none!important}.wpProQuiz_reviewColor{height:10px!important;width:10px!important;display:inline-block!important;margin-right:2px!important}.wpProQuiz_button2{border:1px solid #DADADA!important;background:#f5f5f5!important;color:#303030!important;border-radius:4px!important;padding:3px 5px!important;box-shadow:1px 1px 1px #A7A7A7!important;text-shadow:none!important;filter:none!important;margin:0!important;font-weight:400!important}.wpProQuiz_button2:hover{background:#EBEBEB!important}.wpProQuiz_reviewDiv{margin:20px 0!important}.wpProQuiz_header{margin:0!important}.wpProQuiz_catOverview{margin-top:10px;margin-bottom:20px}.wpProQuiz_catOverview li{list-style:none!important;padding:0!important;clear:left!important;border-bottom:1px dashed #aaa;height:1.05em!important;margin:10px 0 0!important;position:relative!important}.wpProQuiz_catOverview span{background:#fff!important;padding:0 3px 0 0!important;float:left!important;position:absolute!important;text-decoration:none!important}span.wpProQuiz_catPercent{font-weight:700!important;padding-left:5px!important;color:#000!important;right:0!important}.wpProQuiz_forms{margin:20px 0!important}.wpProQuiz_required{color:red!important;font-weight:700!important}.wpProQuiz_invalidate{border:1px solid #FFCFCF!important;background:#FFEBE8!important;padding:4px!important;margin:4px 0!important;display:none}.wpProQuiz_forms table{width:auto!important;border-collapse:separate!important;border-spacing:2px!important;border:0}.wpProQuiz_forms table .alt{background:inherit!important}.wpProQuiz_forms td{vertical-align:top!important;padding:0 0 8px!important;margin:0!important;border:0!important;background:0 0!important}.wpProQuiz_forms input,.wpProQuiz_forms label,.wpProQuiz_forms select,.wpProQuiz_forms textarea{margin:0!important;float:none!important;display:inline!important}.wpProQuiz_forms select{width:auto!important}.wpProQuiz_resultForm{display:none}.wpProQuiz_quiz input[type=checkbox]{-webkit-appearance:checkbox}.wpProQuiz_quiz input[type=radio]{-webkit-appearance:radio}
gulpfile.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var gulp = require('gulp');
2
+ var minifyCss = require('gulp-minify-css');
3
+ var ext = require('gulp-ext-replace');
4
+ var uglify = require('gulp-uglify');
5
+
6
+ var paths = {
7
+ css: [
8
+ 'css/wpProQuiz_front.css'
9
+ ],
10
+ js: [
11
+ 'js/wpProQuiz_admin.js',
12
+ 'js/wpProQuiz_front.js',
13
+ 'js/wpProQuiz_toplist.js'
14
+ ]
15
+ };
16
+
17
+ gulp.task('css-task', function() {
18
+ return gulp
19
+ .src(paths.css)
20
+ .pipe(ext('min.css'))
21
+ .pipe(minifyCss({
22
+ compatibility: 'ie7'
23
+ }))
24
+ .pipe(gulp.dest('css'));
25
+ });
26
+
27
+ gulp.task('js-task', function() {
28
+ return gulp
29
+ .src(paths.js)
30
+ .pipe(ext('min.js'))
31
+ .pipe(uglify())
32
+ .pipe(gulp.dest('js'));
33
+ });
34
+
35
+ gulp.task('watch', function() {
36
+ gulp.watch(paths.css, ['css-task']);
37
+ gulp.watch(paths.js, ['js-task']);
38
+ });
39
+
40
+ gulp.task('default', ['css-task', 'js-task']);
js/wpProQuiz_admin.js CHANGED
@@ -1,3336 +1,3393 @@
1
- jQuery(document).ready(function($) {
2
- /**
3
- * @memberOf $.fn
4
- */
5
- $.fn.wpProQuiz_preview = function() {
6
- var methods = {
7
- openPreview: function(obj) {
8
- window.open($(obj).attr('href'), 'wpProQuizPreview', 'width=900,height=900');
9
- }
10
- };
11
-
12
- var init = function() {
13
- $('.wpProQuiz_prview').click(function(e) {
14
- methods.openPreview(this);
15
- e.preventDefault();
16
- });
17
- };
18
-
19
- init();
20
- };
21
-
22
- $.fn.wpProQuiz_quizOverall = function() {
23
-
24
- //function isEmpty(text) {
25
- // text = $.trim(text);
26
- //
27
- // return (!text || 0 === text.length);
28
- //};
29
- //
30
- //function ajaxPost(func, data, success) {
31
- // var d = {
32
- // action: 'wp_pro_quiz_admin_ajax',
33
- // func: func,
34
- // data: data
35
- // };
36
- //
37
- // $.post(ajaxurl, d, success, 'json');
38
- //};
39
- //
40
- //var methods = {
41
- // changeExport: function(input) {
42
- // $input = $(input);
43
- // $export = $('.wpProQuiz_exportList');
44
- // $export2 = $('.wpProQuiz_setQuizCategoryList');
45
- // $ul = $export.find('ul').first();
46
- // $ul2 = $export2.find('ul').first();
47
- // $export.find('li').remove();
48
- // $export2.find('li').remove();
49
- //
50
- // $('input[name="exportItems"]').each(function() {
51
- // $this = $(this);
52
- //
53
- // if(this.checked) {
54
- // var text = $this.parent().parent().find('.wpProQuiz_quizName a:eq(0)').text();
55
- // $('<li>' + text + '</li>').appendTo($ul);
56
- // $('<li>' + text + '</li>').appendTo($ul2);
57
- // }
58
- // });
59
- // },
60
- //
61
- // startExport: function() {
62
- // $ele = $('input[name="exportItems"]:checked');
63
- //
64
- // if($ele.length < 1) {
65
- // alert(wpProQuizLocalize.no_selected_quiz);
66
- // return false;
67
- // }
68
- //
69
- // $hidden = $('#exportHidden');
70
- //
71
- // $hidden.html('');
72
- //
73
- // $('input[name="exportItems"]').each(function() {
74
- // $this = $(this);
75
- //
76
- // if(this.checked) {
77
- // $('<input type="hidden" value="'+ this.value +'" name="exportIds[]">').appendTo($hidden);
78
- // }
79
- // });
80
- //
81
- // return true;
82
- // },
83
- //
84
- // setCategoriesStart: function() {
85
- // $ele = $('input[name="exportItems"]:checked');
86
- //
87
- // if($ele.length < 1) {
88
- // alert(wpProQuizLocalize.no_selected_quiz);
89
- // return false;
90
- // }
91
- //
92
- // var ids = [];
93
- //
94
- // $('input[name="exportItems"]').each(function() {
95
- // $this = $(this);
96
- //
97
- // if(this.checked) {
98
- // ids.push(this.value);
99
- // }
100
- // });
101
- //
102
- // var categoryId = $('select[name="category"]').val();
103
- //
104
- // var data = {
105
- // categoryId: categoryId,
106
- // quizIds: ids
107
- // };
108
- //
109
- // $('#ajaxLoad').show();
110
- //
111
- // ajaxPost('setQuizMultipleCategories', data, function(json) {
112
- // location.reload();
113
- // });
114
- //
115
- // return true;
116
- // },
117
- //
118
- // addCategory: function() {
119
- // var name = $.trim($('input[name="categoryAdd"]').val());
120
- //
121
- // if(isEmpty(name)) {
122
- // return;
123
- // }
124
- //
125
- // var data = {
126
- // categoryName: name,
127
- // type: 'quiz'
128
- // };
129
- //
130
- // ajaxPost('categoryAdd', data, function(json) {
131
- // if(json.err) {
132
- // $('#categoryMsgBox').text(json.err).show('fast').delay(2000).hide('fast');
133
- // return;
134
- // }
135
- //
136
- // var $option = $(document.createElement('option'))
137
- // .val(json.categoryId)
138
- // .text(json.categoryName)
139
- // .attr('selected', 'selected');
140
- //
141
- // $('select[name="category"]').append($option).change();
142
- //
143
- // });
144
- // }
145
- //};
146
- //
147
- //var init = function() {
148
- // $('.wpProQuiz_delete').click(function(e) {
149
- // var b = confirm(wpProQuizLocalize.delete_msg);
150
- //
151
- // if(!b) {
152
- // e.preventDefault();
153
- // return false;
154
- // }
155
- //
156
- // return true;
157
- // });
158
- //
159
- // $('.wpProQuiz_import').click(function(e) {
160
- // e.preventDefault();
161
- // $('.wpProQuiz_importList').show('fast');
162
- //
163
- // $('.wpProQuiz_exportList, .wpProQuiz_setQuizCategoryList').hide();
164
- // $('.wpProQuiz_exportCheck').hide();
165
- //
166
- // });
167
- //
168
- // $('.wpProQuiz_export').click(function(e) {
169
- // e.preventDefault();
170
- //
171
- // $('.wpProQuiz_exportList').show('fast');
172
- // $('.wpProQuiz_exportCheck').show('fast');
173
- // $('.wpProQuiz_importList, .wpProQuiz_setQuizCategoryList').hide();
174
- // });
175
- //
176
- // $('.wpProQuiz_setQuizCategory').click(function(e) {
177
- // e.preventDefault();
178
- //
179
- // $('.wpProQuiz_setQuizCategoryList').show('fast');
180
- // $('.wpProQuiz_exportCheck').show('fast');
181
- // $('.wpProQuiz_importList, .wpProQuiz_exportList').hide();
182
- // });
183
- //
184
- // $('input[name="exportItems"]').change(function() {
185
- // methods.changeExport(this);
186
- // });
187
- //
188
- // $('input[name="exportItemsAll"]').change(function() {
189
- // var $input = $('input[name="exportItems"]');
190
- // if(this.checked)
191
- // $input.attr('checked', true);
192
- // else
193
- // $input.attr('checked', false);
194
- //
195
- // $input.change();
196
- // });
197
- //
198
- // $('#exportStart').click(function(e) {
199
- //
200
- // if(!methods.startExport())
201
- // e.preventDefault();
202
- // });
203
- //
204
- // $('#setCategoriesStart').click(function(e) {
205
- //
206
- // if(!methods.setCategoriesStart())
207
- // e.preventDefault();
208
- // });
209
- //
210
- // $('select[name="category"]').change(function() {
211
- // var $this = $(this);
212
- // var box = $('#categoryAddBox').hide();
213
- //
214
- //
215
- // if($this.val() == "-1") {
216
- // box.show();
217
- // }
218
- //
219
- // }).change();
220
- //
221
- // $('#categoryAddBtn').click(function() {
222
- // methods.addCategory();
223
- // });
224
- //};
225
- //
226
- //init();
227
- };
228
-
229
- // $.fn.wpProQuiz_questionEdit = function() {
230
- //
231
- // var setup = function() {
232
- // if($('input[name="answerType"][checked="checked"]').size() < 1) {
233
- // $('input[name="answerType"][value="single"]').attr({'checked': 'checked'});
234
- // }
235
- //
236
- // $('input[name="answerType"]:checked').click();
237
- // $('#wpProQuiz_correctSameText').change();
238
- // $('#wpProQuiz_tip').change();
239
- // $('input[name="pointsPerAnswer"]').change();
240
- // $('input[name="answerPointsActivated"]').change();
241
- // };
242
- //
243
- // var formListener = {
244
- // setup: function() {
245
- // $('input[name="answerType"]').click(function(e) {
246
- // $('.answer_felder').children().css('display', 'none');
247
- //
248
- // switch (this.value) {
249
- // case 'single':
250
- // formListener.displaySingle('radio');
251
- // break;
252
- // case 'multiple':
253
- // formListener.displaySingle('checkbox');
254
- // break;
255
- // case 'free_answer':
256
- // formListener.displayFreeAnswer();
257
- // break;
258
- // case 'sort_answer':
259
- // formListener.displaySortAnswer();
260
- // break;
261
- // case 'matrix_sort_answer':
262
- // formListener.displayMatrixSortAnswer();
263
- // break;
264
- // case 'cloze_answer':
265
- // formListener.displayClozeAnswer();
266
- // break;
267
- // }
268
- // });
269
- //
270
- // $('.addAnswer').click(function(e) {
271
- // formListener.addAnswer(this);
272
- // });
273
- //
274
- // $('.deleteAnswer').click(function(e) {
275
- // formListener.deleteAnswer(this);
276
- // });
277
- //
278
- // $('#saveQuestion').click(function(e) {
279
- // return validate();
280
- // });
281
- //
282
- // $('.sort_answer ul, .classic_answer ul, .matrix_sort_answer ul').sortable({
283
- // handle: '.wpProQuiz_move',
284
- // update: function(event, ui) {
285
- // formListener.setValueClassicAnswer();
286
- // }
287
- // });
288
- //
289
- // $('#wpProQuiz_correctSameText').change(function() {
290
- // if(this.checked)
291
- // $('#wpProQuiz_incorrectMassageBox').hide();
292
- // else
293
- // $('#wpProQuiz_incorrectMassageBox').show();
294
- // });
295
- //
296
- // $('#wpProQuiz_tip').change(function(e) {
297
- // if(this.checked)
298
- // $('#wpProQuiz_tipBox').show();
299
- // else
300
- // $('#wpProQuiz_tipBox').hide();
301
- // });
302
- //
303
- // $('input[name="pointsPerAnswer"]').change(function() {
304
- // if(this.checked) {
305
- // $('#wpProQuiz_showPointsBox').show();
306
- // } else {
307
- // $('#wpProQuiz_showPointsBox').hide();
308
- // }
309
- // });
310
- //
311
- // $('input[name="answerPointsActivated"]').change(function() {
312
- // if(this.checked) {
313
- // $('input[name="points"]').attr('disabled', 'disabled');
314
- // $('.wpProQuiz_answerPoints').show();
315
- // $('#wpProQuiz_showPointsBox').show();
316
- // } else {
317
- // $('input[name="points"]').removeAttr('disabled');
318
- // $('.wpProQuiz_answerPoints').hide();
319
- // $('#wpProQuiz_showPointsBox').hide();
320
- // }
321
- // });
322
- //
323
- // $('.wpProQuiz_demoBox a').mouseover(function() {
324
- // $(this).next().show();
325
- // }).mouseout(function() {
326
- // $(this).next().hide();
327
- // }).click(function() {
328
- // return false;
329
- // });
330
- //
331
- // },
332
- //
333
- // displaySingle: function(type) {
334
- // $('.classic_answer').find('input[name="answerJson[classic_answer][correct][]"]').each(function() {
335
- // $("<input type=" + type + " />").attr({ name: this.name, value: this.value, checked: this.checked}).insertBefore(this);
336
- // }).remove();
337
- //
338
- // $('.classic_answer').css('display', 'block');
339
- // },
340
- //
341
- // displayFreeAnswer: function() {
342
- // $('.free_answer').css('display', 'block');
343
- // },
344
- //
345
- // displaySortAnswer: function() {
346
- // $('.sort_answer').css('display', 'block');
347
- // },
348
- //
349
- // displayMatrixSortAnswer: function() {
350
- // $('.matrix_sort_answer').show();
351
- // },
352
- //
353
- // displayClozeAnswer: function() {
354
- // $('.cloze_answer').show();
355
- // },
356
- //
357
- // addAnswer: function(obj) {
358
- // $(obj).siblings('ul').children().first()
359
- // .clone().css('display', 'block')
360
- // .appendTo($(obj).siblings('ul'));
361
- //
362
- // formListener.setValueClassicAnswer();
363
- //
364
- // $('.deleteAnswer').click(function(e) {
365
- // formListener.deleteAnswer(this);
366
- // });
367
- // },
368
- //
369
- // deleteAnswer: function(obj) {
370
- // $(obj).parent().parent('li').remove();
371
- //
372
- // formListener.setValueClassicAnswer();
373
- // },
374
- //
375
- // setValueClassicAnswer: function() {
376
- //
377
- // $('.classic_answer ul, .matrix_sort_answer ul, .sort_answer ul').children().each(function() {
378
- // var index = $(this).index();
379
- //
380
- // $(this).find( 'input[name="answerJson[classic_answer][correct][]"], '
381
- // + 'input[name="answerJson[classic_answer][html][]"], '
382
- // + 'input[name="answerJson[answer_matrix_sort][answer_html][]"], '
383
- // + 'input[name="answerJson[answer_matrix_sort][sort_string_html][]"], '
384
- // + 'input[name="answerJson[answer_sort][html][]"]').val(index);
385
- // });
386
- // }
387
- // };
388
- //
389
- // var validate = function () {
390
- //
391
- // var question = '';
392
- // var type = $('input[name="answerType"]:checked');
393
- // var $points = $('input[name="points"]');
394
- //
395
- // if(tinymce.editors.question != undefined && !tinymce.editors.question.isHidden()) {
396
- // question = tinymce.editors.question.getContent();
397
- // } else {
398
- // question = $('textarea[name="question"]').val();
399
- // }
400
- //
401
- // if(isNaN($points.val()) || $points.val() < 1) {
402
- // alert(wpProQuizLocalize.no_nummber_points);
403
- // $points.focus();
404
- // return false;
405
- // }
406
- //
407
- // if(isEmpty(question)) {
408
- // alert(wpProQuizLocalize.no_question_msg);
409
- // return false;
410
- // }
411
- //
412
- //
413
- // if(type.val() == 'single' || type.val() == 'multiple') {
414
- // var findChecked = true;
415
- // var findPoints = true;
416
- // if($('input[name="answerJson[classic_answer][correct][]"]:checked').each(function() {
417
- // if($.trim($(this).parent().parent().parent().parent().find('textarea').val()) != '') {
418
- // findChecked &= true;
419
- // } else {
420
- // findChecked = false;
421
- // }
422
- // })
423
- // .size() < 1) {
424
- // alert(wpProQuizLocalize.no_correct_msg);
425
- // return false;
426
- // }
427
- //
428
- // if($('input[name="answerPointsActivated"]:checked').length) {
429
- // $('input[name="answerJson[classic_answer][points][]"]').each(function() {
430
- // if($.trim($(this).parentsUntil('table').find('textarea').val()) != '') {
431
- // var points = $.trim($(this).val());
432
- //
433
- // if(isNaN(points) || points == '' || points < 0) {
434
- // findPoints = false;
435
- // } else {
436
- // findPoints &= true;
437
- // }
438
- // }
439
- // });
440
- //
441
- // if(!findPoints) {
442
- // alert(wpProQuizLocalize.no_nummber_points_new);
443
- // return false;
444
- // }
445
- // }
446
- //
447
- // if(!findChecked) {
448
- // alert(wpProQuizLocalize.no_answer_msg);
449
- // return false;
450
- // }
451
- // } else if(type.val() == 'sort_answer') {
452
- // var findChecked = false;
453
- // var findPoints = true;
454
- //
455
- // $('textarea[name="answerJson[answer_sort][answer][]"]').each(function() {
456
- // if(isEmpty($(this).val())) {
457
- // findChecked |= false;
458
- // } else {
459
- // findChecked = true;
460
- // }
461
- // });
462
- //
463
- // if($('input[name="answerPointsActivated"]:checked').length) {
464
- // $('input[name="answerJson[answer_sort][points][]"]').each(function() {
465
- // if($.trim($(this).parentsUntil('table').find('textarea').val()) != '') {
466
- // var points = $.trim($(this).val());
467
- //
468
- // if(isNaN(points) || points == '' || points < 0) {
469
- // findPoints = false;
470
- // } else {
471
- // findPoints &= true;
472
- // }
473
- // }
474
- // });
475
- //
476
- // if(!findPoints) {
477
- // alert(wpProQuizLocalize.no_nummber_points_new);
478
- // return false;
479
- // }
480
- // }
481
- //
482
- // if(!findChecked) {
483
- // alert(wpProQuizLocalize.no_answer_msg);
484
- // return false;
485
- // }
486
- // } else if(type.val() == 'matrix_sort_answer') {
487
- // var findChecked = false;
488
- // var findPoints = true;
489
- // $('textarea[name="answerJson[answer_matrix_sort][answer][]"]').each(function() {
490
- // if(isEmpty($(this).val())) {
491
- // findChecked |= false;
492
- // } else {
493
- //
494
- // var $sortString = $(this).parent().parent().find('textarea[name="answerJson[answer_matrix_sort][sort_string][]"]');
495
- //
496
- // if(isEmpty($sortString.val())) {
497
- // findChecked |= false;
498
- // } else {
499
- // findChecked = true;
500
- // }
501
- // }
502
- // });
503
- //
504
- // if($('input[name="answerPointsActivated"]:checked').length) {
505
- // $('input[name="answerJson[answer_matrix_sort][points][]"]').each(function() {
506
- // if($.trim($(this).parentsUntil('table').find('textarea').val()) != '') {
507
- // var points = $.trim($(this).val());
508
- //
509
- // if(isNaN(points) || points == '' || points < 0) {
510
- // findPoints = false;
511
- // } else {
512
- // findPoints &= true;
513
- // }
514
- // }
515
- // });
516
- //
517
- // if(!findPoints) {
518
- // alert(wpProQuizLocalize.no_nummber_points_new);
519
- // return false;
520
- // }
521
- // }
522
- //
523
- // if(!findChecked) {
524
- // alert(wpProQuizLocalize.no_answer_msg);
525
- // return false;
526
- // }
527
- // } else if(type.val() == 'cloze_answer') {
528
- // var clozeText = '';
529
- //
530
- // if(tinymce.editors.cloze != undefined && !tinymce.editors.cloze.isHidden()) {
531
- // clozeText = tinymce.editors.cloze.getContent();
532
- // } else {
533
- // clozeText = $('textarea[name="answerJson[answer_cloze][text]"]').val();
534
- // }
535
- //
536
- // if(isEmpty(clozeText)) {
537
- // alert(wpProQuizLocalize.no_answer_msg);
538
- // return false;
539
- // }
540
- // } else if(type.val() == 'free_answer') {
541
- // var freeText = $('textarea[name="answerJson[free_answer][correct]"]').val();
542
- //
543
- // if(isEmpty(freeText)) {
544
- // alert(wpProQuizLocalize.no_answer_msg);
545
- // return false;
546
- // }
547
- // }
548
- //
549
- // return true;
550
- // };
551
- //
552
- // var isEmpty = function(str) {
553
- // str = $.trim(str);
554
- // return (!str || 0 === str.length);
555
- // };
556
- //
557
- // formListener.setup();
558
- // setup();
559
- // };
560
-
561
- //$.fn.wpProQuiz_questionOverall = function() {
562
- //
563
- // var methode = {
564
- // saveSort: function() {
565
- //
566
- // var data = {
567
- // action: 'wp_pro_quiz_update_sort',
568
- // sort: methode.parseSortArray()
569
- // };
570
- //
571
- // var location = window.location.pathname + window.location.search;
572
- // var url = location.replace('admin.php', 'admin-ajax.php') + '&action=save_sort';
573
- //
574
- // $.post(url, data, function(response) {
575
- // $('#sortMsg').show(400).delay(1000).hide(400);
576
- // });
577
- // },
578
- //
579
- // parseSortArray: function() {
580
- // var array = new Array();
581
- //
582
- // $('tbody tr').each(function() {
583
- // array.push(this.id.replace('wpProQuiz_questionId_', ''));
584
- // });
585
- //
586
- // return array;
587
- // },
588
- //
589
- // sortUpdate: function(e, ui) {
590
- // $('.wpProQuiz_questionOverall tbody').children().each(function() {
591
- // $t = $(this).children().first().text($(this).index() + 1);
592
- // });
593
- // },
594
- //
595
- // loadQuestionCopy: function() {
596
- // var list = $('#questionCopySelect');
597
- // var location = window.location.pathname + window.location.search;
598
- // var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_question';
599
- // var data = {
600
- // action: 'wp_pro_quiz_load_question',
601
- // excludeId: 1
602
- // };
603
- //
604
- // list.hide();
605
- // list.empty();
606
- //
607
- // $('#loadDataImg').show();
608
- //
609
- // $.post(
610
- // url,
611
- // data,
612
- // function(json) {
613
- // $.each(json, function(i, v) {
614
- //
615
- // var group = $(document.createElement('optgroup'));
616
- //
617
- // group.attr('label', v.name);
618
- //
619
- // $.each(v.question, function(qi, qv) {
620
- // $(document.createElement('option'))
621
- // .val(qv.id)
622
- // .text(qv.name)
623
- // .appendTo(group);
624
- //
625
- //
626
- // });
627
- //
628
- // list.append(group);
629
- //
630
- // });
631
- //
632
- // $('#loadDataImg').hide();
633
- // list.show();
634
- // },
635
- // 'json'
636
- // );
637
- // }
638
- // };
639
- //
640
- // var init = function() {
641
- // $('.wp-list-table tbody').sortable({ handle: '.wpProQuiz_move', update: methode.sortUpdate });
642
- //
643
- // $('.wpProQuiz_delete').click(function(e) {
644
- // var b = confirm(wpProQuizLocalize.delete_msg);
645
- //
646
- // if(!b) {
647
- // e.preventDefault();
648
- // return false;
649
- // }
650
- //
651
- // return true;
652
- // });
653
- //
654
- // $('#wpProQuiz_saveSort').click(function(e) {
655
- // e.preventDefault();
656
- // methode.saveSort();
657
- // });
658
- //
659
- // $('#wpProQuiz_questionCopy').click(function(e) {
660
- // var $this = $('.wpProQuiz_questionCopy');
661
- //
662
- // if($this.is(':visible')) {
663
- // $this.hide();
664
- // } else {
665
- // $this.show();
666
- // methode.loadQuestionCopy();
667
- // }
668
- //
669
- // e.preventDefault();
670
- // });
671
- // };
672
- //
673
- // init();
674
- //};
675
-
676
- $.fn.wpProQuiz_quizEdit = function() {
677
-
678
- function ajaxPost(func, data, success) {
679
- var d = {
680
- action: 'wp_pro_quiz_admin_ajax',
681
- func: func,
682
- data: data
683
- };
684
-
685
- $.post(ajaxurl, d, success, 'json');
686
- };
687
-
688
- var methode = {
689
- addCategory: function() {
690
- var name = $.trim($('input[name="categoryAdd"]').val());
691
-
692
- if(isEmpty(name)) {
693
- return;
694
- }
695
-
696
- var data = {
697
- categoryName: name,
698
- type: 'quiz'
699
- };
700
-
701
- ajaxPost('categoryAdd', data, function(json) {
702
- if(json.err) {
703
- $('#categoryMsgBox').text(json.err).show('fast').delay(2000).hide('fast');
704
- return;
705
- }
706
-
707
- var $option = $(document.createElement('option'))
708
- .val(json.categoryId)
709
- .text(json.categoryName)
710
- .attr('selected', 'selected');
711
-
712
- $('select[name="category"]').append($option).change();
713
-
714
- });
715
- },
716
-
717
- addResult: function() {
718
- $('#resultList').children().each(function() {
719
- if($(this).css('display') == 'none') {
720
- //TODO rework
721
- var $this = $(this);
722
- var $text = $this.find('textarea[name="resultTextGrade[text][]"]');
723
- var id = $text.attr('id');
724
- var hidden = true;
725
-
726
- $this.find('input[name="resultTextGrade[prozent][]"]').val('0');
727
- $this.find('input[name="resultTextGrade[activ][]"]').val('1').keyup();
728
-
729
- if(tinymce.editors[id] != undefined && !tinymce.editors[id].isHidden()) {
730
- hidden = false;
731
- }
732
-
733
- if(switchEditors != undefined && !hidden) {
734
- switchEditors.go(id, 'toggle');
735
- switchEditors.go(id, 'toggle');
736
- }
737
-
738
- if(tinymce.editors[id] != undefined) {
739
- tinymce.editors[id].setContent('');
740
- } else {
741
- $text.val('');
742
- }
743
-
744
- if(tinymce.editors[id] != undefined && !hidden) {
745
- tinyMCE.execCommand('mceRemoveControl', false, id);
746
- }
747
-
748
- $this.parent().children(':visible').last().after($this);
749
-
750
- if(tinymce.editors[id] != undefined && !hidden) {
751
- tinyMCE.execCommand('mceAddControl', false, id);
752
- }
753
-
754
- $(this).show();
755
-
756
- if(switchEditors != undefined && !hidden) {
757
- switchEditors.go(id, 'toggle');
758
- }
759
-
760
-
761
- return false;
762
- }
763
- });
764
- },
765
-
766
- deleteResult: function(e) {
767
- $(e).parent().parent().hide();
768
- $(e).siblings('input[name="resultTextGrade[activ][]"]').val('0');
769
- },
770
-
771
- changeResult: function(e) {
772
- var $this = $(e);
773
-
774
- if(methode.validResultInput($this.val())) {
775
- $this.siblings('.resultProzent').text($this.val());
776
- $this.removeAttr('style');
777
- return true;
778
- }
779
-
780
- $this.css('background-color', '#FF9696');
781
-
782
- return false;
783
- },
784
-
785
- validResultInput: function(input) {
786
-
787
- if(isEmpty(input))
788
- return false;
789
-
790
- input = input.replace(/\,/, '.');
791
-
792
- if(!isNaN(input) && Number(input) <= 100 && Number(input) >= 0) {
793
- if(input.match(/\./) != null)
794
- return input.split('.')[1].length < 3;
795
-
796
- return true;
797
- }
798
-
799
- return false;
800
- },
801
-
802
- validInput: function() {
803
- if(isEmpty($('#wpProQuiz_title').val())) {
804
- alert(wpProQuizLocalize.no_title_msg);
805
- return false;
806
- }
807
-
808
- var text = '';
809
-
810
- if(tinymce.editors.text != undefined && !tinymce.editors.text.isHidden()) {
811
- text = tinymce.editors.text.getContent();
812
- } else {
813
- text = $('textarea[name="text"]').val();
814
- }
815
-
816
- if(isEmpty(text)) {
817
- alert(wpProQuizLocalize.no_quiz_start_msg);
818
- return false;
819
- }
820
-
821
- if($('#wpProQuiz_resultGradeEnabled:checked').length) {
822
- var rCheck = true;
823
-
824
- $('#resultList').children().each(function() {
825
- if($(this).is(':visible')) {
826
- if(!methode.validResultInput($(this).find('input[name="resultTextGrade[prozent][]"]').val())) {
827
- rCheck = false;
828
- return false;
829
- }
830
- }
831
- });
832
-
833
- if(!rCheck) {
834
- alert(wpProQuizLocalize.fail_grade_result);
835
- return false;
836
- }
837
- }
838
-
839
- return true;
840
- },
841
-
842
- resetLock: function() {
843
- var location = window.location.pathname + window.location.search;
844
- var url = location.replace('admin.php', 'admin-ajax.php');
845
- url = url.replace('action=edit', 'action=reset_lock');
846
-
847
- $.post(url, {
848
- action: 'wp_pro_quiz_reset_lock'
849
- }, function(data) {
850
- $('#resetLockMsg').show('fast').delay(2000).hide('fast');
851
- });
852
- },
853
-
854
- generateFormIds: function() {
855
- var index = 0;
856
-
857
- $('#form_table tbody > tr').each(function() {
858
- $(this).find('[name^="form[]"]').each(function() {
859
- var newname = $(this).attr('name').substr(6);
860
- $(this).attr('name', 'form[' + index + ']' + newname);
861
- });
862
-
863
- ++index;
864
- });
865
- },
866
-
867
- updateFormIds: function() {
868
- var index = -1;
869
- var selected = $('.emailFormVariables option:selected').val();
870
- var $formVariables = $('.formVariables').empty();
871
- var $emailFormVariables = $('.emailFormVariables').empty().append('<option value="-1"></option>');
872
-
873
- if($('.emailFormVariables').data('default') > -1) {
874
- selected = $('.emailFormVariables').data('default');
875
- $('.emailFormVariables').data('default', -1);
876
- }
877
-
878
- $('#form_table tbody > tr').each(function() {
879
- $(this).children().first().text(index);
880
- var fieldName = $(this).find('.formFieldName').val();
881
- var type = $(this).find('[name="form[][type]"] option:selected');
882
- var name = $(this).find('[name="form[][fieldname]"]').val();
883
-
884
- //is deleted?
885
- if($(this).find('input[name="form[][form_delete]"]').val() == 1)
886
- return;
887
-
888
- if(index >= 0 && !isEmpty(fieldName))
889
- $formVariables.append($('<li><span>$form{' + index + '}</span> - ' + fieldName + '</li>'));
890
-
891
- if(type.val() == 4)
892
- $emailFormVariables.append($('<option value="' + index + '">' + name + '</option>'))
893
-
894
- index++;
895
- });
896
-
897
- $('.emailFormVariables option[value="' + selected + '"]').prop('selected', true);
898
- }
899
-
900
- };
901
-
902
- var isEmpty = function(str) {
903
- str = $.trim(str);
904
- return (!str || 0 === str.length);
905
- };
906
-
907
- var init = function() {
908
- $('#statistics_on').change(function() {
909
- if(this.checked) {
910
- $('#statistics_ip_lock_tr').show();
911
- } else {
912
- $('#statistics_ip_lock_tr').hide();
913
- }
914
- });
915
-
916
- $('.addResult').click(function() {
917
- methode.addResult();
918
- });
919
-
920
- $('.deleteResult').click(function (e) {
921
- methode.deleteResult(this);
922
- });
923
-
924
- $('input[name="resultTextGrade[prozent][]"]').keyup(function(event) {
925
- methode.changeResult(this);
926
- }).keydown(function(event) {
927
- if(event.which == 13) {
928
- event.preventDefault();
929
- }
930
- });
931
-
932
- $('#wpProQuiz_resultGradeEnabled').change(function() {
933
- if(this.checked) {
934
- $('#resultGrade').show();
935
- $('#resultNormal').hide();
936
- } else {
937
- $('#resultGrade').hide();
938
- $('#resultNormal').show();
939
- }
940
- });
941
-
942
- $('#wpProQuiz_save').click(function(e) {
943
- if(!methode.validInput())
944
- e.preventDefault();
945
- else
946
- methode.generateFormIds();
947
-
948
- $('select[name="prerequisiteList[]"] option').attr('selected', 'selected');
949
- });
950
-
951
- $('input[name="template"]').click(function(e) {
952
- if($('select[name="templateSaveList"]').val() == '0') {
953
- if(isEmpty($('input[name="templateName"]').val())) {
954
- alert(wpProQuizLocalize.temploate_no_name);
955
-
956
- e.preventDefault();
957
- return false;
958
- }
959
- }
960
-
961
- methode.generateFormIds();
962
- $('select[name="prerequisiteList[]"] option').attr('selected', 'selected');
963
- });
964
-
965
- $('select[name="templateSaveList"]').change(function() {
966
- var $templateName = $('input[name="templateName"]');
967
-
968
- if($(this).val() == '0') {
969
- $templateName.show();
970
- } else {
971
- $templateName.hide();
972
- }
973
- }).change();
974
-
975
- $('input[name="quizRunOnce"]').change(function(e) {
976
- if(this.checked) {
977
- $('#wpProQuiz_quiz_run_once_type').show();
978
- $('input[name="quizRunOnceType"]:checked').change();
979
- } else {
980
- $('#wpProQuiz_quiz_run_once_type').hide();
981
- }
982
- });
983
-
984
- $('input[name="quizRunOnceType"]').change(function(e) {
985
- if(this.checked && (this.value == "1" || this.value == "3")) {
986
- $('#wpProQuiz_quiz_run_once_cookie').show();
987
- } else {
988
- $('#wpProQuiz_quiz_run_once_cookie').hide();
989
- }
990
- });
991
-
992
- $('input[name="resetQuizLock"]').click(function(e) {
993
- methode.resetLock();
994
-
995
- return false;
996
- });
997
-
998
- $('.wpProQuiz_demoBox a').mouseover(function(e) {
999
- var $this = $(this);
1000
- var d = $('#poststuff').width();
1001
- var img = $this.siblings().outerWidth(true);
1002
-
1003
- if(e.pageX + img > d) {
1004
- //var v = d + (e.pageX - (e.pageX + img + 30));
1005
- var v = jQuery(document).width() - $this.parent().offset().left - img - 30;
1006
- $(this).next().css('left', v + "px");
1007
- }
1008
-
1009
- $(this).next().show();
1010
-
1011
- }).mouseout(function() {
1012
- $(this).next().hide();
1013
- }).click(function() {
1014
- return false;
1015
- });
1016
-
1017
- $('input[name="showMaxQuestion"]').change(function() {
1018
- if(this.checked) {
1019
- // $('input[name="statisticsOn"]').removeAttr('checked').attr('disabled', 'disabled').change();
1020
- $('#wpProQuiz_showMaxBox').show();
1021
- } else {
1022
- // $('input[name="statisticsOn"]').removeAttr('disabled');
1023
- $('#wpProQuiz_showMaxBox').hide();
1024
- }
1025
- });
1026
-
1027
- $('#btnPrerequisiteAdd').click(function() {
1028
- $('select[name="quizList"] option:selected').removeAttr('selected').appendTo('select[name="prerequisiteList[]"]');
1029
- });
1030
-
1031
- $('#btnPrerequisiteDelete').click(function() {
1032
- $('select[name="prerequisiteList[]"] option:selected').removeAttr('selected').appendTo('select[name="quizList"]');
1033
- });
1034
-
1035
- $('input[name="prerequisite"]').change(function() {
1036
- if(this.checked)
1037
- $('#prerequisiteBox').show();
1038
- else
1039
- $('#prerequisiteBox').hide();
1040
-
1041
-
1042
- }).change();
1043
-
1044
- $('input[name="toplistDataAddMultiple"]').change(function() {
1045
- if(this.checked)
1046
- $('#toplistDataAddBlockBox').show();
1047
- else
1048
- $('#toplistDataAddBlockBox').hide();
1049
-
1050
- }).change();
1051
-
1052
- $('input[name="toplistActivated"]').change(function() {
1053
- if(this.checked)
1054
- $('#toplistBox > tr:gt(0)').show();
1055
- else
1056
- $('#toplistBox > tr:gt(0)').hide();
1057
-
1058
- }).change();
1059
-
1060
- $('input[name="showReviewQuestion"]').change(function() {
1061
- if(this.checked) {
1062
- $('.wpProQuiz_reviewQuestionOptions').show();
1063
- } else {
1064
- $('.wpProQuiz_reviewQuestionOptions').hide();
1065
- }
1066
- }).change();
1067
-
1068
- $('#statistics_on').change();
1069
- $('#wpProQuiz_resultGradeEnabled').change();
1070
- $('input[name="quizRunOnce"]').change();
1071
- $('input[name="quizRunOnceType"]:checked').change();
1072
- $('input[name="showMaxQuestion"]').change();
1073
-
1074
- $('#form_add').click(function() {
1075
- $('#form_table tbody > tr:eq(0)').clone(true).appendTo('#form_table tbody').show();
1076
- methode.updateFormIds();
1077
- });
1078
-
1079
- $('input[name="form_delete"]').click(function() {
1080
- var con = $(this).parents('tr');
1081
-
1082
- if(con.find('input[name="form[][form_id]"]').val() != "0") {
1083
- con.find('input[name="form[][form_delete]"]').val(1);
1084
- con.hide();
1085
- } else {
1086
- con.remove();
1087
- }
1088
-
1089
- methode.updateFormIds();
1090
- });
1091
-
1092
- $('#form_table tbody').sortable({ handle: '.form_move', update: methode.updateFormIds });
1093
- $('.form_move').click(function() {
1094
- return false;
1095
- });
1096
-
1097
- $('select[name="form[][type]"]').change(function() {
1098
- switch (Number($(this).val())) {
1099
- case 7:
1100
- case 8:
1101
- $(this).siblings('.editDropDown').show();
1102
- break;
1103
- default:
1104
- $(this).siblings('.editDropDown, .dropDownEditBox').hide();
1105
- break;
1106
- }
1107
-
1108
- }).change();
1109
-
1110
- $('.editDropDown').click(function() {
1111
- $('.dropDownEditBox').not(
1112
- $(this).siblings('.dropDownEditBox').toggle())
1113
- .hide();
1114
-
1115
- return false;
1116
- });
1117
-
1118
- $('.dropDownEditBox input').click(function() {
1119
- $(this).parent().hide();
1120
- });
1121
-
1122
- $('.formFieldName, select[name="form[][type]"]').change(function() {
1123
- methode.updateFormIds();
1124
- });
1125
-
1126
- $('select[name="category"]').change(function() {
1127
- var $this = $(this);
1128
- var box = $('#categoryAddBox').hide();
1129
-
1130
-
1131
- if($this.val() == "-1") {
1132
- box.show();
1133
- }
1134
-
1135
- }).change();
1136
-
1137
- $('#categoryAddBtn').click(function() {
1138
- methode.addCategory();
1139
- });
1140
-
1141
- $('input[name="emailNotification"]').change(function() {
1142
- var $tr = $('#adminEmailSettings tr:gt(0)');
1143
-
1144
- if($('input[name="emailNotification"]:checked').val() > 0) {
1145
- $tr.show();
1146
- } else {
1147
- $tr.hide();
1148
- }
1149
- }).change();
1150
-
1151
- $('input[name="userEmailNotification"]').change(function() {
1152
- var $tr = $('#userEmailSettings tr:gt(0)');
1153
-
1154
- if($('input[name="userEmailNotification"]:checked').val() > 0) {
1155
- $tr.show();
1156
- } else {
1157
- $tr.hide();
1158
- }
1159
- }).change();
1160
-
1161
- methode.updateFormIds();
1162
-
1163
- $('input[name="email[html]"]').change(function() {
1164
- if(switchEditors == undefined)
1165
- return false;
1166
-
1167
- if(this.checked) {
1168
- switchEditors.go('adminEmailEditor', 'tmce');
1169
- } else {
1170
- switchEditors.go('adminEmailEditor', 'html');
1171
- }
1172
-
1173
- }).change();
1174
-
1175
- $('input[name="userEmail[html]"]').change(function() {
1176
- if(switchEditors == undefined)
1177
- return false;
1178
-
1179
- if(this.checked) {
1180
- switchEditors.go('userEmailEditor', 'tmce');
1181
- } else {
1182
- switchEditors.go('userEmailEditor', 'html');
1183
- }
1184
-
1185
- }).change();
1186
- };
1187
-
1188
- init();
1189
- };
1190
-
1191
- $.fn.wpProQuiz_statistics = function() {
1192
- var currectTab = 'wpProQuiz_typeAnonymeUser';
1193
- var changePageNav = true;
1194
-
1195
- var methode = {
1196
- loadStatistics: function(userId) {
1197
- var location = window.location.pathname + window.location.search;
1198
- var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_statistics';
1199
- var data = {
1200
- action: 'wp_pro_quiz_load_statistics',
1201
- userId: userId
1202
- };
1203
-
1204
- $('#wpProQuiz_loadData').show();
1205
- $('#wpProQuiz_statistics_content, #wpProQuiz_statistics_overview').hide();
1206
-
1207
- $.post(
1208
- url,
1209
- data,
1210
- methode.setStatistics,
1211
- 'json'
1212
- );
1213
- },
1214
-
1215
- setStatistics: function(json) {
1216
- var $table = $('.wpProQuiz_statistics_table');
1217
- var $tbody = $table.find('tbody');
1218
-
1219
- if(currectTab == 'wpProQuiz_typeOverview') {
1220
- return;
1221
- }
1222
-
1223
- var setItem = function(i, j, r) {
1224
- i.find('.wpProQuiz_cCorrect').text(j.cCorrect + ' (' + j.pCorrect + '%)');
1225
- i.find('.wpProQuiz_cIncorrect').text(j.cIncorrect + ' (' + j.pIncorrect + '%)');
1226
- i.find('.wpProQuiz_cTip').text(j.cTip);
1227
- i.find('.wpProQuiz_cPoints').text(j.cPoints);
1228
-
1229
- if(r == true) {
1230
- $table.find('.wpProQuiz_cResult').text(j.result + '%');
1231
- }
1232
- };
1233
-
1234
- setItem($table, json.clear, false);
1235
-
1236
- $.each(json.items, function(i, v) {
1237
- setItem($tbody.find('#wpProQuiz_tr_' + v.id), v, false);
1238
- });
1239
-
1240
- setItem($table.find('tfoot'), json.global, true);
1241
-
1242
- $('#wpProQuiz_loadData').hide();
1243
- $('#wpProQuiz_statistics_content, .wpProQuiz_statistics_table').show();
1244
- },
1245
-
1246
- loadOverview: function() {
1247
- $('.wpProQuiz_statistics_table, #wpProQuiz_statistics_content, #wpProQuiz_statistics_overview').hide();
1248
- $('#wpProQuiz_loadData').show();
1249
-
1250
- var location = window.location.pathname + window.location.search;
1251
- var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_statistics';
1252
- var data = {
1253
- action: 'wp_pro_quiz_load_statistics',
1254
- overview: true,
1255
- pageLimit: $('#wpProQuiz_pageLimit').val(),
1256
- onlyCompleted: Number($('#wpProQuiz_onlyCompleted').is(':checked')),
1257
- page: $('#wpProQuiz_currentPage').val(),
1258
- generatePageNav: Number(changePageNav)
1259
- };
1260
-
1261
- $.post(
1262
- url,
1263
- data,
1264
- function(json) {
1265
- $('#wpProQuiz_statistics_overview_data').empty();
1266
-
1267
- if(currectTab != 'wpProQuiz_typeOverview') {
1268
- return;
1269
- }
1270
-
1271
- var item = $( '<tr>'
1272
- + '<th><a href="#">---</a></th>'
1273
- + '<th class="wpProQuiz_points">---</th>'
1274
- + '<th class="wpProQuiz_cCorrect" style="color: green;">---</th>'
1275
- + '<th class="wpProQuiz_cIncorrect" style="color: red;">---</th>'
1276
- + '<th class="wpProQuiz_cTip">---</th>'
1277
- + '<th class="wpProQuiz_cResult" style="font-weight: bold;">---</th>'
1278
- + '</tr>'
1279
- );
1280
-
1281
- $.each(json.items, function(i, v) {
1282
- var d = item.clone();
1283
-
1284
- d.find('a').text(v.userName).data('userId', v.userId).click(function() {
1285
- $('#userSelect').val($(this).data('userId'));
1286
-
1287
- $('#wpProQuiz_typeRegisteredUser').click();
1288
-
1289
- return false;
1290
- });
1291
-
1292
- if(v.completed) {
1293
- d.find('.wpProQuiz_points').text(v.cPoints);
1294
- d.find('.wpProQuiz_cCorrect').text(v.cCorrect + ' (' + v.pCorrect + '%)');
1295
- d.find('.wpProQuiz_cIncorrect').text(v.cIncorrect + ' (' + v.pIncorrect + '%)');
1296
- d.find('.wpProQuiz_cTip').text(v.cTip);
1297
- d.find('.wpProQuiz_cResult').text(v.result + '%');
1298
- } else {
1299
- d.find('th').removeAttr('style');
1300
- }
1301
-
1302
- $('#wpProQuiz_statistics_overview_data').append(d);
1303
- });
1304
-
1305
- if(json.page != undefined) {
1306
- methode.setPageNav(json.page);
1307
- changePageNav = false;
1308
- }
1309
-
1310
- $('#wpProQuiz_loadData').hide();
1311
- $('#wpProQuiz_statistics_overview').show();
1312
- },
1313
- 'json'
1314
- );
1315
- },
1316
-
1317
- loadFormOverview: function() {
1318
- $('#wpProQuiz_tabFormOverview').show();
1319
- },
1320
-
1321
- changeTab: function(id) {
1322
- currectTab = id;
1323
-
1324
- if(id == 'wpProQuiz_typeRegisteredUser') {
1325
- methode.loadStatistics($('#userSelect').val());
1326
- } else if( id == 'wpProQuiz_typeAnonymeUser') {
1327
- methode.loadStatistics(0);
1328
- } else if(id == 'wpProQuiz_typeForm') {
1329
- methode.loadFormOverview();
1330
- } else {
1331
- methode.loadOverview();
1332
- }
1333
- },
1334
-
1335
- resetStatistic: function(complete) {
1336
- var userId = (currectTab == 'wpProQuiz_typeRegisteredUser') ? $('#userSelect').val() : 0;
1337
- var location = window.location.pathname + window.location.search;
1338
- var url = location.replace('admin.php', 'admin-ajax.php') + '&action=reset';
1339
- var data = {
1340
- action: 'wp_pro_quiz_statistics',
1341
- userId: userId,
1342
- 'complete': complete
1343
- };
1344
-
1345
- $.post(url, data, function(e) {
1346
- methode.changeTab(currectTab);
1347
- });
1348
- },
1349
-
1350
- setPageNav: function(page) {
1351
- page = Math.ceil(page / $('#wpProQuiz_pageLimit').val());
1352
- $('#wpProQuiz_currentPage').empty();
1353
-
1354
- for(var i = 1; i <= page; i++) {
1355
- $(document.createElement('option'))
1356
- .val(i)
1357
- .text(i)
1358
- .appendTo($('#wpProQuiz_currentPage'));
1359
- }
1360
-
1361
- $('#wpProQuiz_pageLeft, #wpProQuiz_pageRight').hide();
1362
-
1363
- if($('#wpProQuiz_currentPage option').length > 1) {
1364
- $('#wpProQuiz_pageRight').show();
1365
-
1366
- }
1367
- }
1368
- };
1369
-
1370
- var init = function() {
1371
- $('.wpProQuiz_tab').click(function(e) {
1372
- var $this = $(this);
1373
-
1374
- if($this.hasClass('button-primary')) {
1375
- return false;
1376
- }
1377
-
1378
- if($this.attr('id') == 'wpProQuiz_typeRegisteredUser') {
1379
- $('#wpProQuiz_userBox').show();
1380
- } else {
1381
- $('#wpProQuiz_userBox').hide();
1382
- }
1383
-
1384
- $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
1385
- $this.removeClass('button-secondary').addClass('button-primary');
1386
-
1387
- methode.changeTab($this.attr('id'));
1388
-
1389
- return false;
1390
- });
1391
-
1392
- $('#userSelect').change(function() {
1393
- methode.changeTab('wpProQuiz_typeRegisteredUser');
1394
- });
1395
-
1396
- $('.wpProQuiz_update').click(function() {
1397
- methode.changeTab(currectTab);
1398
-
1399
- return false;
1400
- });
1401
-
1402
- $('#wpProQuiz_reset').click(function() {
1403
-
1404
- var c =confirm(wpProQuizLocalize.reset_statistics_msg);
1405
-
1406
- if(c) {
1407
- methode.resetStatistic(false);
1408
- }
1409
-
1410
-
1411
- return false;
1412
- });
1413
-
1414
- $('.wpProQuiz_resetComplete').click(function() {
1415
-
1416
- var c =confirm(wpProQuizLocalize.reset_statistics_msg);
1417
-
1418
- if(c) {
1419
- methode.resetStatistic(true);
1420
- }
1421
-
1422
- return false;
1423
- });
1424
-
1425
- $('#wpProQuiz_pageLimit, #wpProQuiz_onlyCompleted').change(function() {
1426
- $('#wpProQuiz_currentPage').val(0);
1427
- changePageNav = true;
1428
- methode.changeTab(currectTab);
1429
-
1430
- return false;
1431
- });
1432
-
1433
- $('#wpProQuiz_currentPage').change(function() {
1434
- $('#wpProQuiz_pageLeft, #wpProQuiz_pageRight').hide();
1435
-
1436
- if($('#wpProQuiz_currentPage option').length == 1) {
1437
-
1438
- } else if($('#wpProQuiz_currentPage option:first-child:selected').length) {
1439
- $('#wpProQuiz_pageRight').show();
1440
- } else if($('#wpProQuiz_currentPage option:last-child:selected').length) {
1441
- $('#wpProQuiz_pageLeft').show();
1442
- }else {
1443
- $('#wpProQuiz_pageLeft, #wpProQuiz_pageRight').show();
1444
- }
1445
-
1446
- methode.changeTab(currectTab);
1447
- });
1448
-
1449
- $('#wpProQuiz_pageRight').click(function() {
1450
- $('#wpProQuiz_currentPage option:selected').next().attr('selected', 'selected');
1451
- $('#wpProQuiz_currentPage').change();
1452
-
1453
- return false;
1454
- });
1455
-
1456
- $('#wpProQuiz_pageLeft').click(function() {
1457
- $('#wpProQuiz_currentPage option:selected').prev().attr('selected', 'selected');
1458
- $('#wpProQuiz_currentPage').change();
1459
-
1460
- return false;
1461
- });
1462
-
1463
- methode.changeTab('wpProQuiz_typeAnonymeUser');
1464
- };
1465
-
1466
- init();
1467
- };
1468
-
1469
- $.fn.wpProQuiz_toplist = function() {
1470
- var elements = {
1471
- sort: $('#wpProQuiz_sorting'),
1472
- pageLimit: $('#wpProQuiz_pageLimit'),
1473
- currentPage: $('#wpProQuiz_currentPage'),
1474
- loadDataBox: $('#wpProQuiz_loadData'),
1475
- pageLeft: $('#wpProQuiz_pageLeft'),
1476
- pageRight: $('#wpProQuiz_pageRight'),
1477
- dataBody: $('#wpProQuiz_toplistTable tbody'),
1478
- rowClone: $('#wpProQuiz_toplistTable tbody tr:eq(0)').clone(),
1479
- content: $('#wpProQuiz_content')
1480
- };
1481
-
1482
- var methods = {
1483
- loadData: function(action) {
1484
- var location = window.location.pathname + window.location.search;
1485
- var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_toplist';
1486
- var th = this;
1487
- var data = {
1488
- action: 'wp_pro_quiz_load_toplist',
1489
- sort: elements.sort.val(),
1490
- limit: elements.pageLimit.val(),
1491
- page: elements.currentPage.val()
1492
- };
1493
-
1494
- if(action != undefined) {
1495
- $.extend(data, action);
1496
- }
1497
-
1498
- elements.loadDataBox.show();
1499
- elements.content.hide();
1500
-
1501
- $.post(url, data, function(json) {
1502
- //methods.handleDataRequest(json.data);
1503
- th.handleDataRequest(json.data);
1504
-
1505
- if(json.nav != undefined) {
1506
- //methods.handleNav(json.nav);
1507
- th.handleNav(json.nav);
1508
- }
1509
-
1510
- elements.loadDataBox.hide();
1511
- elements.content.show();
1512
- }, 'json');
1513
- },
1514
-
1515
- handleNav: function(nav) {
1516
- elements.currentPage.empty();
1517
-
1518
- for(var i = 1; i <= nav.pages; i++) {
1519
- $(document.createElement('option'))
1520
- .val(i).text(i)
1521
- .appendTo(elements.currentPage);
1522
- }
1523
-
1524
- this.checkNav();
1525
- },
1526
-
1527
- handleDataRequest: function(json) {
1528
- var methods = this;
1529
-
1530
- elements.dataBody.empty();
1531
-
1532
- $.each(json, function(i, v) {
1533
- var data = elements.rowClone.clone().children();
1534
-
1535
- data.eq(0).children().val(v.id);
1536
- data.eq(1).find('strong').text(v.name);
1537
- data.eq(1).find('.inline_editUsername').val(v.name);
1538
- data.eq(2).find('.wpProQuiz_email').text(v.email);
1539
- data.eq(2).find('input').val(v.email);
1540
- data.eq(3).text(v.type);
1541
- data.eq(4).text(v.date);
1542
- data.eq(5).text(v.points);
1543
- data.eq(6).text(v.result);
1544
-
1545
- data.parent().show().appendTo(elements.dataBody);
1546
- });
1547
-
1548
- if(!json.length) {
1549
- $(document.createElement('td'))
1550
- .attr('colspan', '7')
1551
- .text(wpProQuizLocalize.no_data_available)
1552
- .css({'font-weight': 'bold', 'text-align': 'center', 'padding': '5px'})
1553
- .appendTo(document.createElement('tr'))
1554
- .appendTo(elements.dataBody);
1555
- }
1556
-
1557
- $('.wpProQuiz_delete').click(function() {
1558
- if(confirm(wpProQuizLocalize.confirm_delete_entry)) {
1559
- var id = new Array($(this).closest('tr').find('input[name="checkedData[]"]').val());
1560
-
1561
- methods.loadData({a: 'delete', toplistIds: id});
1562
- }
1563
-
1564
- return false;
1565
- });
1566
-
1567
- $('.wpProQuiz_edit').click(function() {
1568
- var $contain = $(this).closest('tr');
1569
-
1570
- $contain.find('.row-actions').hide();
1571
- $contain.find('.inline-edit').show();
1572
-
1573
- $contain.find('.wpProQuiz_username, .wpProQuiz_email').hide();
1574
- $contain.find('.inline_editUsername, .inline_editEmail').show();
1575
-
1576
- return false;
1577
- });
1578
-
1579
- $('.inline_editSave').click(function() {
1580
- var $contain = $(this).closest('tr');
1581
- var username = $contain.find('.inline_editUsername').val();
1582
- var email = $contain.find('.inline_editEmail').val();
1583
-
1584
- if(methods.isEmpty(username) || methods.isEmpty(email)) {
1585
- alert(wpProQuizLocalize.not_all_fields_completed);
1586
-
1587
- return false;
1588
- }
1589
-
1590
- methods.loadData({
1591
- a: 'edit',
1592
- toplistId: $contain.find('input[name="checkedData[]"]').val(),
1593
- name: username,
1594
- email: email
1595
- });
1596
-
1597
- return false;
1598
- });
1599
-
1600
- $('.inline_editCancel').click(function() {
1601
- var $contain = $(this).closest('tr');
1602
-
1603
- $contain.find('.row-actions').show();
1604
- $contain.find('.inline-edit').hide();
1605
-
1606
- $contain.find('.wpProQuiz_username, .wpProQuiz_email').show();
1607
- $contain.find('.inline_editUsername, .inline_editEmail').hide();
1608
-
1609
- $contain.find('.inline_editUsername').val($contain.find('.wpProQuiz_username').text());
1610
- $contain.find('.inline_editEmail').val($contain.find('.wpProQuiz_email').text());
1611
-
1612
- return false;
1613
- });
1614
- },
1615
-
1616
- checkNav: function() {
1617
- var n = elements.currentPage.val();
1618
-
1619
- if(n == 1) {
1620
- elements.pageLeft.hide();
1621
- } else {
1622
- elements.pageLeft.show();
1623
- }
1624
-
1625
- if(n == elements.currentPage.children().length) {
1626
- elements.pageRight.hide();
1627
- } else {
1628
- elements.pageRight.show();
1629
- }
1630
- },
1631
-
1632
- isEmpty: function(text) {
1633
- text = $.trim(text);
1634
-
1635
- return (!text || 0 === text.length);
1636
- }
1637
- };
1638
-
1639
- var init = function() {
1640
- elements.sort.change(function() {
1641
- methods.loadData();
1642
- });
1643
-
1644
- elements.pageLimit.change(function() {
1645
- methods.loadData({nav: 1});
1646
- });
1647
-
1648
- elements.currentPage.change(function() {
1649
- methods.checkNav();
1650
- methods.loadData();
1651
- });
1652
-
1653
- elements.pageLeft.click(function() {
1654
- elements.currentPage.val(Number(elements.currentPage.val()) - 1);
1655
- methods.checkNav();
1656
- methods.loadData();
1657
- });
1658
-
1659
- elements.pageRight.click(function() {
1660
- elements.currentPage.val(Number(elements.currentPage.val()) + 1);
1661
- methods.checkNav();
1662
- methods.loadData();
1663
- });
1664
-
1665
- $('#wpProQuiz_deleteAll').click(function() {
1666
- methods.loadData({a: 'deleteAll'});
1667
- });
1668
-
1669
- $('#wpProQuiz_action').click(function() {
1670
- var name = $('#wpProQuiz_actionName').val();
1671
-
1672
- if(name != '0') {
1673
-
1674
- var ids = $('input[name="checkedData[]"]:checked').map(function() {
1675
- return $(this).val();
1676
- }).get();
1677
-
1678
- methods.loadData({a: name, toplistIds: ids});
1679
- }
1680
- });
1681
-
1682
- $('#wpProQuiz_checkedAll').change(function() {
1683
- if(this.checked)
1684
- $('input[name="checkedData[]"]').attr('checked', 'checked');
1685
- else
1686
- $('input[name="checkedData[]"]').removeAttr('checked', 'checked');
1687
- });
1688
-
1689
- methods.loadData({nav: 1});
1690
- };
1691
-
1692
- init();
1693
- };
1694
-
1695
-
1696
- if($('.wpProQuiz_quizOverall').length)
1697
- $('.wpProQuiz_quizOverall').wpProQuiz_preview();
1698
-
1699
- if($('.wpProQuiz_quizOverall').length) {
1700
- $('.wpProQuiz_quizOverall').wpProQuiz_quizOverall();
1701
- }
1702
-
1703
- if($('.wpProQuiz_quizEdit').length)
1704
- $('.wpProQuiz_quizEdit').wpProQuiz_quizEdit();
1705
-
1706
- // if($('.wpProQuiz_questionEdit').length)
1707
- // $('.wpProQuiz_questionEdit').wpProQuiz_questionEdit();
1708
-
1709
- //if($('.wpProQuiz_questionOverall').length)
1710
- // $('.wpProQuiz_questionOverall').wpProQuiz_questionOverall();
1711
-
1712
- // if($('.wpProQuiz_statistics').length)
1713
- // $('.wpProQuiz_statistics').wpProQuiz_statistics();
1714
-
1715
- if($('.wpProQuiz_toplist').length)
1716
- $('.wpProQuiz_toplist').wpProQuiz_toplist();
1717
-
1718
- /**
1719
- * NEW
1720
- */
1721
- /**
1722
- * @memberOf WpProQuiz_Admin
1723
- */
1724
- function WpProQuiz_Admin() {
1725
- var global = this;
1726
-
1727
- global = {
1728
- displayChecked: function(t, box, neg, disabled) {
1729
- var c = neg ? !t.checked : t.checked;
1730
-
1731
- if(disabled)
1732
- c ? box.attr('disabled', 'disabled') : box.removeAttr('disabled');
1733
- else
1734
- c ? box.show() : box.hide();
1735
- },
1736
-
1737
- isEmpty: function(text) {
1738
- text = $.trim(text);
1739
-
1740
- return (!text || 0 === text.length);
1741
- },
1742
-
1743
- isNumber: function(number) {
1744
- number = $.trim(number);
1745
- return !global.isEmpty(number) && !isNaN(number);
1746
- },
1747
-
1748
- getMceContent: function(id) {
1749
- var editor = tinymce.editors[id];
1750
-
1751
- if(editor != undefined && !editor.isHidden()) {
1752
- return editor.getContent();
1753
- }
1754
-
1755
- return $('#'+id).val();
1756
- },
1757
-
1758
- ajaxPost: function(func, data, success) {
1759
- var d = {
1760
- action: 'wp_pro_quiz_admin_ajax',
1761
- func: func,
1762
- data: data
1763
- };
1764
-
1765
- $.post(ajaxurl, d, success, 'json');
1766
- }
1767
- };
1768
-
1769
- var tabWrapper = function() {
1770
- $('.wpProQuiz_tab_wrapper a').click(function() {
1771
- var $this = $(this);
1772
- var tabId = $this.data('tab');
1773
- var currentTab = $this.siblings('.button-primary').removeClass('button-primary').addClass('button-secondary');
1774
-
1775
- $this.removeClass('button-secondary').addClass('button-primary');
1776
-
1777
- $(currentTab.data('tab')).hide('fast');
1778
- $(tabId).show('fast');
1779
-
1780
- $(document).trigger({type: 'changeTab', tabId: tabId});
1781
-
1782
- return false;
1783
- });
1784
- };
1785
-
1786
- var module = {
1787
- /**
1788
- * @memberOf WpProQuiz_admin.module
1789
- */
1790
-
1791
- gobalSettings: function() {
1792
- var methode = {
1793
- categoryDelete: function(id, type) {
1794
- var data = {
1795
- categoryId: id
1796
- };
1797
-
1798
- global.ajaxPost('categoryDelete', data, function(json) {
1799
- if(json.err) {
1800
-
1801
- return;
1802
- }
1803
-
1804
- $('select[name="category' + type + '"] option[value="'+id+'"]').remove();
1805
- $('select[name="category' + type + '"]').change();
1806
- });
1807
- },
1808
-
1809
- categoryEdit: function(id, name, type) {
1810
- var data = {
1811
- categoryId: id,
1812
- categoryName: $.trim(name)
1813
- };
1814
-
1815
- if(global.isEmpty(name)) {
1816
- alert(wpProQuizLocalize.category_no_name);
1817
- return;
1818
- }
1819
-
1820
- global.ajaxPost('categoryEdit', data, function(json) {
1821
- if(json.err) {
1822
-
1823
- return;
1824
- }
1825
-
1826
- $('select[name="category' + type + '"] option[value="'+id+'"]').text(data.categoryName);
1827
- $('select[name="category' + type + '"]').change();
1828
- });
1829
- },
1830
-
1831
- changeTimeFormat: function(inputName, $select) {
1832
- if($select.val() != "0")
1833
- $('input[name="' + inputName + '"]').val($select.val());
1834
- },
1835
-
1836
- templateDelete: function(id, type) {
1837
- var data = {
1838
- templateId: id,
1839
- type: type
1840
- };
1841
-
1842
- global.ajaxPost('templateDelete', data, function(json) {
1843
- if(json.err) {
1844
-
1845
- return;
1846
- }
1847
-
1848
- if(!type) {
1849
- $('select[name="templateQuiz"] option[value="'+id+'"]').remove();
1850
- $('select[name="templateQuiz"]').change();
1851
- } else {
1852
- $('select[name="templateQuestion"] option[value="'+id+'"]').remove();
1853
- $('select[name="templateQuestion"]').change();
1854
- }
1855
- });
1856
- },
1857
-
1858
- templateEdit: function(id, name, type) {
1859
-
1860
- if(global.isEmpty(name)) {
1861
- alert(wpProQuizLocalize.category_no_name);
1862
- return;
1863
- }
1864
-
1865
- var data = {
1866
- templateId: id,
1867
- name: $.trim(name),
1868
- type: type
1869
- };
1870
-
1871
- global.ajaxPost('templateEdit', data, function(json) {
1872
- if(json.err) {
1873
-
1874
- return;
1875
- }
1876
-
1877
- if(!type) {
1878
- $('select[name="templateQuiz"] option[value="'+id+'"]').text(data.name);
1879
- $('select[name="templateQuiz"]').change();
1880
- } else {
1881
- $('select[name="templateQuestion"] option[value="'+id+'"]').text(data.name);
1882
- $('select[name="templateQuestion"]').change();
1883
- }
1884
- });
1885
- }
1886
- };
1887
-
1888
- var init = function() {
1889
- // $('.wpProQuiz_tab').click(function() {
1890
- // var $this = $(this);
1891
- //
1892
- // $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
1893
- // $this.removeClass('button-secondary').addClass('button-primary');
1894
- //
1895
- // $('#problemInfo, #problemContent, #globalContent').hide('fast');
1896
- //
1897
- // if($this.attr('id') == 'globalTab') {
1898
- // $('#globalContent').show('fast');
1899
- // } else {
1900
- // $('#problemInfo, #problemContent').show('fast');
1901
- // }
1902
- // });
1903
-
1904
- $('select[name="category"]').change(function() {
1905
- $('input[name="categoryEditText"]').val($(this).find(':selected').text());
1906
- }).change();
1907
-
1908
- $('input[name="categoryDelete"]').click(function() {
1909
- var id = $('select[name="category"] option:selected').val();
1910
-
1911
- methode.categoryDelete(id, '');
1912
- });
1913
-
1914
- $('input[name="categoryEdit"]').click(function() {
1915
- var id = $('select[name="category"] option:selected').val();
1916
- var text = $('input[name="categoryEditText"]').val();
1917
-
1918
- methode.categoryEdit(id, text, '');
1919
- });
1920
-
1921
- $('select[name="categoryQuiz"]').change(function() {
1922
- $('input[name="categoryQuizEditText"]').val($(this).find(':selected').text());
1923
- }).change();
1924
-
1925
- $('input[name="categoryQuizDelete"]').click(function() {
1926
- var id = $('select[name="categoryQuiz"] option:selected').val();
1927
-
1928
- methode.categoryDelete(id, 'Quiz');
1929
- });
1930
-
1931
- $('input[name="categoryQuizEdit"]').click(function() {
1932
- var id = $('select[name="categoryQuiz"] option:selected').val();
1933
- var text = $('input[name="categoryQuizEditText"]').val();
1934
-
1935
- methode.categoryEdit(id, text, 'Quiz');
1936
- });
1937
-
1938
- $('#statistic_time_format_select').change(function() {
1939
- methode.changeTimeFormat('statisticTimeFormat', $(this));
1940
- });
1941
-
1942
- $(document).bind('changeTab', function(data) {
1943
- $('#problemInfo').hide('fast');
1944
-
1945
- switch (data.tabId) {
1946
- case '#problemContent':
1947
- $('#problemInfo').show('fast');
1948
- break;
1949
- case '#emailSettingsTab':
1950
- break;
1951
- }
1952
- });
1953
-
1954
- $('input[name="email[html]"]').change(function() {
1955
- if(switchEditors == undefined)
1956
- return false;
1957
-
1958
- if(this.checked) {
1959
- switchEditors.go('adminEmailEditor', 'tmce');
1960
- } else {
1961
- switchEditors.go('adminEmailEditor', 'html');
1962
- }
1963
-
1964
- }).change();
1965
-
1966
- $('input[name="userEmail[html]"]').change(function() {
1967
- if(switchEditors == undefined)
1968
- return false;
1969
-
1970
- if(this.checked) {
1971
- switchEditors.go('userEmailEditor', 'tmce');
1972
- } else {
1973
- switchEditors.go('userEmailEditor', 'html');
1974
- }
1975
-
1976
- }).change();
1977
-
1978
- $('select[name="templateQuiz"]').change(function() {
1979
- $('input[name="templateQuizEditText"]').val($(this).find(':selected').text());
1980
- }).change();
1981
-
1982
- $('select[name="templateQuestion"]').change(function() {
1983
- $('input[name="templateQuestionEditText"]').val($(this).find(':selected').text());
1984
- }).change();
1985
-
1986
- $('input[name="templateQuizDelete"]').click(function() {
1987
- var id = $('select[name="templateQuiz"] option:selected').val();
1988
-
1989
- methode.templateDelete(id, 0);
1990
- });
1991
-
1992
- $('input[name="templateQuestionDelete"]').click(function() {
1993
- var id = $('select[name="templateQuestion"] option:selected').val();
1994
-
1995
- methode.templateDelete(id, 1);
1996
- });
1997
-
1998
- $('input[name="templateQuizEdit"]').click(function() {
1999
- var id = $('select[name="templateQuiz"] option:selected').val();
2000
- var text = $('input[name="templateQuizEditText"]').val();
2001
-
2002
- methode.templateEdit(id, text, 0);
2003
- });
2004
-
2005
- $('input[name="templateQuestionEdit"]').click(function() {
2006
- var id = $('select[name="templateQuestion"] option:selected').val();
2007
- var text = $('input[name="templateQuestionEditText"]').val();
2008
-
2009
- methode.templateEdit(id, text, 1);
2010
- });
2011
- };
2012
-
2013
- init();
2014
- },
2015
-
2016
- questionEdit: function() {
2017
- var methode = this;
2018
- var filter = $.noop();
2019
-
2020
- var elements = {
2021
- answerChildren: $('.answer_felder > div'),
2022
- pointsModus: $('input[name="answerPointsActivated"]'),
2023
- gPoints: $('input[name="points"]')
2024
- };
2025
-
2026
- methode = {
2027
- generateArrayIndex: function() {
2028
- var type = $('input[name="answerType"]:checked').val();
2029
- type = (type == 'single' || type == 'multiple') ? 'classic_answer' : type;
2030
-
2031
- $('.answerList').each(function() {
2032
- var currentType = $(this).parent().attr('class');
2033
-
2034
- $(this).children().each(function(i, v) {
2035
- $(this).find('[name^="answerData"]').each(function() {
2036
- var name = this.name;
2037
- var x = name.search(/\](\[\w+\])+$/);
2038
- var n = (type == currentType) ? i : 'none';
2039
-
2040
- if(x > 0) {
2041
- this.name = 'answerData[' + n + name.substring(x, name.length);
2042
-
2043
- }
2044
- });
2045
- });
2046
- });
2047
- },
2048
-
2049
- globalValidate: function() {
2050
- if(global.isEmpty(global.getMceContent('question'))) {
2051
- alert(wpProQuizLocalize.no_question_msg);
2052
-
2053
- return false;
2054
- }
2055
-
2056
- if(!elements.pointsModus.is(':checked')) {
2057
- var p = elements.gPoints.val();
2058
-
2059
- if(!global.isNumber(p) || p < 1) {
2060
- alert(wpProQuizLocalize.no_nummber_points);
2061
-
2062
- return false;
2063
- }
2064
- } else {
2065
- if($('input[name="answerType"]:checked').val() == 'free_answer') {
2066
- alert(wpProQuizLocalize.dif_points);
2067
- return false;
2068
- }
2069
- }
2070
-
2071
- if(filter() === false)
2072
- return false;
2073
-
2074
- return true;
2075
- },
2076
-
2077
- answerRemove: function() {
2078
- var li = $(this).parent();
2079
-
2080
- if(li.parent().children().length < 2)
2081
- return false;
2082
-
2083
- li.remove();
2084
-
2085
- return false;
2086
- },
2087
-
2088
- addCategory: function() {
2089
- var name = $.trim($('input[name="categoryAdd"]').val());
2090
-
2091
- if(global.isEmpty(name)) {
2092
- return;
2093
- }
2094
-
2095
- var data = {
2096
- categoryName: name
2097
- };
2098
-
2099
- global.ajaxPost('categoryAdd', data, function(json) {
2100
- if(json.err) {
2101
- $('#categoryMsgBox').text(json.err).show('fast').delay(2000).hide('fast');
2102
- return;
2103
- }
2104
-
2105
- var $option = $(document.createElement('option'))
2106
- .val(json.categoryId)
2107
- .text(json.categoryName)
2108
- .attr('selected', 'selected');
2109
-
2110
- $('select[name="category"]').append($option).change();
2111
-
2112
- });
2113
- },
2114
-
2115
- addMediaClick: function() {
2116
- if(typeof tb_show != "function")
2117
- return false;
2118
-
2119
- var closest = $(this).closest('li');
2120
- var htmlCheck = closest.find('input[name="answerData[][html]"]:eq(0)');
2121
- var field = closest.find('.wpProQuiz_text:eq(0)');
2122
-
2123
- window.org_send_to_editor = window.send_to_editor;
2124
- var org_tb_remove = tb_remove;
2125
-
2126
- window.send_to_editor = function(html) {
2127
- var img = $('img', html)[0].outerHTML;
2128
-
2129
- field.val(field.val() + img);
2130
- htmlCheck.attr('checked', true);
2131
-
2132
- tb_remove();
2133
-
2134
- window.send_to_editor = window.org_send_to_editor;
2135
- };
2136
-
2137
- window.tb_remove = function() {
2138
- window.send_to_editor = window.org_send_to_editor;
2139
- tb_remove = org_tb_remove;
2140
-
2141
- tb_remove();
2142
- };
2143
-
2144
- tb_show('', 'media-upload.php?type=image&TB_iframe=true');
2145
- }
2146
- };
2147
-
2148
- var validate = {
2149
- classic_answer: function() {
2150
- var findText = 0;
2151
- var findCorrect = 0;
2152
- var findPoints = 0;
2153
-
2154
- $('.classic_answer .answerList').children().each(function() {
2155
- var t = $(this);
2156
-
2157
- if(!global.isEmpty(t.find('textarea[name="answerData[][answer]"]').val())) {
2158
- findText++;
2159
-
2160
- if(t.find('input[name="answerData[][correct]"]:checked').length) {
2161
- findCorrect++;
2162
- }
2163
-
2164
- var p = t.find('input[name="answerData[][points]"]').val();
2165
-
2166
- if(global.isNumber(p) && p >= 0) {
2167
- findPoints++;
2168
- }
2169
- }
2170
- });
2171
-
2172
- if(!findText) {
2173
- alert(wpProQuizLocalize.no_answer_msg);
2174
- return false;
2175
- }
2176
-
2177
- if(!findCorrect && !($('input[name="disableCorrect"]').is(':checked')
2178
- && $('input[name="answerPointsDiffModusActivated"]').is(':checked')
2179
- && $('input[name="answerPointsActivated"]').is(':checked')
2180
- && $('input[name="answerType"]:checked').val() == 'single')) {
2181
- alert(wpProQuizLocalize.no_correct_msg);
2182
- return false;
2183
- }
2184
-
2185
- if(findPoints != findText && elements.pointsModus.is(':checked')) {
2186
- alert(wpProQuizLocalize.no_nummber_points_new);
2187
- return false;
2188
- }
2189
-
2190
- return true;
2191
- },
2192
-
2193
- free_answer: function() {
2194
- if(global.isEmpty($('.free_answer textarea[name="answerData[][answer]"]').val())) {
2195
- alert(wpProQuizLocalize.no_answer_msg);
2196
- return false;
2197
- }
2198
-
2199
- return true;
2200
- },
2201
-
2202
- cloze_answer: function() {
2203
- if(global.isEmpty(global.getMceContent('cloze'))) {
2204
- alert(wpProQuizLocalize.no_answer_msg);
2205
- return false;
2206
- }
2207
-
2208
- return true;
2209
- },
2210
-
2211
- sort_answer: function() {
2212
- var findText = 0;
2213
- var findPoints = 0;
2214
-
2215
- $('.sort_answer .answerList').children().each(function() {
2216
- var t = $(this);
2217
-
2218
- if(!global.isEmpty(t.find('textarea[name="answerData[][answer]"]').val())) {
2219
- findText++;
2220
-
2221
- var p = t.find('input[name="answerData[][points]"]').val();
2222
-
2223
- if(global.isNumber(p) && p >= 0) {
2224
- findPoints++;
2225
- }
2226
- }
2227
- });
2228
-
2229
- if(!findText) {
2230
- alert(wpProQuizLocalize.no_answer_msg);
2231
- return false;
2232
- }
2233
-
2234
- if(findPoints != findText && elements.pointsModus.is(':checked')) {
2235
- alert(wpProQuizLocalize.no_nummber_points_new);
2236
- return false;
2237
- }
2238
-
2239
- return true;
2240
- },
2241
-
2242
- matrix_sort_answer: function() {
2243
- var findText = 0;
2244
- var findPoints = 0;
2245
- var sortString = true;
2246
- var menge = 0;
2247
-
2248
- $('.matrix_sort_answer .answerList').children().each(function() {
2249
- var t = $(this);
2250
- var p = t.find('input[name="answerData[][points]"]').val();
2251
-
2252
- if(!global.isEmpty(t.find('textarea[name="answerData[][answer]"]').val())) {
2253
- findText++;
2254
- menge++;
2255
-
2256
- if(global.isEmpty(t.find('textarea[name="answerData[][sort_string]"]').val())) {
2257
- sortString = false;
2258
- }
2259
-
2260
- if(global.isNumber(p) && p >= 0) {
2261
- findPoints++;
2262
- }
2263
- } else {
2264
- if(!global.isEmpty(t.find('textarea[name="answerData[][sort_string]"]').val())) {
2265
- menge++;
2266
-
2267
- if(global.isNumber(p) && p >= 0) {
2268
- findPoints++;
2269
- }
2270
- }
2271
- }
2272
- });
2273
-
2274
- if(!findText) {
2275
- alert(wpProQuizLocalize.no_answer_msg);
2276
- return false;
2277
- }
2278
-
2279
- if(!sortString) {
2280
- alert(wpProQuizLocalize.no_sort_element_criterion);
2281
- return false;
2282
- }
2283
-
2284
- if(findPoints != menge && elements.pointsModus.is(':checked')) {
2285
- alert(wpProQuizLocalize.no_nummber_points_new);
2286
- return false;
2287
- }
2288
-
2289
- return true;
2290
- },
2291
-
2292
- assessment_answer: function() {
2293
- if(global.isEmpty(global.getMceContent('assessment'))) {
2294
- alert(wpProQuizLocalize.no_answer_msg);
2295
- return false;
2296
- }
2297
-
2298
- return true;
2299
- }
2300
- };
2301
-
2302
- var formListener = function() {
2303
- $('#wpProQuiz_tip').change(function() {
2304
- global.displayChecked(this, $('#wpProQuiz_tipBox'));
2305
- }).change();
2306
-
2307
- $('#wpProQuiz_correctSameText').change(function() {
2308
- global.displayChecked(this, $('#wpProQuiz_incorrectMassageBox'), true);
2309
- }).change();
2310
-
2311
- $('input[name="answerType"]').click(function() {
2312
- elements.answerChildren.hide();
2313
- var v = this.value;
2314
-
2315
- if(v == 'single') {
2316
- $('#singleChoiceOptions').show();
2317
- $('input[name="disableCorrect"]').change();
2318
- } else {
2319
- $('#singleChoiceOptions').hide();
2320
- $('.classic_answer .wpProQuiz_classCorrect').parent().parent().show();
2321
- }
2322
-
2323
- if(v == 'single' || v == 'multiple') {
2324
- var type = (v == 'single') ? 'radio' : 'checkbox';
2325
- v = 'classic_answer';
2326
-
2327
- $('.wpProQuiz_classCorrect').each(function() {
2328
- $("<input type=" + type + " />")
2329
- .attr({ name: this.name, value: this.value, checked: this.checked})
2330
- .addClass('wpProQuiz_classCorrect wpProQuiz_checkbox')
2331
- .insertBefore(this);
2332
- }).remove();
2333
- }
2334
-
2335
- filter = (validate[v] != undefined) ? validate[v] : $.noop();
2336
-
2337
- $('.' + v).show();
2338
- });
2339
-
2340
- $('input[name="answerType"]:checked').click();
2341
-
2342
- $('.deleteAnswer').click(methode.answerRemove);
2343
-
2344
- $('.addAnswer').click(function() {
2345
- var ul = $(this).siblings('ul');
2346
- var clone = ul.find('li:eq(0)').clone();
2347
-
2348
- clone.find('.wpProQuiz_checkbox').removeAttr('checked');
2349
- clone.find('.wpProQuiz_text').val('');
2350
- clone.find('.wpProQuiz_points').val(1);
2351
- clone.find('.deleteAnswer').click(methode.answerRemove);
2352
- clone.find('.addMedia').click(methode.addMediaClick);
2353
-
2354
- clone.appendTo(ul);
2355
-
2356
- return false;
2357
- });
2358
-
2359
- $('.sort_answer ul, .classic_answer ul, .matrix_sort_answer ul').sortable({
2360
- handle: '.wpProQuiz_move'
2361
- });
2362
-
2363
- $('#saveQuestion').click(function() {
2364
- if(!methode.globalValidate()) {
2365
- return false;
2366
- }
2367
-
2368
- methode.generateArrayIndex();
2369
-
2370
- return true;
2371
- });
2372
-
2373
- $(elements.pointsModus).change(function() {
2374
- global.displayChecked(this, $('.wpProQuiz_answerPoints'));
2375
- global.displayChecked(this, $('#wpProQuiz_showPointsBox'));
2376
- global.displayChecked(this, elements.gPoints, false, true);
2377
- global.displayChecked(this, $('input[name="answerPointsDiffModusActivated"]'), true, true);
2378
-
2379
- if(this.checked) {
2380
- $('input[name="answerPointsDiffModusActivated"]').change();
2381
- $('input[name="disableCorrect"]').change();
2382
- } else {
2383
- $('.classic_answer .wpProQuiz_classCorrect').parent().parent().show();
2384
- $('input[name="disableCorrect"]').attr('disabled', 'disabled');
2385
- }
2386
- }).change();
2387
-
2388
- $('select[name="category"]').change(function() {
2389
- var $this = $(this);
2390
- var box = $('#categoryAddBox').hide();
2391
-
2392
-
2393
- if($this.val() == "-1") {
2394
- box.show();
2395
- }
2396
-
2397
- }).change();
2398
-
2399
- $('#categoryAddBtn').click(function() {
2400
- methode.addCategory();
2401
- });
2402
-
2403
- $('.addMedia').click(methode.addMediaClick);
2404
-
2405
- $('input[name="answerPointsDiffModusActivated"]').change(function() {
2406
- global.displayChecked(this, $('input[name="disableCorrect"]'), true, true);
2407
-
2408
- if(this.checked)
2409
- $('input[name="disableCorrect"]').change();
2410
- else
2411
- $('.classic_answer .wpProQuiz_classCorrect').parent().parent().show();
2412
- }).change();
2413
-
2414
- $('input[name="disableCorrect"]').change(function() {
2415
- global.displayChecked(this, $('.classic_answer .wpProQuiz_classCorrect').parent().parent(), true);
2416
- }).change();
2417
-
2418
- $('#clickPointDia').click(function() {
2419
- $('.pointDia').toggle('fast');
2420
-
2421
- return false;
2422
- });
2423
-
2424
- $('input[name="template"]').click(function(e) {
2425
- if($('select[name="templateSaveList"]').val() == '0') {
2426
- if(global.isEmpty($('input[name="templateName"]').val())) {
2427
- alert(wpProQuizLocalize.temploate_no_name);
2428
-
2429
- e.preventDefault();
2430
- return false;
2431
- }
2432
- }
2433
-
2434
- methode.generateArrayIndex();
2435
- });
2436
-
2437
- $('select[name="templateSaveList"]').change(function() {
2438
- var $templateName = $('input[name="templateName"]');
2439
-
2440
- if($(this).val() == '0') {
2441
- $templateName.show();
2442
- } else {
2443
- $templateName.hide();
2444
- }
2445
- }).change();
2446
- };
2447
-
2448
- var init = function() {
2449
- elements.answerChildren.hide();
2450
-
2451
- formListener();
2452
- };
2453
-
2454
- init();
2455
- },
2456
-
2457
- statistic: function() {
2458
-
2459
- var methode = this;
2460
-
2461
- var quizId = $('#quizId').val();
2462
-
2463
- var currentTab = 'users';
2464
-
2465
- var elements = {
2466
- currentPage: $('#wpProQuiz_currentPage'),
2467
- pageLeft: $('#wpProQuiz_pageLeft'),
2468
- pageRight: $('#wpProQuiz_pageRight'),
2469
- testSelect: $('#testSelect')
2470
-
2471
- };
2472
-
2473
- methode = {
2474
- loadStatistic: function(userId, callback) {
2475
- var data = {
2476
- userId: userId
2477
- };
2478
-
2479
- global.ajaxPost('statisticLoad', data, function(json) {
2480
-
2481
- });
2482
- },
2483
-
2484
- loadUsersStatistic: function() {
2485
- var userId = $('#userSelect').val();
2486
-
2487
- var data = {
2488
- userId: userId,
2489
- quizId: quizId,
2490
- testId: $('#testSelect').val()
2491
- };
2492
-
2493
- methode.toggleLoadBox(false);
2494
-
2495
- global.ajaxPost('statisticLoad', data, function(json) {
2496
- $.each(json.question, function() {
2497
- var $tr = $('#wpProQuiz_tr_' + this.questionId);
2498
-
2499
- methode.setStatisticData($tr, this);
2500
- });
2501
-
2502
- $.each(json.category, function(i, v) {
2503
- var $tr = $('#wpProQuiz_ctr_' + i);
2504
-
2505
- methode.setStatisticData($tr, v);
2506
- });
2507
-
2508
- $('#testSelect option:gt(0)').remove();
2509
- var $testSelect = $('#testSelect');
2510
-
2511
- $.each(json.tests, function() {
2512
- var $option = $(document.createElement('option'));
2513
-
2514
- $option.val(this.id);
2515
- $option.text(this.date);
2516
-
2517
- if(json.testId == this.id)
2518
- $option.attr('selected', true);
2519
-
2520
- $testSelect.append($option);
2521
- });
2522
-
2523
- methode.parseFormData(json.formData);
2524
-
2525
- methode.toggleLoadBox(true);
2526
- });
2527
- },
2528
-
2529
- loadUsersStatistic_: function(userId, testId) {
2530
-
2531
- var data = {
2532
- userId: userId,
2533
- quizId: quizId,
2534
- testId: testId
2535
- };
2536
-
2537
- methode.toggleLoadBox(false);
2538
-
2539
- global.ajaxPost('statisticLoad', data, function(json) {
2540
- $.each(json.question, function() {
2541
- var $tr = $('#wpProQuiz_tr_' + this.questionId);
2542
-
2543
- methode.setStatisticData($tr, this);
2544
- });
2545
-
2546
- $.each(json.category, function(i, v) {
2547
- var $tr = $('#wpProQuiz_ctr_' + i);
2548
-
2549
- methode.setStatisticData($tr, v);
2550
- });
2551
-
2552
- $('#testSelect option:gt(0)').remove();
2553
- var $testSelect = $('#testSelect');
2554
-
2555
- $.each(json.tests, function() {
2556
- var $option = $(document.createElement('option'));
2557
-
2558
- $option.val(this.id);
2559
- $option.text(this.date);
2560
-
2561
- if(json.testId == this.id)
2562
- $option.attr('selected', true);
2563
-
2564
- $testSelect.append($option);
2565
- });
2566
-
2567
- methode.parseFormData(json.formData);
2568
-
2569
- $('#userSelect').val(userId);
2570
- $('#testSelect').val(testId);
2571
-
2572
- methode.toggleLoadBox(true);
2573
- });
2574
- },
2575
-
2576
- parseFormData: function(data) {
2577
- var $formBox = $('#wpProQuiz_form_box');
2578
-
2579
- if(data == null) {
2580
- $formBox.hide();
2581
- return;
2582
- }
2583
-
2584
- $.each(data, function(i, v) {
2585
- $('#form_id_' + i).text(v);
2586
- });
2587
-
2588
- $formBox.show();
2589
- },
2590
-
2591
- setStatisticData: function($o, v) {
2592
- $o.find('.wpProQuiz_cCorrect').text(v.correct);
2593
- $o.find('.wpProQuiz_cIncorrect').text(v.incorrect);
2594
- $o.find('.wpProQuiz_cTip').text(v.hint);
2595
- $o.find('.wpProQuiz_cPoints').text(v.points);
2596
- $o.find('.wpProQuiz_cResult').text(v.result);
2597
- $o.find('.wpProQuiz_cTime').text(v.questionTime);
2598
- $o.find('.wpProQuiz_cCreateTime').text(v.date);
2599
- },
2600
-
2601
- toggleLoadBox: function(show) {
2602
- var $loadBox = $('#wpProQuiz_loadData');
2603
- var $content = $('#wpProQuiz_content');
2604
-
2605
- if(show) {
2606
- $loadBox.hide();
2607
- $content.show();
2608
- } else {
2609
- $content.hide();
2610
- $loadBox.show();
2611
- }
2612
- },
2613
-
2614
- reset: function(type) {
2615
- var userId = $('#userSelect').val();
2616
-
2617
- if(!confirm(wpProQuizLocalize.reset_statistics_msg)) {
2618
- return;
2619
- }
2620
-
2621
- var data = {
2622
- quizId: quizId,
2623
- userId: userId,
2624
- testId: elements.testSelect.val(),
2625
- type: type
2626
- };
2627
-
2628
- methode.toggleLoadBox(false);
2629
-
2630
- global.ajaxPost('statisticReset', data, function() {
2631
- methode.loadUsersStatistic();
2632
- });
2633
- },
2634
-
2635
- loadStatisticOverview: function(nav) {
2636
-
2637
- var data = {
2638
- quizId: quizId,
2639
- pageLimit: $('#wpProQuiz_pageLimit').val(),
2640
- onlyCompleted: Number($('#wpProQuiz_onlyCompleted').is(':checked')),
2641
- page: elements.currentPage.val(),
2642
- nav: Number(nav)
2643
- };
2644
-
2645
- methode.toggleLoadBox(false);
2646
-
2647
- global.ajaxPost('statisticLoadOverview', data, function(json) {
2648
- var $body = $('#wpProQuiz_statistics_overview_data');
2649
- var $tr = $body.children();
2650
- var $c = $tr.first().clone();
2651
-
2652
- $tr.slice(1).remove();
2653
-
2654
- $.each(json.items, function() {
2655
- var clone = $c.clone();
2656
-
2657
- methode.setStatisticData(clone, this);
2658
-
2659
- clone.find('a').text(this.userName).data('userId', this.userId).click(function() {
2660
- $('#userSelect').val($(this).data('userId'));
2661
-
2662
- $('#wpProQuiz_typeUser').click();
2663
-
2664
- return false;
2665
- });
2666
-
2667
- clone.show().appendTo($body);
2668
- });
2669
-
2670
- $c.remove();
2671
-
2672
- methode.toggleLoadBox(true);
2673
-
2674
- if(json.page != undefined)
2675
- methode.handleNav(json.page);
2676
- });
2677
-
2678
- },
2679
-
2680
- handleNav: function(nav) {
2681
- var $p = $('#wpProQuiz_currentPage').empty();
2682
-
2683
- for(var i = 1; i <= nav; i++) {
2684
- $(document.createElement('option'))
2685
- .val(i)
2686
- .text(i)
2687
- .appendTo($p);
2688
- }
2689
-
2690
- methode.checkNavBar();
2691
- },
2692
-
2693
- checkNavBar: function() {
2694
- var n = elements.currentPage.val();
2695
-
2696
- if(n == 1) {
2697
- elements.pageLeft.hide();
2698
- } else {
2699
- elements.pageLeft.show();
2700
- }
2701
-
2702
- if(n == elements.currentPage.children().length) {
2703
- elements.pageRight.hide();
2704
- } else {
2705
- elements.pageRight.show();
2706
- }
2707
- },
2708
-
2709
- refresh: function() {
2710
- if(currentTab == 'users') {
2711
- methode.loadUsersStatistic();
2712
- } else if(currentTab == 'formOverview') {
2713
- methode.loadFormsOverview(true);
2714
- } else {
2715
- methode.loadStatisticOverview(true);
2716
- }
2717
- },
2718
-
2719
- loadFormsOverview: function(nav) {
2720
- var data = {
2721
- quizId: quizId,
2722
- pageLimit: $('#wpProQuiz_fromPageLimit').val(),
2723
- onlyUser: $('#wpProQuiz_formUser').val(),
2724
- page: $('#wpProQuiz_formCurrentPage').val(),
2725
- nav: Number(nav)
2726
- };
2727
-
2728
- methode.toggleLoadBox(false);
2729
-
2730
- global.ajaxPost('statisticLoadFormOverview', data, function(json) {
2731
- var $body = $('#wpProQuiz_statistics_form_data');
2732
- var $tr = $body.children();
2733
- var $c = $tr.first().clone();
2734
-
2735
- $tr.slice(1).remove();
2736
-
2737
- $.each(json.items, function() {
2738
- var clone = $c.clone();
2739
-
2740
- methode.setStatisticData(clone, this);
2741
-
2742
- clone.find('a').text(this.userName).data('userId', this.userId).data('testId', this.testId).click(function() {
2743
- methode.switchTabOnLoad('users');
2744
- methode.loadUsersStatistic_($(this).data('userId'), $(this).data('testId'));
2745
-
2746
- return false;
2747
- });
2748
-
2749
- clone.show().appendTo($body);
2750
- });
2751
-
2752
- $c.remove();
2753
-
2754
- methode.toggleLoadBox(true);
2755
-
2756
- if(json.page != undefined)
2757
- methode.handleFormNav(json.page);
2758
- });
2759
- },
2760
-
2761
- handleFormNav: function(nav) {
2762
- var $p = $('#wpProQuiz_formCurrentPage').empty();
2763
-
2764
- for(var i = 1; i <= nav; i++) {
2765
- $(document.createElement('option'))
2766
- .val(i)
2767
- .text(i)
2768
- .appendTo($p);
2769
- }
2770
-
2771
- methode.checkFormNavBar();
2772
- },
2773
-
2774
- checkFormNavBar: function() {
2775
- var n = $('#wpProQuiz_formCurrentPage').val();
2776
-
2777
-
2778
- if(n == 1) {
2779
- $('#wpProQuiz_formPageLeft').hide();
2780
- } else {
2781
- $('#wpProQuiz_formPageLeft').show();
2782
- }
2783
-
2784
- if(n ==$('#wpProQuiz_formCurrentPage').children().length) {
2785
- $('#wpProQuiz_formPageRight').hide();
2786
- } else {
2787
- $('#wpProQuiz_formPageRight').show();
2788
- }
2789
- },
2790
-
2791
- switchTabOnLoad: function(name) {
2792
- $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
2793
- $('.wpProQuiz_tabContent').hide();
2794
-
2795
- var $this = $('#wpProQuiz_typeOverview');
2796
-
2797
- if(name == 'users') {
2798
- currentTab = 'users';
2799
- $('#wpProQuiz_tabUsers').show();
2800
- $this = $('#wpProQuiz_typeUser');
2801
- } else if(name == 'formOverview') {
2802
- currentTab = 'formOverview';
2803
- $('#wpProQuiz_tabFormOverview').show();
2804
- $this = $('#wpProQuiz_typeForm');
2805
- } else {
2806
- currentTab = 'overview';
2807
- $('#wpProQuiz_tabOverview').show();
2808
- }
2809
-
2810
- $this.removeClass('button-secondary').addClass('button-primary');
2811
- }
2812
- };
2813
-
2814
- var init = function() {
2815
-
2816
- $('#userSelect, #testSelect').change(function() {
2817
- methode.loadUsersStatistic();
2818
- });
2819
-
2820
- $('.wpProQuiz_update').click(function() {
2821
- methode.refresh();
2822
- });
2823
-
2824
- $('#wpProQuiz_reset').click(function() {
2825
- methode.reset(0);
2826
- });
2827
-
2828
- $('#wpProQuiz_resetUser').click(function() {
2829
- methode.reset(1);
2830
- });
2831
-
2832
- $('.wpProQuiz_resetComplete').click(function() {
2833
- methode.reset(2);
2834
- });
2835
-
2836
- $('.wpProQuiz_tab').click(function() {
2837
- var $this = $(this);
2838
-
2839
- $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
2840
- $this.removeClass('button-secondary').addClass('button-primary');
2841
- $('.wpProQuiz_tabContent').hide();
2842
-
2843
- if($this.attr('id') == 'wpProQuiz_typeUser') {
2844
- currentTab = 'users';
2845
- $('#wpProQuiz_tabUsers').show();
2846
- methode.loadUsersStatistic();
2847
- } else if($this.attr('id') == 'wpProQuiz_typeForm') {
2848
- currentTab = 'formOverview';
2849
- $('#wpProQuiz_tabFormOverview').show();
2850
- methode.loadFormsOverview(true);
2851
- } else {
2852
- currentTab = 'overview';
2853
- $('#wpProQuiz_tabOverview').show();
2854
- methode.loadStatisticOverview(true);
2855
- }
2856
-
2857
- return false;
2858
- });
2859
-
2860
- $('#wpProQuiz_onlyCompleted').change(function() {
2861
- elements.currentPage.val(1);
2862
- methode.loadStatisticOverview(true);
2863
- });
2864
-
2865
- $('#wpProQuiz_pageLimit').change(function() {
2866
- elements.currentPage.val(1);
2867
- methode.loadStatisticOverview(true);
2868
- });
2869
-
2870
- elements.pageLeft.click(function() {
2871
- elements.currentPage.val(Number(elements.currentPage.val()) - 1);
2872
- methode.loadStatisticOverview(false);
2873
- methode.checkNavBar();
2874
- });
2875
-
2876
- elements.pageRight.click(function() {
2877
- elements.currentPage.val(Number(elements.currentPage.val()) + 1);
2878
- methode.loadStatisticOverview(false);
2879
- methode.checkNavBar();
2880
- });
2881
-
2882
- elements.currentPage.change(function() {
2883
- methode.loadStatisticOverview(false);
2884
- methode.checkNavBar();
2885
- });
2886
-
2887
- $('#wpProQuiz_formUser, #wpProQuiz_fromPageLimit').change(function() {
2888
- $('#wpProQuiz_formCurrentPage').val(1);
2889
- methode.loadFormsOverview(true);
2890
- });
2891
-
2892
- $('#wpProQuiz_formPageLeft').click(function() {
2893
- $('#wpProQuiz_formCurrentPage').val(Number(elements.currentPage.val()) - 1);
2894
- methode.loadFormsOverview(false);
2895
- methode.checkFormNavBar();
2896
- });
2897
-
2898
- $('#wpProQuiz_formPageRight').click(function() {
2899
- $('#wpProQuiz_formCurrentPage').val(Number(elements.currentPage.val()) + 1);
2900
- methode.loadFormsOverview(false);
2901
- methode.checkFormNavBar();
2902
- });
2903
-
2904
- $('#wpProQuiz_formCurrentPage').change(function() {
2905
- methode.loadFormsOverview(false);
2906
- methode.checkFormNavBar();
2907
- });
2908
-
2909
- methode.loadUsersStatistic();
2910
- };
2911
-
2912
- init();
2913
- },
2914
-
2915
- statisticNew: function() {
2916
- var quizId = $('#quizId').val();
2917
- var historyNavigator = null;
2918
- var overviewNavigator = null;
2919
-
2920
- var historyFilter = {
2921
- data: {
2922
- quizId: quizId,
2923
- users: -1,
2924
- pageLimit: 100,
2925
- dateFrom: 0,
2926
- dateTo: 0,
2927
- generateNav: 0
2928
- },
2929
-
2930
- changeFilter: function() {
2931
- var getTime = function(p) {
2932
- var date = p.datepicker('getDate');
2933
-
2934
- return date === null ? 0 : date.getTime() / 1000;
2935
- };
2936
-
2937
- $.extend(this.data, {
2938
- users: $('#wpProQuiz_historyUser').val(),
2939
- pageLimit: $('#wpProQuiz_historyPageLimit').val(),
2940
- dateFrom: getTime($('#datepickerFrom')),
2941
- dateTo: getTime($('#datepickerTo')),
2942
- generateNav: 1
2943
- });
2944
-
2945
- return this.data;
2946
- }
2947
- };
2948
-
2949
- var overviewFilter = {
2950
- data: {
2951
- pageLimit: 100,
2952
- onlyCompleted: 0,
2953
- generateNav: 0,
2954
- quizId: quizId
2955
- },
2956
-
2957
- changeFilter: function() {
2958
- $.extend(this.data, {
2959
- pageLimit: $('#wpProQuiz_overviewPageLimit').val(),
2960
- onlyCompleted: Number($('#wpProQuiz_overviewOnlyCompleted').is(':checked')),
2961
- generateNav: 1
2962
- });
2963
- }
2964
- };
2965
-
2966
- var deleteMethode = {
2967
- deleteUserStatistic: function(refId, userId) {
2968
- if(!confirm(wpProQuizLocalize.reset_statistics_msg))
2969
- return false;
2970
-
2971
- var data = {
2972
- refId: refId,
2973
- userId: userId,
2974
- quizId: quizId,
2975
- type: 0
2976
- };
2977
-
2978
- global.ajaxPost('statisticResetNew', data, function() {
2979
- $('#wpProQuiz_user_overlay').hide();
2980
-
2981
- historyFilter.changeFilter();
2982
- methode.loadHistoryAjax();
2983
-
2984
- overviewFilter.changeFilter();
2985
- methode.loadOverviewAjax();
2986
-
2987
- });
2988
- },
2989
-
2990
- deleteAll: function() {
2991
- if(!confirm(wpProQuizLocalize.reset_statistics_msg))
2992
- return false;
2993
-
2994
- var data = {
2995
- quizId: quizId,
2996
- type: 1
2997
- };
2998
-
2999
- global.ajaxPost('statisticResetNew', data, function() {
3000
- historyFilter.changeFilter();
3001
- methode.loadHistoryAjax();
3002
-
3003
- overviewFilter.changeFilter();
3004
- methode.loadOverviewAjax();
3005
- });
3006
- }
3007
- };
3008
-
3009
- var methode = {
3010
- loadHistoryAjax: function() {
3011
-
3012
- var data = $.extend({
3013
- page: historyFilter.data.generateNav ? 1 : historyNavigator.getCurrentPage()
3014
- }, historyFilter.data);
3015
-
3016
- methode.loadBox(true);
3017
- var content = $('#wpProQuiz_historyLoadContext').hide();
3018
-
3019
- global.ajaxPost('statisticLoadHistory', data, function(json) {
3020
- content.html(json.html).show();
3021
-
3022
- if(json.navi)
3023
- historyNavigator.setNumPage(json.navi);
3024
-
3025
- historyFilter.data.generateNav = 0;
3026
-
3027
- content.find('.user_statistic').click(function() {
3028
- methode.loadUserAjax(0, $(this).data('ref_id'), false);
3029
-
3030
- return false;
3031
- });
3032
-
3033
- content.find('.wpProQuiz_delete').click(function() {
3034
- deleteMethode.deleteUserStatistic($(this).parents('tr').find('.user_statistic').data('ref_id'), 0);
3035
-
3036
- return false;
3037
- });
3038
-
3039
- methode.loadBox(false);
3040
- });
3041
-
3042
- },
3043
-
3044
- loadUserAjax: function(userId, refId, avg) {
3045
- $('#wpProQuiz_user_overlay, #wpProQuiz_loadUserData').show();
3046
-
3047
- var content = $('#wpProQuiz_user_content').hide();
3048
-
3049
- var data = {
3050
- quizId: quizId,
3051
- userId: userId,
3052
- refId: refId,
3053
- avg: Number(avg)
3054
- };
3055
-
3056
- global.ajaxPost('statisticLoadUser', data, function(json) {
3057
- content.html(json.html);
3058
-
3059
- content.find('.wpProQuiz_update').click(function() {
3060
- methode.loadUserAjax(userId, refId, avg);
3061
-
3062
- return false;
3063
- });
3064
-
3065
- content.find('#wpProQuiz_resetUserStatistic').click(function() {
3066
- deleteMethode.deleteUserStatistic(refId, userId);
3067
- });
3068
-
3069
- content.find('.statistic_data').click(function() {
3070
- $(this).parents('tr').next().toggle('fast');
3071
-
3072
- return false;
3073
- });
3074
-
3075
- $('#wpProQuiz_loadUserData').hide();
3076
- content.show();
3077
- });
3078
-
3079
- },
3080
-
3081
- loadBox: function(show, contain) {
3082
- if(show)
3083
- $('#wpProQuiz_loadDataHistory').show();
3084
- else
3085
- $('#wpProQuiz_loadDataHistory').hide();
3086
-
3087
- },
3088
-
3089
- loadOverviewAjax: function() {
3090
- var data = $.extend({
3091
- page: overviewFilter.data.generateNav ? 1 : overviewNavigator.getCurrentPage()
3092
- }, overviewFilter.data);
3093
-
3094
- $('#wpProQuiz_loadDataOverview').show();
3095
-
3096
- var content = $('#wpProQuiz_overviewLoadContext').hide();
3097
-
3098
- global.ajaxPost('statisticLoadOverviewNew', data, function(json) {
3099
- content.html(json.html).show();
3100
-
3101
- if(json.navi)
3102
- overviewNavigator.setNumPage(json.navi);
3103
-
3104
- overviewFilter.data.generateNav = 0;
3105
-
3106
- content.find('.user_statistic').click(function() {
3107
- methode.loadUserAjax($(this).data('user_id'), 0, true);
3108
-
3109
- return false;
3110
- });
3111
-
3112
- content.find('.wpProQuiz_delete').click(function() {
3113
- deleteMethode.deleteUserStatistic(0, $(this).parents('tr').find('.user_statistic').data('user_id'));
3114
-
3115
- return false;
3116
- });
3117
-
3118
- $('#wpProQuiz_loadDataOverview').hide();
3119
- });
3120
- }
3121
- };
3122
-
3123
-
3124
- var init = function() {
3125
- historyNavigator = new Navigator($('#historyNavigation'), {
3126
- onChange: function() {
3127
- methode.loadHistoryAjax();
3128
- }
3129
- });
3130
-
3131
- overviewNavigator = new Navigator($('#overviewNavigation'), {
3132
- onChange: function() {
3133
- methode.loadOverviewAjax();
3134
- }
3135
- });
3136
-
3137
- $('#datepickerFrom').datepicker({
3138
- closeText: wpProQuizLocalize.closeText,
3139
- currentText: wpProQuizLocalize.currentText,
3140
- monthNames: wpProQuizLocalize.monthNames,
3141
- monthNamesShort: wpProQuizLocalize.monthNamesShort,
3142
- dayNames: wpProQuizLocalize.dayNames,
3143
- dayNamesShort: wpProQuizLocalize.dayNamesShort,
3144
- dayNamesMin: wpProQuizLocalize.dayNamesMin,
3145
- dateFormat: wpProQuizLocalize.dateFormat,
3146
- firstDay: wpProQuizLocalize.firstDay,
3147
-
3148
- changeMonth: true,
3149
- onClose: function(selectedDate) {
3150
- $('#datepickerTo').datepicker('option', 'minDate', selectedDate);
3151
- }
3152
- });
3153
-
3154
- $('#datepickerTo').datepicker({
3155
- closeText: wpProQuizLocalize.closeText,
3156
- currentText: wpProQuizLocalize.currentText,
3157
- monthNames: wpProQuizLocalize.monthNames,
3158
- monthNamesShort: wpProQuizLocalize.monthNamesShort,
3159
- dayNames: wpProQuizLocalize.dayNames,
3160
- dayNamesShort: wpProQuizLocalize.dayNamesShort,
3161
- dayNamesMin: wpProQuizLocalize.dayNamesMin,
3162
- dateFormat: wpProQuizLocalize.dateFormat,
3163
- firstDay: wpProQuizLocalize.firstDay,
3164
-
3165
- changeMonth: true,
3166
- onClose: function(selectedDate) {
3167
- $('#datepickerFrom').datepicker('option', 'maxDate', selectedDate);
3168
- }
3169
- });
3170
-
3171
- $('#filter').click(function() {
3172
- historyFilter.changeFilter();
3173
- methode.loadHistoryAjax();
3174
- });
3175
-
3176
- $('#wpProQuiz_overlay_close').click(function() {
3177
- $('#wpProQuiz_user_overlay').hide();
3178
- });
3179
-
3180
- $('#wpProQuiz_tabHistory .wpProQuiz_update').click(function() {
3181
- historyFilter.changeFilter();
3182
- methode.loadHistoryAjax();
3183
-
3184
- return false;
3185
- });
3186
-
3187
- $('#wpProQuiz_tabOverview .wpProQuiz_update').click(function() {
3188
- overviewFilter.changeFilter();
3189
- methode.loadOverviewAjax();
3190
-
3191
- return false;
3192
- });
3193
-
3194
- $('.wpProQuiz_resetComplete').click(function() {
3195
- deleteMethode.deleteAll();
3196
-
3197
- return false;
3198
- });
3199
-
3200
- $('#overviewFilter').click(function() {
3201
- overviewFilter.changeFilter();
3202
- methode.loadOverviewAjax();
3203
- });
3204
-
3205
- historyFilter.changeFilter();
3206
- methode.loadHistoryAjax();
3207
-
3208
- overviewFilter.changeFilter();
3209
- methode.loadOverviewAjax();
3210
- };
3211
-
3212
- init();
3213
- }
3214
- };
3215
-
3216
- var init = function() {
3217
- tabWrapper();
3218
-
3219
- var m = $.noop;
3220
-
3221
- if($('.wpProQuiz_questionEdit').length) {
3222
- m = module.questionEdit;
3223
- } else if($('.wpProQuiz_globalSettings').length) {
3224
- m = module.gobalSettings;
3225
- } else if($('.wpProQuiz_statistics').length) {
3226
- m = module.statistic;
3227
- } else if($('.wpProQuiz_statisticsNew').length) {
3228
- m = module.statisticNew;
3229
- }
3230
-
3231
- m();
3232
-
3233
- $('.wpProQuiz_demoImgBox a').mouseover(function(e) {
3234
- var $this = $(this);
3235
- var d = $(document).width();
3236
- var img = $this.siblings().outerWidth(true);
3237
-
3238
- if(e.pageX + img > d) {
3239
- var v = d - (e.pageX + img + 30);
3240
- $(this).next().css('left', v + "px");
3241
- }
3242
-
3243
- $(this).next().show();
3244
-
3245
- }).mouseout(function() {
3246
- $(this).next().hide();
3247
- }).click(function() {
3248
- return false;
3249
- });
3250
- };
3251
-
3252
- init();
3253
- }
3254
-
3255
- WpProQuiz_Admin();
3256
-
3257
- function Navigator(obj, option) {
3258
- var defaultOption = {
3259
- onChange: null
3260
- };
3261
-
3262
- var elements = {
3263
- contain: null,
3264
- pageLeft: null,
3265
- pageRight: null,
3266
- currentPage: null
3267
- };
3268
-
3269
- var checkNavBar = function() {
3270
- var num = elements.currentPage.children().length;
3271
- var cur = Number(elements.currentPage.val());
3272
-
3273
- elements.pageLeft.hide();
3274
- elements.pageRight.hide();
3275
-
3276
- if(cur > 1)
3277
- elements.pageLeft.show();
3278
-
3279
- if((cur + 1) <= num)
3280
- elements.pageRight.show();
3281
- };
3282
-
3283
- var init = function() {
3284
- $.extend(elements, {
3285
- contain: obj,
3286
- pageLeft: obj.find('.navigationLeft'),
3287
- pageRight: obj.find('.navigationRight'),
3288
- currentPage: obj.find('.navigationCurrentPage')
3289
- });
3290
-
3291
- $.extend(defaultOption, option);
3292
-
3293
- elements.pageLeft.click(function() {
3294
- elements.currentPage.val(Number(elements.currentPage.val()) - 1);
3295
- checkNavBar();
3296
-
3297
- if(defaultOption.onChange)
3298
- defaultOption.onChange(elements.currentPage.val());
3299
- });
3300
-
3301
- elements.pageRight.click(function() {
3302
- elements.currentPage.val(Number(elements.currentPage.val()) + 1);
3303
- checkNavBar();
3304
-
3305
- if(defaultOption.onChange)
3306
- defaultOption.onChange(elements.currentPage.val());
3307
- });
3308
-
3309
- elements.currentPage.change(function() {
3310
- checkNavBar();
3311
-
3312
- if(defaultOption.onChange)
3313
- defaultOption.onChange(elements.currentPage.val());
3314
- });
3315
- };
3316
-
3317
- this.getCurrentPage = function() {
3318
- return elements.currentPage.val();
3319
- }
3320
-
3321
- this.setNumPage = function(num) {
3322
- elements.currentPage.empty();
3323
-
3324
- for(var i = 1; i <= num; i++) {
3325
- $(document.createElement('option'))
3326
- .val(i)
3327
- .text(i)
3328
- .appendTo(elements.currentPage);
3329
- }
3330
-
3331
- checkNavBar();
3332
- }
3333
-
3334
- init();
3335
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3336
  });
1
+ jQuery(document).ready(function ($) {
2
+ /**
3
+ * @memberOf $.fn
4
+ */
5
+ $.fn.wpProQuiz_preview = function () {
6
+ var methods = {
7
+ openPreview: function (obj) {
8
+ window.open($(obj).attr('href'), 'wpProQuizPreview', 'width=900,height=900');
9
+ }
10
+ };
11
+
12
+ var init = function () {
13
+ $('.wpProQuiz_prview').click(function (e) {
14
+ methods.openPreview(this);
15
+ e.preventDefault();
16
+ });
17
+ };
18
+
19
+ init();
20
+ };
21
+
22
+ $.fn.wpProQuiz_quizOverall = function () {
23
+
24
+ //function isEmpty(text) {
25
+ // text = $.trim(text);
26
+ //
27
+ // return (!text || 0 === text.length);
28
+ //};
29
+ //
30
+ //function ajaxPost(func, data, success) {
31
+ // var d = {
32
+ // action: 'wp_pro_quiz_admin_ajax',
33
+ // func: func,
34
+ // data: data
35
+ // };
36
+ //
37
+ // $.post(ajaxurl, d, success, 'json');
38
+ //};
39
+ //
40
+ //var methods = {
41
+ // changeExport: function(input) {
42
+ // $input = $(input);
43
+ // $export = $('.wpProQuiz_exportList');
44
+ // $export2 = $('.wpProQuiz_setQuizCategoryList');
45
+ // $ul = $export.find('ul').first();
46
+ // $ul2 = $export2.find('ul').first();
47
+ // $export.find('li').remove();
48
+ // $export2.find('li').remove();
49
+ //
50
+ // $('input[name="exportItems"]').each(function() {
51
+ // $this = $(this);
52
+ //
53
+ // if(this.checked) {
54
+ // var text = $this.parent().parent().find('.wpProQuiz_quizName a:eq(0)').text();
55
+ // $('<li>' + text + '</li>').appendTo($ul);
56
+ // $('<li>' + text + '</li>').appendTo($ul2);
57
+ // }
58
+ // });
59
+ // },
60
+ //
61
+ // startExport: function() {
62
+ // $ele = $('input[name="exportItems"]:checked');
63
+ //
64
+ // if($ele.length < 1) {
65
+ // alert(wpProQuizLocalize.no_selected_quiz);
66
+ // return false;
67
+ // }
68
+ //
69
+ // $hidden = $('#exportHidden');
70
+ //
71
+ // $hidden.html('');
72
+ //
73
+ // $('input[name="exportItems"]').each(function() {
74
+ // $this = $(this);
75
+ //
76
+ // if(this.checked) {
77
+ // $('<input type="hidden" value="'+ this.value +'" name="exportIds[]">').appendTo($hidden);
78
+ // }
79
+ // });
80
+ //
81
+ // return true;
82
+ // },
83
+ //
84
+ // setCategoriesStart: function() {
85
+ // $ele = $('input[name="exportItems"]:checked');
86
+ //
87
+ // if($ele.length < 1) {
88
+ // alert(wpProQuizLocalize.no_selected_quiz);
89
+ // return false;
90
+ // }
91
+ //
92
+ // var ids = [];
93
+ //
94
+ // $('input[name="exportItems"]').each(function() {
95
+ // $this = $(this);
96
+ //
97
+ // if(this.checked) {
98
+ // ids.push(this.value);
99
+ // }
100
+ // });
101
+ //
102
+ // var categoryId = $('select[name="category"]').val();
103
+ //
104
+ // var data = {
105
+ // categoryId: categoryId,
106
+ // quizIds: ids
107
+ // };
108
+ //
109
+ // $('#ajaxLoad').show();
110
+ //
111
+ // ajaxPost('setQuizMultipleCategories', data, function(json) {
112
+ // location.reload();
113
+ // });
114
+ //
115
+ // return true;
116
+ // },
117
+ //
118
+ // addCategory: function() {
119
+ // var name = $.trim($('input[name="categoryAdd"]').val());
120
+ //
121
+ // if(isEmpty(name)) {
122
+ // return;
123
+ // }
124
+ //
125
+ // var data = {
126
+ // categoryName: name,
127
+ // type: 'quiz'
128
+ // };
129
+ //
130
+ // ajaxPost('categoryAdd', data, function(json) {
131
+ // if(json.err) {
132
+ // $('#categoryMsgBox').text(json.err).show('fast').delay(2000).hide('fast');
133
+ // return;
134
+ // }
135
+ //
136
+ // var $option = $(document.createElement('option'))
137
+ // .val(json.categoryId)
138
+ // .text(json.categoryName)
139
+ // .attr('selected', 'selected');
140
+ //
141
+ // $('select[name="category"]').append($option).change();
142
+ //
143
+ // });
144
+ // }
145
+ //};
146
+ //
147
+ //var init = function() {
148
+ // $('.wpProQuiz_delete').click(function(e) {
149
+ // var b = confirm(wpProQuizLocalize.delete_msg);
150
+ //
151
+ // if(!b) {
152
+ // e.preventDefault();
153
+ // return false;
154
+ // }
155
+ //
156
+ // return true;
157
+ // });
158
+ //
159
+ // $('.wpProQuiz_import').click(function(e) {
160
+ // e.preventDefault();
161
+ // $('.wpProQuiz_importList').show('fast');
162
+ //
163
+ // $('.wpProQuiz_exportList, .wpProQuiz_setQuizCategoryList').hide();
164
+ // $('.wpProQuiz_exportCheck').hide();
165
+ //
166
+ // });
167
+ //
168
+ // $('.wpProQuiz_export').click(function(e) {
169
+ // e.preventDefault();
170
+ //
171
+ // $('.wpProQuiz_exportList').show('fast');
172
+ // $('.wpProQuiz_exportCheck').show('fast');
173
+ // $('.wpProQuiz_importList, .wpProQuiz_setQuizCategoryList').hide();
174
+ // });
175
+ //
176
+ // $('.wpProQuiz_setQuizCategory').click(function(e) {
177
+ // e.preventDefault();
178
+ //
179
+ // $('.wpProQuiz_setQuizCategoryList').show('fast');
180
+ // $('.wpProQuiz_exportCheck').show('fast');
181
+ // $('.wpProQuiz_importList, .wpProQuiz_exportList').hide();
182
+ // });
183
+ //
184
+ // $('input[name="exportItems"]').change(function() {
185
+ // methods.changeExport(this);
186
+ // });
187
+ //
188
+ // $('input[name="exportItemsAll"]').change(function() {
189
+ // var $input = $('input[name="exportItems"]');
190
+ // if(this.checked)
191
+ // $input.attr('checked', true);
192
+ // else
193
+ // $input.attr('checked', false);
194
+ //
195
+ // $input.change();
196
+ // });
197
+ //
198
+ // $('#exportStart').click(function(e) {
199
+ //
200
+ // if(!methods.startExport())
201
+ // e.preventDefault();
202
+ // });
203
+ //
204
+ // $('#setCategoriesStart').click(function(e) {
205
+ //
206
+ // if(!methods.setCategoriesStart())
207
+ // e.preventDefault();
208
+ // });
209
+ //
210
+ // $('select[name="category"]').change(function() {
211
+ // var $this = $(this);
212
+ // var box = $('#categoryAddBox').hide();
213
+ //
214
+ //
215
+ // if($this.val() == "-1") {
216
+ // box.show();
217
+ // }
218
+ //
219
+ // }).change();
220
+ //
221
+ // $('#categoryAddBtn').click(function() {
222
+ // methods.addCategory();
223
+ // });
224
+ //};
225
+ //
226
+ //init();
227
+ };
228
+
229
+ // $.fn.wpProQuiz_questionEdit = function() {
230
+ //
231
+ // var setup = function() {
232
+ // if($('input[name="answerType"][checked="checked"]').size() < 1) {
233
+ // $('input[name="answerType"][value="single"]').attr({'checked': 'checked'});
234
+ // }
235
+ //
236
+ // $('input[name="answerType"]:checked').click();
237
+ // $('#wpProQuiz_correctSameText').change();
238
+ // $('#wpProQuiz_tip').change();
239
+ // $('input[name="pointsPerAnswer"]').change();
240
+ // $('input[name="answerPointsActivated"]').change();
241
+ // };
242
+ //
243
+ // var formListener = {
244
+ // setup: function() {
245
+ // $('input[name="answerType"]').click(function(e) {
246
+ // $('.answer_felder').children().css('display', 'none');
247
+ //
248
+ // switch (this.value) {
249
+ // case 'single':
250
+ // formListener.displaySingle('radio');
251
+ // break;
252
+ // case 'multiple':
253
+ // formListener.displaySingle('checkbox');
254
+ // break;
255
+ // case 'free_answer':
256
+ // formListener.displayFreeAnswer();
257
+ // break;
258
+ // case 'sort_answer':
259
+ // formListener.displaySortAnswer();
260
+ // break;
261
+ // case 'matrix_sort_answer':
262
+ // formListener.displayMatrixSortAnswer();
263
+ // break;
264
+ // case 'cloze_answer':
265
+ // formListener.displayClozeAnswer();
266
+ // break;
267
+ // }
268
+ // });
269
+ //
270
+ // $('.addAnswer').click(function(e) {
271
+ // formListener.addAnswer(this);
272
+ // });
273
+ //
274
+ // $('.deleteAnswer').click(function(e) {
275
+ // formListener.deleteAnswer(this);
276
+ // });
277
+ //
278
+ // $('#saveQuestion').click(function(e) {
279
+ // return validate();
280
+ // });
281
+ //
282
+ // $('.sort_answer ul, .classic_answer ul, .matrix_sort_answer ul').sortable({
283
+ // handle: '.wpProQuiz_move',
284
+ // update: function(event, ui) {
285
+ // formListener.setValueClassicAnswer();
286
+ // }
287
+ // });
288
+ //
289
+ // $('#wpProQuiz_correctSameText').change(function() {
290
+ // if(this.checked)
291
+ // $('#wpProQuiz_incorrectMassageBox').hide();
292
+ // else
293
+ // $('#wpProQuiz_incorrectMassageBox').show();
294
+ // });
295
+ //
296
+ // $('#wpProQuiz_tip').change(function(e) {
297
+ // if(this.checked)
298
+ // $('#wpProQuiz_tipBox').show();
299
+ // else
300
+ // $('#wpProQuiz_tipBox').hide();
301
+ // });
302
+ //
303
+ // $('input[name="pointsPerAnswer"]').change(function() {
304
+ // if(this.checked) {
305
+ // $('#wpProQuiz_showPointsBox').show();
306
+ // } else {
307
+ // $('#wpProQuiz_showPointsBox').hide();
308
+ // }
309
+ // });
310
+ //
311
+ // $('input[name="answerPointsActivated"]').change(function() {
312
+ // if(this.checked) {
313
+ // $('input[name="points"]').attr('disabled', 'disabled');
314
+ // $('.wpProQuiz_answerPoints').show();
315
+ // $('#wpProQuiz_showPointsBox').show();
316
+ // } else {
317
+ // $('input[name="points"]').removeAttr('disabled');
318
+ // $('.wpProQuiz_answerPoints').hide();
319
+ // $('#wpProQuiz_showPointsBox').hide();
320
+ // }
321
+ // });
322
+ //
323
+ // $('.wpProQuiz_demoBox a').mouseover(function() {
324
+ // $(this).next().show();
325
+ // }).mouseout(function() {
326
+ // $(this).next().hide();
327
+ // }).click(function() {
328
+ // return false;
329
+ // });
330
+ //
331
+ // },
332
+ //
333
+ // displaySingle: function(type) {
334
+ // $('.classic_answer').find('input[name="answerJson[classic_answer][correct][]"]').each(function() {
335
+ // $("<input type=" + type + " />").attr({ name: this.name, value: this.value, checked: this.checked}).insertBefore(this);
336
+ // }).remove();
337
+ //
338
+ // $('.classic_answer').css('display', 'block');
339
+ // },
340
+ //
341
+ // displayFreeAnswer: function() {
342
+ // $('.free_answer').css('display', 'block');
343
+ // },
344
+ //
345
+ // displaySortAnswer: function() {
346
+ // $('.sort_answer').css('display', 'block');
347
+ // },
348
+ //
349
+ // displayMatrixSortAnswer: function() {
350
+ // $('.matrix_sort_answer').show();
351
+ // },
352
+ //
353
+ // displayClozeAnswer: function() {
354
+ // $('.cloze_answer').show();
355
+ // },
356
+ //
357
+ // addAnswer: function(obj) {
358
+ // $(obj).siblings('ul').children().first()
359
+ // .clone().css('display', 'block')
360
+ // .appendTo($(obj).siblings('ul'));
361
+ //
362
+ // formListener.setValueClassicAnswer();
363
+ //
364
+ // $('.deleteAnswer').click(function(e) {
365
+ // formListener.deleteAnswer(this);
366
+ // });
367
+ // },
368
+ //
369
+ // deleteAnswer: function(obj) {
370
+ // $(obj).parent().parent('li').remove();
371
+ //
372
+ // formListener.setValueClassicAnswer();
373
+ // },
374
+ //
375
+ // setValueClassicAnswer: function() {
376
+ //
377
+ // $('.classic_answer ul, .matrix_sort_answer ul, .sort_answer ul').children().each(function() {
378
+ // var index = $(this).index();
379
+ //
380
+ // $(this).find( 'input[name="answerJson[classic_answer][correct][]"], '
381
+ // + 'input[name="answerJson[classic_answer][html][]"], '
382
+ // + 'input[name="answerJson[answer_matrix_sort][answer_html][]"], '
383
+ // + 'input[name="answerJson[answer_matrix_sort][sort_string_html][]"], '
384
+ // + 'input[name="answerJson[answer_sort][html][]"]').val(index);
385
+ // });
386
+ // }
387
+ // };
388
+ //
389
+ // var validate = function () {
390
+ //
391
+ // var question = '';
392
+ // var type = $('input[name="answerType"]:checked');
393
+ // var $points = $('input[name="points"]');
394
+ //
395
+ // if(tinymce.editors.question != undefined && !tinymce.editors.question.isHidden()) {
396
+ // question = tinymce.editors.question.getContent();
397
+ // } else {
398
+ // question = $('textarea[name="question"]').val();
399
+ // }
400
+ //
401
+ // if(isNaN($points.val()) || $points.val() < 1) {
402
+ // alert(wpProQuizLocalize.no_nummber_points);
403
+ // $points.focus();
404
+ // return false;
405
+ // }
406
+ //
407
+ // if(isEmpty(question)) {
408
+ // alert(wpProQuizLocalize.no_question_msg);
409
+ // return false;
410
+ // }
411
+ //
412
+ //
413
+ // if(type.val() == 'single' || type.val() == 'multiple') {
414
+ // var findChecked = true;
415
+ // var findPoints = true;
416
+ // if($('input[name="answerJson[classic_answer][correct][]"]:checked').each(function() {
417
+ // if($.trim($(this).parent().parent().parent().parent().find('textarea').val()) != '') {
418
+ // findChecked &= true;
419
+ // } else {
420
+ // findChecked = false;
421
+ // }
422
+ // })
423
+ // .size() < 1) {
424
+ // alert(wpProQuizLocalize.no_correct_msg);
425
+ // return false;
426
+ // }
427
+ //
428
+ // if($('input[name="answerPointsActivated"]:checked').length) {
429
+ // $('input[name="answerJson[classic_answer][points][]"]').each(function() {
430
+ // if($.trim($(this).parentsUntil('table').find('textarea').val()) != '') {
431
+ // var points = $.trim($(this).val());
432
+ //
433
+ // if(isNaN(points) || points == '' || points < 0) {
434
+ // findPoints = false;
435
+ // } else {
436
+ // findPoints &= true;
437
+ // }
438
+ // }
439
+ // });
440
+ //
441
+ // if(!findPoints) {
442
+ // alert(wpProQuizLocalize.no_nummber_points_new);
443
+ // return false;
444
+ // }
445
+ // }
446
+ //
447
+ // if(!findChecked) {
448
+ // alert(wpProQuizLocalize.no_answer_msg);
449
+ // return false;
450
+ // }
451
+ // } else if(type.val() == 'sort_answer') {
452
+ // var findChecked = false;
453
+ // var findPoints = true;
454
+ //
455
+ // $('textarea[name="answerJson[answer_sort][answer][]"]').each(function() {
456
+ // if(isEmpty($(this).val())) {
457
+ // findChecked |= false;
458
+ // } else {
459
+ // findChecked = true;
460
+ // }
461
+ // });
462
+ //
463
+ // if($('input[name="answerPointsActivated"]:checked').length) {
464
+ // $('input[name="answerJson[answer_sort][points][]"]').each(function() {
465
+ // if($.trim($(this).parentsUntil('table').find('textarea').val()) != '') {
466
+ // var points = $.trim($(this).val());
467
+ //
468
+ // if(isNaN(points) || points == '' || points < 0) {
469
+ // findPoints = false;
470
+ // } else {
471
+ // findPoints &= true;
472
+ // }
473
+ // }
474
+ // });
475
+ //
476
+ // if(!findPoints) {
477
+ // alert(wpProQuizLocalize.no_nummber_points_new);
478
+ // return false;
479
+ // }
480
+ // }
481
+ //
482
+ // if(!findChecked) {
483
+ // alert(wpProQuizLocalize.no_answer_msg);
484
+ // return false;
485
+ // }
486
+ // } else if(type.val() == 'matrix_sort_answer') {
487
+ // var findChecked = false;
488
+ // var findPoints = true;
489
+ // $('textarea[name="answerJson[answer_matrix_sort][answer][]"]').each(function() {
490
+ // if(isEmpty($(this).val())) {
491
+ // findChecked |= false;
492
+ // } else {
493
+ //
494
+ // var $sortString = $(this).parent().parent().find('textarea[name="answerJson[answer_matrix_sort][sort_string][]"]');
495
+ //
496
+ // if(isEmpty($sortString.val())) {
497
+ // findChecked |= false;
498
+ // } else {
499
+ // findChecked = true;
500
+ // }
501
+ // }
502
+ // });
503
+ //
504
+ // if($('input[name="answerPointsActivated"]:checked').length) {
505
+ // $('input[name="answerJson[answer_matrix_sort][points][]"]').each(function() {
506
+ // if($.trim($(this).parentsUntil('table').find('textarea').val()) != '') {
507
+ // var points = $.trim($(this).val());
508
+ //
509
+ // if(isNaN(points) || points == '' || points < 0) {
510
+ // findPoints = false;
511
+ // } else {
512
+ // findPoints &= true;
513
+ // }
514
+ // }
515
+ // });
516
+ //
517
+ // if(!findPoints) {
518
+ // alert(wpProQuizLocalize.no_nummber_points_new);
519
+ // return false;
520
+ // }
521
+ // }
522
+ //
523
+ // if(!findChecked) {
524
+ // alert(wpProQuizLocalize.no_answer_msg);
525
+ // return false;
526
+ // }
527
+ // } else if(type.val() == 'cloze_answer') {
528
+ // var clozeText = '';
529
+ //
530
+ // if(tinymce.editors.cloze != undefined && !tinymce.editors.cloze.isHidden()) {
531
+ // clozeText = tinymce.editors.cloze.getContent();
532
+ // } else {
533
+ // clozeText = $('textarea[name="answerJson[answer_cloze][text]"]').val();
534
+ // }
535
+ //
536
+ // if(isEmpty(clozeText)) {
537
+ // alert(wpProQuizLocalize.no_answer_msg);
538
+ // return false;
539
+ // }
540
+ // } else if(type.val() == 'free_answer') {
541
+ // var freeText = $('textarea[name="answerJson[free_answer][correct]"]').val();
542
+ //
543
+ // if(isEmpty(freeText)) {
544
+ // alert(wpProQuizLocalize.no_answer_msg);
545
+ // return false;
546
+ // }
547
+ // }
548
+ //
549
+ // return true;
550
+ // };
551
+ //
552
+ // var isEmpty = function(str) {
553
+ // str = $.trim(str);
554
+ // return (!str || 0 === str.length);
555
+ // };
556
+ //
557
+ // formListener.setup();
558
+ // setup();
559
+ // };
560
+
561
+ //$.fn.wpProQuiz_questionOverall = function() {
562
+ //
563
+ // var methode = {
564
+ // saveSort: function() {
565
+ //
566
+ // var data = {
567
+ // action: 'wp_pro_quiz_update_sort',
568
+ // sort: methode.parseSortArray()
569
+ // };
570
+ //
571
+ // var location = window.location.pathname + window.location.search;
572
+ // var url = location.replace('admin.php', 'admin-ajax.php') + '&action=save_sort';
573
+ //
574
+ // $.post(url, data, function(response) {
575
+ // $('#sortMsg').show(400).delay(1000).hide(400);
576
+ // });
577
+ // },
578
+ //
579
+ // parseSortArray: function() {
580
+ // var array = new Array();
581
+ //
582
+ // $('tbody tr').each(function() {
583
+ // array.push(this.id.replace('wpProQuiz_questionId_', ''));
584
+ // });
585
+ //
586
+ // return array;
587
+ // },
588
+ //
589
+ // sortUpdate: function(e, ui) {
590
+ // $('.wpProQuiz_questionOverall tbody').children().each(function() {
591
+ // $t = $(this).children().first().text($(this).index() + 1);
592
+ // });
593
+ // },
594
+ //
595
+ // loadQuestionCopy: function() {
596
+ // var list = $('#questionCopySelect');
597
+ // var location = window.location.pathname + window.location.search;
598
+ // var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_question';
599
+ // var data = {
600
+ // action: 'wp_pro_quiz_load_question',
601
+ // excludeId: 1
602
+ // };
603
+ //
604
+ // list.hide();
605
+ // list.empty();
606
+ //
607
+ // $('#loadDataImg').show();
608
+ //
609
+ // $.post(
610
+ // url,
611
+ // data,
612
+ // function(json) {
613
+ // $.each(json, function(i, v) {
614
+ //
615
+ // var group = $(document.createElement('optgroup'));
616
+ //
617
+ // group.attr('label', v.name);
618
+ //
619
+ // $.each(v.question, function(qi, qv) {
620
+ // $(document.createElement('option'))
621
+ // .val(qv.id)
622
+ // .text(qv.name)
623
+ // .appendTo(group);
624
+ //
625
+ //
626
+ // });
627
+ //
628
+ // list.append(group);
629
+ //
630
+ // });
631
+ //
632
+ // $('#loadDataImg').hide();
633
+ // list.show();
634
+ // },
635
+ // 'json'
636
+ // );
637
+ // }
638
+ // };
639
+ //
640
+ // var init = function() {
641
+ // $('.wp-list-table tbody').sortable({ handle: '.wpProQuiz_move', update: methode.sortUpdate });
642
+ //
643
+ // $('.wpProQuiz_delete').click(function(e) {
644
+ // var b = confirm(wpProQuizLocalize.delete_msg);
645
+ //
646
+ // if(!b) {
647
+ // e.preventDefault();
648
+ // return false;
649
+ // }
650
+ //
651
+ // return true;
652
+ // });
653
+ //
654
+ // $('#wpProQuiz_saveSort').click(function(e) {
655
+ // e.preventDefault();
656
+ // methode.saveSort();
657
+ // });
658
+ //
659
+ // $('#wpProQuiz_questionCopy').click(function(e) {
660
+ // var $this = $('.wpProQuiz_questionCopy');
661
+ //
662
+ // if($this.is(':visible')) {
663
+ // $this.hide();
664
+ // } else {
665
+ // $this.show();
666
+ // methode.loadQuestionCopy();
667
+ // }
668
+ //
669
+ // e.preventDefault();
670
+ // });
671
+ // };
672
+ //
673
+ // init();
674
+ //};
675
+
676
+ $.fn.wpProQuiz_quizEdit = function () {
677
+
678
+ function ajaxPost(func, data, success) {
679
+ var d = {
680
+ action: 'wp_pro_quiz_admin_ajax',
681
+ func: func,
682
+ data: data
683
+ };
684
+
685
+ $.post(ajaxurl, d, success, 'json');
686
+ };
687
+
688
+ var methode = {
689
+ addCategory: function () {
690
+ var name = $.trim($('input[name="categoryAdd"]').val());
691
+
692
+ if (isEmpty(name)) {
693
+ return;
694
+ }
695
+
696
+ var data = {
697
+ categoryName: name,
698
+ type: 'quiz'
699
+ };
700
+
701
+ ajaxPost('categoryAdd', data, function (json) {
702
+ if (json.err) {
703
+ $('#categoryMsgBox').text(json.err).show('fast').delay(2000).hide('fast');
704
+ return;
705
+ }
706
+
707
+ var $option = $(document.createElement('option'))
708
+ .val(json.categoryId)
709
+ .text(json.categoryName)
710
+ .attr('selected', 'selected');
711
+
712
+ $('select[name="category"]').append($option).change();
713
+
714
+ });
715
+ },
716
+
717
+ addResult: function () {
718
+ $('#resultList').children().each(function () {
719
+ if ($(this).css('display') == 'none') {
720
+ //TODO rework
721
+ var $this = $(this);
722
+ var $text = $this.find('textarea[name="resultTextGrade[text][]"]');
723
+ var id = $text.attr('id');
724
+ var hidden = true;
725
+
726
+ $this.find('input[name="resultTextGrade[prozent][]"]').val('0');
727
+ $this.find('input[name="resultTextGrade[activ][]"]').val('1').keyup();
728
+
729
+ if (tinymce.editors[id] != undefined && !tinymce.editors[id].isHidden()) {
730
+ hidden = false;
731
+ }
732
+
733
+ if (switchEditors != undefined && !hidden) {
734
+ switchEditors.go(id, 'toggle');
735
+ switchEditors.go(id, 'toggle');
736
+ }
737
+
738
+ if (tinymce.editors[id] != undefined) {
739
+ tinymce.editors[id].setContent('');
740
+ } else {
741
+ $text.val('');
742
+ }
743
+
744
+ if (tinymce.editors[id] != undefined && !hidden) {
745
+ tinyMCE.execCommand('mceRemoveControl', false, id);
746
+ }
747
+
748
+ $this.parent().children(':visible').last().after($this);
749
+
750
+ if (tinymce.editors[id] != undefined && !hidden) {
751
+ tinyMCE.execCommand('mceAddControl', false, id);
752
+ }
753
+
754
+ $(this).show();
755
+
756
+ if (switchEditors != undefined && !hidden) {
757
+ switchEditors.go(id, 'toggle');
758
+ }
759
+
760
+ return false;
761
+ }
762
+ });
763
+ },
764
+
765
+ deleteResult: function (e) {
766
+ $(e).parent().parent().hide();
767
+ $(e).siblings('input[name="resultTextGrade[activ][]"]').val('0');
768
+ },
769
+
770
+ changeResult: function (e) {
771
+ var $this = $(e);
772
+
773
+ if (methode.validResultInput($this.val())) {
774
+ $this.siblings('.resultProzent').text($this.val());
775
+ $this.removeAttr('style');
776
+ return true;
777
+ }
778
+
779
+ $this.css('background-color', '#FF9696');
780
+
781
+ return false;
782
+ },
783
+
784
+ validResultInput: function (input) {
785
+
786
+ if (isEmpty(input))
787
+ return false;
788
+
789
+ input = input.replace(/\,/, '.');
790
+
791
+ if (!isNaN(input) && Number(input) <= 100 && Number(input) >= 0) {
792
+ if (input.match(/\./) != null)
793
+ return input.split('.')[1].length < 3;
794
+
795
+ return true;
796
+ }
797
+
798
+ return false;
799
+ },
800
+
801
+ validInput: function () {
802
+ if (isEmpty($('#wpProQuiz_title').val())) {
803
+ alert(wpProQuizLocalize.no_title_msg);
804
+ return false;
805
+ }
806
+
807
+ var text = '';
808
+
809
+ if (tinymce.editors.text != undefined && !tinymce.editors.text.isHidden()) {
810
+ text = tinymce.editors.text.getContent();
811
+ } else {
812
+ text = $('textarea[name="text"]').val();
813
+ }
814
+
815
+ if (isEmpty(text)) {
816
+ alert(wpProQuizLocalize.no_quiz_start_msg);
817
+ return false;
818
+ }
819
+
820
+ if ($('#wpProQuiz_resultGradeEnabled:checked').length) {
821
+ var rCheck = true;
822
+
823
+ $('#resultList').children().each(function () {
824
+ if ($(this).is(':visible')) {
825
+ if (!methode.validResultInput($(this).find('input[name="resultTextGrade[prozent][]"]').val())) {
826
+ rCheck = false;
827
+ return false;
828
+ }
829
+ }
830
+ });
831
+
832
+ if (!rCheck) {
833
+ alert(wpProQuizLocalize.fail_grade_result);
834
+ return false;
835
+ }
836
+ }
837
+
838
+ return true;
839
+ },
840
+
841
+ resetLock: function () {
842
+ //var location = window.location.pathname + window.location.search;
843
+ //var url = location.replace('admin.php', 'admin-ajax.php');
844
+ //url = url.replace('action=edit', 'action=reset_lock');
845
+ //
846
+ //$.post(url, {
847
+ // action: 'wp_pro_quiz_reset_lock'
848
+ //}, function (data) {
849
+ // $('#resetLockMsg').show('fast').delay(2000).hide('fast');
850
+ //});
851
+
852
+ ajaxPost('resetLock', {
853
+ quizId: $('input[name="ajax_quiz_id"]').val()
854
+ }, function () {
855
+ $('#resetLockMsg').show('fast').delay(2000).hide('fast');
856
+ });
857
+ },
858
+
859
+ generateFormIds: function () {
860
+ var index = 0;
861
+
862
+ $('#form_table tbody > tr').each(function () {
863
+ $(this).find('[name^="form[]"]').each(function () {
864
+ var newname = $(this).attr('name').substr(6);
865
+ $(this).attr('name', 'form[' + index + ']' + newname);
866
+ });
867
+
868
+ ++index;
869
+ });
870
+ },
871
+
872
+ updateFormIds: function () {
873
+ var index = -1;
874
+ var selected = $('.emailFormVariables option:selected').val();
875
+ var $formVariables = $('.formVariables').empty();
876
+ var $emailFormVariables = $('.emailFormVariables').empty().append('<option value="-1"></option>');
877
+
878
+ if ($('.emailFormVariables').data('default') > -1) {
879
+ selected = $('.emailFormVariables').data('default');
880
+ $('.emailFormVariables').data('default', -1);
881
+ }
882
+
883
+ $('#form_table tbody > tr').each(function () {
884
+ $(this).children().first().text(index);
885
+ var fieldName = $(this).find('.formFieldName').val();
886
+ var type = $(this).find('[name="form[][type]"] option:selected');
887
+ var name = $(this).find('[name="form[][fieldname]"]').val();
888
+
889
+ //is deleted?
890
+ if ($(this).find('input[name="form[][form_delete]"]').val() == 1)
891
+ return;
892
+
893
+ if (index >= 0 && !isEmpty(fieldName))
894
+ $formVariables.append($('<li><span>$form{' + index + '}</span> - ' + fieldName + '</li>'));
895
+
896
+ if (type.val() == 4)
897
+ $emailFormVariables.append($('<option value="' + index + '">' + name + '</option>'))
898
+
899
+ index++;
900
+ });
901
+
902
+ $('.emailFormVariables option[value="' + selected + '"]').prop('selected', true);
903
+ }
904
+
905
+ };
906
+
907
+ var isEmpty = function (str) {
908
+ str = $.trim(str);
909
+ return (!str || 0 === str.length);
910
+ };
911
+
912
+ var init = function () {
913
+ $('#statistics_on').change(function () {
914
+ if (this.checked) {
915
+ $('#statistics_ip_lock_tr').show();
916
+ } else {
917
+ $('#statistics_ip_lock_tr').hide();
918
+ }
919
+ });
920
+
921
+ $('.addResult').click(function () {
922
+ methode.addResult();
923
+ });
924
+
925
+ $('.deleteResult').click(function (e) {
926
+ methode.deleteResult(this);
927
+ });
928
+
929
+ $('input[name="resultTextGrade[prozent][]"]').keyup(function (event) {
930
+ methode.changeResult(this);
931
+ }).keydown(function (event) {
932
+ if (event.which == 13) {
933
+ event.preventDefault();
934
+ }
935
+ });
936
+
937
+ $('#wpProQuiz_resultGradeEnabled').change(function () {
938
+ if (this.checked) {
939
+ $('#resultGrade').show();
940
+ $('#resultNormal').hide();
941
+ } else {
942
+ $('#resultGrade').hide();
943
+ $('#resultNormal').show();
944
+ }
945
+ });
946
+
947
+ $('#wpProQuiz_save').click(function (e) {
948
+ if (!methode.validInput())
949
+ e.preventDefault();
950
+ else
951
+ methode.generateFormIds();
952
+
953
+ $('select[name="prerequisiteList[]"] option').attr('selected', 'selected');
954
+ });
955
+
956
+ $('input[name="template"]').click(function (e) {
957
+ if ($('select[name="templateSaveList"]').val() == '0') {
958
+ if (isEmpty($('input[name="templateName"]').val())) {
959
+ alert(wpProQuizLocalize.temploate_no_name);
960
+
961
+ e.preventDefault();
962
+ return false;
963
+ }
964
+ }
965
+
966
+ methode.generateFormIds();
967
+ $('select[name="prerequisiteList[]"] option').attr('selected', 'selected');
968
+ });
969
+
970
+ $('select[name="templateSaveList"]').change(function () {
971
+ var $templateName = $('input[name="templateName"]');
972
+
973
+ if ($(this).val() == '0') {
974
+ $templateName.show();
975
+ } else {
976
+ $templateName.hide();
977
+ }
978
+ }).change();
979
+
980
+ $('input[name="quizRunOnce"]').change(function (e) {
981
+ if (this.checked) {
982
+ $('#wpProQuiz_quiz_run_once_type').show();
983
+ $('input[name="quizRunOnceType"]:checked').change();
984
+ } else {
985
+ $('#wpProQuiz_quiz_run_once_type').hide();
986
+ }
987
+ });
988
+
989
+ $('input[name="quizRunOnceType"]').change(function (e) {
990
+ if (this.checked && (this.value == "1" || this.value == "3")) {
991
+ $('#wpProQuiz_quiz_run_once_cookie').show();
992
+ } else {
993
+ $('#wpProQuiz_quiz_run_once_cookie').hide();
994
+ }
995
+ });
996
+
997
+ $('input[name="resetQuizLock"]').click(function (e) {
998
+ methode.resetLock();
999
+
1000
+ return false;
1001
+ });
1002
+
1003
+ $('.wpProQuiz_demoBox a').mouseover(function (e) {
1004
+ var $this = $(this);
1005
+ var d = $('#poststuff').width();
1006
+ var img = $this.siblings().outerWidth(true);
1007
+
1008
+ if (e.pageX + img > d) {
1009
+ //var v = d + (e.pageX - (e.pageX + img + 30));
1010
+ var v = jQuery(document).width() - $this.parent().offset().left - img - 30;
1011
+ $(this).next().css('left', v + "px");
1012
+ }
1013
+
1014
+ $(this).next().show();
1015
+
1016
+ }).mouseout(function () {
1017
+ $(this).next().hide();
1018
+ }).click(function () {
1019
+ return false;
1020
+ });
1021
+
1022
+ $('input[name="showMaxQuestion"]').change(function () {
1023
+ if (this.checked) {
1024
+ // $('input[name="statisticsOn"]').removeAttr('checked').attr('disabled', 'disabled').change();
1025
+ $('#wpProQuiz_showMaxBox').show();
1026
+ } else {
1027
+ // $('input[name="statisticsOn"]').removeAttr('disabled');
1028
+ $('#wpProQuiz_showMaxBox').hide();
1029
+ }
1030
+ });
1031
+
1032
+ $('#btnPrerequisiteAdd').click(function () {
1033
+ $('select[name="quizList"] option:selected').removeAttr('selected').appendTo('select[name="prerequisiteList[]"]');
1034
+ });
1035
+
1036
+ $('#btnPrerequisiteDelete').click(function () {
1037
+ $('select[name="prerequisiteList[]"] option:selected').removeAttr('selected').appendTo('select[name="quizList"]');
1038
+ });
1039
+
1040
+ $('input[name="prerequisite"]').change(function () {
1041
+ if (this.checked)
1042
+ $('#prerequisiteBox').show();
1043
+ else
1044
+ $('#prerequisiteBox').hide();
1045
+
1046
+ }).change();
1047
+
1048
+ $('input[name="toplistDataAddMultiple"]').change(function () {
1049
+ if (this.checked)
1050
+ $('#toplistDataAddBlockBox').show();
1051
+ else
1052
+ $('#toplistDataAddBlockBox').hide();
1053
+
1054
+ }).change();
1055
+
1056
+ $('input[name="toplistActivated"]').change(function () {
1057
+ if (this.checked)
1058
+ $('#toplistBox > tr:gt(0)').show();
1059
+ else
1060
+ $('#toplistBox > tr:gt(0)').hide();
1061
+
1062
+ }).change();
1063
+
1064
+ $('input[name="showReviewQuestion"]').change(function () {
1065
+ if (this.checked) {
1066
+ $('.wpProQuiz_reviewQuestionOptions').show();
1067
+ } else {
1068
+ $('.wpProQuiz_reviewQuestionOptions').hide();
1069
+ }
1070
+ }).change();
1071
+
1072
+ $('#statistics_on').change();
1073
+ $('#wpProQuiz_resultGradeEnabled').change();
1074
+ $('input[name="quizRunOnce"]').change();
1075
+ $('input[name="quizRunOnceType"]:checked').change();
1076
+ $('input[name="showMaxQuestion"]').change();
1077
+
1078
+ $('#form_add').click(function () {
1079
+ $('#form_table tbody > tr:eq(0)').clone(true).appendTo('#form_table tbody').show();
1080
+ methode.updateFormIds();
1081
+ });
1082
+
1083
+ $('input[name="form_delete"]').click(function () {
1084
+ var con = $(this).parents('tr');
1085
+
1086
+ if (con.find('input[name="form[][form_id]"]').val() != "0") {
1087
+ con.find('input[name="form[][form_delete]"]').val(1);
1088
+ con.hide();
1089
+ } else {
1090
+ con.remove();
1091
+ }
1092
+
1093
+ methode.updateFormIds();
1094
+ });
1095
+
1096
+ $('#form_table tbody').sortable({
1097
+ handle: '.form_move',
1098
+ update: methode.updateFormIds
1099
+ });
1100
+ $('.form_move').click(function () {
1101
+ return false;
1102
+ });
1103
+
1104
+ $('select[name="form[][type]"]').change(function () {
1105
+ switch (Number($(this).val())) {
1106
+ case 7:
1107
+ case 8:
1108
+ $(this).siblings('.editDropDown').show();
1109
+ break;
1110
+ default:
1111
+ $(this).siblings('.editDropDown, .dropDownEditBox').hide();
1112
+ break;
1113
+ }
1114
+
1115
+ }).change();
1116
+
1117
+ $('.editDropDown').click(function () {
1118
+ $('.dropDownEditBox').not(
1119
+ $(this).siblings('.dropDownEditBox').toggle())
1120
+ .hide();
1121
+
1122
+ return false;
1123
+ });
1124
+
1125
+ $('.dropDownEditBox input').click(function () {
1126
+ $(this).parent().hide();
1127
+ });
1128
+
1129
+ $('.formFieldName, select[name="form[][type]"]').change(function () {
1130
+ methode.updateFormIds();
1131
+ });
1132
+
1133
+ $('select[name="category"]').change(function () {
1134
+ var $this = $(this);
1135
+ var box = $('#categoryAddBox').hide();
1136
+
1137
+ if ($this.val() == "-1") {
1138
+ box.show();
1139
+ }
1140
+
1141
+ }).change();
1142
+
1143
+ $('#categoryAddBtn').click(function () {
1144
+ methode.addCategory();
1145
+ });
1146
+
1147
+ $('input[name="emailNotification"]').change(function () {
1148
+ var $tr = $('#adminEmailSettings tr:gt(0)');
1149
+
1150
+ if ($('input[name="emailNotification"]:checked').val() > 0) {
1151
+ $tr.show();
1152
+ } else {
1153
+ $tr.hide();
1154
+ }
1155
+ }).change();
1156
+
1157
+ $('input[name="userEmailNotification"]').change(function () {
1158
+ var $tr = $('#userEmailSettings tr:gt(0)');
1159
+
1160
+ if ($('input[name="userEmailNotification"]:checked').val() > 0) {
1161
+ $tr.show();
1162
+ } else {
1163
+ $tr.hide();
1164
+ }
1165
+ }).change();
1166
+
1167
+ methode.updateFormIds();
1168
+
1169
+ $('input[name="email[html]"]').change(function () {
1170
+ if (switchEditors == undefined)
1171
+ return false;
1172
+
1173
+ if (this.checked) {
1174
+ switchEditors.go('adminEmailEditor', 'tmce');
1175
+ } else {
1176
+ switchEditors.go('adminEmailEditor', 'html');
1177
+ }
1178
+
1179
+ });
1180
+
1181
+ $('input[name="adminEmail[html]"]').change(function () {
1182
+ if (switchEditors == undefined)
1183
+ return false;
1184
+
1185
+ if (this.checked) {
1186
+ switchEditors.go('adminEmailEditor', 'tmce');
1187
+ } else {
1188
+ switchEditors.go('adminEmailEditor', 'html');
1189
+ }
1190
+
1191
+ });
1192
+
1193
+ $('input[name="userEmail[html]"]').change(function () {
1194
+ if (switchEditors == undefined)
1195
+ return false;
1196
+
1197
+ if (this.checked) {
1198
+ switchEditors.go('userEmailEditor', 'tmce');
1199
+ } else {
1200
+ switchEditors.go('userEmailEditor', 'html');
1201
+ }
1202
+
1203
+ });
1204
+
1205
+ setTimeout(function () {
1206
+ $('input[name="userEmail[html]"]').change();
1207
+ $('input[name="email[html]"]').change();
1208
+ }, 1000);
1209
+ };
1210
+
1211
+ init();
1212
+ };
1213
+
1214
+ $.fn.wpProQuiz_statistics = function () {
1215
+ var currectTab = 'wpProQuiz_typeAnonymeUser';
1216
+ var changePageNav = true;
1217
+
1218
+ var methode = {
1219
+ loadStatistics: function (userId) {
1220
+ var location = window.location.pathname + window.location.search;
1221
+ var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_statistics';
1222
+ var data = {
1223
+ action: 'wp_pro_quiz_load_statistics',
1224
+ userId: userId
1225
+ };
1226
+
1227
+ $('#wpProQuiz_loadData').show();
1228
+ $('#wpProQuiz_statistics_content, #wpProQuiz_statistics_overview').hide();
1229
+
1230
+ $.post(
1231
+ url,
1232
+ data,
1233
+ methode.setStatistics,
1234
+ 'json'
1235
+ );
1236
+ },
1237
+
1238
+ setStatistics: function (json) {
1239
+ var $table = $('.wpProQuiz_statistics_table');
1240
+ var $tbody = $table.find('tbody');
1241
+
1242
+ if (currectTab == 'wpProQuiz_typeOverview') {
1243
+ return;
1244
+ }
1245
+
1246
+ var setItem = function (i, j, r) {
1247
+ i.find('.wpProQuiz_cCorrect').text(j.cCorrect + ' (' + j.pCorrect + '%)');
1248
+ i.find('.wpProQuiz_cIncorrect').text(j.cIncorrect + ' (' + j.pIncorrect + '%)');
1249
+ i.find('.wpProQuiz_cTip').text(j.cTip);
1250
+ i.find('.wpProQuiz_cPoints').text(j.cPoints);
1251
+
1252
+ if (r == true) {
1253
+ $table.find('.wpProQuiz_cResult').text(j.result + '%');
1254
+ }
1255
+ };
1256
+
1257
+ setItem($table, json.clear, false);
1258
+
1259
+ $.each(json.items, function (i, v) {
1260
+ setItem($tbody.find('#wpProQuiz_tr_' + v.id), v, false);
1261
+ });
1262
+
1263
+ setItem($table.find('tfoot'), json.global, true);
1264
+
1265
+ $('#wpProQuiz_loadData').hide();
1266
+ $('#wpProQuiz_statistics_content, .wpProQuiz_statistics_table').show();
1267
+ },
1268
+
1269
+ loadOverview: function () {
1270
+ $('.wpProQuiz_statistics_table, #wpProQuiz_statistics_content, #wpProQuiz_statistics_overview').hide();
1271
+ $('#wpProQuiz_loadData').show();
1272
+
1273
+ var location = window.location.pathname + window.location.search;
1274
+ var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_statistics';
1275
+ var data = {
1276
+ action: 'wp_pro_quiz_load_statistics',
1277
+ overview: true,
1278
+ pageLimit: $('#wpProQuiz_pageLimit').val(),
1279
+ onlyCompleted: Number($('#wpProQuiz_onlyCompleted').is(':checked')),
1280
+ page: $('#wpProQuiz_currentPage').val(),
1281
+ generatePageNav: Number(changePageNav)
1282
+ };
1283
+
1284
+ $.post(
1285
+ url,
1286
+ data,
1287
+ function (json) {
1288
+ $('#wpProQuiz_statistics_overview_data').empty();
1289
+
1290
+ if (currectTab != 'wpProQuiz_typeOverview') {
1291
+ return;
1292
+ }
1293
+
1294
+ var item = $('<tr>'
1295
+ + '<th><a href="#">---</a></th>'
1296
+ + '<th class="wpProQuiz_points">---</th>'
1297
+ + '<th class="wpProQuiz_cCorrect" style="color: green;">---</th>'
1298
+ + '<th class="wpProQuiz_cIncorrect" style="color: red;">---</th>'
1299
+ + '<th class="wpProQuiz_cTip">---</th>'
1300
+ + '<th class="wpProQuiz_cResult" style="font-weight: bold;">---</th>'
1301
+ + '</tr>'
1302
+ );
1303
+
1304
+ $.each(json.items, function (i, v) {
1305
+ var d = item.clone();
1306
+
1307
+ d.find('a').text(v.userName).data('userId', v.userId).click(function () {
1308
+ $('#userSelect').val($(this).data('userId'));
1309
+
1310
+ $('#wpProQuiz_typeRegisteredUser').click();
1311
+
1312
+ return false;
1313
+ });
1314
+
1315
+ if (v.completed) {
1316
+ d.find('.wpProQuiz_points').text(v.cPoints);
1317
+ d.find('.wpProQuiz_cCorrect').text(v.cCorrect + ' (' + v.pCorrect + '%)');
1318
+ d.find('.wpProQuiz_cIncorrect').text(v.cIncorrect + ' (' + v.pIncorrect + '%)');
1319
+ d.find('.wpProQuiz_cTip').text(v.cTip);
1320
+ d.find('.wpProQuiz_cResult').text(v.result + '%');
1321
+ } else {
1322
+ d.find('th').removeAttr('style');
1323
+ }
1324
+
1325
+ $('#wpProQuiz_statistics_overview_data').append(d);
1326
+ });
1327
+
1328
+ if (json.page != undefined) {
1329
+ methode.setPageNav(json.page);
1330
+ changePageNav = false;
1331
+ }
1332
+
1333
+ $('#wpProQuiz_loadData').hide();
1334
+ $('#wpProQuiz_statistics_overview').show();
1335
+ },
1336
+ 'json'
1337
+ );
1338
+ },
1339
+
1340
+ loadFormOverview: function () {
1341
+ $('#wpProQuiz_tabFormOverview').show();
1342
+ },
1343
+
1344
+ changeTab: function (id) {
1345
+ currectTab = id;
1346
+
1347
+ if (id == 'wpProQuiz_typeRegisteredUser') {
1348
+ methode.loadStatistics($('#userSelect').val());
1349
+ } else if (id == 'wpProQuiz_typeAnonymeUser') {
1350
+ methode.loadStatistics(0);
1351
+ } else if (id == 'wpProQuiz_typeForm') {
1352
+ methode.loadFormOverview();
1353
+ } else {
1354
+ methode.loadOverview();
1355
+ }
1356
+ },
1357
+
1358
+ resetStatistic: function (complete) {
1359
+ var userId = (currectTab == 'wpProQuiz_typeRegisteredUser') ? $('#userSelect').val() : 0;
1360
+ var location = window.location.pathname + window.location.search;
1361
+ var url = location.replace('admin.php', 'admin-ajax.php') + '&action=reset';
1362
+ var data = {
1363
+ action: 'wp_pro_quiz_statistics',
1364
+ userId: userId,
1365
+ 'complete': complete
1366
+ };
1367
+
1368
+ $.post(url, data, function (e) {
1369
+ methode.changeTab(currectTab);
1370
+ });
1371
+ },
1372
+
1373
+ setPageNav: function (page) {
1374
+ page = Math.ceil(page / $('#wpProQuiz_pageLimit').val());
1375
+ $('#wpProQuiz_currentPage').empty();
1376
+
1377
+ for (var i = 1; i <= page; i++) {
1378
+ $(document.createElement('option'))
1379
+ .val(i)
1380
+ .text(i)
1381
+ .appendTo($('#wpProQuiz_currentPage'));
1382
+ }
1383
+
1384
+ $('#wpProQuiz_pageLeft, #wpProQuiz_pageRight').hide();
1385
+
1386
+ if ($('#wpProQuiz_currentPage option').length > 1) {
1387
+ $('#wpProQuiz_pageRight').show();
1388
+
1389
+ }
1390
+ }
1391
+ };
1392
+
1393
+ var init = function () {
1394
+ $('.wpProQuiz_tab').click(function (e) {
1395
+ var $this = $(this);
1396
+
1397
+ if ($this.hasClass('button-primary')) {
1398
+ return false;
1399
+ }
1400
+
1401
+ if ($this.attr('id') == 'wpProQuiz_typeRegisteredUser') {
1402
+ $('#wpProQuiz_userBox').show();
1403
+ } else {
1404
+ $('#wpProQuiz_userBox').hide();
1405
+ }
1406
+
1407
+ $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
1408
+ $this.removeClass('button-secondary').addClass('button-primary');
1409
+
1410
+ methode.changeTab($this.attr('id'));
1411
+
1412
+ return false;
1413
+ });
1414
+
1415
+ $('#userSelect').change(function () {
1416
+ methode.changeTab('wpProQuiz_typeRegisteredUser');
1417
+ });
1418
+
1419
+ $('.wpProQuiz_update').click(function () {
1420
+ methode.changeTab(currectTab);
1421
+
1422
+ return false;
1423
+ });
1424
+
1425
+ $('#wpProQuiz_reset').click(function () {
1426
+
1427
+ var c = confirm(wpProQuizLocalize.reset_statistics_msg);
1428
+
1429
+ if (c) {
1430
+ methode.resetStatistic(false);
1431
+ }
1432
+
1433
+ return false;
1434
+ });
1435
+
1436
+ $('.wpProQuiz_resetComplete').click(function () {
1437
+
1438
+ var c = confirm(wpProQuizLocalize.reset_statistics_msg);
1439
+
1440
+ if (c) {
1441
+ methode.resetStatistic(true);
1442
+ }
1443
+
1444
+ return false;
1445
+ });
1446
+
1447
+ $('#wpProQuiz_pageLimit, #wpProQuiz_onlyCompleted').change(function () {
1448
+ $('#wpProQuiz_currentPage').val(0);
1449
+ changePageNav = true;
1450
+ methode.changeTab(currectTab);
1451
+
1452
+ return false;
1453
+ });
1454
+
1455
+ $('#wpProQuiz_currentPage').change(function () {
1456
+ $('#wpProQuiz_pageLeft, #wpProQuiz_pageRight').hide();
1457
+
1458
+ if ($('#wpProQuiz_currentPage option').length == 1) {
1459
+
1460
+ } else if ($('#wpProQuiz_currentPage option:first-child:selected').length) {
1461
+ $('#wpProQuiz_pageRight').show();
1462
+ } else if ($('#wpProQuiz_currentPage option:last-child:selected').length) {
1463
+ $('#wpProQuiz_pageLeft').show();
1464
+ } else {
1465
+ $('#wpProQuiz_pageLeft, #wpProQuiz_pageRight').show();
1466
+ }
1467
+
1468
+ methode.changeTab(currectTab);
1469
+ });
1470
+
1471
+ $('#wpProQuiz_pageRight').click(function () {
1472
+ $('#wpProQuiz_currentPage option:selected').next().attr('selected', 'selected');
1473
+ $('#wpProQuiz_currentPage').change();
1474
+
1475
+ return false;
1476
+ });
1477
+
1478
+ $('#wpProQuiz_pageLeft').click(function () {
1479
+ $('#wpProQuiz_currentPage option:selected').prev().attr('selected', 'selected');
1480
+ $('#wpProQuiz_currentPage').change();
1481
+
1482
+ return false;
1483
+ });
1484
+
1485
+ methode.changeTab('wpProQuiz_typeAnonymeUser');
1486
+ };
1487
+
1488
+ init();
1489
+ };
1490
+
1491
+ $.fn.wpProQuiz_toplist = function () {
1492
+ function ajaxPost(func, data, success) {
1493
+ var d = {
1494
+ action: 'wp_pro_quiz_admin_ajax',
1495
+ func: func,
1496
+ data: data
1497
+ };
1498
+
1499
+ $.post(ajaxurl, d, success, 'json');
1500
+ }
1501
+
1502
+ var elements = {
1503
+ sort: $('#wpProQuiz_sorting'),
1504
+ pageLimit: $('#wpProQuiz_pageLimit'),
1505
+ currentPage: $('#wpProQuiz_currentPage'),
1506
+ loadDataBox: $('#wpProQuiz_loadData'),
1507
+ pageLeft: $('#wpProQuiz_pageLeft'),
1508
+ pageRight: $('#wpProQuiz_pageRight'),
1509
+ dataBody: $('#wpProQuiz_toplistTable tbody'),
1510
+ rowClone: $('#wpProQuiz_toplistTable tbody tr:eq(0)').clone(),
1511
+ content: $('#wpProQuiz_content')
1512
+ };
1513
+
1514
+ var methods = {
1515
+ loadData: function (action) {
1516
+ //var location = window.location.pathname + window.location.search;
1517
+ //var url = location.replace('admin.php', 'admin-ajax.php') + '&action=load_toplist';
1518
+ var th = this;
1519
+ var data = {
1520
+ //action: 'wp_pro_quiz_load_toplist',
1521
+ sort: elements.sort.val(),
1522
+ limit: elements.pageLimit.val(),
1523
+ page: elements.currentPage.val(),
1524
+ quizId: $('input[name="ajax_quiz_id"]').val()
1525
+ };
1526
+
1527
+ if (action != undefined) {
1528
+ $.extend(data, action);
1529
+ }
1530
+
1531
+ elements.loadDataBox.show();
1532
+ elements.content.hide();
1533
+
1534
+ //$.post(url, data, function (json) {
1535
+ // //methods.handleDataRequest(json.data);
1536
+ // th.handleDataRequest(json.data);
1537
+ //
1538
+ // if (json.nav != undefined) {
1539
+ // //methods.handleNav(json.nav);
1540
+ // th.handleNav(json.nav);
1541
+ // }
1542
+ //
1543
+ // elements.loadDataBox.hide();
1544
+ // elements.content.show();
1545
+ //}, 'json');
1546
+
1547
+ ajaxPost('adminToplist', data, function (json) {
1548
+ th.handleDataRequest(json.data);
1549
+
1550
+ if (json.nav != undefined) {
1551
+ th.handleNav(json.nav);
1552
+ }
1553
+
1554
+ elements.loadDataBox.hide();
1555
+ elements.content.show();
1556
+ });
1557
+ },
1558
+
1559
+ handleNav: function (nav) {
1560
+ elements.currentPage.empty();
1561
+
1562
+ for (var i = 1; i <= nav.pages; i++) {
1563
+ $(document.createElement('option'))
1564
+ .val(i).text(i)
1565
+ .appendTo(elements.currentPage);
1566
+ }
1567
+
1568
+ this.checkNav();
1569
+ },
1570
+
1571
+ handleDataRequest: function (json) {
1572
+ var methods = this;
1573
+
1574
+ elements.dataBody.empty();
1575
+
1576
+ $.each(json, function (i, v) {
1577
+ var data = elements.rowClone.clone().children();
1578
+
1579
+ data.eq(0).children().val(v.id);
1580
+ data.eq(1).find('strong').text(v.name);
1581
+ data.eq(1).find('.inline_editUsername').val(v.name);
1582
+ data.eq(2).find('.wpProQuiz_email').text(v.email);
1583
+ data.eq(2).find('input').val(v.email);
1584
+ data.eq(3).text(v.type);
1585
+ data.eq(4).text(v.date);
1586
+ data.eq(5).text(v.points);
1587
+ data.eq(6).text(v.result);
1588
+
1589
+ data.parent().show().appendTo(elements.dataBody);
1590
+ });
1591
+
1592
+ if (!json.length) {
1593
+ $(document.createElement('td'))
1594
+ .attr('colspan', '7')
1595
+ .text(wpProQuizLocalize.no_data_available)
1596
+ .css({
1597
+ 'font-weight': 'bold',
1598
+ 'text-align': 'center',
1599
+ 'padding': '5px'
1600
+ })
1601
+ .appendTo(document.createElement('tr'))
1602
+ .appendTo(elements.dataBody);
1603
+ }
1604
+
1605
+ $('.wpProQuiz_delete').click(function () {
1606
+ if (confirm(wpProQuizLocalize.confirm_delete_entry)) {
1607
+ var id = new Array($(this).closest('tr').find('input[name="checkedData[]"]').val());
1608
+
1609
+ methods.loadData({
1610
+ a: 'delete',
1611
+ toplistIds: id
1612
+ });
1613
+ }
1614
+
1615
+ return false;
1616
+ });
1617
+
1618
+ $('.wpProQuiz_edit').click(function () {
1619
+ var $contain = $(this).closest('tr');
1620
+
1621
+ $contain.find('.row-actions').hide();
1622
+ $contain.find('.inline-edit').show();
1623
+
1624
+ $contain.find('.wpProQuiz_username, .wpProQuiz_email').hide();
1625
+ $contain.find('.inline_editUsername, .inline_editEmail').show();
1626
+
1627
+ return false;
1628
+ });
1629
+
1630
+ $('.inline_editSave').click(function () {
1631
+ var $contain = $(this).closest('tr');
1632
+ var username = $contain.find('.inline_editUsername').val();
1633
+ var email = $contain.find('.inline_editEmail').val();
1634
+
1635
+ if (methods.isEmpty(username) || methods.isEmpty(email)) {
1636
+ alert(wpProQuizLocalize.not_all_fields_completed);
1637
+
1638
+ return false;
1639
+ }
1640
+
1641
+ methods.loadData({
1642
+ a: 'edit',
1643
+ toplistId: $contain.find('input[name="checkedData[]"]').val(),
1644
+ name: username,
1645
+ email: email
1646
+ });
1647
+
1648
+ return false;
1649
+ });
1650
+
1651
+ $('.inline_editCancel').click(function () {
1652
+ var $contain = $(this).closest('tr');
1653
+
1654
+ $contain.find('.row-actions').show();
1655
+ $contain.find('.inline-edit').hide();
1656
+
1657
+ $contain.find('.wpProQuiz_username, .wpProQuiz_email').show();
1658
+ $contain.find('.inline_editUsername, .inline_editEmail').hide();
1659
+
1660
+ $contain.find('.inline_editUsername').val($contain.find('.wpProQuiz_username').text());
1661
+ $contain.find('.inline_editEmail').val($contain.find('.wpProQuiz_email').text());
1662
+
1663
+ return false;
1664
+ });
1665
+ },
1666
+
1667
+ checkNav: function () {
1668
+ var n = elements.currentPage.val();
1669
+
1670
+ if (n == 1) {
1671
+ elements.pageLeft.hide();
1672
+ } else {
1673
+ elements.pageLeft.show();
1674
+ }
1675
+
1676
+ if (n == elements.currentPage.children().length) {
1677
+ elements.pageRight.hide();
1678
+ } else {
1679
+ elements.pageRight.show();
1680
+ }
1681
+ },
1682
+
1683
+ isEmpty: function (text) {
1684
+ text = $.trim(text);
1685
+
1686
+ return (!text || 0 === text.length);
1687
+ }
1688
+ };
1689
+
1690
+ var init = function () {
1691
+ elements.sort.change(function () {
1692
+ methods.loadData();
1693
+ });
1694
+
1695
+ elements.pageLimit.change(function () {
1696
+ methods.loadData({nav: 1});
1697
+ });
1698
+
1699
+ elements.currentPage.change(function () {
1700
+ methods.checkNav();
1701
+ methods.loadData();
1702
+ });
1703
+
1704
+ elements.pageLeft.click(function () {
1705
+ elements.currentPage.val(Number(elements.currentPage.val()) - 1);
1706
+ methods.checkNav();
1707
+ methods.loadData();
1708
+ });
1709
+
1710
+ elements.pageRight.click(function () {
1711
+ elements.currentPage.val(Number(elements.currentPage.val()) + 1);
1712
+ methods.checkNav();
1713
+ methods.loadData();
1714
+ });
1715
+
1716
+ $('#wpProQuiz_deleteAll').click(function () {
1717
+ methods.loadData({a: 'deleteAll'});
1718
+ });
1719
+
1720
+ $('#wpProQuiz_action').click(function () {
1721
+ var name = $('#wpProQuiz_actionName').val();
1722
+
1723
+ if (name != '0') {
1724
+
1725
+ var ids = $('input[name="checkedData[]"]:checked').map(function () {
1726
+ return $(this).val();
1727
+ }).get();
1728
+
1729
+ methods.loadData({
1730
+ a: name,
1731
+ toplistIds: ids
1732
+ });
1733
+ }
1734
+ });
1735
+
1736
+ $('#wpProQuiz_checkedAll').change(function () {
1737
+ if (this.checked)
1738
+ $('input[name="checkedData[]"]').attr('checked', 'checked');
1739
+ else
1740
+ $('input[name="checkedData[]"]').removeAttr('checked', 'checked');
1741
+ });
1742
+
1743
+ methods.loadData({nav: 1});
1744
+ };
1745
+
1746
+ init();
1747
+ };
1748
+
1749
+ if ($('.wpProQuiz_quizOverall').length)
1750
+ $('.wpProQuiz_quizOverall').wpProQuiz_preview();
1751
+
1752
+ if ($('.wpProQuiz_quizOverall').length) {
1753
+ $('.wpProQuiz_quizOverall').wpProQuiz_quizOverall();
1754
+ }
1755
+
1756
+ if ($('.wpProQuiz_quizEdit').length)
1757
+ $('.wpProQuiz_quizEdit').wpProQuiz_quizEdit();
1758
+
1759
+ // if($('.wpProQuiz_questionEdit').length)
1760
+ // $('.wpProQuiz_questionEdit').wpProQuiz_questionEdit();
1761
+
1762
+ //if($('.wpProQuiz_questionOverall').length)
1763
+ // $('.wpProQuiz_questionOverall').wpProQuiz_questionOverall();
1764
+
1765
+ // if($('.wpProQuiz_statistics').length)
1766
+ // $('.wpProQuiz_statistics').wpProQuiz_statistics();
1767
+
1768
+ if ($('.wpProQuiz_toplist').length)
1769
+ $('.wpProQuiz_toplist').wpProQuiz_toplist();
1770
+
1771
+ /**
1772
+ * NEW
1773
+ */
1774
+ /**
1775
+ * @memberOf WpProQuiz_Admin
1776
+ */
1777
+ function WpProQuiz_Admin() {
1778
+ var global = this;
1779
+
1780
+ global = {
1781
+ displayChecked: function (t, box, neg, disabled) {
1782
+ var c = neg ? !t.checked : t.checked;
1783
+
1784
+ if (disabled)
1785
+ c ? box.attr('disabled', 'disabled') : box.removeAttr('disabled');
1786
+ else
1787
+ c ? box.show() : box.hide();
1788
+ },
1789
+
1790
+ isEmpty: function (text) {
1791
+ text = $.trim(text);
1792
+
1793
+ return (!text || 0 === text.length);
1794
+ },
1795
+
1796
+ isNumber: function (number) {
1797
+ number = $.trim(number);
1798
+ return !global.isEmpty(number) && !isNaN(number);
1799
+ },
1800
+
1801
+ getMceContent: function (id) {
1802
+ var editor = tinymce.editors[id];
1803
+
1804
+ if (editor != undefined && !editor.isHidden()) {
1805
+ return editor.getContent();
1806
+ }
1807
+
1808
+ return $('#' + id).val();
1809
+ },
1810
+
1811
+ ajaxPost: function (func, data, success) {
1812
+ var d = {
1813
+ action: 'wp_pro_quiz_admin_ajax',
1814
+ func: func,
1815
+ data: data
1816
+ };
1817
+
1818
+ $.post(ajaxurl, d, success, 'json');
1819
+ }
1820
+ };
1821
+
1822
+ var tabWrapper = function () {
1823
+ $('.wpProQuiz_tab_wrapper a').click(function () {
1824
+ var $this = $(this);
1825
+ var tabId = $this.data('tab');
1826
+ var currentTab = $this.siblings('.button-primary').removeClass('button-primary').addClass('button-secondary');
1827
+
1828
+ $this.removeClass('button-secondary').addClass('button-primary');
1829
+
1830
+ $(currentTab.data('tab')).hide('fast');
1831
+ $(tabId).show('fast');
1832
+
1833
+ $(document).trigger({
1834
+ type: 'changeTab',
1835
+ tabId: tabId
1836
+ });
1837
+
1838
+ return false;
1839
+ });
1840
+ };
1841
+
1842
+ var module = {
1843
+ /**
1844
+ * @memberOf WpProQuiz_admin.module
1845
+ */
1846
+
1847
+ gobalSettings: function () {
1848
+ var methode = {
1849
+ categoryDelete: function (id, type) {
1850
+ var data = {
1851
+ categoryId: id
1852
+ };
1853
+
1854
+ global.ajaxPost('categoryDelete', data, function (json) {
1855
+ if (json.err) {
1856
+
1857
+ return;
1858
+ }
1859
+
1860
+ $('select[name="category' + type + '"] option[value="' + id + '"]').remove();
1861
+ $('select[name="category' + type + '"]').change();
1862
+ });
1863
+ },
1864
+
1865
+ categoryEdit: function (id, name, type) {
1866
+ var data = {
1867
+ categoryId: id,
1868
+ categoryName: $.trim(name)
1869
+ };
1870
+
1871
+ if (global.isEmpty(name)) {
1872
+ alert(wpProQuizLocalize.category_no_name);
1873
+ return;
1874
+ }
1875
+
1876
+ global.ajaxPost('categoryEdit', data, function (json) {
1877
+ if (json.err) {
1878
+
1879
+ return;
1880
+ }
1881
+
1882
+ $('select[name="category' + type + '"] option[value="' + id + '"]').text(data.categoryName);
1883
+ $('select[name="category' + type + '"]').change();
1884
+ });
1885
+ },
1886
+
1887
+ changeTimeFormat: function (inputName, $select) {
1888
+ if ($select.val() != "0")
1889
+ $('input[name="' + inputName + '"]').val($select.val());
1890
+ },
1891
+
1892
+ templateDelete: function (id, type) {
1893
+ var data = {
1894
+ templateId: id,
1895
+ type: type
1896
+ };
1897
+
1898
+ global.ajaxPost('templateDelete', data, function (json) {
1899
+ if (json.err) {
1900
+
1901
+ return;
1902
+ }
1903
+
1904
+ if (!type) {
1905
+ $('select[name="templateQuiz"] option[value="' + id + '"]').remove();
1906
+ $('select[name="templateQuiz"]').change();
1907
+ } else {
1908
+ $('select[name="templateQuestion"] option[value="' + id + '"]').remove();
1909
+ $('select[name="templateQuestion"]').change();
1910
+ }
1911
+ });
1912
+ },
1913
+
1914
+ templateEdit: function (id, name, type) {
1915
+
1916
+ if (global.isEmpty(name)) {
1917
+ alert(wpProQuizLocalize.category_no_name);
1918
+ return;
1919
+ }
1920
+
1921
+ var data = {
1922
+ templateId: id,
1923
+ name: $.trim(name),
1924
+ type: type
1925
+ };
1926
+
1927
+ global.ajaxPost('templateEdit', data, function (json) {
1928
+ if (json.err) {
1929
+
1930
+ return;
1931
+ }
1932
+
1933
+ if (!type) {
1934
+ $('select[name="templateQuiz"] option[value="' + id + '"]').text(data.name);
1935
+ $('select[name="templateQuiz"]').change();
1936
+ } else {
1937
+ $('select[name="templateQuestion"] option[value="' + id + '"]').text(data.name);
1938
+ $('select[name="templateQuestion"]').change();
1939
+ }
1940
+ });
1941
+ }
1942
+ };
1943
+
1944
+ var init = function () {
1945
+ // $('.wpProQuiz_tab').click(function() {
1946
+ // var $this = $(this);
1947
+ //
1948
+ // $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
1949
+ // $this.removeClass('button-secondary').addClass('button-primary');
1950
+ //
1951
+ // $('#problemInfo, #problemContent, #globalContent').hide('fast');
1952
+ //
1953
+ // if($this.attr('id') == 'globalTab') {
1954
+ // $('#globalContent').show('fast');
1955
+ // } else {
1956
+ // $('#problemInfo, #problemContent').show('fast');
1957
+ // }
1958
+ // });
1959
+
1960
+ $('select[name="category"]').change(function () {
1961
+ $('input[name="categoryEditText"]').val($(this).find(':selected').text());
1962
+ }).change();
1963
+
1964
+ $('input[name="categoryDelete"]').click(function () {
1965
+ var id = $('select[name="category"] option:selected').val();
1966
+
1967
+ methode.categoryDelete(id, '');
1968
+ });
1969
+
1970
+ $('input[name="categoryEdit"]').click(function () {
1971
+ var id = $('select[name="category"] option:selected').val();
1972
+ var text = $('input[name="categoryEditText"]').val();
1973
+
1974
+ methode.categoryEdit(id, text, '');
1975
+ });
1976
+
1977
+ $('select[name="categoryQuiz"]').change(function () {
1978
+ $('input[name="categoryQuizEditText"]').val($(this).find(':selected').text());
1979
+ }).change();
1980
+
1981
+ $('input[name="categoryQuizDelete"]').click(function () {
1982
+ var id = $('select[name="categoryQuiz"] option:selected').val();
1983
+
1984
+ methode.categoryDelete(id, 'Quiz');
1985
+ });
1986
+
1987
+ $('input[name="categoryQuizEdit"]').click(function () {
1988
+ var id = $('select[name="categoryQuiz"] option:selected').val();
1989
+ var text = $('input[name="categoryQuizEditText"]').val();
1990
+
1991
+ methode.categoryEdit(id, text, 'Quiz');
1992
+ });
1993
+
1994
+ $('#statistic_time_format_select').change(function () {
1995
+ methode.changeTimeFormat('statisticTimeFormat', $(this));
1996
+ });
1997
+
1998
+ $(document).bind('changeTab', function (data) {
1999
+ $('#problemInfo').hide('fast');
2000
+
2001
+ switch (data.tabId) {
2002
+ case '#problemContent':
2003
+ $('#problemInfo').show('fast');
2004
+ break;
2005
+ case '#emailSettingsTab':
2006
+ break;
2007
+ }
2008
+ });
2009
+
2010
+ $('input[name="email[html]"]').change(function () {
2011
+ if (switchEditors == undefined)
2012
+ return false;
2013
+
2014
+ if (this.checked) {
2015
+ switchEditors.go('adminEmailEditor', 'tmce');
2016
+ } else {
2017
+ switchEditors.go('adminEmailEditor', 'html');
2018
+ }
2019
+
2020
+ }).change();
2021
+
2022
+ $('input[name="userEmail[html]"]').change(function () {
2023
+ if (switchEditors == undefined)
2024
+ return false;
2025
+
2026
+ if (this.checked) {
2027
+ switchEditors.go('userEmailEditor', 'tmce');
2028
+ } else {
2029
+ switchEditors.go('userEmailEditor', 'html');
2030
+ }
2031
+
2032
+ }).change();
2033
+
2034
+ $('select[name="templateQuiz"]').change(function () {
2035
+ $('input[name="templateQuizEditText"]').val($(this).find(':selected').text());
2036
+ }).change();
2037
+
2038
+ $('select[name="templateQuestion"]').change(function () {
2039
+ $('input[name="templateQuestionEditText"]').val($(this).find(':selected').text());
2040
+ }).change();
2041
+
2042
+ $('input[name="templateQuizDelete"]').click(function () {
2043
+ var id = $('select[name="templateQuiz"] option:selected').val();
2044
+
2045
+ methode.templateDelete(id, 0);
2046
+ });
2047
+
2048
+ $('input[name="templateQuestionDelete"]').click(function () {
2049
+ var id = $('select[name="templateQuestion"] option:selected').val();
2050
+
2051
+ methode.templateDelete(id, 1);
2052
+ });
2053
+
2054
+ $('input[name="templateQuizEdit"]').click(function () {
2055
+ var id = $('select[name="templateQuiz"] option:selected').val();
2056
+ var text = $('input[name="templateQuizEditText"]').val();
2057
+
2058
+ methode.templateEdit(id, text, 0);
2059
+ });
2060
+
2061
+ $('input[name="templateQuestionEdit"]').click(function () {
2062
+ var id = $('select[name="templateQuestion"] option:selected').val();
2063
+ var text = $('input[name="templateQuestionEditText"]').val();
2064
+
2065
+ methode.templateEdit(id, text, 1);
2066
+ });
2067
+ };
2068
+
2069
+ init();
2070
+ },
2071
+
2072
+ questionEdit: function () {
2073
+ var methode = this;
2074
+ var filter = $.noop();
2075
+
2076
+ var elements = {
2077
+ answerChildren: $('.answer_felder > div'),
2078
+ pointsModus: $('input[name="answerPointsActivated"]'),
2079
+ gPoints: $('input[name="points"]')
2080
+ };
2081
+
2082
+ methode = {
2083
+ generateArrayIndex: function () {
2084
+ var type = $('input[name="answerType"]:checked').val();
2085
+ type = (type == 'single' || type == 'multiple') ? 'classic_answer' : type;
2086
+
2087
+ $('.answerList').each(function () {
2088
+ var currentType = $(this).parent().attr('class');
2089
+
2090
+ $(this).children().each(function (i, v) {
2091
+ $(this).find('[name^="answerData"]').each(function () {
2092
+ var name = this.name;
2093
+ var x = name.search(/\](\[\w+\])+$/);
2094
+ var n = (type == currentType) ? i : 'none';
2095
+
2096
+ if (x > 0) {
2097
+ this.name = 'answerData[' + n + name.substring(x, name.length);
2098
+
2099
+ }
2100
+ });
2101
+ });
2102
+ });
2103
+ },
2104
+
2105
+ globalValidate: function () {
2106
+ if (global.isEmpty(global.getMceContent('question'))) {
2107
+ alert(wpProQuizLocalize.no_question_msg);
2108
+
2109
+ return false;
2110
+ }
2111
+
2112
+ if (!elements.pointsModus.is(':checked')) {
2113
+ var p = elements.gPoints.val();
2114
+
2115
+ if (!global.isNumber(p) || p < 1) {
2116
+ alert(wpProQuizLocalize.no_nummber_points);
2117
+
2118
+ return false;
2119
+ }
2120
+ } else {
2121
+ if ($('input[name="answerType"]:checked').val() == 'free_answer') {
2122
+ alert(wpProQuizLocalize.dif_points);
2123
+ return false;
2124
+ }
2125
+ }
2126
+
2127
+ if (filter() === false)
2128
+ return false;
2129
+
2130
+ return true;
2131
+ },
2132
+
2133
+ answerRemove: function () {
2134
+ var li = $(this).parent();
2135
+
2136
+ if (li.parent().children().length < 2)
2137
+ return false;
2138
+
2139
+ li.remove();
2140
+
2141
+ return false;
2142
+ },
2143
+
2144
+ addCategory: function () {
2145
+ var name = $.trim($('input[name="categoryAdd"]').val());
2146
+
2147
+ if (global.isEmpty(name)) {
2148
+ return;
2149
+ }
2150
+
2151
+ var data = {
2152
+ categoryName: name
2153
+ };
2154
+
2155
+ global.ajaxPost('categoryAdd', data, function (json) {
2156
+ if (json.err) {
2157
+ $('#categoryMsgBox').text(json.err).show('fast').delay(2000).hide('fast');
2158
+ return;
2159
+ }
2160
+
2161
+ var $option = $(document.createElement('option'))
2162
+ .val(json.categoryId)
2163
+ .text(json.categoryName)
2164
+ .attr('selected', 'selected');
2165
+
2166
+ $('select[name="category"]').append($option).change();
2167
+
2168
+ });
2169
+ },
2170
+
2171
+ addMediaClick: function () {
2172
+ if (typeof tb_show != "function")
2173
+ return false;
2174
+
2175
+ var closest = $(this).closest('li');
2176
+ var htmlCheck = closest.find('input[name="answerData[][html]"]:eq(0)');
2177
+ var field = closest.find('.wpProQuiz_text:eq(0)');
2178
+
2179
+ window.org_send_to_editor = window.send_to_editor;
2180
+ var org_tb_remove = tb_remove;
2181
+
2182
+ window.send_to_editor = function (html) {
2183
+ var img = $('img', html)[0].outerHTML;
2184
+
2185
+ field.val(field.val() + img);
2186
+ htmlCheck.attr('checked', true);
2187
+
2188
+ tb_remove();
2189
+
2190
+ window.send_to_editor = window.org_send_to_editor;
2191
+ };
2192
+
2193
+ window.tb_remove = function () {
2194
+ window.send_to_editor = window.org_send_to_editor;
2195
+ tb_remove = org_tb_remove;
2196
+
2197
+ tb_remove();
2198
+ };
2199
+
2200
+ tb_show('', 'media-upload.php?type=image&TB_iframe=true');
2201
+ }
2202
+ };
2203
+
2204
+ var validate = {
2205
+ classic_answer: function () {
2206
+ var findText = 0;
2207
+ var findCorrect = 0;
2208
+ var findPoints = 0;
2209
+
2210
+ $('.classic_answer .answerList').children().each(function () {
2211
+ var t = $(this);
2212
+
2213
+ if (!global.isEmpty(t.find('textarea[name="answerData[][answer]"]').val())) {
2214
+ findText++;
2215
+
2216
+ if (t.find('input[name="answerData[][correct]"]:checked').length) {
2217
+ findCorrect++;
2218
+ }
2219
+
2220
+ var p = t.find('input[name="answerData[][points]"]').val();
2221
+
2222
+ if (global.isNumber(p) && p >= 0) {
2223
+ findPoints++;
2224
+ }
2225
+ }
2226
+ });
2227
+
2228
+ if (!findText) {
2229
+ alert(wpProQuizLocalize.no_answer_msg);
2230
+ return false;
2231
+ }
2232
+
2233
+ if (!findCorrect && !($('input[name="disableCorrect"]').is(':checked')
2234
+ && $('input[name="answerPointsDiffModusActivated"]').is(':checked')
2235
+ && $('input[name="answerPointsActivated"]').is(':checked')
2236
+ && $('input[name="answerType"]:checked').val() == 'single')) {
2237
+ alert(wpProQuizLocalize.no_correct_msg);
2238
+ return false;
2239
+ }
2240
+
2241
+ if (findPoints != findText && elements.pointsModus.is(':checked')) {
2242
+ alert(wpProQuizLocalize.no_nummber_points_new);
2243
+ return false;
2244
+ }
2245
+
2246
+ return true;
2247
+ },
2248
+
2249
+ free_answer: function () {
2250
+ if (global.isEmpty($('.free_answer textarea[name="answerData[][answer]"]').val())) {
2251
+ alert(wpProQuizLocalize.no_answer_msg);
2252
+ return false;
2253
+ }
2254
+
2255
+ return true;
2256
+ },
2257
+
2258
+ cloze_answer: function () {
2259
+ if (global.isEmpty(global.getMceContent('cloze'))) {
2260
+ alert(wpProQuizLocalize.no_answer_msg);
2261
+ return false;
2262
+ }
2263
+
2264
+ return true;
2265
+ },
2266
+
2267
+ sort_answer: function () {
2268
+ var findText = 0;
2269
+ var findPoints = 0;
2270
+
2271
+ $('.sort_answer .answerList').children().each(function () {
2272
+ var t = $(this);
2273
+
2274
+ if (!global.isEmpty(t.find('textarea[name="answerData[][answer]"]').val())) {
2275
+ findText++;
2276
+
2277
+ var p = t.find('input[name="answerData[][points]"]').val();
2278
+
2279
+ if (global.isNumber(p) && p >= 0) {
2280
+ findPoints++;
2281
+ }
2282
+ }
2283
+ });
2284
+
2285
+ if (!findText) {
2286
+ alert(wpProQuizLocalize.no_answer_msg);
2287
+ return false;
2288
+ }
2289
+
2290
+ if (findPoints != findText && elements.pointsModus.is(':checked')) {
2291
+ alert(wpProQuizLocalize.no_nummber_points_new);
2292
+ return false;
2293
+ }
2294
+
2295
+ return true;
2296
+ },
2297
+
2298
+ matrix_sort_answer: function () {
2299
+ var findText = 0;
2300
+ var findPoints = 0;
2301
+ var sortString = true;
2302
+ var menge = 0;
2303
+
2304
+ $('.matrix_sort_answer .answerList').children().each(function () {
2305
+ var t = $(this);
2306
+ var p = t.find('input[name="answerData[][points]"]').val();
2307
+
2308
+ if (!global.isEmpty(t.find('textarea[name="answerData[][answer]"]').val())) {
2309
+ findText++;
2310
+ menge++;
2311
+
2312
+ if (global.isEmpty(t.find('textarea[name="answerData[][sort_string]"]').val())) {
2313
+ sortString = false;
2314
+ }
2315
+
2316
+ if (global.isNumber(p) && p >= 0) {
2317
+ findPoints++;
2318
+ }
2319
+ } else {
2320
+ if (!global.isEmpty(t.find('textarea[name="answerData[][sort_string]"]').val())) {
2321
+ menge++;
2322
+
2323
+ if (global.isNumber(p) && p >= 0) {
2324
+ findPoints++;
2325
+ }
2326
+ }
2327
+ }
2328
+ });
2329
+
2330
+ if (!findText) {
2331
+ alert(wpProQuizLocalize.no_answer_msg);
2332
+ return false;
2333
+ }
2334
+
2335
+ if (!sortString) {
2336
+ alert(wpProQuizLocalize.no_sort_element_criterion);
2337
+ return false;
2338
+ }
2339
+
2340
+ if (findPoints != menge && elements.pointsModus.is(':checked')) {
2341
+ alert(wpProQuizLocalize.no_nummber_points_new);
2342
+ return false;
2343
+ }
2344
+
2345
+ return true;
2346
+ },
2347
+
2348
+ assessment_answer: function () {
2349
+ if (global.isEmpty(global.getMceContent('assessment'))) {
2350
+ alert(wpProQuizLocalize.no_answer_msg);
2351
+ return false;
2352
+ }
2353
+
2354
+ return true;
2355
+ }
2356
+ };
2357
+
2358
+ var formListener = function () {
2359
+ $('#wpProQuiz_tip').change(function () {
2360
+ global.displayChecked(this, $('#wpProQuiz_tipBox'));
2361
+ }).change();
2362
+
2363
+ $('#wpProQuiz_correctSameText').change(function () {
2364
+ global.displayChecked(this, $('#wpProQuiz_incorrectMassageBox'), true);
2365
+ }).change();
2366
+
2367
+ $('input[name="answerType"]').click(function () {
2368
+ elements.answerChildren.hide();
2369
+ var v = this.value;
2370
+
2371
+ if (v == 'single') {
2372
+ $('#singleChoiceOptions').show();
2373
+ $('input[name="disableCorrect"]').change();
2374
+ } else {
2375
+ $('#singleChoiceOptions').hide();
2376
+ $('.classic_answer .wpProQuiz_classCorrect').parent().parent().show();
2377
+ }
2378
+
2379
+ if (v == 'single' || v == 'multiple') {
2380
+ var type = (v == 'single') ? 'radio' : 'checkbox';
2381
+ v = 'classic_answer';
2382
+
2383
+ $('.wpProQuiz_classCorrect').each(function () {
2384
+ $("<input type=" + type + " />")
2385
+ .attr({
2386
+ name: this.name,
2387
+ value: this.value,
2388
+ checked: this.checked
2389
+ })
2390
+ .addClass('wpProQuiz_classCorrect wpProQuiz_checkbox')
2391
+ .insertBefore(this);
2392
+ }).remove();
2393
+ }
2394
+
2395
+ filter = (validate[v] != undefined) ? validate[v] : $.noop();
2396
+
2397
+ $('.' + v).show();
2398
+ });
2399
+
2400
+ $('input[name="answerType"]:checked').click();
2401
+
2402
+ $('.deleteAnswer').click(methode.answerRemove);
2403
+
2404
+ $('.addAnswer').click(function () {
2405
+ var ul = $(this).siblings('ul');
2406
+ var clone = ul.find('li:eq(0)').clone();
2407
+
2408
+ clone.find('.wpProQuiz_checkbox').removeAttr('checked');
2409
+ clone.find('.wpProQuiz_text').val('');
2410
+ clone.find('.wpProQuiz_points').val(1);
2411
+ clone.find('.deleteAnswer').click(methode.answerRemove);
2412
+ clone.find('.addMedia').click(methode.addMediaClick);
2413
+
2414
+ clone.appendTo(ul);
2415
+
2416
+ return false;
2417
+ });
2418
+
2419
+ $('.sort_answer ul, .classic_answer ul, .matrix_sort_answer ul').sortable({
2420
+ handle: '.wpProQuiz_move'
2421
+ });
2422
+
2423
+ $('#saveQuestion').click(function () {
2424
+ if (!methode.globalValidate()) {
2425
+ return false;
2426
+ }
2427
+
2428
+ methode.generateArrayIndex();
2429
+
2430
+ return true;
2431
+ });
2432
+
2433
+ $(elements.pointsModus).change(function () {
2434
+ global.displayChecked(this, $('.wpProQuiz_answerPoints'));
2435
+ global.displayChecked(this, $('#wpProQuiz_showPointsBox'));
2436
+ global.displayChecked(this, elements.gPoints, false, true);
2437
+ global.displayChecked(this, $('input[name="answerPointsDiffModusActivated"]'), true, true);
2438
+
2439
+ if (this.checked) {
2440
+ $('input[name="answerPointsDiffModusActivated"]').change();
2441
+ $('input[name="disableCorrect"]').change();
2442
+ } else {
2443
+ $('.classic_answer .wpProQuiz_classCorrect').parent().parent().show();
2444
+ $('input[name="disableCorrect"]').attr('disabled', 'disabled');
2445
+ }
2446
+ }).change();
2447
+
2448
+ $('select[name="category"]').change(function () {
2449
+ var $this = $(this);
2450
+ var box = $('#categoryAddBox').hide();
2451
+
2452
+ if ($this.val() == "-1") {
2453
+ box.show();
2454
+ }
2455
+
2456
+ }).change();
2457
+
2458
+ $('#categoryAddBtn').click(function () {
2459
+ methode.addCategory();
2460
+ });
2461
+
2462
+ $('.addMedia').click(methode.addMediaClick);
2463
+
2464
+ $('input[name="answerPointsDiffModusActivated"]').change(function () {
2465
+ global.displayChecked(this, $('input[name="disableCorrect"]'), true, true);
2466
+
2467
+ if (this.checked)
2468
+ $('input[name="disableCorrect"]').change();
2469
+ else
2470
+ $('.classic_answer .wpProQuiz_classCorrect').parent().parent().show();
2471
+ }).change();
2472
+
2473
+ $('input[name="disableCorrect"]').change(function () {
2474
+ global.displayChecked(this, $('.classic_answer .wpProQuiz_classCorrect').parent().parent(), true);
2475
+ }).change();
2476
+
2477
+ $('#clickPointDia').click(function () {
2478
+ $('.pointDia').toggle('fast');
2479
+
2480
+ return false;
2481
+ });
2482
+
2483
+ $('input[name="template"]').click(function (e) {
2484
+ if ($('select[name="templateSaveList"]').val() == '0') {
2485
+ if (global.isEmpty($('input[name="templateName"]').val())) {
2486
+ alert(wpProQuizLocalize.temploate_no_name);
2487
+
2488
+ e.preventDefault();
2489
+ return false;
2490
+ }
2491
+ }
2492
+
2493
+ methode.generateArrayIndex();
2494
+ });
2495
+
2496
+ $('select[name="templateSaveList"]').change(function () {
2497
+ var $templateName = $('input[name="templateName"]');
2498
+
2499
+ if ($(this).val() == '0') {
2500
+ $templateName.show();
2501
+ } else {
2502
+ $templateName.hide();
2503
+ }
2504
+ }).change();
2505
+ };
2506
+
2507
+ var init = function () {
2508
+ elements.answerChildren.hide();
2509
+
2510
+ formListener();
2511
+ };
2512
+
2513
+ init();
2514
+ },
2515
+
2516
+ statistic: function () {
2517
+
2518
+ var methode = this;
2519
+
2520
+ var quizId = $('#quizId').val();
2521
+
2522
+ var currentTab = 'users';
2523
+
2524
+ var elements = {
2525
+ currentPage: $('#wpProQuiz_currentPage'),
2526
+ pageLeft: $('#wpProQuiz_pageLeft'),
2527
+ pageRight: $('#wpProQuiz_pageRight'),
2528
+ testSelect: $('#testSelect')
2529
+
2530
+ };
2531
+
2532
+ methode = {
2533
+ loadStatistic: function (userId, callback) {
2534
+ var data = {
2535
+ userId: userId
2536
+ };
2537
+
2538
+ global.ajaxPost('statisticLoad', data, function (json) {
2539
+
2540
+ });
2541
+ },
2542
+
2543
+ loadUsersStatistic: function () {
2544
+ //var userId = $('#userSelect').val();
2545
+ //
2546
+ //var data = {
2547
+ // userId: userId,
2548
+ // quizId: quizId,
2549
+ // testId: $('#testSelect').val()
2550
+ //};
2551
+ //
2552
+ //methode.toggleLoadBox(false);
2553
+ //
2554
+ //global.ajaxPost('statisticLoad', data, function (json) {
2555
+ // $.each(json.question, function () {
2556
+ // var $tr = $('#wpProQuiz_tr_' + this.questionId);
2557
+ //
2558
+ // methode.setStatisticData($tr, this);
2559
+ // });
2560
+ //
2561
+ // $.each(json.category, function (i, v) {
2562
+ // var $tr = $('#wpProQuiz_ctr_' + i);
2563
+ //
2564
+ // methode.setStatisticData($tr, v);
2565
+ // });
2566
+ //
2567
+ // $('#testSelect option:gt(0)').remove();
2568
+ // var $testSelect = $('#testSelect');
2569
+ //
2570
+ // $.each(json.tests, function () {
2571
+ // var $option = $(document.createElement('option'));
2572
+ //
2573
+ // $option.val(this.id);
2574
+ // $option.text(this.date);
2575
+ //
2576
+ // if (json.testId == this.id)
2577
+ // $option.attr('selected', true);
2578
+ //
2579
+ // $testSelect.append($option);
2580
+ // });
2581
+ //
2582
+ // methode.parseFormData(json.formData);
2583
+ //
2584
+ // methode.toggleLoadBox(true);
2585
+ //});
2586
+ },
2587
+
2588
+ loadUsersStatistic_: function (userId, testId) {
2589
+
2590
+ var data = {
2591
+ userId: userId,
2592
+ quizId: quizId,
2593
+ testId: testId
2594
+ };
2595
+
2596
+ methode.toggleLoadBox(false);
2597
+
2598
+ global.ajaxPost('statisticLoad', data, function (json) {
2599
+ $.each(json.question, function () {
2600
+ var $tr = $('#wpProQuiz_tr_' + this.questionId);
2601
+
2602
+ methode.setStatisticData($tr, this);
2603
+ });
2604
+
2605
+ $.each(json.category, function (i, v) {
2606
+ var $tr = $('#wpProQuiz_ctr_' + i);
2607
+
2608
+ methode.setStatisticData($tr, v);
2609
+ });
2610
+
2611
+ $('#testSelect option:gt(0)').remove();
2612
+ var $testSelect = $('#testSelect');
2613
+
2614
+ $.each(json.tests, function () {
2615
+ var $option = $(document.createElement('option'));
2616
+
2617
+ $option.val(this.id);
2618
+ $option.text(this.date);
2619
+
2620
+ if (json.testId == this.id)
2621
+ $option.attr('selected', true);
2622
+
2623
+ $testSelect.append($option);
2624
+ });
2625
+
2626
+ methode.parseFormData(json.formData);
2627
+
2628
+ $('#userSelect').val(userId);
2629
+ $('#testSelect').val(testId);
2630
+
2631
+ methode.toggleLoadBox(true);
2632
+ });
2633
+ },
2634
+
2635
+ parseFormData: function (data) {
2636
+ var $formBox = $('#wpProQuiz_form_box');
2637
+
2638
+ if (data == null) {
2639
+ $formBox.hide();
2640
+ return;
2641
+ }
2642
+
2643
+ $.each(data, function (i, v) {
2644
+ $('#form_id_' + i).text(v);
2645
+ });
2646
+
2647
+ $formBox.show();
2648
+ },
2649
+
2650
+ setStatisticData: function ($o, v) {
2651
+ $o.find('.wpProQuiz_cCorrect').text(v.correct);
2652
+ $o.find('.wpProQuiz_cIncorrect').text(v.incorrect);
2653
+ $o.find('.wpProQuiz_cTip').text(v.hint);
2654
+ $o.find('.wpProQuiz_cPoints').text(v.points);
2655
+ $o.find('.wpProQuiz_cResult').text(v.result);
2656
+ $o.find('.wpProQuiz_cTime').text(v.questionTime);
2657
+ $o.find('.wpProQuiz_cCreateTime').text(v.date);
2658
+ },
2659
+
2660
+ toggleLoadBox: function (show) {
2661
+ var $loadBox = $('#wpProQuiz_loadData');
2662
+ var $content = $('#wpProQuiz_content');
2663
+
2664
+ if (show) {
2665
+ $loadBox.hide();
2666
+ $content.show();
2667
+ } else {
2668
+ $content.hide();
2669
+ $loadBox.show();
2670
+ }
2671
+ },
2672
+
2673
+ reset: function (type) {
2674
+ var userId = $('#userSelect').val();
2675
+
2676
+ if (!confirm(wpProQuizLocalize.reset_statistics_msg)) {
2677
+ return;
2678
+ }
2679
+
2680
+ var data = {
2681
+ quizId: quizId,
2682
+ userId: userId,
2683
+ testId: elements.testSelect.val(),
2684
+ type: type
2685
+ };
2686
+
2687
+ methode.toggleLoadBox(false);
2688
+
2689
+ global.ajaxPost('statisticReset', data, function () {
2690
+ methode.loadUsersStatistic();
2691
+ });
2692
+ },
2693
+
2694
+ loadStatisticOverview: function (nav) {
2695
+
2696
+ var data = {
2697
+ quizId: quizId,
2698
+ pageLimit: $('#wpProQuiz_pageLimit').val(),
2699
+ onlyCompleted: Number($('#wpProQuiz_onlyCompleted').is(':checked')),
2700
+ page: elements.currentPage.val(),
2701
+ nav: Number(nav)
2702
+ };
2703
+
2704
+ methode.toggleLoadBox(false);
2705
+
2706
+ global.ajaxPost('statisticLoadOverview', data, function (json) {
2707
+ var $body = $('#wpProQuiz_statistics_overview_data');
2708
+ var $tr = $body.children();
2709
+ var $c = $tr.first().clone();
2710
+
2711
+ $tr.slice(1).remove();
2712
+
2713
+ $.each(json.items, function () {
2714
+ var clone = $c.clone();
2715
+
2716
+ methode.setStatisticData(clone, this);
2717
+
2718
+ clone.find('a').text(this.userName).data('userId', this.userId).click(function () {
2719
+ $('#userSelect').val($(this).data('userId'));
2720
+
2721
+ $('#wpProQuiz_typeUser').click();
2722
+
2723
+ return false;
2724
+ });
2725
+
2726
+ clone.show().appendTo($body);
2727
+ });
2728
+
2729
+ $c.remove();
2730
+
2731
+ methode.toggleLoadBox(true);
2732
+
2733
+ if (json.page != undefined)
2734
+ methode.handleNav(json.page);
2735
+ });
2736
+
2737
+ },
2738
+
2739
+ handleNav: function (nav) {
2740
+ var $p = $('#wpProQuiz_currentPage').empty();
2741
+
2742
+ for (var i = 1; i <= nav; i++) {
2743
+ $(document.createElement('option'))
2744
+ .val(i)
2745
+ .text(i)
2746
+ .appendTo($p);
2747
+ }
2748
+
2749
+ methode.checkNavBar();
2750
+ },
2751
+
2752
+ checkNavBar: function () {
2753
+ var n = elements.currentPage.val();
2754
+
2755
+ if (n == 1) {
2756
+ elements.pageLeft.hide();
2757
+ } else {
2758
+ elements.pageLeft.show();
2759
+ }
2760
+
2761
+ if (n == elements.currentPage.children().length) {
2762
+ elements.pageRight.hide();
2763
+ } else {
2764
+ elements.pageRight.show();
2765
+ }
2766
+ },
2767
+
2768
+ refresh: function () {
2769
+ if (currentTab == 'users') {
2770
+ methode.loadUsersStatistic();
2771
+ } else if (currentTab == 'formOverview') {
2772
+ methode.loadFormsOverview(true);
2773
+ } else {
2774
+ methode.loadStatisticOverview(true);
2775
+ }
2776
+ },
2777
+
2778
+ loadFormsOverview: function (nav) {
2779
+ var data = {
2780
+ quizId: quizId,
2781
+ pageLimit: $('#wpProQuiz_fromPageLimit').val(),
2782
+ onlyUser: $('#wpProQuiz_formUser').val(),
2783
+ page: $('#wpProQuiz_formCurrentPage').val(),
2784
+ nav: Number(nav)
2785
+ };
2786
+
2787
+ methode.toggleLoadBox(false);
2788
+
2789
+ global.ajaxPost('statisticLoadFormOverview', data, function (json) {
2790
+ var $body = $('#wpProQuiz_statistics_form_data');
2791
+ var $tr = $body.children();
2792
+ var $c = $tr.first().clone();
2793
+
2794
+ $tr.slice(1).remove();
2795
+
2796
+ $.each(json.items, function () {
2797
+ var clone = $c.clone();
2798
+
2799
+ methode.setStatisticData(clone, this);
2800
+
2801
+ clone.find('a').text(this.userName).data('userId', this.userId).data('testId', this.testId).click(function () {
2802
+ methode.switchTabOnLoad('users');
2803
+ methode.loadUsersStatistic_($(this).data('userId'), $(this).data('testId'));
2804
+
2805
+ return false;
2806
+ });
2807
+
2808
+ clone.show().appendTo($body);
2809
+ });
2810
+
2811
+ $c.remove();
2812
+
2813
+ methode.toggleLoadBox(true);
2814
+
2815
+ if (json.page != undefined)
2816
+ methode.handleFormNav(json.page);
2817
+ });
2818
+ },
2819
+
2820
+ handleFormNav: function (nav) {
2821
+ var $p = $('#wpProQuiz_formCurrentPage').empty();
2822
+
2823
+ for (var i = 1; i <= nav; i++) {
2824
+ $(document.createElement('option'))
2825
+ .val(i)
2826
+ .text(i)
2827
+ .appendTo($p);
2828
+ }
2829
+
2830
+ methode.checkFormNavBar();
2831
+ },
2832
+
2833
+ checkFormNavBar: function () {
2834
+ var n = $('#wpProQuiz_formCurrentPage').val();
2835
+
2836
+ if (n == 1) {
2837
+ $('#wpProQuiz_formPageLeft').hide();
2838
+ } else {
2839
+ $('#wpProQuiz_formPageLeft').show();
2840
+ }
2841
+
2842
+ if (n == $('#wpProQuiz_formCurrentPage').children().length) {
2843
+ $('#wpProQuiz_formPageRight').hide();
2844
+ } else {
2845
+ $('#wpProQuiz_formPageRight').show();
2846
+ }
2847
+ },
2848
+
2849
+ switchTabOnLoad: function (name) {
2850
+ $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
2851
+ $('.wpProQuiz_tabContent').hide();
2852
+
2853
+ var $this = $('#wpProQuiz_typeOverview');
2854
+
2855
+ if (name == 'users') {
2856
+ currentTab = 'users';
2857
+ $('#wpProQuiz_tabUsers').show();
2858
+ $this = $('#wpProQuiz_typeUser');
2859
+ } else if (name == 'formOverview') {
2860
+ currentTab = 'formOverview';
2861
+ $('#wpProQuiz_tabFormOverview').show();
2862
+ $this = $('#wpProQuiz_typeForm');
2863
+ } else {
2864
+ currentTab = 'overview';
2865
+ $('#wpProQuiz_tabOverview').show();
2866
+ }
2867
+
2868
+ $this.removeClass('button-secondary').addClass('button-primary');
2869
+ }
2870
+ };
2871
+
2872
+ var init = function () {
2873
+
2874
+ $('#userSelect, #testSelect').change(function () {
2875
+ methode.loadUsersStatistic();
2876
+ });
2877
+
2878
+ $('.wpProQuiz_update').click(function () {
2879
+ methode.refresh();
2880
+ });
2881
+
2882
+ $('#wpProQuiz_reset').click(function () {
2883
+ methode.reset(0);
2884
+ });
2885
+
2886
+ $('#wpProQuiz_resetUser').click(function () {
2887
+ methode.reset(1);
2888
+ });
2889
+
2890
+ $('.wpProQuiz_resetComplete').click(function () {
2891
+ methode.reset(2);
2892
+ });
2893
+
2894
+ $('.wpProQuiz_tab').click(function () {
2895
+ var $this = $(this);
2896
+
2897
+ $('.wpProQuiz_tab').removeClass('button-primary').addClass('button-secondary');
2898
+ $this.removeClass('button-secondary').addClass('button-primary');
2899
+ $('.wpProQuiz_tabContent').hide();
2900
+
2901
+ if ($this.attr('id') == 'wpProQuiz_typeUser') {
2902
+ currentTab = 'users';
2903
+ $('#wpProQuiz_tabUsers').show();
2904
+ methode.loadUsersStatistic();
2905
+ } else if ($this.attr('id') == 'wpProQuiz_typeForm') {
2906
+ currentTab = 'formOverview';
2907
+ $('#wpProQuiz_tabFormOverview').show();
2908
+ methode.loadFormsOverview(true);
2909
+ } else {
2910
+ currentTab = 'overview';
2911
+ $('#wpProQuiz_tabOverview').show();
2912
+ methode.loadStatisticOverview(true);
2913
+ }
2914
+
2915
+ return false;
2916
+ });
2917
+
2918
+ $('#wpProQuiz_onlyCompleted').change(function () {
2919
+ elements.currentPage.val(1);
2920
+ methode.loadStatisticOverview(true);
2921
+ });
2922
+
2923
+ $('#wpProQuiz_pageLimit').change(function () {
2924
+ elements.currentPage.val(1);
2925
+ methode.loadStatisticOverview(true);
2926
+ });
2927
+
2928
+ elements.pageLeft.click(function () {
2929
+ elements.currentPage.val(Number(elements.currentPage.val()) - 1);
2930
+ methode.loadStatisticOverview(false);
2931
+ methode.checkNavBar();
2932
+ });
2933
+
2934
+ elements.pageRight.click(function () {
2935
+ elements.currentPage.val(Number(elements.currentPage.val()) + 1);
2936
+ methode.loadStatisticOverview(false);
2937
+ methode.checkNavBar();
2938
+ });
2939
+
2940
+ elements.currentPage.change(function () {
2941
+ methode.loadStatisticOverview(false);
2942
+ methode.checkNavBar();
2943
+ });
2944
+
2945
+ $('#wpProQuiz_formUser, #wpProQuiz_fromPageLimit').change(function () {
2946
+ $('#wpProQuiz_formCurrentPage').val(1);
2947
+ methode.loadFormsOverview(true);
2948
+ });
2949
+
2950
+ $('#wpProQuiz_formPageLeft').click(function () {
2951
+ $('#wpProQuiz_formCurrentPage').val(Number(elements.currentPage.val()) - 1);
2952
+ methode.loadFormsOverview(false);
2953
+ methode.checkFormNavBar();
2954
+ });
2955
+
2956
+ $('#wpProQuiz_formPageRight').click(function () {
2957
+ $('#wpProQuiz_formCurrentPage').val(Number(elements.currentPage.val()) + 1);
2958
+ methode.loadFormsOverview(false);
2959
+ methode.checkFormNavBar();
2960
+ });
2961
+
2962
+ $('#wpProQuiz_formCurrentPage').change(function () {
2963
+ methode.loadFormsOverview(false);
2964
+ methode.checkFormNavBar();
2965
+ });
2966
+
2967
+ methode.loadUsersStatistic();
2968
+ };
2969
+
2970
+ init();
2971
+ },
2972
+
2973
+ statisticNew: function () {
2974
+ var quizId = $('#quizId').val();
2975
+ var historyNavigator = null;
2976
+ var overviewNavigator = null;
2977
+
2978
+ var historyFilter = {
2979
+ data: {
2980
+ quizId: quizId,
2981
+ users: -1,
2982
+ pageLimit: 100,
2983
+ dateFrom: 0,
2984
+ dateTo: 0,
2985
+ generateNav: 0
2986
+ },
2987
+
2988
+ changeFilter: function () {
2989
+ var getTime = function (p) {
2990
+ var date = p.datepicker('getDate');
2991
+
2992
+ return date === null ? 0 : date.getTime() / 1000;
2993
+ };
2994
+
2995
+ $.extend(this.data, {
2996
+ users: $('#wpProQuiz_historyUser').val(),
2997
+ pageLimit: $('#wpProQuiz_historyPageLimit').val(),
2998
+ dateFrom: getTime($('#datepickerFrom')),
2999
+ dateTo: getTime($('#datepickerTo')),
3000
+ generateNav: 1
3001
+ });
3002
+
3003
+ return this.data;
3004
+ }
3005
+ };
3006
+
3007
+ var overviewFilter = {
3008
+ data: {
3009
+ pageLimit: 100,
3010
+ onlyCompleted: 0,
3011
+ generateNav: 0,
3012
+ quizId: quizId
3013
+ },
3014
+
3015
+ changeFilter: function () {
3016
+ $.extend(this.data, {
3017
+ pageLimit: $('#wpProQuiz_overviewPageLimit').val(),
3018
+ onlyCompleted: Number($('#wpProQuiz_overviewOnlyCompleted').is(':checked')),
3019
+ generateNav: 1
3020
+ });
3021
+ }
3022
+ };
3023
+
3024
+ var deleteMethode = {
3025
+ deleteUserStatistic: function (refId, userId) {
3026
+ if (!confirm(wpProQuizLocalize.reset_statistics_msg))
3027
+ return false;
3028
+
3029
+ var data = {
3030
+ refId: refId,
3031
+ userId: userId,
3032
+ quizId: quizId,
3033
+ type: 0
3034
+ };
3035
+
3036
+ global.ajaxPost('statisticResetNew', data, function () {
3037
+ $('#wpProQuiz_user_overlay').hide();
3038
+
3039
+ historyFilter.changeFilter();
3040
+ methode.loadHistoryAjax();
3041
+
3042
+ overviewFilter.changeFilter();
3043
+ methode.loadOverviewAjax();
3044
+
3045
+ });
3046
+ },
3047
+
3048
+ deleteAll: function () {
3049
+ if (!confirm(wpProQuizLocalize.reset_statistics_msg))
3050
+ return false;
3051
+
3052
+ var data = {
3053
+ quizId: quizId,
3054
+ type: 1
3055
+ };
3056
+
3057
+ global.ajaxPost('statisticResetNew', data, function () {
3058
+ historyFilter.changeFilter();
3059
+ methode.loadHistoryAjax();
3060
+
3061
+ overviewFilter.changeFilter();
3062
+ methode.loadOverviewAjax();
3063
+ });
3064
+ }
3065
+ };
3066
+
3067
+ var methode = {
3068
+ loadHistoryAjax: function () {
3069
+
3070
+ var data = $.extend({
3071
+ page: historyFilter.data.generateNav ? 1 : historyNavigator.getCurrentPage()
3072
+ }, historyFilter.data);
3073
+
3074
+ methode.loadBox(true);
3075
+ var content = $('#wpProQuiz_historyLoadContext').hide();
3076
+
3077
+ global.ajaxPost('statisticLoadHistory', data, function (json) {
3078
+ content.html(json.html).show();
3079
+
3080
+ if (json.navi)
3081
+ historyNavigator.setNumPage(json.navi);
3082
+
3083
+ historyFilter.data.generateNav = 0;
3084
+
3085
+ content.find('.user_statistic').click(function () {
3086
+ methode.loadUserAjax(0, $(this).data('ref_id'), false);
3087
+
3088
+ return false;
3089
+ });
3090
+
3091
+ content.find('.wpProQuiz_delete').click(function () {
3092
+ deleteMethode.deleteUserStatistic($(this).parents('tr').find('.user_statistic').data('ref_id'), 0);
3093
+
3094
+ return false;
3095
+ });
3096
+
3097
+ methode.loadBox(false);
3098
+ });
3099
+
3100
+ },
3101
+
3102
+ loadUserAjax: function (userId, refId, avg) {
3103
+ $('#wpProQuiz_user_overlay, #wpProQuiz_loadUserData').show();
3104
+
3105
+ var content = $('#wpProQuiz_user_content').hide();
3106
+
3107
+ var data = {
3108
+ quizId: quizId,
3109
+ userId: userId,
3110
+ refId: refId,
3111
+ avg: Number(avg)
3112
+ };
3113
+
3114
+ global.ajaxPost('statisticLoadUser', data, function (json) {
3115
+ content.html(json.html);
3116
+
3117
+ content.find('.wpProQuiz_update').click(function () {
3118
+ methode.loadUserAjax(userId, refId, avg);
3119
+
3120
+ return false;
3121
+ });
3122
+
3123
+ content.find('#wpProQuiz_resetUserStatistic').click(function () {
3124
+ deleteMethode.deleteUserStatistic(refId, userId);
3125
+ });
3126
+
3127
+ content.find('.statistic_data').click(function () {
3128
+ $(this).parents('tr').next().toggle('fast');
3129
+
3130
+ return false;
3131
+ });
3132
+
3133
+ $('#wpProQuiz_loadUserData').hide();
3134
+ content.show();
3135
+ });
3136
+
3137
+ },
3138
+
3139
+ loadBox: function (show, contain) {
3140
+ if (show)
3141
+ $('#wpProQuiz_loadDataHistory').show();
3142
+ else
3143
+ $('#wpProQuiz_loadDataHistory').hide();
3144
+
3145
+ },
3146
+
3147
+ loadOverviewAjax: function () {
3148
+ var data = $.extend({
3149
+ page: overviewFilter.data.generateNav ? 1 : overviewNavigator.getCurrentPage()
3150
+ }, overviewFilter.data);
3151
+
3152
+ $('#wpProQuiz_loadDataOverview').show();
3153
+
3154
+ var content = $('#wpProQuiz_overviewLoadContext').hide();
3155
+
3156
+ global.ajaxPost('statisticLoadOverviewNew', data, function (json) {
3157
+ content.html(json.html).show();
3158
+
3159
+ if (json.navi)
3160
+ overviewNavigator.setNumPage(json.navi);
3161
+
3162
+ overviewFilter.data.generateNav = 0;
3163
+
3164
+ content.find('.user_statistic').click(function () {
3165
+ methode.loadUserAjax($(this).data('user_id'), 0, true);
3166
+
3167
+ return false;
3168
+ });
3169
+
3170
+ content.find('.wpProQuiz_delete').click(function () {
3171
+ deleteMethode.deleteUserStatistic(0, $(this).parents('tr').find('.user_statistic').data('user_id'));
3172
+
3173
+ return false;
3174
+ });
3175
+
3176
+ $('#wpProQuiz_loadDataOverview').hide();
3177
+ });
3178
+ }
3179
+ };
3180
+
3181
+ var init = function () {
3182
+ historyNavigator = new Navigator($('#historyNavigation'), {
3183
+ onChange: function () {
3184
+ methode.loadHistoryAjax();
3185
+ }
3186
+ });
3187
+
3188
+ overviewNavigator = new Navigator($('#overviewNavigation'), {
3189
+ onChange: function () {
3190
+ methode.loadOverviewAjax();
3191
+ }
3192
+ });
3193
+
3194
+ $('#datepickerFrom').datepicker({
3195
+ closeText: wpProQuizLocalize.closeText,
3196
+ currentText: wpProQuizLocalize.currentText,
3197
+ monthNames: wpProQuizLocalize.monthNames,
3198
+ monthNamesShort: wpProQuizLocalize.monthNamesShort,
3199
+ dayNames: wpProQuizLocalize.dayNames,
3200
+ dayNamesShort: wpProQuizLocalize.dayNamesShort,
3201
+ dayNamesMin: wpProQuizLocalize.dayNamesMin,
3202
+ dateFormat: wpProQuizLocalize.dateFormat,
3203
+ firstDay: wpProQuizLocalize.firstDay,
3204
+
3205
+ changeMonth: true,
3206
+ onClose: function (selectedDate) {
3207
+ $('#datepickerTo').datepicker('option', 'minDate', selectedDate);
3208
+ }
3209
+ });
3210
+
3211
+ $('#datepickerTo').datepicker({
3212
+ closeText: wpProQuizLocalize.closeText,
3213
+ currentText: wpProQuizLocalize.currentText,
3214
+ monthNames: wpProQuizLocalize.monthNames,
3215
+ monthNamesShort: wpProQuizLocalize.monthNamesShort,
3216
+ dayNames: wpProQuizLocalize.dayNames,
3217
+ dayNamesShort: wpProQuizLocalize.dayNamesShort,
3218
+ dayNamesMin: wpProQuizLocalize.dayNamesMin,
3219
+ dateFormat: wpProQuizLocalize.dateFormat,
3220
+ firstDay: wpProQuizLocalize.firstDay,
3221
+
3222
+ changeMonth: true,
3223
+ onClose: function (selectedDate) {
3224
+ $('#datepickerFrom').datepicker('option', 'maxDate', selectedDate);
3225
+ }
3226
+ });
3227
+
3228
+ $('#filter').click(function () {
3229
+ historyFilter.changeFilter();
3230
+ methode.loadHistoryAjax();
3231
+ });
3232
+
3233
+ $('#wpProQuiz_overlay_close').click(function () {
3234
+ $('#wpProQuiz_user_overlay').hide();
3235
+ });
3236
+
3237
+ $('#wpProQuiz_tabHistory .wpProQuiz_update').click(function () {
3238
+ historyFilter.changeFilter();
3239
+ methode.loadHistoryAjax();
3240
+
3241
+ return false;
3242
+ });
3243
+
3244
+ $('#wpProQuiz_tabOverview .wpProQuiz_update').click(function () {
3245
+ overviewFilter.changeFilter();
3246
+ methode.loadOverviewAjax();
3247
+
3248
+ return false;
3249
+ });
3250
+
3251
+ $('.wpProQuiz_resetComplete').click(function () {
3252
+ deleteMethode.deleteAll();
3253
+
3254
+ return false;
3255
+ });
3256
+
3257
+ $('#overviewFilter').click(function () {
3258
+ overviewFilter.changeFilter();
3259
+ methode.loadOverviewAjax();
3260
+ });
3261
+
3262
+ historyFilter.changeFilter();
3263
+ methode.loadHistoryAjax();
3264
+
3265
+ overviewFilter.changeFilter();
3266
+ methode.loadOverviewAjax();
3267
+ };
3268
+
3269
+ init();
3270
+ }
3271
+ };
3272
+
3273
+ var init = function () {
3274
+ tabWrapper();
3275
+
3276
+ var m = $.noop;
3277
+
3278
+ if ($('.wpProQuiz_questionEdit').length) {
3279
+ m = module.questionEdit;
3280
+ } else if ($('.wpProQuiz_globalSettings').length) {
3281
+ m = module.gobalSettings;
3282
+ } else if ($('.wpProQuiz_statistics').length) {
3283
+ m = module.statistic;
3284
+ } else if ($('.wpProQuiz_statisticsNew').length) {
3285
+ m = module.statisticNew;
3286
+ }
3287
+
3288
+ m();
3289
+
3290
+ $('.wpProQuiz_demoImgBox a').mouseover(function (e) {
3291
+ var $this = $(this);
3292
+ var d = $(document).width();
3293
+ var img = $this.siblings().outerWidth(true);
3294
+
3295
+ if (e.pageX + img > d) {
3296
+ var v = d - (e.pageX + img + 30);
3297
+ $(this).next().css('left', v + "px");
3298
+ }
3299
+
3300
+ $(this).next().show();
3301
+
3302
+ }).mouseout(function () {
3303
+ $(this).next().hide();
3304
+ }).click(function () {
3305
+ return false;
3306
+ });
3307
+ };
3308
+
3309
+ init();
3310
+ }
3311
+
3312
+ WpProQuiz_Admin();
3313
+
3314
+ function Navigator(obj, option) {
3315
+ var defaultOption = {
3316
+ onChange: null
3317
+ };
3318
+
3319
+ var elements = {
3320
+ contain: null,
3321
+ pageLeft: null,
3322
+ pageRight: null,
3323
+ currentPage: null
3324
+ };
3325
+
3326
+ var checkNavBar = function () {
3327
+ var num = elements.currentPage.children().length;
3328
+ var cur = Number(elements.currentPage.val());
3329
+
3330
+ elements.pageLeft.hide();
3331
+ elements.pageRight.hide();
3332
+
3333
+ if (cur > 1)
3334
+ elements.pageLeft.show();
3335
+
3336
+ if ((cur + 1) <= num)
3337
+ elements.pageRight.show();
3338
+ };
3339
+
3340
+ var init = function () {
3341
+ $.extend(elements, {
3342
+ contain: obj,
3343
+ pageLeft: obj.find('.navigationLeft'),
3344
+ pageRight: obj.find('.navigationRight'),
3345
+ currentPage: obj.find('.navigationCurrentPage')
3346
+ });
3347
+
3348
+ $.extend(defaultOption, option);
3349
+
3350
+ elements.pageLeft.click(function () {
3351
+ elements.currentPage.val(Number(elements.currentPage.val()) - 1);
3352
+ checkNavBar();
3353
+
3354
+ if (defaultOption.onChange)
3355
+ defaultOption.onChange(elements.currentPage.val());
3356
+ });
3357
+
3358
+ elements.pageRight.click(function () {
3359
+ elements.currentPage.val(Number(elements.currentPage.val()) + 1);
3360
+ checkNavBar();
3361
+
3362
+ if (defaultOption.onChange)
3363
+ defaultOption.onChange(elements.currentPage.val());
3364
+ });
3365
+
3366
+ elements.currentPage.change(function () {
3367
+ checkNavBar();
3368
+
3369
+ if (defaultOption.onChange)
3370
+ defaultOption.onChange(elements.currentPage.val());
3371
+ });
3372
+ };
3373
+
3374
+ this.getCurrentPage = function () {
3375
+ return elements.currentPage.val();
3376
+ }
3377
+
3378
+ this.setNumPage = function (num) {
3379
+ elements.currentPage.empty();
3380
+
3381
+ for (var i = 1; i <= num; i++) {
3382
+ $(document.createElement('option'))
3383
+ .val(i)
3384
+ .text(i)
3385
+ .appendTo(elements.currentPage);
3386
+ }
3387
+
3388
+ checkNavBar();
3389
+ }
3390
+
3391
+ init();
3392
+ }
3393
  });
js/wpProQuiz_admin.min.js CHANGED
@@ -1,83 +1,2 @@
1
- jQuery(document).ready(function(a){function r(c,f){var d={onChange:null},b={contain:null,pageLeft:null,pageRight:null,currentPage:null},h=function(){var a=b.currentPage.children().length,g=Number(b.currentPage.val());b.pageLeft.hide();b.pageRight.hide();1<g&&b.pageLeft.show();g+1<=a&&b.pageRight.show()};this.getCurrentPage=function(){return b.currentPage.val()};this.setNumPage=function(c){b.currentPage.empty();for(var g=1;g<=c;g++)a(document.createElement("option")).val(g).text(g).appendTo(b.currentPage);
2
- h()};(function(){a.extend(b,{contain:c,pageLeft:c.find(".navigationLeft"),pageRight:c.find(".navigationRight"),currentPage:c.find(".navigationCurrentPage")});a.extend(d,f);b.pageLeft.click(function(){b.currentPage.val(Number(b.currentPage.val())-1);h();if(d.onChange)d.onChange(b.currentPage.val())});b.pageRight.click(function(){b.currentPage.val(Number(b.currentPage.val())+1);h();if(d.onChange)d.onChange(b.currentPage.val())});b.currentPage.change(function(){h();if(d.onChange)d.onChange(b.currentPage.val())})})()}
3
- a.fn.wpProQuiz_preview=function(){var c={openPreview:function(c){window.open(a(c).attr("href"),"wpProQuizPreview","width=900,height=900")}};(function(){a(".wpProQuiz_prview").click(function(a){c.openPreview(this);a.preventDefault()})})()};a.fn.wpProQuiz_quizOverall=function(){};a.fn.wpProQuiz_quizEdit=function(){function c(b,c,d){a.post(ajaxurl,{action:"wp_pro_quiz_admin_ajax",func:b,data:c},d,"json")}var f={addCategory:function(){var b=a.trim(a('input[name="categoryAdd"]').val());d(b)||c("categoryAdd",
4
- {categoryName:b,type:"quiz"},function(b){b.err?a("#categoryMsgBox").text(b.err).show("fast").delay(2E3).hide("fast"):(b=a(document.createElement("option")).val(b.categoryId).text(b.categoryName).attr("selected","selected"),a('select[name="category"]').append(b).change())})},addResult:function(){a("#resultList").children().each(function(){if("none"==a(this).css("display")){var b=a(this),c=b.find('textarea[name="resultTextGrade[text][]"]'),d=c.attr("id"),g=!0;b.find('input[name="resultTextGrade[prozent][]"]').val("0");
5
- b.find('input[name="resultTextGrade[activ][]"]').val("1").keyup();void 0==tinymce.editors[d]||tinymce.editors[d].isHidden()||(g=!1);void 0==switchEditors||g||(switchEditors.go(d,"toggle"),switchEditors.go(d,"toggle"));void 0!=tinymce.editors[d]?tinymce.editors[d].setContent(""):c.val("");void 0==tinymce.editors[d]||g||tinyMCE.execCommand("mceRemoveControl",!1,d);b.parent().children(":visible").last().after(b);void 0==tinymce.editors[d]||g||tinyMCE.execCommand("mceAddControl",!1,d);a(this).show();
6
- void 0==switchEditors||g||switchEditors.go(d,"toggle");return!1}})},deleteResult:function(b){a(b).parent().parent().hide();a(b).siblings('input[name="resultTextGrade[activ][]"]').val("0")},changeResult:function(b){b=a(b);if(f.validResultInput(b.val()))return b.siblings(".resultProzent").text(b.val()),b.removeAttr("style"),!0;b.css("background-color","#FF9696");return!1},validResultInput:function(a){if(d(a))return!1;a=a.replace(/\,/,".");return!isNaN(a)&&100>=Number(a)&&0<=Number(a)?null!=a.match(/\./)?
7
- 3>a.split(".")[1].length:!0:!1},validInput:function(){if(d(a("#wpProQuiz_title").val()))return alert(wpProQuizLocalize.no_title_msg),!1;var b="",b=void 0==tinymce.editors.text||tinymce.editors.text.isHidden()?a('textarea[name="text"]').val():tinymce.editors.text.getContent();if(d(b))return alert(wpProQuizLocalize.no_quiz_start_msg),!1;if(a("#wpProQuiz_resultGradeEnabled:checked").length){var c=!0;a("#resultList").children().each(function(){if(a(this).is(":visible")&&!f.validResultInput(a(this).find('input[name="resultTextGrade[prozent][]"]').val()))return c=
8
- !1});if(!c)return alert(wpProQuizLocalize.fail_grade_result),!1}return!0},resetLock:function(){var b=(window.location.pathname+window.location.search).replace("admin.php","admin-ajax.php"),b=b.replace("action=edit","action=reset_lock");a.post(b,{action:"wp_pro_quiz_reset_lock"},function(b){a("#resetLockMsg").show("fast").delay(2E3).hide("fast")})},generateFormIds:function(){var b=0;a("#form_table tbody > tr").each(function(){a(this).find('[name^="form[]"]').each(function(){var c=a(this).attr("name").substr(6);
9
- a(this).attr("name","form["+b+"]"+c)});++b})},updateFormIds:function(){var b=-1,c=a(".emailFormVariables option:selected").val(),f=a(".formVariables").empty(),g=a(".emailFormVariables").empty().append('<option value="-1"></option>');-1<a(".emailFormVariables").data("default")&&(c=a(".emailFormVariables").data("default"),a(".emailFormVariables").data("default",-1));a("#form_table tbody > tr").each(function(){a(this).children().first().text(b);var c=a(this).find(".formFieldName").val(),l=a(this).find('[name="form[][type]"] option:selected'),
10
- e=a(this).find('[name="form[][fieldname]"]').val();1!=a(this).find('input[name="form[][form_delete]"]').val()&&(0<=b&&!d(c)&&f.append(a("<li><span>$form{"+b+"}</span> - "+c+"</li>")),4==l.val()&&g.append(a('<option value="'+b+'">'+e+"</option>")),b++)});a('.emailFormVariables option[value="'+c+'"]').prop("selected",!0)}},d=function(b){b=a.trim(b);return!b||0===b.length};(function(){a("#statistics_on").change(function(){this.checked?a("#statistics_ip_lock_tr").show():a("#statistics_ip_lock_tr").hide()});
11
- a(".addResult").click(function(){f.addResult()});a(".deleteResult").click(function(a){f.deleteResult(this)});a('input[name="resultTextGrade[prozent][]"]').keyup(function(a){f.changeResult(this)}).keydown(function(a){13==a.which&&a.preventDefault()});a("#wpProQuiz_resultGradeEnabled").change(function(){this.checked?(a("#resultGrade").show(),a("#resultNormal").hide()):(a("#resultGrade").hide(),a("#resultNormal").show())});a("#wpProQuiz_save").click(function(b){f.validInput()?f.generateFormIds():b.preventDefault();
12
- a('select[name="prerequisiteList[]"] option').attr("selected","selected")});a('input[name="template"]').click(function(b){if("0"==a('select[name="templateSaveList"]').val()&&d(a('input[name="templateName"]').val()))return alert(wpProQuizLocalize.temploate_no_name),b.preventDefault(),!1;f.generateFormIds();a('select[name="prerequisiteList[]"] option').attr("selected","selected")});a('select[name="templateSaveList"]').change(function(){var b=a('input[name="templateName"]');"0"==a(this).val()?b.show():
13
- b.hide()}).change();a('input[name="quizRunOnce"]').change(function(b){this.checked?(a("#wpProQuiz_quiz_run_once_type").show(),a('input[name="quizRunOnceType"]:checked').change()):a("#wpProQuiz_quiz_run_once_type").hide()});a('input[name="quizRunOnceType"]').change(function(b){!this.checked||"1"!=this.value&&"3"!=this.value?a("#wpProQuiz_quiz_run_once_cookie").hide():a("#wpProQuiz_quiz_run_once_cookie").show()});a('input[name="resetQuizLock"]').click(function(a){f.resetLock();return!1});a(".wpProQuiz_demoBox a").mouseover(function(b){var c=
14
- a(this),d=a("#poststuff").width(),g=c.siblings().outerWidth(!0);b.pageX+g>d&&(b=jQuery(document).width()-c.parent().offset().left-g-30,a(this).next().css("left",b+"px"));a(this).next().show()}).mouseout(function(){a(this).next().hide()}).click(function(){return!1});a('input[name="showMaxQuestion"]').change(function(){this.checked?a("#wpProQuiz_showMaxBox").show():a("#wpProQuiz_showMaxBox").hide()});a("#btnPrerequisiteAdd").click(function(){a('select[name="quizList"] option:selected').removeAttr("selected").appendTo('select[name="prerequisiteList[]"]')});
15
- a("#btnPrerequisiteDelete").click(function(){a('select[name="prerequisiteList[]"] option:selected').removeAttr("selected").appendTo('select[name="quizList"]')});a('input[name="prerequisite"]').change(function(){this.checked?a("#prerequisiteBox").show():a("#prerequisiteBox").hide()}).change();a('input[name="toplistDataAddMultiple"]').change(function(){this.checked?a("#toplistDataAddBlockBox").show():a("#toplistDataAddBlockBox").hide()}).change();a('input[name="toplistActivated"]').change(function(){this.checked?
16
- a("#toplistBox > tr:gt(0)").show():a("#toplistBox > tr:gt(0)").hide()}).change();a('input[name="showReviewQuestion"]').change(function(){this.checked?a(".wpProQuiz_reviewQuestionOptions").show():a(".wpProQuiz_reviewQuestionOptions").hide()}).change();a("#statistics_on").change();a("#wpProQuiz_resultGradeEnabled").change();a('input[name="quizRunOnce"]').change();a('input[name="quizRunOnceType"]:checked').change();a('input[name="showMaxQuestion"]').change();a("#form_add").click(function(){a("#form_table tbody > tr:eq(0)").clone(!0).appendTo("#form_table tbody").show();
17
- f.updateFormIds()});a('input[name="form_delete"]').click(function(){var b=a(this).parents("tr");"0"!=b.find('input[name="form[][form_id]"]').val()?(b.find('input[name="form[][form_delete]"]').val(1),b.hide()):b.remove();f.updateFormIds()});a("#form_table tbody").sortable({handle:".form_move",update:f.updateFormIds});a(".form_move").click(function(){return!1});a('select[name="form[][type]"]').change(function(){switch(Number(a(this).val())){case 7:case 8:a(this).siblings(".editDropDown").show();break;
18
- default:a(this).siblings(".editDropDown, .dropDownEditBox").hide()}}).change();a(".editDropDown").click(function(){a(".dropDownEditBox").not(a(this).siblings(".dropDownEditBox").toggle()).hide();return!1});a(".dropDownEditBox input").click(function(){a(this).parent().hide()});a('.formFieldName, select[name="form[][type]"]').change(function(){f.updateFormIds()});a('select[name="category"]').change(function(){var b=a(this),c=a("#categoryAddBox").hide();"-1"==b.val()&&c.show()}).change();a("#categoryAddBtn").click(function(){f.addCategory()});
19
- a('input[name="emailNotification"]').change(function(){var b=a("#adminEmailSettings tr:gt(0)");0<a('input[name="emailNotification"]:checked').val()?b.show():b.hide()}).change();a('input[name="userEmailNotification"]').change(function(){var b=a("#userEmailSettings tr:gt(0)");0<a('input[name="userEmailNotification"]:checked').val()?b.show():b.hide()}).change();f.updateFormIds();a('input[name="email[html]"]').change(function(){if(void 0==switchEditors)return!1;this.checked?switchEditors.go("adminEmailEditor",
20
- "tmce"):switchEditors.go("adminEmailEditor","html")}).change();a('input[name="userEmail[html]"]').change(function(){if(void 0==switchEditors)return!1;this.checked?switchEditors.go("userEmailEditor","tmce"):switchEditors.go("userEmailEditor","html")}).change()})()};a.fn.wpProQuiz_statistics=function(){var c="wpProQuiz_typeAnonymeUser",f=!0,d={loadStatistics:function(b){var c=(window.location.pathname+window.location.search).replace("admin.php","admin-ajax.php")+"&action=load_statistics";b={action:"wp_pro_quiz_load_statistics",
21
- userId:b};a("#wpProQuiz_loadData").show();a("#wpProQuiz_statistics_content, #wpProQuiz_statistics_overview").hide();a.post(c,b,d.setStatistics,"json")},setStatistics:function(b){var d=a(".wpProQuiz_statistics_table"),f=d.find("tbody");if("wpProQuiz_typeOverview"!=c){var g=function(a,g,b){a.find(".wpProQuiz_cCorrect").text(g.cCorrect+" ("+g.pCorrect+"%)");a.find(".wpProQuiz_cIncorrect").text(g.cIncorrect+" ("+g.pIncorrect+"%)");a.find(".wpProQuiz_cTip").text(g.cTip);a.find(".wpProQuiz_cPoints").text(g.cPoints);
22
- 1==b&&d.find(".wpProQuiz_cResult").text(g.result+"%")};g(d,b.clear,!1);a.each(b.items,function(a,b){g(f.find("#wpProQuiz_tr_"+b.id),b,!1)});g(d.find("tfoot"),b.global,!0);a("#wpProQuiz_loadData").hide();a("#wpProQuiz_statistics_content, .wpProQuiz_statistics_table").show()}},loadOverview:function(){a(".wpProQuiz_statistics_table, #wpProQuiz_statistics_content, #wpProQuiz_statistics_overview").hide();a("#wpProQuiz_loadData").show();var b=(window.location.pathname+window.location.search).replace("admin.php",
23
- "admin-ajax.php")+"&action=load_statistics",h={action:"wp_pro_quiz_load_statistics",overview:!0,pageLimit:a("#wpProQuiz_pageLimit").val(),onlyCompleted:Number(a("#wpProQuiz_onlyCompleted").is(":checked")),page:a("#wpProQuiz_currentPage").val(),generatePageNav:Number(f)};a.post(b,h,function(b){a("#wpProQuiz_statistics_overview_data").empty();if("wpProQuiz_typeOverview"==c){var g=a('<tr><th><a href="#">---</a></th><th class="wpProQuiz_points">---</th><th class="wpProQuiz_cCorrect" style="color: green;">---</th><th class="wpProQuiz_cIncorrect" style="color: red;">---</th><th class="wpProQuiz_cTip">---</th><th class="wpProQuiz_cResult" style="font-weight: bold;">---</th></tr>');
24
- a.each(b.items,function(b,c){var e=g.clone();e.find("a").text(c.userName).data("userId",c.userId).click(function(){a("#userSelect").val(a(this).data("userId"));a("#wpProQuiz_typeRegisteredUser").click();return!1});c.completed?(e.find(".wpProQuiz_points").text(c.cPoints),e.find(".wpProQuiz_cCorrect").text(c.cCorrect+" ("+c.pCorrect+"%)"),e.find(".wpProQuiz_cIncorrect").text(c.cIncorrect+" ("+c.pIncorrect+"%)"),e.find(".wpProQuiz_cTip").text(c.cTip),e.find(".wpProQuiz_cResult").text(c.result+"%")):
25
- e.find("th").removeAttr("style");a("#wpProQuiz_statistics_overview_data").append(e)});void 0!=b.page&&(d.setPageNav(b.page),f=!1);a("#wpProQuiz_loadData").hide();a("#wpProQuiz_statistics_overview").show()}},"json")},loadFormOverview:function(){a("#wpProQuiz_tabFormOverview").show()},changeTab:function(b){c=b;"wpProQuiz_typeRegisteredUser"==b?d.loadStatistics(a("#userSelect").val()):"wpProQuiz_typeAnonymeUser"==b?d.loadStatistics(0):"wpProQuiz_typeForm"==b?d.loadFormOverview():d.loadOverview()},resetStatistic:function(b){var f=
26
- "wpProQuiz_typeRegisteredUser"==c?a("#userSelect").val():0,n=(window.location.pathname+window.location.search).replace("admin.php","admin-ajax.php")+"&action=reset";a.post(n,{action:"wp_pro_quiz_statistics",userId:f,complete:b},function(a){d.changeTab(c)})},setPageNav:function(b){b=Math.ceil(b/a("#wpProQuiz_pageLimit").val());a("#wpProQuiz_currentPage").empty();for(var c=1;c<=b;c++)a(document.createElement("option")).val(c).text(c).appendTo(a("#wpProQuiz_currentPage"));a("#wpProQuiz_pageLeft, #wpProQuiz_pageRight").hide();
27
- 1<a("#wpProQuiz_currentPage option").length&&a("#wpProQuiz_pageRight").show()}};(function(){a(".wpProQuiz_tab").click(function(b){b=a(this);if(b.hasClass("button-primary"))return!1;"wpProQuiz_typeRegisteredUser"==b.attr("id")?a("#wpProQuiz_userBox").show():a("#wpProQuiz_userBox").hide();a(".wpProQuiz_tab").removeClass("button-primary").addClass("button-secondary");b.removeClass("button-secondary").addClass("button-primary");d.changeTab(b.attr("id"));return!1});a("#userSelect").change(function(){d.changeTab("wpProQuiz_typeRegisteredUser")});
28
- a(".wpProQuiz_update").click(function(){d.changeTab(c);return!1});a("#wpProQuiz_reset").click(function(){confirm(wpProQuizLocalize.reset_statistics_msg)&&d.resetStatistic(!1);return!1});a(".wpProQuiz_resetComplete").click(function(){confirm(wpProQuizLocalize.reset_statistics_msg)&&d.resetStatistic(!0);return!1});a("#wpProQuiz_pageLimit, #wpProQuiz_onlyCompleted").change(function(){a("#wpProQuiz_currentPage").val(0);f=!0;d.changeTab(c);return!1});a("#wpProQuiz_currentPage").change(function(){a("#wpProQuiz_pageLeft, #wpProQuiz_pageRight").hide();
29
- 1!=a("#wpProQuiz_currentPage option").length&&(a("#wpProQuiz_currentPage option:first-child:selected").length?a("#wpProQuiz_pageRight").show():a("#wpProQuiz_currentPage option:last-child:selected").length?a("#wpProQuiz_pageLeft").show():a("#wpProQuiz_pageLeft, #wpProQuiz_pageRight").show());d.changeTab(c)});a("#wpProQuiz_pageRight").click(function(){a("#wpProQuiz_currentPage option:selected").next().attr("selected","selected");a("#wpProQuiz_currentPage").change();return!1});a("#wpProQuiz_pageLeft").click(function(){a("#wpProQuiz_currentPage option:selected").prev().attr("selected",
30
- "selected");a("#wpProQuiz_currentPage").change();return!1});d.changeTab("wpProQuiz_typeAnonymeUser")})()};a.fn.wpProQuiz_toplist=function(){var c=a("#wpProQuiz_sorting"),f=a("#wpProQuiz_pageLimit"),d=a("#wpProQuiz_currentPage"),b=a("#wpProQuiz_loadData"),h=a("#wpProQuiz_pageLeft"),n=a("#wpProQuiz_pageRight"),g=a("#wpProQuiz_toplistTable tbody"),q=a("#wpProQuiz_toplistTable tbody tr:eq(0)").clone(),l=a("#wpProQuiz_content"),e={loadData:function(g){var q=(window.location.pathname+window.location.search).replace("admin.php",
31
- "admin-ajax.php")+"&action=load_toplist",k=this,t={action:"wp_pro_quiz_load_toplist",sort:c.val(),limit:f.val(),page:d.val()};void 0!=g&&a.extend(t,g);b.show();l.hide();a.post(q,t,function(a){k.handleDataRequest(a.data);void 0!=a.nav&&k.handleNav(a.nav);b.hide();l.show()},"json")},handleNav:function(g){d.empty();for(var b=1;b<=g.pages;b++)a(document.createElement("option")).val(b).text(b).appendTo(d);this.checkNav()},handleDataRequest:function(b){var c=this;g.empty();a.each(b,function(a,b){var c=
32
- q.clone().children();c.eq(0).children().val(b.id);c.eq(1).find("strong").text(b.name);c.eq(1).find(".inline_editUsername").val(b.name);c.eq(2).find(".wpProQuiz_email").text(b.email);c.eq(2).find("input").val(b.email);c.eq(3).text(b.type);c.eq(4).text(b.date);c.eq(5).text(b.points);c.eq(6).text(b.result);c.parent().show().appendTo(g)});b.length||a(document.createElement("td")).attr("colspan","7").text(wpProQuizLocalize.no_data_available).css({"font-weight":"bold","text-align":"center",padding:"5px"}).appendTo(document.createElement("tr")).appendTo(g);
33
- a(".wpProQuiz_delete").click(function(){if(confirm(wpProQuizLocalize.confirm_delete_entry)){var b=Array(a(this).closest("tr").find('input[name="checkedData[]"]').val());c.loadData({a:"delete",toplistIds:b})}return!1});a(".wpProQuiz_edit").click(function(){var b=a(this).closest("tr");b.find(".row-actions").hide();b.find(".inline-edit").show();b.find(".wpProQuiz_username, .wpProQuiz_email").hide();b.find(".inline_editUsername, .inline_editEmail").show();return!1});a(".inline_editSave").click(function(){var b=
34
- a(this).closest("tr"),g=b.find(".inline_editUsername").val(),p=b.find(".inline_editEmail").val();if(c.isEmpty(g)||c.isEmpty(p))return alert(wpProQuizLocalize.not_all_fields_completed),!1;c.loadData({a:"edit",toplistId:b.find('input[name="checkedData[]"]').val(),name:g,email:p});return!1});a(".inline_editCancel").click(function(){var b=a(this).closest("tr");b.find(".row-actions").show();b.find(".inline-edit").hide();b.find(".wpProQuiz_username, .wpProQuiz_email").show();b.find(".inline_editUsername, .inline_editEmail").hide();
35
- b.find(".inline_editUsername").val(b.find(".wpProQuiz_username").text());b.find(".inline_editEmail").val(b.find(".wpProQuiz_email").text());return!1})},checkNav:function(){var a=d.val();1==a?h.hide():h.show();a==d.children().length?n.hide():n.show()},isEmpty:function(b){b=a.trim(b);return!b||0===b.length}};(function(){c.change(function(){e.loadData()});f.change(function(){e.loadData({nav:1})});d.change(function(){e.checkNav();e.loadData()});h.click(function(){d.val(Number(d.val())-1);e.checkNav();
36
- e.loadData()});n.click(function(){d.val(Number(d.val())+1);e.checkNav();e.loadData()});a("#wpProQuiz_deleteAll").click(function(){e.loadData({a:"deleteAll"})});a("#wpProQuiz_action").click(function(){var b=a("#wpProQuiz_actionName").val();if("0"!=b){var g=a('input[name="checkedData[]"]:checked').map(function(){return a(this).val()}).get();e.loadData({a:b,toplistIds:g})}});a("#wpProQuiz_checkedAll").change(function(){this.checked?a('input[name="checkedData[]"]').attr("checked","checked"):a('input[name="checkedData[]"]').removeAttr("checked",
37
- "checked")});e.loadData({nav:1})})()};a(".wpProQuiz_quizOverall").length&&a(".wpProQuiz_quizOverall").wpProQuiz_preview();a(".wpProQuiz_quizOverall").length&&a(".wpProQuiz_quizOverall").wpProQuiz_quizOverall();a(".wpProQuiz_quizEdit").length&&a(".wpProQuiz_quizEdit").wpProQuiz_quizEdit();a(".wpProQuiz_toplist").length&&a(".wpProQuiz_toplist").wpProQuiz_toplist();(function(){var c=this,c={displayChecked:function(a,b,c,e){a=c?!a.checked:a.checked;e?a?b.attr("disabled","disabled"):b.removeAttr("disabled"):
38
- a?b.show():b.hide()},isEmpty:function(b){b=a.trim(b);return!b||0===b.length},isNumber:function(b){b=a.trim(b);return!c.isEmpty(b)&&!isNaN(b)},getMceContent:function(b){var c=tinymce.editors[b];return void 0==c||c.isHidden()?a("#"+b).val():c.getContent()},ajaxPost:function(b,c,d){a.post(ajaxurl,{action:"wp_pro_quiz_admin_ajax",func:b,data:c},d,"json")}},f=function(){a(".wpProQuiz_tab_wrapper a").click(function(){var b=a(this),c=b.data("tab"),d=b.siblings(".button-primary").removeClass("button-primary").addClass("button-secondary");
39
- b.removeClass("button-secondary").addClass("button-primary");a(d.data("tab")).hide("fast");a(c).show("fast");a(document).trigger({type:"changeTab",tabId:c});return!1})},d=function(){var b={categoryDelete:function(b,g){c.ajaxPost("categoryDelete",{categoryId:b},function(c){c.err||(a('select[name="category'+g+'"] option[value="'+b+'"]').remove(),a('select[name="category'+g+'"]').change())})},categoryEdit:function(b,g,d){var f={categoryId:b,categoryName:a.trim(g)};c.isEmpty(g)?alert(wpProQuizLocalize.category_no_name):
40
- c.ajaxPost("categoryEdit",f,function(c){c.err||(a('select[name="category'+d+'"] option[value="'+b+'"]').text(f.categoryName),a('select[name="category'+d+'"]').change())})},changeTimeFormat:function(b,c){"0"!=c.val()&&a('input[name="'+b+'"]').val(c.val())},templateDelete:function(b,g){c.ajaxPost("templateDelete",{templateId:b,type:g},function(c){c.err||(g?(a('select[name="templateQuestion"] option[value="'+b+'"]').remove(),a('select[name="templateQuestion"]').change()):(a('select[name="templateQuiz"] option[value="'+
41
- b+'"]').remove(),a('select[name="templateQuiz"]').change()))})},templateEdit:function(b,g,d){if(c.isEmpty(g))alert(wpProQuizLocalize.category_no_name);else{var f={templateId:b,name:a.trim(g),type:d};c.ajaxPost("templateEdit",f,function(c){c.err||(d?(a('select[name="templateQuestion"] option[value="'+b+'"]').text(f.name),a('select[name="templateQuestion"]').change()):(a('select[name="templateQuiz"] option[value="'+b+'"]').text(f.name),a('select[name="templateQuiz"]').change()))})}}};(function(){a('select[name="category"]').change(function(){a('input[name="categoryEditText"]').val(a(this).find(":selected").text())}).change();
42
- a('input[name="categoryDelete"]').click(function(){var c=a('select[name="category"] option:selected').val();b.categoryDelete(c,"")});a('input[name="categoryEdit"]').click(function(){var c=a('select[name="category"] option:selected').val(),d=a('input[name="categoryEditText"]').val();b.categoryEdit(c,d,"")});a('select[name="categoryQuiz"]').change(function(){a('input[name="categoryQuizEditText"]').val(a(this).find(":selected").text())}).change();a('input[name="categoryQuizDelete"]').click(function(){var c=
43
- a('select[name="categoryQuiz"] option:selected').val();b.categoryDelete(c,"Quiz")});a('input[name="categoryQuizEdit"]').click(function(){var c=a('select[name="categoryQuiz"] option:selected').val(),d=a('input[name="categoryQuizEditText"]').val();b.categoryEdit(c,d,"Quiz")});a("#statistic_time_format_select").change(function(){b.changeTimeFormat("statisticTimeFormat",a(this))});a(document).bind("changeTab",function(b){a("#problemInfo").hide("fast");switch(b.tabId){case "#problemContent":a("#problemInfo").show("fast")}});
44
- a('input[name="email[html]"]').change(function(){if(void 0==switchEditors)return!1;this.checked?switchEditors.go("adminEmailEditor","tmce"):switchEditors.go("adminEmailEditor","html")}).change();a('input[name="userEmail[html]"]').change(function(){if(void 0==switchEditors)return!1;this.checked?switchEditors.go("userEmailEditor","tmce"):switchEditors.go("userEmailEditor","html")}).change();a('select[name="templateQuiz"]').change(function(){a('input[name="templateQuizEditText"]').val(a(this).find(":selected").text())}).change();
45
- a('select[name="templateQuestion"]').change(function(){a('input[name="templateQuestionEditText"]').val(a(this).find(":selected").text())}).change();a('input[name="templateQuizDelete"]').click(function(){var c=a('select[name="templateQuiz"] option:selected').val();b.templateDelete(c,0)});a('input[name="templateQuestionDelete"]').click(function(){var c=a('select[name="templateQuestion"] option:selected').val();b.templateDelete(c,1)});a('input[name="templateQuizEdit"]').click(function(){var c=a('select[name="templateQuiz"] option:selected').val(),
46
- d=a('input[name="templateQuizEditText"]').val();b.templateEdit(c,d,0)});a('input[name="templateQuestionEdit"]').click(function(){var c=a('select[name="templateQuestion"] option:selected').val(),d=a('input[name="templateQuestionEditText"]').val();b.templateEdit(c,d,1)})})()},b=function(){var b=this,d=a.noop(),f=a(".answer_felder > div"),e=a('input[name="answerPointsActivated"]'),s=a('input[name="points"]'),b={generateArrayIndex:function(){var b=a('input[name="answerType"]:checked').val(),b="single"==
47
- b||"multiple"==b?"classic_answer":b;a(".answerList").each(function(){var c=a(this).parent().attr("class");a(this).children().each(function(g,d){a(this).find('[name^="answerData"]').each(function(){var a=this.name,d=a.search(/\](\[\w+\])+$/),e=b==c?g:"none";0<d&&(this.name="answerData["+e+a.substring(d,a.length))})})})},globalValidate:function(){if(c.isEmpty(c.getMceContent("question")))return alert(wpProQuizLocalize.no_question_msg),!1;if(!e.is(":checked")){var b=s.val();if(!c.isNumber(b)||1>b)return alert(wpProQuizLocalize.no_nummber_points),
48
- !1}else if("free_answer"==a('input[name="answerType"]:checked').val())return alert(wpProQuizLocalize.dif_points),!1;return!1===d()?!1:!0},answerRemove:function(){var b=a(this).parent();if(2>b.parent().children().length)return!1;b.remove();return!1},addCategory:function(){var b=a.trim(a('input[name="categoryAdd"]').val());c.isEmpty(b)||c.ajaxPost("categoryAdd",{categoryName:b},function(b){b.err?a("#categoryMsgBox").text(b.err).show("fast").delay(2E3).hide("fast"):(b=a(document.createElement("option")).val(b.categoryId).text(b.categoryName).attr("selected",
49
- "selected"),a('select[name="category"]').append(b).change())})},addMediaClick:function(){if("function"!=typeof tb_show)return!1;var b=a(this).closest("li"),c=b.find('input[name="answerData[][html]"]:eq(0)'),g=b.find(".wpProQuiz_text:eq(0)");window.org_send_to_editor=window.send_to_editor;var d=tb_remove;window.send_to_editor=function(b){b=a("img",b)[0].outerHTML;g.val(g.val()+b);c.attr("checked",!0);tb_remove();window.send_to_editor=window.org_send_to_editor};window.tb_remove=function(){window.send_to_editor=
50
- window.org_send_to_editor;tb_remove=d;tb_remove()};tb_show("","media-upload.php?type=image&TB_iframe=true")}},h={classic_answer:function(){var b=0,g=0,d=0;a(".classic_answer .answerList").children().each(function(){var e=a(this);c.isEmpty(e.find('textarea[name="answerData[][answer]"]').val())||(b++,e.find('input[name="answerData[][correct]"]:checked').length&&g++,e=e.find('input[name="answerData[][points]"]').val(),c.isNumber(e)&&0<=e&&d++)});return b?g||a('input[name="disableCorrect"]').is(":checked")&&
51
- a('input[name="answerPointsDiffModusActivated"]').is(":checked")&&a('input[name="answerPointsActivated"]').is(":checked")&&"single"==a('input[name="answerType"]:checked').val()?d!=b&&e.is(":checked")?(alert(wpProQuizLocalize.no_nummber_points_new),!1):!0:(alert(wpProQuizLocalize.no_correct_msg),!1):(alert(wpProQuizLocalize.no_answer_msg),!1)},free_answer:function(){return c.isEmpty(a('.free_answer textarea[name="answerData[][answer]"]').val())?(alert(wpProQuizLocalize.no_answer_msg),!1):!0},cloze_answer:function(){return c.isEmpty(c.getMceContent("cloze"))?
52
- (alert(wpProQuizLocalize.no_answer_msg),!1):!0},sort_answer:function(){var b=0,g=0;a(".sort_answer .answerList").children().each(function(){var d=a(this);c.isEmpty(d.find('textarea[name="answerData[][answer]"]').val())||(b++,d=d.find('input[name="answerData[][points]"]').val(),c.isNumber(d)&&0<=d&&g++)});return b?g!=b&&e.is(":checked")?(alert(wpProQuizLocalize.no_nummber_points_new),!1):!0:(alert(wpProQuizLocalize.no_answer_msg),!1)},matrix_sort_answer:function(){var b=0,g=0,d=!0,f=0;a(".matrix_sort_answer .answerList").children().each(function(){var e=
53
- a(this),l=e.find('input[name="answerData[][points]"]').val();c.isEmpty(e.find('textarea[name="answerData[][answer]"]').val())?c.isEmpty(e.find('textarea[name="answerData[][sort_string]"]').val())||(f++,c.isNumber(l)&&0<=l&&g++):(b++,f++,c.isEmpty(e.find('textarea[name="answerData[][sort_string]"]').val())&&(d=!1),c.isNumber(l)&&0<=l&&g++)});return b?d?g!=f&&e.is(":checked")?(alert(wpProQuizLocalize.no_nummber_points_new),!1):!0:(alert(wpProQuizLocalize.no_sort_element_criterion),!1):(alert(wpProQuizLocalize.no_answer_msg),
54
- !1)},assessment_answer:function(){return c.isEmpty(c.getMceContent("assessment"))?(alert(wpProQuizLocalize.no_answer_msg),!1):!0}};f.hide();(function(){a("#wpProQuiz_tip").change(function(){c.displayChecked(this,a("#wpProQuiz_tipBox"))}).change();a("#wpProQuiz_correctSameText").change(function(){c.displayChecked(this,a("#wpProQuiz_incorrectMassageBox"),!0)}).change();a('input[name="answerType"]').click(function(){f.hide();var b=this.value;"single"==b?(a("#singleChoiceOptions").show(),a('input[name="disableCorrect"]').change()):
55
- (a("#singleChoiceOptions").hide(),a(".classic_answer .wpProQuiz_classCorrect").parent().parent().show());if("single"==b||"multiple"==b){var c="single"==b?"radio":"checkbox",b="classic_answer";a(".wpProQuiz_classCorrect").each(function(){a("<input type="+c+" />").attr({name:this.name,value:this.value,checked:this.checked}).addClass("wpProQuiz_classCorrect wpProQuiz_checkbox").insertBefore(this)}).remove()}d=void 0!=h[b]?h[b]:a.noop();a("."+b).show()});a('input[name="answerType"]:checked').click();
56
- a(".deleteAnswer").click(b.answerRemove);a(".addAnswer").click(function(){var c=a(this).siblings("ul"),d=c.find("li:eq(0)").clone();d.find(".wpProQuiz_checkbox").removeAttr("checked");d.find(".wpProQuiz_text").val("");d.find(".wpProQuiz_points").val(1);d.find(".deleteAnswer").click(b.answerRemove);d.find(".addMedia").click(b.addMediaClick);d.appendTo(c);return!1});a(".sort_answer ul, .classic_answer ul, .matrix_sort_answer ul").sortable({handle:".wpProQuiz_move"});a("#saveQuestion").click(function(){if(!b.globalValidate())return!1;
57
- b.generateArrayIndex();return!0});a(e).change(function(){c.displayChecked(this,a(".wpProQuiz_answerPoints"));c.displayChecked(this,a("#wpProQuiz_showPointsBox"));c.displayChecked(this,s,!1,!0);c.displayChecked(this,a('input[name="answerPointsDiffModusActivated"]'),!0,!0);this.checked?(a('input[name="answerPointsDiffModusActivated"]').change(),a('input[name="disableCorrect"]').change()):(a(".classic_answer .wpProQuiz_classCorrect").parent().parent().show(),a('input[name="disableCorrect"]').attr("disabled",
58
- "disabled"))}).change();a('select[name="category"]').change(function(){var b=a(this),c=a("#categoryAddBox").hide();"-1"==b.val()&&c.show()}).change();a("#categoryAddBtn").click(function(){b.addCategory()});a(".addMedia").click(b.addMediaClick);a('input[name="answerPointsDiffModusActivated"]').change(function(){c.displayChecked(this,a('input[name="disableCorrect"]'),!0,!0);this.checked?a('input[name="disableCorrect"]').change():a(".classic_answer .wpProQuiz_classCorrect").parent().parent().show()}).change();
59
- a('input[name="disableCorrect"]').change(function(){c.displayChecked(this,a(".classic_answer .wpProQuiz_classCorrect").parent().parent(),!0)}).change();a("#clickPointDia").click(function(){a(".pointDia").toggle("fast");return!1});a('input[name="template"]').click(function(d){if("0"==a('select[name="templateSaveList"]').val()&&c.isEmpty(a('input[name="templateName"]').val()))return alert(wpProQuizLocalize.temploate_no_name),d.preventDefault(),!1;b.generateArrayIndex()});a('select[name="templateSaveList"]').change(function(){var b=
60
- a('input[name="templateName"]');"0"==a(this).val()?b.show():b.hide()}).change()})()},h=function(){var b=this,d=a("#quizId").val(),f="users",e=a("#wpProQuiz_currentPage"),h=a("#wpProQuiz_pageLeft"),m=a("#wpProQuiz_pageRight"),k=a("#testSelect"),b={loadStatistic:function(a,b){c.ajaxPost("statisticLoad",{userId:a},function(a){})},loadUsersStatistic:function(){var e={userId:a("#userSelect").val(),quizId:d,testId:a("#testSelect").val()};b.toggleLoadBox(!1);c.ajaxPost("statisticLoad",e,function(c){a.each(c.question,
61
- function(){var c=a("#wpProQuiz_tr_"+this.questionId);b.setStatisticData(c,this)});a.each(c.category,function(c,d){var e=a("#wpProQuiz_ctr_"+c);b.setStatisticData(e,d)});a("#testSelect option:gt(0)").remove();var d=a("#testSelect");a.each(c.tests,function(){var b=a(document.createElement("option"));b.val(this.id);b.text(this.date);c.testId==this.id&&b.attr("selected",!0);d.append(b)});b.parseFormData(c.formData);b.toggleLoadBox(!0)})},loadUsersStatistic_:function(e,p){var f={userId:e,quizId:d,testId:p};
62
- b.toggleLoadBox(!1);c.ajaxPost("statisticLoad",f,function(c){a.each(c.question,function(){var c=a("#wpProQuiz_tr_"+this.questionId);b.setStatisticData(c,this)});a.each(c.category,function(c,d){var e=a("#wpProQuiz_ctr_"+c);b.setStatisticData(e,d)});a("#testSelect option:gt(0)").remove();var d=a("#testSelect");a.each(c.tests,function(){var b=a(document.createElement("option"));b.val(this.id);b.text(this.date);c.testId==this.id&&b.attr("selected",!0);d.append(b)});b.parseFormData(c.formData);a("#userSelect").val(e);
63
- a("#testSelect").val(p);b.toggleLoadBox(!0)})},parseFormData:function(b){var c=a("#wpProQuiz_form_box");null==b?c.hide():(a.each(b,function(b,c){a("#form_id_"+b).text(c)}),c.show())},setStatisticData:function(a,b){a.find(".wpProQuiz_cCorrect").text(b.correct);a.find(".wpProQuiz_cIncorrect").text(b.incorrect);a.find(".wpProQuiz_cTip").text(b.hint);a.find(".wpProQuiz_cPoints").text(b.points);a.find(".wpProQuiz_cResult").text(b.result);a.find(".wpProQuiz_cTime").text(b.questionTime);a.find(".wpProQuiz_cCreateTime").text(b.date)},
64
- toggleLoadBox:function(b){var c=a("#wpProQuiz_loadData"),d=a("#wpProQuiz_content");b?(c.hide(),d.show()):(d.hide(),c.show())},reset:function(e){var f=a("#userSelect").val();confirm(wpProQuizLocalize.reset_statistics_msg)&&(e={quizId:d,userId:f,testId:k.val(),type:e},b.toggleLoadBox(!1),c.ajaxPost("statisticReset",e,function(){b.loadUsersStatistic()}))},loadStatisticOverview:function(f){f={quizId:d,pageLimit:a("#wpProQuiz_pageLimit").val(),onlyCompleted:Number(a("#wpProQuiz_onlyCompleted").is(":checked")),
65
- page:e.val(),nav:Number(f)};b.toggleLoadBox(!1);c.ajaxPost("statisticLoadOverview",f,function(c){var d=a("#wpProQuiz_statistics_overview_data"),e=d.children(),f=e.first().clone();e.slice(1).remove();a.each(c.items,function(){var c=f.clone();b.setStatisticData(c,this);c.find("a").text(this.userName).data("userId",this.userId).click(function(){a("#userSelect").val(a(this).data("userId"));a("#wpProQuiz_typeUser").click();return!1});c.show().appendTo(d)});f.remove();b.toggleLoadBox(!0);void 0!=c.page&&
66
- b.handleNav(c.page)})},handleNav:function(c){for(var d=a("#wpProQuiz_currentPage").empty(),e=1;e<=c;e++)a(document.createElement("option")).val(e).text(e).appendTo(d);b.checkNavBar()},checkNavBar:function(){var a=e.val();1==a?h.hide():h.show();a==e.children().length?m.hide():m.show()},refresh:function(){"users"==f?b.loadUsersStatistic():"formOverview"==f?b.loadFormsOverview(!0):b.loadStatisticOverview(!0)},loadFormsOverview:function(e){e={quizId:d,pageLimit:a("#wpProQuiz_fromPageLimit").val(),onlyUser:a("#wpProQuiz_formUser").val(),
67
- page:a("#wpProQuiz_formCurrentPage").val(),nav:Number(e)};b.toggleLoadBox(!1);c.ajaxPost("statisticLoadFormOverview",e,function(c){var d=a("#wpProQuiz_statistics_form_data"),e=d.children(),f=e.first().clone();e.slice(1).remove();a.each(c.items,function(){var c=f.clone();b.setStatisticData(c,this);c.find("a").text(this.userName).data("userId",this.userId).data("testId",this.testId).click(function(){b.switchTabOnLoad("users");b.loadUsersStatistic_(a(this).data("userId"),a(this).data("testId"));return!1});
68
- c.show().appendTo(d)});f.remove();b.toggleLoadBox(!0);void 0!=c.page&&b.handleFormNav(c.page)})},handleFormNav:function(c){for(var d=a("#wpProQuiz_formCurrentPage").empty(),e=1;e<=c;e++)a(document.createElement("option")).val(e).text(e).appendTo(d);b.checkFormNavBar()},checkFormNavBar:function(){var b=a("#wpProQuiz_formCurrentPage").val();1==b?a("#wpProQuiz_formPageLeft").hide():a("#wpProQuiz_formPageLeft").show();b==a("#wpProQuiz_formCurrentPage").children().length?a("#wpProQuiz_formPageRight").hide():
69
- a("#wpProQuiz_formPageRight").show()},switchTabOnLoad:function(b){a(".wpProQuiz_tab").removeClass("button-primary").addClass("button-secondary");a(".wpProQuiz_tabContent").hide();var c=a("#wpProQuiz_typeOverview");"users"==b?(f="users",a("#wpProQuiz_tabUsers").show(),c=a("#wpProQuiz_typeUser")):"formOverview"==b?(f="formOverview",a("#wpProQuiz_tabFormOverview").show(),c=a("#wpProQuiz_typeForm")):(f="overview",a("#wpProQuiz_tabOverview").show());c.removeClass("button-secondary").addClass("button-primary")}};
70
- (function(){a("#userSelect, #testSelect").change(function(){b.loadUsersStatistic()});a(".wpProQuiz_update").click(function(){b.refresh()});a("#wpProQuiz_reset").click(function(){b.reset(0)});a("#wpProQuiz_resetUser").click(function(){b.reset(1)});a(".wpProQuiz_resetComplete").click(function(){b.reset(2)});a(".wpProQuiz_tab").click(function(){var c=a(this);a(".wpProQuiz_tab").removeClass("button-primary").addClass("button-secondary");c.removeClass("button-secondary").addClass("button-primary");a(".wpProQuiz_tabContent").hide();
71
- "wpProQuiz_typeUser"==c.attr("id")?(f="users",a("#wpProQuiz_tabUsers").show(),b.loadUsersStatistic()):"wpProQuiz_typeForm"==c.attr("id")?(f="formOverview",a("#wpProQuiz_tabFormOverview").show(),b.loadFormsOverview(!0)):(f="overview",a("#wpProQuiz_tabOverview").show(),b.loadStatisticOverview(!0));return!1});a("#wpProQuiz_onlyCompleted").change(function(){e.val(1);b.loadStatisticOverview(!0)});a("#wpProQuiz_pageLimit").change(function(){e.val(1);b.loadStatisticOverview(!0)});h.click(function(){e.val(Number(e.val())-
72
- 1);b.loadStatisticOverview(!1);b.checkNavBar()});m.click(function(){e.val(Number(e.val())+1);b.loadStatisticOverview(!1);b.checkNavBar()});e.change(function(){b.loadStatisticOverview(!1);b.checkNavBar()});a("#wpProQuiz_formUser, #wpProQuiz_fromPageLimit").change(function(){a("#wpProQuiz_formCurrentPage").val(1);b.loadFormsOverview(!0)});a("#wpProQuiz_formPageLeft").click(function(){a("#wpProQuiz_formCurrentPage").val(Number(e.val())-1);b.loadFormsOverview(!1);b.checkFormNavBar()});a("#wpProQuiz_formPageRight").click(function(){a("#wpProQuiz_formCurrentPage").val(Number(e.val())+
73
- 1);b.loadFormsOverview(!1);b.checkFormNavBar()});a("#wpProQuiz_formCurrentPage").change(function(){b.loadFormsOverview(!1);b.checkFormNavBar()});b.loadUsersStatistic()})()},n=function(){var b=a("#quizId").val(),d=null,f=null,e={data:{quizId:b,users:-1,pageLimit:100,dateFrom:0,dateTo:0,generateNav:0},changeFilter:function(){var b=function(a){a=a.datepicker("getDate");return null===a?0:a.getTime()/1E3};a.extend(this.data,{users:a("#wpProQuiz_historyUser").val(),pageLimit:a("#wpProQuiz_historyPageLimit").val(),
74
- dateFrom:b(a("#datepickerFrom")),dateTo:b(a("#datepickerTo")),generateNav:1});return this.data}},h={data:{pageLimit:100,onlyCompleted:0,generateNav:0,quizId:b},changeFilter:function(){a.extend(this.data,{pageLimit:a("#wpProQuiz_overviewPageLimit").val(),onlyCompleted:Number(a("#wpProQuiz_overviewOnlyCompleted").is(":checked")),generateNav:1})}},m={deleteUserStatistic:function(d,f){if(!confirm(wpProQuizLocalize.reset_statistics_msg))return!1;c.ajaxPost("statisticResetNew",{refId:d,userId:f,quizId:b,
75
- type:0},function(){a("#wpProQuiz_user_overlay").hide();e.changeFilter();k.loadHistoryAjax();h.changeFilter();k.loadOverviewAjax()})},deleteAll:function(){if(!confirm(wpProQuizLocalize.reset_statistics_msg))return!1;c.ajaxPost("statisticResetNew",{quizId:b,type:1},function(){e.changeFilter();k.loadHistoryAjax();h.changeFilter();k.loadOverviewAjax()})}},k={loadHistoryAjax:function(){var b=a.extend({page:e.data.generateNav?1:d.getCurrentPage()},e.data);k.loadBox(!0);var g=a("#wpProQuiz_historyLoadContext").hide();
76
- c.ajaxPost("statisticLoadHistory",b,function(b){g.html(b.html).show();b.navi&&d.setNumPage(b.navi);e.data.generateNav=0;g.find(".user_statistic").click(function(){k.loadUserAjax(0,a(this).data("ref_id"),!1);return!1});g.find(".wpProQuiz_delete").click(function(){m.deleteUserStatistic(a(this).parents("tr").find(".user_statistic").data("ref_id"),0);return!1});k.loadBox(!1)})},loadUserAjax:function(d,e,f){a("#wpProQuiz_user_overlay, #wpProQuiz_loadUserData").show();var h=a("#wpProQuiz_user_content").hide();
77
- c.ajaxPost("statisticLoadUser",{quizId:b,userId:d,refId:e,avg:Number(f)},function(b){h.html(b.html);h.find(".wpProQuiz_update").click(function(){k.loadUserAjax(d,e,f);return!1});h.find("#wpProQuiz_resetUserStatistic").click(function(){m.deleteUserStatistic(e,d)});h.find(".statistic_data").click(function(){a(this).parents("tr").next().toggle("fast");return!1});a("#wpProQuiz_loadUserData").hide();h.show()})},loadBox:function(b,c){b?a("#wpProQuiz_loadDataHistory").show():a("#wpProQuiz_loadDataHistory").hide()},
78
- loadOverviewAjax:function(){var b=a.extend({page:h.data.generateNav?1:f.getCurrentPage()},h.data);a("#wpProQuiz_loadDataOverview").show();var d=a("#wpProQuiz_overviewLoadContext").hide();c.ajaxPost("statisticLoadOverviewNew",b,function(b){d.html(b.html).show();b.navi&&f.setNumPage(b.navi);h.data.generateNav=0;d.find(".user_statistic").click(function(){k.loadUserAjax(a(this).data("user_id"),0,!0);return!1});d.find(".wpProQuiz_delete").click(function(){m.deleteUserStatistic(0,a(this).parents("tr").find(".user_statistic").data("user_id"));
79
- return!1});a("#wpProQuiz_loadDataOverview").hide()})}};(function(){d=new r(a("#historyNavigation"),{onChange:function(){k.loadHistoryAjax()}});f=new r(a("#overviewNavigation"),{onChange:function(){k.loadOverviewAjax()}});a("#datepickerFrom").datepicker({closeText:wpProQuizLocalize.closeText,currentText:wpProQuizLocalize.currentText,monthNames:wpProQuizLocalize.monthNames,monthNamesShort:wpProQuizLocalize.monthNamesShort,dayNames:wpProQuizLocalize.dayNames,dayNamesShort:wpProQuizLocalize.dayNamesShort,
80
- dayNamesMin:wpProQuizLocalize.dayNamesMin,dateFormat:wpProQuizLocalize.dateFormat,firstDay:wpProQuizLocalize.firstDay,changeMonth:!0,onClose:function(b){a("#datepickerTo").datepicker("option","minDate",b)}});a("#datepickerTo").datepicker({closeText:wpProQuizLocalize.closeText,currentText:wpProQuizLocalize.currentText,monthNames:wpProQuizLocalize.monthNames,monthNamesShort:wpProQuizLocalize.monthNamesShort,dayNames:wpProQuizLocalize.dayNames,dayNamesShort:wpProQuizLocalize.dayNamesShort,dayNamesMin:wpProQuizLocalize.dayNamesMin,
81
- dateFormat:wpProQuizLocalize.dateFormat,firstDay:wpProQuizLocalize.firstDay,changeMonth:!0,onClose:function(b){a("#datepickerFrom").datepicker("option","maxDate",b)}});a("#filter").click(function(){e.changeFilter();k.loadHistoryAjax()});a("#wpProQuiz_overlay_close").click(function(){a("#wpProQuiz_user_overlay").hide()});a("#wpProQuiz_tabHistory .wpProQuiz_update").click(function(){e.changeFilter();k.loadHistoryAjax();return!1});a("#wpProQuiz_tabOverview .wpProQuiz_update").click(function(){h.changeFilter();
82
- k.loadOverviewAjax();return!1});a(".wpProQuiz_resetComplete").click(function(){m.deleteAll();return!1});a("#overviewFilter").click(function(){h.changeFilter();k.loadOverviewAjax()});e.changeFilter();k.loadHistoryAjax();h.changeFilter();k.loadOverviewAjax()})()};(function(){f();var c=a.noop;a(".wpProQuiz_questionEdit").length?c=b:a(".wpProQuiz_globalSettings").length?c=d:a(".wpProQuiz_statistics").length?c=h:a(".wpProQuiz_statisticsNew").length&&(c=n);c();a(".wpProQuiz_demoImgBox a").mouseover(function(b){var c=
83
- a(this),d=a(document).width(),c=c.siblings().outerWidth(!0);b.pageX+c>d&&(b=d-(b.pageX+c+30),a(this).next().css("left",b+"px"));a(this).next().show()}).mouseout(function(){a(this).next().hide()}).click(function(){return!1})})()})()});
1
+ jQuery(document).ready(function(e){function t(){var t=this;t={displayChecked:function(e,t,i,a){var n=i?!e.checked:e.checked;a?n?t.attr("disabled","disabled"):t.removeAttr("disabled"):n?t.show():t.hide()},isEmpty:function(t){return t=e.trim(t),!t||0===t.length},isNumber:function(i){return i=e.trim(i),!t.isEmpty(i)&&!isNaN(i)},getMceContent:function(t){var i=tinymce.editors[t];return void 0==i||i.isHidden()?e("#"+t).val():i.getContent()},ajaxPost:function(t,i,a){var n={action:"wp_pro_quiz_admin_ajax",func:t,data:i};e.post(ajaxurl,n,a,"json")}};var a=function(){e(".wpProQuiz_tab_wrapper a").click(function(){var t=e(this),i=t.data("tab"),a=t.siblings(".button-primary").removeClass("button-primary").addClass("button-secondary");return t.removeClass("button-secondary").addClass("button-primary"),e(a.data("tab")).hide("fast"),e(i).show("fast"),e(document).trigger({type:"changeTab",tabId:i}),!1})},n={gobalSettings:function(){var i={categoryDelete:function(i,a){var n={categoryId:i};t.ajaxPost("categoryDelete",n,function(t){t.err||(e('select[name="category'+a+'"] option[value="'+i+'"]').remove(),e('select[name="category'+a+'"]').change())})},categoryEdit:function(i,a,n){var o={categoryId:i,categoryName:e.trim(a)};return t.isEmpty(a)?void alert(wpProQuizLocalize.category_no_name):void t.ajaxPost("categoryEdit",o,function(t){t.err||(e('select[name="category'+n+'"] option[value="'+i+'"]').text(o.categoryName),e('select[name="category'+n+'"]').change())})},changeTimeFormat:function(t,i){"0"!=i.val()&&e('input[name="'+t+'"]').val(i.val())},templateDelete:function(i,a){var n={templateId:i,type:a};t.ajaxPost("templateDelete",n,function(t){t.err||(a?(e('select[name="templateQuestion"] option[value="'+i+'"]').remove(),e('select[name="templateQuestion"]').change()):(e('select[name="templateQuiz"] option[value="'+i+'"]').remove(),e('select[name="templateQuiz"]').change()))})},templateEdit:function(i,a,n){if(t.isEmpty(a))return void alert(wpProQuizLocalize.category_no_name);var o={templateId:i,name:e.trim(a),type:n};t.ajaxPost("templateEdit",o,function(t){t.err||(n?(e('select[name="templateQuestion"] option[value="'+i+'"]').text(o.name),e('select[name="templateQuestion"]').change()):(e('select[name="templateQuiz"] option[value="'+i+'"]').text(o.name),e('select[name="templateQuiz"]').change()))})}},a=function(){e('select[name="category"]').change(function(){e('input[name="categoryEditText"]').val(e(this).find(":selected").text())}).change(),e('input[name="categoryDelete"]').click(function(){var t=e('select[name="category"] option:selected').val();i.categoryDelete(t,"")}),e('input[name="categoryEdit"]').click(function(){var t=e('select[name="category"] option:selected').val(),a=e('input[name="categoryEditText"]').val();i.categoryEdit(t,a,"")}),e('select[name="categoryQuiz"]').change(function(){e('input[name="categoryQuizEditText"]').val(e(this).find(":selected").text())}).change(),e('input[name="categoryQuizDelete"]').click(function(){var t=e('select[name="categoryQuiz"] option:selected').val();i.categoryDelete(t,"Quiz")}),e('input[name="categoryQuizEdit"]').click(function(){var t=e('select[name="categoryQuiz"] option:selected').val(),a=e('input[name="categoryQuizEditText"]').val();i.categoryEdit(t,a,"Quiz")}),e("#statistic_time_format_select").change(function(){i.changeTimeFormat("statisticTimeFormat",e(this))}),e(document).bind("changeTab",function(t){switch(e("#problemInfo").hide("fast"),t.tabId){case"#problemContent":e("#problemInfo").show("fast");break;case"#emailSettingsTab":}}),e('input[name="email[html]"]').change(function(){return void 0==switchEditors?!1:void(this.checked?switchEditors.go("adminEmailEditor","tmce"):switchEditors.go("adminEmailEditor","html"))}).change(),e('input[name="userEmail[html]"]').change(function(){return void 0==switchEditors?!1:void(this.checked?switchEditors.go("userEmailEditor","tmce"):switchEditors.go("userEmailEditor","html"))}).change(),e('select[name="templateQuiz"]').change(function(){e('input[name="templateQuizEditText"]').val(e(this).find(":selected").text())}).change(),e('select[name="templateQuestion"]').change(function(){e('input[name="templateQuestionEditText"]').val(e(this).find(":selected").text())}).change(),e('input[name="templateQuizDelete"]').click(function(){var t=e('select[name="templateQuiz"] option:selected').val();i.templateDelete(t,0)}),e('input[name="templateQuestionDelete"]').click(function(){var t=e('select[name="templateQuestion"] option:selected').val();i.templateDelete(t,1)}),e('input[name="templateQuizEdit"]').click(function(){var t=e('select[name="templateQuiz"] option:selected').val(),a=e('input[name="templateQuizEditText"]').val();i.templateEdit(t,a,0)}),e('input[name="templateQuestionEdit"]').click(function(){var t=e('select[name="templateQuestion"] option:selected').val(),a=e('input[name="templateQuestionEditText"]').val();i.templateEdit(t,a,1)})};a()},questionEdit:function(){var i=this,a=e.noop(),n={answerChildren:e(".answer_felder > div"),pointsModus:e('input[name="answerPointsActivated"]'),gPoints:e('input[name="points"]')};i={generateArrayIndex:function(){var t=e('input[name="answerType"]:checked').val();t="single"==t||"multiple"==t?"classic_answer":t,e(".answerList").each(function(){var i=e(this).parent().attr("class");e(this).children().each(function(a,n){e(this).find('[name^="answerData"]').each(function(){var e=this.name,n=e.search(/\](\[\w+\])+$/),o=t==i?a:"none";n>0&&(this.name="answerData["+o+e.substring(n,e.length))})})})},globalValidate:function(){if(t.isEmpty(t.getMceContent("question")))return alert(wpProQuizLocalize.no_question_msg),!1;if(n.pointsModus.is(":checked")){if("free_answer"==e('input[name="answerType"]:checked').val())return alert(wpProQuizLocalize.dif_points),!1}else{var i=n.gPoints.val();if(!t.isNumber(i)||1>i)return alert(wpProQuizLocalize.no_nummber_points),!1}return a()===!1?!1:!0},answerRemove:function(){var t=e(this).parent();return t.parent().children().length<2?!1:(t.remove(),!1)},addCategory:function(){var i=e.trim(e('input[name="categoryAdd"]').val());if(!t.isEmpty(i)){var a={categoryName:i};t.ajaxPost("categoryAdd",a,function(t){if(t.err)return void e("#categoryMsgBox").text(t.err).show("fast").delay(2e3).hide("fast");var i=e(document.createElement("option")).val(t.categoryId).text(t.categoryName).attr("selected","selected");e('select[name="category"]').append(i).change()})}},addMediaClick:function(){if("function"!=typeof tb_show)return!1;var t=e(this).closest("li"),i=t.find('input[name="answerData[][html]"]:eq(0)'),a=t.find(".wpProQuiz_text:eq(0)");window.org_send_to_editor=window.send_to_editor;var n=tb_remove;window.send_to_editor=function(t){var n=e("img",t)[0].outerHTML;a.val(a.val()+n),i.attr("checked",!0),tb_remove(),window.send_to_editor=window.org_send_to_editor},window.tb_remove=function(){window.send_to_editor=window.org_send_to_editor,tb_remove=n,tb_remove()},tb_show("","media-upload.php?type=image&TB_iframe=true")}};var o={classic_answer:function(){var i=0,a=0,o=0;return e(".classic_answer .answerList").children().each(function(){var n=e(this);if(!t.isEmpty(n.find('textarea[name="answerData[][answer]"]').val())){i++,n.find('input[name="answerData[][correct]"]:checked').length&&a++;var r=n.find('input[name="answerData[][points]"]').val();t.isNumber(r)&&r>=0&&o++}}),i?a||e('input[name="disableCorrect"]').is(":checked")&&e('input[name="answerPointsDiffModusActivated"]').is(":checked")&&e('input[name="answerPointsActivated"]').is(":checked")&&"single"==e('input[name="answerType"]:checked').val()?o!=i&&n.pointsModus.is(":checked")?(alert(wpProQuizLocalize.no_nummber_points_new),!1):!0:(alert(wpProQuizLocalize.no_correct_msg),!1):(alert(wpProQuizLocalize.no_answer_msg),!1)},free_answer:function(){return t.isEmpty(e('.free_answer textarea[name="answerData[][answer]"]').val())?(alert(wpProQuizLocalize.no_answer_msg),!1):!0},cloze_answer:function(){return t.isEmpty(t.getMceContent("cloze"))?(alert(wpProQuizLocalize.no_answer_msg),!1):!0},sort_answer:function(){var i=0,a=0;return e(".sort_answer .answerList").children().each(function(){var n=e(this);if(!t.isEmpty(n.find('textarea[name="answerData[][answer]"]').val())){i++;var o=n.find('input[name="answerData[][points]"]').val();t.isNumber(o)&&o>=0&&a++}}),i?a!=i&&n.pointsModus.is(":checked")?(alert(wpProQuizLocalize.no_nummber_points_new),!1):!0:(alert(wpProQuizLocalize.no_answer_msg),!1)},matrix_sort_answer:function(){var i=0,a=0,o=!0,r=0;return e(".matrix_sort_answer .answerList").children().each(function(){var n=e(this),c=n.find('input[name="answerData[][points]"]').val();t.isEmpty(n.find('textarea[name="answerData[][answer]"]').val())?t.isEmpty(n.find('textarea[name="answerData[][sort_string]"]').val())||(r++,t.isNumber(c)&&c>=0&&a++):(i++,r++,t.isEmpty(n.find('textarea[name="answerData[][sort_string]"]').val())&&(o=!1),t.isNumber(c)&&c>=0&&a++)}),i?o?a!=r&&n.pointsModus.is(":checked")?(alert(wpProQuizLocalize.no_nummber_points_new),!1):!0:(alert(wpProQuizLocalize.no_sort_element_criterion),!1):(alert(wpProQuizLocalize.no_answer_msg),!1)},assessment_answer:function(){return t.isEmpty(t.getMceContent("assessment"))?(alert(wpProQuizLocalize.no_answer_msg),!1):!0}},r=function(){e("#wpProQuiz_tip").change(function(){t.displayChecked(this,e("#wpProQuiz_tipBox"))}).change(),e("#wpProQuiz_correctSameText").change(function(){t.displayChecked(this,e("#wpProQuiz_incorrectMassageBox"),!0)}).change(),e('input[name="answerType"]').click(function(){n.answerChildren.hide();var t=this.value;if("single"==t?(e("#singleChoiceOptions").show(),e('input[name="disableCorrect"]').change()):(e("#singleChoiceOptions").hide(),e(".classic_answer .wpProQuiz_classCorrect").parent().parent().show()),"single"==t||"multiple"==t){var i="single"==t?"radio":"checkbox";t="classic_answer",e(".wpProQuiz_classCorrect").each(function(){e("<input type="+i+" />").attr({name:this.name,value:this.value,checked:this.checked}).addClass("wpProQuiz_classCorrect wpProQuiz_checkbox").insertBefore(this)}).remove()}a=void 0!=o[t]?o[t]:e.noop(),e("."+t).show()}),e('input[name="answerType"]:checked').click(),e(".deleteAnswer").click(i.answerRemove),e(".addAnswer").click(function(){var t=e(this).siblings("ul"),a=t.find("li:eq(0)").clone();return a.find(".wpProQuiz_checkbox").removeAttr("checked"),a.find(".wpProQuiz_text").val(""),a.find(".wpProQuiz_points").val(1),a.find(".deleteAnswer").click(i.answerRemove),a.find(".addMedia").click(i.addMediaClick),a.appendTo(t),!1}),e(".sort_answer ul, .classic_answer ul, .matrix_sort_answer ul").sortable({handle:".wpProQuiz_move"}),e("#saveQuestion").click(function(){return i.globalValidate()?(i.generateArrayIndex(),!0):!1}),e(n.pointsModus).change(function(){t.displayChecked(this,e(".wpProQuiz_answerPoints")),t.displayChecked(this,e("#wpProQuiz_showPointsBox")),t.displayChecked(this,n.gPoints,!1,!0),t.displayChecked(this,e('input[name="answerPointsDiffModusActivated"]'),!0,!0),this.checked?(e('input[name="answerPointsDiffModusActivated"]').change(),e('input[name="disableCorrect"]').change()):(e(".classic_answer .wpProQuiz_classCorrect").parent().parent().show(),e('input[name="disableCorrect"]').attr("disabled","disabled"))}).change(),e('select[name="category"]').change(function(){var t=e(this),i=e("#categoryAddBox").hide();"-1"==t.val()&&i.show()}).change(),e("#categoryAddBtn").click(function(){i.addCategory()}),e(".addMedia").click(i.addMediaClick),e('input[name="answerPointsDiffModusActivated"]').change(function(){t.displayChecked(this,e('input[name="disableCorrect"]'),!0,!0),this.checked?e('input[name="disableCorrect"]').change():e(".classic_answer .wpProQuiz_classCorrect").parent().parent().show()}).change(),e('input[name="disableCorrect"]').change(function(){t.displayChecked(this,e(".classic_answer .wpProQuiz_classCorrect").parent().parent(),!0)}).change(),e("#clickPointDia").click(function(){return e(".pointDia").toggle("fast"),!1}),e('input[name="template"]').click(function(a){return"0"==e('select[name="templateSaveList"]').val()&&t.isEmpty(e('input[name="templateName"]').val())?(alert(wpProQuizLocalize.temploate_no_name),a.preventDefault(),!1):void i.generateArrayIndex()}),e('select[name="templateSaveList"]').change(function(){var t=e('input[name="templateName"]');"0"==e(this).val()?t.show():t.hide()}).change()},c=function(){n.answerChildren.hide(),r()};c()},statistic:function(){var i=this,a=e("#quizId").val(),n="users",o={currentPage:e("#wpProQuiz_currentPage"),pageLeft:e("#wpProQuiz_pageLeft"),pageRight:e("#wpProQuiz_pageRight"),testSelect:e("#testSelect")};i={loadStatistic:function(e,i){var a={userId:e};t.ajaxPost("statisticLoad",a,function(e){})},loadUsersStatistic:function(){},loadUsersStatistic_:function(n,o){var r={userId:n,quizId:a,testId:o};i.toggleLoadBox(!1),t.ajaxPost("statisticLoad",r,function(t){e.each(t.question,function(){var t=e("#wpProQuiz_tr_"+this.questionId);i.setStatisticData(t,this)}),e.each(t.category,function(t,a){var n=e("#wpProQuiz_ctr_"+t);i.setStatisticData(n,a)}),e("#testSelect option:gt(0)").remove();var a=e("#testSelect");e.each(t.tests,function(){var i=e(document.createElement("option"));i.val(this.id),i.text(this.date),t.testId==this.id&&i.attr("selected",!0),a.append(i)}),i.parseFormData(t.formData),e("#userSelect").val(n),e("#testSelect").val(o),i.toggleLoadBox(!0)})},parseFormData:function(t){var i=e("#wpProQuiz_form_box");return null==t?void i.hide():(e.each(t,function(t,i){e("#form_id_"+t).text(i)}),void i.show())},setStatisticData:function(e,t){e.find(".wpProQuiz_cCorrect").text(t.correct),e.find(".wpProQuiz_cIncorrect").text(t.incorrect),e.find(".wpProQuiz_cTip").text(t.hint),e.find(".wpProQuiz_cPoints").text(t.points),e.find(".wpProQuiz_cResult").text(t.result),e.find(".wpProQuiz_cTime").text(t.questionTime),e.find(".wpProQuiz_cCreateTime").text(t.date)},toggleLoadBox:function(t){var i=e("#wpProQuiz_loadData"),a=e("#wpProQuiz_content");t?(i.hide(),a.show()):(a.hide(),i.show())},reset:function(n){var r=e("#userSelect").val();if(confirm(wpProQuizLocalize.reset_statistics_msg)){var c={quizId:a,userId:r,testId:o.testSelect.val(),type:n};i.toggleLoadBox(!1),t.ajaxPost("statisticReset",c,function(){i.loadUsersStatistic()})}},loadStatisticOverview:function(n){var r={quizId:a,pageLimit:e("#wpProQuiz_pageLimit").val(),onlyCompleted:Number(e("#wpProQuiz_onlyCompleted").is(":checked")),page:o.currentPage.val(),nav:Number(n)};i.toggleLoadBox(!1),t.ajaxPost("statisticLoadOverview",r,function(t){var a=e("#wpProQuiz_statistics_overview_data"),n=a.children(),o=n.first().clone();n.slice(1).remove(),e.each(t.items,function(){var t=o.clone();i.setStatisticData(t,this),t.find("a").text(this.userName).data("userId",this.userId).click(function(){return e("#userSelect").val(e(this).data("userId")),e("#wpProQuiz_typeUser").click(),!1}),t.show().appendTo(a)}),o.remove(),i.toggleLoadBox(!0),void 0!=t.page&&i.handleNav(t.page)})},handleNav:function(t){for(var a=e("#wpProQuiz_currentPage").empty(),n=1;t>=n;n++)e(document.createElement("option")).val(n).text(n).appendTo(a);i.checkNavBar()},checkNavBar:function(){var e=o.currentPage.val();1==e?o.pageLeft.hide():o.pageLeft.show(),e==o.currentPage.children().length?o.pageRight.hide():o.pageRight.show()},refresh:function(){"users"==n?i.loadUsersStatistic():"formOverview"==n?i.loadFormsOverview(!0):i.loadStatisticOverview(!0)},loadFormsOverview:function(n){var o={quizId:a,pageLimit:e("#wpProQuiz_fromPageLimit").val(),onlyUser:e("#wpProQuiz_formUser").val(),page:e("#wpProQuiz_formCurrentPage").val(),nav:Number(n)};i.toggleLoadBox(!1),t.ajaxPost("statisticLoadFormOverview",o,function(t){var a=e("#wpProQuiz_statistics_form_data"),n=a.children(),o=n.first().clone();n.slice(1).remove(),e.each(t.items,function(){var t=o.clone();i.setStatisticData(t,this),t.find("a").text(this.userName).data("userId",this.userId).data("testId",this.testId).click(function(){return i.switchTabOnLoad("users"),i.loadUsersStatistic_(e(this).data("userId"),e(this).data("testId")),!1}),t.show().appendTo(a)}),o.remove(),i.toggleLoadBox(!0),void 0!=t.page&&i.handleFormNav(t.page)})},handleFormNav:function(t){for(var a=e("#wpProQuiz_formCurrentPage").empty(),n=1;t>=n;n++)e(document.createElement("option")).val(n).text(n).appendTo(a);i.checkFormNavBar()},checkFormNavBar:function(){var t=e("#wpProQuiz_formCurrentPage").val();1==t?e("#wpProQuiz_formPageLeft").hide():e("#wpProQuiz_formPageLeft").show(),t==e("#wpProQuiz_formCurrentPage").children().length?e("#wpProQuiz_formPageRight").hide():e("#wpProQuiz_formPageRight").show()},switchTabOnLoad:function(t){e(".wpProQuiz_tab").removeClass("button-primary").addClass("button-secondary"),e(".wpProQuiz_tabContent").hide();var i=e("#wpProQuiz_typeOverview");"users"==t?(n="users",e("#wpProQuiz_tabUsers").show(),i=e("#wpProQuiz_typeUser")):"formOverview"==t?(n="formOverview",e("#wpProQuiz_tabFormOverview").show(),i=e("#wpProQuiz_typeForm")):(n="overview",e("#wpProQuiz_tabOverview").show()),i.removeClass("button-secondary").addClass("button-primary")}};var r=function(){e("#userSelect, #testSelect").change(function(){i.loadUsersStatistic()}),e(".wpProQuiz_update").click(function(){i.refresh()}),e("#wpProQuiz_reset").click(function(){i.reset(0)}),e("#wpProQuiz_resetUser").click(function(){i.reset(1)}),e(".wpProQuiz_resetComplete").click(function(){i.reset(2)}),e(".wpProQuiz_tab").click(function(){var t=e(this);return e(".wpProQuiz_tab").removeClass("button-primary").addClass("button-secondary"),t.removeClass("button-secondary").addClass("button-primary"),e(".wpProQuiz_tabContent").hide(),"wpProQuiz_typeUser"==t.attr("id")?(n="users",e("#wpProQuiz_tabUsers").show(),i.loadUsersStatistic()):"wpProQuiz_typeForm"==t.attr("id")?(n="formOverview",e("#wpProQuiz_tabFormOverview").show(),i.loadFormsOverview(!0)):(n="overview",e("#wpProQuiz_tabOverview").show(),i.loadStatisticOverview(!0)),!1}),e("#wpProQuiz_onlyCompleted").change(function(){o.currentPage.val(1),i.loadStatisticOverview(!0)}),e("#wpProQuiz_pageLimit").change(function(){o.currentPage.val(1),i.loadStatisticOverview(!0)}),o.pageLeft.click(function(){o.currentPage.val(Number(o.currentPage.val())-1),i.loadStatisticOverview(!1),i.checkNavBar()}),o.pageRight.click(function(){o.currentPage.val(Number(o.currentPage.val())+1),i.loadStatisticOverview(!1),i.checkNavBar()}),o.currentPage.change(function(){i.loadStatisticOverview(!1),i.checkNavBar()}),e("#wpProQuiz_formUser, #wpProQuiz_fromPageLimit").change(function(){e("#wpProQuiz_formCurrentPage").val(1),i.loadFormsOverview(!0)}),e("#wpProQuiz_formPageLeft").click(function(){e("#wpProQuiz_formCurrentPage").val(Number(o.currentPage.val())-1),i.loadFormsOverview(!1),i.checkFormNavBar()}),e("#wpProQuiz_formPageRight").click(function(){e("#wpProQuiz_formCurrentPage").val(Number(o.currentPage.val())+1),i.loadFormsOverview(!1),i.checkFormNavBar()}),e("#wpProQuiz_formCurrentPage").change(function(){i.loadFormsOverview(!1),i.checkFormNavBar()}),i.loadUsersStatistic()};r()},statisticNew:function(){var a=e("#quizId").val(),n=null,o=null,r={data:{quizId:a,users:-1,pageLimit:100,dateFrom:0,dateTo:0,generateNav:0},changeFilter:function(){var t=function(e){var t=e.datepicker("getDate");return null===t?0:t.getTime()/1e3};return e.extend(this.data,{users:e("#wpProQuiz_historyUser").val(),pageLimit:e("#wpProQuiz_historyPageLimit").val(),dateFrom:t(e("#datepickerFrom")),dateTo:t(e("#datepickerTo")),generateNav:1}),this.data}},c={data:{pageLimit:100,onlyCompleted:0,generateNav:0,quizId:a},changeFilter:function(){e.extend(this.data,{pageLimit:e("#wpProQuiz_overviewPageLimit").val(),onlyCompleted:Number(e("#wpProQuiz_overviewOnlyCompleted").is(":checked")),generateNav:1})}},s={deleteUserStatistic:function(i,n){if(!confirm(wpProQuizLocalize.reset_statistics_msg))return!1;var o={refId:i,userId:n,quizId:a,type:0};t.ajaxPost("statisticResetNew",o,function(){e("#wpProQuiz_user_overlay").hide(),r.changeFilter(),u.loadHistoryAjax(),c.changeFilter(),u.loadOverviewAjax()})},deleteAll:function(){if(!confirm(wpProQuizLocalize.reset_statistics_msg))return!1;var e={quizId:a,type:1};t.ajaxPost("statisticResetNew",e,function(){r.changeFilter(),u.loadHistoryAjax(),c.changeFilter(),u.loadOverviewAjax()})}},u={loadHistoryAjax:function(){var i=e.extend({page:r.data.generateNav?1:n.getCurrentPage()},r.data);u.loadBox(!0);var a=e("#wpProQuiz_historyLoadContext").hide();t.ajaxPost("statisticLoadHistory",i,function(t){a.html(t.html).show(),t.navi&&n.setNumPage(t.navi),r.data.generateNav=0,a.find(".user_statistic").click(function(){return u.loadUserAjax(0,e(this).data("ref_id"),!1),!1}),a.find(".wpProQuiz_delete").click(function(){return s.deleteUserStatistic(e(this).parents("tr").find(".user_statistic").data("ref_id"),0),!1}),u.loadBox(!1)})},loadUserAjax:function(i,n,o){e("#wpProQuiz_user_overlay, #wpProQuiz_loadUserData").show();var r=e("#wpProQuiz_user_content").hide(),c={quizId:a,userId:i,refId:n,avg:Number(o)};t.ajaxPost("statisticLoadUser",c,function(t){r.html(t.html),r.find(".wpProQuiz_update").click(function(){return u.loadUserAjax(i,n,o),!1}),r.find("#wpProQuiz_resetUserStatistic").click(function(){s.deleteUserStatistic(n,i)}),r.find(".statistic_data").click(function(){return e(this).parents("tr").next().toggle("fast"),!1}),e("#wpProQuiz_loadUserData").hide(),r.show()})},loadBox:function(t,i){t?e("#wpProQuiz_loadDataHistory").show():e("#wpProQuiz_loadDataHistory").hide()},loadOverviewAjax:function(){var i=e.extend({page:c.data.generateNav?1:o.getCurrentPage()},c.data);e("#wpProQuiz_loadDataOverview").show();var a=e("#wpProQuiz_overviewLoadContext").hide();t.ajaxPost("statisticLoadOverviewNew",i,function(t){a.html(t.html).show(),t.navi&&o.setNumPage(t.navi),c.data.generateNav=0,a.find(".user_statistic").click(function(){return u.loadUserAjax(e(this).data("user_id"),0,!0),!1}),a.find(".wpProQuiz_delete").click(function(){return s.deleteUserStatistic(0,e(this).parents("tr").find(".user_statistic").data("user_id")),!1}),e("#wpProQuiz_loadDataOverview").hide()})}},l=function(){n=new i(e("#historyNavigation"),{onChange:function(){u.loadHistoryAjax()}}),o=new i(e("#overviewNavigation"),{onChange:function(){u.loadOverviewAjax()}}),e("#datepickerFrom").datepicker({closeText:wpProQuizLocalize.closeText,currentText:wpProQuizLocalize.currentText,monthNames:wpProQuizLocalize.monthNames,monthNamesShort:wpProQuizLocalize.monthNamesShort,dayNames:wpProQuizLocalize.dayNames,dayNamesShort:wpProQuizLocalize.dayNamesShort,dayNamesMin:wpProQuizLocalize.dayNamesMin,dateFormat:wpProQuizLocalize.dateFormat,firstDay:wpProQuizLocalize.firstDay,changeMonth:!0,onClose:function(t){e("#datepickerTo").datepicker("option","minDate",t)}}),e("#datepickerTo").datepicker({closeText:wpProQuizLocalize.closeText,currentText:wpProQuizLocalize.currentText,monthNames:wpProQuizLocalize.monthNames,monthNamesShort:wpProQuizLocalize.monthNamesShort,dayNames:wpProQuizLocalize.dayNames,dayNamesShort:wpProQuizLocalize.dayNamesShort,dayNamesMin:wpProQuizLocalize.dayNamesMin,dateFormat:wpProQuizLocalize.dateFormat,firstDay:wpProQuizLocalize.firstDay,changeMonth:!0,onClose:function(t){e("#datepickerFrom").datepicker("option","maxDate",t)}}),e("#filter").click(function(){r.changeFilter(),u.loadHistoryAjax()}),e("#wpProQuiz_overlay_close").click(function(){e("#wpProQuiz_user_overlay").hide()}),e("#wpProQuiz_tabHistory .wpProQuiz_update").click(function(){return r.changeFilter(),u.loadHistoryAjax(),!1}),e("#wpProQuiz_tabOverview .wpProQuiz_update").click(function(){return c.changeFilter(),u.loadOverviewAjax(),!1}),e(".wpProQuiz_resetComplete").click(function(){return s.deleteAll(),!1}),e("#overviewFilter").click(function(){c.changeFilter(),u.loadOverviewAjax()}),r.changeFilter(),u.loadHistoryAjax(),c.changeFilter(),u.loadOverviewAjax()};l()}},o=function(){a();var t=e.noop;e(".wpProQuiz_questionEdit").length?t=n.questionEdit:e(".wpProQuiz_globalSettings").length?t=n.gobalSettings:e(".wpProQuiz_statistics").length?t=n.statistic:e(".wpProQuiz_statisticsNew").length&&(t=n.statisticNew),t(),e(".wpProQuiz_demoImgBox a").mouseover(function(t){var i=e(this),a=e(document).width(),n=i.siblings().outerWidth(!0);if(t.pageX+n>a){var o=a-(t.pageX+n+30);e(this).next().css("left",o+"px")}e(this).next().show()}).mouseout(function(){e(this).next().hide()}).click(function(){return!1})};o()}function i(t,i){var a={onChange:null},n={contain:null,pageLeft:null,pageRight:null,currentPage:null},o=function(){var e=n.currentPage.children().length,t=Number(n.currentPage.val());n.pageLeft.hide(),n.pageRight.hide(),t>1&&n.pageLeft.show(),e>=t+1&&n.pageRight.show()},r=function(){e.extend(n,{contain:t,pageLeft:t.find(".navigationLeft"),pageRight:t.find(".navigationRight"),currentPage:t.find(".navigationCurrentPage")}),e.extend(a,i),n.pageLeft.click(function(){n.currentPage.val(Number(n.currentPage.val())-1),o(),a.onChange&&a.onChange(n.currentPage.val())}),n.pageRight.click(function(){n.currentPage.val(Number(n.currentPage.val())+1),o(),a.onChange&&a.onChange(n.currentPage.val())}),n.currentPage.change(function(){o(),a.onChange&&a.onChange(n.currentPage.val())})};this.getCurrentPage=function(){return n.currentPage.val()},this.setNumPage=function(t){n.currentPage.empty();for(var i=1;t>=i;i++)e(document.createElement("option")).val(i).text(i).appendTo(n.currentPage);o()},r()}e.fn.wpProQuiz_preview=function(){var t={openPreview:function(t){window.open(e(t).attr("href"),"wpProQuizPreview","width=900,height=900")}},i=function(){e(".wpProQuiz_prview").click(function(e){t.openPreview(this),e.preventDefault()})};i()},e.fn.wpProQuiz_quizOverall=function(){},e.fn.wpProQuiz_quizEdit=function(){function t(t,i,a){var n={action:"wp_pro_quiz_admin_ajax",func:t,data:i};e.post(ajaxurl,n,a,"json")}var i={addCategory:function(){var i=e.trim(e('input[name="categoryAdd"]').val());if(!a(i)){var n={categoryName:i,type:"quiz"};t("categoryAdd",n,function(t){if(t.err)return void e("#categoryMsgBox").text(t.err).show("fast").delay(2e3).hide("fast");var i=e(document.createElement("option")).val(t.categoryId).text(t.categoryName).attr("selected","selected");e('select[name="category"]').append(i).change()})}},addResult:function(){e("#resultList").children().each(function(){if("none"==e(this).css("display")){var t=e(this),i=t.find('textarea[name="resultTextGrade[text][]"]'),a=i.attr("id"),n=!0;return t.find('input[name="resultTextGrade[prozent][]"]').val("0"),t.find('input[name="resultTextGrade[activ][]"]').val("1").keyup(),void 0==tinymce.editors[a]||tinymce.editors[a].isHidden()||(n=!1),void 0==switchEditors||n||(switchEditors.go(a,"toggle"),switchEditors.go(a,"toggle")),void 0!=tinymce.editors[a]?tinymce.editors[a].setContent(""):i.val(""),void 0==tinymce.editors[a]||n||tinyMCE.execCommand("mceRemoveControl",!1,a),t.parent().children(":visible").last().after(t),void 0==tinymce.editors[a]||n||tinyMCE.execCommand("mceAddControl",!1,a),e(this).show(),void 0==switchEditors||n||switchEditors.go(a,"toggle"),!1}})},deleteResult:function(t){e(t).parent().parent().hide(),e(t).siblings('input[name="resultTextGrade[activ][]"]').val("0")},changeResult:function(t){var a=e(t);return i.validResultInput(a.val())?(a.siblings(".resultProzent").text(a.val()),a.removeAttr("style"),!0):(a.css("background-color","#FF9696"),!1)},validResultInput:function(e){return a(e)?!1:(e=e.replace(/\,/,"."),!isNaN(e)&&Number(e)<=100&&Number(e)>=0?null!=e.match(/\./)?e.split(".")[1].length<3:!0:!1)},validInput:function(){if(a(e("#wpProQuiz_title").val()))return alert(wpProQuizLocalize.no_title_msg),!1;var t="";if(t=void 0==tinymce.editors.text||tinymce.editors.text.isHidden()?e('textarea[name="text"]').val():tinymce.editors.text.getContent(),a(t))return alert(wpProQuizLocalize.no_quiz_start_msg),!1;if(e("#wpProQuiz_resultGradeEnabled:checked").length){var n=!0;if(e("#resultList").children().each(function(){return e(this).is(":visible")&&!i.validResultInput(e(this).find('input[name="resultTextGrade[prozent][]"]').val())?(n=!1,!1):void 0}),!n)return alert(wpProQuizLocalize.fail_grade_result),!1}return!0},resetLock:function(){t("resetLock",{quizId:e('input[name="ajax_quiz_id"]').val()},function(){e("#resetLockMsg").show("fast").delay(2e3).hide("fast")})},generateFormIds:function(){var t=0;e("#form_table tbody > tr").each(function(){e(this).find('[name^="form[]"]').each(function(){var i=e(this).attr("name").substr(6);e(this).attr("name","form["+t+"]"+i)}),++t})},updateFormIds:function(){var t=-1,i=e(".emailFormVariables option:selected").val(),n=e(".formVariables").empty(),o=e(".emailFormVariables").empty().append('<option value="-1"></option>');e(".emailFormVariables").data("default")>-1&&(i=e(".emailFormVariables").data("default"),e(".emailFormVariables").data("default",-1)),e("#form_table tbody > tr").each(function(){e(this).children().first().text(t);var i=e(this).find(".formFieldName").val(),r=e(this).find('[name="form[][type]"] option:selected'),c=e(this).find('[name="form[][fieldname]"]').val();1!=e(this).find('input[name="form[][form_delete]"]').val()&&(t>=0&&!a(i)&&n.append(e("<li><span>$form{"+t+"}</span> - "+i+"</li>")),4==r.val()&&o.append(e('<option value="'+t+'">'+c+"</option>")),t++)}),e('.emailFormVariables option[value="'+i+'"]').prop("selected",!0)}},a=function(t){return t=e.trim(t),!t||0===t.length},n=function(){e("#statistics_on").change(function(){this.checked?e("#statistics_ip_lock_tr").show():e("#statistics_ip_lock_tr").hide()}),e(".addResult").click(function(){i.addResult()}),e(".deleteResult").click(function(e){i.deleteResult(this)}),e('input[name="resultTextGrade[prozent][]"]').keyup(function(e){i.changeResult(this)}).keydown(function(e){13==e.which&&e.preventDefault()}),e("#wpProQuiz_resultGradeEnabled").change(function(){this.checked?(e("#resultGrade").show(),e("#resultNormal").hide()):(e("#resultGrade").hide(),e("#resultNormal").show())}),e("#wpProQuiz_save").click(function(t){i.validInput()?i.generateFormIds():t.preventDefault(),e('select[name="prerequisiteList[]"] option').attr("selected","selected")}),e('input[name="template"]').click(function(t){return"0"==e('select[name="templateSaveList"]').val()&&a(e('input[name="templateName"]').val())?(alert(wpProQuizLocalize.temploate_no_name),t.preventDefault(),!1):(i.generateFormIds(),void e('select[name="prerequisiteList[]"] option').attr("selected","selected"))}),e('select[name="templateSaveList"]').change(function(){var t=e('input[name="templateName"]');"0"==e(this).val()?t.show():t.hide()}).change(),e('input[name="quizRunOnce"]').change(function(t){this.checked?(e("#wpProQuiz_quiz_run_once_type").show(),e('input[name="quizRunOnceType"]:checked').change()):e("#wpProQuiz_quiz_run_once_type").hide()}),e('input[name="quizRunOnceType"]').change(function(t){!this.checked||"1"!=this.value&&"3"!=this.value?e("#wpProQuiz_quiz_run_once_cookie").hide():e("#wpProQuiz_quiz_run_once_cookie").show()}),e('input[name="resetQuizLock"]').click(function(e){return i.resetLock(),!1}),e(".wpProQuiz_demoBox a").mouseover(function(t){var i=e(this),a=e("#poststuff").width(),n=i.siblings().outerWidth(!0);if(t.pageX+n>a){var o=jQuery(document).width()-i.parent().offset().left-n-30;e(this).next().css("left",o+"px")}e(this).next().show()}).mouseout(function(){e(this).next().hide()}).click(function(){return!1}),e('input[name="showMaxQuestion"]').change(function(){this.checked?e("#wpProQuiz_showMaxBox").show():e("#wpProQuiz_showMaxBox").hide()}),e("#btnPrerequisiteAdd").click(function(){e('select[name="quizList"] option:selected').removeAttr("selected").appendTo('select[name="prerequisiteList[]"]')}),e("#btnPrerequisiteDelete").click(function(){e('select[name="prerequisiteList[]"] option:selected').removeAttr("selected").appendTo('select[name="quizList"]')}),e('input[name="prerequisite"]').change(function(){this.checked?e("#prerequisiteBox").show():e("#prerequisiteBox").hide()}).change(),e('input[name="toplistDataAddMultiple"]').change(function(){this.checked?e("#toplistDataAddBlockBox").show():e("#toplistDataAddBlockBox").hide()}).change(),e('input[name="toplistActivated"]').change(function(){this.checked?e("#toplistBox > tr:gt(0)").show():e("#toplistBox > tr:gt(0)").hide();
2
+ }).change(),e('input[name="showReviewQuestion"]').change(function(){this.checked?e(".wpProQuiz_reviewQuestionOptions").show():e(".wpProQuiz_reviewQuestionOptions").hide()}).change(),e("#statistics_on").change(),e("#wpProQuiz_resultGradeEnabled").change(),e('input[name="quizRunOnce"]').change(),e('input[name="quizRunOnceType"]:checked').change(),e('input[name="showMaxQuestion"]').change(),e("#form_add").click(function(){e("#form_table tbody > tr:eq(0)").clone(!0).appendTo("#form_table tbody").show(),i.updateFormIds()}),e('input[name="form_delete"]').click(function(){var t=e(this).parents("tr");"0"!=t.find('input[name="form[][form_id]"]').val()?(t.find('input[name="form[][form_delete]"]').val(1),t.hide()):t.remove(),i.updateFormIds()}),e("#form_table tbody").sortable({handle:".form_move",update:i.updateFormIds}),e(".form_move").click(function(){return!1}),e('select[name="form[][type]"]').change(function(){switch(Number(e(this).val())){case 7:case 8:e(this).siblings(".editDropDown").show();break;default:e(this).siblings(".editDropDown, .dropDownEditBox").hide()}}).change(),e(".editDropDown").click(function(){return e(".dropDownEditBox").not(e(this).siblings(".dropDownEditBox").toggle()).hide(),!1}),e(".dropDownEditBox input").click(function(){e(this).parent().hide()}),e('.formFieldName, select[name="form[][type]"]').change(function(){i.updateFormIds()}),e('select[name="category"]').change(function(){var t=e(this),i=e("#categoryAddBox").hide();"-1"==t.val()&&i.show()}).change(),e("#categoryAddBtn").click(function(){i.addCategory()}),e('input[name="emailNotification"]').change(function(){var t=e("#adminEmailSettings tr:gt(0)");e('input[name="emailNotification"]:checked').val()>0?t.show():t.hide()}).change(),e('input[name="userEmailNotification"]').change(function(){var t=e("#userEmailSettings tr:gt(0)");e('input[name="userEmailNotification"]:checked').val()>0?t.show():t.hide()}).change(),i.updateFormIds(),e('input[name="email[html]"]').change(function(){return void 0==switchEditors?!1:void(this.checked?switchEditors.go("adminEmailEditor","tmce"):switchEditors.go("adminEmailEditor","html"))}),e('input[name="adminEmail[html]"]').change(function(){return void 0==switchEditors?!1:void(this.checked?switchEditors.go("adminEmailEditor","tmce"):switchEditors.go("adminEmailEditor","html"))}),e('input[name="userEmail[html]"]').change(function(){return void 0==switchEditors?!1:void(this.checked?switchEditors.go("userEmailEditor","tmce"):switchEditors.go("userEmailEditor","html"))}),setTimeout(function(){e('input[name="userEmail[html]"]').change(),e('input[name="email[html]"]').change()},1e3)};n()},e.fn.wpProQuiz_statistics=function(){var t="wpProQuiz_typeAnonymeUser",i=!0,a={loadStatistics:function(t){var i=window.location.pathname+window.location.search,n=i.replace("admin.php","admin-ajax.php")+"&action=load_statistics",o={action:"wp_pro_quiz_load_statistics",userId:t};e("#wpProQuiz_loadData").show(),e("#wpProQuiz_statistics_content, #wpProQuiz_statistics_overview").hide(),e.post(n,o,a.setStatistics,"json")},setStatistics:function(i){var a=e(".wpProQuiz_statistics_table"),n=a.find("tbody");if("wpProQuiz_typeOverview"!=t){var o=function(e,t,i){e.find(".wpProQuiz_cCorrect").text(t.cCorrect+" ("+t.pCorrect+"%)"),e.find(".wpProQuiz_cIncorrect").text(t.cIncorrect+" ("+t.pIncorrect+"%)"),e.find(".wpProQuiz_cTip").text(t.cTip),e.find(".wpProQuiz_cPoints").text(t.cPoints),1==i&&a.find(".wpProQuiz_cResult").text(t.result+"%")};o(a,i.clear,!1),e.each(i.items,function(e,t){o(n.find("#wpProQuiz_tr_"+t.id),t,!1)}),o(a.find("tfoot"),i.global,!0),e("#wpProQuiz_loadData").hide(),e("#wpProQuiz_statistics_content, .wpProQuiz_statistics_table").show()}},loadOverview:function(){e(".wpProQuiz_statistics_table, #wpProQuiz_statistics_content, #wpProQuiz_statistics_overview").hide(),e("#wpProQuiz_loadData").show();var n=window.location.pathname+window.location.search,o=n.replace("admin.php","admin-ajax.php")+"&action=load_statistics",r={action:"wp_pro_quiz_load_statistics",overview:!0,pageLimit:e("#wpProQuiz_pageLimit").val(),onlyCompleted:Number(e("#wpProQuiz_onlyCompleted").is(":checked")),page:e("#wpProQuiz_currentPage").val(),generatePageNav:Number(i)};e.post(o,r,function(n){if(e("#wpProQuiz_statistics_overview_data").empty(),"wpProQuiz_typeOverview"==t){var o=e('<tr><th><a href="#">---</a></th><th class="wpProQuiz_points">---</th><th class="wpProQuiz_cCorrect" style="color: green;">---</th><th class="wpProQuiz_cIncorrect" style="color: red;">---</th><th class="wpProQuiz_cTip">---</th><th class="wpProQuiz_cResult" style="font-weight: bold;">---</th></tr>');e.each(n.items,function(t,i){var a=o.clone();a.find("a").text(i.userName).data("userId",i.userId).click(function(){return e("#userSelect").val(e(this).data("userId")),e("#wpProQuiz_typeRegisteredUser").click(),!1}),i.completed?(a.find(".wpProQuiz_points").text(i.cPoints),a.find(".wpProQuiz_cCorrect").text(i.cCorrect+" ("+i.pCorrect+"%)"),a.find(".wpProQuiz_cIncorrect").text(i.cIncorrect+" ("+i.pIncorrect+"%)"),a.find(".wpProQuiz_cTip").text(i.cTip),a.find(".wpProQuiz_cResult").text(i.result+"%")):a.find("th").removeAttr("style"),e("#wpProQuiz_statistics_overview_data").append(a)}),void 0!=n.page&&(a.setPageNav(n.page),i=!1),e("#wpProQuiz_loadData").hide(),e("#wpProQuiz_statistics_overview").show()}},"json")},loadFormOverview:function(){e("#wpProQuiz_tabFormOverview").show()},changeTab:function(i){t=i,"wpProQuiz_typeRegisteredUser"==i?a.loadStatistics(e("#userSelect").val()):"wpProQuiz_typeAnonymeUser"==i?a.loadStatistics(0):"wpProQuiz_typeForm"==i?a.loadFormOverview():a.loadOverview()},resetStatistic:function(i){var n="wpProQuiz_typeRegisteredUser"==t?e("#userSelect").val():0,o=window.location.pathname+window.location.search,r=o.replace("admin.php","admin-ajax.php")+"&action=reset",c={action:"wp_pro_quiz_statistics",userId:n,complete:i};e.post(r,c,function(e){a.changeTab(t)})},setPageNav:function(t){t=Math.ceil(t/e("#wpProQuiz_pageLimit").val()),e("#wpProQuiz_currentPage").empty();for(var i=1;t>=i;i++)e(document.createElement("option")).val(i).text(i).appendTo(e("#wpProQuiz_currentPage"));e("#wpProQuiz_pageLeft, #wpProQuiz_pageRight").hide(),e("#wpProQuiz_currentPage option").length>1&&e("#wpProQuiz_pageRight").show()}},n=function(){e(".wpProQuiz_tab").click(function(t){var i=e(this);return i.hasClass("button-primary")?!1:("wpProQuiz_typeRegisteredUser"==i.attr("id")?e("#wpProQuiz_userBox").show():e("#wpProQuiz_userBox").hide(),e(".wpProQuiz_tab").removeClass("button-primary").addClass("button-secondary"),i.removeClass("button-secondary").addClass("button-primary"),a.changeTab(i.attr("id")),!1)}),e("#userSelect").change(function(){a.changeTab("wpProQuiz_typeRegisteredUser")}),e(".wpProQuiz_update").click(function(){return a.changeTab(t),!1}),e("#wpProQuiz_reset").click(function(){var e=confirm(wpProQuizLocalize.reset_statistics_msg);return e&&a.resetStatistic(!1),!1}),e(".wpProQuiz_resetComplete").click(function(){var e=confirm(wpProQuizLocalize.reset_statistics_msg);return e&&a.resetStatistic(!0),!1}),e("#wpProQuiz_pageLimit, #wpProQuiz_onlyCompleted").change(function(){return e("#wpProQuiz_currentPage").val(0),i=!0,a.changeTab(t),!1}),e("#wpProQuiz_currentPage").change(function(){e("#wpProQuiz_pageLeft, #wpProQuiz_pageRight").hide(),1==e("#wpProQuiz_currentPage option").length||(e("#wpProQuiz_currentPage option:first-child:selected").length?e("#wpProQuiz_pageRight").show():e("#wpProQuiz_currentPage option:last-child:selected").length?e("#wpProQuiz_pageLeft").show():e("#wpProQuiz_pageLeft, #wpProQuiz_pageRight").show()),a.changeTab(t)}),e("#wpProQuiz_pageRight").click(function(){return e("#wpProQuiz_currentPage option:selected").next().attr("selected","selected"),e("#wpProQuiz_currentPage").change(),!1}),e("#wpProQuiz_pageLeft").click(function(){return e("#wpProQuiz_currentPage option:selected").prev().attr("selected","selected"),e("#wpProQuiz_currentPage").change(),!1}),a.changeTab("wpProQuiz_typeAnonymeUser")};n()},e.fn.wpProQuiz_toplist=function(){function t(t,i,a){var n={action:"wp_pro_quiz_admin_ajax",func:t,data:i};e.post(ajaxurl,n,a,"json")}var i={sort:e("#wpProQuiz_sorting"),pageLimit:e("#wpProQuiz_pageLimit"),currentPage:e("#wpProQuiz_currentPage"),loadDataBox:e("#wpProQuiz_loadData"),pageLeft:e("#wpProQuiz_pageLeft"),pageRight:e("#wpProQuiz_pageRight"),dataBody:e("#wpProQuiz_toplistTable tbody"),rowClone:e("#wpProQuiz_toplistTable tbody tr:eq(0)").clone(),content:e("#wpProQuiz_content")},a={loadData:function(a){var n=this,o={sort:i.sort.val(),limit:i.pageLimit.val(),page:i.currentPage.val(),quizId:e('input[name="ajax_quiz_id"]').val()};void 0!=a&&e.extend(o,a),i.loadDataBox.show(),i.content.hide(),t("adminToplist",o,function(e){n.handleDataRequest(e.data),void 0!=e.nav&&n.handleNav(e.nav),i.loadDataBox.hide(),i.content.show()})},handleNav:function(t){i.currentPage.empty();for(var a=1;a<=t.pages;a++)e(document.createElement("option")).val(a).text(a).appendTo(i.currentPage);this.checkNav()},handleDataRequest:function(t){var a=this;i.dataBody.empty(),e.each(t,function(e,t){var a=i.rowClone.clone().children();a.eq(0).children().val(t.id),a.eq(1).find("strong").text(t.name),a.eq(1).find(".inline_editUsername").val(t.name),a.eq(2).find(".wpProQuiz_email").text(t.email),a.eq(2).find("input").val(t.email),a.eq(3).text(t.type),a.eq(4).text(t.date),a.eq(5).text(t.points),a.eq(6).text(t.result),a.parent().show().appendTo(i.dataBody)}),t.length||e(document.createElement("td")).attr("colspan","7").text(wpProQuizLocalize.no_data_available).css({"font-weight":"bold","text-align":"center",padding:"5px"}).appendTo(document.createElement("tr")).appendTo(i.dataBody),e(".wpProQuiz_delete").click(function(){if(confirm(wpProQuizLocalize.confirm_delete_entry)){var t=new Array(e(this).closest("tr").find('input[name="checkedData[]"]').val());a.loadData({a:"delete",toplistIds:t})}return!1}),e(".wpProQuiz_edit").click(function(){var t=e(this).closest("tr");return t.find(".row-actions").hide(),t.find(".inline-edit").show(),t.find(".wpProQuiz_username, .wpProQuiz_email").hide(),t.find(".inline_editUsername, .inline_editEmail").show(),!1}),e(".inline_editSave").click(function(){var t=e(this).closest("tr"),i=t.find(".inline_editUsername").val(),n=t.find(".inline_editEmail").val();return a.isEmpty(i)||a.isEmpty(n)?(alert(wpProQuizLocalize.not_all_fields_completed),!1):(a.loadData({a:"edit",toplistId:t.find('input[name="checkedData[]"]').val(),name:i,email:n}),!1)}),e(".inline_editCancel").click(function(){var t=e(this).closest("tr");return t.find(".row-actions").show(),t.find(".inline-edit").hide(),t.find(".wpProQuiz_username, .wpProQuiz_email").show(),t.find(".inline_editUsername, .inline_editEmail").hide(),t.find(".inline_editUsername").val(t.find(".wpProQuiz_username").text()),t.find(".inline_editEmail").val(t.find(".wpProQuiz_email").text()),!1})},checkNav:function(){var e=i.currentPage.val();1==e?i.pageLeft.hide():i.pageLeft.show(),e==i.currentPage.children().length?i.pageRight.hide():i.pageRight.show()},isEmpty:function(t){return t=e.trim(t),!t||0===t.length}},n=function(){i.sort.change(function(){a.loadData()}),i.pageLimit.change(function(){a.loadData({nav:1})}),i.currentPage.change(function(){a.checkNav(),a.loadData()}),i.pageLeft.click(function(){i.currentPage.val(Number(i.currentPage.val())-1),a.checkNav(),a.loadData()}),i.pageRight.click(function(){i.currentPage.val(Number(i.currentPage.val())+1),a.checkNav(),a.loadData()}),e("#wpProQuiz_deleteAll").click(function(){a.loadData({a:"deleteAll"})}),e("#wpProQuiz_action").click(function(){var t=e("#wpProQuiz_actionName").val();if("0"!=t){var i=e('input[name="checkedData[]"]:checked').map(function(){return e(this).val()}).get();a.loadData({a:t,toplistIds:i})}}),e("#wpProQuiz_checkedAll").change(function(){this.checked?e('input[name="checkedData[]"]').attr("checked","checked"):e('input[name="checkedData[]"]').removeAttr("checked","checked")}),a.loadData({nav:1})};n()},e(".wpProQuiz_quizOverall").length&&e(".wpProQuiz_quizOverall").wpProQuiz_preview(),e(".wpProQuiz_quizOverall").length&&e(".wpProQuiz_quizOverall").wpProQuiz_quizOverall(),e(".wpProQuiz_quizEdit").length&&e(".wpProQuiz_quizEdit").wpProQuiz_quizEdit(),e(".wpProQuiz_toplist").length&&e(".wpProQuiz_toplist").wpProQuiz_toplist(),t()});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/wpProQuiz_front.js CHANGED
@@ -1,2004 +1,2220 @@
1
- (function($) {
2
- /**
3
- * @memberOf $
4
- */
5
- $.wpProQuizFront = function(element, options) {
6
-
7
- var $e = $(element);
8
- var config = options;
9
- var plugin = this;
10
- var results = new Object();
11
- var catResults = new Object();
12
- var startTime = 0;
13
- var currentQuestion = null;
14
- var quizSolved = [];
15
- var lastButtonValue = "";
16
- var inViewQuestions = false;
17
- var currentPage = 1;
18
-
19
- var bitOptions = {
20
- randomAnswer: 0,
21
- randomQuestion: 0,
22
- disabledAnswerMark: 0,
23
- checkBeforeStart: 0,
24
- preview: 0,
25
- cors: 0,
26
- isAddAutomatic: 0,
27
- quizSummeryHide: 0,
28
- skipButton: 0,
29
- reviewQustion: 0,
30
- autoStart: 0,
31
- forcingQuestionSolve: 0,
32
- hideQuestionPositionOverview: 0,
33
- formActivated: 0,
34
- maxShowQuestion: 0,
35
- sortCategories: 0
36
- };
37
-
38
- var quizStatus = {
39
- isQuizStart: 0,
40
- isLocked: 0,
41
- loadLock: 0,
42
- isPrerequisite: 0,
43
- isUserStartLocked: 0
44
- };
45
-
46
- var globalNames = {
47
- check: 'input[name="check"]',
48
- next: 'input[name="next"]',
49
- questionList: '.wpProQuiz_questionList',
50
- skip: 'input[name="skip"]',
51
- singlePageLeft: 'input[name="wpProQuiz_pageLeft"]',
52
- singlePageRight: 'input[name="wpProQuiz_pageRight"]'
53
- };
54
-
55
- var globalElements = {
56
- back: $e.find('input[name="back"]'),
57
- next: $e.find(globalNames.next),
58
- quiz: $e.find('.wpProQuiz_quiz'),
59
- questionList: $e.find('.wpProQuiz_list'),
60
- results: $e.find('.wpProQuiz_results'),
61
- quizStartPage: $e.find('.wpProQuiz_text'),
62
- timelimit: $e.find('.wpProQuiz_time_limit'),
63
- toplistShowInButton: $e.find('.wpProQuiz_toplistShowInButton'),
64
- listItems: $()
65
- };
66
-
67
- var toplistData = {
68
- token: '',
69
- isUser: 0
70
- };
71
-
72
- var formPosConst = {
73
- START: 0,
74
- END: 1
75
- };
76
-
77
- /**
78
- * @memberOf timelimit
79
- */
80
- var timelimit = (function() {
81
- var _counter = config.timelimit;
82
- var _intervalId = 0;
83
- var instance = {};
84
-
85
- instance.stop = function() {
86
- if(_counter) {
87
- window.clearInterval(_intervalId);
88
- globalElements.timelimit.hide();
89
- }
90
- };
91
-
92
- instance.start = function() {
93
- if(!_counter)
94
- return;
95
-
96
- var x = _counter * 1000;
97
-
98
- var $timeText = globalElements.timelimit.find('span').text(plugin.methode.parseTime(_counter));
99
- var $timeDiv = globalElements.timelimit.find('.wpProQuiz_progress');
100
-
101
- globalElements.timelimit.show();
102
-
103
- var beforeTime = +new Date();
104
-
105
- _intervalId = window.setInterval(function() {
106
-
107
- var diff = (+new Date() - beforeTime);
108
- var elapsedTime = x - diff;
109
-
110
- if(diff >= 500) {
111
- $timeText.text(plugin.methode.parseTime(Math.ceil(elapsedTime / 1000)));
112
- }
113
-
114
- $timeDiv.css('width', (elapsedTime / x * 100) + '%');
115
-
116
- if(elapsedTime <= 0) {
117
- instance.stop();
118
- plugin.methode.finishQuiz(true);
119
- }
120
-
121
- }, 16);
122
- };
123
-
124
- return instance;
125
-
126
- })();
127
-
128
-
129
- /**
130
- * @memberOf reviewBox
131
- */
132
- var reviewBox = new function() {
133
-
134
- var $contain = [], $cursor = [], $list = [], $items = [];
135
- var x = 0, offset = 0, diff = 0, top = 0, max = 0;
136
- var itemsStatus = [];
137
-
138
- this.init = function() {
139
- $contain = $e.find('.wpProQuiz_reviewQuestion');
140
- $cursor = $contain.find('div');
141
- $list = $contain.find('ol');
142
- $items = $list.children();
143
-
144
- $cursor.mousedown(function(e) {
145
- e.preventDefault();
146
- e.stopPropagation();
147
-
148
- offset = e.pageY - $cursor.offset().top + top;
149
-
150
- $(document).bind('mouseup.scrollEvent', endScroll);
151
- $(document).bind('mousemove.scrollEvent', moveScroll);
152
-
153
- });
154
-
155
- $items.click(function(e) {
156
- plugin.methode.showQuestion($(this).index());
157
- });
158
-
159
- $e.bind('questionSolved', function(e) {
160
- itemsStatus[e.values.index].solved = e.values.solved;
161
- setColor(e.values.index);
162
- });
163
-
164
- $e.bind('changeQuestion', function(e) {
165
- $items.removeClass('wpProQuiz_reviewQuestionTarget');
166
-
167
- $items.eq(e.values.index).addClass('wpProQuiz_reviewQuestionTarget');
168
-
169
- scroll(e.values.index);
170
- });
171
-
172
- $e.bind('reviewQuestion', function(e) {
173
- itemsStatus[e.values.index].review = !itemsStatus[e.values.index].review;
174
- setColor(e.values.index);
175
- });
176
-
177
- $contain.bind('mousewheel DOMMouseScroll', function(e) {
178
- e.preventDefault();
179
-
180
- var ev = e.originalEvent;
181
- var w = ev.wheelDelta ? -ev.wheelDelta / 120 : ev.detail / 3;
182
- var plus = 20 * w;
183
-
184
- var x = top - $list.offset().top + plus;
185
-
186
- if(x > max)
187
- x = max;
188
-
189
- if(x < 0)
190
- x = 0;
191
-
192
- var o = x / diff;
193
-
194
- $list.attr('style', 'margin-top: ' + (-x) + 'px !important');
195
- $cursor.css({top: o});
196
-
197
- return false;
198
- });
199
- };
200
-
201
- this.show = function(save) {
202
- if(bitOptions.reviewQustion)
203
- $contain.parent().show();
204
-
205
- $e.find('.wpProQuiz_reviewDiv .wpProQuiz_button2').show();
206
-
207
- if(save)
208
- return;
209
-
210
- $list.attr('style', 'margin-top: 0px !important');
211
- $cursor.css({top: 0});
212
-
213
- var h = $list.outerHeight();
214
- var c = $contain.height();
215
- x = c - $cursor.height();
216
- offset = 0;
217
- max = h-c;
218
- diff = max / x;
219
-
220
- this.reset();
221
-
222
- if(h > 100) {
223
- $cursor.show();
224
- }
225
-
226
- top = $cursor.offset().top;
227
- };
228
-
229
- this.hide = function() {
230
- $contain.parent().hide();
231
- };
232
-
233
- this.toggle = function() {
234
- if(bitOptions.reviewQustion) {
235
- $contain.parent().toggle();
236
- $items.removeClass('wpProQuiz_reviewQuestionTarget');
237
- $e.find('.wpProQuiz_reviewDiv .wpProQuiz_button2').hide();
238
-
239
- $list.attr('style', 'margin-top: 0px !important');
240
- $cursor.css({top: 0});
241
-
242
- var h = $list.outerHeight();
243
- var c = $contain.height();
244
- x = c - $cursor.height();
245
- offset = 0;
246
- max = h-c;
247
- diff = max / x;
248
-
249
- if(h > 100) {
250
- $cursor.show();
251
- }
252
-
253
- top = $cursor.offset().top;
254
- }
255
- };
256
-
257
- this.reset = function() {
258
- for(var i = 0, c = $items.length; i < c; i++) {
259
- itemsStatus[i] = {};
260
- }
261
-
262
- $items.removeClass('wpProQuiz_reviewQuestionTarget').css('background-color', '');
263
- };
264
-
265
- function scroll(index) {
266
- var $item = $items.eq(index);
267
- var iTop = $item.offset().top;
268
- var cTop = $contain.offset().top;
269
- var calc = iTop - cTop;
270
-
271
-
272
- if((calc - 4) < 0 || (calc + 32) > 100) {
273
- var x = cTop - $items.eq(0).offset().top - (cTop - $list.offset().top) + $item.position().top;
274
-
275
- if(x > max)
276
- x = max;
277
-
278
- var o = x / diff;
279
-
280
- $list.attr('style', 'margin-top: ' + (-x) + 'px !important');
281
- $cursor.css({top: o});
282
- }
283
- }
284
-
285
- function setColor(index) {
286
- var color = '';
287
- var itemStatus = itemsStatus[index];
288
-
289
- if(itemStatus.review) {
290
- color = '#FFB800';
291
- } else if(itemStatus.solved) {
292
- color = '#6CA54C';
293
- }
294
-
295
- $items.eq(index).css('background-color', color);
296
- }
297
-
298
- function moveScroll(e) {
299
- e.preventDefault();
300
-
301
- var o = e.pageY - offset;
302
-
303
- if(o < 0)
304
- o = 0;
305
-
306
- if(o > x)
307
- o = x;
308
-
309
- var v = diff * o;
310
-
311
- $list.attr('style', 'margin-top: ' + (-v) + 'px !important');
312
-
313
- $cursor.css({top: o});
314
- }
315
-
316
- function endScroll(e) {
317
- e.preventDefault();
318
-
319
- $(document).unbind('.scrollEvent');
320
- }
321
- };
322
-
323
-
324
- function QuestionTimer() {
325
- var questionStartTime = 0;
326
- var currentQuestionId = -1;
327
-
328
- var quizStartTimer = 0;
329
- var isQuizStart = false;
330
-
331
- this.questionStart = function(questionId) {
332
- if(currentQuestionId != -1)
333
- this.questionStop();
334
-
335
- currentQuestionId = questionId;
336
- questionStartTime = +new Date();
337
- };
338
-
339
- this.questionStop = function() {
340
- if(currentQuestionId == -1)
341
- return;
342
-
343
- results[currentQuestionId].time += Math.round((new Date() - questionStartTime) / 1000);
344
-
345
- currentQuestionId = -1;
346
- };
347
-
348
- this.startQuiz = function() {
349
- if(isQuizStart)
350
- this.stopQuiz();
351
-
352
- quizStartTimer = +new Date();
353
- isQuizStart = true;
354
- };
355
-
356
- this.stopQuiz = function() {
357
- if(!isQuizStart)
358
- return;
359
-
360
- results['comp'].quizTime += Math.round((new Date() - quizStartTimer) / 1000);
361
- isQuizStart = false;
362
- };
363
-
364
- this.init = function() {
365
-
366
- };
367
-
368
- };
369
-
370
- var questionTimer = new QuestionTimer();
371
-
372
- /**
373
- * @memberOf checker
374
- */
375
- var checker = function(name, data, $question, $questionList) {
376
- var correct = true;
377
- var points = 0;
378
- var isDiffPoints = $.isArray(data.points);
379
- var statistcAnswerData = {};
380
-
381
- var func = {
382
- singleMulti: function() {
383
- var input = $questionList.find('.wpProQuiz_questionInput').attr('disabled', 'disabled');
384
- var isDiffMode = data.diffMode;
385
-
386
- $questionList.children().each(function(i) {
387
- var $item = $(this);
388
- var index = $item.data('pos');
389
- var checked = input.eq(i).is(':checked');
390
-
391
- if(data.correct[index]) {
392
- if(!checked) {
393
- correct = false;
394
- } else {
395
- if(isDiffPoints) {
396
- if(isDiffMode)
397
- points = data.points[index];
398
- else
399
- points += data.points[index];
400
- }
401
- }
402
-
403
- if(data.disCorrect) {
404
- correct = true;
405
- } else {
406
- plugin.methode.marker($item, true);
407
- }
408
-
409
- } else {
410
- if(checked) {
411
- if(!data.disCorrect) {
412
- plugin.methode.marker($item, false);
413
- correct = false;
414
- } else {
415
- correct = true;
416
- }
417
-
418
- if(isDiffMode)
419
- points = data.points[index];
420
- } else {
421
- if(isDiffPoints && !isDiffMode) {
422
- points += data.points[index];
423
- }
424
- }
425
- }
426
- });
427
- },
428
-
429
- sort_answer: function() {
430
- var $items = $questionList.children();
431
-
432
- $items.each(function(i, v) {
433
- var $this = $(this);
434
-
435
- statistcAnswerData[i] = $this.data('pos');
436
-
437
- if(i == $this.data('pos')) {
438
- plugin.methode.marker($this, true);
439
-
440
- if(isDiffPoints) {
441
- points += data.points[i];
442
- }
443
- } else {
444
- plugin.methode.marker($this, false);
445
- correct = false;
446
- }
447
- });
448
-
449
- $items.children().css({'box-shadow': '0 0', 'cursor': 'auto'});
450
-
451
- $questionList.sortable("destroy");
452
-
453
- $items.sort(function(a, b) {
454
- return $(a).data('pos') > $(b).data('pos') ? 1 : -1;
455
- });
456
-
457
- $questionList.append($items);
458
- },
459
-
460
- matrix_sort_answer: function() {
461
- var $items = $questionList.children();
462
- var matrix = new Array();
463
- statistcAnswerData = {0:-1};
464
-
465
- $items.each(function() {
466
- var $this = $(this);
467
- var i = $this.data('pos');
468
- var $stringUl = $this.find('.wpProQuiz_maxtrixSortCriterion');
469
- var $stringItem = $stringUl.children();
470
-
471
- if($stringItem.length)
472
- statistcAnswerData[i] = $stringItem.data('pos');
473
-
474
- if($stringItem.length && $.inArray(String(i), String($stringItem.data('correct')).split(',')) >= 0) {
475
- // if(i == $stringItem.data('pos')) {
476
- plugin.methode.marker($stringUl, true);
477
-
478
- if(isDiffPoints) {
479
- points += data.points[i];
480
- }
481
- } else {
482
- correct = false;
483
- plugin.methode.marker($stringUl, false);
484
- }
485
-
486
- matrix[i] = $stringUl;
487
- });
488
-
489
- plugin.methode.resetMatrix($question);
490
-
491
- $question.find('.wpProQuiz_sortStringItem').each(function() {
492
- var x = matrix[$(this).data('pos')];
493
- if(x != undefined)
494
- x.append(this);
495
- }).css({'box-shadow': '0 0', 'cursor': 'auto'});
496
-
497
- $question.find('.wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion').sortable("destroy");
498
- },
499
-
500
- free_answer: function() {
501
- var $li = $questionList.children();
502
- var value = $li.find('.wpProQuiz_questionInput').attr('disabled', 'disabled').val();
503
-
504
- if($.inArray($.trim(value).toLowerCase(), data.correct) >= 0) {
505
- plugin.methode.marker($li, true);
506
- } else {
507
- plugin.methode.marker($li, false);
508
- correct = false;
509
- }
510
- },
511
-
512
- cloze_answer: function() {
513
- $questionList.find('.wpProQuiz_cloze').each(function(i, v) {
514
- var $this = $(this);
515
- var cloze = $this.children();
516
- var input = cloze.eq(0);
517
- var span = cloze.eq(1);
518
- var inputText = plugin.methode.cleanupCurlyQuotes(input.val());
519
-
520
- if($.inArray(inputText, data.correct[i]) >= 0) {
521
- if(isDiffPoints) {
522
- points += data.points[i];
523
- }
524
-
525
- if(!bitOptions.disabledAnswerMark) {
526
- input.css('background-color', '#B0DAB0');
527
- }
528
- } else {
529
- if(!bitOptions.disabledAnswerMark) {
530
- input.css('background-color', '#FFBABA');
531
- }
532
-
533
- correct = false;
534
-
535
- span.show();
536
- }
537
-
538
- input.attr('disabled', 'disabled');
539
- });
540
- },
541
-
542
- assessment_answer: function() {
543
- correct = true;
544
- var $input = $questionList.find('.wpProQuiz_questionInput').attr('disabled', 'disabled');
545
- var val = 0;
546
-
547
- $input.filter(':checked').each(function() {
548
- val += parseInt($(this).val());
549
- });
550
-
551
- points = val;
552
- }
553
- };
554
-
555
- func[name]();
556
-
557
- if(!isDiffPoints && correct) {
558
- points = data.points;
559
- }
560
-
561
- return {c: correct, p: points, s: statistcAnswerData};
562
- };
563
-
564
- /**
565
- * @memberOf formClass
566
- */
567
- var formClass = new function() {
568
- var funcs = {
569
- isEmpty: function(str) {
570
- str = $.trim(str);
571
- return (!str || 0 === str.length);
572
- }
573
-
574
- // testValidate: function(str, type) {
575
- // switch (type) {
576
- // case 0: //None
577
- // return true;
578
- // case 1: //Text
579
- // return !funcs.isEmpty(str);
580
- // case 2: //Number
581
- // return !isNaN(str);
582
- // case 3: //E-Mail
583
- // return new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)
584
- // .test($.trim(str));
585
- // }
586
- // }
587
- };
588
-
589
- var typeConst = {
590
- TEXT: 0,
591
- TEXTAREA: 1,
592
- NUMBER: 2,
593
- CHECKBOX: 3,
594
- EMAIL: 4,
595
- YES_NO: 5,
596
- DATE: 6,
597
- SELECT: 7,
598
- RADIO: 8
599
- };
600
-
601
- this.checkForm = function() {
602
- var check = true;
603
-
604
- $e.find('.wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select').each(function() {
605
- var $this = $(this);
606
- var isRequired = $this.data('required') == 1;
607
- var type = $this.data('type');
608
- var test = true;
609
- var value = $.trim($this.val());
610
-
611
- switch (type) {
612
- case typeConst.TEXT:
613
- case typeConst.TEXTAREA:
614
- case typeConst.SELECT:
615
- if(isRequired)
616
- test = !funcs.isEmpty(value);
617
-
618
- break;
619
- case typeConst.NUMBER:
620
- if(isRequired || !funcs.isEmpty(value))
621
- test = !funcs.isEmpty(value) && !isNaN(value);
622
-
623
- break;
624
- case typeConst.EMAIL:
625
- if(isRequired || !funcs.isEmpty(value))
626
- test = !funcs.isEmpty(value) && new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)
627
- .test(value);
628
-
629
- break;
630
- case typeConst.CHECKBOX:
631
- if(isRequired)
632
- test = $this.is(':checked');
633
-
634
- break;
635
- case typeConst.YES_NO:
636
- case typeConst.RADIO:
637
- if(isRequired)
638
- test = $this.find('input[type="radio"]:checked').val() !== undefined;
639
- break;
640
- case typeConst.DATE:
641
- var num = 0, co = 0;
642
-
643
- $this.find('select').each(function() {
644
- num++;
645
- co += funcs.isEmpty($(this).val()) ? 0 : 1;
646
- });
647
-
648
- if(isRequired || co > 0)
649
- test = num == co;
650
-
651
- break;
652
- }
653
-
654
- if(test) {
655
- $this.siblings('.wpProQuiz_invalidate').hide();
656
- } else {
657
- check = false;
658
- $this.siblings('.wpProQuiz_invalidate').show();
659
- }
660
-
661
- });
662
-
663
- // $('.wpProQuiz_forms input, .wpProQuiz_forms textarea').each(function() {
664
- // var $this = $(this);
665
- // var isRequired = $this.data('required') == 1;
666
- // var validate = $this.data('validate') & 0xFF;
667
- // var test = false;
668
- // var $infos = $this.parents('div:eq(0)').find('.wpProQuiz_invalidate');
669
- //
670
- // if(isRequired) {
671
- // if($this.attr('type') == 'checkbox') {
672
- // if($this.is(':checked'))
673
- // test = true;
674
- //
675
- // } else {
676
- // if(!funcs.isEmpty($this.val()))
677
- // test = true;
678
- // }
679
- //
680
- // if(!test) {
681
- // check = false;
682
- // $infos.eq(0).show();
683
- // } else {
684
- // $infos.eq(0).hide();
685
- // }
686
- // }
687
- //
688
- // if(!funcs.testValidate($this.val(), validate)) {
689
- // check = false;
690
- // $infos.eq(1).show();
691
- // } else {
692
- // $infos.eq(1).hide();
693
- // }
694
- //
695
- // });
696
-
697
- // if(!check)
698
- // alert(WpProQuizGlobal.fieldsNotFilled);
699
- //
700
- return check;
701
- };
702
-
703
- this.getFormData = function() {
704
- var data = {};
705
-
706
- $e.find('.wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select').each(function() {
707
- var $this = $(this);
708
- var id = $this.data('form_id');
709
- var type = $this.data('type');
710
-
711
- switch (type) {
712
- case typeConst.TEXT:
713
- case typeConst.TEXTAREA:
714
- case typeConst.SELECT:
715
- case typeConst.NUMBER:
716
- case typeConst.EMAIL:
717
- data[id] = $this.val();
718
- break;
719
- case typeConst.CHECKBOX:
720
- data[id] = $this.is(':checked') ? 1 : 0;
721
- break;
722
- case typeConst.YES_NO:
723
- case typeConst.RADIO:
724
- data[id] = $this.find('input[type="radio"]:checked').val();
725
- break;
726
- case typeConst.DATE:
727
- data[id] = {
728
- day: $this.find('select[name="wpProQuiz_field_' + id +'_day"]').val(),
729
- month: $this.find('select[name="wpProQuiz_field_' + id +'_month"]').val(),
730
- year: $this.find('select[name="wpProQuiz_field_' + id +'_year"]').val()
731
- };
732
- break;
733
- }
734
- });
735
-
736
- return data;
737
- };
738
- };
739
-
740
- var fetchAllAnswerData = function(resultData) {
741
- $e.find('.wpProQuiz_questionList').each(function() {
742
- var $this = $(this);
743
- var questionId = $this.data('question_id');
744
- var type = $this.data('type');
745
- var data = {};
746
-
747
- if(type == 'single' || type == 'multiple') {
748
- $this.find('.wpProQuiz_questionListItem').each(function() {
749
- data[$(this).data('pos')] = +$(this).find('.wpProQuiz_questionInput').is(':checked');
750
- });
751
- } else if(type == 'free_answer') {
752
- data[0] = $this.find('.wpProQuiz_questionInput').val();
753
- } else if(type == 'sort_answer') {
754
- return true;
755
- // $this.find('.wpProQuiz_questionListItem').each(function() {
756
- // data[$(this).index()] = $(this).data('pos');
757
- // });
758
- } else if(type == 'matrix_sort_answer') {
759
- return true;
760
- // $this.find('.wpProQuiz_questionListItem').each(function() {
761
- // data[$(this).data('pos')] = $(this).find('.wpProQuiz_answerCorrect').length;
762
- // });
763
- } else if(type == 'cloze_answer') {
764
- var i = 0;
765
- $this.find('.wpProQuiz_cloze input').each(function() {
766
- data[i++] = $(this).val();
767
- });
768
- } else if(type == 'assessment_answer') {
769
- data[0] = '';
770
-
771
- $this.find('.wpProQuiz_questionInput:checked').each(function() {
772
- data[$(this).data('index')] = $(this).val();
773
- });
774
- }
775
-
776
- resultData[questionId]['data'] = data;
777
-
778
- });
779
- };
780
-
781
- plugin.methode = {
782
- /**
783
- * @memberOf plugin.methode
784
- */
785
-
786
- parseBitOptions: function() {
787
- if(config.bo) {
788
- bitOptions.randomAnswer = config.bo & (1 << 0);
789
- bitOptions.randomQuestion = config.bo & (1 << 1);
790
- bitOptions.disabledAnswerMark = config.bo & (1 << 2);
791
- bitOptions.checkBeforeStart = config.bo & (1 << 3);
792
- bitOptions.preview = config.bo & (1 << 4);
793
- bitOptions.isAddAutomatic = config.bo & (1 << 6);
794
- bitOptions.reviewQustion = config.bo & ( 1 << 7);
795
- bitOptions.quizSummeryHide = config.bo & (1 << 8);
796
- bitOptions.skipButton = config.bo & (1 << 9);
797
- bitOptions.autoStart = config.bo & (1 << 10);
798
- bitOptions.forcingQuestionSolve = config.bo & (1 << 11);
799
- bitOptions.hideQuestionPositionOverview = config.bo & (1 << 12);
800
- bitOptions.formActivated = config.bo & (1 << 13);
801
- bitOptions.maxShowQuestion = config.bo & (1 << 14);
802
- bitOptions.sortCategories = config.bo & (1 << 15);
803
-
804
- var cors = config.bo & (1 << 5);
805
-
806
- if(cors && jQuery.support != undefined && jQuery.support.cors != undefined && jQuery.support.cors == false) {
807
- bitOptions.cors = cors;
808
- }
809
- }
810
- },
811
-
812
- setClozeStyle: function() {
813
- $e.find('.wpProQuiz_cloze input').each(function() {
814
- var $this = $(this);
815
- var word = "";
816
- var wordLen = $this.data('wordlen');
817
-
818
- for(var i = 0; i < wordLen; i++)
819
- word += "w";
820
-
821
- var clone = $(document.createElement("span"))
822
- .css('visibility', 'hidden')
823
- .text(word)
824
- .appendTo($('body'));
825
-
826
-
827
- var width = clone.width();
828
-
829
- clone.remove();
830
-
831
- $this.width(width + 5);
832
- });
833
- },
834
-
835
- parseTime: function(sec) {
836
- var seconds = parseInt(sec % 60);
837
- var minutes = parseInt((sec / 60) % 60);
838
- var hours = parseInt((sec / 3600) % 24);
839
-
840
- seconds = (seconds > 9 ? '' : '0') + seconds;
841
- minutes = (minutes > 9 ? '' : '0') + minutes;
842
- hours = (hours > 9 ? '' : '0') + hours;
843
-
844
- return hours + ':' + minutes + ':' + seconds;
845
- },
846
-
847
- cleanupCurlyQuotes: function(str) {
848
- str = str.replace(/\u2018/, "'");
849
- str = str.replace(/\u2019/, "'");
850
-
851
- str = str.replace(/\u201C/, '"');
852
- str = str.replace(/\u201D/, '"');
853
-
854
- return $.trim(str).toLowerCase();
855
- },
856
-
857
- resetMatrix: function(selector) {
858
- selector.each(function() {
859
- var $this = $(this);
860
- var $list = $this.find('.wpProQuiz_sortStringList');
861
-
862
- $this.find('.wpProQuiz_sortStringItem').each(function() {
863
- $list.append($(this));
864
- });
865
- });
866
- },
867
-
868
- marker: function(e, correct) {
869
- if(!bitOptions.disabledAnswerMark) {
870
- if(correct) {
871
- e.addClass('wpProQuiz_answerCorrect');
872
- } else {
873
- e.addClass('wpProQuiz_answerIncorrect');
874
- }
875
- }
876
-
877
- },
878
-
879
- startQuiz: function(loadData) {
880
- if(quizStatus.loadLock) {
881
- quizStatus.isQuizStart = 1;
882
-
883
- return;
884
- }
885
-
886
- quizStatus.isQuizStart = 0;
887
-
888
- if(quizStatus.isLocked) {
889
- globalElements.quizStartPage.hide();
890
- $e.find('.wpProQuiz_lock').show();
891
-
892
- return;
893
- }
894
-
895
- if(quizStatus.isPrerequisite) {
896
- globalElements.quizStartPage.hide();
897
- $e.find('.wpProQuiz_prerequisite').show();
898
-
899
- return;
900
- }
901
-
902
- if(quizStatus.isUserStartLocked) {
903
- globalElements.quizStartPage.hide();
904
- $e.find('.wpProQuiz_startOnlyRegisteredUser').show();
905
-
906
- return;
907
- }
908
-
909
- if(bitOptions.maxShowQuestion && !loadData) {
910
- globalElements.quizStartPage.hide();
911
- $e.find('.wpProQuiz_loadQuiz').show();
912
-
913
- plugin.methode.loadQuizDataAjax(true);
914
-
915
- return;
916
- }
917
-
918
- if(bitOptions.formActivated && config.formPos == formPosConst.START) {
919
- if(!formClass.checkForm())
920
- return;
921
- }
922
-
923
- plugin.methode.loadQuizData();
924
-
925
- if(bitOptions.randomQuestion) {
926
- plugin.methode.random(globalElements.questionList);
927
- }
928
-
929
- if(bitOptions.randomAnswer) {
930
- plugin.methode.random($e.find(globalNames.questionList));
931
- }
932
-
933
- if(bitOptions.sortCategories) {
934
- plugin.methode.sortCategories();
935
- }
936
-
937
- plugin.methode.random($e.find('.wpProQuiz_sortStringList'));
938
- plugin.methode.random($e.find('[data-type="sort_answer"]'));
939
-
940
- $e.find('.wpProQuiz_listItem').each(function(i, v) {
941
- var $this = $(this);
942
- $this.find('.wpProQuiz_question_page span:eq(0)').text(i+1);
943
- $this.find('> h5 span').text(i+1);
944
-
945
- $this.find('.wpProQuiz_questionListItem').each(function(i, v) {
946
- $(this).find('> span:not(.wpProQuiz_cloze)').text(i+1 + '. ');
947
- });
948
- });
949
-
950
- globalElements.next = $e.find(globalNames.next);
951
-
952
- switch (config.mode) {
953
- case 3:
954
- $e.find('input[name="checkSingle"]').show();
955
- break;
956
- case 2:
957
- $e.find(globalNames.check).show();
958
-
959
- if(!bitOptions.skipButton && bitOptions.reviewQustion)
960
- $e.find(globalNames.skip).show();
961
-
962
- break;
963
- case 1:
964
- $e.find('input[name="back"]').slice(1).show();
965
- case 0:
966
- globalElements.next.show();
967
- break;
968
- }
969
-
970
- if(bitOptions.hideQuestionPositionOverview || config.mode == 3)
971
- $e.find('.wpProQuiz_question_page').hide();
972
-
973
- //Change last name
974
- var $lastButton = globalElements.next.last();
975
- lastButtonValue = $lastButton.val();
976
- $lastButton.val(config.lbn);
977
-
978
- var $listItem = globalElements.questionList.children();
979
-
980
- globalElements.listItems = $e.find('.wpProQuiz_list > li');
981
-
982
- if(config.mode == 3) {
983
- plugin.methode.showSinglePage(0);
984
- // if(config.qpp) {
985
- // $listItem.slice(0, config.qpp).show();
986
- // $e.find(globalNames.singlePageRight).show();
987
- // $e.find('input[name="checkSingle"]').hide();
988
- // } else {
989
- // $listItem.show();
990
- // }
991
- } else {
992
- currentQuestion = $listItem.eq(0).show();
993
-
994
- var questionId = currentQuestion.find(globalNames.questionList).data('question_id');
995
- questionTimer.questionStart(questionId);
996
- }
997
-
998
- questionTimer.startQuiz();
999
-
1000
- $e.find('.wpProQuiz_sortable').parents('ul').sortable({
1001
- update: function( event, ui ) {
1002
- var $p = $(this).parents('.wpProQuiz_listItem');
1003
-
1004
- $e.trigger({type: 'questionSolved', values: {item: $p, index: $p.index(), solved: true}});
1005
- }
1006
- }).disableSelection();
1007
-
1008
- $e.find('.wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion').sortable({
1009
- connectWith: '.wpProQuiz_maxtrixSortCriterion:not(:has(li)), .wpProQuiz_sortStringList',
1010
- placeholder: 'wpProQuiz_placehold',
1011
- update: function( event, ui ) {
1012
- var $p = $(this).parents('.wpProQuiz_listItem');
1013
-
1014
- $e.trigger({type: 'questionSolved', values: {item: $p, index: $p.index(), solved: true}});
1015
- }
1016
- }).disableSelection();
1017
-
1018
- quizSolved = [];
1019
-
1020
- timelimit.start();
1021
-
1022
- startTime = +new Date();
1023
-
1024
- results = {comp: {points: 0, correctQuestions: 0, quizTime: 0}};
1025
-
1026
- $e.find('.wpProQuiz_questionList').each(function() {
1027
- var questionId = $(this).data('question_id');
1028
-
1029
- results[questionId] = {time: 0, solved: 0};
1030
- });
1031
-
1032
- catResults = {};
1033
-
1034
- $.each(options.catPoints, function(i, v) {
1035
- catResults[i] = 0;
1036
- });
1037
-
1038
- globalElements.quizStartPage.hide();
1039
- $e.find('.wpProQuiz_loadQuiz').hide();
1040
- globalElements.quiz.show();
1041
- reviewBox.show();
1042
-
1043
- if(config.mode != 3) {
1044
- $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1045
- }
1046
- },
1047
-
1048
- showSingleQuestion: function(question) {
1049
- var page = question ? Math.ceil(question / config.qpp) : 1;
1050
-
1051
- this.showSinglePage(page);
1052
-
1053
- // plugin.methode.scrollTo($element, 1);
1054
- },
1055
-
1056
- showSinglePage: function(page) {
1057
- $listItem = globalElements.questionList.children().hide();
1058
-
1059
- if(!config.qpp) {
1060
- $listItem.show();
1061
-
1062
- return;
1063
- }
1064
-
1065
- page = page ? +page : 1;
1066
-
1067
- var maxPage = Math.ceil($e.find('.wpProQuiz_list > li').length / config.qpp);
1068
-
1069
- if(page > maxPage)
1070
- return;
1071
-
1072
- var pl = $e.find(globalNames.singlePageLeft).hide();
1073
- var pr = $e.find(globalNames.singlePageRight).hide();
1074
- var cs = $e.find('input[name="checkSingle"]').hide();
1075
-
1076
- if(page > 1) {
1077
- pl.val(pl.data('text').replace(/%d/, page-1)).show();
1078
- }
1079
-
1080
- if(page == maxPage) {
1081
- cs.show();
1082
- } else {
1083
- pr.val(pr.data('text').replace(/%d/, page+1)).show();
1084
- }
1085
-
1086
- currentPage = page;
1087
-
1088
- var start = config.qpp * (page - 1);
1089
-
1090
- $listItem.slice(start, start + config.qpp).show();
1091
- plugin.methode.scrollTo(globalElements.quiz);
1092
- },
1093
-
1094
- nextQuestion: function() {
1095
- // currentQuestion = currentQuestion.hide().next().show();
1096
- //
1097
- // plugin.methode.scrollTo(globalElements.quiz);
1098
- //
1099
- // $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1100
- //
1101
- // if(!currentQuestion.length) {
1102
- // plugin.methode.showQuizSummary();
1103
- // }
1104
-
1105
- this.showQuestionObject(currentQuestion.next());
1106
- },
1107
-
1108
- prevQuestion: function() {
1109
- // currentQuestion = currentQuestion.hide().prev().show();
1110
- //
1111
- // plugin.methode.scrollTo(globalElements.quiz);
1112
- //
1113
- // $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1114
- //
1115
- this.showQuestionObject(currentQuestion.prev());
1116
- },
1117
-
1118
- showQuestion: function(index) {
1119
- var $element = globalElements.listItems.eq(index);
1120
-
1121
- if(config.mode == 3 || inViewQuestions) {
1122
- if(config.qpp) {
1123
- plugin.methode.showSingleQuestion(index+1);
1124
- // questionTimer.startQuiz();
1125
- // return;
1126
- }
1127
- // plugin.methode.scrollTo($e.find('.wpProQuiz_list > li').eq(index), 1);
1128
- plugin.methode.scrollTo($element, 1);
1129
- questionTimer.startQuiz();
1130
- return;
1131
- }
1132
-
1133
- // currentQuestion.hide();
1134
- //
1135
- // currentQuestion = $element.show();
1136
- //
1137
- // plugin.methode.scrollTo(globalElements.quiz);
1138
- //
1139
- // $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1140
- //
1141
- // if(!currentQuestion.length)
1142
- // plugin.methode.showQuizSummary();
1143
-
1144
- this.showQuestionObject($element);
1145
- },
1146
-
1147
- showQuestionObject: function(obj) {
1148
- if(!obj.length && bitOptions.forcingQuestionSolve && bitOptions.quizSummeryHide && bitOptions.reviewQustion) {
1149
- for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1150
- if(!quizSolved[i]) {
1151
- alert(WpProQuizGlobal.questionsNotSolved);
1152
- return false;
1153
- }
1154
- }
1155
- }
1156
-
1157
- currentQuestion.hide();
1158
-
1159
- currentQuestion = obj.show();
1160
-
1161
- plugin.methode.scrollTo(globalElements.quiz);
1162
-
1163
- $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1164
-
1165
- if(!currentQuestion.length) {
1166
- plugin.methode.showQuizSummary();
1167
- } else {
1168
- var questionId = currentQuestion.find(globalNames.questionList).data('question_id');
1169
- questionTimer.questionStart(questionId);
1170
- }
1171
- },
1172
-
1173
- skipQuestion: function() {
1174
- $e.trigger({type: 'skipQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1175
-
1176
- plugin.methode.nextQuestion();
1177
- },
1178
-
1179
- reviewQuestion: function() {
1180
- $e.trigger({type: 'reviewQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1181
- },
1182
-
1183
- showQuizSummary: function() {
1184
- questionTimer.questionStop();
1185
- questionTimer.stopQuiz();
1186
-
1187
- if(bitOptions.quizSummeryHide || !bitOptions.reviewQustion) {
1188
- if(bitOptions.formActivated && config.formPos == formPosConst.END) {
1189
- reviewBox.hide();
1190
- globalElements.quiz.hide();
1191
- plugin.methode.scrollTo($e.find('.wpProQuiz_infopage').show());
1192
- } else {
1193
- plugin.methode.finishQuiz();
1194
- }
1195
-
1196
- return;
1197
- }
1198
-
1199
- var quizSummary = $e.find('.wpProQuiz_checkPage');
1200
-
1201
- quizSummary.find('ol:eq(0)').empty()
1202
- .append($e.find('.wpProQuiz_reviewQuestion ol li').clone().removeClass('wpProQuiz_reviewQuestionTarget'))
1203
- .children().click(function(e) {
1204
- quizSummary.hide();
1205
- globalElements.quiz.show();
1206
- reviewBox.show(true);
1207
-
1208
- plugin.methode.showQuestion($(this).index());
1209
- });
1210
-
1211
- var cSolved = 0;
1212
-
1213
- for(var i = 0, c = quizSolved.length; i < c; i++) {
1214
- if(quizSolved[i]) {
1215
- cSolved++;
1216
- }
1217
- }
1218
-
1219
- quizSummary.find('span:eq(0)').text(cSolved);
1220
-
1221
- reviewBox.hide();
1222
- globalElements.quiz.hide();
1223
-
1224
- quizSummary.show();
1225
-
1226
- plugin.methode.scrollTo(quizSummary);
1227
- },
1228
-
1229
- finishQuiz: function(timeover) {
1230
- questionTimer.questionStop();
1231
- questionTimer.stopQuiz();
1232
- timelimit.stop();
1233
-
1234
- var time = (+new Date() - startTime) / 1000;
1235
- time = (config.timelimit && time > config.timelimit) ? config.timelimit : time;
1236
-
1237
- $e.find('.wpProQuiz_quiz_time span').text(plugin.methode.parseTime(time));
1238
-
1239
- if(timeover) {
1240
- globalElements.results.find('.wpProQuiz_time_limit_expired').show();
1241
- }
1242
-
1243
- plugin.methode.checkQuestion(globalElements.questionList.children(), true);
1244
-
1245
- $e.find('.wpProQuiz_correct_answer').text(results.comp.correctQuestions);
1246
-
1247
- results.comp.result = Math.round(results.comp.points / config.globalPoints * 100 * 100) / 100;
1248
- results.comp.solved = 0;
1249
-
1250
- //for(var i = 0; i < quizSolved.length; i++)
1251
- // results.comp.solved += quizSolved[i] ? 1 : 0;
1252
-
1253
- var $pointFields = $e.find('.wpProQuiz_points span');
1254
-
1255
- $pointFields.eq(0).text(results.comp.points);
1256
- $pointFields.eq(1).text(config.globalPoints);
1257
- $pointFields.eq(2).text(results.comp.result + '%');
1258
-
1259
- //Result-Text START
1260
- var $resultText = $e.find('.wpProQuiz_resultsList > li').eq(plugin.methode.findResultIndex(results.comp.result));
1261
-
1262
- var formData = formClass.getFormData();
1263
-
1264
- $resultText.find('.wpProQuiz_resultForm').each(function() {
1265
- var $this = $(this);
1266
- var formId = $this.data('form_id');
1267
- var data = formData[formId];
1268
-
1269
- if(typeof data === 'object') {
1270
- data = data['day'] + '-' + data['month'] + '-' + data['year'];
1271
- }
1272
-
1273
- $this.text(data).show();
1274
- });
1275
-
1276
- $resultText.show();
1277
-
1278
- //Result-Text END
1279
-
1280
- plugin.methode.setAverageResult(results.comp.result, false);
1281
-
1282
- this.setCategoryOverview();
1283
-
1284
- plugin.methode.sendCompletedQuiz();
1285
-
1286
- if(bitOptions.isAddAutomatic && toplistData.isUser) {
1287
- plugin.methode.addToplist();
1288
- }
1289
-
1290
- reviewBox.hide();
1291
-
1292
- $e.find('.wpProQuiz_checkPage, .wpProQuiz_infopage').hide();
1293
- globalElements.quiz.hide();
1294
- globalElements.results.show();
1295
-
1296
- plugin.methode.scrollTo(globalElements.results);
1297
- },
1298
-
1299
- setCategoryOverview: function() {
1300
- results.comp.cats = {};
1301
-
1302
- $e.find('.wpProQuiz_catOverview li').each(function() {
1303
- var $this = $(this);
1304
- var catId = $this.data('category_id');
1305
-
1306
- if(config.catPoints[catId] === undefined) {
1307
- $this.hide();
1308
- return true;
1309
- }
1310
-
1311
- var r = Math.round(catResults[catId] / config.catPoints[catId] * 100 * 100) / 100;
1312
-
1313
- results.comp.cats[catId] = r;
1314
-
1315
- $this.find('.wpProQuiz_catPercent').text(r + '%');
1316
-
1317
- $this.show();
1318
- });
1319
- },
1320
-
1321
- questionSolved: function(e) {
1322
- quizSolved[e.values.index] = e.values.solved;
1323
-
1324
- var $questionList = e.values.item.find(globalNames.questionList);
1325
- var data = config.json[$questionList.data('question_id')];
1326
- results[data.id].solved = Number(e.values.fake ? results[data.id].solved : e.values.solved);
1327
- },
1328
-
1329
- sendCompletedQuiz: function() {
1330
- if(bitOptions.preview)
1331
- return;
1332
-
1333
- fetchAllAnswerData(results);
1334
-
1335
- var formData = formClass.getFormData();
1336
-
1337
- plugin.methode.ajax({
1338
- action : 'wp_pro_quiz_completed_quiz',
1339
- quizId : config.quizId,
1340
- results : results,
1341
- forms: formData
1342
- });
1343
- },
1344
-
1345
- findResultIndex: function(p) {
1346
- var r = config.resultsGrade;
1347
- var index = -1;
1348
- var diff = 999999;
1349
-
1350
- for(var i = 0; i < r.length; i++){
1351
- var v = r[i];
1352
-
1353
- if((p >= v) && ((p-v) < diff)) {
1354
- diff = p-v;
1355
- index = i;
1356
- }
1357
- }
1358
-
1359
- return index;
1360
- },
1361
-
1362
- showQustionList: function() {
1363
- inViewQuestions = !inViewQuestions;
1364
- globalElements.toplistShowInButton.hide();
1365
- globalElements.quiz.toggle();
1366
- $e.find('.wpProQuiz_QuestionButton').hide();
1367
- globalElements.questionList.children().show();
1368
- reviewBox.toggle();
1369
-
1370
- $e.find('.wpProQuiz_question_page').hide();
1371
- },
1372
-
1373
- random: function(group) {
1374
- group.each(function() {
1375
- var e = $(this).children().get().sort(function() {
1376
- return Math.round(Math.random()) - 0.5;
1377
- });
1378
-
1379
- $(e).appendTo(e[0].parentNode);
1380
- });
1381
- },
1382
-
1383
- sortCategories: function() {
1384
- var e = $('.wpProQuiz_list').children().get().sort(function(a, b) {
1385
- var aQuestionId = $(a).find('.wpProQuiz_questionList').data('question_id');
1386
- var bQuestionId = $(b).find('.wpProQuiz_questionList').data('question_id');
1387
-
1388
- return config.json[aQuestionId].catId - config.json[bQuestionId].catId;
1389
- });
1390
-
1391
- $(e).appendTo(e[0].parentNode);
1392
- },
1393
-
1394
- restartQuiz: function() {
1395
- globalElements.results.hide();
1396
- globalElements.quizStartPage.show();
1397
- globalElements.questionList.children().hide();
1398
- globalElements.toplistShowInButton.hide();
1399
- reviewBox.hide();
1400
-
1401
- $e.find('.wpProQuiz_questionInput, .wpProQuiz_cloze input').removeAttr('disabled').removeAttr('checked')
1402
- .css('background-color', '');
1403
-
1404
- // $e.find('.wpProQuiz_cloze input').val('');
1405
- $e.find('.wpProQuiz_questionListItem input[type="text"]').val('');
1406
-
1407
- $e.find('.wpProQuiz_answerCorrect, .wpProQuiz_answerIncorrect').removeClass('wpProQuiz_answerCorrect wpProQuiz_answerIncorrect');
1408
-
1409
- $e.find('.wpProQuiz_listItem').data('check', false);
1410
-
1411
- $e.find('.wpProQuiz_response').hide().children().hide();
1412
-
1413
- plugin.methode.resetMatrix($e.find('.wpProQuiz_listItem'));
1414
-
1415
- $e.find('.wpProQuiz_sortStringItem, .wpProQuiz_sortable').removeAttr('style');
1416
-
1417
- $e.find('.wpProQuiz_clozeCorrect, .wpProQuiz_QuestionButton, .wpProQuiz_resultsList > li').hide();
1418
-
1419
- $e.find('.wpProQuiz_question_page, input[name="tip"]').show();
1420
- $e.find('.wpProQuiz_resultForm').text('').hide();
1421
-
1422
- globalElements.results.find('.wpProQuiz_time_limit_expired').hide();
1423
-
1424
- globalElements.next.last().val(lastButtonValue);
1425
-
1426
- inViewQuestions = false;
1427
- },
1428
-
1429
- checkQuestion: function(list, endCheck) {
1430
- list = (list == undefined) ? currentQuestion : list;
1431
-
1432
- list.each(function() {
1433
- var $this = $(this);
1434
- var $questionList = $this.find(globalNames.questionList);
1435
- var data = config.json[$questionList.data('question_id')];
1436
- var name = data.type;
1437
-
1438
- questionTimer.questionStop();
1439
-
1440
- if($this.data('check')) {
1441
- return true;
1442
- }
1443
-
1444
- if(data.type == 'single' || data.type == 'multiple') {
1445
- name = 'singleMulti';
1446
- }
1447
-
1448
- var result = checker(name, data, $this, $questionList);
1449
-
1450
- $this.find('.wpProQuiz_response').show();
1451
- $this.find(globalNames.check).hide();
1452
- $this.find(globalNames.skip).hide();
1453
- $this.find(globalNames.next).show();
1454
-
1455
- results[data.id].points = result.p;
1456
- results[data.id].correct = Number(result.c);
1457
- results[data.id].data = result.s;
1458
-
1459
- results['comp'].points += result.p;
1460
-
1461
- catResults[data.catId] += result.p;
1462
-
1463
- if(result.c) {
1464
- $this.find('.wpProQuiz_correct').show();
1465
- results['comp'].correctQuestions += 1;
1466
- } else {
1467
- $this.find('.wpProQuiz_incorrect').show();
1468
- }
1469
-
1470
- $this.find('.wpProQuiz_responsePoints').text(result.p);
1471
-
1472
- $this.data('check', true);
1473
-
1474
- if(!endCheck)
1475
- $e.trigger({type: 'questionSolved', values: {item: $this, index: $this.index(), solved: true, fake: true}});
1476
- });
1477
- },
1478
-
1479
- showTip: function() {
1480
- var $this = $(this);
1481
- var id = $this.siblings('.wpProQuiz_question').find(globalNames.questionList).data('question_id');
1482
-
1483
- $this.siblings('.wpProQuiz_tipp').toggle('fast');
1484
-
1485
- results[id].tip = 1;
1486
-
1487
- $(document).bind('mouseup.tipEvent', function(e) {
1488
-
1489
- var $tip = $e.find('.wpProQuiz_tipp');
1490
- var $btn = $e.find('input[name="tip"]');
1491
-
1492
- if(!$tip.is(e.target) && $tip.has(e.target).length == 0 && !$btn.is(e.target)) {
1493
- $tip.hide('fast');
1494
- $(document).unbind('.tipEvent');
1495
- }
1496
- });
1497
- },
1498
-
1499
- ajax: function(data, success, dataType) {
1500
- dataType = dataType || 'json';
1501
-
1502
- if(bitOptions.cors) {
1503
- jQuery.support.cors = true;
1504
- }
1505
-
1506
- $.post(WpProQuizGlobal.ajaxurl, data, success, dataType);
1507
-
1508
- if(bitOptions.cors) {
1509
- jQuery.support.cors = false;
1510
- }
1511
- },
1512
-
1513
- checkQuizLock: function() {
1514
-
1515
- quizStatus.loadLock = 1;
1516
-
1517
- plugin.methode.ajax({
1518
- action: 'wp_pro_quiz_check_lock',
1519
- quizId: config.quizId
1520
- }, function(json) {
1521
-
1522
- if(json.lock != undefined) {
1523
- quizStatus.isLocked = json.lock.is;
1524
-
1525
- if(json.lock.pre) {
1526
- $e.find('input[name="restartQuiz"]').hide();
1527
- }
1528
- }
1529
-
1530
- if(json.prerequisite != undefined) {
1531
- quizStatus.isPrerequisite = 1;
1532
- $e.find('.wpProQuiz_prerequisite span').text(json.prerequisite);
1533
- }
1534
-
1535
- if(json.startUserLock != undefined) {
1536
- quizStatus.isUserStartLocked = json.startUserLock;
1537
- }
1538
-
1539
- quizStatus.loadLock = 0;
1540
-
1541
- if(quizStatus.isQuizStart) {
1542
- plugin.methode.startQuiz();
1543
- }
1544
- });
1545
- },
1546
-
1547
- loadQuizData: function() {
1548
- plugin.methode.ajax({
1549
- action: 'wp_pro_quiz_load_quiz_data',
1550
- quizId: config.quizId
1551
- }, function(json) {
1552
- if(json.toplist) {
1553
- plugin.methode.handleToplistData(json.toplist);
1554
- }
1555
-
1556
- if(json.averageResult != undefined) {
1557
- plugin.methode.setAverageResult(json.averageResult, true);
1558
- }
1559
- });
1560
- },
1561
-
1562
- setAverageResult: function(p, g) {
1563
- var v = $e.find('.wpProQuiz_resultValue:eq(' + (g ? 0 : 1) + ') > * ');
1564
-
1565
- v.eq(1).text(p + '%');
1566
- v.eq(0).css('width', (240 * p / 100) + 'px');
1567
- },
1568
-
1569
- handleToplistData: function(json) {
1570
- var $tp = $e.find('.wpProQuiz_addToplist');
1571
- var $addBox = $tp.find('.wpProQuiz_addBox').show().children('div');
1572
-
1573
- if(json.canAdd) {
1574
- $tp.show();
1575
- $tp.find('.wpProQuiz_addToplistMessage').hide();
1576
- $tp.find('.wpProQuiz_toplistButton').show();
1577
-
1578
- toplistData.token = json.token;
1579
- toplistData.isUser = 0;
1580
-
1581
- if(json.userId) {
1582
- $addBox.hide();
1583
- toplistData.isUser = 1;
1584
-
1585
- if(bitOptions.isAddAutomatic) {
1586
- $tp.hide();
1587
- }
1588
- } else {
1589
- $addBox.show();
1590
-
1591
- var $captcha = $addBox.children().eq(1);
1592
-
1593
- if(json.captcha) {
1594
-
1595
- $captcha.find('input[name="wpProQuiz_captchaPrefix"]').val(json.captcha.code);
1596
- $captcha.find('.wpProQuiz_captchaImg').attr('src', json.captcha.img);
1597
- $captcha.find('input[name="wpProQuiz_captcha"]').val('');
1598
-
1599
- $captcha.show();
1600
- } else {
1601
- $captcha.hide();
1602
- }
1603
- }
1604
- } else {
1605
- $tp.hide();
1606
- }
1607
- },
1608
-
1609
- scrollTo: function(e, h) {
1610
- var x = e.offset().top - 100;
1611
-
1612
- if(h || (window.pageYOffset || document.body.scrollTop) > x) {
1613
- $('html,body').animate({scrollTop: x}, 300);
1614
- }
1615
- },
1616
-
1617
- addToplist: function() {
1618
- if(bitOptions.preview)
1619
- return;
1620
-
1621
- var $addToplistMessage = $e.find('.wpProQuiz_addToplistMessage').text(WpProQuizGlobal.loadData).show();
1622
- var $addBox = $e.find('.wpProQuiz_addBox').hide();
1623
-
1624
- plugin.methode.ajax({
1625
- action: 'wp_pro_quiz_add_toplist',
1626
- quizId: config.quizId,
1627
- token: toplistData.token,
1628
- name: $addBox.find('input[name="wpProQuiz_toplistName"]').val(),
1629
- email: $addBox.find('input[name="wpProQuiz_toplistEmail"]').val(),
1630
- captcha: $addBox.find('input[name="wpProQuiz_captcha"]').val(),
1631
- prefix: $addBox.find('input[name="wpProQuiz_captchaPrefix"]').val(),
1632
- points: results.comp.points,
1633
- totalPoints:config.globalPoints
1634
- }, function(json) {
1635
- $addToplistMessage.text(json.text);
1636
-
1637
- if(json.clear) {
1638
- $addBox.hide();
1639
- plugin.methode.updateToplist();
1640
- } else {
1641
- $addBox.show();
1642
- }
1643
-
1644
- if(json.captcha) {
1645
- $addBox.find('.wpProQuiz_captchaImg').attr('src', json.captcha.img);
1646
- $addBox.find('input[name="wpProQuiz_captchaPrefix"]').val(json.captcha.code);
1647
- $addBox.find('input[name="wpProQuiz_captcha"]').val('');
1648
- }
1649
- });
1650
- },
1651
-
1652
- updateToplist: function() {
1653
- if(typeof(wpProQuiz_fetchToplist) == "function") {
1654
- wpProQuiz_fetchToplist();
1655
- }
1656
- },
1657
-
1658
- registerSolved: function() {
1659
- $e.find('.wpProQuiz_questionInput[type="text"]').change(function(e) {
1660
- var $this = $(this);
1661
- var $p = $this.parents('.wpProQuiz_listItem');
1662
- var s = false;
1663
-
1664
- if($this.val() != '') {
1665
- s = true;
1666
- }
1667
-
1668
- $e.trigger({type: 'questionSolved', values: {item: $p, index: $p.index(), solved: s}});
1669
- });
1670
-
1671
- $e.find('.wpProQuiz_questionList[data-type="single"] .wpProQuiz_questionInput, .wpProQuiz_questionList[data-type="assessment_answer"] .wpProQuiz_questionInput').change(function(e) {
1672
- var $this = $(this);
1673
- var $p = $this.parents('.wpProQuiz_listItem');
1674
- var s = this.checked;
1675
-
1676
- $e.trigger({type: 'questionSolved', values: {item: $p, index: $p.index(), solved: s}});
1677
- });
1678
-
1679
- $e.find('.wpProQuiz_cloze input').change(function() {
1680
- var $this = $(this);
1681
- var $p = $this.parents('.wpProQuiz_listItem');
1682
- var s = true;
1683
-
1684
- $p.find('.wpProQuiz_cloze input').each(function() {
1685
- if($(this).val() == '') {
1686
- s = false;
1687
- return false;
1688
- }
1689
- });
1690
-
1691
- $e.trigger({type: 'questionSolved', values: {item: $p, index: $p.index(), solved: s}});
1692
- });
1693
-
1694
- $e.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').change(function(e) {
1695
- var $this = $(this);
1696
- var $p = $this.parents('.wpProQuiz_listItem');
1697
- var c = 0;
1698
-
1699
- $p.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').each(function(e) {
1700
- if(this.checked)
1701
- c++;
1702
- });
1703
-
1704
- $e.trigger({type: 'questionSolved', values: {item: $p, index: $p.index(), solved: (c) ? true : false}});
1705
-
1706
- });
1707
- },
1708
-
1709
- loadQuizDataAjax: function(quizStart) {
1710
- plugin.methode.ajax({
1711
- action: 'wp_pro_quiz_admin_ajax',
1712
- func: 'quizLoadData',
1713
- data: {
1714
- quizId: config.quizId
1715
- }
1716
- }, function(json) {
1717
-
1718
- config.globalPoints = json.globalPoints;
1719
- config.catPoints = json.catPoints;
1720
- config.json = json.json;
1721
-
1722
- globalElements.quiz.remove();
1723
-
1724
- $e.find('.wpProQuiz_quizAnker').after(json.content);
1725
-
1726
- //Reinit globalElements
1727
- globalElements = {
1728
- back: $e.find('input[name="back"]'),
1729
- next: $e.find(globalNames.next),
1730
- quiz: $e.find('.wpProQuiz_quiz'),
1731
- questionList: $e.find('.wpProQuiz_list'),
1732
- results: $e.find('.wpProQuiz_results'),
1733
- quizStartPage: $e.find('.wpProQuiz_text'),
1734
- timelimit: $e.find('.wpProQuiz_time_limit'),
1735
- toplistShowInButton: $e.find('.wpProQuiz_toplistShowInButton'),
1736
- listItems: $()
1737
- };
1738
-
1739
- plugin.methode.initQuiz();
1740
-
1741
- if(quizStart)
1742
- plugin.methode.startQuiz(true);
1743
-
1744
- });
1745
- },
1746
-
1747
- initQuiz: function() {
1748
- plugin.methode.setClozeStyle();
1749
- plugin.methode.registerSolved();
1750
-
1751
- globalElements.next.click(function() {
1752
- if(bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
1753
- && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1754
-
1755
- alert(WpProQuizGlobal.questionNotSolved);
1756
- return false;
1757
- }
1758
-
1759
- plugin.methode.nextQuestion();
1760
- });
1761
-
1762
- globalElements.back.click(function() {
1763
- plugin.methode.prevQuestion();
1764
- });
1765
-
1766
- $e.find(globalNames.check).click(function() {
1767
- if(bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
1768
- && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1769
-
1770
- alert(WpProQuizGlobal.questionNotSolved);
1771
- return false;
1772
- }
1773
-
1774
- plugin.methode.checkQuestion();
1775
- });
1776
-
1777
- $e.find('input[name="checkSingle"]').click(function() {
1778
- if(bitOptions.forcingQuestionSolve && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1779
- for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1780
- if(!quizSolved[i]) {
1781
- alert(WpProQuizGlobal.questionsNotSolved);
1782
- return false;
1783
- }
1784
- }
1785
- }
1786
-
1787
- plugin.methode.showQuizSummary();
1788
- });
1789
-
1790
- $e.find('input[name="tip"]').click(plugin.methode.showTip);
1791
- $e.find('input[name="skip"]').click(plugin.methode.skipQuestion);
1792
-
1793
- $e.find('input[name="wpProQuiz_pageLeft"]').click(function() {
1794
- plugin.methode.showSinglePage(currentPage-1);
1795
- });
1796
-
1797
- $e.find('input[name="wpProQuiz_pageRight"]').click(function() {
1798
- plugin.methode.showSinglePage(currentPage+1);
1799
- });
1800
- }
1801
- };
1802
-
1803
- // /**
1804
- // * @memberOf plugin
1805
- // */
1806
- // plugin.init = function() {
1807
- // //
1808
- // plugin.methode.setClozeStyle();
1809
- // //
1810
- // plugin.methode.registerSolved();
1811
- //
1812
- //
1813
- // reviewBox.init();
1814
- //
1815
- // if(bitOptions.checkBeforeStart && !bitOptions.preview) {
1816
- // plugin.methode.checkQuizLock();
1817
- // }
1818
- //
1819
- // $e.find('input[name="startQuiz"]').click(function() {
1820
- // plugin.methode.startQuiz();
1821
- // return false;
1822
- // });
1823
- //
1824
- // //
1825
- // globalElements.next.click(function() {
1826
- // if(bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
1827
- // && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1828
- //
1829
- // alert(WpProQuizGlobal.questionNotSolved);
1830
- // return false;
1831
- // }
1832
- //
1833
- // plugin.methode.nextQuestion();
1834
- // });
1835
- //
1836
- // //
1837
- // globalElements.back.click(function() {
1838
- // plugin.methode.prevQuestion();
1839
- // });
1840
- //
1841
- // $e.find('input[name="reShowQuestion"]').click(function() {
1842
- // plugin.methode.showQustionList();
1843
- // });
1844
- //
1845
- // $e.find('input[name="restartQuiz"]').click(function() {
1846
- // plugin.methode.restartQuiz();
1847
- // });
1848
- //
1849
- // //
1850
- // $e.find(globalNames.check).click(function() {
1851
- // if(bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
1852
- // && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1853
- //
1854
- // alert(WpProQuizGlobal.questionNotSolved);
1855
- // return false;
1856
- // }
1857
- //
1858
- // plugin.methode.checkQuestion();
1859
- // });
1860
- //
1861
- // //
1862
- // $e.find('input[name="checkSingle"]').click(function() {
1863
- // if(bitOptions.forcingQuestionSolve && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1864
- // for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1865
- // if(!quizSolved[i]) {
1866
- // alert(WpProQuizGlobal.questionsNotSolved);
1867
- // return false;
1868
- // }
1869
- // }
1870
- // }
1871
- //
1872
- // plugin.methode.showQuizSummary();
1873
- // });
1874
- //
1875
- // //
1876
- // $e.find('input[name="tip"]').click(plugin.methode.showTip);
1877
- //
1878
- // //
1879
- // $e.find('input[name="skip"]').click(plugin.methode.skipQuestion);
1880
- //
1881
- // $e.find('input[name="review"]').click(plugin.methode.reviewQuestion);
1882
- //
1883
- // $e.find('input[name="wpProQuiz_toplistAdd"]').click(plugin.methode.addToplist);
1884
- //
1885
- // $e.find('input[name="quizSummary"]').click(plugin.methode.showQuizSummary);
1886
- //
1887
- // $e.find('input[name="endQuizSummary"]').click(function() {
1888
- // if(bitOptions.forcingQuestionSolve) {
1889
- // for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1890
- // if(!quizSolved[i]) {
1891
- // alert(WpProQuizGlobal.questionsNotSolved);
1892
- // return false;
1893
- // }
1894
- // }
1895
- // }
1896
- //
1897
- // if(bitOptions.formActivated && config.formPos == formPosConst.END && !formClass.checkForm())
1898
- // return;
1899
- //
1900
- // plugin.methode.finishQuiz();
1901
- // });
1902
- //
1903
- // $e.find('input[name="endInfopage"]').click(function() {
1904
- // if(formClass.checkForm())
1905
- // plugin.methode.finishQuiz();
1906
- // });
1907
- //
1908
- // $e.find('input[name="showToplist"]').click(function() {
1909
- // globalElements.quiz.hide();
1910
- // globalElements.toplistShowInButton.toggle();
1911
- // });
1912
- //
1913
- // //
1914
- // $e.find('input[name="wpProQuiz_pageLeft"]').click(function() {
1915
- // plugin.methode.showSinglePage(currentPage-1);
1916
- // });
1917
- //
1918
- // //
1919
- // $e.find('input[name="wpProQuiz_pageRight"]').click(function() {
1920
- // plugin.methode.showSinglePage(currentPage+1);
1921
- // });
1922
- //
1923
- // $e.bind('questionSolved', plugin.methode.questionSolved);
1924
- // };
1925
-
1926
- /**
1927
- * @memberOf plugin
1928
- */
1929
- plugin.preInit = function() {
1930
- plugin.methode.parseBitOptions();
1931
- reviewBox.init();
1932
-
1933
- $e.find('input[name="startQuiz"]').click(function() {
1934
- plugin.methode.startQuiz();
1935
- return false;
1936
- });
1937
-
1938
- if(bitOptions.checkBeforeStart && !bitOptions.preview) {
1939
- plugin.methode.checkQuizLock();
1940
- }
1941
-
1942
- $e.find('input[name="reShowQuestion"]').click(function() {
1943
- plugin.methode.showQustionList();
1944
- });
1945
-
1946
- $e.find('input[name="restartQuiz"]').click(function() {
1947
- plugin.methode.restartQuiz();
1948
- });
1949
-
1950
-
1951
- $e.find('input[name="review"]').click(plugin.methode.reviewQuestion);
1952
-
1953
- $e.find('input[name="wpProQuiz_toplistAdd"]').click(plugin.methode.addToplist);
1954
-
1955
- $e.find('input[name="quizSummary"]').click(plugin.methode.showQuizSummary);
1956
-
1957
- $e.find('input[name="endQuizSummary"]').click(function() {
1958
- if(bitOptions.forcingQuestionSolve) {
1959
- for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1960
- if(!quizSolved[i]) {
1961
- alert(WpProQuizGlobal.questionsNotSolved);
1962
- return false;
1963
- }
1964
- }
1965
- }
1966
-
1967
- if(bitOptions.formActivated && config.formPos == formPosConst.END && !formClass.checkForm())
1968
- return;
1969
-
1970
- plugin.methode.finishQuiz();
1971
- });
1972
-
1973
- $e.find('input[name="endInfopage"]').click(function() {
1974
- if(formClass.checkForm())
1975
- plugin.methode.finishQuiz();
1976
- });
1977
-
1978
- $e.find('input[name="showToplist"]').click(function() {
1979
- globalElements.quiz.hide();
1980
- globalElements.toplistShowInButton.toggle();
1981
- });
1982
-
1983
- $e.bind('questionSolved', plugin.methode.questionSolved);
1984
-
1985
- if(!bitOptions.maxShowQuestion) {
1986
- plugin.methode.initQuiz();
1987
- }
1988
-
1989
- if(bitOptions.autoStart)
1990
- plugin.methode.startQuiz();
1991
- };
1992
-
1993
- plugin.preInit();
1994
- };
1995
-
1996
- $.fn.wpProQuizFront = function(options) {
1997
- return this.each(function() {
1998
- if(undefined == $(this).data('wpProQuizFront')) {
1999
- $(this).data('wpProQuizFront', new $.wpProQuizFront(this, options));
2000
- }
2001
- });
2002
- };
2003
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2004
  })(jQuery);
1
+ //wpProQuizReady = jQuery.noop;
2
+
3
+ /**
4
+ * Source: https://github.com/jfriend00/docReady
5
+ */
6
+ (function(funcName, baseObj) {
7
+ // The public function name defaults to window.wpProQuizReady
8
+ // but you can pass in your own object and own function name and those will be used
9
+ // if you want to put them in a different namespace
10
+ funcName = funcName || "wpProQuizReady";
11
+ baseObj = baseObj || window;
12
+ var readyList = [];
13
+ var readyFired = false;
14
+ var readyEventHandlersInstalled = false;
15
+
16
+ // call this when the document is ready
17
+ // this function protects itself against being called more than once
18
+ function ready() {
19
+ if (!readyFired) {
20
+ // this must be set to true before we start calling callbacks
21
+ readyFired = true;
22
+ for (var i = 0; i < readyList.length; i++) {
23
+ // if a callback here happens to add new ready handlers,
24
+ // the wpProQuizReady() function will see that it already fired
25
+ // and will schedule the callback to run right after
26
+ // this event loop finishes so all handlers will still execute
27
+ // in order and no new ones will be added to the readyList
28
+ // while we are processing the list
29
+ readyList[i].fn.call(window, readyList[i].ctx);
30
+ }
31
+ // allow any closures held by these functions to free
32
+ readyList = [];
33
+ }
34
+ }
35
+
36
+ function readyStateChange() {
37
+ if ( document.readyState === "complete" ) {
38
+ ready();
39
+ }
40
+ }
41
+
42
+ // This is the one public interface
43
+ // wpProQuizReady(fn, context);
44
+ // the context argument is optional - if present, it will be passed
45
+ // as an argument to the callback
46
+ baseObj[funcName] = function(callback, context) {
47
+ // if ready has already fired, then just schedule the callback
48
+ // to fire asynchronously, but right away
49
+ if (readyFired) {
50
+ setTimeout(function() {callback(context);}, 1);
51
+ return;
52
+ } else {
53
+ // add the function and context to the list
54
+ readyList.push({fn: callback, ctx: context});
55
+ }
56
+ // if document already ready to go, schedule the ready function to run
57
+ if (document.readyState === "complete") {
58
+ setTimeout(ready, 1);
59
+ } else if (!readyEventHandlersInstalled) {
60
+ // otherwise if we don't have event handlers installed, install them
61
+ if (document.addEventListener) {
62
+ // first choice is DOMContentLoaded event
63
+ document.addEventListener("DOMContentLoaded", ready, false);
64
+ // backup is window load event
65
+ window.addEventListener("load", ready, false);
66
+ } else {
67
+ // must be IE
68
+ document.attachEvent("onreadystatechange", readyStateChange);
69
+ window.attachEvent("onload", ready);
70
+ }
71
+ readyEventHandlersInstalled = true;
72
+ }
73
+ }
74
+ })("wpProQuizReady", window);
75
+
76
+ wpProQuizReady(function () {
77
+ var r = window.wpProQuizInitList || [];
78
+
79
+ for(var i = 0; i < r.length; i++) {
80
+ jQuery(r[i].id).wpProQuizFront(r[i].init);
81
+ }
82
+ });
83
+
84
+ (function ($) {
85
+ /**
86
+ * @memberOf $
87
+ */
88
+ $.wpProQuizFront = function (element, options) {
89
+
90
+ var $e = $(element);
91
+ var config = options;
92
+ var plugin = this;
93
+ var results = new Object();
94
+ var catResults = new Object();
95
+ var startTime = 0;
96
+ var currentQuestion = null;
97
+ var quizSolved = [];
98
+ var lastButtonValue = "";
99
+ var inViewQuestions = false;
100
+ var currentPage = 1;
101
+
102
+ var bitOptions = {
103
+ randomAnswer: 0,
104
+ randomQuestion: 0,
105
+ disabledAnswerMark: 0,
106
+ checkBeforeStart: 0,
107
+ preview: 0,
108
+ cors: 0,
109
+ isAddAutomatic: 0,
110
+ quizSummeryHide: 0,
111
+ skipButton: 0,
112
+ reviewQustion: 0,
113
+ autoStart: 0,
114
+ forcingQuestionSolve: 0,
115
+ hideQuestionPositionOverview: 0,
116
+ formActivated: 0,
117
+ maxShowQuestion: 0,
118
+ sortCategories: 0
119
+ };
120
+
121
+ var quizStatus = {
122
+ isQuizStart: 0,
123
+ isLocked: 0,
124
+ loadLock: 0,
125
+ isPrerequisite: 0,
126
+ isUserStartLocked: 0
127
+ };
128
+
129
+ var globalNames = {
130
+ check: 'input[name="check"]',
131
+ next: 'input[name="next"]',
132
+ questionList: '.wpProQuiz_questionList',
133
+ skip: 'input[name="skip"]',
134
+ singlePageLeft: 'input[name="wpProQuiz_pageLeft"]',
135
+ singlePageRight: 'input[name="wpProQuiz_pageRight"]'
136
+ };
137
+
138
+ var globalElements = {
139
+ back: $e.find('input[name="back"]'),
140
+ next: $e.find(globalNames.next),
141
+ quiz: $e.find('.wpProQuiz_quiz'),
142
+ questionList: $e.find('.wpProQuiz_list'),
143
+ results: $e.find('.wpProQuiz_results'),
144
+ quizStartPage: $e.find('.wpProQuiz_text'),
145
+ timelimit: $e.find('.wpProQuiz_time_limit'),
146
+ toplistShowInButton: $e.find('.wpProQuiz_toplistShowInButton'),
147
+ listItems: $()
148
+ };
149
+
150
+ var toplistData = {
151
+ token: '',
152
+ isUser: 0
153
+ };
154
+
155
+ var formPosConst = {
156
+ START: 0,
157
+ END: 1
158
+ };
159
+
160
+ /**
161
+ * @memberOf timelimit
162
+ */
163
+ var timelimit = (function () {
164
+ var _counter = config.timelimit;
165
+ var _intervalId = 0;
166
+ var instance = {};
167
+
168
+ instance.stop = function () {
169
+ if (_counter) {
170
+ window.clearInterval(_intervalId);
171
+ globalElements.timelimit.hide();
172
+ }
173
+ };
174
+
175
+ instance.start = function () {
176
+ if (!_counter)
177
+ return;
178
+
179
+ var x = _counter * 1000;
180
+
181
+ var $timeText = globalElements.timelimit.find('span').text(plugin.methode.parseTime(_counter));
182
+ var $timeDiv = globalElements.timelimit.find('.wpProQuiz_progress');
183
+
184
+ globalElements.timelimit.show();
185
+
186
+ var beforeTime = +new Date();
187
+
188
+ _intervalId = window.setInterval(function () {
189
+
190
+ var diff = (+new Date() - beforeTime);
191
+ var elapsedTime = x - diff;
192
+
193
+ if (diff >= 500) {
194
+ $timeText.text(plugin.methode.parseTime(Math.ceil(elapsedTime / 1000)));
195
+ }
196
+
197
+ $timeDiv.css('width', (elapsedTime / x * 100) + '%');
198
+
199
+ if (elapsedTime <= 0) {
200
+ instance.stop();
201
+ plugin.methode.finishQuiz(true);
202
+ }
203
+
204
+ }, 16);
205
+ };
206
+
207
+ return instance;
208
+
209
+ })();
210
+
211
+ /**
212
+ * @memberOf reviewBox
213
+ */
214
+ var reviewBox = new function () {
215
+
216
+ var $contain = [], $cursor = [], $list = [], $items = [];
217
+ var x = 0, offset = 0, diff = 0, top = 0, max = 0;
218
+ var itemsStatus = [];
219
+
220
+ this.init = function () {
221
+ $contain = $e.find('.wpProQuiz_reviewQuestion');
222
+ $cursor = $contain.find('div');
223
+ $list = $contain.find('ol');
224
+ $items = $list.children();
225
+
226
+ $cursor.mousedown(function (e) {
227
+ e.preventDefault();
228
+ e.stopPropagation();
229
+
230
+ offset = e.pageY - $cursor.offset().top + top;
231
+
232
+ $(document).bind('mouseup.scrollEvent', endScroll);
233
+ $(document).bind('mousemove.scrollEvent', moveScroll);
234
+
235
+ });
236
+
237
+ $items.click(function (e) {
238
+ plugin.methode.showQuestion($(this).index());
239
+ });
240
+
241
+ $e.bind('questionSolved', function (e) {
242
+ itemsStatus[e.values.index].solved = e.values.solved;
243
+ setColor(e.values.index);
244
+ });
245
+
246
+ $e.bind('changeQuestion', function (e) {
247
+ $items.removeClass('wpProQuiz_reviewQuestionTarget');
248
+
249
+ $items.eq(e.values.index).addClass('wpProQuiz_reviewQuestionTarget');
250
+
251
+ scroll(e.values.index);
252
+ });
253
+
254
+ $e.bind('reviewQuestion', function (e) {
255
+ itemsStatus[e.values.index].review = !itemsStatus[e.values.index].review;
256
+ setColor(e.values.index);
257
+ });
258
+
259
+ $contain.bind('mousewheel DOMMouseScroll', function (e) {
260
+ e.preventDefault();
261
+
262
+ var ev = e.originalEvent;
263
+ var w = ev.wheelDelta ? -ev.wheelDelta / 120 : ev.detail / 3;
264
+ var plus = 20 * w;
265
+
266
+ var x = top - $list.offset().top + plus;
267
+
268
+ if (x > max)
269
+ x = max;
270
+
271
+ if (x < 0)
272
+ x = 0;
273
+
274
+ var o = x / diff;
275
+
276
+ $list.attr('style', 'margin-top: ' + (-x) + 'px !important');
277
+ $cursor.css({top: o});
278
+
279
+ return false;
280
+ });
281
+ };
282
+
283
+ this.show = function (save) {
284
+ if (bitOptions.reviewQustion)
285
+ $contain.parent().show();
286
+
287
+ $e.find('.wpProQuiz_reviewDiv .wpProQuiz_button2').show();
288
+
289
+ if (save)
290
+ return;
291
+
292
+ $list.attr('style', 'margin-top: 0px !important');
293
+ $cursor.css({top: 0});
294
+
295
+ var h = $list.outerHeight();
296
+ var c = $contain.height();
297
+ x = c - $cursor.height();
298
+ offset = 0;
299
+ max = h - c;
300
+ diff = max / x;
301
+
302
+ this.reset();
303
+
304
+ if (h > 100) {
305
+ $cursor.show();
306
+ }
307
+
308
+ top = $cursor.offset().top;
309
+ };
310
+
311
+ this.hide = function () {
312
+ $contain.parent().hide();
313
+ };
314
+
315
+ this.toggle = function () {
316
+ if (bitOptions.reviewQustion) {
317
+ $contain.parent().toggle();
318
+ $items.removeClass('wpProQuiz_reviewQuestionTarget');
319
+ $e.find('.wpProQuiz_reviewDiv .wpProQuiz_button2').hide();
320
+
321
+ $list.attr('style', 'margin-top: 0px !important');
322
+ $cursor.css({top: 0});
323
+
324
+ var h = $list.outerHeight();
325
+ var c = $contain.height();
326
+ x = c - $cursor.height();
327
+ offset = 0;
328
+ max = h - c;
329
+ diff = max / x;
330
+
331
+ if (h > 100) {
332
+ $cursor.show();
333
+ }
334
+
335
+ top = $cursor.offset().top;
336
+ }
337
+ };
338
+
339
+ this.reset = function () {
340
+ for (var i = 0, c = $items.length; i < c; i++) {
341
+ itemsStatus[i] = {};
342
+ }
343
+
344
+ $items.removeClass('wpProQuiz_reviewQuestionTarget').css('background-color', '');
345
+ };
346
+
347
+ function scroll(index) {
348
+ var $item = $items.eq(index);
349
+ var iTop = $item.offset().top;
350
+ var cTop = $contain.offset().top;
351
+ var calc = iTop - cTop;
352
+
353
+ if ((calc - 4) < 0 || (calc + 32) > 100) {
354
+ var x = cTop - $items.eq(0).offset().top - (cTop - $list.offset().top) + $item.position().top;
355
+
356
+ if (x > max)
357
+ x = max;
358
+
359
+ var o = x / diff;
360
+
361
+ $list.attr('style', 'margin-top: ' + (-x) + 'px !important');
362
+ $cursor.css({top: o});
363
+ }
364
+ }
365
+
366
+ function setColor(index) {
367
+ var color = '';
368
+ var itemStatus = itemsStatus[index];
369
+
370
+ if (itemStatus.review) {
371
+ color = '#FFB800';
372
+ } else if (itemStatus.solved) {
373
+ color = '#6CA54C';
374
+ }
375
+
376
+ $items.eq(index).css('background-color', color);
377
+ }
378
+
379
+ function moveScroll(e) {
380
+ e.preventDefault();
381
+
382
+ var o = e.pageY - offset;
383
+
384
+ if (o < 0)
385
+ o = 0;
386
+
387
+ if (o > x)
388
+ o = x;
389
+
390
+ var v = diff * o;
391
+
392
+ $list.attr('style', 'margin-top: ' + (-v) + 'px !important');
393
+
394
+ $cursor.css({top: o});
395
+ }
396
+
397
+ function endScroll(e) {
398
+ e.preventDefault();
399
+
400
+ $(document).unbind('.scrollEvent');
401
+ }
402
+ };
403
+
404
+ function QuestionTimer() {
405
+ var questionStartTime = 0;
406
+ var currentQuestionId = -1;
407
+
408
+ var quizStartTimer = 0;
409
+ var isQuizStart = false;
410
+
411
+ this.questionStart = function (questionId) {
412
+ if (currentQuestionId != -1)
413
+ this.questionStop();
414
+
415
+ currentQuestionId = questionId;
416
+ questionStartTime = +new Date();
417
+ };
418
+
419
+ this.questionStop = function () {
420
+ if (currentQuestionId == -1)
421
+ return;
422
+
423
+ results[currentQuestionId].time += Math.round((new Date() - questionStartTime) / 1000);
424
+
425
+ currentQuestionId = -1;
426
+ };
427
+
428
+ this.startQuiz = function () {
429
+ if (isQuizStart)
430
+ this.stopQuiz();
431
+
432
+ quizStartTimer = +new Date();
433
+ isQuizStart = true;
434
+ };
435
+
436
+ this.stopQuiz = function () {
437
+ if (!isQuizStart)
438
+ return;
439
+
440
+ results['comp'].quizTime += Math.round((new Date() - quizStartTimer) / 1000);
441
+ isQuizStart = false;
442
+ };
443
+
444
+ this.init = function () {
445
+
446
+ };
447
+
448
+ };
449
+
450
+ var questionTimer = new QuestionTimer();
451
+
452
+ /**
453
+ * @memberOf checker
454
+ */
455
+ var checker = function (name, data, $question, $questionList) {
456
+ var correct = true;
457
+ var points = 0;
458
+ var isDiffPoints = $.isArray(data.points);
459
+ var statistcAnswerData = {};
460
+
461
+ var func = {
462
+ singleMulti: function () {
463
+ var input = $questionList.find('.wpProQuiz_questionInput').attr('disabled', 'disabled');
464
+ var isDiffMode = data.diffMode;
465
+
466
+ $questionList.children().each(function (i) {
467
+ var $item = $(this);
468
+ var index = $item.data('pos');
469
+ var checked = input.eq(i).is(':checked');
470
+
471
+ if (data.correct[index]) {
472
+ if (!checked) {
473
+ correct = false;
474
+ } else {
475
+ if (isDiffPoints) {
476
+ if (isDiffMode)
477
+ points = data.points[index];
478
+ else
479
+ points += data.points[index];
480
+ }
481
+ }
482
+
483
+ if (data.disCorrect) {
484
+ correct = true;
485
+ } else {
486
+ plugin.methode.marker($item, true);
487
+ }
488
+
489
+ } else {
490
+ if (checked) {
491
+ if (!data.disCorrect) {
492
+ plugin.methode.marker($item, false);
493
+ correct = false;
494
+ } else {
495
+ correct = true;
496
+ }
497
+
498
+ if (isDiffMode)
499
+ points = data.points[index];
500
+ } else {
501
+ if (isDiffPoints && !isDiffMode) {
502
+ points += data.points[index];
503
+ }
504
+ }
505
+ }
506
+ });
507
+ },
508
+
509
+ sort_answer: function () {
510
+ var $items = $questionList.children();
511
+
512
+ $items.each(function (i, v) {
513
+ var $this = $(this);
514
+
515
+ statistcAnswerData[i] = $this.data('pos');
516
+
517
+ if (i == $this.data('pos')) {
518
+ plugin.methode.marker($this, true);
519
+
520
+ if (isDiffPoints) {
521
+ points += data.points[i];
522
+ }
523
+ } else {
524
+ plugin.methode.marker($this, false);
525
+ correct = false;
526
+ }
527
+ });
528
+
529
+ $items.children().css({
530
+ 'box-shadow': '0 0',
531
+ 'cursor': 'auto'
532
+ });
533
+
534
+ $questionList.sortable("destroy");
535
+
536
+ $items.sort(function (a, b) {
537
+ return $(a).data('pos') > $(b).data('pos') ? 1 : -1;
538
+ });
539
+
540
+ $questionList.append($items);
541
+ },
542
+
543
+ matrix_sort_answer: function () {
544
+ var $items = $questionList.children();
545
+ var matrix = new Array();
546
+ statistcAnswerData = {0: -1};
547
+
548
+ $items.each(function () {
549
+ var $this = $(this);
550
+ var i = $this.data('pos');
551
+ var $stringUl = $this.find('.wpProQuiz_maxtrixSortCriterion');
552
+ var $stringItem = $stringUl.children();
553
+
554
+ if ($stringItem.length)
555
+ statistcAnswerData[i] = $stringItem.data('pos');
556
+
557
+ if ($stringItem.length && $.inArray(String(i), String($stringItem.data('correct')).split(',')) >= 0) {
558
+ // if(i == $stringItem.data('pos')) {
559
+ plugin.methode.marker($stringUl, true);
560
+
561
+ if (isDiffPoints) {
562
+ points += data.points[i];
563
+ }
564
+ } else {
565
+ correct = false;
566
+ plugin.methode.marker($stringUl, false);
567
+ }
568
+
569
+ matrix[i] = $stringUl;
570
+ });
571
+
572
+ plugin.methode.resetMatrix($question);
573
+
574
+ $question.find('.wpProQuiz_sortStringItem').each(function () {
575
+ var x = matrix[$(this).data('pos')];
576
+ if (x != undefined)
577
+ x.append(this);
578
+ }).css({
579
+ 'box-shadow': '0 0',
580
+ 'cursor': 'auto'
581
+ });
582
+
583
+ $question.find('.wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion').sortable("destroy");
584
+ },
585
+
586
+ free_answer: function () {
587
+ var $li = $questionList.children();
588
+ var value = $li.find('.wpProQuiz_questionInput').attr('disabled', 'disabled').val();
589
+
590
+ if ($.inArray($.trim(value).toLowerCase(), data.correct) >= 0) {
591
+ plugin.methode.marker($li, true);
592
+ } else {
593
+ plugin.methode.marker($li, false);
594
+ correct = false;
595
+ }
596
+ },
597
+
598
+ cloze_answer: function () {
599
+ $questionList.find('.wpProQuiz_cloze').each(function (i, v) {
600
+ var $this = $(this);
601
+ var cloze = $this.children();
602
+ var input = cloze.eq(0);
603
+ var span = cloze.eq(1);
604
+ var inputText = plugin.methode.cleanupCurlyQuotes(input.val());
605
+
606
+ if ($.inArray(inputText, data.correct[i]) >= 0) {
607
+ if (isDiffPoints) {
608
+ points += data.points[i];
609
+ }
610
+
611
+ if (!bitOptions.disabledAnswerMark) {
612
+ input.css('background-color', '#B0DAB0');
613
+ }
614
+ } else {
615
+ if (!bitOptions.disabledAnswerMark) {
616
+ input.css('background-color', '#FFBABA');
617
+ }
618
+
619
+ correct = false;
620
+
621
+ span.show();
622
+ }
623
+
624
+ input.attr('disabled', 'disabled');
625
+ });
626
+ },
627
+
628
+ assessment_answer: function () {
629
+ correct = true;
630
+ var $input = $questionList.find('.wpProQuiz_questionInput').attr('disabled', 'disabled');
631
+ var val = 0;
632
+
633
+ $input.filter(':checked').each(function () {
634
+ val += parseInt($(this).val());
635
+ });
636
+
637
+ points = val;
638
+ }
639
+ };
640
+
641
+ func[name]();
642
+
643
+ if (!isDiffPoints && correct) {
644
+ points = data.points;
645
+ }
646
+
647
+ return {
648
+ c: correct,
649
+ p: points,
650
+ s: statistcAnswerData
651
+ };
652
+ };
653
+
654
+ /**
655
+ * @memberOf formClass
656
+ */
657
+ var formClass = new function () {
658
+ var funcs = {
659
+ isEmpty: function (str) {
660
+ str = $.trim(str);
661
+ return (!str || 0 === str.length);
662
+ }
663
+
664
+ // testValidate: function(str, type) {
665
+ // switch (type) {
666
+ // case 0: //None
667
+ // return true;
668
+ // case 1: //Text
669
+ // return !funcs.isEmpty(str);
670
+ // case 2: //Number
671
+ // return !isNaN(str);
672
+ // case 3: //E-Mail
673
+ // return new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)
674
+ // .test($.trim(str));
675
+ // }
676
+ // }
677
+ };
678
+
679
+ var typeConst = {
680
+ TEXT: 0,
681
+ TEXTAREA: 1,
682
+ NUMBER: 2,
683
+ CHECKBOX: 3,
684
+ EMAIL: 4,
685
+ YES_NO: 5,
686
+ DATE: 6,
687
+ SELECT: 7,
688
+ RADIO: 8
689
+ };
690
+
691
+ this.checkForm = function () {
692
+ var check = true;
693
+
694
+ $e.find('.wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select').each(function () {
695
+ var $this = $(this);
696
+ var isRequired = $this.data('required') == 1;
697
+ var type = $this.data('type');
698
+ var test = true;
699
+ var value = $.trim($this.val());
700
+
701
+ switch (type) {
702
+ case typeConst.TEXT:
703
+ case typeConst.TEXTAREA:
704
+ case typeConst.SELECT:
705
+ if (isRequired)
706
+ test = !funcs.isEmpty(value);
707
+
708
+ break;
709
+ case typeConst.NUMBER:
710
+ if (isRequired || !funcs.isEmpty(value))
711
+ test = !funcs.isEmpty(value) && !isNaN(value);
712
+
713
+ break;
714
+ case typeConst.EMAIL:
715
+ if (isRequired || !funcs.isEmpty(value))
716
+ test = !funcs.isEmpty(value) && new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)
717
+ .test(value);
718
+
719
+ break;
720
+ case typeConst.CHECKBOX:
721
+ if (isRequired)
722
+ test = $this.is(':checked');
723
+
724
+ break;
725
+ case typeConst.YES_NO:
726
+ case typeConst.RADIO:
727
+ if (isRequired)
728
+ test = $this.find('input[type="radio"]:checked').val() !== undefined;
729
+ break;
730
+ case typeConst.DATE:
731
+ var num = 0, co = 0;
732
+
733
+ $this.find('select').each(function () {
734
+ num++;
735
+ co += funcs.isEmpty($(this).val()) ? 0 : 1;
736
+ });
737
+
738
+ if (isRequired || co > 0)
739
+ test = num == co;
740
+
741
+ break;
742
+ }
743
+
744
+ if (test) {
745
+ $this.siblings('.wpProQuiz_invalidate').hide();
746
+ } else {
747
+ check = false;
748
+ $this.siblings('.wpProQuiz_invalidate').show();
749
+ }
750
+
751
+ });
752
+
753
+ // $('.wpProQuiz_forms input, .wpProQuiz_forms textarea').each(function() {
754
+ // var $this = $(this);
755
+ // var isRequired = $this.data('required') == 1;
756
+ // var validate = $this.data('validate') & 0xFF;
757
+ // var test = false;
758
+ // var $infos = $this.parents('div:eq(0)').find('.wpProQuiz_invalidate');
759
+ //
760
+ // if(isRequired) {
761
+ // if($this.attr('type') == 'checkbox') {
762
+ // if($this.is(':checked'))
763
+ // test = true;
764
+ //
765
+ // } else {
766
+ // if(!funcs.isEmpty($this.val()))
767
+ // test = true;
768
+ // }
769
+ //
770
+ // if(!test) {
771
+ // check = false;
772
+ // $infos.eq(0).show();
773
+ // } else {
774
+ // $infos.eq(0).hide();
775
+ // }
776
+ // }
777
+ //
778
+ // if(!funcs.testValidate($this.val(), validate)) {
779
+ // check = false;
780
+ // $infos.eq(1).show();
781
+ // } else {
782
+ // $infos.eq(1).hide();
783
+ // }
784
+ //
785
+ // });
786
+
787
+ // if(!check)
788
+ // alert(WpProQuizGlobal.fieldsNotFilled);
789
+ //
790
+ return check;
791
+ };
792
+
793
+ this.getFormData = function () {
794
+ var data = {};
795
+
796
+ $e.find('.wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select').each(function () {
797
+ var $this = $(this);
798
+ var id = $this.data('form_id');
799
+ var type = $this.data('type');
800
+
801
+ switch (type) {
802
+ case typeConst.TEXT:
803
+ case typeConst.TEXTAREA:
804
+ case typeConst.SELECT:
805
+ case typeConst.NUMBER:
806
+ case typeConst.EMAIL:
807
+ data[id] = $this.val();
808
+ break;
809
+ case typeConst.CHECKBOX:
810
+ data[id] = $this.is(':checked') ? 1 : 0;
811
+ break;
812
+ case typeConst.YES_NO:
813
+ case typeConst.RADIO:
814
+ data[id] = $this.find('input[type="radio"]:checked').val();
815
+ break;
816
+ case typeConst.DATE:
817
+ data[id] = {
818
+ day: $this.find('select[name="wpProQuiz_field_' + id + '_day"]').val(),
819
+ month: $this.find('select[name="wpProQuiz_field_' + id + '_month"]').val(),
820
+ year: $this.find('select[name="wpProQuiz_field_' + id + '_year"]').val()
821
+ };
822
+ break;
823
+ }
824
+ });
825
+
826
+ return data;
827
+ };
828
+ };
829
+
830
+ var fetchAllAnswerData = function (resultData) {
831
+ $e.find('.wpProQuiz_questionList').each(function () {
832
+ var $this = $(this);
833
+ var questionId = $this.data('question_id');
834
+ var type = $this.data('type');
835
+ var data = {};
836
+
837
+ if (type == 'single' || type == 'multiple') {
838
+ $this.find('.wpProQuiz_questionListItem').each(function () {
839
+ data[$(this).data('pos')] = +$(this).find('.wpProQuiz_questionInput').is(':checked');
840
+ });
841
+ } else if (type == 'free_answer') {
842
+ data[0] = $this.find('.wpProQuiz_questionInput').val();
843
+ } else if (type == 'sort_answer') {
844
+ return true;
845
+ // $this.find('.wpProQuiz_questionListItem').each(function() {
846
+ // data[$(this).index()] = $(this).data('pos');
847
+ // });
848
+ } else if (type == 'matrix_sort_answer') {
849
+ return true;
850
+ // $this.find('.wpProQuiz_questionListItem').each(function() {
851
+ // data[$(this).data('pos')] = $(this).find('.wpProQuiz_answerCorrect').length;
852
+ // });
853
+ } else if (type == 'cloze_answer') {
854
+ var i = 0;
855
+ $this.find('.wpProQuiz_cloze input').each(function () {
856
+ data[i++] = $(this).val();
857
+ });
858
+ } else if (type == 'assessment_answer') {
859
+ data[0] = '';
860
+
861
+ $this.find('.wpProQuiz_questionInput:checked').each(function () {
862
+ data[$(this).data('index')] = $(this).val();
863
+ });
864
+ }
865
+
866
+ resultData[questionId]['data'] = data;
867
+
868
+ });
869
+ };
870
+
871
+ plugin.methode = {
872
+ /**
873
+ * @memberOf plugin.methode
874
+ */
875
+
876
+ parseBitOptions: function () {
877
+ if (config.bo) {
878
+ bitOptions.randomAnswer = config.bo & (1 << 0);
879
+ bitOptions.randomQuestion = config.bo & (1 << 1);
880
+ bitOptions.disabledAnswerMark = config.bo & (1 << 2);
881
+ bitOptions.checkBeforeStart = config.bo & (1 << 3);
882
+ bitOptions.preview = config.bo & (1 << 4);
883
+ bitOptions.isAddAutomatic = config.bo & (1 << 6);
884
+ bitOptions.reviewQustion = config.bo & ( 1 << 7);
885
+ bitOptions.quizSummeryHide = config.bo & (1 << 8);
886
+ bitOptions.skipButton = config.bo & (1 << 9);
887
+ bitOptions.autoStart = config.bo & (1 << 10);
888
+ bitOptions.forcingQuestionSolve = config.bo & (1 << 11);
889
+ bitOptions.hideQuestionPositionOverview = config.bo & (1 << 12);
890
+ bitOptions.formActivated = config.bo & (1 << 13);
891
+ bitOptions.maxShowQuestion = config.bo & (1 << 14);
892
+ bitOptions.sortCategories = config.bo & (1 << 15);
893
+
894
+ var cors = config.bo & (1 << 5);
895
+
896
+ if (cors && jQuery.support != undefined && jQuery.support.cors != undefined && jQuery.support.cors == false) {
897
+ bitOptions.cors = cors;
898
+ }
899
+ }
900
+ },
901
+
902
+ setClozeStyle: function () {
903
+ $e.find('.wpProQuiz_cloze input').each(function () {
904
+ var $this = $(this);
905
+ var word = "";
906
+ var wordLen = $this.data('wordlen');
907
+
908
+ for (var i = 0; i < wordLen; i++)
909
+ word += "w";
910
+
911
+ var clone = $(document.createElement("span"))
912
+ .css('visibility', 'hidden')
913
+ .text(word)
914
+ .appendTo($('body'));
915
+
916
+ var width = clone.width();
917
+
918
+ clone.remove();
919
+
920
+ $this.width(width + 5);
921
+ });
922
+ },
923
+
924
+ parseTime: function (sec) {
925
+ var seconds = parseInt(sec % 60);
926
+ var minutes = parseInt((sec / 60) % 60);
927
+ var hours = parseInt((sec / 3600) % 24);
928
+
929
+ seconds = (seconds > 9 ? '' : '0') + seconds;
930
+ minutes = (minutes > 9 ? '' : '0') + minutes;
931
+ hours = (hours > 9 ? '' : '0') + hours;
932
+
933
+ return hours + ':' + minutes + ':' + seconds;
934
+ },
935
+
936
+ cleanupCurlyQuotes: function (str) {
937
+ str = str.replace(/\u2018/, "'");
938
+ str = str.replace(/\u2019/, "'");
939
+
940
+ str = str.replace(/\u201C/, '"');
941
+ str = str.replace(/\u201D/, '"');
942
+
943
+ return $.trim(str).toLowerCase();
944
+ },
945
+
946
+ resetMatrix: function (selector) {
947
+ selector.each(function () {
948
+ var $this = $(this);
949
+ var $list = $this.find('.wpProQuiz_sortStringList');
950
+
951
+ $this.find('.wpProQuiz_sortStringItem').each(function () {
952
+ $list.append($(this));
953
+ });
954
+ });
955
+ },
956
+
957
+ marker: function (e, correct) {
958
+ if (!bitOptions.disabledAnswerMark) {
959
+ if (correct) {
960
+ e.addClass('wpProQuiz_answerCorrect');
961
+ } else {
962
+ e.addClass('wpProQuiz_answerIncorrect');
963
+ }
964
+ }
965
+
966
+ },
967
+
968
+ startQuiz: function (loadData) {
969
+ if (quizStatus.loadLock) {
970
+ quizStatus.isQuizStart = 1;
971
+
972
+ return;
973
+ }
974
+
975
+ quizStatus.isQuizStart = 0;
976
+
977
+ if (quizStatus.isLocked) {
978
+ globalElements.quizStartPage.hide();
979
+ $e.find('.wpProQuiz_lock').show();
980
+
981
+ return;
982
+ }
983
+
984
+ if (quizStatus.isPrerequisite) {
985
+ globalElements.quizStartPage.hide();
986
+ $e.find('.wpProQuiz_prerequisite').show();
987
+
988
+ return;
989
+ }
990
+
991
+ if (quizStatus.isUserStartLocked) {
992
+ globalElements.quizStartPage.hide();
993
+ $e.find('.wpProQuiz_startOnlyRegisteredUser').show();
994
+
995
+ return;
996
+ }
997
+
998
+ if (bitOptions.maxShowQuestion && !loadData) {
999
+ globalElements.quizStartPage.hide();
1000
+ $e.find('.wpProQuiz_loadQuiz').show();
1001
+
1002
+ plugin.methode.loadQuizDataAjax(true);
1003
+
1004
+ return;
1005
+ }
1006
+
1007
+ if (bitOptions.formActivated && config.formPos == formPosConst.START) {
1008
+ if (!formClass.checkForm())
1009
+ return;
1010
+ }
1011
+
1012
+ plugin.methode.loadQuizData();
1013
+
1014
+ if (bitOptions.randomQuestion) {
1015
+ plugin.methode.random(globalElements.questionList);
1016
+ }
1017
+
1018
+ if (bitOptions.randomAnswer) {
1019
+ plugin.methode.random($e.find(globalNames.questionList));
1020
+ }
1021
+
1022
+ if (bitOptions.sortCategories) {
1023
+ plugin.methode.sortCategories();
1024
+ }
1025
+
1026
+ plugin.methode.random($e.find('.wpProQuiz_sortStringList'));
1027
+ plugin.methode.random($e.find('[data-type="sort_answer"]'));
1028
+
1029
+ $e.find('.wpProQuiz_listItem').each(function (i, v) {
1030
+ var $this = $(this);
1031
+ $this.find('.wpProQuiz_question_page span:eq(0)').text(i + 1);
1032
+ $this.find('> h5 span').text(i + 1);
1033
+
1034
+ $this.find('.wpProQuiz_questionListItem').each(function (i, v) {
1035
+ $(this).find('> span:not(.wpProQuiz_cloze)').text(i + 1 + '. ');
1036
+ });
1037
+ });
1038
+
1039
+ globalElements.next = $e.find(globalNames.next);
1040
+
1041
+ switch (config.mode) {
1042
+ case 3:
1043
+ $e.find('input[name="checkSingle"]').show();
1044
+ break;
1045
+ case 2:
1046
+ $e.find(globalNames.check).show();
1047
+
1048
+ if (!bitOptions.skipButton && bitOptions.reviewQustion)
1049
+ $e.find(globalNames.skip).show();
1050
+
1051
+ break;
1052
+ case 1:
1053
+ $e.find('input[name="back"]').slice(1).show();
1054
+ case 0:
1055
+ globalElements.next.show();
1056
+ break;
1057
+ }
1058
+
1059
+ if (bitOptions.hideQuestionPositionOverview || config.mode == 3)
1060
+ $e.find('.wpProQuiz_question_page').hide();
1061
+
1062
+ //Change last name
1063
+ var $lastButton = globalElements.next.last();
1064
+ lastButtonValue = $lastButton.val();
1065
+ $lastButton.val(config.lbn);
1066
+
1067
+ var $listItem = globalElements.questionList.children();
1068
+
1069
+ globalElements.listItems = $e.find('.wpProQuiz_list > li');
1070
+
1071
+ if (config.mode == 3) {
1072
+ plugin.methode.showSinglePage(0);
1073
+ // if(config.qpp) {
1074
+ // $listItem.slice(0, config.qpp).show();
1075
+ // $e.find(globalNames.singlePageRight).show();
1076
+ // $e.find('input[name="checkSingle"]').hide();
1077
+ // } else {
1078
+ // $listItem.show();
1079
+ // }
1080
+ } else {
1081
+ currentQuestion = $listItem.eq(0).show();
1082
+
1083
+ var questionId = currentQuestion.find(globalNames.questionList).data('question_id');
1084
+ questionTimer.questionStart(questionId);
1085
+ }
1086
+
1087
+ questionTimer.startQuiz();
1088
+
1089
+ $e.find('.wpProQuiz_sortable').parents('ul').sortable({
1090
+ update: function (event, ui) {
1091
+ var $p = $(this).parents('.wpProQuiz_listItem');
1092
+
1093
+ $e.trigger({
1094
+ type: 'questionSolved',
1095
+ values: {
1096
+ item: $p,
1097
+ index: $p.index(),
1098
+ solved: true
1099
+ }
1100
+ });
1101
+ }
1102
+ }).disableSelection();
1103
+
1104
+ $e.find('.wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion').sortable({
1105
+ connectWith: '.wpProQuiz_maxtrixSortCriterion:not(:has(li)), .wpProQuiz_sortStringList',
1106
+ placeholder: 'wpProQuiz_placehold',
1107
+ update: function (event, ui) {
1108
+ var $p = $(this).parents('.wpProQuiz_listItem');
1109
+
1110
+ $e.trigger({
1111
+ type: 'questionSolved',
1112
+ values: {
1113
+ item: $p,
1114
+ index: $p.index(),
1115
+ solved: true
1116
+ }
1117
+ });
1118
+ }
1119
+ }).disableSelection();
1120
+
1121
+ quizSolved = [];
1122
+
1123
+ timelimit.start();
1124
+
1125
+ startTime = +new Date();
1126
+
1127
+ results = {
1128
+ comp: {
1129
+ points: 0,
1130
+ correctQuestions: 0,
1131
+ quizTime: 0
1132
+ }
1133
+ };
1134
+
1135
+ $e.find('.wpProQuiz_questionList').each(function () {
1136
+ var questionId = $(this).data('question_id');
1137
+
1138
+ results[questionId] = {
1139
+ time: 0,
1140
+ solved: 0
1141
+ };
1142
+ });
1143
+
1144
+ catResults = {};
1145
+
1146
+ $.each(options.catPoints, function (i, v) {
1147
+ catResults[i] = 0;
1148
+ });
1149
+
1150
+ globalElements.quizStartPage.hide();
1151
+ $e.find('.wpProQuiz_loadQuiz').hide();
1152
+ globalElements.quiz.show();
1153
+ reviewBox.show();
1154
+
1155
+ if (config.mode != 3) {
1156
+ $e.trigger({
1157
+ type: 'changeQuestion',
1158
+ values: {
1159
+ item: currentQuestion,
1160
+ index: currentQuestion.index()
1161
+ }
1162
+ });
1163
+ }
1164
+ },
1165
+
1166
+ showSingleQuestion: function (question) {
1167
+ var page = question ? Math.ceil(question / config.qpp) : 1;
1168
+
1169
+ this.showSinglePage(page);
1170
+
1171
+ // plugin.methode.scrollTo($element, 1);
1172
+ },
1173
+
1174
+ showSinglePage: function (page) {
1175
+ $listItem = globalElements.questionList.children().hide();
1176
+
1177
+ if (!config.qpp) {
1178
+ $listItem.show();
1179
+
1180
+ return;
1181
+ }
1182
+
1183
+ page = page ? +page : 1;
1184
+
1185
+ var maxPage = Math.ceil($e.find('.wpProQuiz_list > li').length / config.qpp);
1186
+
1187
+ if (page > maxPage)
1188
+ return;
1189
+
1190
+ var pl = $e.find(globalNames.singlePageLeft).hide();
1191
+ var pr = $e.find(globalNames.singlePageRight).hide();
1192
+ var cs = $e.find('input[name="checkSingle"]').hide();
1193
+
1194
+ if (page > 1) {
1195
+ pl.val(pl.data('text').replace(/%d/, page - 1)).show();
1196
+ }
1197
+
1198
+ if (page == maxPage) {
1199
+ cs.show();
1200
+ } else {
1201
+ pr.val(pr.data('text').replace(/%d/, page + 1)).show();
1202
+ }
1203
+
1204
+ currentPage = page;
1205
+
1206
+ var start = config.qpp * (page - 1);
1207
+
1208
+ $listItem.slice(start, start + config.qpp).show();
1209
+ plugin.methode.scrollTo(globalElements.quiz);
1210
+ },
1211
+
1212
+ nextQuestion: function () {
1213
+ // currentQuestion = currentQuestion.hide().next().show();
1214
+ //
1215
+ // plugin.methode.scrollTo(globalElements.quiz);
1216
+ //
1217
+ // $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1218
+ //
1219
+ // if(!currentQuestion.length) {
1220
+ // plugin.methode.showQuizSummary();
1221
+ // }
1222
+
1223
+ this.showQuestionObject(currentQuestion.next());
1224
+ },
1225
+
1226
+ prevQuestion: function () {
1227
+ // currentQuestion = currentQuestion.hide().prev().show();
1228
+ //
1229
+ // plugin.methode.scrollTo(globalElements.quiz);
1230
+ //
1231
+ // $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1232
+ //
1233
+ this.showQuestionObject(currentQuestion.prev());
1234
+ },
1235
+
1236
+ showQuestion: function (index) {
1237
+ var $element = globalElements.listItems.eq(index);
1238
+
1239
+ if (config.mode == 3 || inViewQuestions) {
1240
+ if (config.qpp) {
1241
+ plugin.methode.showSingleQuestion(index + 1);
1242
+ // questionTimer.startQuiz();
1243
+ // return;
1244
+ }
1245
+ // plugin.methode.scrollTo($e.find('.wpProQuiz_list > li').eq(index), 1);
1246
+ plugin.methode.scrollTo($element, 1);
1247
+ questionTimer.startQuiz();
1248
+ return;
1249
+ }
1250
+
1251
+ // currentQuestion.hide();
1252
+ //
1253
+ // currentQuestion = $element.show();
1254
+ //
1255
+ // plugin.methode.scrollTo(globalElements.quiz);
1256
+ //
1257
+ // $e.trigger({type: 'changeQuestion', values: {item: currentQuestion, index: currentQuestion.index()}});
1258
+ //
1259
+ // if(!currentQuestion.length)
1260
+ // plugin.methode.showQuizSummary();
1261
+
1262
+ this.showQuestionObject($element);
1263
+ },
1264
+
1265
+ showQuestionObject: function (obj) {
1266
+ if (!obj.length && bitOptions.forcingQuestionSolve && bitOptions.quizSummeryHide && bitOptions.reviewQustion) {
1267
+ for (var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1268
+ if (!quizSolved[i]) {
1269
+ alert(WpProQuizGlobal.questionsNotSolved);
1270
+ return false;
1271
+ }
1272
+ }
1273
+ }
1274
+
1275
+ currentQuestion.hide();
1276
+
1277
+ currentQuestion = obj.show();
1278
+
1279
+ plugin.methode.scrollTo(globalElements.quiz);
1280
+
1281
+ $e.trigger({
1282
+ type: 'changeQuestion',
1283
+ values: {
1284
+ item: currentQuestion,
1285
+ index: currentQuestion.index()
1286
+ }
1287
+ });
1288
+
1289
+ if (!currentQuestion.length) {
1290
+ plugin.methode.showQuizSummary();
1291
+ } else {
1292
+ var questionId = currentQuestion.find(globalNames.questionList).data('question_id');
1293
+ questionTimer.questionStart(questionId);
1294
+ }
1295
+ },
1296
+
1297
+ skipQuestion: function () {
1298
+ $e.trigger({
1299
+ type: 'skipQuestion',
1300
+ values: {
1301
+ item: currentQuestion,
1302
+ index: currentQuestion.index()
1303
+ }
1304
+ });
1305
+
1306
+ plugin.methode.nextQuestion();
1307
+ },
1308
+
1309
+ reviewQuestion: function () {
1310
+ $e.trigger({
1311
+ type: 'reviewQuestion',
1312
+ values: {
1313
+ item: currentQuestion,
1314
+ index: currentQuestion.index()
1315
+ }
1316
+ });
1317
+ },
1318
+
1319
+ showQuizSummary: function () {
1320
+ questionTimer.questionStop();
1321
+ questionTimer.stopQuiz();
1322
+
1323
+ if (bitOptions.quizSummeryHide || !bitOptions.reviewQustion) {
1324
+ if (bitOptions.formActivated && config.formPos == formPosConst.END) {
1325
+ reviewBox.hide();
1326
+ globalElements.quiz.hide();
1327
+ plugin.methode.scrollTo($e.find('.wpProQuiz_infopage').show());
1328
+ } else {
1329
+ plugin.methode.finishQuiz();
1330
+ }
1331
+
1332
+ return;
1333
+ }
1334
+
1335
+ var quizSummary = $e.find('.wpProQuiz_checkPage');
1336
+
1337
+ quizSummary.find('ol:eq(0)').empty()
1338
+ .append($e.find('.wpProQuiz_reviewQuestion ol li').clone().removeClass('wpProQuiz_reviewQuestionTarget'))
1339
+ .children().click(function (e) {
1340
+ quizSummary.hide();
1341
+ globalElements.quiz.show();
1342
+ reviewBox.show(true);
1343
+
1344
+ plugin.methode.showQuestion($(this).index());
1345
+ });
1346
+
1347
+ var cSolved = 0;
1348
+
1349
+ for (var i = 0, c = quizSolved.length; i < c; i++) {
1350
+ if (quizSolved[i]) {
1351
+ cSolved++;
1352
+ }
1353
+ }
1354
+
1355
+ quizSummary.find('span:eq(0)').text(cSolved);
1356
+
1357
+ reviewBox.hide();
1358
+ globalElements.quiz.hide();
1359
+
1360
+ quizSummary.show();
1361
+
1362
+ plugin.methode.scrollTo(quizSummary);
1363
+ },
1364
+
1365
+ finishQuiz: function (timeover) {
1366
+ questionTimer.questionStop();
1367
+ questionTimer.stopQuiz();
1368
+ timelimit.stop();
1369
+
1370
+ var time = (+new Date() - startTime) / 1000;
1371
+ time = (config.timelimit && time > config.timelimit) ? config.timelimit : time;
1372
+
1373
+ $e.find('.wpProQuiz_quiz_time span').text(plugin.methode.parseTime(time));
1374
+
1375
+ if (timeover) {
1376
+ globalElements.results.find('.wpProQuiz_time_limit_expired').show();
1377
+ }
1378
+
1379
+ plugin.methode.checkQuestion(globalElements.questionList.children(), true);
1380
+
1381
+ $e.find('.wpProQuiz_correct_answer').text(results.comp.correctQuestions);
1382
+
1383
+ results.comp.result = Math.round(results.comp.points / config.globalPoints * 100 * 100) / 100;
1384
+ results.comp.solved = 0;
1385
+
1386
+ //for(var i = 0; i < quizSolved.length; i++)
1387
+ // results.comp.solved += quizSolved[i] ? 1 : 0;
1388
+
1389
+ var $pointFields = $e.find('.wpProQuiz_points span');
1390
+
1391
+ $pointFields.eq(0).text(results.comp.points);
1392
+ $pointFields.eq(1).text(config.globalPoints);
1393
+ $pointFields.eq(2).text(results.comp.result + '%');
1394
+
1395
+ //Result-Text START
1396
+ var $resultText = $e.find('.wpProQuiz_resultsList > li').eq(plugin.methode.findResultIndex(results.comp.result));
1397
+
1398
+ var formData = formClass.getFormData();
1399
+
1400
+ $resultText.find('.wpProQuiz_resultForm').each(function () {
1401
+ var $this = $(this);
1402
+ var formId = $this.data('form_id');
1403
+ var data = formData[formId];
1404
+
1405
+ if (typeof data === 'object') {
1406
+ data = data['day'] + '-' + data['month'] + '-' + data['year'];
1407
+ }
1408
+
1409
+ $this.text(data).show();
1410
+ });
1411
+
1412
+ $resultText.show();
1413
+
1414
+ //Result-Text END
1415
+
1416
+ plugin.methode.setAverageResult(results.comp.result, false);
1417
+
1418
+ this.setCategoryOverview();
1419
+
1420
+ plugin.methode.sendCompletedQuiz();
1421
+
1422
+ if (bitOptions.isAddAutomatic && toplistData.isUser) {
1423
+ plugin.methode.addToplist();
1424
+ }
1425
+
1426
+ reviewBox.hide();
1427
+
1428
+ $e.find('.wpProQuiz_checkPage, .wpProQuiz_infopage').hide();
1429
+ globalElements.quiz.hide();
1430
+ globalElements.results.show();
1431
+
1432
+ plugin.methode.scrollTo(globalElements.results);
1433
+ },
1434
+
1435
+ setCategoryOverview: function () {
1436
+ results.comp.cats = {};
1437
+
1438
+ $e.find('.wpProQuiz_catOverview li').each(function () {
1439
+ var $this = $(this);
1440
+ var catId = $this.data('category_id');
1441
+
1442
+ if (config.catPoints[catId] === undefined) {
1443
+ $this.hide();
1444
+ return true;
1445
+ }
1446
+
1447
+ var r = Math.round(catResults[catId] / config.catPoints[catId] * 100 * 100) / 100;
1448
+
1449
+ results.comp.cats[catId] = r;
1450
+
1451
+ $this.find('.wpProQuiz_catPercent').text(r + '%');
1452
+
1453
+ $this.show();
1454
+ });
1455
+ },
1456
+
1457
+ questionSolved: function (e) {
1458
+ quizSolved[e.values.index] = e.values.solved;
1459
+
1460
+ var $questionList = e.values.item.find(globalNames.questionList);
1461
+ var data = config.json[$questionList.data('question_id')];
1462
+ results[data.id].solved = Number(e.values.fake ? results[data.id].solved : e.values.solved);
1463
+ },
1464
+
1465
+ sendCompletedQuiz: function () {
1466
+ if (bitOptions.preview)
1467
+ return;
1468
+
1469
+ fetchAllAnswerData(results);
1470
+
1471
+ var formData = formClass.getFormData();
1472
+
1473
+ //plugin.methode.ajax({
1474
+ // action: 'wp_pro_quiz_completed_quiz',
1475
+ // quizId: config.quizId,
1476
+ // results: results,
1477
+ // forms: formData
1478
+ //});
1479
+
1480
+ plugin.methode.ajax({
1481
+ action: 'wp_pro_quiz_admin_ajax',
1482
+ func: 'completedQuiz',
1483
+ data: {
1484
+ quizId: config.quizId,
1485
+ results: results,
1486
+ forms: formData
1487
+ }
1488
+ });
1489
+ },
1490
+
1491
+ findResultIndex: function (p) {
1492
+ var r = config.resultsGrade;
1493
+ var index = -1;
1494
+ var diff = 999999;
1495
+
1496
+ for (var i = 0; i < r.length; i++) {
1497
+ var v = r[i];
1498
+
1499
+ if ((p >= v) && ((p - v) < diff)) {
1500
+ diff = p - v;
1501
+ index = i;
1502
+ }
1503
+ }
1504
+
1505
+ return index;
1506
+ },
1507
+
1508
+ showQustionList: function () {
1509
+ inViewQuestions = !inViewQuestions;
1510
+ globalElements.toplistShowInButton.hide();
1511
+ globalElements.quiz.toggle();
1512
+ $e.find('.wpProQuiz_QuestionButton').hide();
1513
+ globalElements.questionList.children().show();
1514
+ reviewBox.toggle();
1515
+
1516
+ $e.find('.wpProQuiz_question_page').hide();
1517
+ },
1518
+
1519
+ random: function (group) {
1520
+ group.each(function () {
1521
+ var e = $(this).children().get().sort(function () {
1522
+ return Math.round(Math.random()) - 0.5;
1523
+ });
1524
+
1525
+ $(e).appendTo(e[0].parentNode);
1526
+ });
1527
+ },
1528
+
1529
+ sortCategories: function () {
1530
+ var e = $('.wpProQuiz_list').children().get().sort(function (a, b) {
1531
+ var aQuestionId = $(a).find('.wpProQuiz_questionList').data('question_id');
1532
+ var bQuestionId = $(b).find('.wpProQuiz_questionList').data('question_id');
1533
+
1534
+ return config.json[aQuestionId].catId - config.json[bQuestionId].catId;
1535
+ });
1536
+
1537
+ $(e).appendTo(e[0].parentNode);
1538
+ },
1539
+
1540
+ restartQuiz: function () {
1541
+ globalElements.results.hide();
1542
+ globalElements.quizStartPage.show();
1543
+ globalElements.questionList.children().hide();
1544
+ globalElements.toplistShowInButton.hide();
1545
+ reviewBox.hide();
1546
+
1547
+ $e.find('.wpProQuiz_questionInput, .wpProQuiz_cloze input').removeAttr('disabled').removeAttr('checked')
1548
+ .css('background-color', '');
1549
+
1550
+ // $e.find('.wpProQuiz_cloze input').val('');
1551
+ $e.find('.wpProQuiz_questionListItem input[type="text"]').val('');
1552
+
1553
+ $e.find('.wpProQuiz_answerCorrect, .wpProQuiz_answerIncorrect').removeClass('wpProQuiz_answerCorrect wpProQuiz_answerIncorrect');
1554
+
1555
+ $e.find('.wpProQuiz_listItem').data('check', false);
1556
+
1557
+ $e.find('.wpProQuiz_response').hide().children().hide();
1558
+
1559
+ plugin.methode.resetMatrix($e.find('.wpProQuiz_listItem'));
1560
+
1561
+ $e.find('.wpProQuiz_sortStringItem, .wpProQuiz_sortable').removeAttr('style');
1562
+
1563
+ $e.find('.wpProQuiz_clozeCorrect, .wpProQuiz_QuestionButton, .wpProQuiz_resultsList > li').hide();
1564
+
1565
+ $e.find('.wpProQuiz_question_page, input[name="tip"]').show();
1566
+ $e.find('.wpProQuiz_resultForm').text('').hide();
1567
+
1568
+ globalElements.results.find('.wpProQuiz_time_limit_expired').hide();
1569
+
1570
+ globalElements.next.last().val(lastButtonValue);
1571
+
1572
+ inViewQuestions = false;
1573
+ },
1574
+
1575
+ checkQuestion: function (list, endCheck) {
1576
+ list = (list == undefined) ? currentQuestion : list;
1577
+
1578
+ list.each(function () {
1579
+ var $this = $(this);
1580
+ var $questionList = $this.find(globalNames.questionList);
1581
+ var data = config.json[$questionList.data('question_id')];
1582
+ var name = data.type;
1583
+
1584
+ questionTimer.questionStop();
1585
+
1586
+ if ($this.data('check')) {
1587
+ return true;
1588
+ }
1589
+
1590
+ if (data.type == 'single' || data.type == 'multiple') {
1591
+ name = 'singleMulti';
1592
+ }
1593
+
1594
+ var result = checker(name, data, $this, $questionList);
1595
+
1596
+ $this.find('.wpProQuiz_response').show();
1597
+ $this.find(globalNames.check).hide();
1598
+ $this.find(globalNames.skip).hide();
1599
+ $this.find(globalNames.next).show();
1600
+
1601
+ results[data.id].points = result.p;
1602
+ results[data.id].correct = Number(result.c);
1603
+ results[data.id].data = result.s;
1604
+
1605
+ results['comp'].points += result.p;
1606
+
1607
+ catResults[data.catId] += result.p;
1608
+
1609
+ if (result.c) {
1610
+ $this.find('.wpProQuiz_correct').show();
1611
+ results['comp'].correctQuestions += 1;
1612
+ } else {
1613
+ $this.find('.wpProQuiz_incorrect').show();
1614
+ }
1615
+
1616
+ $this.find('.wpProQuiz_responsePoints').text(result.p);
1617
+
1618
+ $this.data('check', true);
1619
+
1620
+ if (!endCheck)
1621
+ $e.trigger({
1622
+ type: 'questionSolved',
1623
+ values: {
1624
+ item: $this,
1625
+ index: $this.index(),
1626
+ solved: true,
1627
+ fake: true
1628
+ }
1629
+ });
1630
+ });
1631
+ },
1632
+
1633
+ showTip: function () {
1634
+ var $this = $(this);
1635
+ var id = $this.siblings('.wpProQuiz_question').find(globalNames.questionList).data('question_id');
1636
+
1637
+ $this.siblings('.wpProQuiz_tipp').toggle('fast');
1638
+
1639
+ results[id].tip = 1;
1640
+
1641
+ $(document).bind('mouseup.tipEvent', function (e) {
1642
+
1643
+ var $tip = $e.find('.wpProQuiz_tipp');
1644
+ var $btn = $e.find('input[name="tip"]');
1645
+
1646
+ if (!$tip.is(e.target) && $tip.has(e.target).length == 0 && !$btn.is(e.target)) {
1647
+ $tip.hide('fast');
1648
+ $(document).unbind('.tipEvent');
1649
+ }
1650
+ });
1651
+ },
1652
+
1653
+ ajax: function (data, success, dataType) {
1654
+ dataType = dataType || 'json';
1655
+
1656
+ if (bitOptions.cors) {
1657
+ jQuery.support.cors = true;
1658
+ }
1659
+
1660
+ $.post(WpProQuizGlobal.ajaxurl, data, success, dataType);
1661
+
1662
+ if (bitOptions.cors) {
1663
+ jQuery.support.cors = false;
1664
+ }
1665
+ },
1666
+
1667
+ checkQuizLock: function () {
1668
+
1669
+ quizStatus.loadLock = 1;
1670
+
1671
+ plugin.methode.ajax({
1672
+ //action: 'wp_pro_quiz_check_lock',
1673
+ //quizId: config.quizId
1674
+
1675
+ action: 'wp_pro_quiz_admin_ajax',
1676
+ func: 'quizCheckLock',
1677
+ data: {
1678
+ quizId: config.quizId
1679
+ }
1680
+ }, function (json) {
1681
+
1682
+ if (json.lock != undefined) {
1683
+ quizStatus.isLocked = json.lock.is;
1684
+
1685
+ if (json.lock.pre) {
1686
+ $e.find('input[name="restartQuiz"]').hide();
1687
+ }
1688
+ }
1689
+
1690
+ if (json.prerequisite != undefined) {
1691
+ quizStatus.isPrerequisite = 1;
1692
+ $e.find('.wpProQuiz_prerequisite span').text(json.prerequisite);
1693
+ }
1694
+
1695
+ if (json.startUserLock != undefined) {
1696
+ quizStatus.isUserStartLocked = json.startUserLock;
1697
+ }
1698
+
1699
+ quizStatus.loadLock = 0;
1700
+
1701
+ if (quizStatus.isQuizStart) {
1702
+ plugin.methode.startQuiz();
1703
+ }
1704
+ });
1705
+ },
1706
+
1707
+ loadQuizData: function () {
1708
+ plugin.methode.ajax({
1709
+ action: 'wp_pro_quiz_admin_ajax',
1710
+ func: 'loadQuizData',
1711
+ data: {
1712
+ quizId: config.quizId
1713
+ }
1714
+ }, function (json) {
1715
+ if (json.toplist) {
1716
+ plugin.methode.handleToplistData(json.toplist);
1717
+ }
1718
+
1719
+ if (json.averageResult != undefined) {
1720
+ plugin.methode.setAverageResult(json.averageResult, true);
1721
+ }
1722
+ });
1723
+
1724
+ //plugin.methode.ajax({
1725
+ // action: 'wp_pro_quiz_load_quiz_data',
1726
+ // quizId: config.quizId
1727
+ //}, function (json) {
1728
+ // if (json.toplist) {
1729
+ // plugin.methode.handleToplistData(json.toplist);
1730
+ // }
1731
+ //
1732
+ // if (json.averageResult != undefined) {
1733
+ // plugin.methode.setAverageResult(json.averageResult, true);
1734
+ // }
1735
+ //});
1736
+ },
1737
+
1738
+ setAverageResult: function (p, g) {
1739
+ var v = $e.find('.wpProQuiz_resultValue:eq(' + (g ? 0 : 1) + ') > * ');
1740
+
1741
+ v.eq(1).text(p + '%');
1742
+ v.eq(0).css('width', (240 * p / 100) + 'px');
1743
+ },
1744
+
1745
+ handleToplistData: function (json) {
1746
+ var $tp = $e.find('.wpProQuiz_addToplist');
1747
+ var $addBox = $tp.find('.wpProQuiz_addBox').show().children('div');
1748
+
1749
+ if (json.canAdd) {
1750
+ $tp.show();
1751
+ $tp.find('.wpProQuiz_addToplistMessage').hide();
1752
+ $tp.find('.wpProQuiz_toplistButton').show();
1753
+
1754
+ toplistData.token = json.token;
1755
+ toplistData.isUser = 0;
1756
+
1757
+ if (json.userId) {
1758
+ $addBox.hide();
1759
+ toplistData.isUser = 1;
1760
+
1761
+ if (bitOptions.isAddAutomatic) {
1762
+ $tp.hide();
1763
+ }
1764
+ } else {
1765
+ $addBox.show();
1766
+
1767
+ var $captcha = $addBox.children().eq(1);
1768
+
1769
+ if (json.captcha) {
1770
+
1771
+ $captcha.find('input[name="wpProQuiz_captchaPrefix"]').val(json.captcha.code);
1772
+ $captcha.find('.wpProQuiz_captchaImg').attr('src', json.captcha.img);
1773
+ $captcha.find('input[name="wpProQuiz_captcha"]').val('');
1774
+
1775
+ $captcha.show();
1776
+ } else {
1777
+ $captcha.hide();
1778
+ }
1779
+ }
1780
+ } else {
1781
+ $tp.hide();
1782
+ }
1783
+ },
1784
+
1785
+ scrollTo: function (e, h) {
1786
+ var x = e.offset().top - 100;
1787
+
1788
+ if (h || (window.pageYOffset || document.body.scrollTop) > x) {
1789
+ $('html,body').animate({scrollTop: x}, 300);
1790
+ }
1791
+ },
1792
+
1793
+ addToplist: function () {
1794
+ if (bitOptions.preview)
1795
+ return;
1796
+
1797
+ var $addToplistMessage = $e.find('.wpProQuiz_addToplistMessage').text(WpProQuizGlobal.loadData).show();
1798
+ var $addBox = $e.find('.wpProQuiz_addBox').hide();
1799
+
1800
+ plugin.methode.ajax({
1801
+ //action: 'wp_pro_quiz_add_toplist',
1802
+ //quizId: config.quizId,
1803
+ //token: toplistData.token,
1804
+ //name: $addBox.find('input[name="wpProQuiz_toplistName"]').val(),
1805
+ //email: $addBox.find('input[name="wpProQuiz_toplistEmail"]').val(),
1806
+ //captcha: $addBox.find('input[name="wpProQuiz_captcha"]').val(),
1807
+ //prefix: $addBox.find('input[name="wpProQuiz_captchaPrefix"]').val(),
1808
+ //points: results.comp.points,
1809
+ //totalPoints: config.globalPoints
1810
+
1811
+ action: 'wp_pro_quiz_admin_ajax',
1812
+ func: 'addInToplist',
1813
+ data: {
1814
+ quizId: config.quizId,
1815
+ token: toplistData.token,
1816
+ name: $addBox.find('input[name="wpProQuiz_toplistName"]').val(),
1817
+ email: $addBox.find('input[name="wpProQuiz_toplistEmail"]').val(),
1818
+ captcha: $addBox.find('input[name="wpProQuiz_captcha"]').val(),
1819
+ prefix: $addBox.find('input[name="wpProQuiz_captchaPrefix"]').val(),
1820
+ points: results.comp.points,
1821
+ totalPoints: config.globalPoints
1822
+ }
1823
+ }, function (json) {
1824
+ $addToplistMessage.text(json.text);
1825
+
1826
+ if (json.clear) {
1827
+ $addBox.hide();
1828
+ plugin.methode.updateToplist();
1829
+ } else {
1830
+ $addBox.show();
1831
+ }
1832
+
1833
+ if (json.captcha) {
1834
+ $addBox.find('.wpProQuiz_captchaImg').attr('src', json.captcha.img);
1835
+ $addBox.find('input[name="wpProQuiz_captchaPrefix"]').val(json.captcha.code);
1836
+ $addBox.find('input[name="wpProQuiz_captcha"]').val('');
1837
+ }
1838
+ });
1839
+ },
1840
+
1841
+ updateToplist: function () {
1842
+ if (typeof(wpProQuiz_fetchToplist) == "function") {
1843
+ wpProQuiz_fetchToplist();
1844
+ }
1845
+ },
1846
+
1847
+ registerSolved: function () {
1848
+ $e.find('.wpProQuiz_questionInput[type="text"]').change(function (e) {
1849
+ var $this = $(this);
1850
+ var $p = $this.parents('.wpProQuiz_listItem');
1851
+ var s = false;
1852
+
1853
+ if ($this.val() != '') {
1854
+ s = true;
1855
+ }
1856
+
1857
+ $e.trigger({
1858
+ type: 'questionSolved',
1859
+ values: {
1860
+ item: $p,
1861
+ index: $p.index(),
1862
+ solved: s
1863
+ }
1864
+ });
1865
+ });
1866
+
1867
+ $e.find('.wpProQuiz_questionList[data-type="single"] .wpProQuiz_questionInput, .wpProQuiz_questionList[data-type="assessment_answer"] .wpProQuiz_questionInput').change(function (e) {
1868
+ var $this = $(this);
1869
+ var $p = $this.parents('.wpProQuiz_listItem');
1870
+ var s = this.checked;
1871
+
1872
+ $e.trigger({
1873
+ type: 'questionSolved',
1874
+ values: {
1875
+ item: $p,
1876
+ index: $p.index(),
1877
+ solved: s
1878
+ }
1879
+ });
1880
+ });
1881
+
1882
+ $e.find('.wpProQuiz_cloze input').change(function () {
1883
+ var $this = $(this);
1884
+ var $p = $this.parents('.wpProQuiz_listItem');
1885
+ var s = true;
1886
+
1887
+ $p.find('.wpProQuiz_cloze input').each(function () {
1888
+ if ($(this).val() == '') {
1889
+ s = false;
1890
+ return false;
1891
+ }
1892
+ });
1893
+
1894
+ $e.trigger({
1895
+ type: 'questionSolved',
1896
+ values: {
1897
+ item: $p,
1898
+ index: $p.index(),
1899
+ solved: s
1900
+ }
1901
+ });
1902
+ });
1903
+
1904
+ $e.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').change(function (e) {
1905
+ var $this = $(this);
1906
+ var $p = $this.parents('.wpProQuiz_listItem');
1907
+ var c = 0;
1908
+
1909
+ $p.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').each(function (e) {
1910
+ if (this.checked)
1911
+ c++;
1912
+ });
1913
+
1914
+ $e.trigger({
1915
+ type: 'questionSolved',
1916
+ values: {
1917
+ item: $p,
1918
+ index: $p.index(),
1919
+ solved: (c) ? true : false
1920
+ }
1921
+ });
1922
+
1923
+ });
1924
+ },
1925
+
1926
+ loadQuizDataAjax: function (quizStart) {
1927
+ plugin.methode.ajax({
1928
+ action: 'wp_pro_quiz_admin_ajax',
1929
+ func: 'quizLoadData',
1930
+ data: {
1931
+ quizId: config.quizId
1932
+ }
1933
+ }, function (json) {
1934
+
1935
+ config.globalPoints = json.globalPoints;
1936
+ config.catPoints = json.catPoints;
1937
+ config.json = json.json;
1938
+
1939
+ globalElements.quiz.remove();
1940
+
1941
+ $e.find('.wpProQuiz_quizAnker').after(json.content);
1942
+
1943
+ //Reinit globalElements
1944
+ globalElements = {
1945
+ back: $e.find('input[name="back"]'),
1946
+ next: $e.find(globalNames.next),
1947
+ quiz: $e.find('.wpProQuiz_quiz'),
1948
+ questionList: $e.find('.wpProQuiz_list'),
1949
+ results: $e.find('.wpProQuiz_results'),
1950
+ quizStartPage: $e.find('.wpProQuiz_text'),
1951
+ timelimit: $e.find('.wpProQuiz_time_limit'),
1952
+ toplistShowInButton: $e.find('.wpProQuiz_toplistShowInButton'),
1953
+ listItems: $()
1954
+ };
1955
+
1956
+ plugin.methode.initQuiz();
1957
+
1958
+ if (quizStart)
1959
+ plugin.methode.startQuiz(true);
1960
+
1961
+ });
1962
+ },
1963
+
1964
+ initQuiz: function () {
1965
+ plugin.methode.setClozeStyle();
1966
+ plugin.methode.registerSolved();
1967
+
1968
+ globalElements.next.click(function () {
1969
+ if (bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
1970
+ && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1971
+
1972
+ alert(WpProQuizGlobal.questionNotSolved);
1973
+ return false;
1974
+ }
1975
+
1976
+ plugin.methode.nextQuestion();
1977
+ });
1978
+
1979
+ globalElements.back.click(function () {
1980
+ plugin.methode.prevQuestion();
1981
+ });
1982
+
1983
+ $e.find(globalNames.check).click(function () {
1984
+ if (bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
1985
+ && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1986
+
1987
+ alert(WpProQuizGlobal.questionNotSolved);
1988
+ return false;
1989
+ }
1990
+
1991
+ plugin.methode.checkQuestion();
1992
+ });
1993
+
1994
+ $e.find('input[name="checkSingle"]').click(function () {
1995
+ if (bitOptions.forcingQuestionSolve && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
1996
+ for (var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
1997
+ if (!quizSolved[i]) {
1998
+ alert(WpProQuizGlobal.questionsNotSolved);
1999
+ return false;
2000
+ }
2001
+ }
2002
+ }
2003
+
2004
+ plugin.methode.showQuizSummary();
2005
+ });
2006
+
2007
+ $e.find('input[name="tip"]').click(plugin.methode.showTip);
2008
+ $e.find('input[name="skip"]').click(plugin.methode.skipQuestion);
2009
+
2010
+ $e.find('input[name="wpProQuiz_pageLeft"]').click(function () {
2011
+ plugin.methode.showSinglePage(currentPage - 1);
2012
+ });
2013
+
2014
+ $e.find('input[name="wpProQuiz_pageRight"]').click(function () {
2015
+ plugin.methode.showSinglePage(currentPage + 1);
2016
+ });
2017
+ }
2018
+ };
2019
+
2020
+ // /**
2021
+ // * @memberOf plugin
2022
+ // */
2023
+ // plugin.init = function() {
2024
+ // //
2025
+ // plugin.methode.setClozeStyle();
2026
+ // //
2027
+ // plugin.methode.registerSolved();
2028
+ //
2029
+ //
2030
+ // reviewBox.init();
2031
+ //
2032
+ // if(bitOptions.checkBeforeStart && !bitOptions.preview) {
2033
+ // plugin.methode.checkQuizLock();
2034
+ // }
2035
+ //
2036
+ // $e.find('input[name="startQuiz"]').click(function() {
2037
+ // plugin.methode.startQuiz();
2038
+ // return false;
2039
+ // });
2040
+ //
2041
+ // //
2042
+ // globalElements.next.click(function() {
2043
+ // if(bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
2044
+ // && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
2045
+ //
2046
+ // alert(WpProQuizGlobal.questionNotSolved);
2047
+ // return false;
2048
+ // }
2049
+ //
2050
+ // plugin.methode.nextQuestion();
2051
+ // });
2052
+ //
2053
+ // //
2054
+ // globalElements.back.click(function() {
2055
+ // plugin.methode.prevQuestion();
2056
+ // });
2057
+ //
2058
+ // $e.find('input[name="reShowQuestion"]').click(function() {
2059
+ // plugin.methode.showQustionList();
2060
+ // });
2061
+ //
2062
+ // $e.find('input[name="restartQuiz"]').click(function() {
2063
+ // plugin.methode.restartQuiz();
2064
+ // });
2065
+ //
2066
+ // //
2067
+ // $e.find(globalNames.check).click(function() {
2068
+ // if(bitOptions.forcingQuestionSolve && !quizSolved[currentQuestion.index()]
2069
+ // && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
2070
+ //
2071
+ // alert(WpProQuizGlobal.questionNotSolved);
2072
+ // return false;
2073
+ // }
2074
+ //
2075
+ // plugin.methode.checkQuestion();
2076
+ // });
2077
+ //
2078
+ // //
2079
+ // $e.find('input[name="checkSingle"]').click(function() {
2080
+ // if(bitOptions.forcingQuestionSolve && (bitOptions.quizSummeryHide || !bitOptions.reviewQustion)) {
2081
+ // for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
2082
+ // if(!quizSolved[i]) {
2083
+ // alert(WpProQuizGlobal.questionsNotSolved);
2084
+ // return false;
2085
+ // }
2086
+ // }
2087
+ // }
2088
+ //
2089
+ // plugin.methode.showQuizSummary();
2090
+ // });
2091
+ //
2092
+ // //
2093
+ // $e.find('input[name="tip"]').click(plugin.methode.showTip);
2094
+ //
2095
+ // //
2096
+ // $e.find('input[name="skip"]').click(plugin.methode.skipQuestion);
2097
+ //
2098
+ // $e.find('input[name="review"]').click(plugin.methode.reviewQuestion);
2099
+ //
2100
+ // $e.find('input[name="wpProQuiz_toplistAdd"]').click(plugin.methode.addToplist);
2101
+ //
2102
+ // $e.find('input[name="quizSummary"]').click(plugin.methode.showQuizSummary);
2103
+ //
2104
+ // $e.find('input[name="endQuizSummary"]').click(function() {
2105
+ // if(bitOptions.forcingQuestionSolve) {
2106
+ // for(var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
2107
+ // if(!quizSolved[i]) {
2108
+ // alert(WpProQuizGlobal.questionsNotSolved);
2109
+ // return false;
2110
+ // }
2111
+ // }
2112
+ // }
2113
+ //
2114
+ // if(bitOptions.formActivated && config.formPos == formPosConst.END && !formClass.checkForm())
2115
+ // return;
2116
+ //
2117
+ // plugin.methode.finishQuiz();
2118
+ // });
2119
+ //
2120
+ // $e.find('input[name="endInfopage"]').click(function() {
2121
+ // if(formClass.checkForm())
2122
+ // plugin.methode.finishQuiz();
2123
+ // });
2124
+ //
2125
+ // $e.find('input[name="showToplist"]').click(function() {
2126
+ // globalElements.quiz.hide();
2127
+ // globalElements.toplistShowInButton.toggle();
2128
+ // });
2129
+ //
2130
+ // //
2131
+ // $e.find('input[name="wpProQuiz_pageLeft"]').click(function() {
2132
+ // plugin.methode.showSinglePage(currentPage-1);
2133
+ // });
2134
+ //
2135
+ // //
2136
+ // $e.find('input[name="wpProQuiz_pageRight"]').click(function() {
2137
+ // plugin.methode.showSinglePage(currentPage+1);
2138
+ // });
2139
+ //
2140
+ // $e.bind('questionSolved', plugin.methode.questionSolved);
2141
+ // };
2142
+
2143
+ /**
2144
+ * @memberOf plugin
2145
+ */
2146
+ plugin.preInit = function () {
2147
+ plugin.methode.parseBitOptions();
2148
+ reviewBox.init();
2149
+
2150
+ $e.find('input[name="startQuiz"]').click(function () {
2151
+ plugin.methode.startQuiz();
2152
+ return false;
2153
+ });
2154
+
2155
+ if (bitOptions.checkBeforeStart && !bitOptions.preview) {
2156
+ plugin.methode.checkQuizLock();
2157
+ }
2158
+
2159
+ $e.find('input[name="reShowQuestion"]').click(function () {
2160
+ plugin.methode.showQustionList();
2161
+ });
2162
+
2163
+ $e.find('input[name="restartQuiz"]').click(function () {
2164
+ plugin.methode.restartQuiz();
2165
+ });
2166
+
2167
+ $e.find('input[name="review"]').click(plugin.methode.reviewQuestion);
2168
+
2169
+ $e.find('input[name="wpProQuiz_toplistAdd"]').click(plugin.methode.addToplist);
2170
+
2171
+ $e.find('input[name="quizSummary"]').click(plugin.methode.showQuizSummary);
2172
+
2173
+ $e.find('input[name="endQuizSummary"]').click(function () {
2174
+ if (bitOptions.forcingQuestionSolve) {
2175
+ for (var i = 0, c = $e.find('.wpProQuiz_listItem').length; i < c; i++) {
2176
+ if (!quizSolved[i]) {
2177
+ alert(WpProQuizGlobal.questionsNotSolved);
2178
+ return false;
2179
+ }
2180
+ }
2181
+ }
2182
+
2183
+ if (bitOptions.formActivated && config.formPos == formPosConst.END && !formClass.checkForm())
2184
+ return;
2185
+
2186
+ plugin.methode.finishQuiz();
2187
+ });
2188
+
2189
+ $e.find('input[name="endInfopage"]').click(function () {
2190
+ if (formClass.checkForm())
2191
+ plugin.methode.finishQuiz();
2192
+ });
2193
+
2194
+ $e.find('input[name="showToplist"]').click(function () {
2195
+ globalElements.quiz.hide();
2196
+ globalElements.toplistShowInButton.toggle();
2197
+ });
2198
+
2199
+ $e.bind('questionSolved', plugin.methode.questionSolved);
2200
+
2201
+ if (!bitOptions.maxShowQuestion) {
2202
+ plugin.methode.initQuiz();
2203
+ }
2204
+
2205
+ if (bitOptions.autoStart)
2206
+ plugin.methode.startQuiz();
2207
+ };
2208
+
2209
+ plugin.preInit();
2210
+ };
2211
+
2212
+ $.fn.wpProQuizFront = function (options) {
2213
+ return this.each(function () {
2214
+ if (undefined == $(this).data('wpProQuizFront')) {
2215
+ $(this).data('wpProQuizFront', new $.wpProQuizFront(this, options));
2216
+ }
2217
+ });
2218
+ };
2219
+
2220
  })(jQuery);
js/wpProQuiz_front.min.js CHANGED
@@ -1,48 +1 @@
1
- (function(g){g.wpProQuizFront=function(M,e){var b=g(M),d=this,h={},A={},V=0,k=null,p=[],W="",F=!1,N=1,X=0,Y=0,G=0,Z=0,H=0,O=0,P=0,w=0,$=0,q=0,aa=0,x=0,ba=0,I=0,Q=0,ca=0,R=0,da=0,S=0,ea=0,fa=0,ga=b.find('input[name="back"]'),y=b.find('input[name="next"]'),n=b.find(".wpProQuiz_quiz"),u=b.find(".wpProQuiz_list"),z=b.find(".wpProQuiz_results"),v=b.find(".wpProQuiz_text"),B=b.find(".wpProQuiz_time_limit"),J=b.find(".wpProQuiz_toplistShowInButton"),T=g(),ha="",U=0,ia=function(){var a=e.timelimit,c=0,b=
2
- {stop:function(){a&&(window.clearInterval(c),B.hide())},start:function(){if(a){var f=1E3*a,m=B.find("span").text(d.methode.parseTime(a)),g=B.find(".wpProQuiz_progress");B.show();var e=+new Date;c=window.setInterval(function(){var a=+new Date-e,c=f-a;500<=a&&m.text(d.methode.parseTime(Math.ceil(c/1E3)));g.css("width",c/f*100+"%");0>=c&&(b.stop(),d.methode.finishQuiz(!0))},16)}}};return b}(),t=new function(){function a(a){var c="",b=C[a];b.review?c="#FFB800":b.solved&&(c="#6CA54C");h.eq(a).css("background-color",
3
- c)}function c(a){a.preventDefault();a=a.pageY-K;0>a&&(a=0);a>k&&(a=k);e.attr("style","margin-top: "+-(D*a)+"px !important");m.css({top:a})}function l(a){a.preventDefault();g(document).unbind(".scrollEvent")}var f=[],m=[],e=[],h=[],k=0,K=0,D=0,L=0,s=0,C=[];this.init=function(){f=b.find(".wpProQuiz_reviewQuestion");m=f.find("div");e=f.find("ol");h=e.children();m.mousedown(function(a){a.preventDefault();a.stopPropagation();K=a.pageY-m.offset().top+L;g(document).bind("mouseup.scrollEvent",l);g(document).bind("mousemove.scrollEvent",
4
- c)});h.click(function(a){d.methode.showQuestion(g(this).index())});b.bind("questionSolved",function(c){C[c.values.index].solved=c.values.solved;a(c.values.index)});b.bind("changeQuestion",function(a){h.removeClass("wpProQuiz_reviewQuestionTarget");h.eq(a.values.index).addClass("wpProQuiz_reviewQuestionTarget");a=h.eq(a.values.index);var c=a.offset().top,b=f.offset().top,c=c-b;if(0>c-4||100<c+32)a=b-h.eq(0).offset().top-(b-e.offset().top)+a.position().top,a>s&&(a=s),b=a/D,e.attr("style","margin-top: "+
5
- -a+"px !important"),m.css({top:b})});b.bind("reviewQuestion",function(c){C[c.values.index].review=!C[c.values.index].review;a(c.values.index)});f.bind("mousewheel DOMMouseScroll",function(a){a.preventDefault();a=a.originalEvent;a=20*(a.wheelDelta?-a.wheelDelta/120:a.detail/3);a=L-e.offset().top+a;a>s&&(a=s);0>a&&(a=0);var c=a/D;e.attr("style","margin-top: "+-a+"px !important");m.css({top:c});return!1})};this.show=function(a){q&&f.parent().show();b.find(".wpProQuiz_reviewDiv .wpProQuiz_button2").show();
6
- if(!a){e.attr("style","margin-top: 0px !important");m.css({top:0});a=e.outerHeight();var c=f.height();k=c-m.height();K=0;s=a-c;D=s/k;this.reset();100<a&&m.show();L=m.offset().top}};this.hide=function(){f.parent().hide()};this.toggle=function(){if(q){f.parent().toggle();h.removeClass("wpProQuiz_reviewQuestionTarget");b.find(".wpProQuiz_reviewDiv .wpProQuiz_button2").hide();e.attr("style","margin-top: 0px !important");m.css({top:0});var a=e.outerHeight(),c=f.height();k=c-m.height();K=0;s=a-c;D=s/k;
7
- 100<a&&m.show();L=m.offset().top}};this.reset=function(){for(var a=0,c=h.length;a<c;a++)C[a]={};h.removeClass("wpProQuiz_reviewQuestionTarget").css("background-color","")}},r=new function(){var a=0,c=-1,b=0,f=!1;this.questionStart=function(b){-1!=c&&this.questionStop();c=b;a=+new Date};this.questionStop=function(){-1!=c&&(h[c].time+=Math.round((new Date-a)/1E3),c=-1)};this.startQuiz=function(){f&&this.stopQuiz();b=+new Date;f=!0};this.stopQuiz=function(){f&&(h.comp.quizTime+=Math.round((new Date-
8
- b)/1E3),f=!1)};this.init=function(){}},ja=function(a,c,b,f){var m=!0,e=0,h=g.isArray(c.points),k={};({singleMulti:function(){var a=f.find(".wpProQuiz_questionInput").attr("disabled","disabled"),b=c.diffMode;f.children().each(function(l){var f=g(this),k=f.data("pos");l=a.eq(l).is(":checked");c.correct[k]?(l?h&&(e=b?c.points[k]:e+c.points[k]):m=!1,c.disCorrect?m=!0:d.methode.marker(f,!0)):l?(c.disCorrect?m=!0:(d.methode.marker(f,!1),m=!1),b&&(e=c.points[k])):h&&!b&&(e+=c.points[k])})},sort_answer:function(){var a=
9
- f.children();a.each(function(a,b){var l=g(this);k[a]=l.data("pos");a==l.data("pos")?(d.methode.marker(l,!0),h&&(e+=c.points[a])):(d.methode.marker(l,!1),m=!1)});a.children().css({"box-shadow":"0 0",cursor:"auto"});f.sortable("destroy");a.sort(function(a,c){return g(a).data("pos")>g(c).data("pos")?1:-1});f.append(a)},matrix_sort_answer:function(){var a=f.children(),n=[];k={0:-1};a.each(function(){var a=g(this),b=a.data("pos"),a=a.find(".wpProQuiz_maxtrixSortCriterion"),l=a.children();l.length&&(k[b]=
10
- l.data("pos"));l.length&&0<=g.inArray(String(b),String(l.data("correct")).split(","))?(d.methode.marker(a,!0),h&&(e+=c.points[b])):(m=!1,d.methode.marker(a,!1));n[b]=a});d.methode.resetMatrix(b);b.find(".wpProQuiz_sortStringItem").each(function(){var a=n[g(this).data("pos")];void 0!=a&&a.append(this)}).css({"box-shadow":"0 0",cursor:"auto"});b.find(".wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion").sortable("destroy")},free_answer:function(){var a=f.children(),b=a.find(".wpProQuiz_questionInput").attr("disabled",
11
- "disabled").val();0<=g.inArray(g.trim(b).toLowerCase(),c.correct)?d.methode.marker(a,!0):(d.methode.marker(a,!1),m=!1)},cloze_answer:function(){f.find(".wpProQuiz_cloze").each(function(a,b){var l=g(this).children(),f=l.eq(0),l=l.eq(1),k=d.methode.cleanupCurlyQuotes(f.val());0<=g.inArray(k,c.correct[a])?(h&&(e+=c.points[a]),G||f.css("background-color","#B0DAB0")):(G||f.css("background-color","#FFBABA"),m=!1,l.show());f.attr("disabled","disabled")})},assessment_answer:function(){m=!0;var a=0;f.find(".wpProQuiz_questionInput").attr("disabled",
12
- "disabled").filter(":checked").each(function(){a+=parseInt(g(this).val())});e=a}})[a]();!h&&m&&(e=c.points);return{c:m,p:e,s:k}},E=new function(){var a={isEmpty:function(a){a=g.trim(a);return!a||0===a.length}};this.checkForm=function(){var c=!0;b.find(".wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select").each(function(){var b=g(this),f=1==b.data("required"),e=b.data("type"),d=!0,h=g.trim(b.val());switch(e){case 0:case 1:case 7:f&&(d=
13
- !a.isEmpty(h));break;case 2:if(f||!a.isEmpty(h))d=!a.isEmpty(h)&&!isNaN(h);break;case 4:if(f||!a.isEmpty(h))d=!a.isEmpty(h)&&(new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)).test(h);break;case 3:f&&(d=b.is(":checked"));break;case 5:case 8:f&&(d=void 0!==b.find('input[type="radio"]:checked').val());break;case 6:var k=0,n=0;b.find("select").each(function(){k++;n+=a.isEmpty(g(this).val())?0:1});if(f||
14
- 0<n)d=k==n}d?b.siblings(".wpProQuiz_invalidate").hide():(c=!1,b.siblings(".wpProQuiz_invalidate").show())});return c};this.getFormData=function(){var a={};b.find(".wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select").each(function(){var b=g(this),f=b.data("form_id");switch(b.data("type")){case 0:case 1:case 7:case 2:case 4:a[f]=b.val();break;case 3:a[f]=b.is(":checked")?1:0;break;case 5:case 8:a[f]=b.find('input[type="radio"]:checked').val();
15
- break;case 6:a[f]={day:b.find('select[name="wpProQuiz_field_'+f+'_day"]').val(),month:b.find('select[name="wpProQuiz_field_'+f+'_month"]').val(),year:b.find('select[name="wpProQuiz_field_'+f+'_year"]').val()}}});return a}},ka=function(a){b.find(".wpProQuiz_questionList").each(function(){var c=g(this),b=c.data("question_id"),f=c.data("type"),e={};if("single"==f||"multiple"==f)c.find(".wpProQuiz_questionListItem").each(function(){e[g(this).data("pos")]=+g(this).find(".wpProQuiz_questionInput").is(":checked")});
16
- else if("free_answer"==f)e[0]=c.find(".wpProQuiz_questionInput").val();else{if("sort_answer"==f||"matrix_sort_answer"==f)return!0;if("cloze_answer"==f){var d=0;c.find(".wpProQuiz_cloze input").each(function(){e[d++]=g(this).val()})}else"assessment_answer"==f&&(e[0]="",c.find(".wpProQuiz_questionInput:checked").each(function(){e[g(this).data("index")]=g(this).val()}))}a[b].data=e})};d.methode={parseBitOptions:function(){if(e.bo){X=e.bo&1;Y=e.bo&2;G=e.bo&4;Z=e.bo&8;H=e.bo&16;P=e.bo&64;q=e.bo&128;w=
17
- e.bo&256;$=e.bo&512;aa=e.bo&1024;x=e.bo&2048;ba=e.bo&4096;I=e.bo&8192;Q=e.bo&16384;ca=e.bo&32768;var a=e.bo&32;a&&void 0!=jQuery.support&&void 0!=jQuery.support.cors&&0==jQuery.support.cors&&(O=a)}},setClozeStyle:function(){b.find(".wpProQuiz_cloze input").each(function(){for(var a=g(this),c="",b=a.data("wordlen"),f=0;f<b;f++)c+="w";c=g(document.createElement("span")).css("visibility","hidden").text(c).appendTo(g("body"));b=c.width();c.remove();a.width(b+5)})},parseTime:function(a){var c=parseInt(a%
18
- 60),b=parseInt(a/60%60);a=parseInt(a/3600%24);return(9<a?"":"0")+a+":"+((9<b?"":"0")+b)+":"+((9<c?"":"0")+c)},cleanupCurlyQuotes:function(a){a=a.replace(/\u2018/,"'");a=a.replace(/\u2019/,"'");a=a.replace(/\u201C/,'"');a=a.replace(/\u201D/,'"');return g.trim(a).toLowerCase()},resetMatrix:function(a){a.each(function(){var a=g(this),b=a.find(".wpProQuiz_sortStringList");a.find(".wpProQuiz_sortStringItem").each(function(){b.append(g(this))})})},marker:function(a,c){G||(c?a.addClass("wpProQuiz_answerCorrect"):
19
- a.addClass("wpProQuiz_answerIncorrect"))},startQuiz:function(a){if(S)R=1;else if(R=0,da)v.hide(),b.find(".wpProQuiz_lock").show();else if(ea)v.hide(),b.find(".wpProQuiz_prerequisite").show();else if(fa)v.hide(),b.find(".wpProQuiz_startOnlyRegisteredUser").show();else if(Q&&!a)v.hide(),b.find(".wpProQuiz_loadQuiz").show(),d.methode.loadQuizDataAjax(!0);else if(!I||0!=e.formPos||E.checkForm()){d.methode.loadQuizData();Y&&d.methode.random(u);X&&d.methode.random(b.find(".wpProQuiz_questionList"));ca&&
20
- d.methode.sortCategories();d.methode.random(b.find(".wpProQuiz_sortStringList"));d.methode.random(b.find('[data-type="sort_answer"]'));b.find(".wpProQuiz_listItem").each(function(a,b){var f=g(this);f.find(".wpProQuiz_question_page span:eq(0)").text(a+1);f.find("> h5 span").text(a+1);f.find(".wpProQuiz_questionListItem").each(function(a,b){g(this).find("> span:not(.wpProQuiz_cloze)").text(a+1+". ")})});y=b.find('input[name="next"]');switch(e.mode){case 3:b.find('input[name="checkSingle"]').show();
21
- break;case 2:b.find('input[name="check"]').show();!$&&q&&b.find('input[name="skip"]').show();break;case 1:b.find('input[name="back"]').slice(1).show();case 0:y.show()}(ba||3==e.mode)&&b.find(".wpProQuiz_question_page").hide();a=y.last();W=a.val();a.val(e.lbn);a=u.children();T=b.find(".wpProQuiz_list > li");3==e.mode?d.methode.showSinglePage(0):(k=a.eq(0).show(),a=k.find(".wpProQuiz_questionList").data("question_id"),r.questionStart(a));r.startQuiz();b.find(".wpProQuiz_sortable").parents("ul").sortable({update:function(a,
22
- e){var f=g(this).parents(".wpProQuiz_listItem");b.trigger({type:"questionSolved",values:{item:f,index:f.index(),solved:!0}})}}).disableSelection();b.find(".wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion").sortable({connectWith:".wpProQuiz_maxtrixSortCriterion:not(:has(li)), .wpProQuiz_sortStringList",placeholder:"wpProQuiz_placehold",update:function(a,e){var f=g(this).parents(".wpProQuiz_listItem");b.trigger({type:"questionSolved",values:{item:f,index:f.index(),solved:!0}})}}).disableSelection();
23
- p=[];ia.start();V=+new Date;h={comp:{points:0,correctQuestions:0,quizTime:0}};b.find(".wpProQuiz_questionList").each(function(){var a=g(this).data("question_id");h[a]={time:0,solved:0}});A={};g.each(e.catPoints,function(a,b){A[a]=0});v.hide();b.find(".wpProQuiz_loadQuiz").hide();n.show();t.show();3!=e.mode&&b.trigger({type:"changeQuestion",values:{item:k,index:k.index()}})}},showSingleQuestion:function(a){a=a?Math.ceil(a/e.qpp):1;this.showSinglePage(a)},showSinglePage:function(a){$listItem=u.children().hide();
24
- if(e.qpp){a=a?+a:1;var c=Math.ceil(b.find(".wpProQuiz_list > li").length/e.qpp);if(!(a>c)){var l=b.find('input[name="wpProQuiz_pageLeft"]').hide(),f=b.find('input[name="wpProQuiz_pageRight"]').hide(),g=b.find('input[name="checkSingle"]').hide();1<a&&l.val(l.data("text").replace(/%d/,a-1)).show();a==c?g.show():f.val(f.data("text").replace(/%d/,a+1)).show();N=a;a=e.qpp*(a-1);$listItem.slice(a,a+e.qpp).show();d.methode.scrollTo(n)}}else $listItem.show()},nextQuestion:function(){this.showQuestionObject(k.next())},
25
- prevQuestion:function(){this.showQuestionObject(k.prev())},showQuestion:function(a){var b=T.eq(a);3==e.mode||F?(e.qpp&&d.methode.showSingleQuestion(a+1),d.methode.scrollTo(b,1),r.startQuiz()):this.showQuestionObject(b)},showQuestionObject:function(a){if(!a.length&&x&&w&&q)for(var c=0,e=b.find(".wpProQuiz_listItem").length;c<e;c++)if(!p[c])return alert(WpProQuizGlobal.questionsNotSolved),!1;k.hide();k=a.show();d.methode.scrollTo(n);b.trigger({type:"changeQuestion",values:{item:k,index:k.index()}});
26
- k.length?(a=k.find(".wpProQuiz_questionList").data("question_id"),r.questionStart(a)):d.methode.showQuizSummary()},skipQuestion:function(){b.trigger({type:"skipQuestion",values:{item:k,index:k.index()}});d.methode.nextQuestion()},reviewQuestion:function(){b.trigger({type:"reviewQuestion",values:{item:k,index:k.index()}})},showQuizSummary:function(){r.questionStop();r.stopQuiz();if(w||!q)I&&1==e.formPos?(t.hide(),n.hide(),d.methode.scrollTo(b.find(".wpProQuiz_infopage").show())):d.methode.finishQuiz();
27
- else{var a=b.find(".wpProQuiz_checkPage");a.find("ol:eq(0)").empty().append(b.find(".wpProQuiz_reviewQuestion ol li").clone().removeClass("wpProQuiz_reviewQuestionTarget")).children().click(function(b){a.hide();n.show();t.show(!0);d.methode.showQuestion(g(this).index())});for(var c=0,l=0,f=p.length;l<f;l++)p[l]&&c++;a.find("span:eq(0)").text(c);t.hide();n.hide();a.show();d.methode.scrollTo(a)}},finishQuiz:function(a){r.questionStop();r.stopQuiz();ia.stop();var c=(+new Date-V)/1E3,c=e.timelimit&&c>
28
- e.timelimit?e.timelimit:c;b.find(".wpProQuiz_quiz_time span").text(d.methode.parseTime(c));a&&z.find(".wpProQuiz_time_limit_expired").show();d.methode.checkQuestion(u.children(),!0);b.find(".wpProQuiz_correct_answer").text(h.comp.correctQuestions);h.comp.result=Math.round(h.comp.points/e.globalPoints*1E4)/100;h.comp.solved=0;a=b.find(".wpProQuiz_points span");a.eq(0).text(h.comp.points);a.eq(1).text(e.globalPoints);a.eq(2).text(h.comp.result+"%");a=b.find(".wpProQuiz_resultsList > li").eq(d.methode.findResultIndex(h.comp.result));
29
- var l=E.getFormData();a.find(".wpProQuiz_resultForm").each(function(){var a=g(this),b=a.data("form_id"),b=l[b];"object"===typeof b&&(b=b.day+"-"+b.month+"-"+b.year);a.text(b).show()});a.show();d.methode.setAverageResult(h.comp.result,!1);this.setCategoryOverview();d.methode.sendCompletedQuiz();P&&U&&d.methode.addToplist();t.hide();b.find(".wpProQuiz_checkPage, .wpProQuiz_infopage").hide();n.hide();z.show();d.methode.scrollTo(z)},setCategoryOverview:function(){h.comp.cats={};b.find(".wpProQuiz_catOverview li").each(function(){var a=
30
- g(this),b=a.data("category_id");if(void 0===e.catPoints[b])return a.hide(),!0;var d=Math.round(A[b]/e.catPoints[b]*1E4)/100;h.comp.cats[b]=d;a.find(".wpProQuiz_catPercent").text(d+"%");a.show()})},questionSolved:function(a){p[a.values.index]=a.values.solved;var b=a.values.item.find(".wpProQuiz_questionList"),b=e.json[b.data("question_id")];h[b.id].solved=Number(a.values.fake?h[b.id].solved:a.values.solved)},sendCompletedQuiz:function(){if(!H){ka(h);var a=E.getFormData();d.methode.ajax({action:"wp_pro_quiz_completed_quiz",
31
- quizId:e.quizId,results:h,forms:a})}},findResultIndex:function(a){for(var b=e.resultsGrade,d=-1,f=999999,g=0;g<b.length;g++){var h=b[g];a>=h&&a-h<f&&(f=a-h,d=g)}return d},showQustionList:function(){F=!F;J.hide();n.toggle();b.find(".wpProQuiz_QuestionButton").hide();u.children().show();t.toggle();b.find(".wpProQuiz_question_page").hide()},random:function(a){a.each(function(){var a=g(this).children().get().sort(function(){return Math.round(Math.random())-.5});g(a).appendTo(a[0].parentNode)})},sortCategories:function(){var a=
32
- g(".wpProQuiz_list").children().get().sort(function(a,b){var f=g(a).find(".wpProQuiz_questionList").data("question_id"),d=g(b).find(".wpProQuiz_questionList").data("question_id");return e.json[f].catId-e.json[d].catId});g(a).appendTo(a[0].parentNode)},restartQuiz:function(){z.hide();v.show();u.children().hide();J.hide();t.hide();b.find(".wpProQuiz_questionInput, .wpProQuiz_cloze input").removeAttr("disabled").removeAttr("checked").css("background-color","");b.find('.wpProQuiz_questionListItem input[type="text"]').val("");
33
- b.find(".wpProQuiz_answerCorrect, .wpProQuiz_answerIncorrect").removeClass("wpProQuiz_answerCorrect wpProQuiz_answerIncorrect");b.find(".wpProQuiz_listItem").data("check",!1);b.find(".wpProQuiz_response").hide().children().hide();d.methode.resetMatrix(b.find(".wpProQuiz_listItem"));b.find(".wpProQuiz_sortStringItem, .wpProQuiz_sortable").removeAttr("style");b.find(".wpProQuiz_clozeCorrect, .wpProQuiz_QuestionButton, .wpProQuiz_resultsList > li").hide();b.find('.wpProQuiz_question_page, input[name="tip"]').show();
34
- b.find(".wpProQuiz_resultForm").text("").hide();z.find(".wpProQuiz_time_limit_expired").hide();y.last().val(W);F=!1},checkQuestion:function(a,c){a=void 0==a?k:a;a.each(function(){var a=g(this),f=a.find(".wpProQuiz_questionList"),d=e.json[f.data("question_id")],k=d.type;r.questionStop();if(a.data("check"))return!0;if("single"==d.type||"multiple"==d.type)k="singleMulti";f=ja(k,d,a,f);a.find(".wpProQuiz_response").show();a.find('input[name="check"]').hide();a.find('input[name="skip"]').hide();a.find('input[name="next"]').show();
35
- h[d.id].points=f.p;h[d.id].correct=Number(f.c);h[d.id].data=f.s;h.comp.points+=f.p;A[d.catId]+=f.p;f.c?(a.find(".wpProQuiz_correct").show(),h.comp.correctQuestions+=1):a.find(".wpProQuiz_incorrect").show();a.find(".wpProQuiz_responsePoints").text(f.p);a.data("check",!0);c||b.trigger({type:"questionSolved",values:{item:a,index:a.index(),solved:!0,fake:!0}})})},showTip:function(){var a=g(this),c=a.siblings(".wpProQuiz_question").find(".wpProQuiz_questionList").data("question_id");a.siblings(".wpProQuiz_tipp").toggle("fast");
36
- h[c].tip=1;g(document).bind("mouseup.tipEvent",function(a){var c=b.find(".wpProQuiz_tipp"),d=b.find('input[name="tip"]');c.is(a.target)||0!=c.has(a.target).length||d.is(a.target)||(c.hide("fast"),g(document).unbind(".tipEvent"))})},ajax:function(a,b,d){O&&(jQuery.support.cors=!0);g.post(WpProQuizGlobal.ajaxurl,a,b,d||"json");O&&(jQuery.support.cors=!1)},checkQuizLock:function(){S=1;d.methode.ajax({action:"wp_pro_quiz_check_lock",quizId:e.quizId},function(a){void 0!=a.lock&&(da=a.lock.is,a.lock.pre&&
37
- b.find('input[name="restartQuiz"]').hide());void 0!=a.prerequisite&&(ea=1,b.find(".wpProQuiz_prerequisite span").text(a.prerequisite));void 0!=a.startUserLock&&(fa=a.startUserLock);S=0;R&&d.methode.startQuiz()})},loadQuizData:function(){d.methode.ajax({action:"wp_pro_quiz_load_quiz_data",quizId:e.quizId},function(a){a.toplist&&d.methode.handleToplistData(a.toplist);void 0!=a.averageResult&&d.methode.setAverageResult(a.averageResult,!0)})},setAverageResult:function(a,c){var d=b.find(".wpProQuiz_resultValue:eq("+
38
- (c?0:1)+") > * ");d.eq(1).text(a+"%");d.eq(0).css("width",240*a/100+"px")},handleToplistData:function(a){var c=b.find(".wpProQuiz_addToplist"),d=c.find(".wpProQuiz_addBox").show().children("div");a.canAdd?(c.show(),c.find(".wpProQuiz_addToplistMessage").hide(),c.find(".wpProQuiz_toplistButton").show(),ha=a.token,U=0,a.userId?(d.hide(),U=1,P&&c.hide()):(d.show(),c=d.children().eq(1),a.captcha?(c.find('input[name="wpProQuiz_captchaPrefix"]').val(a.captcha.code),c.find(".wpProQuiz_captchaImg").attr("src",
39
- a.captcha.img),c.find('input[name="wpProQuiz_captcha"]').val(""),c.show()):c.hide())):c.hide()},scrollTo:function(a,b){var d=a.offset().top-100;(b||(window.pageYOffset||document.body.scrollTop)>d)&&g("html,body").animate({scrollTop:d},300)},addToplist:function(){if(!H){var a=b.find(".wpProQuiz_addToplistMessage").text(WpProQuizGlobal.loadData).show(),c=b.find(".wpProQuiz_addBox").hide();d.methode.ajax({action:"wp_pro_quiz_add_toplist",quizId:e.quizId,token:ha,name:c.find('input[name="wpProQuiz_toplistName"]').val(),
40
- email:c.find('input[name="wpProQuiz_toplistEmail"]').val(),captcha:c.find('input[name="wpProQuiz_captcha"]').val(),prefix:c.find('input[name="wpProQuiz_captchaPrefix"]').val(),points:h.comp.points,totalPoints:e.globalPoints},function(b){a.text(b.text);b.clear?(c.hide(),d.methode.updateToplist()):c.show();b.captcha&&(c.find(".wpProQuiz_captchaImg").attr("src",b.captcha.img),c.find('input[name="wpProQuiz_captchaPrefix"]').val(b.captcha.code),c.find('input[name="wpProQuiz_captcha"]').val(""))})}},updateToplist:function(){"function"==
41
- typeof wpProQuiz_fetchToplist&&wpProQuiz_fetchToplist()},registerSolved:function(){b.find('.wpProQuiz_questionInput[type="text"]').change(function(a){a=g(this);var c=a.parents(".wpProQuiz_listItem"),d=!1;""!=a.val()&&(d=!0);b.trigger({type:"questionSolved",values:{item:c,index:c.index(),solved:d}})});b.find('.wpProQuiz_questionList[data-type="single"] .wpProQuiz_questionInput, .wpProQuiz_questionList[data-type="assessment_answer"] .wpProQuiz_questionInput').change(function(a){a=g(this).parents(".wpProQuiz_listItem");
42
- var c=this.checked;b.trigger({type:"questionSolved",values:{item:a,index:a.index(),solved:c}})});b.find(".wpProQuiz_cloze input").change(function(){var a=g(this).parents(".wpProQuiz_listItem"),c=!0;a.find(".wpProQuiz_cloze input").each(function(){if(""==g(this).val())return c=!1});b.trigger({type:"questionSolved",values:{item:a,index:a.index(),solved:c}})});b.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').change(function(a){a=g(this).parents(".wpProQuiz_listItem");
43
- var c=0;a.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').each(function(a){this.checked&&c++});b.trigger({type:"questionSolved",values:{item:a,index:a.index(),solved:c?!0:!1}})})},loadQuizDataAjax:function(a){d.methode.ajax({action:"wp_pro_quiz_admin_ajax",func:"quizLoadData",data:{quizId:e.quizId}},function(c){e.globalPoints=c.globalPoints;e.catPoints=c.catPoints;e.json=c.json;n.remove();b.find(".wpProQuiz_quizAnker").after(c.content);ga=b.find('input[name="back"]');
44
- y=b.find('input[name="next"]');n=b.find(".wpProQuiz_quiz");u=b.find(".wpProQuiz_list");z=b.find(".wpProQuiz_results");v=b.find(".wpProQuiz_text");B=b.find(".wpProQuiz_time_limit");J=b.find(".wpProQuiz_toplistShowInButton");T=g();d.methode.initQuiz();a&&d.methode.startQuiz(!0)})},initQuiz:function(){d.methode.setClozeStyle();d.methode.registerSolved();y.click(function(){if(x&&!p[k.index()]&&(w||!q))return alert(WpProQuizGlobal.questionNotSolved),!1;d.methode.nextQuestion()});ga.click(function(){d.methode.prevQuestion()});
45
- b.find('input[name="check"]').click(function(){if(x&&!p[k.index()]&&(w||!q))return alert(WpProQuizGlobal.questionNotSolved),!1;d.methode.checkQuestion()});b.find('input[name="checkSingle"]').click(function(){if(x&&(w||!q))for(var a=0,c=b.find(".wpProQuiz_listItem").length;a<c;a++)if(!p[a])return alert(WpProQuizGlobal.questionsNotSolved),!1;d.methode.showQuizSummary()});b.find('input[name="tip"]').click(d.methode.showTip);b.find('input[name="skip"]').click(d.methode.skipQuestion);b.find('input[name="wpProQuiz_pageLeft"]').click(function(){d.methode.showSinglePage(N-
46
- 1)});b.find('input[name="wpProQuiz_pageRight"]').click(function(){d.methode.showSinglePage(N+1)})}};d.preInit=function(){d.methode.parseBitOptions();t.init();b.find('input[name="startQuiz"]').click(function(){d.methode.startQuiz();return!1});Z&&!H&&d.methode.checkQuizLock();b.find('input[name="reShowQuestion"]').click(function(){d.methode.showQustionList()});b.find('input[name="restartQuiz"]').click(function(){d.methode.restartQuiz()});b.find('input[name="review"]').click(d.methode.reviewQuestion);
47
- b.find('input[name="wpProQuiz_toplistAdd"]').click(d.methode.addToplist);b.find('input[name="quizSummary"]').click(d.methode.showQuizSummary);b.find('input[name="endQuizSummary"]').click(function(){if(x)for(var a=0,c=b.find(".wpProQuiz_listItem").length;a<c;a++)if(!p[a])return alert(WpProQuizGlobal.questionsNotSolved),!1;I&&1==e.formPos&&!E.checkForm()||d.methode.finishQuiz()});b.find('input[name="endInfopage"]').click(function(){E.checkForm()&&d.methode.finishQuiz()});b.find('input[name="showToplist"]').click(function(){n.hide();
48
- J.toggle()});b.bind("questionSolved",d.methode.questionSolved);Q||d.methode.initQuiz();aa&&d.methode.startQuiz()};d.preInit()};g.fn.wpProQuizFront=function(M){return this.each(function(){void 0==g(this).data("wpProQuizFront")&&g(this).data("wpProQuizFront",new g.wpProQuizFront(this,M))})}})(jQuery);
1
+ !function(i,e){function t(){if(!r){r=!0;for(var i=0;i<n.length;i++)n[i].fn.call(window,n[i].ctx);n=[]}}function o(){"complete"===document.readyState&&t()}i=i||"wpProQuizReady",e=e||window;var n=[],r=!1,s=!1;e[i]=function(i,e){return r?void setTimeout(function(){i(e)},1):(n.push({fn:i,ctx:e}),void("complete"===document.readyState?setTimeout(t,1):s||(document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):(document.attachEvent("onreadystatechange",o),window.attachEvent("onload",t)),s=!0)))}}("wpProQuizReady",window),wpProQuizReady(function(){for(var i=window.wpProQuizInitList||[],e=0;e<i.length;e++)jQuery(i[e].id).wpProQuizFront(i[e].init)}),function(i){i.wpProQuizFront=function(e,t){function o(){var i=0,e=-1,t=0,o=!1;this.questionStart=function(t){-1!=e&&this.questionStop(),e=t,i=+new Date},this.questionStop=function(){-1!=e&&(a[e].time+=Math.round((new Date-i)/1e3),e=-1)},this.startQuiz=function(){o&&this.stopQuiz(),t=+new Date,o=!0},this.stopQuiz=function(){o&&(a.comp.quizTime+=Math.round((new Date-t)/1e3),o=!1)},this.init=function(){}}var n=i(e),r=t,s=this,a=new Object,u=new Object,d=0,c=null,p=[],l="",h=!1,f=1,m={randomAnswer:0,randomQuestion:0,disabledAnswerMark:0,checkBeforeStart:0,preview:0,cors:0,isAddAutomatic:0,quizSummeryHide:0,skipButton:0,reviewQustion:0,autoStart:0,forcingQuestionSolve:0,hideQuestionPositionOverview:0,formActivated:0,maxShowQuestion:0,sortCategories:0},w={isQuizStart:0,isLocked:0,loadLock:0,isPrerequisite:0,isUserStartLocked:0},Q={check:'input[name="check"]',next:'input[name="next"]',questionList:".wpProQuiz_questionList",skip:'input[name="skip"]',singlePageLeft:'input[name="wpProQuiz_pageLeft"]',singlePageRight:'input[name="wpProQuiz_pageRight"]'},v={back:n.find('input[name="back"]'),next:n.find(Q.next),quiz:n.find(".wpProQuiz_quiz"),questionList:n.find(".wpProQuiz_list"),results:n.find(".wpProQuiz_results"),quizStartPage:n.find(".wpProQuiz_text"),timelimit:n.find(".wpProQuiz_time_limit"),toplistShowInButton:n.find(".wpProQuiz_toplistShowInButton"),listItems:i()},z={token:"",isUser:0},_={START:0,END:1},P=function(){var i=r.timelimit,e=0,t={};return t.stop=function(){i&&(window.clearInterval(e),v.timelimit.hide())},t.start=function(){if(i){var o=1e3*i,n=v.timelimit.find("span").text(s.methode.parseTime(i)),r=v.timelimit.find(".wpProQuiz_progress");v.timelimit.show();var a=+new Date;e=window.setInterval(function(){var i=+new Date-a,e=o-i;i>=500&&n.text(s.methode.parseTime(Math.ceil(e/1e3))),r.css("width",e/o*100+"%"),0>=e&&(t.stop(),s.methode.finishQuiz(!0))},16)}},t}(),g=new function(){function e(i){var e=c.eq(i),t=e.offset().top,o=a.offset().top,n=t-o;if(0>n-4||n+32>100){var r=o-c.eq(0).offset().top-(o-d.offset().top)+e.position().top;r>w&&(r=w);var s=r/h;d.attr("style","margin-top: "+-r+"px !important"),u.css({top:s})}}function t(i){var e="",t=Q[i];t.review?e="#FFB800":t.solved&&(e="#6CA54C"),c.eq(i).css("background-color",e)}function o(i){i.preventDefault();var e=i.pageY-l;0>e&&(e=0),e>p&&(e=p);var t=h*e;d.attr("style","margin-top: "+-t+"px !important"),u.css({top:e})}function r(e){e.preventDefault(),i(document).unbind(".scrollEvent")}var a=[],u=[],d=[],c=[],p=0,l=0,h=0,f=0,w=0,Q=[];this.init=function(){a=n.find(".wpProQuiz_reviewQuestion"),u=a.find("div"),d=a.find("ol"),c=d.children(),u.mousedown(function(e){e.preventDefault(),e.stopPropagation(),l=e.pageY-u.offset().top+f,i(document).bind("mouseup.scrollEvent",r),i(document).bind("mousemove.scrollEvent",o)}),c.click(function(e){s.methode.showQuestion(i(this).index())}),n.bind("questionSolved",function(i){Q[i.values.index].solved=i.values.solved,t(i.values.index)}),n.bind("changeQuestion",function(i){c.removeClass("wpProQuiz_reviewQuestionTarget"),c.eq(i.values.index).addClass("wpProQuiz_reviewQuestionTarget"),e(i.values.index)}),n.bind("reviewQuestion",function(i){Q[i.values.index].review=!Q[i.values.index].review,t(i.values.index)}),a.bind("mousewheel DOMMouseScroll",function(i){i.preventDefault();var e=i.originalEvent,t=e.wheelDelta?-e.wheelDelta/120:e.detail/3,o=20*t,n=f-d.offset().top+o;n>w&&(n=w),0>n&&(n=0);var r=n/h;return d.attr("style","margin-top: "+-n+"px !important"),u.css({top:r}),!1})},this.show=function(i){if(m.reviewQustion&&a.parent().show(),n.find(".wpProQuiz_reviewDiv .wpProQuiz_button2").show(),!i){d.attr("style","margin-top: 0px !important"),u.css({top:0});var e=d.outerHeight(),t=a.height();p=t-u.height(),l=0,w=e-t,h=w/p,this.reset(),e>100&&u.show(),f=u.offset().top}},this.hide=function(){a.parent().hide()},this.toggle=function(){if(m.reviewQustion){a.parent().toggle(),c.removeClass("wpProQuiz_reviewQuestionTarget"),n.find(".wpProQuiz_reviewDiv .wpProQuiz_button2").hide(),d.attr("style","margin-top: 0px !important"),u.css({top:0});var i=d.outerHeight(),e=a.height();p=e-u.height(),l=0,w=i-e,h=w/p,i>100&&u.show(),f=u.offset().top}},this.reset=function(){for(var i=0,e=c.length;e>i;i++)Q[i]={};c.removeClass("wpProQuiz_reviewQuestionTarget").css("background-color","")}},q=new o,x=function(e,t,o,n){var r=!0,a=0,u=i.isArray(t.points),d={},c={singleMulti:function(){var e=n.find(".wpProQuiz_questionInput").attr("disabled","disabled"),o=t.diffMode;n.children().each(function(n){var d=i(this),c=d.data("pos"),p=e.eq(n).is(":checked");t.correct[c]?(p?u&&(o?a=t.points[c]:a+=t.points[c]):r=!1,t.disCorrect?r=!0:s.methode.marker(d,!0)):p?(t.disCorrect?r=!0:(s.methode.marker(d,!1),r=!1),o&&(a=t.points[c])):u&&!o&&(a+=t.points[c])})},sort_answer:function(){var e=n.children();e.each(function(e,o){var n=i(this);d[e]=n.data("pos"),e==n.data("pos")?(s.methode.marker(n,!0),u&&(a+=t.points[e])):(s.methode.marker(n,!1),r=!1)}),e.children().css({"box-shadow":"0 0",cursor:"auto"}),n.sortable("destroy"),e.sort(function(e,t){return i(e).data("pos")>i(t).data("pos")?1:-1}),n.append(e)},matrix_sort_answer:function(){var e=n.children(),c=new Array;d={0:-1},e.each(function(){var e=i(this),o=e.data("pos"),n=e.find(".wpProQuiz_maxtrixSortCriterion"),p=n.children();p.length&&(d[o]=p.data("pos")),p.length&&i.inArray(String(o),String(p.data("correct")).split(","))>=0?(s.methode.marker(n,!0),u&&(a+=t.points[o])):(r=!1,s.methode.marker(n,!1)),c[o]=n}),s.methode.resetMatrix(o),o.find(".wpProQuiz_sortStringItem").each(function(){var e=c[i(this).data("pos")];void 0!=e&&e.append(this)}).css({"box-shadow":"0 0",cursor:"auto"}),o.find(".wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion").sortable("destroy")},free_answer:function(){var e=n.children(),o=e.find(".wpProQuiz_questionInput").attr("disabled","disabled").val();i.inArray(i.trim(o).toLowerCase(),t.correct)>=0?s.methode.marker(e,!0):(s.methode.marker(e,!1),r=!1)},cloze_answer:function(){n.find(".wpProQuiz_cloze").each(function(e,o){var n=i(this),d=n.children(),c=d.eq(0),p=d.eq(1),l=s.methode.cleanupCurlyQuotes(c.val());i.inArray(l,t.correct[e])>=0?(u&&(a+=t.points[e]),m.disabledAnswerMark||c.css("background-color","#B0DAB0")):(m.disabledAnswerMark||c.css("background-color","#FFBABA"),r=!1,p.show()),c.attr("disabled","disabled")})},assessment_answer:function(){r=!0;var e=n.find(".wpProQuiz_questionInput").attr("disabled","disabled"),t=0;e.filter(":checked").each(function(){t+=parseInt(i(this).val())}),a=t}};return c[e](),!u&&r&&(a=t.points),{c:r,p:a,s:d}},k=new function(){var e={isEmpty:function(e){return e=i.trim(e),!e||0===e.length}},t={TEXT:0,TEXTAREA:1,NUMBER:2,CHECKBOX:3,EMAIL:4,YES_NO:5,DATE:6,SELECT:7,RADIO:8};this.checkForm=function(){var o=!0;return n.find(".wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select").each(function(){var n=i(this),r=1==n.data("required"),s=n.data("type"),a=!0,u=i.trim(n.val());switch(s){case t.TEXT:case t.TEXTAREA:case t.SELECT:r&&(a=!e.isEmpty(u));break;case t.NUMBER:(r||!e.isEmpty(u))&&(a=!e.isEmpty(u)&&!isNaN(u));break;case t.EMAIL:(r||!e.isEmpty(u))&&(a=!e.isEmpty(u)&&new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/).test(u));break;case t.CHECKBOX:r&&(a=n.is(":checked"));break;case t.YES_NO:case t.RADIO:r&&(a=void 0!==n.find('input[type="radio"]:checked').val());break;case t.DATE:var d=0,c=0;n.find("select").each(function(){d++,c+=e.isEmpty(i(this).val())?0:1}),(r||c>0)&&(a=d==c)}a?n.siblings(".wpProQuiz_invalidate").hide():(o=!1,n.siblings(".wpProQuiz_invalidate").show())}),o},this.getFormData=function(){var e={};return n.find(".wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select").each(function(){var o=i(this),n=o.data("form_id"),r=o.data("type");switch(r){case t.TEXT:case t.TEXTAREA:case t.SELECT:case t.NUMBER:case t.EMAIL:e[n]=o.val();break;case t.CHECKBOX:e[n]=o.is(":checked")?1:0;break;case t.YES_NO:case t.RADIO:e[n]=o.find('input[type="radio"]:checked').val();break;case t.DATE:e[n]={day:o.find('select[name="wpProQuiz_field_'+n+'_day"]').val(),month:o.find('select[name="wpProQuiz_field_'+n+'_month"]').val(),year:o.find('select[name="wpProQuiz_field_'+n+'_year"]').val()}}}),e}},S=function(e){n.find(".wpProQuiz_questionList").each(function(){var t=i(this),o=t.data("question_id"),n=t.data("type"),r={};if("single"==n||"multiple"==n)t.find(".wpProQuiz_questionListItem").each(function(){r[i(this).data("pos")]=+i(this).find(".wpProQuiz_questionInput").is(":checked")});else if("free_answer"==n)r[0]=t.find(".wpProQuiz_questionInput").val();else{if("sort_answer"==n)return!0;if("matrix_sort_answer"==n)return!0;if("cloze_answer"==n){var s=0;t.find(".wpProQuiz_cloze input").each(function(){r[s++]=i(this).val()})}else"assessment_answer"==n&&(r[0]="",t.find(".wpProQuiz_questionInput:checked").each(function(){r[i(this).data("index")]=i(this).val()}))}e[o].data=r})};s.methode={parseBitOptions:function(){if(r.bo){m.randomAnswer=1&r.bo,m.randomQuestion=2&r.bo,m.disabledAnswerMark=4&r.bo,m.checkBeforeStart=8&r.bo,m.preview=16&r.bo,m.isAddAutomatic=64&r.bo,m.reviewQustion=128&r.bo,m.quizSummeryHide=256&r.bo,m.skipButton=512&r.bo,m.autoStart=1024&r.bo,m.forcingQuestionSolve=2048&r.bo,m.hideQuestionPositionOverview=4096&r.bo,m.formActivated=8192&r.bo,m.maxShowQuestion=16384&r.bo,m.sortCategories=32768&r.bo;var i=32&r.bo;i&&void 0!=jQuery.support&&void 0!=jQuery.support.cors&&0==jQuery.support.cors&&(m.cors=i)}},setClozeStyle:function(){n.find(".wpProQuiz_cloze input").each(function(){for(var e=i(this),t="",o=e.data("wordlen"),n=0;o>n;n++)t+="w";var r=i(document.createElement("span")).css("visibility","hidden").text(t).appendTo(i("body")),s=r.width();r.remove(),e.width(s+5)})},parseTime:function(i){var e=parseInt(i%60),t=parseInt(i/60%60),o=parseInt(i/3600%24);return e=(e>9?"":"0")+e,t=(t>9?"":"0")+t,o=(o>9?"":"0")+o,o+":"+t+":"+e},cleanupCurlyQuotes:function(e){return e=e.replace(/\u2018/,"'"),e=e.replace(/\u2019/,"'"),e=e.replace(/\u201C/,'"'),e=e.replace(/\u201D/,'"'),i.trim(e).toLowerCase()},resetMatrix:function(e){e.each(function(){var e=i(this),t=e.find(".wpProQuiz_sortStringList");e.find(".wpProQuiz_sortStringItem").each(function(){t.append(i(this))})})},marker:function(i,e){m.disabledAnswerMark||(e?i.addClass("wpProQuiz_answerCorrect"):i.addClass("wpProQuiz_answerIncorrect"))},startQuiz:function(e){if(w.loadLock)return void(w.isQuizStart=1);if(w.isQuizStart=0,w.isLocked)return v.quizStartPage.hide(),void n.find(".wpProQuiz_lock").show();if(w.isPrerequisite)return v.quizStartPage.hide(),void n.find(".wpProQuiz_prerequisite").show();if(w.isUserStartLocked)return v.quizStartPage.hide(),void n.find(".wpProQuiz_startOnlyRegisteredUser").show();if(m.maxShowQuestion&&!e)return v.quizStartPage.hide(),n.find(".wpProQuiz_loadQuiz").show(),void s.methode.loadQuizDataAjax(!0);if(!m.formActivated||r.formPos!=_.START||k.checkForm()){switch(s.methode.loadQuizData(),m.randomQuestion&&s.methode.random(v.questionList),m.randomAnswer&&s.methode.random(n.find(Q.questionList)),m.sortCategories&&s.methode.sortCategories(),s.methode.random(n.find(".wpProQuiz_sortStringList")),s.methode.random(n.find('[data-type="sort_answer"]')),n.find(".wpProQuiz_listItem").each(function(e,t){var o=i(this);o.find(".wpProQuiz_question_page span:eq(0)").text(e+1),o.find("> h5 span").text(e+1),o.find(".wpProQuiz_questionListItem").each(function(e,t){i(this).find("> span:not(.wpProQuiz_cloze)").text(e+1+". ")})}),v.next=n.find(Q.next),r.mode){case 3:n.find('input[name="checkSingle"]').show();break;case 2:n.find(Q.check).show(),!m.skipButton&&m.reviewQustion&&n.find(Q.skip).show();break;case 1:n.find('input[name="back"]').slice(1).show();case 0:v.next.show()}(m.hideQuestionPositionOverview||3==r.mode)&&n.find(".wpProQuiz_question_page").hide();var o=v.next.last();l=o.val(),o.val(r.lbn);var h=v.questionList.children();if(v.listItems=n.find(".wpProQuiz_list > li"),3==r.mode)s.methode.showSinglePage(0);else{c=h.eq(0).show();var f=c.find(Q.questionList).data("question_id");q.questionStart(f)}q.startQuiz(),n.find(".wpProQuiz_sortable").parents("ul").sortable({update:function(e,t){var o=i(this).parents(".wpProQuiz_listItem");n.trigger({type:"questionSolved",values:{item:o,index:o.index(),solved:!0}})}}).disableSelection(),n.find(".wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion").sortable({connectWith:".wpProQuiz_maxtrixSortCriterion:not(:has(li)), .wpProQuiz_sortStringList",placeholder:"wpProQuiz_placehold",update:function(e,t){var o=i(this).parents(".wpProQuiz_listItem");n.trigger({type:"questionSolved",values:{item:o,index:o.index(),solved:!0}})}}).disableSelection(),p=[],P.start(),d=+new Date,a={comp:{points:0,correctQuestions:0,quizTime:0}},n.find(".wpProQuiz_questionList").each(function(){var e=i(this).data("question_id");a[e]={time:0,solved:0}}),u={},i.each(t.catPoints,function(i,e){u[i]=0}),v.quizStartPage.hide(),n.find(".wpProQuiz_loadQuiz").hide(),v.quiz.show(),g.show(),3!=r.mode&&n.trigger({type:"changeQuestion",values:{item:c,index:c.index()}})}},showSingleQuestion:function(i){var e=i?Math.ceil(i/r.qpp):1;this.showSinglePage(e)},showSinglePage:function(i){if($listItem=v.questionList.children().hide(),!r.qpp)return void $listItem.show();i=i?+i:1;var e=Math.ceil(n.find(".wpProQuiz_list > li").length/r.qpp);if(!(i>e)){var t=n.find(Q.singlePageLeft).hide(),o=n.find(Q.singlePageRight).hide(),a=n.find('input[name="checkSingle"]').hide();i>1&&t.val(t.data("text").replace(/%d/,i-1)).show(),i==e?a.show():o.val(o.data("text").replace(/%d/,i+1)).show(),f=i;var u=r.qpp*(i-1);$listItem.slice(u,u+r.qpp).show(),s.methode.scrollTo(v.quiz)}},nextQuestion:function(){this.showQuestionObject(c.next())},prevQuestion:function(){this.showQuestionObject(c.prev())},showQuestion:function(i){var e=v.listItems.eq(i);return 3==r.mode||h?(r.qpp&&s.methode.showSingleQuestion(i+1),s.methode.scrollTo(e,1),void q.startQuiz()):void this.showQuestionObject(e)},showQuestionObject:function(i){if(!i.length&&m.forcingQuestionSolve&&m.quizSummeryHide&&m.reviewQustion)for(var e=0,t=n.find(".wpProQuiz_listItem").length;t>e;e++)if(!p[e])return alert(WpProQuizGlobal.questionsNotSolved),!1;if(c.hide(),c=i.show(),s.methode.scrollTo(v.quiz),n.trigger({type:"changeQuestion",values:{item:c,index:c.index()}}),c.length){var o=c.find(Q.questionList).data("question_id");q.questionStart(o)}else s.methode.showQuizSummary()},skipQuestion:function(){n.trigger({type:"skipQuestion",values:{item:c,index:c.index()}}),s.methode.nextQuestion()},reviewQuestion:function(){n.trigger({type:"reviewQuestion",values:{item:c,index:c.index()}})},showQuizSummary:function(){if(q.questionStop(),q.stopQuiz(),m.quizSummeryHide||!m.reviewQustion)return void(m.formActivated&&r.formPos==_.END?(g.hide(),v.quiz.hide(),s.methode.scrollTo(n.find(".wpProQuiz_infopage").show())):s.methode.finishQuiz());var e=n.find(".wpProQuiz_checkPage");e.find("ol:eq(0)").empty().append(n.find(".wpProQuiz_reviewQuestion ol li").clone().removeClass("wpProQuiz_reviewQuestionTarget")).children().click(function(t){e.hide(),v.quiz.show(),g.show(!0),s.methode.showQuestion(i(this).index())});for(var t=0,o=0,a=p.length;a>o;o++)p[o]&&t++;e.find("span:eq(0)").text(t),g.hide(),v.quiz.hide(),e.show(),s.methode.scrollTo(e)},finishQuiz:function(e){q.questionStop(),q.stopQuiz(),P.stop();var t=(+new Date-d)/1e3;t=r.timelimit&&t>r.timelimit?r.timelimit:t,n.find(".wpProQuiz_quiz_time span").text(s.methode.parseTime(t)),e&&v.results.find(".wpProQuiz_time_limit_expired").show(),s.methode.checkQuestion(v.questionList.children(),!0),n.find(".wpProQuiz_correct_answer").text(a.comp.correctQuestions),a.comp.result=Math.round(a.comp.points/r.globalPoints*100*100)/100,a.comp.solved=0;var o=n.find(".wpProQuiz_points span");o.eq(0).text(a.comp.points),o.eq(1).text(r.globalPoints),o.eq(2).text(a.comp.result+"%");var u=n.find(".wpProQuiz_resultsList > li").eq(s.methode.findResultIndex(a.comp.result)),c=k.getFormData();u.find(".wpProQuiz_resultForm").each(function(){var e=i(this),t=e.data("form_id"),o=c[t];"object"==typeof o&&(o=o.day+"-"+o.month+"-"+o.year),e.text(o).show()}),u.show(),s.methode.setAverageResult(a.comp.result,!1),this.setCategoryOverview(),s.methode.sendCompletedQuiz(),m.isAddAutomatic&&z.isUser&&s.methode.addToplist(),g.hide(),n.find(".wpProQuiz_checkPage, .wpProQuiz_infopage").hide(),v.quiz.hide(),v.results.show(),s.methode.scrollTo(v.results)},setCategoryOverview:function(){a.comp.cats={},n.find(".wpProQuiz_catOverview li").each(function(){var e=i(this),t=e.data("category_id");if(void 0===r.catPoints[t])return e.hide(),!0;var o=Math.round(u[t]/r.catPoints[t]*100*100)/100;a.comp.cats[t]=o,e.find(".wpProQuiz_catPercent").text(o+"%"),e.show()})},questionSolved:function(i){p[i.values.index]=i.values.solved;var e=i.values.item.find(Q.questionList),t=r.json[e.data("question_id")];a[t.id].solved=Number(i.values.fake?a[t.id].solved:i.values.solved)},sendCompletedQuiz:function(){if(!m.preview){S(a);var i=k.getFormData();s.methode.ajax({action:"wp_pro_quiz_admin_ajax",func:"completedQuiz",data:{quizId:r.quizId,results:a,forms:i}})}},findResultIndex:function(i){for(var e=r.resultsGrade,t=-1,o=999999,n=0;n<e.length;n++){var s=e[n];i>=s&&o>i-s&&(o=i-s,t=n)}return t},showQustionList:function(){h=!h,v.toplistShowInButton.hide(),v.quiz.toggle(),n.find(".wpProQuiz_QuestionButton").hide(),v.questionList.children().show(),g.toggle(),n.find(".wpProQuiz_question_page").hide()},random:function(e){e.each(function(){var e=i(this).children().get().sort(function(){return Math.round(Math.random())-.5});i(e).appendTo(e[0].parentNode)})},sortCategories:function(){var e=i(".wpProQuiz_list").children().get().sort(function(e,t){var o=i(e).find(".wpProQuiz_questionList").data("question_id"),n=i(t).find(".wpProQuiz_questionList").data("question_id");return r.json[o].catId-r.json[n].catId});i(e).appendTo(e[0].parentNode)},restartQuiz:function(){v.results.hide(),v.quizStartPage.show(),v.questionList.children().hide(),v.toplistShowInButton.hide(),g.hide(),n.find(".wpProQuiz_questionInput, .wpProQuiz_cloze input").removeAttr("disabled").removeAttr("checked").css("background-color",""),n.find('.wpProQuiz_questionListItem input[type="text"]').val(""),n.find(".wpProQuiz_answerCorrect, .wpProQuiz_answerIncorrect").removeClass("wpProQuiz_answerCorrect wpProQuiz_answerIncorrect"),n.find(".wpProQuiz_listItem").data("check",!1),n.find(".wpProQuiz_response").hide().children().hide(),s.methode.resetMatrix(n.find(".wpProQuiz_listItem")),n.find(".wpProQuiz_sortStringItem, .wpProQuiz_sortable").removeAttr("style"),n.find(".wpProQuiz_clozeCorrect, .wpProQuiz_QuestionButton, .wpProQuiz_resultsList > li").hide(),n.find('.wpProQuiz_question_page, input[name="tip"]').show(),n.find(".wpProQuiz_resultForm").text("").hide(),v.results.find(".wpProQuiz_time_limit_expired").hide(),v.next.last().val(l),h=!1},checkQuestion:function(e,t){e=void 0==e?c:e,e.each(function(){var e=i(this),o=e.find(Q.questionList),s=r.json[o.data("question_id")],d=s.type;if(q.questionStop(),e.data("check"))return!0;("single"==s.type||"multiple"==s.type)&&(d="singleMulti");var c=x(d,s,e,o);e.find(".wpProQuiz_response").show(),e.find(Q.check).hide(),e.find(Q.skip).hide(),e.find(Q.next).show(),a[s.id].points=c.p,a[s.id].correct=Number(c.c),a[s.id].data=c.s,a.comp.points+=c.p,u[s.catId]+=c.p,c.c?(e.find(".wpProQuiz_correct").show(),a.comp.correctQuestions+=1):e.find(".wpProQuiz_incorrect").show(),e.find(".wpProQuiz_responsePoints").text(c.p),e.data("check",!0),t||n.trigger({type:"questionSolved",values:{item:e,index:e.index(),solved:!0,fake:!0}})})},showTip:function(){var e=i(this),t=e.siblings(".wpProQuiz_question").find(Q.questionList).data("question_id");e.siblings(".wpProQuiz_tipp").toggle("fast"),a[t].tip=1,i(document).bind("mouseup.tipEvent",function(e){var t=n.find(".wpProQuiz_tipp"),o=n.find('input[name="tip"]');t.is(e.target)||0!=t.has(e.target).length||o.is(e.target)||(t.hide("fast"),i(document).unbind(".tipEvent"))})},ajax:function(e,t,o){o=o||"json",m.cors&&(jQuery.support.cors=!0),i.post(WpProQuizGlobal.ajaxurl,e,t,o),m.cors&&(jQuery.support.cors=!1)},checkQuizLock:function(){w.loadLock=1,s.methode.ajax({action:"wp_pro_quiz_admin_ajax",func:"quizCheckLock",data:{quizId:r.quizId}},function(i){void 0!=i.lock&&(w.isLocked=i.lock.is,i.lock.pre&&n.find('input[name="restartQuiz"]').hide()),void 0!=i.prerequisite&&(w.isPrerequisite=1,n.find(".wpProQuiz_prerequisite span").text(i.prerequisite)),void 0!=i.startUserLock&&(w.isUserStartLocked=i.startUserLock),w.loadLock=0,w.isQuizStart&&s.methode.startQuiz()})},loadQuizData:function(){s.methode.ajax({action:"wp_pro_quiz_admin_ajax",func:"loadQuizData",data:{quizId:r.quizId}},function(i){i.toplist&&s.methode.handleToplistData(i.toplist),void 0!=i.averageResult&&s.methode.setAverageResult(i.averageResult,!0)})},setAverageResult:function(i,e){var t=n.find(".wpProQuiz_resultValue:eq("+(e?0:1)+") > * ");t.eq(1).text(i+"%"),t.eq(0).css("width",240*i/100+"px")},handleToplistData:function(i){var e=n.find(".wpProQuiz_addToplist"),t=e.find(".wpProQuiz_addBox").show().children("div");if(i.canAdd)if(e.show(),e.find(".wpProQuiz_addToplistMessage").hide(),e.find(".wpProQuiz_toplistButton").show(),z.token=i.token,z.isUser=0,i.userId)t.hide(),z.isUser=1,m.isAddAutomatic&&e.hide();else{t.show();var o=t.children().eq(1);i.captcha?(o.find('input[name="wpProQuiz_captchaPrefix"]').val(i.captcha.code),o.find(".wpProQuiz_captchaImg").attr("src",i.captcha.img),o.find('input[name="wpProQuiz_captcha"]').val(""),o.show()):o.hide()}else e.hide()},scrollTo:function(e,t){var o=e.offset().top-100;(t||(window.pageYOffset||document.body.scrollTop)>o)&&i("html,body").animate({scrollTop:o},300)},addToplist:function(){if(!m.preview){var i=n.find(".wpProQuiz_addToplistMessage").text(WpProQuizGlobal.loadData).show(),e=n.find(".wpProQuiz_addBox").hide();s.methode.ajax({action:"wp_pro_quiz_admin_ajax",func:"addInToplist",data:{quizId:r.quizId,token:z.token,name:e.find('input[name="wpProQuiz_toplistName"]').val(),email:e.find('input[name="wpProQuiz_toplistEmail"]').val(),captcha:e.find('input[name="wpProQuiz_captcha"]').val(),prefix:e.find('input[name="wpProQuiz_captchaPrefix"]').val(),points:a.comp.points,totalPoints:r.globalPoints}},function(t){i.text(t.text),t.clear?(e.hide(),s.methode.updateToplist()):e.show(),t.captcha&&(e.find(".wpProQuiz_captchaImg").attr("src",t.captcha.img),e.find('input[name="wpProQuiz_captchaPrefix"]').val(t.captcha.code),e.find('input[name="wpProQuiz_captcha"]').val(""))})}},updateToplist:function(){"function"==typeof wpProQuiz_fetchToplist&&wpProQuiz_fetchToplist()},registerSolved:function(){n.find('.wpProQuiz_questionInput[type="text"]').change(function(e){var t=i(this),o=t.parents(".wpProQuiz_listItem"),r=!1;""!=t.val()&&(r=!0),n.trigger({type:"questionSolved",values:{item:o,index:o.index(),solved:r}})}),n.find('.wpProQuiz_questionList[data-type="single"] .wpProQuiz_questionInput, .wpProQuiz_questionList[data-type="assessment_answer"] .wpProQuiz_questionInput').change(function(e){var t=i(this),o=t.parents(".wpProQuiz_listItem"),r=this.checked;n.trigger({type:"questionSolved",values:{item:o,index:o.index(),solved:r}})}),n.find(".wpProQuiz_cloze input").change(function(){var e=i(this),t=e.parents(".wpProQuiz_listItem"),o=!0;t.find(".wpProQuiz_cloze input").each(function(){return""==i(this).val()?(o=!1,!1):void 0}),n.trigger({type:"questionSolved",values:{item:t,index:t.index(),solved:o}})}),n.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').change(function(e){var t=i(this),o=t.parents(".wpProQuiz_listItem"),r=0;o.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').each(function(i){this.checked&&r++}),n.trigger({type:"questionSolved",values:{item:o,index:o.index(),solved:r?!0:!1}})})},loadQuizDataAjax:function(e){s.methode.ajax({action:"wp_pro_quiz_admin_ajax",func:"quizLoadData",data:{quizId:r.quizId}},function(t){r.globalPoints=t.globalPoints,r.catPoints=t.catPoints,r.json=t.json,v.quiz.remove(),n.find(".wpProQuiz_quizAnker").after(t.content),v={back:n.find('input[name="back"]'),next:n.find(Q.next),quiz:n.find(".wpProQuiz_quiz"),questionList:n.find(".wpProQuiz_list"),results:n.find(".wpProQuiz_results"),quizStartPage:n.find(".wpProQuiz_text"),timelimit:n.find(".wpProQuiz_time_limit"),toplistShowInButton:n.find(".wpProQuiz_toplistShowInButton"),listItems:i()},s.methode.initQuiz(),e&&s.methode.startQuiz(!0)})},initQuiz:function(){s.methode.setClozeStyle(),s.methode.registerSolved(),v.next.click(function(){return!m.forcingQuestionSolve||p[c.index()]||!m.quizSummeryHide&&m.reviewQustion?void s.methode.nextQuestion():(alert(WpProQuizGlobal.questionNotSolved),!1)}),v.back.click(function(){s.methode.prevQuestion()}),n.find(Q.check).click(function(){return!m.forcingQuestionSolve||p[c.index()]||!m.quizSummeryHide&&m.reviewQustion?void s.methode.checkQuestion():(alert(WpProQuizGlobal.questionNotSolved),!1)}),n.find('input[name="checkSingle"]').click(function(){if(m.forcingQuestionSolve&&(m.quizSummeryHide||!m.reviewQustion))for(var i=0,e=n.find(".wpProQuiz_listItem").length;e>i;i++)if(!p[i])return alert(WpProQuizGlobal.questionsNotSolved),!1;s.methode.showQuizSummary()}),n.find('input[name="tip"]').click(s.methode.showTip),n.find('input[name="skip"]').click(s.methode.skipQuestion),n.find('input[name="wpProQuiz_pageLeft"]').click(function(){s.methode.showSinglePage(f-1)}),n.find('input[name="wpProQuiz_pageRight"]').click(function(){s.methode.showSinglePage(f+1)})}},s.preInit=function(){s.methode.parseBitOptions(),g.init(),n.find('input[name="startQuiz"]').click(function(){return s.methode.startQuiz(),!1}),m.checkBeforeStart&&!m.preview&&s.methode.checkQuizLock(),n.find('input[name="reShowQuestion"]').click(function(){s.methode.showQustionList()}),n.find('input[name="restartQuiz"]').click(function(){s.methode.restartQuiz()}),n.find('input[name="review"]').click(s.methode.reviewQuestion),n.find('input[name="wpProQuiz_toplistAdd"]').click(s.methode.addToplist),n.find('input[name="quizSummary"]').click(s.methode.showQuizSummary),n.find('input[name="endQuizSummary"]').click(function(){if(m.forcingQuestionSolve)for(var i=0,e=n.find(".wpProQuiz_listItem").length;e>i;i++)if(!p[i])return alert(WpProQuizGlobal.questionsNotSolved),!1;(!m.formActivated||r.formPos!=_.END||k.checkForm())&&s.methode.finishQuiz()}),n.find('input[name="endInfopage"]').click(function(){k.checkForm()&&s.methode.finishQuiz()}),n.find('input[name="showToplist"]').click(function(){v.quiz.hide(),v.toplistShowInButton.toggle()}),n.bind("questionSolved",s.methode.questionSolved),m.maxShowQuestion||s.methode.initQuiz(),m.autoStart&&s.methode.startQuiz()},s.preInit()},i.fn.wpProQuizFront=function(e){return this.each(function(){void 0==i(this).data("wpProQuizFront")&&i(this).data("wpProQuizFront",new i.wpProQuizFront(this,e))})}}(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/wpProQuiz_toplist.js CHANGED
@@ -1,68 +1,73 @@
1
- function wpProQuiz_fetchToplist() {
2
- var plugin = this;
3
-
4
- plugin.toplist = {
5
- handleRequest: function(json) {
6
- jQuery('.wpProQuiz_toplist').each(function() {
7
- var $tp = jQuery(this);
8
- var data = json[$tp.data('quiz_id')];
9
- var $trs = $tp.find('tbody tr');
10
- var clone = $trs.eq(2);
11
-
12
- $trs.slice(3).remove();
13
-
14
- if(data == undefined) {
15
- $trs.eq(0).hide().end().eq(1).show();
16
- return true;
17
- }
18
-
19
- for(var i = 0, c = data.length; i < c; i++) {
20
- var td = clone.clone().children();
21
-
22
- td.eq(0).text(i+1);
23
- td.eq(1).text(data[i].name);
24
- td.eq(2).text(data[i].date);
25
- td.eq(3).text(data[i].points);
26
- td.eq(4).text(data[i].result + ' %');
27
-
28
- if(i & 1) {
29
- td.addClass('wpProQuiz_toplistTrOdd');
30
- }
31
-
32
- td.parent().show().appendTo($tp.find('tbody'));
33
- }
34
-
35
- $trs.eq(0).hide();
36
- $trs.eq(1).hide();
37
- });
38
- },
39
-
40
- fetchIds: function() {
41
- var ids = new Array();
42
-
43
- jQuery('.wpProQuiz_toplist').each(function() {
44
- ids.push(jQuery(this).data('quiz_id'));
45
- });
46
-
47
- return ids;
48
- },
49
-
50
- init: function() {
51
- var quizIds = plugin.toplist.fetchIds();
52
-
53
- if(quizIds.length == 0)
54
- return;
55
-
56
- jQuery.post(WpProQuizGlobal.ajaxurl, {
57
- action: 'wp_pro_quiz_show_front_toplist',
58
- quizIds: quizIds
59
- }, function(json) {
60
- plugin.toplist.handleRequest(json);
61
- }, 'json');
62
- }
63
- };
64
-
65
- plugin.toplist.init();
66
- }
67
-
 
 
 
 
 
68
  jQuery(document).ready(wpProQuiz_fetchToplist);
1
+ function wpProQuiz_fetchToplist() {
2
+ var plugin = this;
3
+
4
+ plugin.toplist = {
5
+ handleRequest: function (json) {
6
+ jQuery('.wpProQuiz_toplist').each(function () {
7
+ var $tp = jQuery(this);
8
+ var data = json[$tp.data('quiz_id')];
9
+ var $trs = $tp.find('tbody tr');
10
+ var clone = $trs.eq(2);
11
+
12
+ $trs.slice(3).remove();
13
+
14
+ if (data == undefined) {
15
+ $trs.eq(0).hide().end().eq(1).show();
16
+ return true;
17
+ }
18
+
19
+ for (var i = 0, c = data.length; i < c; i++) {
20
+ var td = clone.clone().children();
21
+
22
+ td.eq(0).text(i + 1);
23
+ td.eq(1).text(data[i].name);
24
+ td.eq(2).text(data[i].date);
25
+ td.eq(3).text(data[i].points);
26
+ td.eq(4).text(data[i].result + ' %');
27
+
28
+ if (i & 1) {
29
+ td.addClass('wpProQuiz_toplistTrOdd');
30
+ }
31
+
32
+ td.parent().show().appendTo($tp.find('tbody'));
33
+ }
34
+
35
+ $trs.eq(0).hide();
36
+ $trs.eq(1).hide();
37
+ });
38
+ },
39
+
40
+ fetchIds: function () {
41
+ var ids = new Array();
42
+
43
+ jQuery('.wpProQuiz_toplist').each(function () {
44
+ ids.push(jQuery(this).data('quiz_id'));
45
+ });
46
+
47
+ return ids;
48
+ },
49
+
50
+ init: function () {
51
+ var quizIds = plugin.toplist.fetchIds();
52
+
53
+ if (quizIds.length == 0)
54
+ return;
55
+
56
+ jQuery.post(WpProQuizGlobal.ajaxurl, {
57
+ //action: 'wp_pro_quiz_show_front_toplist',
58
+ //quizIds: quizIds
59
+ action: 'wp_pro_quiz_admin_ajax',
60
+ func: 'showFrontToplist',
61
+ data: {
62
+ quizIds: quizIds
63
+ }
64
+ }, function (json) {
65
+ plugin.toplist.handleRequest(json);
66
+ }, 'json');
67
+ }
68
+ };
69
+
70
+ plugin.toplist.init();
71
+ }
72
+
73
  jQuery(document).ready(wpProQuiz_fetchToplist);
js/wpProQuiz_toplist.min.js CHANGED
@@ -1,2 +1 @@
1
- function wpProQuiz_fetchToplist(){var d=this;d.toplist={handleRequest:function(a){jQuery(".wpProQuiz_toplist").each(function(){var g=jQuery(this),e=a[g.data("quiz_id")],f=g.find("tbody tr"),d=f.eq(2);f.slice(3).remove();if(void 0==e)return f.eq(0).hide().end().eq(1).show(),!0;for(var b=0,h=e.length;b<h;b++){var c=d.clone().children();c.eq(0).text(b+1);c.eq(1).text(e[b].name);c.eq(2).text(e[b].date);c.eq(3).text(e[b].points);c.eq(4).text(e[b].result+" %");b&1&&c.addClass("wpProQuiz_toplistTrOdd");
2
- c.parent().show().appendTo(g.find("tbody"))}f.eq(0).hide();f.eq(1).hide()})},fetchIds:function(){var a=[];jQuery(".wpProQuiz_toplist").each(function(){a.push(jQuery(this).data("quiz_id"))});return a},init:function(){var a=d.toplist.fetchIds();0!=a.length&&jQuery.post(WpProQuizGlobal.ajaxurl,{action:"wp_pro_quiz_show_front_toplist",quizIds:a},function(a){d.toplist.handleRequest(a)},"json")}};d.toplist.init()}jQuery(document).ready(wpProQuiz_fetchToplist);
1
+ function wpProQuiz_fetchToplist(){var t=this;t.toplist={handleRequest:function(t){jQuery(".wpProQuiz_toplist").each(function(){var e=jQuery(this),i=t[e.data("quiz_id")],o=e.find("tbody tr"),n=o.eq(2);if(o.slice(3).remove(),void 0==i)return o.eq(0).hide().end().eq(1).show(),!0;for(var r=0,u=i.length;u>r;r++){var a=n.clone().children();a.eq(0).text(r+1),a.eq(1).text(i[r].name),a.eq(2).text(i[r].date),a.eq(3).text(i[r].points),a.eq(4).text(i[r].result+" %"),1&r&&a.addClass("wpProQuiz_toplistTrOdd"),a.parent().show().appendTo(e.find("tbody"))}o.eq(0).hide(),o.eq(1).hide()})},fetchIds:function(){var t=new Array;return jQuery(".wpProQuiz_toplist").each(function(){t.push(jQuery(this).data("quiz_id"))}),t},init:function(){var e=t.toplist.fetchIds();0!=e.length&&jQuery.post(WpProQuizGlobal.ajaxurl,{action:"wp_pro_quiz_admin_ajax",func:"showFrontToplist",data:{quizIds:e}},function(e){t.toplist.handleRequest(e)},"json")}},t.toplist.init()}jQuery(document).ready(wpProQuiz_fetchToplist);
 
languages/wp-pro-quiz-ar.mo CHANGED
Binary file
languages/wp-pro-quiz-ar.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:50+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:50+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: abuhassan <sajja2002@hotmail.com>\n"
8
  "Language: ar\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:21+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:21+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: abuhassan <sajja2002@hotmail.com>\n"
8
  "Language: ar\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-cs_CZ.mo CHANGED
Binary file
languages/wp-pro-quiz-cs_CZ.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz Czech\n"
4
- "POT-Creation-Date: 2015-04-24 09:51+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:51+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Petr Štěpán <p.stepan@vlastenci.cz>\n"
8
  "Language: cs_CZ\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz Czech\n"
4
+ "POT-Creation-Date: 2015-08-30 10:23+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:23+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Petr Štěpán <p.stepan@vlastenci.cz>\n"
8
  "Language: cs_CZ\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
languages/wp-pro-quiz-da_DK.mo CHANGED
Binary file
languages/wp-pro-quiz-da_DK.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:51+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:51+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: da_DK\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:22+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:22+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: da_DK\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-de_DE.mo CHANGED
Binary file
languages/wp-pro-quiz-de_DE.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz v0.28\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2015-04-24 09:51+0100\n"
6
- "PO-Revision-Date: 2015-04-24 09:51+0100\n"
7
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
8
  "Language-Team: Julius Fischer\n"
9
  "Language: de_DE\n"
@@ -11,7 +11,7 @@ msgstr ""
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
- "X-Generator: Poedit 1.6.4\n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
  "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz v0.28\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2015-08-30 10:23+0200\n"
6
+ "PO-Revision-Date: 2015-08-30 10:23+0200\n"
7
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
8
  "Language-Team: Julius Fischer\n"
9
  "Language: de_DE\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
+ "X-Generator: Poedit 1.8.4\n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
  "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
languages/wp-pro-quiz-el.mo CHANGED
Binary file
languages/wp-pro-quiz-el.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:51+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:52+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Ζαχαρίας Σδρέγας <azdrax@gmail.com>\n"
8
  "Language: el\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-SourceCharset: UTF-8\n"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:23+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:23+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Ζαχαρίας Σδρέγας <azdrax@gmail.com>\n"
8
  "Language: el\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-SourceCharset: UTF-8\n"
languages/wp-pro-quiz-es_ES.mo CHANGED
Binary file
languages/wp-pro-quiz-es_ES.po CHANGED
@@ -1,17 +1,19 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:52+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:52+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
- "Language-Team: Julius Fischer\n"
8
- "Language: de\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:24+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:24+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
+ "Language-Team: \n"
8
+ "Language: es\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-fa_IR.mo CHANGED
Binary file
languages/wp-pro-quiz-fa_IR.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:52+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:52+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: ityurd <behrooz.nuri@yahoo.com>\n"
8
  "Language: fa_IR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:24+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:24+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: ityurd <behrooz.nuri@yahoo.com>\n"
8
  "Language: fa_IR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-fi.mo CHANGED
Binary file
languages/wp-pro-quiz-fi.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:52+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:52+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: fi\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:25+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:25+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: fi\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-fr_FR.mo CHANGED
Binary file
languages/wp-pro-quiz-fr_FR.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:52+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:52+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: fr_FR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:25+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:25+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: fr_FR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-hu_HU.mo CHANGED
Binary file
languages/wp-pro-quiz-hu_HU.po CHANGED
@@ -1,18 +1,19 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:52+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:52+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: hu\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:25+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:25+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: hu\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-id_ID.mo CHANGED
Binary file
languages/wp-pro-quiz-id_ID.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:52+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:53+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Creative Computer Club <info@triplec.or.id>\n"
8
  "Language: id_ID\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:25+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:25+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Creative Computer Club <info@triplec.or.id>\n"
8
  "Language: id_ID\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-it_IT.mo CHANGED
Binary file
languages/wp-pro-quiz-it_IT.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:53+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:53+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: it_IT\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:26+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:26+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: it_IT\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-ko_KR.mo CHANGED
Binary file
languages/wp-pro-quiz-ko_KR.po CHANGED
@@ -1,18 +1,19 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:53+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:53+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: ko_KR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=1; plural=0;\n"
 
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:26+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:26+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: \n"
8
  "Language: ko_KR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=1; plural=0;\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-nb_NO.mo CHANGED
Binary file
languages/wp-pro-quiz-nb_NO.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:53+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:53+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Stein Ivar Johnsen\n"
8
  "Language: nb_NO\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:26+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:26+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Stein Ivar Johnsen\n"
8
  "Language: nb_NO\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-nl_NL.mo CHANGED
Binary file
languages/wp-pro-quiz-nl_NL.po CHANGED
@@ -1,17 +1,19 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:53+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:53+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
- "Language-Team: Julius Fischer\n"
8
- "Language: de\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:27+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:27+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
+ "Language-Team: \n"
8
+ "Language: nl\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-pl_PL.mo ADDED
Binary file
languages/wp-pro-quiz-pl_PL.po ADDED
@@ -0,0 +1,2977 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:27+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:27+0200\n"
6
+ "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
+ "Language-Team: \n"
8
+ "Language: pl_PL\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: ..\n"
15
+ "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
16
+ "|| n%100>=20) ? 1 : 2);\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
+
20
+ #: lib/controller/WpProQuiz_Controller_Admin.php:109
21
+ msgid "Do you really want to delete the quiz/question?"
22
+ msgstr "Czy na pewno chcesz usunąć test / pytanie?"
23
+
24
+ #: lib/controller/WpProQuiz_Controller_Admin.php:110
25
+ msgid "Title is not filled!"
26
+ msgstr "Tytuł nie jest wypełniony!"
27
+
28
+ #: lib/controller/WpProQuiz_Controller_Admin.php:111
29
+ msgid "No question deposited!"
30
+ msgstr "Brak przechowywanych pytań!"
31
+
32
+ #: lib/controller/WpProQuiz_Controller_Admin.php:112
33
+ msgid "Correct answer was not selected!"
34
+ msgstr "Poprawna odpowiedź nie została wybrana!"
35
+
36
+ #: lib/controller/WpProQuiz_Controller_Admin.php:113
37
+ msgid "No answer deposited!"
38
+ msgstr "Brak przechowywanych odpowiedzi!"
39
+
40
+ #: lib/controller/WpProQuiz_Controller_Admin.php:114
41
+ msgid "No quiz description filled!"
42
+ msgstr "Opis quizu niewypełniony!"
43
+
44
+ #: lib/controller/WpProQuiz_Controller_Admin.php:115
45
+ msgid "The percent values in result text are incorrect."
46
+ msgstr "Procentowe wartości w informacji o wynikach są nieprawidłowe."
47
+
48
+ #: lib/controller/WpProQuiz_Controller_Admin.php:116
49
+ msgid "No number in the field \"Points\" or less than 1"
50
+ msgstr "Brak liczby w rubryce \"Punkty\" lub liczba ta jest mniejsza niż 1"
51
+
52
+ #: lib/controller/WpProQuiz_Controller_Admin.php:117
53
+ msgid "No number in the field \"Points\" or less than 0"
54
+ msgstr "Brak liczby w rubryce \"Punkty\" lub liczba ta jest mniejsza niż 0"
55
+
56
+ #: lib/controller/WpProQuiz_Controller_Admin.php:118
57
+ msgid "No quiz selected"
58
+ msgstr "Nie wybrano quizu"
59
+
60
+ #: lib/controller/WpProQuiz_Controller_Admin.php:119
61
+ msgid "Do you really want to reset the statistic?"
62
+ msgstr "Czy chcesz zresetować statystyki?"
63
+
64
+ #: lib/controller/WpProQuiz_Controller_Admin.php:120
65
+ #: lib/view/WpProQuiz_View_FrontToplist.php:26
66
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:40
67
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:41
68
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:41
69
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:615
70
+ msgid "No data available"
71
+ msgstr "Brak dostępnych danych"
72
+
73
+ #: lib/controller/WpProQuiz_Controller_Admin.php:121
74
+ msgid "No sort element in the criterion"
75
+ msgstr "Brak danych odpowiadającym tym kryteriom"
76
+
77
+ #: lib/controller/WpProQuiz_Controller_Admin.php:122
78
+ msgid ""
79
+ "\"Different points for every answer\" is not possible at \"Free\" choice"
80
+ msgstr ""
81
+ "\"Różna ilość punktów za każdą odpowiedź\" nie jest możliwa w \"Free\" choice"
82
+
83
+ #: lib/controller/WpProQuiz_Controller_Admin.php:123
84
+ msgid "You must specify a name."
85
+ msgstr "Musisz wybrać nazwę"
86
+
87
+ #: lib/controller/WpProQuiz_Controller_Admin.php:124
88
+ msgid "This entry should really be deleted?"
89
+ msgstr "Czy na pewno chcesz usunąć?"
90
+
91
+ #: lib/controller/WpProQuiz_Controller_Admin.php:125
92
+ msgid "Not all fields completed."
93
+ msgstr "Nie wypełniono wszystkich pól."
94
+
95
+ #: lib/controller/WpProQuiz_Controller_Admin.php:126
96
+ msgid "You must specify a template name."
97
+ msgstr "Musisz wybrać nazwę szablonu."
98
+
99
+ #: lib/controller/WpProQuiz_Controller_Admin.php:129
100
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:181
101
+ msgid "Close"
102
+ msgstr "Zamknij"
103
+
104
+ #: lib/controller/WpProQuiz_Controller_Admin.php:130
105
+ msgid "Today"
106
+ msgstr "Dzisiaj"
107
+
108
+ #: lib/controller/WpProQuiz_Controller_Admin.php:175
109
+ #: lib/controller/WpProQuiz_Controller_Admin.php:176
110
+ #: lib/view/WpProQuiz_View_GobalSettings.php:7
111
+ #: lib/view/WpProQuiz_View_GobalSettings.php:12
112
+ #: lib/view/WpProQuiz_View_GobalSettings.php:42
113
+ msgid "Global settings"
114
+ msgstr "Główne ustawienia"
115
+
116
+ #: lib/controller/WpProQuiz_Controller_Admin.php:183
117
+ #: lib/controller/WpProQuiz_Controller_Admin.php:184
118
+ msgid "Support & More"
119
+ msgstr "Pomoc i inne"
120
+
121
+ #: lib/controller/WpProQuiz_Controller_Front.php:47
122
+ #: lib/controller/WpProQuiz_Controller_Front.php:66
123
+ #: lib/controller/WpProQuiz_Controller_Preview.php:15
124
+ #: lib/view/WpProQuiz_View_AdminToplist.php:47
125
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:249
126
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:354
127
+ #: lib/view/WpProQuiz_View_Statistics.php:46
128
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:73
129
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:149
130
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:187
131
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:233
132
+ msgid "Loading"
133
+ msgstr "Ładowanie"
134
+
135
+ #: lib/controller/WpProQuiz_Controller_Front.php:48
136
+ #: lib/controller/WpProQuiz_Controller_Front.php:67
137
+ #: lib/controller/WpProQuiz_Controller_Preview.php:16
138
+ msgid "You must answer this question."
139
+ msgstr "Musisz odpowiedzieć na te pytanie."
140
+
141
+ #: lib/controller/WpProQuiz_Controller_Front.php:49
142
+ #: lib/controller/WpProQuiz_Controller_Front.php:68
143
+ #: lib/controller/WpProQuiz_Controller_Preview.php:17
144
+ msgid "You must answer all questions before you can completed the quiz."
145
+ msgstr "Musisz odpowiedzieć na wszystkie pytania zanim zakończysz quiz."
146
+
147
+ #: lib/controller/WpProQuiz_Controller_Front.php:50
148
+ #: lib/controller/WpProQuiz_Controller_Front.php:69
149
+ #: lib/controller/WpProQuiz_Controller_Preview.php:18
150
+ msgid "All fields have to be filled."
151
+ msgstr "Wszystkie pola muszą być wypełnione."
152
+
153
+ #: lib/controller/WpProQuiz_Controller_GlobalSettings.php:11
154
+ #: lib/controller/WpProQuiz_Controller_ImportExport.php:23
155
+ #: lib/controller/WpProQuiz_Controller_ImportExport.php:47
156
+ #: lib/controller/WpProQuiz_Controller_Question.php:98
157
+ #: lib/controller/WpProQuiz_Controller_Question.php:102
158
+ #: lib/controller/WpProQuiz_Controller_Question.php:223
159
+ #: lib/controller/WpProQuiz_Controller_Question.php:300
160
+ #: lib/controller/WpProQuiz_Controller_Question.php:311
161
+ #: lib/controller/WpProQuiz_Controller_Question.php:331
162
+ #: lib/controller/WpProQuiz_Controller_Question.php:408
163
+ #: lib/controller/WpProQuiz_Controller_Question.php:596
164
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:71
165
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:75
166
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:332
167
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:369
168
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:453
169
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:662
170
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:676
171
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:40
172
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:88
173
+ msgid "You do not have sufficient permissions to access this page."
174
+ msgstr "Nie masz odpowiednich uprawnień, aby przeglądać tę stronę."
175
+
176
+ #: lib/controller/WpProQuiz_Controller_GlobalSettings.php:22
177
+ msgid "Settings saved"
178
+ msgstr "Ustawienia zapisane"
179
+
180
+ #: lib/controller/WpProQuiz_Controller_GlobalSettings.php:46
181
+ msgid "Database repaired"
182
+ msgstr "Baza danych naprawiona"
183
+
184
+ #: lib/controller/WpProQuiz_Controller_ImportExport.php:91
185
+ #: lib/helper/WpProQuiz_Helper_Import.php:57
186
+ #: lib/helper/WpProQuiz_Helper_Import.php:66
187
+ #: lib/helper/WpProQuiz_Helper_Import.php:73
188
+ msgid "File cannot be processed"
189
+ msgstr "Plik nie może być wgrany"
190
+
191
+ #: lib/controller/WpProQuiz_Controller_Question.php:9
192
+ #: lib/controller/WpProQuiz_Controller_Question.php:19
193
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:91
194
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:386
195
+ msgid "Quiz not found"
196
+ msgstr "Nie znaleziono quizu"
197
+
198
+ #: lib/controller/WpProQuiz_Controller_Question.php:88
199
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:509
200
+ #: lib/view/WpProQuiz_View_Import.php:44
201
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:63
202
+ msgid "Questions"
203
+ msgstr "Pytania"
204
+
205
+ #: lib/controller/WpProQuiz_Controller_Question.php:112
206
+ msgid "Question not found"
207
+ msgstr "Nie znaleziono pytania"
208
+
209
+ #: lib/controller/WpProQuiz_Controller_Question.php:134
210
+ #: lib/controller/WpProQuiz_Controller_Question.php:398
211
+ msgid "Question edited"
212
+ msgstr "Pytanie zedytowane"
213
+
214
+ #: lib/controller/WpProQuiz_Controller_Question.php:136
215
+ msgid "Question added"
216
+ msgstr "Pytanie dodane"
217
+
218
+ #: lib/controller/WpProQuiz_Controller_Question.php:154
219
+ #: lib/controller/WpProQuiz_Controller_Question.php:352
220
+ msgid "Edit question"
221
+ msgstr "Edytuj pytanie"
222
+
223
+ #: lib/controller/WpProQuiz_Controller_Question.php:154
224
+ #: lib/controller/WpProQuiz_Controller_Question.php:466
225
+ msgid "New question"
226
+ msgstr "Nowe pytanie"
227
+
228
+ #: lib/controller/WpProQuiz_Controller_Question.php:200
229
+ #: lib/controller/WpProQuiz_Controller_Question.php:380
230
+ #, php-format
231
+ msgid "Question: %d"
232
+ msgstr "Pytanie: %d"
233
+
234
+ #: lib/controller/WpProQuiz_Controller_Question.php:237
235
+ msgid "questions copied"
236
+ msgstr "pytanie skopiowane"
237
+
238
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:61
239
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:27
240
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:28
241
+ #: lib/view/WpProQuiz_View_QuizEdit.php:355
242
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:28
243
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:29
244
+ msgid "Quiz"
245
+ msgstr "Quiz"
246
+
247
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:130
248
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:401
249
+ msgid "Quiz edited"
250
+ msgstr "Quiz zedytowany"
251
+
252
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:132
253
+ msgid "quiz created"
254
+ msgstr "utworzono quiz"
255
+
256
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:154
257
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:422
258
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:494
259
+ msgid "Quiz title or quiz description are not filled"
260
+ msgstr "Tytuł, lub opis quizu nie został uzupełniony"
261
+
262
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:172
263
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:379
264
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:306
265
+ msgid "Edit quiz"
266
+ msgstr "Edytuj quiz"
267
+
268
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:172
269
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:457
270
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:475
271
+ msgid "Create quiz"
272
+ msgstr "Stwórz quiz"
273
+
274
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:577
275
+ msgid "Template stored"
276
+ msgstr "Szablon zapisany"
277
+
278
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:669
279
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:687
280
+ msgid "Quiz deleted"
281
+ msgstr "Quiz usunięty"
282
+
283
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:951
284
+ #: lib/controller/WpProQuiz_Controller_QuizCompleted.php:190
285
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:667
286
+ msgid "Not categorized"
287
+ msgstr "Nieskategoryzowany"
288
+
289
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:957
290
+ #: lib/controller/WpProQuiz_Controller_QuizCompleted.php:196
291
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:662
292
+ msgid "Categories"
293
+ msgstr "Kategorie"
294
+
295
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:56
296
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:694
297
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:91
298
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:394
299
+ #: lib/view/WpProQuiz_View_QuizEdit.php:54
300
+ #: lib/view/WpProQuiz_View_QuizOverall.php:421
301
+ msgid "No category"
302
+ msgstr "Brak kategorii"
303
+
304
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:572
305
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:622
306
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:720
307
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:624
308
+ msgid "Anonymous"
309
+ msgstr "Anonim"
310
+
311
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:624
312
+ #: lib/controller/WpProQuiz_Controller_Statistics.php:728
313
+ msgid "Deleted user"
314
+ msgstr "Usunięty użytkownik"
315
+
316
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:80
317
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:211
318
+ msgid "No name or e-mail entered."
319
+ msgstr "Brak nazwy lub e-maila"
320
+
321
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:148
322
+ msgid "You signed up successfully."
323
+ msgstr "Zarejestrowano poprawnie"
324
+
325
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:156
326
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:160
327
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:177
328
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:181
329
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:187
330
+ msgid "An error has occurred."
331
+ msgstr "Nastąpił błąd"
332
+
333
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:198
334
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:207
335
+ msgid "You can not enter again."
336
+ msgstr "Nie można wykonać ponownie"
337
+
338
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:215
339
+ msgid "Your name can not exceed 15 characters."
340
+ msgstr "Nazwa nie może przekraczać 15 znaków"
341
+
342
+ #: lib/controller/WpProQuiz_Controller_Toplist.php:223
343
+ msgid "You entered wrong captcha code."
344
+ msgstr "Wpisałeś zły kod"
345
+
346
+ #: lib/helper/WpProQuiz_Helper_Form.php:91
347
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:564
348
+ msgid "ticked"
349
+ msgstr ""
350
+
351
+ #: lib/helper/WpProQuiz_Helper_Form.php:91
352
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:564
353
+ msgid "not ticked"
354
+ msgstr ""
355
+
356
+ #: lib/helper/WpProQuiz_Helper_Form.php:94
357
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:444
358
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:567
359
+ msgid "Yes"
360
+ msgstr "Tak"
361
+
362
+ #: lib/helper/WpProQuiz_Helper_Form.php:94
363
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:449
364
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:567
365
+ msgid "No"
366
+ msgstr "Nie"
367
+
368
+ #: lib/helper/WpProQuiz_Helper_Import.php:9
369
+ #: lib/helper/WpProQuiz_Helper_ImportXml.php:8
370
+ msgid "File was not uploaded"
371
+ msgstr "Plik nie został dodany"
372
+
373
+ #: lib/helper/WpProQuiz_Helper_Import.php:38
374
+ msgid "File have wrong format"
375
+ msgstr "Plik ma zły format"
376
+
377
+ #: lib/helper/WpProQuiz_Helper_Import.php:43
378
+ msgid "File is not compatible with the current version"
379
+ msgstr "Plik nie jest kompatybilny z aktualną wersją"
380
+
381
+ #: lib/helper/WpProQuiz_Helper_ImportXml.php:27
382
+ #: lib/helper/WpProQuiz_Helper_ImportXml.php:40
383
+ msgid "XML could not be loaded."
384
+ msgstr "XML nie może być załadowany"
385
+
386
+ #: lib/model/WpProQuiz_Model_Email.php:78
387
+ #: lib/model/WpProQuiz_Model_Email.php:88
388
+ #: lib/model/WpProQuiz_Model_GlobalSettingsMapper.php:47
389
+ #: lib/model/WpProQuiz_Model_GlobalSettingsMapper.php:79
390
+ msgid "Wp-Pro-Quiz: One user completed a quiz"
391
+ msgstr "Wp-Pro-Quiz: Jeden użytkownik ukończył quiz"
392
+
393
+ #: lib/model/WpProQuiz_Model_Email.php:79
394
+ #: lib/model/WpProQuiz_Model_GlobalSettingsMapper.php:49
395
+ msgid ""
396
+ "Wp-Pro-Quiz\n"
397
+ "\n"
398
+ "The user \"$username\" has completed \"$quizname\" the quiz.\n"
399
+ "\n"
400
+ "Points: $points\n"
401
+ "Result: $result\n"
402
+ "\n"
403
+ msgstr ""
404
+ "Wp-Pro-Quiz\n"
405
+ "\n"
406
+ "Użytkownik \"$username\" ukończył quiz \"$quizname\".\n"
407
+ "\n"
408
+ "Punktów: $points\n"
409
+ "Wynik: $result\n"
410
+ "\n"
411
+
412
+ #: lib/model/WpProQuiz_Model_Email.php:89
413
+ #: lib/model/WpProQuiz_Model_GlobalSettingsMapper.php:81
414
+ msgid ""
415
+ "Wp-Pro-Quiz\n"
416
+ "\n"
417
+ "You have completed the quiz \"$quizname\".\n"
418
+ "\n"
419
+ "Points: $points\n"
420
+ "Result: $result\n"
421
+ "\n"
422
+ msgstr ""
423
+ "Wp-Pro-Quiz\n"
424
+ "\n"
425
+ "Ukończyłeś quiz \"$quizname\".\n"
426
+ "\n"
427
+ "Punktów: $points\n"
428
+ "Wynik: $result\n"
429
+ "\n"
430
+
431
+ #: lib/plugin/WpProQuiz_Plugin_BpAchievementsV2.php:33
432
+ #: lib/plugin/WpProQuiz_Plugin_BpAchievementsV3.php:6
433
+ msgid "The user completed a quiz."
434
+ msgstr "Użytkownik ukończył quiz"
435
+
436
+ #: lib/plugin/WpProQuiz_Plugin_BpAchievementsV3.php:7
437
+ msgid "The user completed a quiz with 100 percent."
438
+ msgstr "Użytkownik ukończył quiz z wynikiem 100 procent"
439
+
440
+ #: lib/plugin/WpProQuiz_Plugin_BpAchievementsV3.php:18
441
+ msgid "A powerful and beautiful quiz plugin for WordPress."
442
+ msgstr "Znakomity i potężny plugin quizu dla wordpressa"
443
+
444
+ #: lib/plugin/WpProQuiz_Plugin_BpAchievementsV3.php:21
445
+ #: lib/view/WpProQuiz_View_QuizOverall.php:290
446
+ msgid "WP-Pro-Quiz"
447
+ msgstr "WP-Pro-Quiz"
448
+
449
+ #: lib/view/WpProQuiz_View_AdminToplist.php:7
450
+ #: lib/view/WpProQuiz_View_FrontToplist.php:8
451
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1029
452
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1041
453
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:78
454
+ msgid "Leaderboard"
455
+ msgstr "Tablica wyników"
456
+
457
+ #: lib/view/WpProQuiz_View_AdminToplist.php:8
458
+ #: lib/view/WpProQuiz_View_GobalSettings.php:9
459
+ #: lib/view/WpProQuiz_View_Import.php:22
460
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:24
461
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:301
462
+ #: lib/view/WpProQuiz_View_QuizEdit.php:23
463
+ #: lib/view/WpProQuiz_View_Statistics.php:29
464
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:57
465
+ #: lib/view/WpProQuiz_View_StyleManager.php:11
466
+ msgid "back to overview"
467
+ msgstr "wróć do przeglądu quizów"
468
+
469
+ #: lib/view/WpProQuiz_View_AdminToplist.php:11
470
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:106
471
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:115
472
+ #: lib/view/WpProQuiz_View_Statistics.php:209
473
+ #: lib/view/WpProQuiz_View_Statistics.php:288
474
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:94
475
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:140
476
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:201
477
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:224
478
+ msgid "Filter"
479
+ msgstr "Filtr"
480
+
481
+ #: lib/view/WpProQuiz_View_AdminToplist.php:16
482
+ msgid "Sort by:"
483
+ msgstr "Sortuj po:"
484
+
485
+ #: lib/view/WpProQuiz_View_AdminToplist.php:18
486
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1121
487
+ msgid "best user"
488
+ msgstr "najlepszy użytkownik"
489
+
490
+ #: lib/view/WpProQuiz_View_AdminToplist.php:19
491
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1125
492
+ msgid "newest entry"
493
+ msgstr "najnowsze wyniki"
494
+
495
+ #: lib/view/WpProQuiz_View_AdminToplist.php:20
496
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1129
497
+ msgid "oldest entry"
498
+ msgstr "najstarsze wyniki"
499
+
500
+ #: lib/view/WpProQuiz_View_AdminToplist.php:26
501
+ #: lib/view/WpProQuiz_View_Statistics.php:220
502
+ #: lib/view/WpProQuiz_View_Statistics.php:303
503
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:120
504
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:212
505
+ msgid "How many entries should be shown on one page:"
506
+ msgstr "Jak dużo wyników powinno być widoczne na jednej stronie:"
507
+
508
+ #: lib/view/WpProQuiz_View_AdminToplist.php:38
509
+ #: lib/view/WpProQuiz_View_AdminToplist.php:57
510
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1390
511
+ msgid "Type"
512
+ msgstr "Typ"
513
+
514
+ #: lib/view/WpProQuiz_View_AdminToplist.php:38
515
+ msgid "UR = unregistered user, R = registered user"
516
+ msgstr "UR = niezarejestrowani użytkownicy, R = zarejestrowani użytkownicy"
517
+
518
+ #: lib/view/WpProQuiz_View_AdminToplist.php:55
519
+ #: lib/view/WpProQuiz_View_Statistics.php:239
520
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:603
521
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:107
522
+ msgid "User"
523
+ msgstr "Użytkownik"
524
+
525
+ #: lib/view/WpProQuiz_View_AdminToplist.php:56
526
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:257
527
+ msgid "E-Mail"
528
+ msgstr "E-mail"
529
+
530
+ #: lib/view/WpProQuiz_View_AdminToplist.php:58
531
+ #: lib/view/WpProQuiz_View_FrontToplist.php:16
532
+ msgid "Entered on"
533
+ msgstr "Dodany"
534
+
535
+ #: lib/view/WpProQuiz_View_AdminToplist.php:59
536
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:909
537
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:931
538
+ #: lib/view/WpProQuiz_View_FrontToplist.php:17
539
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:49
540
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:56
541
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:317
542
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:355
543
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:414
544
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:19
545
+ #: lib/view/WpProQuiz_View_Statistics.php:105
546
+ #: lib/view/WpProQuiz_View_Statistics.php:240
547
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:34
548
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:168
549
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:604
550
+ msgid "Points"
551
+ msgstr "Punkty"
552
+
553
+ #: lib/view/WpProQuiz_View_AdminToplist.php:60
554
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:621
555
+ #: lib/view/WpProQuiz_View_Statistics.php:111
556
+ #: lib/view/WpProQuiz_View_Statistics.php:245
557
+ #: lib/view/WpProQuiz_View_Statistics.php:324
558
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:35
559
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:175
560
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:609
561
+ msgid "Results"
562
+ msgstr "Wyniki"
563
+
564
+ #: lib/view/WpProQuiz_View_AdminToplist.php:72
565
+ #: lib/view/WpProQuiz_View_GobalSettings.php:140
566
+ #: lib/view/WpProQuiz_View_GobalSettings.php:166
567
+ #: lib/view/WpProQuiz_View_GobalSettings.php:192
568
+ #: lib/view/WpProQuiz_View_GobalSettings.php:217
569
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:64
570
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:67
571
+ msgid "Edit"
572
+ msgstr "Edytuj"
573
+
574
+ #: lib/view/WpProQuiz_View_AdminToplist.php:75
575
+ #: lib/view/WpProQuiz_View_AdminToplist.php:100
576
+ #: lib/view/WpProQuiz_View_GobalSettings.php:139
577
+ #: lib/view/WpProQuiz_View_GobalSettings.php:165
578
+ #: lib/view/WpProQuiz_View_GobalSettings.php:191
579
+ #: lib/view/WpProQuiz_View_GobalSettings.php:216
580
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:68
581
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:81
582
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1452
583
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:70
584
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:87
585
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:51
586
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:649
587
+ msgid "Delete"
588
+ msgstr "Usuń"
589
+
590
+ #: lib/view/WpProQuiz_View_AdminToplist.php:80
591
+ msgid "save"
592
+ msgstr "zapisz"
593
+
594
+ #: lib/view/WpProQuiz_View_AdminToplist.php:81
595
+ msgid "cancel"
596
+ msgstr "anuluj"
597
+
598
+ #: lib/view/WpProQuiz_View_AdminToplist.php:99
599
+ msgid "Action"
600
+ msgstr "Akcja"
601
+
602
+ #: lib/view/WpProQuiz_View_AdminToplist.php:102
603
+ msgid "Apply"
604
+ msgstr "Zastosuj"
605
+
606
+ #: lib/view/WpProQuiz_View_AdminToplist.php:103
607
+ msgid "Delete all entries"
608
+ msgstr "Usuń wszystkie wyniki"
609
+
610
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:29
611
+ msgid "Start quiz"
612
+ msgstr "Rozpocznij quiz"
613
+
614
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:30
615
+ msgid "Restart quiz"
616
+ msgstr "Restartuj quiz"
617
+
618
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:31
619
+ #: lib/view/WpProQuiz_View_QuizEdit.php:420
620
+ #: lib/view/WpProQuiz_View_QuizEdit.php:430
621
+ #: lib/view/WpProQuiz_View_QuizEdit.php:435
622
+ msgid "Quiz-summary"
623
+ msgstr "Podsumowanie quizu"
624
+
625
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:32
626
+ msgid "Finish quiz"
627
+ msgstr "Ukończ quiz"
628
+
629
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:33
630
+ msgid "Quiz is loading..."
631
+ msgstr "Ładowanie quizu…"
632
+
633
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:34
634
+ msgid ""
635
+ "You have already completed the quiz before. Hence you can not start it again."
636
+ msgstr "Już ukończyłeś quiz. Nie możesz rozpocząć jeszcze raz."
637
+
638
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:35
639
+ msgid "You must sign in or sign up to start the quiz."
640
+ msgstr "Musisz się zalogować, aby rozpocząć quiz."
641
+
642
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:36
643
+ msgid "You have to finish following quiz, to start this quiz:"
644
+ msgstr "Musisz ukończyć następujący quiz, aby rozpocząć ten:"
645
+
646
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:247
647
+ msgid "Your result has been entered into leaderboard"
648
+ msgstr "Twoje wyniki zostały dodane do podsumowania"
649
+
650
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:254
651
+ #: lib/view/WpProQuiz_View_FrontToplist.php:15
652
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:17
653
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:17
654
+ msgid "Name"
655
+ msgstr "Nazwa"
656
+
657
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:262
658
+ msgid "Captcha"
659
+ msgstr "Captcha"
660
+
661
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:268
662
+ msgid "Send"
663
+ msgstr "Wyślij"
664
+
665
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:359
666
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:458
667
+ msgid "You must fill out this field."
668
+ msgstr "Musisz wypełnić te pole"
669
+
670
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:362
671
+ msgid "You must specify a number."
672
+ msgstr "Musisz wybrać numer"
673
+
674
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:363
675
+ msgid "You must specify a text."
676
+ msgstr "Musisz wpisać tekst"
677
+
678
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:364
679
+ msgid "You must specify an email address."
680
+ msgstr "Musisz wpisać email"
681
+
682
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:365
683
+ msgid "You must specify a date."
684
+ msgstr "Musisz wpisać datę"
685
+
686
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:507
687
+ #, php-format
688
+ msgid "%s of %s questions completed"
689
+ msgstr "%s z %s pytań ukończone"
690
+
691
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:524
692
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:539
693
+ msgid "Information"
694
+ msgstr "Informacja"
695
+
696
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:575
697
+ #: lib/view/WpProQuiz_View_QuizEdit.php:190
698
+ #: lib/view/WpProQuiz_View_QuizEdit.php:195
699
+ msgid "Time limit"
700
+ msgstr "Limit czasu"
701
+
702
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:596
703
+ msgid "Answered"
704
+ msgstr "Udzielono odpowiedzi"
705
+
706
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:600
707
+ msgid "Review"
708
+ msgstr "Do sprawdzenia"
709
+
710
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:607
711
+ msgid "Review question"
712
+ msgstr "Do sprawdzenia"
713
+
714
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:624
715
+ #, php-format
716
+ msgid "%s of %s questions answered correctly"
717
+ msgstr "udzielono odpowiedzi dobrze na %s z %s"
718
+
719
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:628
720
+ msgid "Your time: <span></span>"
721
+ msgstr "Twój czas: <span></span>"
722
+
723
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:632
724
+ msgid "Time has elapsed"
725
+ msgstr "Czas się skończył"
726
+
727
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:636
728
+ #, php-format
729
+ msgid "You have reached %s of %s points, (%s)"
730
+ msgstr "Zdobyłeś %s z %s punktów, (%s)"
731
+
732
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:644
733
+ msgid "Average score"
734
+ msgstr "Średni wynik"
735
+
736
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:651
737
+ msgid "Your score"
738
+ msgstr "Twój wynik"
739
+
740
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:702
741
+ msgid "View questions"
742
+ msgstr "Widok pytań"
743
+
744
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:705
745
+ msgid "Show leaderboard"
746
+ msgstr "Pokaż tablicę wyników"
747
+
748
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:764
749
+ #, php-format
750
+ msgid "Question %s of %s"
751
+ msgstr "Pytań %s z %s"
752
+
753
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:767
754
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:110
755
+ #: lib/view/WpProQuiz_View_Statistics.php:104
756
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:167
757
+ msgid "Question"
758
+ msgstr "Pytanie"
759
+
760
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:771
761
+ #, php-format
762
+ msgid "%d points"
763
+ msgstr "%d punktów"
764
+
765
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:777
766
+ #, php-format
767
+ msgid "Category: %s"
768
+ msgstr "Kategoria: %s"
769
+
770
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:786
771
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:347
772
+ msgid "Sort elements"
773
+ msgstr "Sortuj elementy"
774
+
775
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:907
776
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:914
777
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:305
778
+ #: lib/view/WpProQuiz_View_Statistics.php:106
779
+ #: lib/view/WpProQuiz_View_Statistics.php:241
780
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:31
781
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:169
782
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:354
783
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:605
784
+ msgid "Correct"
785
+ msgstr "Poprawnie"
786
+
787
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:929
788
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:936
789
+ #: lib/view/WpProQuiz_View_Statistics.php:107
790
+ #: lib/view/WpProQuiz_View_Statistics.php:242
791
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:32
792
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:170
793
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:606
794
+ msgid "Incorrect"
795
+ msgstr "Niepoprawnie"
796
+
797
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:959
798
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:970
799
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:154
800
+ msgid "Hint"
801
+ msgstr "Podpowiedź"
802
+
803
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:966
804
+ #: lib/view/WpProQuiz_View_QuizEdit.php:449
805
+ #: lib/view/WpProQuiz_View_QuizEdit.php:454
806
+ msgid "Skip question"
807
+ msgstr "Pomiń pytanie"
808
+
809
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:968
810
+ msgid "Back"
811
+ msgstr "Powrót"
812
+
813
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:972
814
+ msgid "Check"
815
+ msgstr "Sprawdź"
816
+
817
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:973
818
+ msgid "Next"
819
+ msgstr "Dalej"
820
+
821
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:986
822
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:987
823
+ #, php-format
824
+ msgid "Page %d"
825
+ msgstr "Strona %d"
826
+
827
+ #: lib/view/WpProQuiz_View_FrontToplist.php:11
828
+ #, php-format
829
+ msgid "maximum of %s points"
830
+ msgstr "max z %s punktów"
831
+
832
+ #: lib/view/WpProQuiz_View_FrontToplist.php:14
833
+ msgid "Pos."
834
+ msgstr "#"
835
+
836
+ #: lib/view/WpProQuiz_View_FrontToplist.php:18
837
+ msgid "Result"
838
+ msgstr "Wynik"
839
+
840
+ #: lib/view/WpProQuiz_View_FrontToplist.php:23
841
+ msgid "Table is loading"
842
+ msgstr "Tabela ładuje się"
843
+
844
+ #: lib/view/WpProQuiz_View_GlobalHelperTabs.php:29
845
+ msgid "Wp-Pro-Quiz"
846
+ msgstr "Wp-Pro-Quiz"
847
+
848
+ #: lib/view/WpProQuiz_View_GlobalHelperTabs.php:45
849
+ #: lib/view/WpProQuiz_View_GlobalHelperTabs.php:73
850
+ #: lib/view/WpProQuiz_View_WpqSupport.php:10
851
+ msgid "Donate"
852
+ msgstr "Wspomóż"
853
+
854
+ #: lib/view/WpProQuiz_View_GlobalHelperTabs.php:61
855
+ msgid "For more information:"
856
+ msgstr "Więcej informacji:"
857
+
858
+ #: lib/view/WpProQuiz_View_GlobalHelperTabs.php:64
859
+ msgid "Support"
860
+ msgstr "Pomoc"
861
+
862
+ #: lib/view/WpProQuiz_View_GlobalHelperTabs.php:70
863
+ msgid "Wiki"
864
+ msgstr ""
865
+
866
+ #: lib/view/WpProQuiz_View_GobalSettings.php:14
867
+ #: lib/view/WpProQuiz_View_GobalSettings.php:398
868
+ msgid "Settings in case of problems"
869
+ msgstr "Ustawienia w przypadku problemów"
870
+
871
+ #: lib/view/WpProQuiz_View_GobalSettings.php:30
872
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:263
873
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:412
874
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:428
875
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:435
876
+ #: lib/view/WpProQuiz_View_QuizEdit.php:655
877
+ #: lib/view/WpProQuiz_View_QuizOverall.php:439
878
+ #: lib/view/WpProQuiz_View_WpqSupport.php:59
879
+ msgid "Save"
880
+ msgstr "Zapisz"
881
+
882
+ #: lib/view/WpProQuiz_View_GobalSettings.php:48
883
+ #: lib/view/WpProQuiz_View_GobalSettings.php:53
884
+ msgid "Leaderboard time format"
885
+ msgstr "Format czasu w tablicy wyników"
886
+
887
+ #: lib/view/WpProQuiz_View_GobalSettings.php:75
888
+ msgid "Custom"
889
+ msgstr "Niestandardowe"
890
+
891
+ #: lib/view/WpProQuiz_View_GobalSettings.php:79
892
+ #: lib/view/WpProQuiz_View_GobalSettings.php:113
893
+ msgid "Documentation on date and time formatting"
894
+ msgstr "Dokumentacja na temat czasu i daty"
895
+
896
+ #: lib/view/WpProQuiz_View_GobalSettings.php:87
897
+ #: lib/view/WpProQuiz_View_GobalSettings.php:92
898
+ msgid "Statistic time format"
899
+ msgstr "Format czasu w statystykach"
900
+
901
+ #: lib/view/WpProQuiz_View_GobalSettings.php:96
902
+ msgid "Select example:"
903
+ msgstr "Zaznacz przykład:"
904
+
905
+ #: lib/view/WpProQuiz_View_GobalSettings.php:109
906
+ msgid "Time format:"
907
+ msgstr "Format czasu:"
908
+
909
+ #: lib/view/WpProQuiz_View_GobalSettings.php:122
910
+ #: lib/view/WpProQuiz_View_GobalSettings.php:127
911
+ msgid "Category management"
912
+ msgstr "Zarządzanie kategoriami"
913
+
914
+ #: lib/view/WpProQuiz_View_GobalSettings.php:148
915
+ #: lib/view/WpProQuiz_View_GobalSettings.php:153
916
+ msgid "Quiz Category management"
917
+ msgstr "Zarządzanie kategoriami quizu"
918
+
919
+ #: lib/view/WpProQuiz_View_GobalSettings.php:174
920
+ #: lib/view/WpProQuiz_View_GobalSettings.php:179
921
+ msgid "Quiz template management"
922
+ msgstr "Zarządzanie szablonami quizu"
923
+
924
+ #: lib/view/WpProQuiz_View_GobalSettings.php:199
925
+ #: lib/view/WpProQuiz_View_GobalSettings.php:204
926
+ msgid "Question template management"
927
+ msgstr "Zarządzanie szablonami pytań"
928
+
929
+ #: lib/view/WpProQuiz_View_GobalSettings.php:232
930
+ #: lib/view/WpProQuiz_View_GobalSettings.php:528
931
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1478
932
+ msgid "Admin e-mail settings"
933
+ msgstr "Ustawienia adresu e-mail administratora"
934
+
935
+ #: lib/view/WpProQuiz_View_GobalSettings.php:238
936
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1511
937
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1641
938
+ msgid "To:"
939
+ msgstr "Do:"
940
+
941
+ #: lib/view/WpProQuiz_View_GobalSettings.php:245
942
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1518
943
+ msgid ""
944
+ "Separate multiple email addresses with a comma, e.g. wp@test.com, test@test."
945
+ "com"
946
+ msgstr ""
947
+ "Oddziela kilka adresów email przecinkiem np. wp@test.com, test@test.com"
948
+
949
+ #: lib/view/WpProQuiz_View_GobalSettings.php:251
950
+ #: lib/view/WpProQuiz_View_GobalSettings.php:323
951
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1524
952
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1659
953
+ msgid "From:"
954
+ msgstr "Od:"
955
+
956
+ #: lib/view/WpProQuiz_View_GobalSettings.php:264
957
+ #: lib/view/WpProQuiz_View_GobalSettings.php:333
958
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1537
959
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1669
960
+ msgid "Subject:"
961
+ msgstr "Temat:"
962
+
963
+ #: lib/view/WpProQuiz_View_GobalSettings.php:274
964
+ #: lib/view/WpProQuiz_View_GobalSettings.php:343
965
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1547
966
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1679
967
+ msgid "HTML"
968
+ msgstr "HTML"
969
+
970
+ #: lib/view/WpProQuiz_View_GobalSettings.php:278
971
+ #: lib/view/WpProQuiz_View_GobalSettings.php:347
972
+ #: lib/view/WpProQuiz_View_GobalSettings.php:413
973
+ #: lib/view/WpProQuiz_View_GobalSettings.php:435
974
+ #: lib/view/WpProQuiz_View_GobalSettings.php:487
975
+ #: lib/view/WpProQuiz_View_QuizEdit.php:91
976
+ #: lib/view/WpProQuiz_View_QuizEdit.php:110
977
+ #: lib/view/WpProQuiz_View_QuizEdit.php:129
978
+ #: lib/view/WpProQuiz_View_QuizEdit.php:148
979
+ #: lib/view/WpProQuiz_View_QuizEdit.php:164
980
+ #: lib/view/WpProQuiz_View_QuizEdit.php:180
981
+ #: lib/view/WpProQuiz_View_QuizEdit.php:217
982
+ #: lib/view/WpProQuiz_View_QuizEdit.php:257
983
+ #: lib/view/WpProQuiz_View_QuizEdit.php:315
984
+ #: lib/view/WpProQuiz_View_QuizEdit.php:344
985
+ #: lib/view/WpProQuiz_View_QuizEdit.php:405
986
+ #: lib/view/WpProQuiz_View_QuizEdit.php:509
987
+ #: lib/view/WpProQuiz_View_QuizEdit.php:532
988
+ #: lib/view/WpProQuiz_View_QuizEdit.php:551
989
+ #: lib/view/WpProQuiz_View_QuizEdit.php:695
990
+ #: lib/view/WpProQuiz_View_QuizEdit.php:720
991
+ #: lib/view/WpProQuiz_View_QuizEdit.php:746
992
+ #: lib/view/WpProQuiz_View_QuizEdit.php:772
993
+ #: lib/view/WpProQuiz_View_QuizEdit.php:798
994
+ #: lib/view/WpProQuiz_View_QuizEdit.php:840
995
+ #: lib/view/WpProQuiz_View_QuizEdit.php:859
996
+ #: lib/view/WpProQuiz_View_QuizEdit.php:884
997
+ #: lib/view/WpProQuiz_View_QuizEdit.php:934
998
+ #: lib/view/WpProQuiz_View_QuizEdit.php:954
999
+ #: lib/view/WpProQuiz_View_QuizEdit.php:979
1000
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1004
1001
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1046
1002
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1079
1003
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1093
1004
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1141
1005
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1223
1006
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1224
1007
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1225
1008
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1226
1009
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1329
1010
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1551
1011
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1631
1012
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1683
1013
+ msgid "Activate"
1014
+ msgstr "Aktywuj"
1015
+
1016
+ #: lib/view/WpProQuiz_View_GobalSettings.php:284
1017
+ #: lib/view/WpProQuiz_View_GobalSettings.php:353
1018
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1557
1019
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1689
1020
+ msgid "Message body:"
1021
+ msgstr "Treść wiadomości:"
1022
+
1023
+ #: lib/view/WpProQuiz_View_GobalSettings.php:292
1024
+ #: lib/view/WpProQuiz_View_GobalSettings.php:361
1025
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1569
1026
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1701
1027
+ msgid "Allowed variables"
1028
+ msgstr "Dozwolone zmienne"
1029
+
1030
+ #: lib/view/WpProQuiz_View_GobalSettings.php:294
1031
+ #: lib/view/WpProQuiz_View_GobalSettings.php:363
1032
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1580
1033
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1712
1034
+ msgid "User-ID"
1035
+ msgstr "ID użytkownika"
1036
+
1037
+ #: lib/view/WpProQuiz_View_GobalSettings.php:295
1038
+ #: lib/view/WpProQuiz_View_GobalSettings.php:364
1039
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1581
1040
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1713
1041
+ #: lib/view/WpProQuiz_View_Statistics.php:322
1042
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:22
1043
+ msgid "Username"
1044
+ msgstr "Nazwa użytkownika"
1045
+
1046
+ #: lib/view/WpProQuiz_View_GobalSettings.php:296
1047
+ #: lib/view/WpProQuiz_View_GobalSettings.php:365
1048
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1582
1049
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1714
1050
+ msgid "Quiz-Name"
1051
+ msgstr "Nazwa quizu"
1052
+
1053
+ #: lib/view/WpProQuiz_View_GobalSettings.php:297
1054
+ #: lib/view/WpProQuiz_View_GobalSettings.php:366
1055
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1583
1056
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1715
1057
+ msgid "Result in precent"
1058
+ msgstr "Wynik w procentach"
1059
+
1060
+ #: lib/view/WpProQuiz_View_GobalSettings.php:298
1061
+ #: lib/view/WpProQuiz_View_GobalSettings.php:367
1062
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1584
1063
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1716
1064
+ msgid "Reached points"
1065
+ msgstr "Zdobyte punkty"
1066
+
1067
+ #: lib/view/WpProQuiz_View_GobalSettings.php:299
1068
+ #: lib/view/WpProQuiz_View_GobalSettings.php:368
1069
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1585
1070
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1717
1071
+ msgid "IP-address of the user"
1072
+ msgstr "Adres IP użytkownika"
1073
+
1074
+ #: lib/view/WpProQuiz_View_GobalSettings.php:300
1075
+ #: lib/view/WpProQuiz_View_GobalSettings.php:369
1076
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1586
1077
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1718
1078
+ msgid "Category-Overview"
1079
+ msgstr "Przegląd kategorii"
1080
+
1081
+ #: lib/view/WpProQuiz_View_GobalSettings.php:317
1082
+ #: lib/view/WpProQuiz_View_GobalSettings.php:529
1083
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1616
1084
+ msgid "User e-mail settings"
1085
+ msgstr "Ustawienia adresu email użytkownika"
1086
+
1087
+ #: lib/view/WpProQuiz_View_GobalSettings.php:384
1088
+ msgid "to activate"
1089
+ msgstr "aktywowanie"
1090
+
1091
+ #: lib/view/WpProQuiz_View_GobalSettings.php:386
1092
+ msgid "not to activate"
1093
+ msgstr "nie aktywowanie"
1094
+
1095
+ #: lib/view/WpProQuiz_View_GobalSettings.php:392
1096
+ #: lib/view/WpProQuiz_View_WpqSupport.php:64
1097
+ msgid "Please note"
1098
+ msgstr "Pamiętaj"
1099
+
1100
+ #: lib/view/WpProQuiz_View_GobalSettings.php:394
1101
+ msgid ""
1102
+ "These settings should only be set in cases of problems with Wp-Pro-Quiz."
1103
+ msgstr ""
1104
+ "Te ustawienia powinny być zmieniane tylko w razie problemów z Wp-Pro-Quiz."
1105
+
1106
+ #: lib/view/WpProQuiz_View_GobalSettings.php:404
1107
+ #: lib/view/WpProQuiz_View_GobalSettings.php:409
1108
+ msgid "Automatically add [raw] shortcode"
1109
+ msgstr "Automatycznie dodaje shortcode [raw]"
1110
+
1111
+ #: lib/view/WpProQuiz_View_GobalSettings.php:413
1112
+ #, php-format
1113
+ msgid "It is recommended %s this option on your system."
1114
+ msgstr "Jest zalecane %s tej opcji w Twoim systemie."
1115
+
1116
+ #: lib/view/WpProQuiz_View_GobalSettings.php:416
1117
+ msgid ""
1118
+ "If this option is activated, a [raw] shortcode is automatically set around "
1119
+ "WpProQuiz shortcode ( [WpProQuiz X] ) into [raw] [WpProQuiz X] [/raw]"
1120
+ msgstr ""
1121
+ "Jeśli ta opcja jest aktywna, shortcode [raw] jest automatycznie ustawiany "
1122
+ "przy shortcode'ach WpProQuizu ( [WpProQuiz X] ) do [raw] [WpProQuiz X] [/"
1123
+ "raw]"
1124
+
1125
+ #: lib/view/WpProQuiz_View_GobalSettings.php:419
1126
+ msgid ""
1127
+ "Own themes changes internal order of filters, what causes the problems. "
1128
+ "With additional shortcode [raw] this is prevented."
1129
+ msgstr ""
1130
+ "Własne skórki zmieniają wewnętrzą kolejność filtrów, co może powodować "
1131
+ "problemy. Dodatkowy shortcode [raw] temu zapobiega."
1132
+
1133
+ #: lib/view/WpProQuiz_View_GobalSettings.php:426
1134
+ #: lib/view/WpProQuiz_View_GobalSettings.php:431
1135
+ msgid "Do not load the Javascript-files in the footer"
1136
+ msgstr "Nie ładuj plików javascript w stopce"
1137
+
1138
+ #: lib/view/WpProQuiz_View_GobalSettings.php:438
1139
+ msgid ""
1140
+ "Generally all WpProQuiz-Javascript files are loaded in the footer and only "
1141
+ "when they are really needed."
1142
+ msgstr ""
1143
+ "Ogólnie wszystkie pliki Javascript w WpProQuiz są ładowane w stopce i tylko "
1144
+ "jeśli są na prawdę potrzebne."
1145
+
1146
+ #: lib/view/WpProQuiz_View_GobalSettings.php:441
1147
+ msgid "In very old Wordpress themes this can lead to problems."
1148
+ msgstr ""
1149
+ "W bardzo starych wersjach szablonów Wordpress to może prowadzić do problemów."
1150
+
1151
+ #: lib/view/WpProQuiz_View_GobalSettings.php:444
1152
+ msgid ""
1153
+ "If you activate this option, all WpProQuiz-Javascript files are loaded in "
1154
+ "the header even if they are not needed."
1155
+ msgstr ""
1156
+ "Jeśli aktywujesz tę opcję, wszystkie pliki Javascript w WpProQuiz będą "
1157
+ "ładowane w nagłówku (header) nawet jeśli nie są potrzebne."
1158
+
1159
+ #: lib/view/WpProQuiz_View_GobalSettings.php:447
1160
+ #, php-format
1161
+ msgid ""
1162
+ "Anyone who wants to learn more about this topic should read through the "
1163
+ "following websites %s and %s."
1164
+ msgstr ""
1165
+ "Każdy, kto chce się dowiedzieć więcej na ten temat, powinien zajrzeć do tych "
1166
+ "stron %s i %s."
1167
+
1168
+ #: lib/view/WpProQuiz_View_GobalSettings.php:456
1169
+ #: lib/view/WpProQuiz_View_GobalSettings.php:461
1170
+ msgid "Touch Library"
1171
+ msgstr "Touch Library"
1172
+
1173
+ #: lib/view/WpProQuiz_View_GobalSettings.php:465
1174
+ #: lib/view/WpProQuiz_View_QuizEdit.php:439
1175
+ #: lib/view/WpProQuiz_View_QuizEdit.php:458
1176
+ #: lib/view/WpProQuiz_View_QuizEdit.php:478
1177
+ #: lib/view/WpProQuiz_View_QuizEdit.php:909
1178
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1493
1179
+ msgid "Deactivate"
1180
+ msgstr "Deaktywuj"
1181
+
1182
+ #: lib/view/WpProQuiz_View_GobalSettings.php:468
1183
+ msgid "In Version 0.13 a new Touch Library was added for mobile devices."
1184
+ msgstr ""
1185
+ "W wersji 0.13 nowa \"Touch Library\" została dodana do urządzeń mobilnych."
1186
+
1187
+ #: lib/view/WpProQuiz_View_GobalSettings.php:471
1188
+ msgid "If you have any problems with the Touch Library, please deactivate it."
1189
+ msgstr "Jeśli masz jakieś problemy z \"Touch Library\", proszę wyłącz to."
1190
+
1191
+ #: lib/view/WpProQuiz_View_GobalSettings.php:478
1192
+ #: lib/view/WpProQuiz_View_GobalSettings.php:483
1193
+ msgid "jQuery support cors"
1194
+ msgstr "Wsparcie jQuery"
1195
+
1196
+ #: lib/view/WpProQuiz_View_GobalSettings.php:490
1197
+ msgid "Is required only in rare cases."
1198
+ msgstr "Jest wymagane tylko w rzadkich przypadkach."
1199
+
1200
+ #: lib/view/WpProQuiz_View_GobalSettings.php:493
1201
+ msgid "If you have problems with the front ajax, please activate it."
1202
+ msgstr "Jeśli masz problemy z ajaxem, proszę aktywuj to."
1203
+
1204
+ #: lib/view/WpProQuiz_View_GobalSettings.php:496
1205
+ msgid "e.g. Domain with special characters in combination with IE"
1206
+ msgstr "np. domena ze specjalnymi znakami w połączeniu z IE"
1207
+
1208
+ #: lib/view/WpProQuiz_View_GobalSettings.php:503
1209
+ #: lib/view/WpProQuiz_View_GobalSettings.php:508
1210
+ #: lib/view/WpProQuiz_View_GobalSettings.php:510
1211
+ msgid "Repair database"
1212
+ msgstr "Napraw bazę danych"
1213
+
1214
+ #: lib/view/WpProQuiz_View_GobalSettings.php:512
1215
+ msgid "No date will be deleted. Only WP-Pro-Quiz tables will be repaired."
1216
+ msgstr ""
1217
+ "Żadne dane nie zostaną usunięte. Tylko tabele WP-Pro-Quiz zostaną naprawione"
1218
+
1219
+ #: lib/view/WpProQuiz_View_Import.php:21
1220
+ #: lib/view/WpProQuiz_View_QuizOverall.php:273
1221
+ #: lib/view/WpProQuiz_View_QuizOverall.php:308
1222
+ #: lib/view/WpProQuiz_View_QuizOverall.php:353
1223
+ msgid "Import"
1224
+ msgstr "Zaimportuj"
1225
+
1226
+ #: lib/view/WpProQuiz_View_Import.php:25
1227
+ msgid "Error"
1228
+ msgstr "Błąd"
1229
+
1230
+ #: lib/view/WpProQuiz_View_Import.php:32
1231
+ msgid "Successfully"
1232
+ msgstr "Pomyślnie"
1233
+
1234
+ #: lib/view/WpProQuiz_View_Import.php:34
1235
+ msgid "Import completed successfully"
1236
+ msgstr "Import ukończony pomyślnie"
1237
+
1238
+ #: lib/view/WpProQuiz_View_Import.php:43
1239
+ msgid "Quiz name"
1240
+ msgstr "Nazwa Quizu"
1241
+
1242
+ #: lib/view/WpProQuiz_View_Import.php:69
1243
+ #: lib/view/WpProQuiz_View_QuizOverall.php:364
1244
+ msgid "Start import"
1245
+ msgstr "Zacznij import"
1246
+
1247
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:7
1248
+ #: lib/view/WpProQuiz_View_WpqSupport.php:31
1249
+ msgid "WP-Pro-Quiz special modification"
1250
+ msgstr "WP-Pro-Quiz specjalne modyfikacje"
1251
+
1252
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:9
1253
+ #: lib/view/WpProQuiz_View_QuizOverall.php:285
1254
+ #: lib/view/WpProQuiz_View_WpqSupport.php:32
1255
+ msgid "You need special WP-Pro-Quiz modification for your website?"
1256
+ msgstr "Potrzebujesz specjalnej modyfikacji do WP-Pro-Quiz na Twoją stronę?"
1257
+
1258
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:11
1259
+ msgid "We offer you:"
1260
+ msgstr "Oferujemy Ci:"
1261
+
1262
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:13
1263
+ msgid "Design adaption for your theme"
1264
+ msgstr "Dostosowanie do wyglądu Twojej witryny"
1265
+
1266
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:14
1267
+ msgid "Creation of additional modules for your needs"
1268
+ msgstr "Stworzenie dodatkowych modułów dla Twoich potrzeb"
1269
+
1270
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:15
1271
+ msgid "Premium Support"
1272
+ msgstr "Pomoc premium"
1273
+
1274
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:18
1275
+ msgid "Contact us:"
1276
+ msgstr "Skontaktuj się z nami:"
1277
+
1278
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:20
1279
+ msgid "Send us an e-mail"
1280
+ msgstr "Wyślij nam e-mail"
1281
+
1282
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:21
1283
+ msgid "The e-mail must be written in english or german"
1284
+ msgstr "E-mail musi być napisany w języku angielskim lub niemieckim"
1285
+
1286
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:22
1287
+ msgid "Explain your wish detailed and exactly as possible"
1288
+ msgstr "Opisz modyfikację, której potrzebujesz najjaśniej jak potrafisz"
1289
+
1290
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:24
1291
+ msgid "You can send us screenshots, sketches and attachments"
1292
+ msgstr "Możesz wysłać nam załączniki, zrzuty ekranu"
1293
+
1294
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:27
1295
+ msgid "Send us your full name and your web address (webpage-URL)"
1296
+ msgstr "Wyślij nam swoje pełne imie i adres strony (URL)"
1297
+
1298
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:28
1299
+ msgid ""
1300
+ "If you wish design adaption, we additionally need the name of your theme"
1301
+ msgstr ""
1302
+ "Jeśli chcesz, aby modyfikacja była dostosowana do wyglądu Twojej witryny, "
1303
+ "napisz jakiego używasz stylu"
1304
+
1305
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:32
1306
+ msgid ""
1307
+ "After receiving your e-mail we will verify your request on feasibility. "
1308
+ "After this you will receive e-mail from us with further details and offer."
1309
+ msgstr ""
1310
+ "Po otrzymaniu od Ciebie e-maila zweryfikujemy wiadomość, następnie otrzymasz "
1311
+ "od nas wiadomość ze szczegółową ofertą."
1312
+
1313
+ #: lib/view/WpProQuiz_View_InfoAdaptation.php:35
1314
+ msgid ""
1315
+ "Extended support in first 6 months. Reported bugs and updates of WP Pro Quiz "
1316
+ "are supported. Exception are major releases (update of main version)"
1317
+ msgstr ""
1318
+ "Rozszerzone wsparcie przez pierwsze 6msc. Odnotowane błędy i aktualizacje WP "
1319
+ "Pro Quiz są wspierane. Z wyjątkiem głównych wydań (aktualizacji głównych "
1320
+ "wersji)"
1321
+
1322
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:33
1323
+ #: lib/view/WpProQuiz_View_QuizEdit.php:32
1324
+ msgid "load template"
1325
+ msgstr "załaduj szablon"
1326
+
1327
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:40
1328
+ msgid "Title"
1329
+ msgstr "Tytuł"
1330
+
1331
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:40
1332
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:80
1333
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:125
1334
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:142
1335
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:154
1336
+ #: lib/view/WpProQuiz_View_QuizEdit.php:43
1337
+ #: lib/view/WpProQuiz_View_QuizEdit.php:582
1338
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1029
1339
+ msgid "(optional)"
1340
+ msgstr "(opcjonalnie)"
1341
+
1342
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:43
1343
+ msgid ""
1344
+ "The title is used for overview, it is not visible in quiz. If you leave the "
1345
+ "title field empty, a title will be generated."
1346
+ msgstr ""
1347
+ "Tytuł jest używany w podglądzie, nie jest widoczny w quizie. Jeśli zostawisz "
1348
+ "te pole puste, tytuł zostanie wygenerowany automatycznie."
1349
+
1350
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:49
1351
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:110
1352
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:211
1353
+ #: lib/view/WpProQuiz_View_QuizEdit.php:37
1354
+ #: lib/view/WpProQuiz_View_QuizEdit.php:571
1355
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1210
1356
+ msgid "(required)"
1357
+ msgstr "(obowiązkowe)"
1358
+
1359
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:53
1360
+ msgid "Points for this question (Standard is 1 point)"
1361
+ msgstr "Punkty za te pytanie (Standardowo 1 punkt)"
1362
+
1363
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:59
1364
+ msgid ""
1365
+ "This points will be rewarded, only if the user closes the question correctly."
1366
+ msgstr "Punkty zostaną naliczone, tylko jeśli użytkownik odpowie prawidłowo."
1367
+
1368
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:65
1369
+ msgid "Different points for each answer"
1370
+ msgstr "Różna ilość punktów za każde z pytań"
1371
+
1372
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:68
1373
+ msgid ""
1374
+ "If you enable this option, you can enter different points for every answer."
1375
+ msgstr ""
1376
+ "Jeśli włączysz tę opcję, będziesz mógł ustalić różne ilości punktów za każdą "
1377
+ "z odpowiedzi."
1378
+
1379
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:74
1380
+ msgid "Show reached points in the correct- and incorrect message?"
1381
+ msgstr ""
1382
+ "Pokazać uzyskane punkty w wiadomości o poprawnych i niepoprawnych "
1383
+ "odpowiedziach?"
1384
+
1385
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:80
1386
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:18
1387
+ #: lib/view/WpProQuiz_View_QuizEdit.php:43
1388
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:18
1389
+ #: lib/view/WpProQuiz_View_Statistics.php:124
1390
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:187
1391
+ msgid "Category"
1392
+ msgstr "Kategoria"
1393
+
1394
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:83
1395
+ msgid ""
1396
+ "You can assign classify category for a question. Categories are e.g. visible "
1397
+ "in statistics function."
1398
+ msgstr ""
1399
+ "Możesz przypisać kategorie do pytania. Kategorie są widoczne np. w "
1400
+ "statystykach."
1401
+
1402
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:86
1403
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:389
1404
+ #: lib/view/WpProQuiz_View_QuizEdit.php:49
1405
+ #: lib/view/WpProQuiz_View_QuizOverall.php:416
1406
+ msgid "You can manage categories in global settings."
1407
+ msgstr "Możesz zarządzać kategoriami w globalnych ustawieniach."
1408
+
1409
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:90
1410
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:100
1411
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:393
1412
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:403
1413
+ #: lib/view/WpProQuiz_View_QuizEdit.php:53
1414
+ #: lib/view/WpProQuiz_View_QuizEdit.php:63
1415
+ #: lib/view/WpProQuiz_View_QuizOverall.php:420
1416
+ #: lib/view/WpProQuiz_View_QuizOverall.php:430
1417
+ msgid "Create new category"
1418
+ msgstr "Stwórz nową kategorię"
1419
+
1420
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:102
1421
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:405
1422
+ #: lib/view/WpProQuiz_View_QuizEdit.php:65
1423
+ #: lib/view/WpProQuiz_View_QuizOverall.php:432
1424
+ msgid "Create"
1425
+ msgstr "Nowa"
1426
+
1427
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:118
1428
+ msgid "Message with the correct / incorrect answer"
1429
+ msgstr "Wiadomość z poprawnymi/niepoprawnymi odpowiedziami"
1430
+
1431
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:120
1432
+ msgid "Deactivated in quiz settings."
1433
+ msgstr "Wyłączone w ustawieniach quizu."
1434
+
1435
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:125
1436
+ msgid "Message with the correct answer"
1437
+ msgstr "Wiadomość w przypadku poprawnej odpowiedzi"
1438
+
1439
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:128
1440
+ msgid ""
1441
+ "This text will be visible if answered correctly. It can be used as "
1442
+ "explanation for complex questions. The message \"Right\" or \"Wrong\" is "
1443
+ "always displayed automatically."
1444
+ msgstr ""
1445
+ "Ten tekst będzie widoczny jeśli odpowiedziano prawidłowo. Może być używane "
1446
+ "dla złożonych pytań. Wiadomość o poprawnych lub niepoprawnych odpowiedziach "
1447
+ "jest zawsze pokazywana automatycznie."
1448
+
1449
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:132
1450
+ msgid "Same text for correct- and incorrect-message?"
1451
+ msgstr "Ten sam tekst dla poprawnej i niepoprawnej wiadomości"
1452
+
1453
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:142
1454
+ msgid "Message with the incorrect answer"
1455
+ msgstr "Wiadomość w przypadku niepoprawnej odpowiedzi"
1456
+
1457
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:145
1458
+ msgid ""
1459
+ "This text will be visible if answered incorrectly. It can be used as "
1460
+ "explanation for complex questions. The message \"Right\" or \"Wrong\" is "
1461
+ "always displayed automatically."
1462
+ msgstr ""
1463
+ "Ten tekst będzie widoczny, jeśli odpowiedziano nieprawidłowo. To może być "
1464
+ "użyte w przypadku wyjaśnienia skomplikowanych pytań. Wiadomość o "
1465
+ "\"Poprawnych\" lub \"Niepoprawnych\" odpowiedziach jest wyświetlana zawsze "
1466
+ "automatycznie."
1467
+
1468
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:157
1469
+ msgid "Here you can enter solution hint."
1470
+ msgstr "Tutaj możesz wpisać podpowiedź."
1471
+
1472
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:161
1473
+ msgid "Activate hint for this question?"
1474
+ msgstr "Włączyć podpowiedzi do pytań?"
1475
+
1476
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:173
1477
+ msgid "Answer type"
1478
+ msgstr "Typ odpowiedzi"
1479
+
1480
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:181
1481
+ msgid "Single choice"
1482
+ msgstr "Pojedynczy wybór"
1483
+
1484
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:185
1485
+ msgid "Multiple choice"
1486
+ msgstr "Wielokrotny wybór"
1487
+
1488
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:189
1489
+ msgid "\"Free\" choice"
1490
+ msgstr ""
1491
+
1492
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:193
1493
+ msgid "\"Sorting\" choice"
1494
+ msgstr "Sortowanie "
1495
+
1496
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:197
1497
+ msgid "\"Matrix Sorting\" choice"
1498
+ msgstr "Dopasowywanie (przeciągnij odpowiedź)"
1499
+
1500
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:201
1501
+ msgid "Cloze"
1502
+ msgstr "Puste pole (wstaw słowo)"
1503
+
1504
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:205
1505
+ msgid "Assessment"
1506
+ msgstr "Ocena"
1507
+
1508
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:211
1509
+ msgid "Answers"
1510
+ msgstr "Odpowiedzi"
1511
+
1512
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:218
1513
+ msgid ""
1514
+ "Please sort the answers in right order with the \"Move\" - Button. The "
1515
+ "answers will be displayed randomly."
1516
+ msgstr ""
1517
+ "Proszę posortować odpowiedzi w poprawnej kolejności używając przycisku "
1518
+ "\"Przenieś\". Odpowiedzi zostaną wyświetlone losowo."
1519
+
1520
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:223
1521
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:229
1522
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:251
1523
+ msgid "Add new answer"
1524
+ msgstr "Dodaj nową odpowiedź"
1525
+
1526
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:233
1527
+ msgid ""
1528
+ "In this mode, not a list have to be sorted, but elements must be assigned to "
1529
+ "matching criterion."
1530
+ msgstr ""
1531
+ "W tym trybie, to nie lista ma zostać posortowana, ale elementy muszą być "
1532
+ "przypisane do odpowiednich kryteriów."
1533
+
1534
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:236
1535
+ msgid ""
1536
+ "You can create sort elements with empty criteria, which can't be assigned by "
1537
+ "user."
1538
+ msgstr ""
1539
+ "Możesz stworzyć elementy do posortowania, z pustymi kryteriami, które nie "
1540
+ "mogą być przypisane przez użytkownika. (innymi słowy - tworząc taką listę, "
1541
+ "stworzysz dodatkowe odpowiedzi, które są niepoprawne/dodatkowe i nie powinny "
1542
+ "być do niczego przypisane przez użytkownika)"
1543
+
1544
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:240
1545
+ msgid "Percentage width of criteria table column:"
1546
+ msgstr "Procentowa szerokość kolumny z kryteriami:"
1547
+
1548
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:245
1549
+ msgid ""
1550
+ "Allows adjustment of the left column's width, and the right column will auto-"
1551
+ "fill the rest of the available space. Increase this to allow accommodate "
1552
+ "longer criterion text. Defaults to 20%."
1553
+ msgstr ""
1554
+ "Pozwala ustalić szerokość lewej kolumny, a szerokość prawej kolumny "
1555
+ "dostosuje swoją szerokość do pozostałeś przestrzeni. Zwiększ to, aby "
1556
+ "dostosować wielkość tekstu kryteriów. Standardowo 20%."
1557
+
1558
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:266
1559
+ #: lib/view/WpProQuiz_View_QuizEdit.php:658
1560
+ msgid "template name"
1561
+ msgstr "nazwa szablonu"
1562
+
1563
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:268
1564
+ #: lib/view/WpProQuiz_View_QuizEdit.php:660
1565
+ msgid "Create new template"
1566
+ msgstr "Utwórz nowy szablon"
1567
+
1568
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:276
1569
+ #: lib/view/WpProQuiz_View_QuizEdit.php:668
1570
+ msgid "Save as template"
1571
+ msgstr "Zapisz jako szablon"
1572
+
1573
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:295
1574
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:345
1575
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:398
1576
+ #: lib/view/WpProQuiz_View_QuizEdit.php:76
1577
+ msgid "Options"
1578
+ msgstr "Opcje"
1579
+
1580
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:296
1581
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:399
1582
+ msgid "Answer"
1583
+ msgstr "Odpowiedź"
1584
+
1585
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:311
1586
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:370
1587
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:376
1588
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:408
1589
+ msgid "Allow HTML"
1590
+ msgstr "Pozwól na HTML"
1591
+
1592
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:328
1593
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:383
1594
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:425
1595
+ msgid "Delete answer"
1596
+ msgstr "Usuń odpowiedź"
1597
+
1598
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:329
1599
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:384
1600
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:426
1601
+ msgid "Add Media"
1602
+ msgstr "Dodaj załącznik"
1603
+
1604
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:330
1605
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:385
1606
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:427
1607
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1453
1608
+ msgid "Move"
1609
+ msgstr "Przenieś"
1610
+
1611
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:346
1612
+ msgid "Criterion"
1613
+ msgstr "Kryteria"
1614
+
1615
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:438
1616
+ msgid ""
1617
+ "correct answers (one per line) (answers will be converted to lower case)"
1618
+ msgstr ""
1619
+ "poprawne odpowiedzi (jedna odpowiedz w każdej linii) (odpowiedzi będą "
1620
+ "skonwertowane do małych liter)"
1621
+
1622
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:451
1623
+ msgid ""
1624
+ "Enclose the searched words with { } e.g. \"I {play} soccer\". Capital and "
1625
+ "small letters will be ignored."
1626
+ msgstr ""
1627
+ "Ustal szukane słowa używając znacznika { } np. \"Ja {kocham} koszykówkę\". "
1628
+ "Duże i małe litery będą ignorowane."
1629
+
1630
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:454
1631
+ msgid ""
1632
+ "You can specify multiple options for a search word. Enclose the word with "
1633
+ "[ ] e.g. <span style=\"font-style: normal; letter-spacing: 2px;\"> \"I "
1634
+ "{[play][love][hate]} soccer\" </span>. In this case answers play, love OR "
1635
+ "hate are correct."
1636
+ msgstr ""
1637
+ "Możesz sprecyzować kilka opcji szukanego słowa. Ustal słowa w znacznikach [] "
1638
+ "np. <span style=\"\font-style:normal; letter-spacing: 2px;\"> \"Ja {[lubię]"
1639
+ "[kocham][nienawidzę]} koszykówkę\" </span>. W tym przypadku odpowiedzi "
1640
+ "lubię, kocham LUB nienawidzę są poprawne."
1641
+
1642
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:457
1643
+ msgid ""
1644
+ "If mode \"Different points for every answer\" is activated, you can assign "
1645
+ "points with |POINTS. Otherwise 1 point will be awarded for every answer."
1646
+ msgstr ""
1647
+ "Jeśli tryb \"Różna ilość punktów za każde pytanie\" jest włączona, możesz "
1648
+ "ustalić ilość punktów używając |PUNKTÓW. Jeśli ta opcja jest wyłączona, za "
1649
+ "każdą z odpowiedzi otrzymasz 1 punkt."
1650
+
1651
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:460
1652
+ msgid ""
1653
+ "e.g. \"I {play} soccer, with a {ball|3}\" - \"play\" gives 1 point and \"ball"
1654
+ "\" 3 points."
1655
+ msgstr ""
1656
+ "np. \"Ja {gram} w koszykówkę, używając {piłki|3}\" - za słowo \"gram\" "
1657
+ "otrzymasz 1 punkt, a za \"piłki\" 3 punkty."
1658
+
1659
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:472
1660
+ msgid "Here you can create an assessment question."
1661
+ msgstr "Tutaj możesz utworzyć pytanie oparte na ocenianiu."
1662
+
1663
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:475
1664
+ msgid ""
1665
+ "Enclose a assesment with {}. The individual assessments are marked with []."
1666
+ msgstr ""
1667
+ "Dodaj oceny za pomocą {}. Pojedyncze oceny powinieneś wpisać między "
1668
+ "znaczniki [ ]."
1669
+
1670
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:477
1671
+ msgid "The number of options in the maximum score."
1672
+ msgstr "Liczba opcji w maksymalnym wyniku"
1673
+
1674
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:480
1675
+ msgid "Examples:"
1676
+ msgstr "Przykład:"
1677
+
1678
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:482
1679
+ msgid "less true { [1] [2] [3] [4] [5] } more true"
1680
+ msgstr "mniej prawdziwe { [1] [2] [3] [4] [5] } bardziej prawdziwe"
1681
+
1682
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:485
1683
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:494
1684
+ #: lib/view/WpProQuiz_View_QuizEdit.php:414
1685
+ #: lib/view/WpProQuiz_View_QuizEdit.php:420
1686
+ #: lib/view/WpProQuiz_View_QuizEdit.php:701
1687
+ #: lib/view/WpProQuiz_View_QuizEdit.php:728
1688
+ #: lib/view/WpProQuiz_View_QuizEdit.php:754
1689
+ #: lib/view/WpProQuiz_View_QuizEdit.php:780
1690
+ #: lib/view/WpProQuiz_View_QuizEdit.php:806
1691
+ #: lib/view/WpProQuiz_View_QuizEdit.php:865
1692
+ #: lib/view/WpProQuiz_View_QuizEdit.php:890
1693
+ #: lib/view/WpProQuiz_View_QuizEdit.php:915
1694
+ #: lib/view/WpProQuiz_View_QuizEdit.php:960
1695
+ #: lib/view/WpProQuiz_View_QuizEdit.php:985
1696
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1010
1697
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1182
1698
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1192
1699
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1245
1700
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1253
1701
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1261
1702
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1269
1703
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1352
1704
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1364
1705
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1371
1706
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1395
1707
+ msgid "Demo"
1708
+ msgstr "Demo"
1709
+
1710
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:491
1711
+ msgid "less true { [a] [b] [c] } more true"
1712
+ msgstr "mniej prawdziwe { [a] [b] [c] } bardziej prawdziwe"
1713
+
1714
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:510
1715
+ msgid "Single choice options"
1716
+ msgstr "Opcja pojedynczego wyboru"
1717
+
1718
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:513
1719
+ msgid ""
1720
+ "If \"Different points for each answer\" is activated, you can activate a "
1721
+ "special mode.<br> This changes the calculation of the points"
1722
+ msgstr ""
1723
+ "Jeśli \"Różna ilość punktów za każde pytania\" jest aktywna, możesz włączyć "
1724
+ "specjalny tryb. <br> Zmienia on naliczanie punktów"
1725
+
1726
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:517
1727
+ msgid "Different points - modus 2 activate"
1728
+ msgstr "Różna ilość punktów - tryb 2 aktywny"
1729
+
1730
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:521
1731
+ msgid "Disables the distinction between correct and incorrect."
1732
+ msgstr "Wyłącza oznaczanie między poprawną i niepoprawną odpowiedzią"
1733
+
1734
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:525
1735
+ msgid "disable correct and incorrent"
1736
+ msgstr "wyłącz poprawne i niepoprawne"
1737
+
1738
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:529
1739
+ msgid "Explanation of points calculation"
1740
+ msgstr "Wyjaśnienie naliczania punktów"
1741
+
1742
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:549
1743
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:554
1744
+ msgid "\"Different points for each answer\" enabled"
1745
+ msgstr "\"Różna ilość punktów do każdego z pytań\" włączony"
1746
+
1747
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:551
1748
+ msgid "\"Different points - mode 2\" disable"
1749
+ msgstr "\"Różna ilość punktów - tryb 2\" wyłączony"
1750
+
1751
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:556
1752
+ msgid "\"Different points - mode 2\" enabled"
1753
+ msgstr "\"Różna ilość punktów - tryb 2\" włączony"
1754
+
1755
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:293
1756
+ #, php-format
1757
+ msgid "Quiz: %s"
1758
+ msgstr ""
1759
+
1760
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:296
1761
+ msgid "Add question"
1762
+ msgstr "Dodaj pytanie"
1763
+
1764
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:307
1765
+ msgid "Sort Question"
1766
+ msgstr "Sortuj pytania"
1767
+
1768
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:308
1769
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:349
1770
+ msgid "Copy questions from another Quiz"
1771
+ msgstr "Skopiuj pytania z innego Quizu"
1772
+
1773
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:332
1774
+ #: lib/view/WpProQuiz_View_QuizOverall.php:321
1775
+ msgid "Search"
1776
+ msgstr "Szukaj"
1777
+
1778
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:350
1779
+ msgid ""
1780
+ "Here you can copy questions from another quiz into this quiz. (Multiple "
1781
+ "selection enabled)"
1782
+ msgstr ""
1783
+ "Tutaj możesz skopiować pytania z innego quizu do tego quizu. (działa "
1784
+ "wielokrotny wybór)"
1785
+
1786
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:362
1787
+ msgid "Copy questions"
1788
+ msgstr "Kopiuj pytania"
1789
+
1790
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:376
1791
+ msgid "Set Question Categories"
1792
+ msgstr "Ustaw kategorię pytania"
1793
+
1794
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:377
1795
+ msgid "Sets multiple question categories"
1796
+ msgstr "Ustaw kilka kategorii pytań"
1797
+
1798
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:386
1799
+ msgid "You can assign classify category for a question."
1800
+ msgstr "Możesz przypisać kategorie do pytania."
1801
+
1802
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:84
1803
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:93
1804
+ msgid "Set Category"
1805
+ msgstr "Ustaw kategorię"
1806
+
1807
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:95
1808
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:104
1809
+ msgid "Filter by category"
1810
+ msgstr "Filtruj po kategorii"
1811
+
1812
+ #: lib/view/WpProQuiz_View_QuestionOverallTable.php:97
1813
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:106
1814
+ msgid "All categories"
1815
+ msgstr "Wszystkie kategorie"
1816
+
1817
+ #: lib/view/WpProQuiz_View_QuizEdit.php:37
1818
+ msgid "Quiz title"
1819
+ msgstr "Tytuł Quizu"
1820
+
1821
+ #: lib/view/WpProQuiz_View_QuizEdit.php:46
1822
+ #: lib/view/WpProQuiz_View_QuizOverall.php:413
1823
+ msgid "You can assign classify category for a quiz."
1824
+ msgstr "Możesz przypisać kategorię do quizu."
1825
+
1826
+ #: lib/view/WpProQuiz_View_QuizEdit.php:82
1827
+ msgid "Hide quiz title"
1828
+ msgstr "Ukryj tytuł quizu"
1829
+
1830
+ #: lib/view/WpProQuiz_View_QuizEdit.php:87
1831
+ msgid "Hide title"
1832
+ msgstr "Ukryj tytuł"
1833
+
1834
+ #: lib/view/WpProQuiz_View_QuizEdit.php:94
1835
+ msgid "The title serves as quiz heading."
1836
+ msgstr "Tytuł pełni funkcję nagłówka quizu."
1837
+
1838
+ #: lib/view/WpProQuiz_View_QuizEdit.php:101
1839
+ #: lib/view/WpProQuiz_View_QuizEdit.php:106
1840
+ msgid "Hide \"Restart quiz\" button"
1841
+ msgstr "Ukryj przycisk \"Restartuj quiz\" "
1842
+
1843
+ #: lib/view/WpProQuiz_View_QuizEdit.php:113
1844
+ msgid "Hide the \"Restart quiz\" button in the Frontend."
1845
+ msgstr "Ukrywa przycisk \"Restartuj quiz\" w quizie."
1846
+
1847
+ #: lib/view/WpProQuiz_View_QuizEdit.php:120
1848
+ #: lib/view/WpProQuiz_View_QuizEdit.php:125
1849
+ msgid "Hide \"View question\" button"
1850
+ msgstr "Ukryj przycisk \"Widok pytań\""
1851
+
1852
+ #: lib/view/WpProQuiz_View_QuizEdit.php:132
1853
+ msgid "Hide the \"View question\" button in the Frontend."
1854
+ msgstr "Ukrywa przycisk \"Widok pytań\" w quizie."
1855
+
1856
+ #: lib/view/WpProQuiz_View_QuizEdit.php:139
1857
+ #: lib/view/WpProQuiz_View_QuizEdit.php:144
1858
+ msgid "Display question randomly"
1859
+ msgstr "Wyświetlaj pytania losowo"
1860
+
1861
+ #: lib/view/WpProQuiz_View_QuizEdit.php:155
1862
+ #: lib/view/WpProQuiz_View_QuizEdit.php:160
1863
+ msgid "Display answers randomly"
1864
+ msgstr "Wyświetlaj odpowiedzi losowo"
1865
+
1866
+ #: lib/view/WpProQuiz_View_QuizEdit.php:171
1867
+ #: lib/view/WpProQuiz_View_QuizEdit.php:176
1868
+ msgid "Sort questions by category"
1869
+ msgstr "Sortuj pytania według kategorii"
1870
+
1871
+ #: lib/view/WpProQuiz_View_QuizEdit.php:183
1872
+ msgid ""
1873
+ "Also works in conjunction with the \"display randomly question\" option."
1874
+ msgstr "Działa również w połączeniu z opcją \"wyświetlaj pytania losowo\"."
1875
+
1876
+ #: lib/view/WpProQuiz_View_QuizEdit.php:198
1877
+ msgid "Seconds"
1878
+ msgstr "Sekundy"
1879
+
1880
+ #: lib/view/WpProQuiz_View_QuizEdit.php:201
1881
+ msgid "0 = no limit"
1882
+ msgstr "0 = brak limitu"
1883
+
1884
+ #: lib/view/WpProQuiz_View_QuizEdit.php:208
1885
+ #: lib/view/WpProQuiz_View_QuizEdit.php:213
1886
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:75
1887
+ msgid "Statistics"
1888
+ msgstr "Statystyki"
1889
+
1890
+ #: lib/view/WpProQuiz_View_QuizEdit.php:220
1891
+ msgid ""
1892
+ "Statistics about right or wrong answers. Statistics will be saved by "
1893
+ "completed quiz, not after every question. The statistics is only visible "
1894
+ "over administration menu. (internal statistics)"
1895
+ msgstr ""
1896
+ "Statystyki o poprawnych i niepoprawnych odpowiedział. Statystyki będą "
1897
+ "zapisywane po ukończeniu quizu, nie po każdym pytaniu. Statystyki są "
1898
+ "widoczne tylko w panelu administratora. (wewnętrzne statystyki)"
1899
+
1900
+ #: lib/view/WpProQuiz_View_QuizEdit.php:227
1901
+ #: lib/view/WpProQuiz_View_QuizEdit.php:232
1902
+ msgid "Statistics IP-lock"
1903
+ msgstr "IP-blokada w statystykach"
1904
+
1905
+ #: lib/view/WpProQuiz_View_QuizEdit.php:236
1906
+ msgid "in minutes (recommended 1440 minutes = 1 day)"
1907
+ msgstr "w minutach (zalecane 1440 minut = 1 dzień)"
1908
+
1909
+ #: lib/view/WpProQuiz_View_QuizEdit.php:239
1910
+ msgid ""
1911
+ "Protect the statistics from spam. Result will only be saved every X minutes "
1912
+ "from same IP. (0 = deactivated)"
1913
+ msgstr ""
1914
+ "Chroń statystyki przed spamem. Wyniki będą zapisywane o każde X minut z tego "
1915
+ "samego IP. (0 = wyłączone)"
1916
+
1917
+ #: lib/view/WpProQuiz_View_QuizEdit.php:246
1918
+ #: lib/view/WpProQuiz_View_QuizEdit.php:252
1919
+ msgid "Execute quiz only once"
1920
+ msgstr "Pozwól rozwiązać quiz tylko raz"
1921
+
1922
+ #: lib/view/WpProQuiz_View_QuizEdit.php:260
1923
+ msgid ""
1924
+ "If you activate this option, the user can complete the quiz only once. "
1925
+ "Afterwards the quiz is blocked for this user."
1926
+ msgstr ""
1927
+ "Jeśli włączysz tę opcję, użytkownik będzie mógł ukończyć quiz tylko raz. "
1928
+ "Potem quiz zostanie dla niego zablokowany."
1929
+
1930
+ #: lib/view/WpProQuiz_View_QuizEdit.php:264
1931
+ msgid "This option applies to:"
1932
+ msgstr "Ta opcja zostanie zastosowana do:"
1933
+
1934
+ #: lib/view/WpProQuiz_View_QuizEdit.php:272
1935
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1057
1936
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:102
1937
+ msgid "all users"
1938
+ msgstr "wszyscy użytkownicy"
1939
+
1940
+ #: lib/view/WpProQuiz_View_QuizEdit.php:276
1941
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1061
1942
+ msgid "registered useres only"
1943
+ msgstr "tylko zarejestrowani użytkownicy"
1944
+
1945
+ #: lib/view/WpProQuiz_View_QuizEdit.php:280
1946
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1065
1947
+ msgid "anonymous users only"
1948
+ msgstr "tylko anonimowi użytkownicy"
1949
+
1950
+ #: lib/view/WpProQuiz_View_QuizEdit.php:286
1951
+ msgid "user identification by cookie"
1952
+ msgstr "identyfikacja poprzez ciasteczka (cookie)"
1953
+
1954
+ #: lib/view/WpProQuiz_View_QuizEdit.php:289
1955
+ msgid ""
1956
+ "If you activate this option, a cookie is set additionally for unregistrated "
1957
+ "(anonymous) users. This ensures a longer assignment of the user than the "
1958
+ "simple assignment by the IP address."
1959
+ msgstr ""
1960
+ "Jeśli włączysz tę opcję, ciasteczka (cookies) są ustawione dodatkowo dla "
1961
+ "niezarejestrowanych (anonimowych) użytkowników. To zapewnia większą "
1962
+ "identyfikację użytkownika niż przypisanie poprzez sam adres IP"
1963
+
1964
+ #: lib/view/WpProQuiz_View_QuizEdit.php:294
1965
+ msgid "Reset the user identification"
1966
+ msgstr "Zresetuj identyfikator użytkownika"
1967
+
1968
+ #: lib/view/WpProQuiz_View_QuizEdit.php:295
1969
+ msgid "User identification has been reset."
1970
+ msgstr "Identyfikator użytkownika został zresetowany"
1971
+
1972
+ #: lib/view/WpProQuiz_View_QuizEdit.php:297
1973
+ msgid "Resets user identification for all users."
1974
+ msgstr "Zresetuj identyfikacje dla wszystkich użytkowników"
1975
+
1976
+ #: lib/view/WpProQuiz_View_QuizEdit.php:306
1977
+ #: lib/view/WpProQuiz_View_QuizEdit.php:311
1978
+ msgid "Show only specific number of questions"
1979
+ msgstr "Pokaż określoną ilość pytań"
1980
+
1981
+ #: lib/view/WpProQuiz_View_QuizEdit.php:318
1982
+ msgid ""
1983
+ "If you enable this option, maximum number of displayed questions will be X "
1984
+ "from X questions. (The output of questions is random)"
1985
+ msgstr ""
1986
+ "Jeśli włączysz tę opcję, maksymalna ilość wyświetlonych pytań będzie X z X "
1987
+ "pytań. (Pytania będą losowe)"
1988
+
1989
+ #: lib/view/WpProQuiz_View_QuizEdit.php:322
1990
+ msgid "How many questions should be displayed simultaneously:"
1991
+ msgstr "Ile pytań wyświetlić jednocześnie:"
1992
+
1993
+ #: lib/view/WpProQuiz_View_QuizEdit.php:327
1994
+ msgid "in percent"
1995
+ msgstr "w procentach"
1996
+
1997
+ #: lib/view/WpProQuiz_View_QuizEdit.php:335
1998
+ #: lib/view/WpProQuiz_View_QuizEdit.php:340
1999
+ msgid "Prerequisites"
2000
+ msgstr "Wymóg wstępu"
2001
+
2002
+ #: lib/view/WpProQuiz_View_QuizEdit.php:347
2003
+ msgid ""
2004
+ "If you enable this option, you can choose quiz, which user have to finish "
2005
+ "before he can start this quiz."
2006
+ msgstr ""
2007
+ "Jeśli włączysz tę opcję, będziesz mógł wybrać quiz, który użytkownik będzie "
2008
+ "musiał ukończyć przed rozpoczęciem tego quizu."
2009
+
2010
+ #: lib/view/WpProQuiz_View_QuizEdit.php:350
2011
+ msgid ""
2012
+ "In all selected quizzes statistic function have to be active. If it is not "
2013
+ "it will be activated automatically."
2014
+ msgstr ""
2015
+ "We wszystkich zaznaczonych quizach funkcja statystyk musi być aktywna. Jeśli "
2016
+ "nie jest, to zostanie aktywowana automatycznie."
2017
+
2018
+ #: lib/view/WpProQuiz_View_QuizEdit.php:357
2019
+ msgid "Prerequisites (This quiz have to be finished)"
2020
+ msgstr "Wymóg wstępu (Ten quiz musi być ukończony)"
2021
+
2022
+ #: lib/view/WpProQuiz_View_QuizEdit.php:396
2023
+ #: lib/view/WpProQuiz_View_QuizEdit.php:401
2024
+ #: lib/view/WpProQuiz_View_QuizEdit.php:414
2025
+ msgid "Question overview"
2026
+ msgstr "Przegląd pytań"
2027
+
2028
+ #: lib/view/WpProQuiz_View_QuizEdit.php:408
2029
+ msgid ""
2030
+ "Add at the top of the quiz a question overview, which allows easy "
2031
+ "navigation. Additional questions can be marked \"to review\"."
2032
+ msgstr ""
2033
+ "Na górze quizu wyświetlony zostanie przegląd pytań, który pozwala na "
2034
+ "łatwą nawigację. Pytania mogą być oznaczane jako \"do sprawdzenia\"."
2035
+
2036
+ #: lib/view/WpProQuiz_View_QuizEdit.php:411
2037
+ msgid "Additional quiz overview will be displayed, before quiz is finished."
2038
+ msgstr "Dodatkowy przegląd quizu będzie wyświetlony przed jego zakończeniem."
2039
+
2040
+ #: lib/view/WpProQuiz_View_QuizEdit.php:442
2041
+ msgid ""
2042
+ "If you enalbe this option, no quiz overview will be displayed, before "
2043
+ "finishing quiz."
2044
+ msgstr ""
2045
+ "Jeśli włączysz tę funkcję nie zostanie wyświetlony przegląd pytań przed "
2046
+ "zakończeniem quizu."
2047
+
2048
+ #: lib/view/WpProQuiz_View_QuizEdit.php:461
2049
+ msgid ""
2050
+ "If you enable this option, user won't be able to skip question. (only in "
2051
+ "\"Overview -> next\" mode). User still will be able to navigate over "
2052
+ "\"Question-Overview\""
2053
+ msgstr ""
2054
+ "Jeśli włączysz tę funkcję, użytkownicy nie będą mogli pominąć pytań. (tylko "
2055
+ "w \"Przegląd -> dalej\" tryb). Użytkownik nadal będzie mógł używać nawigacji "
2056
+ "poprzez \"Przegląd pytań\""
2057
+
2058
+ #: lib/view/WpProQuiz_View_QuizEdit.php:469
2059
+ #: lib/view/WpProQuiz_View_QuizEdit.php:474
2060
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1484
2061
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1489
2062
+ msgid "Admin e-mail notification"
2063
+ msgstr "Powiadomienia administratora poprzez e-mail"
2064
+
2065
+ #: lib/view/WpProQuiz_View_QuizEdit.php:482
2066
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1497
2067
+ msgid "for registered users only"
2068
+ msgstr "tylko dla zarejestrowanych użytkowników"
2069
+
2070
+ #: lib/view/WpProQuiz_View_QuizEdit.php:486
2071
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1501
2072
+ msgid "for all users"
2073
+ msgstr "dla wszystkich użytkowników"
2074
+
2075
+ #: lib/view/WpProQuiz_View_QuizEdit.php:489
2076
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1504
2077
+ msgid ""
2078
+ "If you enable this option, you will be informed if a user completes this "
2079
+ "quiz."
2080
+ msgstr ""
2081
+ "Jeśli włączysz tę funkcję zostaniesz poinformowany, gdy użytkownik ukończy "
2082
+ "quiz."
2083
+
2084
+ #: lib/view/WpProQuiz_View_QuizEdit.php:492
2085
+ #: lib/view/WpProQuiz_View_QuizEdit.php:515
2086
+ msgid "E-Mail settings can be edited in global settings."
2087
+ msgstr "Ustawienia e-maila mogą być edytowane w głównych ustawieniach."
2088
+
2089
+ #: lib/view/WpProQuiz_View_QuizEdit.php:500
2090
+ #: lib/view/WpProQuiz_View_QuizEdit.php:505
2091
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1622
2092
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1627
2093
+ msgid "User e-mail notification"
2094
+ msgstr "Powiadomienia użytkowników poprzez e-mail"
2095
+
2096
+ #: lib/view/WpProQuiz_View_QuizEdit.php:512
2097
+ msgid ""
2098
+ "If you enable this option, an email is sent with his quiz result to the "
2099
+ "user. (only registered users)"
2100
+ msgstr ""
2101
+ "Jeśli włączysz tę funkcję, użytkownicy będą otrzymywać wyniki swoich quizów "
2102
+ "poprzez email. (tylko zarejestrowani użytkownicy)"
2103
+
2104
+ #: lib/view/WpProQuiz_View_QuizEdit.php:523
2105
+ #: lib/view/WpProQuiz_View_QuizEdit.php:528
2106
+ msgid "Autostart"
2107
+ msgstr "Automatyczny start"
2108
+
2109
+ #: lib/view/WpProQuiz_View_QuizEdit.php:535
2110
+ msgid ""
2111
+ "If you enable this option, the quiz will start automatically after the page "
2112
+ "is loaded."
2113
+ msgstr ""
2114
+ "Jeśli włączysz tę funkcję, quiz rozpocznie się automatycznie po załadowaniu "
2115
+ "strony."
2116
+
2117
+ #: lib/view/WpProQuiz_View_QuizEdit.php:542
2118
+ #: lib/view/WpProQuiz_View_QuizEdit.php:547
2119
+ msgid "Only registered users are allowed to start the quiz"
2120
+ msgstr "Tylko zarejestrowani użytkownicy będą mogli rozpocząć quiz"
2121
+
2122
+ #: lib/view/WpProQuiz_View_QuizEdit.php:554
2123
+ msgid ""
2124
+ "If you enable this option, only registered users allowed start the quiz."
2125
+ msgstr ""
2126
+ "Jeśli włączysz tę funkcję, to tylko zarejestrowani użytkownicy będą mogli "
2127
+ "przystąpić do quizu."
2128
+
2129
+ #: lib/view/WpProQuiz_View_QuizEdit.php:571
2130
+ msgid "Quiz description"
2131
+ msgstr "Opis quizu"
2132
+
2133
+ #: lib/view/WpProQuiz_View_QuizEdit.php:574
2134
+ msgid "This text will be displayed before start of the quiz."
2135
+ msgstr "Ten tekst zostanie wyświetlony przed rozpoczęciem quizu."
2136
+
2137
+ #: lib/view/WpProQuiz_View_QuizEdit.php:582
2138
+ msgid "Results text"
2139
+ msgstr "Tekst przy wynikach"
2140
+
2141
+ #: lib/view/WpProQuiz_View_QuizEdit.php:585
2142
+ msgid ""
2143
+ "This text will be displayed at the end of the quiz (in results). (this text "
2144
+ "is optional)"
2145
+ msgstr ""
2146
+ "Ten tekst będzie wyświetlony na zakończenie quizu (w wynikach). (ten tekst "
2147
+ "jest nieobowiązkowy)"
2148
+
2149
+ #: lib/view/WpProQuiz_View_QuizEdit.php:589
2150
+ msgid "Activate graduation"
2151
+ msgstr "Włącz stopniowanie"
2152
+
2153
+ #: lib/view/WpProQuiz_View_QuizEdit.php:595
2154
+ msgid "Hint:"
2155
+ msgstr "Podpowiedź:"
2156
+
2157
+ #: lib/view/WpProQuiz_View_QuizEdit.php:597
2158
+ msgid "Maximal 15 levels"
2159
+ msgstr "Maksymalnie 15 poziomów"
2160
+
2161
+ #: lib/view/WpProQuiz_View_QuizEdit.php:599
2162
+ #, php-format
2163
+ msgid ""
2164
+ "Percentages refer to the total score of the quiz. (Current total %d points "
2165
+ "in %d questions."
2166
+ msgstr ""
2167
+ "Procentowe nawiązanie do całkowitego wyniku quizu. (Aktualnie razem %d "
2168
+ "punktów w %d pytaniach.)"
2169
+
2170
+ #: lib/view/WpProQuiz_View_QuizEdit.php:602
2171
+ msgid "Values can also be mixed up"
2172
+ msgstr "Wartości mogą być również mieszane"
2173
+
2174
+ #: lib/view/WpProQuiz_View_QuizEdit.php:603
2175
+ msgid "10,15% or 10.15% allowed (max. two digits after the decimal point)"
2176
+ msgstr ""
2177
+ "dozwolony format 10,15% lub 10.15% (maksymalnie dwie cyfry po przecinku)"
2178
+
2179
+ #: lib/view/WpProQuiz_View_QuizEdit.php:619
2180
+ #: lib/view/WpProQuiz_View_QuizEdit.php:630
2181
+ msgid "from:"
2182
+ msgstr "Od:"
2183
+
2184
+ #: lib/view/WpProQuiz_View_QuizEdit.php:619
2185
+ #: lib/view/WpProQuiz_View_QuizEdit.php:630
2186
+ msgid "percent"
2187
+ msgstr "procent"
2188
+
2189
+ #: lib/view/WpProQuiz_View_QuizEdit.php:619
2190
+ #: lib/view/WpProQuiz_View_QuizEdit.php:630
2191
+ #, php-format
2192
+ msgid ""
2193
+ "(Will be displayed, when result-percent is >= <span class=\"resultProzent\">"
2194
+ "%s</span>%%)"
2195
+ msgstr ""
2196
+ "(Zostanie wyświetlone, gdy wynik w procentach jest >= <span class="
2197
+ "\"resultProzent\">%s</span>%%)"
2198
+
2199
+ #: lib/view/WpProQuiz_View_QuizEdit.php:620
2200
+ #: lib/view/WpProQuiz_View_QuizEdit.php:631
2201
+ msgid "Delete graduation"
2202
+ msgstr "Usuń stopień"
2203
+
2204
+ #: lib/view/WpProQuiz_View_QuizEdit.php:638
2205
+ msgid "Add graduation"
2206
+ msgstr "Dodaj stopień"
2207
+
2208
+ #: lib/view/WpProQuiz_View_QuizEdit.php:649
2209
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1572
2210
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1704
2211
+ msgid "Custom fields - Variables"
2212
+ msgstr "Pola niestandardowe - zmienne"
2213
+
2214
+ #: lib/view/WpProQuiz_View_QuizEdit.php:680
2215
+ msgid "Result-Options"
2216
+ msgstr "Opcje wyników"
2217
+
2218
+ #: lib/view/WpProQuiz_View_QuizEdit.php:686
2219
+ #: lib/view/WpProQuiz_View_QuizEdit.php:691
2220
+ msgid "Show average points"
2221
+ msgstr "Pokaż średni wynik"
2222
+
2223
+ #: lib/view/WpProQuiz_View_QuizEdit.php:698
2224
+ msgid "Statistics-function must be enabled."
2225
+ msgstr "Funkcja statystyk musi być włączona."
2226
+
2227
+ #: lib/view/WpProQuiz_View_QuizEdit.php:711
2228
+ #: lib/view/WpProQuiz_View_QuizEdit.php:716
2229
+ msgid "Show category score"
2230
+ msgstr "Pokaż wyniki z podziałem na kategorie"
2231
+
2232
+ #: lib/view/WpProQuiz_View_QuizEdit.php:723
2233
+ msgid ""
2234
+ "If you enable this option, the results of each category is displayed on the "
2235
+ "results page."
2236
+ msgstr ""
2237
+ "Jeśli włączysz tę funkcję, wyniki z każdej kategorii będą pokazane na "
2238
+ "stronie z ogólnym wynikiem."
2239
+
2240
+ #: lib/view/WpProQuiz_View_QuizEdit.php:737
2241
+ #: lib/view/WpProQuiz_View_QuizEdit.php:742
2242
+ msgid "Hide correct questions - display"
2243
+ msgstr "Ukryj informacje o poprawnych odpowiedziach"
2244
+
2245
+ #: lib/view/WpProQuiz_View_QuizEdit.php:749
2246
+ msgid ""
2247
+ "If you select this option, no longer the number of correctly answered "
2248
+ "questions are displayed on the results page."
2249
+ msgstr ""
2250
+ "Jeśli włączysz tę opcję, nie będzie już widoczna ilość poprawnych odpowiedzi "
2251
+ "na pytania na stronie z wynikami."
2252
+
2253
+ #: lib/view/WpProQuiz_View_QuizEdit.php:763
2254
+ #: lib/view/WpProQuiz_View_QuizEdit.php:768
2255
+ msgid "Hide quiz time - display"
2256
+ msgstr "Ukryj czas quizu"
2257
+
2258
+ #: lib/view/WpProQuiz_View_QuizEdit.php:775
2259
+ msgid ""
2260
+ "If you enable this option, the time for finishing the quiz won't be "
2261
+ "displayed on the results page anymore."
2262
+ msgstr ""
2263
+ "Jeśli ta opcja zostanie włączona, nie zostanie wyświetlony czas, w którym "
2264
+ "użytkownik ukończył quiz na stronie z wynikami."
2265
+
2266
+ #: lib/view/WpProQuiz_View_QuizEdit.php:789
2267
+ #: lib/view/WpProQuiz_View_QuizEdit.php:794
2268
+ msgid "Hide score - display"
2269
+ msgstr "Ukryj punkty"
2270
+
2271
+ #: lib/view/WpProQuiz_View_QuizEdit.php:801
2272
+ msgid ""
2273
+ "If you enable this option, final score won't be displayed on the results "
2274
+ "page anymore."
2275
+ msgstr ""
2276
+ "Jeśli włączysz tę opcję, ogólne wyniki nie będą wyświetlone na stronie z "
2277
+ "rezultatem quizu."
2278
+
2279
+ #: lib/view/WpProQuiz_View_QuizEdit.php:825
2280
+ msgid "Question-Options"
2281
+ msgstr "Opcje pytania"
2282
+
2283
+ #: lib/view/WpProQuiz_View_QuizEdit.php:831
2284
+ #: lib/view/WpProQuiz_View_QuizEdit.php:836
2285
+ msgid "Show points"
2286
+ msgstr "Pokaż punkty"
2287
+
2288
+ #: lib/view/WpProQuiz_View_QuizEdit.php:843
2289
+ msgid "Shows in quiz, how many points are reachable for respective question."
2290
+ msgstr "Pokaż w quizie, jak dużo punktów jest do zdobycia za każde z pytań."
2291
+
2292
+ #: lib/view/WpProQuiz_View_QuizEdit.php:850
2293
+ #: lib/view/WpProQuiz_View_QuizEdit.php:855
2294
+ msgid "Number answers"
2295
+ msgstr "Ponumerowane odpowiedzi"
2296
+
2297
+ #: lib/view/WpProQuiz_View_QuizEdit.php:862
2298
+ msgid ""
2299
+ "If this option is activated, all answers are numbered (only single and "
2300
+ "multiple choice)"
2301
+ msgstr ""
2302
+ "Jeśli ta opcja będzie włączona, wszystkie odpowiedzi będą ponumerowane "
2303
+ "(tylko pojedynczy lub wielokrotny wybór)"
2304
+
2305
+ #: lib/view/WpProQuiz_View_QuizEdit.php:875
2306
+ #: lib/view/WpProQuiz_View_QuizEdit.php:880
2307
+ msgid "Hide correct- and incorrect message"
2308
+ msgstr "Ukryj wiadomość o poprawnej i niepoprawnej odpowiedzi"
2309
+
2310
+ #: lib/view/WpProQuiz_View_QuizEdit.php:887
2311
+ msgid ""
2312
+ "If you enable this option, no correct- or incorrect message will be "
2313
+ "displayed."
2314
+ msgstr ""
2315
+ "Jeśli włączysz tę opcję, nie zostanie wyświetlona wiadomość o poprawnej lub "
2316
+ "niepoprawnej odpowiedzi."
2317
+
2318
+ #: lib/view/WpProQuiz_View_QuizEdit.php:900
2319
+ #: lib/view/WpProQuiz_View_QuizEdit.php:905
2320
+ msgid "Correct and incorrect answer mark"
2321
+ msgstr "Oznaczenie poprawnej i niepoprawnej odpowiedzi."
2322
+
2323
+ #: lib/view/WpProQuiz_View_QuizEdit.php:912
2324
+ msgid ""
2325
+ "If you enable this option, answers won't be color highlighted as correct or "
2326
+ "incorrect. "
2327
+ msgstr ""
2328
+ "Jeśli włączysz tę opcję, odpowiedzi nie będą podświetlane w odpowiednich "
2329
+ "kolorach (poprawna - zielony, niepoprawna - czerwony)."
2330
+
2331
+ #: lib/view/WpProQuiz_View_QuizEdit.php:925
2332
+ #: lib/view/WpProQuiz_View_QuizEdit.php:930
2333
+ msgid "Force user to answer each question"
2334
+ msgstr "Obowiązkowa odpowiedź na każde z pytań"
2335
+
2336
+ #: lib/view/WpProQuiz_View_QuizEdit.php:937
2337
+ msgid "If you enable this option, the user is forced to answer each question."
2338
+ msgstr ""
2339
+ "Jeśli włączysz tę opcję, użytkownicy będą zmuszeni do odpowiedzi na "
2340
+ "wszystkie pytania."
2341
+
2342
+ #: lib/view/WpProQuiz_View_QuizEdit.php:938
2343
+ msgid ""
2344
+ "If the option \"Question overview\" is activated, this notification will "
2345
+ "appear after end of the quiz, otherwise after each question."
2346
+ msgstr ""
2347
+ "Gdy opcja \"Przegląd pytań\" jest włączona, to powiadomienie będzie widoczne "
2348
+ "przy próbie ukończenia quizu, w przeciwnym razie, po każdym pytaniu."
2349
+
2350
+ #: lib/view/WpProQuiz_View_QuizEdit.php:945
2351
+ #: lib/view/WpProQuiz_View_QuizEdit.php:950
2352
+ msgid "Hide question position overview"
2353
+ msgstr "Ukryj pozycję pytania"
2354
+
2355
+ #: lib/view/WpProQuiz_View_QuizEdit.php:957
2356
+ msgid "If you enable this option, the question position overview is hidden."
2357
+ msgstr "Jeśli włączysz tę funkcję, pozycja pytania będzie ukryta."
2358
+
2359
+ #: lib/view/WpProQuiz_View_QuizEdit.php:970
2360
+ #: lib/view/WpProQuiz_View_QuizEdit.php:975
2361
+ msgid "Hide question numbering"
2362
+ msgstr "Ukryj numer pytania"
2363
+
2364
+ #: lib/view/WpProQuiz_View_QuizEdit.php:982
2365
+ msgid "If you enable this option, the question numbering is hidden."
2366
+ msgstr "Jeśli włączysz tę funkcję, numer pytania będzie ukryty."
2367
+
2368
+ #: lib/view/WpProQuiz_View_QuizEdit.php:995
2369
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1000
2370
+ msgid "Display category"
2371
+ msgstr "Wyświetl kategorię"
2372
+
2373
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1007
2374
+ msgid "If you enable this option, category will be displayed in the question."
2375
+ msgstr "Jeśli włączysz tę opcję, kategoria będzie widoczna przy pytaniach."
2376
+
2377
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1032
2378
+ msgid ""
2379
+ "The leaderboard allows users to enter results in public list and to share "
2380
+ "the result this way."
2381
+ msgstr ""
2382
+ "Tablica wyników, pozwala użytkownikom dodać ich wyniki do publicznej listy i "
2383
+ "udostępnić je w ten sposób."
2384
+
2385
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1035
2386
+ msgid "The leaderboard works independent from internal statistics function."
2387
+ msgstr "Tablica wyników działa niezależnie od wewnętrznych statystyk."
2388
+
2389
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1052
2390
+ msgid "Who can sign up to the list"
2391
+ msgstr "Kto może zostać dodany do listy."
2392
+
2393
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1068
2394
+ msgid ""
2395
+ "Not registered users have to enter name and e-mail (e-mail won't be "
2396
+ "displayed)"
2397
+ msgstr ""
2398
+ "Niezarejestrowani użytkownicy muszą wpisać nazwę i e-mail (e-mail nie będzie "
2399
+ "wyświetlany)"
2400
+
2401
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1074
2402
+ msgid "insert automatically"
2403
+ msgstr "dodaj automatycznie"
2404
+
2405
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1082
2406
+ msgid ""
2407
+ "If you enable this option, logged in users will be automatically entered "
2408
+ "into leaderboard"
2409
+ msgstr ""
2410
+ "Jeśli włączysz tę opcję, wyniki zalogowanych użytkowników będą automatycznie "
2411
+ "dodawane do tablicy wyników"
2412
+
2413
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1088
2414
+ msgid "display captcha"
2415
+ msgstr "wyświetlaj zabezpieczenie (captcha)"
2416
+
2417
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1096
2418
+ msgid ""
2419
+ "If you enable this option, additional captcha will be displayed for users "
2420
+ "who are not registered."
2421
+ msgstr ""
2422
+ "Jeśli włączysz tę opcję, zabezpieczenie (captcha) będzie wyświetlane dla "
2423
+ "użytkowników, którzy nie są zarejestrowani."
2424
+
2425
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1099
2426
+ msgid "This option requires additional plugin:"
2427
+ msgstr "Ta opcja wymaga następującego pluginu:"
2428
+
2429
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1104
2430
+ msgid "Plugin has been detected."
2431
+ msgstr "Plugin został wykryty."
2432
+
2433
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1108
2434
+ msgid "Plugin is not installed."
2435
+ msgstr "Plugin nie został zainstalowany."
2436
+
2437
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1116
2438
+ msgid "Sort list by"
2439
+ msgstr "Sortuj listę według"
2440
+
2441
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1135
2442
+ msgid "Users can apply multiple times"
2443
+ msgstr "Użytkownicy mogą dodać swoje wyniki kilka razy"
2444
+
2445
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1146
2446
+ msgid "User can apply after:"
2447
+ msgstr "Użytkownik kolejny wynik może dodać po "
2448
+
2449
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1148
2450
+ msgid "minute"
2451
+ msgstr "minutach"
2452
+
2453
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1155
2454
+ msgid "How many entries should be displayed"
2455
+ msgstr "Jak dużo wyników powinno zostać wyświetlonych"
2456
+
2457
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1161
2458
+ msgid "Entries"
2459
+ msgstr "Wyników"
2460
+
2461
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1168
2462
+ msgid "Automatically display leaderboard in quiz result"
2463
+ msgstr "Automatycznie wyświetlaj tablicę wyników w rezultacie quizu"
2464
+
2465
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1172
2466
+ msgid "Where should leaderboard be displayed:"
2467
+ msgstr "Gdzie powinna być wyświetlona tablica wyników:"
2468
+
2469
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1175
2470
+ msgid "don't display"
2471
+ msgstr "nie pokazuj"
2472
+
2473
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1179
2474
+ msgid "below the \"result text\""
2475
+ msgstr "pod tekstem o wynikach"
2476
+
2477
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1189
2478
+ msgid "in a button"
2479
+ msgstr "po kliknięciu przycisku"
2480
+
2481
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1210
2482
+ msgid "Quiz-Mode"
2483
+ msgstr "Tryb Quizu"
2484
+
2485
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1215
2486
+ msgid "Normal"
2487
+ msgstr "Normalny"
2488
+
2489
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1216
2490
+ msgid "Normal + Back-Button"
2491
+ msgstr "Normalny + Przycisk \"wróć\""
2492
+
2493
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1217
2494
+ msgid "Check -> continue"
2495
+ msgstr "Sprawdź -> kontynuuj"
2496
+
2497
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1218
2498
+ msgid "Questions below each other"
2499
+ msgstr "Pytania jedno pod drugim"
2500
+
2501
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1230
2502
+ msgid ""
2503
+ "Displays all questions sequentially, \"right\" or \"false\" will be "
2504
+ "displayed at the end of the quiz."
2505
+ msgstr ""
2506
+ "Wyświetla wszystkie pytania po kolei, \"poprawne\" lub \"niepoprawne\" będą "
2507
+ "wyświetlone po zakończeniu quizu."
2508
+
2509
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1233
2510
+ msgid "Allows to use the back button in a question."
2511
+ msgstr "Pozwól na używanie przycisku \"wróć\" w pytaniach"
2512
+
2513
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1236
2514
+ msgid "Shows \"right or wrong\" after each question."
2515
+ msgstr "Pokaż poprawnie lub niepoprawnie po każdym pytaniu."
2516
+
2517
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1239
2518
+ msgid ""
2519
+ "If this option is activated, all answers are displayed below each other, i."
2520
+ "e. all questions are on a single page."
2521
+ msgstr ""
2522
+ "Jeśli ta opcja jest włączona, wszystkie pytania są wyświetlane jedno pod "
2523
+ "drugim, tj. wszystkie pytania są na jednej stronie."
2524
+
2525
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1281
2526
+ msgid "How many questions to be displayed on a page:"
2527
+ msgstr "Ile pytań ma być wyświetlane na stronie:"
2528
+
2529
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1284
2530
+ msgid "(0 = All on one page)"
2531
+ msgstr "(0 = Wszystkie na jednej stronie)"
2532
+
2533
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1306
2534
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1650
2535
+ #: lib/view/WpProQuiz_View_Statistics.php:41
2536
+ #: lib/view/WpProQuiz_View_Statistics.php:364
2537
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:538
2538
+ msgid "Custom fields"
2539
+ msgstr "Niestandardowe pola"
2540
+
2541
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1310
2542
+ msgid ""
2543
+ "You can create custom fields, e.g. to request the name or the e-mail address "
2544
+ "of the users."
2545
+ msgstr ""
2546
+ "Możesz stworzyć niestandardowe pola. Np. aby dowiedzieć się nazwy, adresu e-"
2547
+ "mail użytkowników"
2548
+
2549
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1313
2550
+ msgid "The statistic function have to be enabled."
2551
+ msgstr "Funkcja statystyk musi być włączona"
2552
+
2553
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1320
2554
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1325
2555
+ msgid "Custom fields enable"
2556
+ msgstr "Włączenie niestandardowych pól"
2557
+
2558
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1332
2559
+ msgid "If you enable this option, custom fields are enabled."
2560
+ msgstr "Jeśli włączysz tę funkcję, niestandardowe pola zostaną włączone"
2561
+
2562
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1339
2563
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1344
2564
+ msgid "Display position"
2565
+ msgstr "Gdzie wyświetlać"
2566
+
2567
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1346
2568
+ msgid "Where should the fileds be displayed:"
2569
+ msgstr "Gdzie powinny zostać wyświetlone niestandardowe pola:"
2570
+
2571
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1349
2572
+ msgid "On the quiz startpage"
2573
+ msgstr "Na stronie startowej quizu"
2574
+
2575
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1361
2576
+ msgid "At the end of the quiz (before the quiz result)"
2577
+ msgstr "Na zakończenie quizu (przed pokazaniem rezultatu)"
2578
+
2579
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1389
2580
+ msgid "Field name"
2581
+ msgstr "Nazwa pola"
2582
+
2583
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1391
2584
+ msgid "Required?"
2585
+ msgstr "Wymagane?"
2586
+
2587
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1393
2588
+ msgid "Show in statistic table?"
2589
+ msgstr "Pokazać w tabeli statystyk?"
2590
+
2591
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1423
2592
+ msgid "Text"
2593
+ msgstr "Krótki tekst"
2594
+
2595
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1424
2596
+ msgid "Textarea"
2597
+ msgstr "Pole tekstowe"
2598
+
2599
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1425
2600
+ msgid "Checkbox"
2601
+ msgstr "Pole typu checkbox"
2602
+
2603
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1426
2604
+ msgid "Drop-Down menu"
2605
+ msgstr ""
2606
+
2607
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1427
2608
+ msgid "Radio"
2609
+ msgstr "Pole typu radiobutton "
2610
+
2611
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1428
2612
+ msgid "Number"
2613
+ msgstr "Numer"
2614
+
2615
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1429
2616
+ msgid "Email"
2617
+ msgstr "Email"
2618
+
2619
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1430
2620
+ msgid "Yes/No"
2621
+ msgstr "Tak/Nie"
2622
+
2623
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1431
2624
+ #: lib/view/WpProQuiz_View_Statistics.php:323
2625
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:30
2626
+ msgid "Date"
2627
+ msgstr "Data"
2628
+
2629
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1434
2630
+ msgid "Edit list"
2631
+ msgstr "Edytuj listę"
2632
+
2633
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1437
2634
+ msgid "One entry per line"
2635
+ msgstr "Tylko jedna w każdej linii"
2636
+
2637
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1442
2638
+ msgid "OK"
2639
+ msgstr "OK"
2640
+
2641
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1464
2642
+ msgid "Add field"
2643
+ msgstr "Dodaj pole"
2644
+
2645
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1634
2646
+ msgid ""
2647
+ "If you enable this option, an email is sent with his quiz result to the user."
2648
+ msgstr ""
2649
+ "Jeśli włączysz tę opcję, email z wynikami zostanie wysłany do użytkownika"
2650
+
2651
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1646
2652
+ msgid "User Email-Address (only registered users)"
2653
+ msgstr "Adres email użytkownika (tylko zarejestrowani użytkownicy)"
2654
+
2655
+ #: lib/view/WpProQuiz_View_QuizEdit.php:1652
2656
+ msgid "(Type Email)"
2657
+ msgstr "(Typ email)"
2658
+
2659
+ #: lib/view/WpProQuiz_View_QuizOverall.php:269
2660
+ msgid "Quiz overview"
2661
+ msgstr "Podgląd quizu"
2662
+
2663
+ #: lib/view/WpProQuiz_View_QuizOverall.php:271
2664
+ #: lib/view/WpProQuiz_View_QuizOverall.php:306
2665
+ msgid "Add quiz"
2666
+ msgstr "Dodaj quiz"
2667
+
2668
+ #: lib/view/WpProQuiz_View_QuizOverall.php:286
2669
+ #: lib/view/WpProQuiz_View_WpqSupport.php:33
2670
+ msgid "Learn more"
2671
+ msgstr "Dowiedz się więcej"
2672
+
2673
+ #: lib/view/WpProQuiz_View_QuizOverall.php:354
2674
+ msgid "Import only *.wpq or *.xml files from known and trusted sources."
2675
+ msgstr "Importuje tylko pliki *.wpq lub *.xml ze znanego i zaufanego źródła."
2676
+
2677
+ #: lib/view/WpProQuiz_View_QuizOverall.php:362
2678
+ #, php-format
2679
+ msgid "Maximal %d MiB"
2680
+ msgstr "Maksymalnie %d MiB"
2681
+
2682
+ #: lib/view/WpProQuiz_View_QuizOverall.php:378
2683
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:90
2684
+ msgid "Export"
2685
+ msgstr "Eksportuj"
2686
+
2687
+ #: lib/view/WpProQuiz_View_QuizOverall.php:379
2688
+ msgid ""
2689
+ "Choose the respective question, which you would like to export and press on "
2690
+ "\"Start export\""
2691
+ msgstr ""
2692
+ "Wybierz odpowiednie pytanie, które chcesz wyeksportować i naciśnij "
2693
+ "\"Rozpocznij eksport\""
2694
+
2695
+ #: lib/view/WpProQuiz_View_QuizOverall.php:384
2696
+ msgid "Format:"
2697
+ msgstr "Format:"
2698
+
2699
+ #: lib/view/WpProQuiz_View_QuizOverall.php:385
2700
+ msgid "*.wpq"
2701
+ msgstr "*.wpq"
2702
+
2703
+ #: lib/view/WpProQuiz_View_QuizOverall.php:386
2704
+ msgid "or"
2705
+ msgstr "lub"
2706
+
2707
+ #: lib/view/WpProQuiz_View_QuizOverall.php:387
2708
+ msgid "*.xml"
2709
+ msgstr "*.xml"
2710
+
2711
+ #: lib/view/WpProQuiz_View_QuizOverall.php:389
2712
+ msgid "Start export"
2713
+ msgstr "Rozpocznij eksport"
2714
+
2715
+ #: lib/view/WpProQuiz_View_QuizOverall.php:403
2716
+ msgid "Set Quiz Categories"
2717
+ msgstr "Wybierz kategorię quizu"
2718
+
2719
+ #: lib/view/WpProQuiz_View_QuizOverall.php:404
2720
+ msgid "Sets multiple quiz categories "
2721
+ msgstr "Wybierz kilka kategorii quizu"
2722
+
2723
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:19
2724
+ msgid "Shortcode"
2725
+ msgstr "Shortcode"
2726
+
2727
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:20
2728
+ msgid "Shortcode-Leaderboard"
2729
+ msgstr "Shortcode-Tablica wyników "
2730
+
2731
+ #: lib/view/WpProQuiz_View_QuizOverallTable.php:72
2732
+ msgid "Preview"
2733
+ msgstr "Podgląd"
2734
+
2735
+ #: lib/view/WpProQuiz_View_Statistics.php:28
2736
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:56
2737
+ #, php-format
2738
+ msgid "Quiz: %s - Statistics"
2739
+ msgstr "Quiz: %s - Statystyki"
2740
+
2741
+ #: lib/view/WpProQuiz_View_Statistics.php:33
2742
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:61
2743
+ msgid "Stats not enabled"
2744
+ msgstr "Statystyki wyłączone"
2745
+
2746
+ #: lib/view/WpProQuiz_View_Statistics.php:34
2747
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:62
2748
+ msgid "Activate statistics"
2749
+ msgstr "Aktywuj statystyki"
2750
+
2751
+ #: lib/view/WpProQuiz_View_Statistics.php:39
2752
+ msgid "Users"
2753
+ msgstr "Użytkownicy"
2754
+
2755
+ #: lib/view/WpProQuiz_View_Statistics.php:40
2756
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:68
2757
+ msgid "Overview"
2758
+ msgstr "Przegląd"
2759
+
2760
+ #: lib/view/WpProQuiz_View_Statistics.php:68
2761
+ msgid "Please select user name:"
2762
+ msgstr "Proszę wybierz nazwę użytkownika:"
2763
+
2764
+ #: lib/view/WpProQuiz_View_Statistics.php:72
2765
+ msgid "Select a test:"
2766
+ msgstr "Wybierz test:"
2767
+
2768
+ #: lib/view/WpProQuiz_View_Statistics.php:82
2769
+ msgid "Anonymous user"
2770
+ msgstr "Anonimowy użytkownik"
2771
+
2772
+ #: lib/view/WpProQuiz_View_Statistics.php:91
2773
+ msgid "average"
2774
+ msgstr "średnio"
2775
+
2776
+ #: lib/view/WpProQuiz_View_Statistics.php:108
2777
+ #: lib/view/WpProQuiz_View_Statistics.php:243
2778
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:171
2779
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:607
2780
+ msgid "Hints used"
2781
+ msgstr "Użyte podpowiedzi"
2782
+
2783
+ #: lib/view/WpProQuiz_View_Statistics.php:109
2784
+ #: lib/view/WpProQuiz_View_Statistics.php:244
2785
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:173
2786
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:608
2787
+ msgid "Time"
2788
+ msgstr "Czas"
2789
+
2790
+ #: lib/view/WpProQuiz_View_Statistics.php:110
2791
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:174
2792
+ msgid "Points scored"
2793
+ msgstr "Zdobyte punkty"
2794
+
2795
+ #: lib/view/WpProQuiz_View_Statistics.php:148
2796
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:238
2797
+ msgid "Sub-Total: "
2798
+ msgstr "Łącznie w tej kategorii:"
2799
+
2800
+ #: lib/view/WpProQuiz_View_Statistics.php:169
2801
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:272
2802
+ msgid "Total"
2803
+ msgstr "Łącznie"
2804
+
2805
+ #: lib/view/WpProQuiz_View_Statistics.php:183
2806
+ #: lib/view/WpProQuiz_View_Statistics.php:268
2807
+ #: lib/view/WpProQuiz_View_Statistics.php:343
2808
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:287
2809
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:163
2810
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:247
2811
+ msgid "Refresh"
2812
+ msgstr "Odśwież"
2813
+
2814
+ #: lib/view/WpProQuiz_View_Statistics.php:187
2815
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:291
2816
+ msgid "Reset statistics"
2817
+ msgstr "Resetuj statystyki"
2818
+
2819
+ #: lib/view/WpProQuiz_View_Statistics.php:188
2820
+ msgid "Reset user statistics"
2821
+ msgstr "Resetuj statystyki użytkownika"
2822
+
2823
+ #: lib/view/WpProQuiz_View_Statistics.php:189
2824
+ #: lib/view/WpProQuiz_View_Statistics.php:270
2825
+ #: lib/view/WpProQuiz_View_Statistics.php:345
2826
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:165
2827
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:249
2828
+ msgid "Reset entire statistic"
2829
+ msgstr "Zresetuj wszystkie statystyki"
2830
+
2831
+ #: lib/view/WpProQuiz_View_Statistics.php:214
2832
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:206
2833
+ msgid "Show only users, who solved the quiz:"
2834
+ msgstr "Pokaż tylko użytkowników, którzy rozwiązali quiz:"
2835
+
2836
+ #: lib/view/WpProQuiz_View_Statistics.php:293
2837
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:99
2838
+ msgid "Which users should be displayed:"
2839
+ msgstr "Których użytkowników wyświetlić:"
2840
+
2841
+ #: lib/view/WpProQuiz_View_Statistics.php:295
2842
+ msgid "all"
2843
+ msgstr "wszyscy użytkownicy"
2844
+
2845
+ #: lib/view/WpProQuiz_View_Statistics.php:296
2846
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:103
2847
+ msgid "only registered users"
2848
+ msgstr "tylko zarejestrowani użytkownicy"
2849
+
2850
+ #: lib/view/WpProQuiz_View_Statistics.php:297
2851
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:104
2852
+ msgid "only anonymous users"
2853
+ msgstr "tylko anonimowi użytkownicy"
2854
+
2855
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:33
2856
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:172
2857
+ msgid "Solved"
2858
+ msgstr "Rozwiązane"
2859
+
2860
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:62
2861
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:244
2862
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:277
2863
+ #, php-format
2864
+ msgid "%d of %d"
2865
+ msgstr "%d na %d"
2866
+
2867
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:150
2868
+ #, php-format
2869
+ msgid "User statistics: %s"
2870
+ msgstr "Statystyki użytkownika: %s"
2871
+
2872
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:216
2873
+ msgid "yes"
2874
+ msgstr "tak"
2875
+
2876
+ #: lib/view/WpProQuiz_View_StatisticsAjax.php:216
2877
+ msgid "no"
2878
+ msgstr "nie"
2879
+
2880
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:67
2881
+ msgid "History"
2882
+ msgstr "Historia"
2883
+
2884
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:101
2885
+ msgid "special filter"
2886
+ msgstr "specjalny filtr"
2887
+
2888
+ #: lib/view/WpProQuiz_View_StatisticsNew.php:136
2889
+ #, php-format
2890
+ msgid "Search to date limit from %s to %s"
2891
+ msgstr "Szukaj wyników według daty. Od %s do %s"
2892
+
2893
+ #: lib/view/WpProQuiz_View_StyleManager.php:15
2894
+ msgid "Front"
2895
+ msgstr "Front"
2896
+
2897
+ #: lib/view/WpProQuiz_View_WpqSupport.php:8
2898
+ msgid "Support WP-Pro-Quiz"
2899
+ msgstr "Wsparcie WP-Pro-Quiz"
2900
+
2901
+ #: lib/view/WpProQuiz_View_WpqSupport.php:20
2902
+ msgid "WP-Pro-Quiz is small but nice free quiz plugin for WordPress."
2903
+ msgstr ""
2904
+ "WP-Pro-Quiz jest małym, ale ciekawym i darmowym pluginem służącym do "
2905
+ "tworzenia quizów dla WordPressa"
2906
+
2907
+ #: lib/view/WpProQuiz_View_WpqSupport.php:21
2908
+ msgid ""
2909
+ "I try to implement all wishes as fast as possible and help with problems."
2910
+ msgstr ""
2911
+ "Staram się wdrażać wszystkie prośby najszybciej jak to tylko możliwe i "
2912
+ "naprawiać problemy."
2913
+
2914
+ #: lib/view/WpProQuiz_View_WpqSupport.php:22
2915
+ msgid ""
2916
+ "Your donations can help to ensure that the project continues to remain free."
2917
+ msgstr "Twoje wsparcie może pomóc w tym, aby projekt nadal pozostał darmowy."
2918
+
2919
+ #: lib/view/WpProQuiz_View_WpqSupport.php:39
2920
+ msgid "Translate WP-Pro-Quiz"
2921
+ msgstr "Aby przetłumaczyć WP-Pro-Quiz"
2922
+
2923
+ #: lib/view/WpProQuiz_View_WpqSupport.php:41
2924
+ msgid "You need:"
2925
+ msgstr "Będziesz potrzebował:"
2926
+
2927
+ #: lib/view/WpProQuiz_View_WpqSupport.php:44
2928
+ msgid "Latest POT file"
2929
+ msgstr "Ostatni plik o rozszerzeniu POT"
2930
+
2931
+ #: lib/view/WpProQuiz_View_WpqSupport.php:49
2932
+ msgid "Open PoEdit"
2933
+ msgstr "Otwórz program PoEdit"
2934
+
2935
+ #: lib/view/WpProQuiz_View_WpqSupport.php:50
2936
+ msgid "File - New catalogue from POT file..."
2937
+ msgstr "Plik - Nowe tłumaczenie z pliku POT"
2938
+
2939
+ #: lib/view/WpProQuiz_View_WpqSupport.php:51
2940
+ msgid "Choose wp-pro-quiz.pot"
2941
+ msgstr "Wybierz wp-pro-quiz.pot"
2942
+
2943
+ #: lib/view/WpProQuiz_View_WpqSupport.php:52
2944
+ msgid "Set \"Translation properties\""
2945
+ msgstr "Ustaw szczegóły tłumaczenia"
2946
+
2947
+ #: lib/view/WpProQuiz_View_WpqSupport.php:53
2948
+ msgid "Save PO file - with the name \"wp-pro-qioz-de_DE.po\""
2949
+ msgstr "Zapisz plik PO pod nazwą \"wp-pro-quiz-pl_PL.po\" (pl - polska) "
2950
+
2951
+ #: lib/view/WpProQuiz_View_WpqSupport.php:55
2952
+ msgid "replace de_DE with your countries short code (e.g. en_US, nl_NL...)"
2953
+ msgstr "Zamień pl_PL ze skrótem swojego kraju (np. en_US, de_DE...)"
2954
+
2955
+ #: lib/view/WpProQuiz_View_WpqSupport.php:58
2956
+ msgid "Translate"
2957
+ msgstr "Przetłumacz"
2958
+
2959
+ #: lib/view/WpProQuiz_View_WpqSupport.php:60
2960
+ msgid ""
2961
+ "Upload generated *.mo file to your server, to /wp-content/plugins/wp-pro-"
2962
+ "quiz/languages"
2963
+ msgstr ""
2964
+ "Zapisz wygenerowany plik *.mo na swój serwer do pliku /wp-content/plugin/wp-"
2965
+ "pro-quiz/languages"
2966
+
2967
+ #: lib/view/WpProQuiz_View_WpqSupport.php:61
2968
+ msgid "Finished"
2969
+ msgstr "Zakończono"
2970
+
2971
+ #: lib/view/WpProQuiz_View_WpqSupport.php:65
2972
+ msgid ""
2973
+ "You can translate WP-Pro-Quiz from existing to existing language (e.g. "
2974
+ "english to english) e.g. to rename buttons."
2975
+ msgstr ""
2976
+ "Możesz również przetłumaczyć WP-Pro-Quiz w celu zmiany aktualnych fraz w "
2977
+ "języku, którego używasz (z polskiego na polski)."
languages/wp-pro-quiz-pt_BR.mo CHANGED
Binary file
languages/wp-pro-quiz-pt_BR.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:53+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:54+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Gabriel Vinicios <contato@gvensino.com.br>\n"
8
  "Language: pt_BR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:27+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:28+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Gabriel Vinicios <contato@gvensino.com.br>\n"
8
  "Language: pt_BR\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-ru_RU.mo CHANGED
Binary file
languages/wp-pro-quiz-ru_RU.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:54+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:54+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Sergei Bondarenko\n"
8
  "Language: ru\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:28+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:28+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Sergei Bondarenko\n"
8
  "Language: ru\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-sk_SK.mo CHANGED
Binary file
languages/wp-pro-quiz-sk_SK.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz Slovak\n"
4
- "POT-Creation-Date: 2015-04-24 09:54+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:54+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Petr Štěpán <p.stepan@vlastenci.cz>\n"
8
  "Language: sk_SK\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz Slovak\n"
4
+ "POT-Creation-Date: 2015-08-30 10:28+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:28+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: Petr Štěpán <p.stepan@vlastenci.cz>\n"
8
  "Language: sk_SK\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
languages/wp-pro-quiz-sv_SE.mo CHANGED
Binary file
languages/wp-pro-quiz-sv_SE.po CHANGED
@@ -1,17 +1,18 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:54+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:54+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: abuhassan <sajja2002@hotmail.com>\n"
8
  "Language: ar\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:28+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:28+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: abuhassan <sajja2002@hotmail.com>\n"
8
  "Language: ar\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-tr_TR.mo CHANGED
Binary file
languages/wp-pro-quiz-tr_TR.po CHANGED
@@ -1,17 +1,19 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:54+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:54+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
- "Language-Team: Julius Fischer\n"
8
- "Language: de\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:29+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:29+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
+ "Language-Team: \n"
8
+ "Language: tr\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "Plural-Forms: nplurals=1; plural=0;\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz-zh_TW.mo CHANGED
Binary file
languages/wp-pro-quiz-zh_TW.po CHANGED
@@ -1,17 +1,19 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:54+0100\n"
5
- "PO-Revision-Date: 2015-04-24 09:54+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: 新竹市立茄苳國小 <dinno0307@gmail.com>\n"
8
  "Language: zh_TW\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
 
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2015-08-30 10:30+0200\n"
5
+ "PO-Revision-Date: 2015-08-30 10:30+0200\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
  "Language-Team: 新竹市立茄苳國小 <dinno0307@gmail.com>\n"
8
  "Language: zh_TW\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "Plural-Forms: nplurals=1; plural=0;\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
languages/wp-pro-quiz.pot CHANGED
@@ -1,16 +1,18 @@
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Pro-Quiz\n"
4
- "POT-Creation-Date: 2015-04-24 09:55+0100\n"
5
  "PO-Revision-Date: 2015-04-24 09:55+0100\n"
6
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
7
- "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.6.4\n"
12
  "X-Poedit-KeywordsList: __;_e\n"
13
  "X-Poedit-Basepath: ..\n"
 
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
1
+ #, fuzzy
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WP-Pro-Quiz\n"
5
+ "POT-Creation-Date: 2015-08-30 10:30+0200\n"
6
  "PO-Revision-Date: 2015-04-24 09:55+0100\n"
7
  "Last-Translator: Julius Fischer <webmaster@it-gecko.de>\n"
8
+ "Language-Team: Julius Fischer <wp-pro-quiz@it-gecko.de>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.4\n"
13
  "X-Poedit-KeywordsList: __;_e\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
  #: lib/controller/WpProQuiz_Controller_Admin.php:109
lib/controller/WpProQuiz_Controller_Admin.php CHANGED
@@ -1,276 +1,203 @@
1
- <?php
2
- class WpProQuiz_Controller_Admin {
3
-
4
- protected $_ajax;
5
-
6
- public function __construct() {
7
-
8
- $this->_ajax = new WpProQuiz_Controller_Ajax();
9
-
10
- $this->_ajax->init();
11
-
12
- //deprecated - use WpProQuiz_Controller_Ajax
13
- add_action('wp_ajax_wp_pro_quiz_update_sort', array($this, 'updateSort'));
14
- add_action('wp_ajax_wp_pro_quiz_load_question', array($this, 'updateSort'));
15
-
16
- add_action('wp_ajax_wp_pro_quiz_reset_lock', array($this, 'resetLock'));
17
-
18
- add_action('wp_ajax_wp_pro_quiz_load_toplist', array($this, 'adminToplist'));
19
-
20
- add_action('wp_ajax_wp_pro_quiz_completed_quiz', array($this, 'completedQuiz'));
21
- add_action('wp_ajax_nopriv_wp_pro_quiz_completed_quiz', array($this, 'completedQuiz'));
22
-
23
- add_action('wp_ajax_wp_pro_quiz_check_lock', array($this, 'quizCheckLock'));
24
- add_action('wp_ajax_nopriv_wp_pro_quiz_check_lock', array($this, 'quizCheckLock'));
25
-
26
- //0.19
27
- add_action('wp_ajax_wp_pro_quiz_add_toplist', array($this, 'addInToplist'));
28
- add_action('wp_ajax_nopriv_wp_pro_quiz_add_toplist', array($this, 'addInToplist'));
29
-
30
- add_action('wp_ajax_wp_pro_quiz_show_front_toplist', array($this, 'showFrontToplist'));
31
- add_action('wp_ajax_nopriv_wp_pro_quiz_show_front_toplist', array($this, 'showFrontToplist'));
32
-
33
- add_action('wp_ajax_wp_pro_quiz_load_quiz_data', array($this, 'loadQuizData'));
34
- add_action('wp_ajax_nopriv_wp_pro_quiz_load_quiz_data', array($this, 'loadQuizData'));
35
-
36
-
37
- add_action('admin_menu', array($this, 'register_page'));
38
-
39
- add_filter('set-screen-option', array($this, 'setScreenOption'), 10, 3);
40
- }
41
-
42
- public function setScreenOption($status, $option, $value) {
43
- if ( in_array($option, array('wp_pro_quiz_quiz_overview_per_page', 'wp_pro_quiz_question_overview_per_page')))
44
- return $value;
45
-
46
- return $status;
47
- }
48
-
49
- public function loadQuizData() {
50
- $q = new WpProQuiz_Controller_Quiz();
51
-
52
- echo json_encode($q->loadQuizData());
53
-
54
- exit;
55
- }
56
-
57
- public function adminToplist() {
58
- $t = new WpProQuiz_Controller_Toplist();
59
- $t->route();
60
-
61
- exit;
62
- }
63
-
64
- public function showFrontToplist() {
65
- $t = new WpProQuiz_Controller_Toplist();
66
-
67
- $t->showFrontToplist();
68
-
69
- exit;
70
- }
71
-
72
- public function addInToplist() {
73
- $t = new WpProQuiz_Controller_Toplist();
74
-
75
- $t->addInToplist();
76
-
77
- exit;
78
- }
79
-
80
- public function resetLock() {
81
- $c = new WpProQuiz_Controller_Quiz();
82
- $c->route();
83
- }
84
-
85
- public function quizCheckLock() {
86
- $quizController = new WpProQuiz_Controller_Quiz();
87
-
88
- echo json_encode($quizController->isLockQuiz($_POST['quizId']));
89
-
90
- exit;
91
- }
92
-
93
- public function updateSort() {
94
- $c = new WpProQuiz_Controller_Question();
95
- $c->route();
96
- }
97
-
98
- public function completedQuiz() {
99
- $quiz = new WpProQuiz_Controller_Quiz();
100
- $quiz->completedQuiz();
101
- }
102
-
103
- private function localizeScript() {
104
- global $wp_locale;
105
-
106
- $isRtl = isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false;
107
-
108
- $translation_array = array(
109
- 'delete_msg' => __('Do you really want to delete the quiz/question?', 'wp-pro-quiz'),
110
- 'no_title_msg' => __('Title is not filled!', 'wp-pro-quiz'),
111
- 'no_question_msg' => __('No question deposited!', 'wp-pro-quiz'),
112
- 'no_correct_msg' => __('Correct answer was not selected!', 'wp-pro-quiz'),
113
- 'no_answer_msg' => __('No answer deposited!', 'wp-pro-quiz'),
114
- 'no_quiz_start_msg' => __('No quiz description filled!', 'wp-pro-quiz'),
115
- 'fail_grade_result' => __('The percent values in result text are incorrect.', 'wp-pro-quiz'),
116
- 'no_nummber_points' => __('No number in the field "Points" or less than 1', 'wp-pro-quiz'),
117
- 'no_nummber_points_new' => __('No number in the field "Points" or less than 0', 'wp-pro-quiz'),
118
- 'no_selected_quiz' => __('No quiz selected', 'wp-pro-quiz'),
119
- 'reset_statistics_msg' => __('Do you really want to reset the statistic?', 'wp-pro-quiz'),
120
- 'no_data_available' => __('No data available', 'wp-pro-quiz'),
121
- 'no_sort_element_criterion' => __('No sort element in the criterion', 'wp-pro-quiz'),
122
- 'dif_points' => __('"Different points for every answer" is not possible at "Free" choice', 'wp-pro-quiz'),
123
- 'category_no_name' => __('You must specify a name.', 'wp-pro-quiz'),
124
- 'confirm_delete_entry' => __('This entry should really be deleted?', 'wp-pro-quiz'),
125
- 'not_all_fields_completed' => __('Not all fields completed.', 'wp-pro-quiz'),
126
- 'temploate_no_name' => __('You must specify a template name.', 'wp-pro-quiz'),
127
-
128
-
129
- 'closeText' => __('Close', 'wp-pro-quiz'),
130
- 'currentText' => __('Today', 'wp-pro-quiz'),
131
- 'monthNames' => array_values($wp_locale->month),
132
- 'monthNamesShort' => array_values($wp_locale->month_abbrev),
133
- 'dayNames' => array_values($wp_locale->weekday),
134
- 'dayNamesShort' => array_values($wp_locale->weekday_abbrev),
135
- 'dayNamesMin' => array_values($wp_locale->weekday_initial),
136
- // 'dateFormat' => WpProQuiz_Helper_Until::convertPHPDateFormatToJS(get_option('date_format', 'm/d/Y')),
137
- //e.g. "9 de setembro de 2014" -> change to "hard" dateformat
138
- 'dateFormat' => 'mm/dd/yy',
139
- 'firstDay' => get_option('start_of_week'),
140
- 'isRTL' => $isRtl
141
- );
142
-
143
-
144
-
145
-
146
- wp_localize_script('wpProQuiz_admin_javascript', 'wpProQuizLocalize', $translation_array);
147
- }
148
-
149
- public function enqueueScript() {
150
- wp_enqueue_script(
151
- 'wpProQuiz_admin_javascript',
152
- plugins_url('js/wpProQuiz_admin'.(WPPROQUIZ_DEV ? '' : '.min').'.js', WPPROQUIZ_FILE),
153
- array('jquery', 'jquery-ui-sortable', 'jquery-ui-datepicker'),
154
- WPPROQUIZ_VERSION
155
- );
156
-
157
- wp_enqueue_style('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
158
-
159
- $this->localizeScript();
160
- }
161
-
162
- public function register_page() {
163
- $pages = array();
164
-
165
- $pages[] = add_menu_page(
166
- 'WP-Pro-Quiz',
167
- 'WP-Pro-Quiz',
168
- 'wpProQuiz_show',
169
- 'wpProQuiz',
170
- array($this, 'route'));
171
-
172
-
173
- $pages[] = add_submenu_page(
174
- 'wpProQuiz',
175
- __( 'Global settings', 'wp-pro-quiz' ),
176
- __( 'Global settings', 'wp-pro-quiz' ),
177
- 'wpProQuiz_change_settings',
178
- 'wpProQuiz_globalSettings',
179
- array( $this, 'route' ) );
180
-
181
- $pages[] = add_submenu_page(
182
- 'wpProQuiz',
183
- __( 'Support & More', 'wp-pro-quiz' ),
184
- __( 'Support & More', 'wp-pro-quiz' ),
185
- 'wpProQuiz_show',
186
- 'wpProQuiz_wpq_support',
187
- array( $this, 'route' ) );
188
-
189
- foreach($pages as $p) {
190
- add_action('admin_print_scripts-'.$p, array($this, 'enqueueScript'));
191
- add_action('load-'.$p, array($this, 'routeLoadAction'));
192
- }
193
- }
194
-
195
- public function routeLoadAction() {
196
- $screen = get_current_screen();
197
-
198
- if(!empty($screen)) {
199
- // Workaround for wp_ajax_hidden_columns() with sanitize_key()
200
- $name = strtolower($screen->id);
201
-
202
- if(!empty($_GET['module']))
203
- $name .= '_'.strtolower($_GET['module']);
204
-
205
- set_current_screen($name);
206
-
207
- $screen = get_current_screen();
208
- }
209
-
210
- $helperView = new WpProQuiz_View_GlobalHelperTabs();
211
-
212
- $screen->add_help_tab($helperView->getHelperTab());
213
- $screen->set_help_sidebar($helperView->getHelperSidebar());
214
-
215
- $this->_route(true);
216
- }
217
-
218
- public function route() {
219
- $this->_route();
220
- }
221
-
222
- private function _route($routeAction = false) {
223
- $module = isset($_GET['module']) ? $_GET['module'] : 'overallView';
224
-
225
- if(isset($_GET['page'])) {
226
- if(preg_match('#wpProQuiz_(.+)#', trim($_GET['page']), $matches)) {
227
- $module = $matches[1];
228
- }
229
- }
230
-
231
- $c = null;
232
-
233
- switch ($module) {
234
- case 'overallView':
235
- $c = new WpProQuiz_Controller_Quiz();
236
- break;
237
- case 'question':
238
- $c = new WpProQuiz_Controller_Question();
239
- break;
240
- case 'preview':
241
- $c = new WpProQuiz_Controller_Preview();
242
- break;
243
- case 'statistics':
244
- $c = new WpProQuiz_Controller_Statistics();
245
- break;
246
- case 'importExport':
247
- $c = new WpProQuiz_Controller_ImportExport();
248
- break;
249
- case 'globalSettings':
250
- $c = new WpProQuiz_Controller_GlobalSettings();
251
- break;
252
- case 'styleManager':
253
- $c = new WpProQuiz_Controller_StyleManager();
254
- break;
255
- case 'toplist':
256
- $c = new WpProQuiz_Controller_Toplist();
257
- break;
258
- case 'wpq_support':
259
- $c = new WpProQuiz_Controller_WpqSupport();
260
- break;
261
- case 'info_adaptation':
262
- $c = new WpProQuiz_Controller_InfoAdaptation();
263
- break;
264
- }
265
-
266
- if($c !== null) {
267
- if($routeAction) {
268
- if(method_exists($c, 'routeAction')) {
269
- $c->routeAction();
270
- }
271
- } else {
272
- $c->route();
273
- }
274
- }
275
- }
276
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Admin
4
+ {
5
+
6
+ protected $_ajax;
7
+
8
+ public function __construct()
9
+ {
10
+
11
+ $this->_ajax = new WpProQuiz_Controller_Ajax();
12
+ $this->_ajax->init();
13
+
14
+ add_action('admin_menu', array($this, 'register_page'));
15
+
16
+ add_filter('set-screen-option', array($this, 'setScreenOption'), 10, 3);
17
+ }
18
+
19
+ public function setScreenOption($status, $option, $value)
20
+ {
21
+ if (in_array($option, array('wp_pro_quiz_quiz_overview_per_page', 'wp_pro_quiz_question_overview_per_page'))) {
22
+ return $value;
23
+ }
24
+
25
+ return $status;
26
+ }
27
+
28
+ private function localizeScript()
29
+ {
30
+ global $wp_locale;
31
+
32
+ $isRtl = isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false;
33
+
34
+ $translation_array = array(
35
+ 'delete_msg' => __('Do you really want to delete the quiz/question?', 'wp-pro-quiz'),
36
+ 'no_title_msg' => __('Title is not filled!', 'wp-pro-quiz'),
37
+ 'no_question_msg' => __('No question deposited!', 'wp-pro-quiz'),
38
+ 'no_correct_msg' => __('Correct answer was not selected!', 'wp-pro-quiz'),
39
+ 'no_answer_msg' => __('No answer deposited!', 'wp-pro-quiz'),
40
+ 'no_quiz_start_msg' => __('No quiz description filled!', 'wp-pro-quiz'),
41
+ 'fail_grade_result' => __('The percent values in result text are incorrect.', 'wp-pro-quiz'),
42
+ 'no_nummber_points' => __('No number in the field "Points" or less than 1', 'wp-pro-quiz'),
43
+ 'no_nummber_points_new' => __('No number in the field "Points" or less than 0', 'wp-pro-quiz'),
44
+ 'no_selected_quiz' => __('No quiz selected', 'wp-pro-quiz'),
45
+ 'reset_statistics_msg' => __('Do you really want to reset the statistic?', 'wp-pro-quiz'),
46
+ 'no_data_available' => __('No data available', 'wp-pro-quiz'),
47
+ 'no_sort_element_criterion' => __('No sort element in the criterion', 'wp-pro-quiz'),
48
+ 'dif_points' => __('"Different points for every answer" is not possible at "Free" choice', 'wp-pro-quiz'),
49
+ 'category_no_name' => __('You must specify a name.', 'wp-pro-quiz'),
50
+ 'confirm_delete_entry' => __('This entry should really be deleted?', 'wp-pro-quiz'),
51
+ 'not_all_fields_completed' => __('Not all fields completed.', 'wp-pro-quiz'),
52
+ 'temploate_no_name' => __('You must specify a template name.', 'wp-pro-quiz'),
53
+ 'closeText' => __('Close', 'wp-pro-quiz'),
54
+ 'currentText' => __('Today', 'wp-pro-quiz'),
55
+ 'monthNames' => array_values($wp_locale->month),
56
+ 'monthNamesShort' => array_values($wp_locale->month_abbrev),
57
+ 'dayNames' => array_values($wp_locale->weekday),
58
+ 'dayNamesShort' => array_values($wp_locale->weekday_abbrev),
59
+ 'dayNamesMin' => array_values($wp_locale->weekday_initial),
60
+ // 'dateFormat' => WpProQuiz_Helper_Until::convertPHPDateFormatToJS(get_option('date_format', 'm/d/Y')),
61
+ //e.g. "9 de setembro de 2014" -> change to "hard" dateformat
62
+ 'dateFormat' => 'mm/dd/yy',
63
+ 'firstDay' => get_option('start_of_week'),
64
+ 'isRTL' => $isRtl
65
+ );
66
+
67
+ wp_localize_script('wpProQuiz_admin_javascript', 'wpProQuizLocalize', $translation_array);
68
+ }
69
+
70
+ public function enqueueScript()
71
+ {
72
+ wp_enqueue_script(
73
+ 'wpProQuiz_admin_javascript',
74
+ plugins_url('js/wpProQuiz_admin' . (WPPROQUIZ_DEV ? '' : '.min') . '.js', WPPROQUIZ_FILE),
75
+ array('jquery', 'jquery-ui-sortable', 'jquery-ui-datepicker'),
76
+ WPPROQUIZ_VERSION
77
+ );
78
+
79
+ wp_enqueue_style('jquery-ui',
80
+ 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
81
+
82
+ $this->localizeScript();
83
+ }
84
+
85
+ public function register_page()
86
+ {
87
+ $pages = array();
88
+
89
+ $pages[] = add_menu_page(
90
+ 'WP-Pro-Quiz',
91
+ 'WP-Pro-Quiz',
92
+ 'wpProQuiz_show',
93
+ 'wpProQuiz',
94
+ array($this, 'route'));
95
+
96
+ $pages[] = add_submenu_page(
97
+ 'wpProQuiz',
98
+ __('Global settings', 'wp-pro-quiz'),
99
+ __('Global settings', 'wp-pro-quiz'),
100
+ 'wpProQuiz_change_settings',
101
+ 'wpProQuiz_glSettings',
102
+ array($this, 'route'));
103
+
104
+ $pages[] = add_submenu_page(
105
+ 'wpProQuiz',
106
+ __('Support & More', 'wp-pro-quiz'),
107
+ __('Support & More', 'wp-pro-quiz'),
108
+ 'wpProQuiz_show',
109
+ 'wpProQuiz_wpq_support',
110
+ array($this, 'route'));
111
+
112
+ foreach ($pages as $p) {
113
+ add_action('admin_print_scripts-' . $p, array($this, 'enqueueScript'));
114
+ add_action('load-' . $p, array($this, 'routeLoadAction'));
115
+ }
116
+ }
117
+
118
+ public function routeLoadAction()
119
+ {
120
+ $screen = get_current_screen();
121
+
122
+ if (!empty($screen)) {
123
+ // Workaround for wp_ajax_hidden_columns() with sanitize_key()
124
+ $name = strtolower($screen->id);
125
+
126
+ if (!empty($_GET['module'])) {
127
+ $name .= '_' . strtolower($_GET['module']);
128
+ }
129
+
130
+ set_current_screen($name);
131
+
132
+ $screen = get_current_screen();
133
+ }
134
+
135
+ $helperView = new WpProQuiz_View_GlobalHelperTabs();
136
+
137
+ $screen->add_help_tab($helperView->getHelperTab());
138
+ $screen->set_help_sidebar($helperView->getHelperSidebar());
139
+
140
+ $this->_route(true);
141
+ }
142
+
143
+ public function route()
144
+ {
145
+ $this->_route();
146
+ }
147
+
148
+ private function _route($routeAction = false)
149
+ {
150
+ $module = isset($_GET['module']) ? $_GET['module'] : 'overallView';
151
+
152
+ if (isset($_GET['page'])) {
153
+ if (preg_match('#wpProQuiz_(.+)#', trim($_GET['page']), $matches)) {
154
+ $module = $matches[1];
155
+ }
156
+ }
157
+
158
+ $c = null;
159
+
160
+ switch ($module) {
161
+ case 'overallView':
162
+ $c = new WpProQuiz_Controller_Quiz();
163
+ break;
164
+ case 'question':
165
+ $c = new WpProQuiz_Controller_Question();
166
+ break;
167
+ case 'preview':
168
+ $c = new WpProQuiz_Controller_Preview();
169
+ break;
170
+ case 'statistics':
171
+ $c = new WpProQuiz_Controller_Statistics();
172
+ break;
173
+ case 'importExport':
174
+ $c = new WpProQuiz_Controller_ImportExport();
175
+ break;
176
+ case 'glSettings':
177
+ $c = new WpProQuiz_Controller_GlobalSettings();
178
+ break;
179
+ case 'styleManager':
180
+ $c = new WpProQuiz_Controller_StyleManager();
181
+ break;
182
+ case 'toplist':
183
+ $c = new WpProQuiz_Controller_Toplist();
184
+ break;
185
+ case 'wpq_support':
186
+ $c = new WpProQuiz_Controller_WpqSupport();
187
+ break;
188
+ case 'info_adaptation':
189
+ $c = new WpProQuiz_Controller_InfoAdaptation();
190
+ break;
191
+ }
192
+
193
+ if ($c !== null) {
194
+ if ($routeAction) {
195
+ if (method_exists($c, 'routeAction')) {
196
+ $c->routeAction();
197
+ }
198
+ } else {
199
+ $c->route();
200
+ }
201
+ }
202
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
lib/controller/WpProQuiz_Controller_Ajax.php CHANGED
@@ -1,74 +1,87 @@
1
- <?php
2
- /**
3
- * @since 0.23
4
- */
5
- class WpProQuiz_Controller_Ajax {
6
-
7
- private $_adminCallbacks = array();
8
- private $_frontCallbacks = array();
9
-
10
- public function init() {
11
- $this->initCallbacks();
12
-
13
- add_action('wp_ajax_wp_pro_quiz_admin_ajax', array($this, 'adminAjaxCallback'));
14
- add_action('wp_ajax_nopriv_wp_pro_quiz_admin_ajax', array($this, 'frontAjaxCallback'));
15
- }
16
-
17
- public function adminAjaxCallback() {
18
- $this->ajaxCallbackHandler(true);
19
- }
20
-
21
- public function frontAjaxCallback() {
22
- $this->ajaxCallbackHandler(false);
23
- }
24
-
25
- private function ajaxCallbackHandler($admin) {
26
- $func = isset($_POST['func']) ? $_POST['func'] : '';
27
- $data = isset($_POST['data']) ? $_POST['data'] : null;
28
- $calls = $admin ? $this->_adminCallbacks : $this->_frontCallbacks;
29
-
30
- if(isset($calls[$func])) {
31
- $r = call_user_func($calls[$func], $data, $func);
32
-
33
- if($r !== null)
34
- echo $r;
35
- }
36
-
37
- exit;
38
- }
39
-
40
- private function initCallbacks() {
41
- $this->_adminCallbacks = array(
42
- 'categoryAdd' => array('WpProQuiz_Controller_Category', 'ajaxAddCategory'),
43
- 'categoryDelete' => array('WpProQuiz_Controller_Category', 'ajaxDeleteCategory'),
44
- 'categoryEdit' => array('WpProQuiz_Controller_Category', 'ajaxEditCategory'),
45
-
46
- 'statisticLoad' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadStatistic'), /** @deprecated **/
47
- 'statisticLoadOverview' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadStatsticOverview'), /** @deprecated **/
48
- 'statisticReset' => array('WpProQuiz_Controller_Statistics', 'ajaxReset'), /** @deprecated **/
49
- 'statisticLoadFormOverview' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadFormOverview'), /** @deprecated **/
50
-
51
- 'statisticLoadHistory' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadHistory'),
52
- 'statisticLoadUser' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadStatisticUser'),
53
- 'statisticResetNew' => array('WpProQuiz_Controller_Statistics', 'ajaxRestStatistic'),
54
- 'statisticLoadOverviewNew' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadStatsticOverviewNew'),
55
-
56
- 'templateEdit' => array('WpProQuiz_Controller_Template', 'ajaxEditTemplate'),
57
- 'templateDelete' => array('WpProQuiz_Controller_Template', 'ajaxDeleteTemplate'),
58
-
59
- 'quizLoadData' => array('WpProQuiz_Controller_Front', 'ajaxQuizLoadData'),
60
-
61
- 'setQuizMultipleCategories' => array('WpProQuiz_Controller_Quiz', 'ajaxSetQuizMultipleCategories'),
62
- 'setQuestionMultipleCategories' => array('WpProQuiz_Controller_Question', 'ajaxSetQuestionMultipleCategories'),
63
-
64
- 'loadQuestionsSort' => array('WpProQuiz_Controller_Question', 'ajaxLoadQuestionsSort'),
65
- 'questionSaveSort' => array('WpProQuiz_Controller_Question', 'ajaxSaveSort'),
66
- 'questionaLoadCopyQuestion' => array('WpProQuiz_Controller_Question', 'ajaxLoadCopyQuestion')
67
- );
68
-
69
- //nopriv
70
- $this->_frontCallbacks = array(
71
- 'quizLoadData' => array('WpProQuiz_Controller_Front', 'ajaxQuizLoadData')
72
- );
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
1
+ <?php
2
+
3
+ /**
4
+ * @since 0.23
5
+ */
6
+ class WpProQuiz_Controller_Ajax
7
+ {
8
+
9
+ private $_adminCallbacks = array();
10
+ private $_frontCallbacks = array();
11
+
12
+ public function init()
13
+ {
14
+ $this->initCallbacks();
15
+
16
+ add_action('wp_ajax_wp_pro_quiz_admin_ajax', array($this, 'adminAjaxCallback'));
17
+ add_action('wp_ajax_nopriv_wp_pro_quiz_admin_ajax', array($this, 'frontAjaxCallback'));
18
+ }
19
+
20
+ public function adminAjaxCallback()
21
+ {
22
+ $this->ajaxCallbackHandler(true);
23
+ }
24
+
25
+ public function frontAjaxCallback()
26
+ {
27
+ $this->ajaxCallbackHandler(false);
28
+ }
29
+
30
+ private function ajaxCallbackHandler($admin)
31
+ {
32
+ $func = isset($_POST['func']) ? $_POST['func'] : '';
33
+ $data = isset($_POST['data']) ? $_POST['data'] : null;
34
+ $calls = $admin ? $this->_adminCallbacks : $this->_frontCallbacks;
35
+
36
+ if (isset($calls[$func])) {
37
+ $r = call_user_func($calls[$func], $data, $func);
38
+
39
+ if ($r !== null) {
40
+ echo $r;
41
+ }
42
+ }
43
+
44
+ exit;
45
+ }
46
+
47
+ private function initCallbacks()
48
+ {
49
+ $this->_adminCallbacks = array(
50
+ 'categoryAdd' => array('WpProQuiz_Controller_Category', 'ajaxAddCategory'),
51
+ 'categoryDelete' => array('WpProQuiz_Controller_Category', 'ajaxDeleteCategory'),
52
+ 'categoryEdit' => array('WpProQuiz_Controller_Category', 'ajaxEditCategory'),
53
+ 'statisticLoadHistory' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadHistory'),
54
+ 'statisticLoadUser' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadStatisticUser'),
55
+ 'statisticResetNew' => array('WpProQuiz_Controller_Statistics', 'ajaxRestStatistic'),
56
+ 'statisticLoadOverviewNew' => array('WpProQuiz_Controller_Statistics', 'ajaxLoadStatsticOverviewNew'),
57
+ 'templateEdit' => array('WpProQuiz_Controller_Template', 'ajaxEditTemplate'),
58
+ 'templateDelete' => array('WpProQuiz_Controller_Template', 'ajaxDeleteTemplate'),
59
+ 'quizLoadData' => array('WpProQuiz_Controller_Front', 'ajaxQuizLoadData'),
60
+ 'setQuizMultipleCategories' => array('WpProQuiz_Controller_Quiz', 'ajaxSetQuizMultipleCategories'),
61
+ 'setQuestionMultipleCategories' => array(
62
+ 'WpProQuiz_Controller_Question',
63
+ 'ajaxSetQuestionMultipleCategories'
64
+ ),
65
+ 'loadQuestionsSort' => array('WpProQuiz_Controller_Question', 'ajaxLoadQuestionsSort'),
66
+ 'questionSaveSort' => array('WpProQuiz_Controller_Question', 'ajaxSaveSort'),
67
+ 'questionaLoadCopyQuestion' => array('WpProQuiz_Controller_Question', 'ajaxLoadCopyQuestion'),
68
+ 'loadQuizData' => array('WpProQuiz_Controller_Quiz', 'ajaxLoadQuizData'),
69
+ 'resetLock' => array('WpProQuiz_Controller_Quiz', 'ajaxResetLock'),
70
+ 'adminToplist' => array('WpProQuiz_Controller_Toplist', 'ajaxAdminToplist'),
71
+ 'completedQuiz' => array('WpProQuiz_Controller_Quiz', 'ajaxCompletedQuiz'),
72
+ 'quizCheckLock' => array('WpProQuiz_Controller_Quiz', 'ajaxQuizCheckLock'),
73
+ 'addInToplist' => array('WpProQuiz_Controller_Toplist', 'ajaxAddInToplist'),
74
+ 'showFrontToplist' => array('WpProQuiz_Controller_Toplist', 'ajaxShowFrontToplist')
75
+ );
76
+
77
+ //nopriv
78
+ $this->_frontCallbacks = array(
79
+ 'quizLoadData' => array('WpProQuiz_Controller_Front', 'ajaxQuizLoadData'),
80
+ 'loadQuizData' => array('WpProQuiz_Controller_Quiz', 'ajaxLoadQuizData'),
81
+ 'completedQuiz' => array('WpProQuiz_Controller_Quiz', 'ajaxCompletedQuiz'),
82
+ 'quizCheckLock' => array('WpProQuiz_Controller_Quiz', 'ajaxQuizCheckLock'),
83
+ 'addInToplist' => array('WpProQuiz_Controller_Toplist', 'ajaxAddInToplist'),
84
+ 'showFrontToplist' => array('WpProQuiz_Controller_Toplist', 'ajaxShowFrontToplist')
85
+ );
86
+ }
87
  }
lib/controller/WpProQuiz_Controller_Category.php CHANGED
@@ -1,47 +1,53 @@
1
- <?php
2
- class WpProQuiz_Controller_Category {
3
-
4
- public static function ajaxAddCategory($data, $func) {
5
- if(!current_user_can('wpProQuiz_edit_quiz')) {
6
- return json_encode(array());
7
- }
8
-
9
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
10
-
11
- $category = new WpProQuiz_Model_Category($data);
12
-
13
- $categoryMapper->save($category);
14
-
15
- return json_encode(array('categoryId' => $category->getCategoryId(),
16
- 'categoryName' => $category->getCategoryName()
17
- ));
18
- }
19
-
20
- public static function ajaxEditCategory($data, $func) {
21
- if(!current_user_can('wpProQuiz_edit_quiz')) {
22
- return json_encode(array());
23
- }
24
-
25
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
26
-
27
- $category = new WpProQuiz_Model_Category($data);
28
-
29
- $categoryMapper->save($category);
30
-
31
- return json_encode(array());
32
- }
33
-
34
- public static function ajaxDeleteCategory($data, $func) {
35
- if(!current_user_can('wpProQuiz_edit_quiz')) {
36
- return json_encode(array());
37
- }
38
-
39
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
40
-
41
- $category = new WpProQuiz_Model_Category($data);
42
-
43
- $categoryMapper->delete($category->getCategoryId());
44
-
45
- return json_encode(array());
46
- }
 
 
 
 
 
 
47
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Category
4
+ {
5
+
6
+ public static function ajaxAddCategory($data)
7
+ {
8
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
9
+ return json_encode(array());
10
+ }
11
+
12
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
13
+
14
+ $category = new WpProQuiz_Model_Category($data);
15
+
16
+ $categoryMapper->save($category);
17
+
18
+ return json_encode(array(
19
+ 'categoryId' => $category->getCategoryId(),
20
+ 'categoryName' => $category->getCategoryName()
21
+ ));
22
+ }
23
+
24
+ public static function ajaxEditCategory($data)
25
+ {
26
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
27
+ return json_encode(array());
28
+ }
29
+
30
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
31
+
32
+ $category = new WpProQuiz_Model_Category($data);
33
+
34
+ $categoryMapper->save($category);
35
+
36
+ return json_encode(array());
37
+ }
38
+
39
+ public static function ajaxDeleteCategory($data)
40
+ {
41
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
42
+ return json_encode(array());
43
+ }
44
+
45
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
46
+
47
+ $category = new WpProQuiz_Model_Category($data);
48
+
49
+ $categoryMapper->delete($category->getCategoryId());
50
+
51
+ return json_encode(array());
52
+ }
53
  }
lib/controller/WpProQuiz_Controller_Controller.php CHANGED
@@ -1,18 +1,21 @@
1
- <?php
2
- class WpProQuiz_Controller_Controller {
3
- protected $_post = null;
4
- protected $_cookie = null;
5
-
6
- /**
7
- * @deprecated
8
- */
9
- public function __construct() {
10
- if($this->_post === null) {
11
- $this->_post = stripslashes_deep($_POST);
12
- }
13
-
14
- if($this->_cookie === null && $_COOKIE !== null) {
15
- $this->_cookie = stripslashes_deep($_COOKIE);
16
- }
17
- }
 
 
 
18
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Controller
4
+ {
5
+ protected $_post = null;
6
+ protected $_cookie = null;
7
+
8
+ /**
9
+ * @deprecated
10
+ */
11
+ public function __construct()
12
+ {
13
+ if ($this->_post === null) {
14
+ $this->_post = stripslashes_deep($_POST);
15
+ }
16
+
17
+ if ($this->_cookie === null && $_COOKIE !== null) {
18
+ $this->_cookie = stripslashes_deep($_COOKIE);
19
+ }
20
+ }
21
  }
lib/controller/WpProQuiz_Controller_Front.php CHANGED
@@ -1,242 +1,258 @@
1
- <?php
2
- class WpProQuiz_Controller_Front {
3
-
4
- /**
5
- * @var WpProQuiz_Model_GlobalSettings
6
- */
7
- private $_settings = null;
8
-
9
- public function __construct() {
10
- $this->loadSettings();
11
-
12
- add_action('wp_enqueue_scripts', array($this, 'loadDefaultScripts'));
13
- add_shortcode('WpProQuiz', array($this, 'shortcode'));
14
- add_shortcode('WpProQuiz_toplist', array($this, 'shortcodeToplist'));
15
- }
16
-
17
- public function loadDefaultScripts() {
18
- wp_enqueue_script('jquery');
19
-
20
- $data = array(
21
- 'src' => plugins_url('css/wpProQuiz_front'.(WPPROQUIZ_DEV ? '' : '.min').'.css', WPPROQUIZ_FILE),
22
- 'deps' => array(),
23
- 'ver' => WPPROQUIZ_VERSION,
24
- );
25
-
26
- $data = apply_filters('wpProQuiz_front_style', $data);
27
-
28
- wp_enqueue_style('wpProQuiz_front_style', $data['src'], $data['deps'], $data['ver']);
29
-
30
- if($this->_settings->isJsLoadInHead()) {
31
- $this->loadJsScripts(false, true, true);
32
- }
33
- }
34
-
35
- private function loadJsScripts($footer = true, $quiz = true, $toplist = false) {
36
- if($quiz) {
37
- wp_enqueue_script(
38
- 'wpProQuiz_front_javascript',
39
- plugins_url('js/wpProQuiz_front'.(WPPROQUIZ_DEV ? '' : '.min').'.js', WPPROQUIZ_FILE),
40
- array('jquery-ui-sortable'),
41
- WPPROQUIZ_VERSION,
42
- $footer
43
- );
44
-
45
- wp_localize_script('wpProQuiz_front_javascript', 'WpProQuizGlobal', array(
46
- 'ajaxurl' => admin_url('admin-ajax.php'),
47
- 'loadData' => __('Loading', 'wp-pro-quiz'),
48
- 'questionNotSolved' => __('You must answer this question.', 'wp-pro-quiz'),
49
- 'questionsNotSolved' => __('You must answer all questions before you can completed the quiz.', 'wp-pro-quiz'),
50
- 'fieldsNotFilled' => __('All fields have to be filled.', 'wp-pro-quiz')
51
- ));
52
- }
53
-
54
- if($toplist) {
55
- wp_enqueue_script(
56
- 'wpProQuiz_front_javascript_toplist',
57
- plugins_url('js/wpProQuiz_toplist'.(WPPROQUIZ_DEV ? '' : '.min').'.js', WPPROQUIZ_FILE),
58
- array('jquery-ui-sortable'),
59
- WPPROQUIZ_VERSION,
60
- $footer
61
- );
62
-
63
- if(!wp_script_is('wpProQuiz_front_javascript'))
64
- wp_localize_script('wpProQuiz_front_javascript_toplist', 'WpProQuizGlobal', array(
65
- 'ajaxurl' => admin_url('admin-ajax.php'),
66
- 'loadData' => __('Loading', 'wp-pro-quiz'),
67
- 'questionNotSolved' => __('You must answer this question.', 'wp-pro-quiz'),
68
- 'questionsNotSolved' => __('You must answer all questions before you can completed the quiz.', 'wp-pro-quiz'),
69
- 'fieldsNotFilled' => __('All fields have to be filled.', 'wp-pro-quiz')
70
- ));
71
- }
72
-
73
- if(!$this->_settings->isTouchLibraryDeactivate()) {
74
- wp_enqueue_script(
75
- 'jquery-ui-touch-punch',
76
- plugins_url('js/jquery.ui.touch-punch.min.js', WPPROQUIZ_FILE),
77
- array('jquery-ui-sortable'),
78
- '0.2.2',
79
- $footer
80
- );
81
- }
82
- }
83
-
84
- public function shortcode($attr) {
85
- $id = $attr[0];
86
- $content = '';
87
-
88
- if(!$this->_settings->isJsLoadInHead()) {
89
- $this->loadJsScripts();
90
- }
91
-
92
- if(is_numeric($id)) {
93
- ob_start();
94
-
95
- $this->handleShortCode($id);
96
-
97
- $content = ob_get_contents();
98
-
99
- ob_end_clean();
100
- }
101
-
102
- if($this->_settings->isAddRawShortcode()) {
103
- return '[raw]'.$content.'[/raw]';
104
- }
105
-
106
- return $content;
107
- }
108
-
109
- public function handleShortCode($id) {
110
- $view = new WpProQuiz_View_FrontQuiz();
111
-
112
- $quizMapper = new WpProQuiz_Model_QuizMapper();
113
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
114
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
115
- $formMapper = new WpProQuiz_Model_FormMapper();
116
-
117
- $quiz = $quizMapper->fetch($id);
118
-
119
- $maxQuestion = false;
120
-
121
- if($quiz->isShowMaxQuestion() && $quiz->getShowMaxQuestionValue() > 0) {
122
-
123
- $value = $quiz->getShowMaxQuestionValue();
124
-
125
- if($quiz->isShowMaxQuestionPercent()) {
126
- $count = $questionMapper->count($id);
127
-
128
- $value = ceil($count * $value / 100);
129
- }
130
-
131
- $question = $questionMapper->fetchAll($id, true, $value);
132
- $maxQuestion = true;
133
-
134
- } else {
135
- $question = $questionMapper->fetchAll($id);
136
- }
137
-
138
- if(empty($quiz) || empty($question)) {
139
- echo '';
140
-
141
- return;
142
- }
143
-
144
- $view->quiz = $quiz;
145
- $view->question = $question;
146
- $view->category = $categoryMapper->fetchByQuiz($quiz->getId());
147
- $view->forms = $formMapper->fetch($quiz->getId());
148
-
149
- if($maxQuestion)
150
- $view->showMaxQuestion();
151
- else
152
- $view->show();
153
- }
154
-
155
- public function shortcodeToplist($attr) {
156
- $id = $attr[0];
157
- $content = '';
158
-
159
- if(!$this->_settings->isJsLoadInHead()) {
160
- $this->loadJsScripts(true, false, true);
161
- }
162
-
163
- if(is_numeric($id)) {
164
- ob_start();
165
-
166
- $this->handleShortCodeToplist($id, isset($attr['q']));
167
-
168
- $content = ob_get_contents();
169
-
170
- ob_end_clean();
171
- }
172
-
173
- if($this->_settings->isAddRawShortcode() && !isset($attr['q'])) {
174
- return '[raw]'.$content.'[/raw]';
175
- }
176
-
177
- return $content;
178
- }
179
-
180
- private function handleShortCodeToplist($quizId, $inQuiz = false) {
181
- $quizMapper = new WpProQuiz_Model_QuizMapper();
182
- $view = new WpProQuiz_View_FrontToplist();
183
-
184
- $quiz = $quizMapper->fetch($quizId);
185
-
186
- if($quiz->getId() <= 0 || !$quiz->isToplistActivated()) {
187
- echo '';
188
- return;
189
- }
190
-
191
- $view->quiz = $quiz;
192
- $view->points = $quizMapper->sumQuestionPoints($quizId);
193
- $view->inQuiz = $inQuiz;
194
- $view->show();
195
- }
196
-
197
- private function loadSettings() {
198
- $mapper = new WpProQuiz_Model_GlobalSettingsMapper();
199
-
200
- $this->_settings = $mapper->fetchAll();
201
- }
202
-
203
- public static function ajaxQuizLoadData($data, $func) {
204
- $id = $data['quizId'];
205
-
206
- $view = new WpProQuiz_View_FrontQuiz();
207
-
208
- $quizMapper = new WpProQuiz_Model_QuizMapper();
209
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
210
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
211
- $formMapper = new WpProQuiz_Model_FormMapper();
212
-
213
- $quiz = $quizMapper->fetch($id);
214
-
215
- if($quiz->isShowMaxQuestion() && $quiz->getShowMaxQuestionValue() > 0) {
216
-
217
- $value = $quiz->getShowMaxQuestionValue();
218
-
219
- if($quiz->isShowMaxQuestionPercent()) {
220
- $count = $questionMapper->count($id);
221
-
222
- $value = ceil($count * $value / 100);
223
- }
224
-
225
- $question = $questionMapper->fetchAll($id, true, $value);
226
-
227
- } else {
228
- $question = $questionMapper->fetchAll($id);
229
- }
230
-
231
- if(empty($quiz) || empty($question)) {
232
- return null;
233
- }
234
-
235
- $view->quiz = $quiz;
236
- $view->question = $question;
237
- $view->category = $categoryMapper->fetchByQuiz($quiz->getId());
238
- $view->forms = $formMapper->fetch($quiz->getId());
239
-
240
- return json_encode($view->getQuizData());
241
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Front
4
+ {
5
+
6
+ /**
7
+ * @var WpProQuiz_Model_GlobalSettings
8
+ */
9
+ private $_settings = null;
10
+
11
+ public function __construct()
12
+ {
13
+ $this->loadSettings();
14
+
15
+ add_action('wp_enqueue_scripts', array($this, 'loadDefaultScripts'));
16
+ add_shortcode('WpProQuiz', array($this, 'shortcode'));
17
+ add_shortcode('WpProQuiz_toplist', array($this, 'shortcodeToplist'));
18
+ }
19
+
20
+ public function loadDefaultScripts()
21
+ {
22
+ wp_enqueue_script('jquery');
23
+
24
+ $data = array(
25
+ 'src' => plugins_url('css/wpProQuiz_front' . (WPPROQUIZ_DEV ? '' : '.min') . '.css', WPPROQUIZ_FILE),
26
+ 'deps' => array(),
27
+ 'ver' => WPPROQUIZ_VERSION,
28
+ );
29
+
30
+ $data = apply_filters('wpProQuiz_front_style', $data);
31
+
32
+ wp_enqueue_style('wpProQuiz_front_style', $data['src'], $data['deps'], $data['ver']);
33
+
34
+ if ($this->_settings->isJsLoadInHead()) {
35
+ $this->loadJsScripts(false, true, true);
36
+ }
37
+ }
38
+
39
+ private function loadJsScripts($footer = true, $quiz = true, $toplist = false)
40
+ {
41
+ if ($quiz) {
42
+ wp_enqueue_script(
43
+ 'wpProQuiz_front_javascript',
44
+ plugins_url('js/wpProQuiz_front' . (WPPROQUIZ_DEV ? '' : '.min') . '.js', WPPROQUIZ_FILE),
45
+ array('jquery-ui-sortable'),
46
+ WPPROQUIZ_VERSION,
47
+ $footer
48
+ );
49
+
50
+ wp_localize_script('wpProQuiz_front_javascript', 'WpProQuizGlobal', array(
51
+ 'ajaxurl' => admin_url('admin-ajax.php'),
52
+ 'loadData' => __('Loading', 'wp-pro-quiz'),
53
+ 'questionNotSolved' => __('You must answer this question.', 'wp-pro-quiz'),
54
+ 'questionsNotSolved' => __('You must answer all questions before you can completed the quiz.',
55
+ 'wp-pro-quiz'),
56
+ 'fieldsNotFilled' => __('All fields have to be filled.', 'wp-pro-quiz')
57
+ ));
58
+ }
59
+
60
+ if ($toplist) {
61
+ wp_enqueue_script(
62
+ 'wpProQuiz_front_javascript_toplist',
63
+ plugins_url('js/wpProQuiz_toplist' . (WPPROQUIZ_DEV ? '' : '.min') . '.js', WPPROQUIZ_FILE),
64
+ array('jquery-ui-sortable'),
65
+ WPPROQUIZ_VERSION,
66
+ $footer
67
+ );
68
+
69
+ if (!wp_script_is('wpProQuiz_front_javascript')) {
70
+ wp_localize_script('wpProQuiz_front_javascript_toplist', 'WpProQuizGlobal', array(
71
+ 'ajaxurl' => admin_url('admin-ajax.php'),
72
+ 'loadData' => __('Loading', 'wp-pro-quiz'),
73
+ 'questionNotSolved' => __('You must answer this question.', 'wp-pro-quiz'),
74
+ 'questionsNotSolved' => __('You must answer all questions before you can completed the quiz.',
75
+ 'wp-pro-quiz'),
76
+ 'fieldsNotFilled' => __('All fields have to be filled.', 'wp-pro-quiz')
77
+ ));
78
+ }
79
+ }
80
+
81
+ if (!$this->_settings->isTouchLibraryDeactivate()) {
82
+ wp_enqueue_script(
83
+ 'jquery-ui-touch-punch',
84
+ plugins_url('js/jquery.ui.touch-punch.min.js', WPPROQUIZ_FILE),
85
+ array('jquery-ui-sortable'),
86
+ '0.2.2',
87
+ $footer
88
+ );
89
+ }
90
+ }
91
+
92
+ public function shortcode($attr)
93
+ {
94
+ $id = $attr[0];
95
+ $content = '';
96
+
97
+ if (!$this->_settings->isJsLoadInHead()) {
98
+ $this->loadJsScripts();
99
+ }
100
+
101
+ if (is_numeric($id)) {
102
+ ob_start();
103
+
104
+ $this->handleShortCode($id);
105
+
106
+ $content = ob_get_contents();
107
+
108
+ ob_end_clean();
109
+ }
110
+
111
+ if ($this->_settings->isAddRawShortcode()) {
112
+ return '[raw]' . $content . '[/raw]';
113
+ }
114
+
115
+ return $content;
116
+ }
117
+
118
+ public function handleShortCode($id)
119
+ {
120
+ $view = new WpProQuiz_View_FrontQuiz();
121
+
122
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
123
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
124
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
125
+ $formMapper = new WpProQuiz_Model_FormMapper();
126
+
127
+ $quiz = $quizMapper->fetch($id);
128
+
129
+ $maxQuestion = false;
130
+
131
+ if ($quiz->isShowMaxQuestion() && $quiz->getShowMaxQuestionValue() > 0) {
132
+
133
+ $value = $quiz->getShowMaxQuestionValue();
134
+
135
+ if ($quiz->isShowMaxQuestionPercent()) {
136
+ $count = $questionMapper->count($id);
137
+
138
+ $value = ceil($count * $value / 100);
139
+ }
140
+
141
+ $question = $questionMapper->fetchAll($id, true, $value);
142
+ $maxQuestion = true;
143
+
144
+ } else {
145
+ $question = $questionMapper->fetchAll($id);
146
+ }
147
+
148
+ if (empty($quiz) || empty($question)) {
149
+ echo '';
150
+
151
+ return;
152
+ }
153
+
154
+ $view->quiz = $quiz;
155
+ $view->question = $question;
156
+ $view->category = $categoryMapper->fetchByQuiz($quiz->getId());
157
+ $view->forms = $formMapper->fetch($quiz->getId());
158
+
159
+ if ($maxQuestion) {
160
+ $view->showMaxQuestion();
161
+ } else {
162
+ $view->show();
163
+ }
164
+ }
165
+
166
+ public function shortcodeToplist($attr)
167
+ {
168
+ $id = $attr[0];
169
+ $content = '';
170
+
171
+ if (!$this->_settings->isJsLoadInHead()) {
172
+ $this->loadJsScripts(true, false, true);
173
+ }
174
+
175
+ if (is_numeric($id)) {
176
+ ob_start();
177
+
178
+ $this->handleShortCodeToplist($id, isset($attr['q']));
179
+
180
+ $content = ob_get_contents();
181
+
182
+ ob_end_clean();
183
+ }
184
+
185
+ if ($this->_settings->isAddRawShortcode() && !isset($attr['q'])) {
186
+ return '[raw]' . $content . '[/raw]';
187
+ }
188
+
189
+ return $content;
190
+ }
191
+
192
+ private function handleShortCodeToplist($quizId, $inQuiz = false)
193
+ {
194
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
195
+ $view = new WpProQuiz_View_FrontToplist();
196
+
197
+ $quiz = $quizMapper->fetch($quizId);
198
+
199
+ if ($quiz->getId() <= 0 || !$quiz->isToplistActivated()) {
200
+ echo '';
201
+
202
+ return;
203
+ }
204
+
205
+ $view->quiz = $quiz;
206
+ $view->points = $quizMapper->sumQuestionPoints($quizId);
207
+ $view->inQuiz = $inQuiz;
208
+ $view->show();
209
+ }
210
+
211
+ private function loadSettings()
212
+ {
213
+ $mapper = new WpProQuiz_Model_GlobalSettingsMapper();
214
+
215
+ $this->_settings = $mapper->fetchAll();
216
+ }
217
+
218
+ public static function ajaxQuizLoadData($data)
219
+ {
220
+ $id = $data['quizId'];
221
+
222
+ $view = new WpProQuiz_View_FrontQuiz();
223
+
224
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
225
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
226
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
227
+ $formMapper = new WpProQuiz_Model_FormMapper();
228
+
229
+ $quiz = $quizMapper->fetch($id);
230
+
231
+ if ($quiz->isShowMaxQuestion() && $quiz->getShowMaxQuestionValue() > 0) {
232
+
233
+ $value = $quiz->getShowMaxQuestionValue();
234
+
235
+ if ($quiz->isShowMaxQuestionPercent()) {
236
+ $count = $questionMapper->count($id);
237
+
238
+ $value = ceil($count * $value / 100);
239
+ }
240
+
241
+ $question = $questionMapper->fetchAll($id, true, $value);
242
+
243
+ } else {
244
+ $question = $questionMapper->fetchAll($id);
245
+ }
246
+
247
+ if (empty($quiz) || empty($question)) {
248
+ return null;
249
+ }
250
+
251
+ $view->quiz = $quiz;
252
+ $view->question = $question;
253
+ $view->category = $categoryMapper->fetchByQuiz($quiz->getId());
254
+ $view->forms = $formMapper->fetch($quiz->getId());
255
+
256
+ return json_encode($view->getQuizData());
257
+ }
258
  }
lib/controller/WpProQuiz_Controller_GlobalSettings.php CHANGED
@@ -1,66 +1,66 @@
1
- <?php
2
- class WpProQuiz_Controller_GlobalSettings extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
- $this->edit();
6
- }
7
-
8
- private function edit() {
9
-
10
- if(!current_user_can('wpProQuiz_change_settings')) {
11
- wp_die(__('You do not have sufficient permissions to access this page.'));
12
- }
13
-
14
- $mapper = new WpProQuiz_Model_GlobalSettingsMapper();
15
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
16
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
17
-
18
- $view = new WpProQuiz_View_GobalSettings();
19
-
20
- if(isset($this->_post['submit'])) {
21
- $mapper->save(new WpProQuiz_Model_GlobalSettings($this->_post));
22
- WpProQuiz_View_View::admin_notices(__('Settings saved', 'wp-pro-quiz'), 'info');
23
-
24
- $toplistDateFormat = $this->_post['toplist_date_format'];
25
-
26
- if($toplistDateFormat == 'custom') {
27
- $toplistDateFormat = trim($this->_post['toplist_date_format_custom']);
28
- }
29
-
30
- $statisticTimeFormat = $this->_post['statisticTimeFormat'];
31
-
32
- if(add_option('wpProQuiz_toplistDataFormat', $toplistDateFormat) === false) {
33
- update_option('wpProQuiz_toplistDataFormat', $toplistDateFormat);
34
- }
35
-
36
- if(add_option('wpProQuiz_statisticTimeFormat', $statisticTimeFormat, '', 'no') === false) {
37
- update_option('wpProQuiz_statisticTimeFormat', $statisticTimeFormat);
38
- }
39
-
40
- //Email
41
- //$mapper->saveEmailSettiongs($this->_post['email']);
42
-
43
- //$mapper->saveUserEmailSettiongs($this->_post['userEmail']);
44
-
45
- } else if(isset($this->_post['databaseFix'])) {
46
- WpProQuiz_View_View::admin_notices(__('Database repaired', 'wp-pro-quiz'), 'info');
47
-
48
- $DbUpgradeHelper = new WpProQuiz_Helper_DbUpgrade();
49
- $DbUpgradeHelper->databaseDelta();
50
- }
51
-
52
- $view->settings = $mapper->fetchAll();
53
- $view->isRaw = !preg_match('[raw]', apply_filters('the_content', '[raw]a[/raw]'));
54
- $view->category = $categoryMapper->fetchAll();
55
- $view->categoryQuiz = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);
56
- $view->email = $mapper->getEmailSettings();
57
- $view->userEmail = $mapper->getUserEmailSettings();
58
- $view->templateQuiz = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false);
59
- $view->templateQuestion = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false);
60
-
61
- $view->toplistDataFormat = get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A');
62
- $view->statisticTimeFormat = get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A');
63
-
64
- $view->show();
65
- }
66
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_GlobalSettings extends WpProQuiz_Controller_Controller
4
+ {
5
+
6
+ public function route()
7
+ {
8
+ $this->edit();
9
+ }
10
+
11
+ private function edit()
12
+ {
13
+
14
+ if (!current_user_can('wpProQuiz_change_settings')) {
15
+ wp_die(__('You do not have sufficient permissions to access this page.'));
16
+ }
17
+
18
+ $mapper = new WpProQuiz_Model_GlobalSettingsMapper();
19
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
20
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
21
+
22
+ $view = new WpProQuiz_View_GobalSettings();
23
+
24
+ if (isset($this->_post['submit'])) {
25
+ $mapper->save(new WpProQuiz_Model_GlobalSettings($this->_post));
26
+ WpProQuiz_View_View::admin_notices(__('Settings saved', 'wp-pro-quiz'), 'info');
27
+
28
+ $toplistDateFormat = $this->_post['toplist_date_format'];
29
+
30
+ if ($toplistDateFormat == 'custom') {
31
+ $toplistDateFormat = trim($this->_post['toplist_date_format_custom']);
32
+ }
33
+
34
+ $statisticTimeFormat = $this->_post['statisticTimeFormat'];
35
+
36
+ if (add_option('wpProQuiz_toplistDataFormat', $toplistDateFormat) === false) {
37
+ update_option('wpProQuiz_toplistDataFormat', $toplistDateFormat);
38
+ }
39
+
40
+ if (add_option('wpProQuiz_statisticTimeFormat', $statisticTimeFormat, '', 'no') === false) {
41
+ update_option('wpProQuiz_statisticTimeFormat', $statisticTimeFormat);
42
+ }
43
+ } else {
44
+ if (isset($this->_post['databaseFix'])) {
45
+ WpProQuiz_View_View::admin_notices(__('Database repaired', 'wp-pro-quiz'), 'info');
46
+
47
+ $DbUpgradeHelper = new WpProQuiz_Helper_DbUpgrade();
48
+ $DbUpgradeHelper->databaseDelta();
49
+ }
50
+ }
51
+
52
+ $view->settings = $mapper->fetchAll();
53
+ $view->isRaw = !preg_match('[raw]', apply_filters('the_content', '[raw]a[/raw]'));
54
+ $view->category = $categoryMapper->fetchAll();
55
+ $view->categoryQuiz = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);
56
+ $view->email = $mapper->getEmailSettings();
57
+ $view->userEmail = $mapper->getUserEmailSettings();
58
+ $view->templateQuiz = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false);
59
+ $view->templateQuestion = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false);
60
+
61
+ $view->toplistDataFormat = get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A');
62
+ $view->statisticTimeFormat = get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A');
63
+
64
+ $view->show();
65
+ }
66
  }
lib/controller/WpProQuiz_Controller_ImportExport.php CHANGED
@@ -1,96 +1,105 @@
1
- <?php
2
- class WpProQuiz_Controller_ImportExport extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
-
6
- @set_time_limit(0);
7
- @ini_set('memory_limit', '128M');
8
-
9
- if(!isset($_GET['action']) || $_GET['action'] != 'import' && $_GET['action'] != 'export') {
10
- wp_die("Error");
11
- }
12
-
13
- if($_GET['action'] == 'export') {
14
- $this->handleExport();
15
- } else {
16
- $this->handleImport();
17
- }
18
- }
19
-
20
- private function handleExport() {
21
-
22
- if(!current_user_can('wpProQuiz_export')) {
23
- wp_die(__('You do not have sufficient permissions to access this page.'));
24
- }
25
-
26
- if(isset($this->_post ['exportType']) && $this->_post ['exportType'] == 'xml') {
27
- $export = new WpProQuiz_Helper_ExportXml();
28
- $filename = 'WpProQuiz_export_'.time().'.xml';
29
- } else {
30
- $export = new WpProQuiz_Helper_Export();
31
- $filename = 'WpProQuiz_export_'.time().'.wpq';
32
- }
33
-
34
- $a = $export->export($this->_post['exportIds']);
35
-
36
- header('Content-Type: application/octet-stream');
37
- header('Content-Disposition: attachment; filename="'.$filename.'"');
38
-
39
- echo $a;
40
-
41
- exit;
42
- }
43
-
44
- private function handleImport() {
45
-
46
- if(!current_user_can('wpProQuiz_import')) {
47
- wp_die(__('You do not have sufficient permissions to access this page.'));
48
- }
49
-
50
- $this->view = new WpProQuiz_View_Import();
51
- $this->view->error = false;
52
-
53
- if(isset($_FILES, $_FILES['import']) && substr($_FILES['import']['name'], -3) == 'xml' || isset($this->_post['importType']) && $this->_post['importType'] == 'xml') {
54
- $import = new WpProQuiz_Helper_ImportXml();
55
- $importType = 'xml';
56
- } else {
57
- $import = new WpProQuiz_Helper_Import();
58
- $importType = 'wpq';
59
- }
60
-
61
- $this->view->importType = $importType;
62
-
63
- if(isset($_FILES, $_FILES['import']) && $_FILES['import']['error'] == 0) {
64
- if($import->setImportFileUpload($_FILES['import']) === false) {
65
- $this->view->error = $import->getError();
66
- } else {
67
- $data = $import->getImportData();
68
-
69
- if($data === false) {
70
- $this->view->error = $import->getError();
71
- }
72
-
73
- $this->view->import = $data;
74
- $this->view->importData = $import->getContent();
75
-
76
- unset($data);
77
- }
78
- } else if(isset($this->_post, $this->_post['importSave'])) {
79
- if($import->setImportString($this->_post['importData']) === false) {
80
- $this->view->error = $import->getError();
81
- } else {
82
- $ids = isset($this->_post['importItems']) ? $this->_post['importItems'] : false;
83
-
84
- if($ids !== false && $import->saveImport($ids) === false) {
85
- $this->view->error = $import->getError();
86
- } else {
87
- $this->view->finish = true;
88
- }
89
- }
90
- } else {
91
- $this->view->error = __('File cannot be processed', 'wp-pro-quiz');
92
- }
93
-
94
- $this->view->show();
95
- }
 
 
 
 
 
 
 
 
 
96
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_ImportExport extends WpProQuiz_Controller_Controller
4
+ {
5
+
6
+ public function route()
7
+ {
8
+
9
+ @set_time_limit(0);
10
+ @ini_set('memory_limit', '128M');
11
+
12
+ if (!isset($_GET['action']) || $_GET['action'] != 'import' && $_GET['action'] != 'export') {
13
+ wp_die("Error");
14
+ }
15
+
16
+ if ($_GET['action'] == 'export') {
17
+ $this->handleExport();
18
+ } else {
19
+ $this->handleImport();
20
+ }
21
+ }
22
+
23
+ private function handleExport()
24
+ {
25
+
26
+ if (!current_user_can('wpProQuiz_export')) {
27
+ wp_die(__('You do not have sufficient permissions to access this page.'));
28
+ }
29
+
30
+ if (isset($this->_post ['exportType']) && $this->_post ['exportType'] == 'xml') {
31
+ $export = new WpProQuiz_Helper_ExportXml();
32
+ $filename = 'WpProQuiz_export_' . time() . '.xml';
33
+ } else {
34
+ $export = new WpProQuiz_Helper_Export();
35
+ $filename = 'WpProQuiz_export_' . time() . '.wpq';
36
+ }
37
+
38
+ $a = $export->export($this->_post['exportIds']);
39
+
40
+ header('Content-Type: application/octet-stream');
41
+ header('Content-Disposition: attachment; filename="' . $filename . '"');
42
+
43
+ echo $a;
44
+
45
+ exit;
46
+ }
47
+
48
+ private function handleImport()
49
+ {
50
+
51
+ if (!current_user_can('wpProQuiz_import')) {
52
+ wp_die(__('You do not have sufficient permissions to access this page.'));
53
+ }
54
+
55
+ $view = new WpProQuiz_View_Import();
56
+ $view->error = false;
57
+
58
+ if (isset($_FILES, $_FILES['import']) && substr($_FILES['import']['name'],
59
+ -3) == 'xml' || isset($this->_post['importType']) && $this->_post['importType'] == 'xml'
60
+ ) {
61
+ $import = new WpProQuiz_Helper_ImportXml();
62
+ $importType = 'xml';
63
+ } else {
64
+ $import = new WpProQuiz_Helper_Import();
65
+ $importType = 'wpq';
66
+ }
67
+
68
+ $view->importType = $importType;
69
+
70
+ if (isset($_FILES, $_FILES['import']) && $_FILES['import']['error'] == 0) {
71
+ if ($import->setImportFileUpload($_FILES['import']) === false) {
72
+ $view->error = $import->getError();
73
+ } else {
74
+ $data = $import->getImportData();
75
+
76
+ if ($data === false) {
77
+ $view->error = $import->getError();
78
+ }
79
+
80
+ $view->import = $data;
81
+ $view->importData = $import->getContent();
82
+
83
+ unset($data);
84
+ }
85
+ } else {
86
+ if (isset($this->_post, $this->_post['importSave'])) {
87
+ if ($import->setImportString($this->_post['importData']) === false) {
88
+ $view->error = $import->getError();
89
+ } else {
90
+ $ids = isset($this->_post['importItems']) ? $this->_post['importItems'] : false;
91
+
92
+ if ($ids !== false && $import->saveImport($ids) === false) {
93
+ $view->error = $import->getError();
94
+ } else {
95
+ $view->finish = true;
96
+ }
97
+ }
98
+ } else {
99
+ $view->error = __('File cannot be processed', 'wp-pro-quiz');
100
+ }
101
+ }
102
+
103
+ $view->show();
104
+ }
105
  }
lib/controller/WpProQuiz_Controller_InfoAdaptation.php CHANGED
@@ -1,13 +1,17 @@
1
- <?php
2
- class WpProQuiz_Controller_InfoAdaptation extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
- $this->showAction();
6
- }
7
-
8
- private function showAction() {
9
- $view = new WpProQuiz_View_InfoAdaptation();
10
-
11
- $view->show();
12
- }
 
 
 
 
13
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_InfoAdaptation extends WpProQuiz_Controller_Controller
4
+ {
5
+
6
+ public function route()
7
+ {
8
+ $this->showAction();
9
+ }
10
+
11
+ private function showAction()
12
+ {
13
+ $view = new WpProQuiz_View_InfoAdaptation();
14
+
15
+ $view->show();
16
+ }
17
  }
lib/controller/WpProQuiz_Controller_Preview.php CHANGED
@@ -1,64 +1,69 @@
1
- <?php
2
- class WpProQuiz_Controller_Preview extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
-
6
- wp_enqueue_script(
7
- 'wpProQuiz_front_javascript',
8
- plugins_url('js/wpProQuiz_front'.(WPPROQUIZ_DEV ? '' : '.min').'.js', WPPROQUIZ_FILE),
9
- array('jquery', 'jquery-ui-sortable'),
10
- WPPROQUIZ_VERSION
11
- );
12
-
13
- wp_localize_script('wpProQuiz_front_javascript', 'WpProQuizGlobal', array(
14
- 'ajaxurl' => admin_url('admin-ajax.php'),
15
- 'loadData' => __('Loading', 'wp-pro-quiz'),
16
- 'questionNotSolved' => __('You must answer this question.', 'wp-pro-quiz'),
17
- 'questionsNotSolved' => __('You must answer all questions before you can completed the quiz.', 'wp-pro-quiz'),
18
- 'fieldsNotFilled' => __('All fields have to be filled.', 'wp-pro-quiz')
19
- ));
20
-
21
- wp_enqueue_style(
22
- 'wpProQuiz_front_style',
23
- plugins_url('css/wpProQuiz_front'.(WPPROQUIZ_DEV ? '' : '.min').'.css', WPPROQUIZ_FILE),
24
- array(),
25
- WPPROQUIZ_VERSION
26
- );
27
-
28
- $this->showAction($_GET['id']);
29
- }
30
-
31
- public function showAction($id) {
32
- $view = new WpProQuiz_View_FrontQuiz();
33
-
34
- $quizMapper = new WpProQuiz_Model_QuizMapper();
35
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
36
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
37
- $formMapper = new WpProQuiz_Model_FormMapper();
38
-
39
- $quiz = $quizMapper->fetch($id);
40
-
41
- if($quiz->isShowMaxQuestion() && $quiz->getShowMaxQuestionValue() > 0) {
42
-
43
- $value = $quiz->getShowMaxQuestionValue();
44
-
45
- if($quiz->isShowMaxQuestionPercent()) {
46
- $count = $questionMapper->count($id);
47
-
48
- $value = ceil($count * $value / 100);
49
- }
50
-
51
- $question = $questionMapper->fetchAll($id, true, $value);
52
-
53
- } else {
54
- $question = $questionMapper->fetchAll($id);
55
- }
56
-
57
- $view->quiz = $quiz;
58
- $view->question = $question;
59
- $view->category = $categoryMapper->fetchByQuiz($quiz->getId());
60
- $view->forms = $formMapper->fetch($quiz->getId());
61
-
62
- $view->show(true);
63
- }
 
 
 
 
 
64
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Preview extends WpProQuiz_Controller_Controller
4
+ {
5
+
6
+ public function route()
7
+ {
8
+
9
+ wp_enqueue_script(
10
+ 'wpProQuiz_front_javascript',
11
+ plugins_url('js/wpProQuiz_front' . (WPPROQUIZ_DEV ? '' : '.min') . '.js', WPPROQUIZ_FILE),
12
+ array('jquery', 'jquery-ui-sortable'),
13
+ WPPROQUIZ_VERSION
14
+ );
15
+
16
+ wp_localize_script('wpProQuiz_front_javascript', 'WpProQuizGlobal', array(
17
+ 'ajaxurl' => admin_url('admin-ajax.php'),
18
+ 'loadData' => __('Loading', 'wp-pro-quiz'),
19
+ 'questionNotSolved' => __('You must answer this question.', 'wp-pro-quiz'),
20
+ 'questionsNotSolved' => __('You must answer all questions before you can completed the quiz.',
21
+ 'wp-pro-quiz'),
22
+ 'fieldsNotFilled' => __('All fields have to be filled.', 'wp-pro-quiz')
23
+ ));
24
+
25
+ wp_enqueue_style(
26
+ 'wpProQuiz_front_style',
27
+ plugins_url('css/wpProQuiz_front' . (WPPROQUIZ_DEV ? '' : '.min') . '.css', WPPROQUIZ_FILE),
28
+ array(),
29
+ WPPROQUIZ_VERSION
30
+ );
31
+
32
+ $this->showAction($_GET['id']);
33
+ }
34
+
35
+ public function showAction($id)
36
+ {
37
+ $view = new WpProQuiz_View_FrontQuiz();
38
+
39
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
40
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
41
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
42
+ $formMapper = new WpProQuiz_Model_FormMapper();
43
+
44
+ $quiz = $quizMapper->fetch($id);
45
+
46
+ if ($quiz->isShowMaxQuestion() && $quiz->getShowMaxQuestionValue() > 0) {
47
+
48
+ $value = $quiz->getShowMaxQuestionValue();
49
+
50
+ if ($quiz->isShowMaxQuestionPercent()) {
51
+ $count = $questionMapper->count($id);
52
+
53
+ $value = ceil($count * $value / 100);
54
+ }
55
+
56
+ $question = $questionMapper->fetchAll($id, true, $value);
57
+
58
+ } else {
59
+ $question = $questionMapper->fetchAll($id);
60
+ }
61
+
62
+ $view->quiz = $quiz;
63
+ $view->question = $question;
64
+ $view->category = $categoryMapper->fetchByQuiz($quiz->getId());
65
+ $view->forms = $formMapper->fetch($quiz->getId());
66
+
67
+ $view->show(true);
68
+ }
69
  }
lib/controller/WpProQuiz_Controller_Question.php CHANGED
@@ -1,705 +1,586 @@
1
- <?php
2
- class WpProQuiz_Controller_Question extends WpProQuiz_Controller_Controller {
3
-
4
- private $_quizId;
5
-
6
- public function route() {
7
-
8
- if(!isset($_GET['quiz_id']) || empty($_GET['quiz_id'])) {
9
- WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
10
- return;
11
- }
12
-
13
- $this->_quizId = (int)$_GET['quiz_id'];
14
- $action = isset($_GET['action']) ? $_GET['action'] : 'show';
15
-
16
- $m = new WpProQuiz_Model_QuizMapper();
17
-
18
- if($m->exists($this->_quizId) == 0) {
19
- WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
20
- return;
21
- }
22
-
23
- // if(isset($this->_post['hidden_action'])) {
24
- // switch ($this->_post['hidden_action']) {
25
- // case 'edit':
26
- // $this->editPostAction($this->_post['questionId']);
27
- // break;
28
- // }
29
- // }
30
-
31
- switch ($action) {
32
- // case 'add':
33
- // $this->createAction();
34
- // break;
35
- case 'show':
36
- $this->showAction();
37
- break;
38
- case 'addEdit':
39
- $this->addEditQuestion((int)$_GET['quiz_id']);
40
- break;
41
- // case 'edit':
42
- // $this->editAction($_GET['id']);
43
- // break;
44
- case 'delete':
45
- $this->deleteAction($_GET['id']);
46
- break;
47
- case 'delete_multi':
48
- $this->deleteMultiAction($_GET['quiz_id']);
49
- break;
50
- case 'save_sort':
51
- $this->saveSort();
52
- break;
53
- case 'load_question':
54
- $this->loadQuestion($_GET['quiz_id']);
55
- break;
56
- case 'copy_question':
57
- $this->copyQuestion($_GET['quiz_id']);
58
- break;
59
- default:
60
- $this->showAction();
61
- break;
62
- }
63
- }
64
-
65
- public function routeAction() {
66
- $action = isset($_GET['action']) ? $_GET['action'] : 'show';
67
-
68
- switch ($action) {
69
- default:
70
- $this->showActionHook();
71
- break;
72
- }
73
- }
74
-
75
- private function showActionHook() {
76
- if(! empty($_REQUEST['_wp_http_referer']) ){
77
- wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) );
78
- exit;
79
- }
80
-
81
- if(!class_exists('WP_List_Table')){
82
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
83
- }
84
-
85
- add_filter( 'manage_' . get_current_screen()->id . '_columns', array('WpProQuiz_View_QuestionOverallTable', 'getColumnDefs'));
86
-
87
- add_screen_option( 'per_page', array(
88
- 'label' => __( 'Questions', 'wp-pro-quiz' ),
89
- 'default' => 20,
90
- 'option' => 'wp_pro_quiz_question_overview_per_page' ) );
91
- }
92
-
93
- private function addEditQuestion($quizId) {
94
- $questionId = isset($_GET['questionId']) ? (int)$_GET['questionId'] : 0;
95
-
96
- if($questionId) {
97
- if(!current_user_can('wpProQuiz_edit_quiz')) {
98
- wp_die(__('You do not have sufficient permissions to access this page.'));
99
- }
100
- } else {
101
- if(!current_user_can('wpProQuiz_add_quiz')) {
102
- wp_die(__('You do not have sufficient permissions to access this page.'));
103
- }
104
- }
105
-
106
- $quizMapper = new WpProQuiz_Model_QuizMapper();
107
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
108
- $cateoryMapper = new WpProQuiz_Model_CategoryMapper();
109
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
110
-
111
- if($questionId && $questionMapper->existsAndWritable($questionId) == 0) {
112
- WpProQuiz_View_View::admin_notices(__('Question not found', 'wp-pro-quiz'), 'error');
113
-
114
- return;
115
- }
116
-
117
- $question = new WpProQuiz_Model_Question();
118
-
119
- if(isset($this->_post['template']) || (isset($this->_post['templateLoad']) && isset($this->_post['templateLoadId']))) {
120
- if(isset($this->_post['template']))
121
- $template = $this->saveTemplate();
122
- else
123
- $template = $templateMapper->fetchById($this->_post['templateLoadId']);
124
-
125
- $data = $template->getData();
126
-
127
- if($data !== null) {
128
- $question = $data['question'];
129
- $question->setId($questionId);
130
- $question->setQuizId($quizId);
131
- }
132
- } else if(isset($this->_post['submit'])) {
133
- if($questionId)
134
- WpProQuiz_View_View::admin_notices(__('Question edited', 'wp-pro-quiz'), 'info');
135
- else
136
- WpProQuiz_View_View::admin_notices(__('Question added', 'wp-pro-quiz'), 'info');
137
-
138
- $question = $questionMapper->save($this->getPostQuestionModel($quizId, $questionId), true);
139
- $questionId = $question->getId();
140
-
141
- } else {
142
- if($questionId) {
143
- $question = $questionMapper->fetch($questionId);
144
- }
145
- }
146
-
147
- $this->view = new WpProQuiz_View_QuestionEdit();
148
- $this->view->categories = $cateoryMapper->fetchAll();
149
- $this->view->quiz = $quizMapper->fetch($quizId);
150
- $this->view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false);
151
- $this->view->question = $question;
152
- $this->view->data = $this->setAnswerObject($question);
153
-
154
- $this->view->header = $questionId ? __('Edit question', 'wp-pro-quiz') : __('New question', 'wp-pro-quiz');
155
-
156
- if($this->view->question->isAnswerPointsActivated()) {
157
- $this->view->question->setPoints(1);
158
- }
159
-
160
- $this->view->show();
161
- }
162
-
163
- private function saveTemplate() {
164
- $questionModel = $this->getPostQuestionModel(0, 0);
165
-
166
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
167
- $template = new WpProQuiz_Model_Template();
168
-
169
- if($this->_post['templateSaveList'] == '0') {
170
- $template->setName(trim($this->_post['templateName']));
171
- } else {
172
- $template = $templateMapper->fetchById($this->_post['templateSaveList'], false);
173
- }
174
-
175
- $template->setType(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION);
176
-
177
- $template->setData(array(
178
- 'question' => $questionModel
179
- ));
180
-
181
- return $templateMapper->save($template);
182
- }
183
-
184
- private function getPostQuestionModel($quizId, $questionId) {
185
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
186
-
187
- $post = WpProQuiz_Controller_Request::getPost();
188
-
189
- $post['id'] = $questionId;
190
- $post['quizId'] = $quizId;
191
- $post['title'] = isset($post['title']) ? trim($post['title']) : '';
192
-
193
- $clearPost = $this->clearPost($post);
194
-
195
- $post['answerData'] = $clearPost['answerData'];
196
-
197
- if(empty($post['title'])) {
198
- $count = $questionMapper->count($quizId);
199
-
200
- $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $count+1);
201
- }
202
-
203
- if($post['answerType'] === 'assessment_answer') {
204
- $post['answerPointsActivated'] = 1;
205
- }
206
-
207
- if(isset($post['answerPointsActivated'])) {
208
- if(isset($post['answerPointsDiffModusActivated'])) {
209
- $post['points'] = $clearPost['maxPoints'];
210
- } else {
211
- $post['points'] = $clearPost['points'];
212
- }
213
- }
214
-
215
- $post['categoryId'] = $post['category'] > 0 ? $post['category'] : 0;
216
-
217
- return new WpProQuiz_Model_Question($post);
218
- }
219
-
220
- public function copyQuestion($quizId) {
221
-
222
- if(!current_user_can('wpProQuiz_edit_quiz')) {
223
- wp_die(__('You do not have sufficient permissions to access this page.'));
224
- }
225
-
226
- $m = new WpProQuiz_Model_QuestionMapper();
227
-
228
- $questions = $m->fetchById($this->_post['copyIds']);
229
-
230
- foreach($questions as $question) {
231
- $question->setId(0);
232
- $question->setQuizId($quizId);
233
-
234
- $m->save($question);
235
- }
236
-
237
- WpProQuiz_View_View::admin_notices(__('questions copied', 'wp-pro-quiz'), 'info');
238
-
239
- $this->showAction();
240
- }
241
-
242
- public function loadQuestion($quizId) {
243
-
244
- if(!current_user_can('wpProQuiz_edit_quiz')) {
245
- echo json_encode(array());
246
- exit;
247
- }
248
-
249
- $quizMapper = new WpProQuiz_Model_QuizMapper();
250
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
251
- $data = array();
252
-
253
- $quiz = $quizMapper->fetchAll();
254
-
255
- foreach($quiz as $qz) {
256
-
257
- if($qz->getId() == $quizId)
258
- continue;
259
-
260
- $question = $questionMapper->fetchAll($qz->getId());
261
- $questionArray = array();
262
-
263
- foreach($question as $qu) {
264
- $questionArray[] = array(
265
- 'name' => $qu->getTitle(),
266
- 'id' => $qu->getId()
267
- );
268
- }
269
-
270
- $data[] = array(
271
- 'name' => $qz->getName(),
272
- 'id' => $qz->getId(),
273
- 'question' => $questionArray
274
- );
275
- }
276
-
277
- echo json_encode($data);
278
-
279
- exit;
280
- }
281
-
282
- public function saveSort() {
283
-
284
- if(!current_user_can('wpProQuiz_edit_quiz')) {
285
- exit;
286
- }
287
-
288
- $mapper = new WpProQuiz_Model_QuestionMapper();
289
- $map = $this->_post['sort'];
290
-
291
- foreach($map as $k => $v)
292
- $mapper->updateSort($v, $k);
293
-
294
- exit;
295
- }
296
-
297
- public function deleteAction($id) {
298
-
299
- if(!current_user_can('wpProQuiz_delete_quiz')) {
300
- wp_die(__('You do not have sufficient permissions to access this page.'));
301
- }
302
-
303
- $mapper = new WpProQuiz_Model_QuestionMapper();
304
- $mapper->setOnlineOff($id);
305
-
306
- $this->showAction();
307
- }
308
-
309
- public function deleteMultiAction($quizId) {
310
- if(!current_user_can('wpProQuiz_delete_quiz')) {
311
- wp_die(__('You do not have sufficient permissions to access this page.'));
312
- }
313
-
314
- $mapper = new WpProQuiz_Model_QuestionMapper();
315
-
316
- if(!empty($_POST['ids'])) {
317
- foreach($_POST['ids'] as $id) {
318
- $mapper->setOnlineOff($id);
319
- }
320
- }
321
-
322
- $this->showAction();
323
- }
324
-
325
- /**
326
- * @deprecated
327
- */
328
- public function editAction($id) {
329
-
330
- if(!current_user_can('wpProQuiz_edit_quiz')) {
331
- wp_die(__('You do not have sufficient permissions to access this page.'));
332
- }
333
-
334
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
335
- $quizMapper = new WpProQuiz_Model_QuizMapper();
336
- $cateoryMapper = new WpProQuiz_Model_CategoryMapper();
337
-
338
-
339
- // if($mapper->existsAndWritable($id) == 0) {
340
- // WpProQuiz_View_View::admin_notices(__('Question not found', 'wp-pro-quiz'), 'error');
341
- // return;
342
- // }
343
-
344
- // $this->editPostAction($id);
345
-
346
- $this->view = new WpProQuiz_View_QuestionEdit();
347
- $this->view->quiz = $quizMapper->fetch($id);
348
- $this->view->question = $questionMapper->fetch($id);
349
- $this->view->data = $this->setAnswerObject($this->view->question);
350
- $this->view->categories = $cateoryMapper->fetchAll();
351
-
352
- $this->view->header = __('Edit question', 'wp-pro-quiz');
353
-
354
- if($this->view->question->isAnswerPointsActivated()) {
355
- $this->view->question->setPoints(1);
356
- }
357
-
358
- $this->view->show();
359
- }
360
-
361
- /**
362
- * @deprecated
363
- */
364
- public function editPostAction($id) {
365
- $mapper = new WpProQuiz_Model_QuestionMapper();
366
-
367
- if(isset($this->_post['submit']) && $mapper->existsAndWritable($id)) {
368
- $post = $this->_post;
369
-
370
- $post['id'] = $id;
371
- $post['title'] = isset($post['title']) ? trim($post['title']) : '';
372
-
373
- $clearPost = $this->clearPost($post);
374
-
375
- $post['answerData'] = $clearPost['answerData'];
376
-
377
- if(empty($post['title'])) {
378
- $question = $mapper->fetch($id);
379
-
380
- $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $question->getSort()+1);
381
- }
382
-
383
- if($post['answerType'] === 'assessment_answer') {
384
- $post['answerPointsActivated'] = 1;
385
- }
386
-
387
- if(isset($post['answerPointsActivated'])) {
388
- if(isset($post['answerPointsDiffModusActivated'])) {
389
- $post['points'] = $clearPost['maxPoints'];
390
- } else {
391
- $post['points'] = $clearPost['points'];
392
- }
393
- }
394
-
395
- $post['categoryId'] = $post['category'] > 0 ? $post['category'] : 0;
396
-
397
- $mapper->save(new WpProQuiz_Model_Question($post), true);
398
- WpProQuiz_View_View::admin_notices(__('Question edited', 'wp-pro-quiz'), 'info');
399
- }
400
- }
401
-
402
- /**
403
- * @deprecated
404
- */
405
- public function createAction() {
406
-
407
- if(!current_user_can('wpProQuiz_add_quiz')) {
408
- wp_die(__('You do not have sufficient permissions to access this page.'));
409
- }
410
-
411
- $quizMapper = new WpProQuiz_Model_QuizMapper();
412
- $cateoryMapper = new WpProQuiz_Model_CategoryMapper();
413
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
414
-
415
- // $post = null;
416
-
417
- // if(isset($this->_post['submit'])) {
418
-
419
- // $questionMapper = new WpProQuiz_Model_QuestionMapper();
420
-
421
- // $post = WpProQuiz_Controller_Request::getPost();
422
-
423
- // $post['title'] = isset($post['title']) ? trim($post['title']) : '';
424
- // $post['quizId'] = $this->_quizId;
425
-
426
- // $clearPost = $this->clearPost($post);
427
-
428
- // $post['answerData'] = $clearPost['answerData'];
429
-
430
- // if(empty($post['title'])) {
431
- // $count = $questionMapper->count($this->_quizId);
432
-
433
- // $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $count+1);
434
- // }
435
-
436
- // if($post['answerType'] === 'assessment_answer') {
437
- // $post['answerPointsActivated'] = 1;
438
- // }
439
-
440
- // if(isset($post['answerPointsActivated'])) {
441
- // if(isset($post['answerPointsDiffModusActivated'])) {
442
- // $post['points'] = $clearPost['maxPoints'];
443
- // } else {
444
- // $post['points'] = $clearPost['points'];
445
- // }
446
- // }
447
-
448
- // $post['categoryId'] = $post['category'] > 0 ? $post['category'] : 0;
449
-
450
- // $questionMapper->save(new WpProQuiz_Model_Question($post));
451
-
452
- // WpProQuiz_View_View::admin_notices(__('Question added', 'wp-pro-quiz'), 'info');
453
-
454
- // $this->showAction();
455
-
456
- // return;
457
- // }
458
-
459
- $this->view = new WpProQuiz_View_QuestionEdit();
460
- $this->view->question = new WpProQuiz_Model_Question();
461
- $this->view->categories = $cateoryMapper->fetchAll();
462
- $this->view->quiz = $quizMapper->fetch($this->_quizId);
463
- $this->view->data = $this->setAnswerObject();
464
- $this->view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false);
465
-
466
- $this->view->header = __('New question', 'wp-pro-quiz');
467
-
468
- if($this->view->question->isAnswerPointsActivated()) {
469
- $this->view->question->setPoints(1);
470
- }
471
-
472
- $this->view->show();
473
- }
474
-
475
- private function setAnswerObject(WpProQuiz_Model_Question $question = null) {
476
- //Defaults
477
- $data = array(
478
- 'sort_answer' => array(new WpProQuiz_Model_AnswerTypes()),
479
- 'classic_answer' => array(new WpProQuiz_Model_AnswerTypes()),
480
- 'matrix_sort_answer' => array(new WpProQuiz_Model_AnswerTypes()),
481
- 'cloze_answer' => array(new WpProQuiz_Model_AnswerTypes()),
482
- 'free_answer' => array(new WpProQuiz_Model_AnswerTypes()),
483
- 'assessment_answer' => array(new WpProQuiz_Model_AnswerTypes())
484
- );
485
-
486
- if($question !== null) {
487
- $type = $question->getAnswerType();
488
- $type = ($type == 'single' || $type == 'multiple') ? 'classic_answer' : $type;
489
- $answerData = $question->getAnswerData();
490
-
491
- if(isset($data[$type]) && $answerData !== null) {
492
- $data[$type] = $question->getAnswerData();
493
- }
494
- }
495
-
496
- return $data;
497
- }
498
-
499
- public function clearPost($post) {
500
-
501
- if($post['answerType'] == 'cloze_answer' && isset($post['answerData']['cloze'])) {
502
- preg_match_all('#\{(.*?)(?:\|(\d+))?(?:[\s]+)?\}#im', $post['answerData']['cloze']['answer'], $matches);
503
-
504
- $points = 0;
505
- $maxPoints = 0;
506
-
507
- foreach($matches[2] as $match) {
508
- if(empty($match))
509
- $match = 1;
510
-
511
- $points += $match;
512
- $maxPoints = max($maxPoints, $match);
513
- }
514
-
515
- return array('points' => $points, 'maxPoints' => $maxPoints, 'answerData' => array(new WpProQuiz_Model_AnswerTypes($post['answerData']['cloze'])));
516
- }
517
-
518
- if($post['answerType'] == 'assessment_answer' && isset($post['answerData']['assessment'])) {
519
- preg_match_all('#\{(.*?)\}#im', $post['answerData']['assessment']['answer'], $matches);
520
-
521
- $points = 0;
522
- $maxPoints = 0;
523
-
524
- foreach($matches[1] as $match) {
525
- preg_match_all('#\[([^\|\]]+)(?:\|(\d+))?\]#im', $match, $ms);
526
-
527
- $points += count($ms[1]);
528
- $maxPoints = max($maxPoints, count($ms[1]));
529
- }
530
-
531
- return array('points' => $points, 'maxPoints' => $maxPoints, 'answerData' => array(new WpProQuiz_Model_AnswerTypes($post['answerData']['assessment'])));
532
- }
533
-
534
- unset($post['answerData']['cloze']);
535
- unset($post['answerData']['assessment']);
536
-
537
- if(isset($post['answerData']['none'])) {
538
- unset($post['answerData']['none']);
539
- }
540
-
541
- $answerData = array();
542
- $points = 0;
543
- $maxPoints = 0;
544
-
545
- foreach($post['answerData'] as $k => $v) {
546
- if(trim($v['answer']) == '') {
547
- if($post['answerType'] != 'matrix_sort_answer') {
548
- continue;
549
- } else {
550
- if(trim($v['sort_string']) == '')
551
- continue;
552
- }
553
- }
554
-
555
- $answerType = new WpProQuiz_Model_AnswerTypes($v);
556
- $points += $answerType->getPoints();
557
-
558
- $maxPoints = max($maxPoints, $answerType->getPoints());
559
-
560
- $answerData[] = $answerType;
561
- }
562
-
563
- return array('points' => $points, 'maxPoints' => $maxPoints, 'answerData' => $answerData);
564
- }
565
-
566
- public function clear($a) {
567
- foreach($a as $k => $v) {
568
- if(is_array($v)) {
569
- $a[$k] = $this->clear($a[$k]);
570
- }
571
-
572
- if(is_string($a[$k])) {
573
- $a[$k] = trim($a[$k]);
574
-
575
- if($a[$k] != '') {
576
- continue;
577
- }
578
- }
579
-
580
- if(empty($a[$k])) {
581
- unset($a[$k]);
582
- }
583
- }
584
-
585
- return $a;
586
- }
587
-
588
- private function getCurrentPage() {
589
- $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
590
-
591
- return max( 1, $pagenum );
592
- }
593
-
594
- public function showAction() {
595
- if(!current_user_can('wpProQuiz_show')) {
596
- wp_die(__('You do not have sufficient permissions to access this page.'));
597
- }
598
-
599
- $m = new WpProQuiz_Model_QuizMapper();
600
- $mm = new WpProQuiz_Model_QuestionMapper();
601
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
602
-
603
- $this->view = new WpProQuiz_View_QuestionOverall();
604
- $this->view->quiz = $m->fetch($this->_quizId);
605
-
606
- $per_page = (int) get_user_option( 'wp_pro_quiz_question_overview_per_page' );
607
- if ( empty( $per_page ) || $per_page < 1 )
608
- $per_page = 20;
609
-
610
- $current_page = $this->getCurrentPage();
611
- $search = isset($_GET['s']) ? trim($_GET['s']) : '';
612
- $orderBy = isset($_GET['orderby']) ? trim($_GET['orderby']) : '';
613
- $order = isset($_GET['order']) ? trim($_GET['order']) : '';
614
- $offset = ( $current_page-1 )* $per_page;
615
- $limit = $per_page;
616
- $filter = array();
617
-
618
- if(isset($_GET['cat']))
619
- $filter['cat'] = $_GET['cat'];
620
-
621
- $result = $mm->fetchTable($this->_quizId, $orderBy, $order, $search, $limit, $offset, $filter);
622
-
623
- $this->view->questionItems = $result['questions'];
624
- $this->view->questionCount = $result['count'];
625
- $this->view->categoryItems = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUESTION);
626
- $this->view->perPage = $per_page;
627
-
628
- $this->view->show();
629
- }
630
-
631
- public static function ajaxSetQuestionMultipleCategories($data, $func) {
632
- if(!current_user_can('wpProQuiz_edit_quiz')) {
633
- return json_encode(array());
634
- }
635
-
636
- $quizMapper = new WpProQuiz_Model_QuestionMapper();
637
-
638
- $quizMapper->setMultipeCategories($data['questionIds'], $data['categoryId']);
639
-
640
- return json_encode(array());
641
- }
642
-
643
- public static function ajaxLoadQuestionsSort($data, $func) {
644
- if(!current_user_can('wpProQuiz_edit_quiz')) {
645
- return json_encode(array());
646
- }
647
-
648
- $quizMapper = new WpProQuiz_Model_QuestionMapper();
649
-
650
- $questions = $quizMapper->fetchAllList($data['quizId'], array('id', 'title'), true);
651
-
652
- return json_encode($questions);
653
- }
654
-
655
- public static function ajaxSaveSort($data, $func) {
656
- if(!current_user_can('wpProQuiz_edit_quiz')) {
657
- return json_encode(array());
658
- }
659
-
660
- $mapper = new WpProQuiz_Model_QuestionMapper();
661
-
662
- foreach($data['sort'] as $k => $v)
663
- $mapper->updateSort($v, $k);
664
-
665
- return json_encode(array());
666
- }
667
-
668
- public static function ajaxLoadCopyQuestion($data, $func) {
669
- if(!current_user_can('wpProQuiz_edit_quiz')) {
670
- echo json_encode(array());
671
- exit;
672
- }
673
-
674
- $quizId = $data['quizId'];
675
- $quizMapper = new WpProQuiz_Model_QuizMapper();
676
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
677
- $data = array();
678
-
679
- $quiz = $quizMapper->fetchAll();
680
-
681
- foreach($quiz as $qz) {
682
-
683
- if($qz->getId() == $quizId)
684
- continue;
685
-
686
- $question = $questionMapper->fetchAll($qz->getId());
687
- $questionArray = array();
688
-
689
- foreach($question as $qu) {
690
- $questionArray[] = array(
691
- 'name' => $qu->getTitle(),
692
- 'id' => $qu->getId()
693
- );
694
- }
695
-
696
- $data[] = array(
697
- 'name' => $qz->getName(),
698
- 'id' => $qz->getId(),
699
- 'question' => $questionArray
700
- );
701
- }
702
-
703
- return json_encode($data);
704
- }
705
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Question extends WpProQuiz_Controller_Controller
4
+ {
5
+ private $_quizId;
6
+
7
+ public function route()
8
+ {
9
+ if (!isset($_GET['quiz_id']) || empty($_GET['quiz_id'])) {
10
+ WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
11
+
12
+ return;
13
+ }
14
+
15
+ $this->_quizId = (int)$_GET['quiz_id'];
16
+ $action = isset($_GET['action']) ? $_GET['action'] : 'show';
17
+
18
+ $m = new WpProQuiz_Model_QuizMapper();
19
+
20
+ if ($m->exists($this->_quizId) == 0) {
21
+ WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
22
+
23
+ return;
24
+ }
25
+
26
+ switch ($action) {
27
+ case 'show':
28
+ $this->showAction();
29
+ break;
30
+ case 'addEdit':
31
+ $this->addEditQuestion((int)$_GET['quiz_id']);
32
+ break;
33
+ case 'delete':
34
+ $this->deleteAction($_GET['id']);
35
+ break;
36
+ case 'delete_multi':
37
+ $this->deleteMultiAction();
38
+ break;
39
+ case 'save_sort':
40
+ $this->saveSort();
41
+ break;
42
+ case 'load_question':
43
+ $this->loadQuestion($_GET['quiz_id']);
44
+ break;
45
+ case 'copy_question':
46
+ $this->copyQuestion($_GET['quiz_id']);
47
+ break;
48
+ default:
49
+ $this->showAction();
50
+ break;
51
+ }
52
+ }
53
+
54
+ public function routeAction()
55
+ {
56
+ $action = isset($_GET['action']) ? $_GET['action'] : 'show';
57
+
58
+ switch ($action) {
59
+ default:
60
+ $this->showActionHook();
61
+ break;
62
+ }
63
+ }
64
+
65
+ private function showActionHook()
66
+ {
67
+ if (!empty($_REQUEST['_wp_http_referer'])) {
68
+ wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
69
+ exit;
70
+ }
71
+
72
+ if (!class_exists('WP_List_Table')) {
73
+ require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
74
+ }
75
+
76
+ add_filter('manage_' . get_current_screen()->id . '_columns',
77
+ array('WpProQuiz_View_QuestionOverallTable', 'getColumnDefs'));
78
+
79
+ add_screen_option('per_page', array(
80
+ 'label' => __('Questions', 'wp-pro-quiz'),
81
+ 'default' => 20,
82
+ 'option' => 'wp_pro_quiz_question_overview_per_page'
83
+ ));
84
+ }
85
+
86
+ private function addEditQuestion($quizId)
87
+ {
88
+ $questionId = isset($_GET['questionId']) ? (int)$_GET['questionId'] : 0;
89
+
90
+ if ($questionId) {
91
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
92
+ wp_die(__('You do not have sufficient permissions to access this page.'));
93
+ }
94
+ } else {
95
+ if (!current_user_can('wpProQuiz_add_quiz')) {
96
+ wp_die(__('You do not have sufficient permissions to access this page.'));
97
+ }
98
+ }
99
+
100
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
101
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
102
+ $cateoryMapper = new WpProQuiz_Model_CategoryMapper();
103
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
104
+
105
+ if ($questionId && $questionMapper->existsAndWritable($questionId) == 0) {
106
+ WpProQuiz_View_View::admin_notices(__('Question not found', 'wp-pro-quiz'), 'error');
107
+
108
+ return;
109
+ }
110
+
111
+ $question = new WpProQuiz_Model_Question();
112
+
113
+ if (isset($this->_post['template']) || (isset($this->_post['templateLoad']) && isset($this->_post['templateLoadId']))) {
114
+ if (isset($this->_post['template'])) {
115
+ $template = $this->saveTemplate();
116
+ } else {
117
+ $template = $templateMapper->fetchById($this->_post['templateLoadId']);
118
+ }
119
+
120
+ $data = $template->getData();
121
+
122
+ if ($data !== null) {
123
+ /** @var WpProQuiz_Model_Question $question */
124
+ $question = $data['question'];
125
+ $question->setId($questionId);
126
+ $question->setQuizId($quizId);
127
+ }
128
+ } else {
129
+ if (isset($this->_post['submit'])) {
130
+ if ($questionId) {
131
+ WpProQuiz_View_View::admin_notices(__('Question edited', 'wp-pro-quiz'), 'info');
132
+ } else {
133
+ WpProQuiz_View_View::admin_notices(__('Question added', 'wp-pro-quiz'), 'info');
134
+ }
135
+
136
+ $question = $questionMapper->save($this->getPostQuestionModel($quizId, $questionId), true);
137
+ $questionId = $question->getId();
138
+
139
+ } else {
140
+ if ($questionId) {
141
+ $question = $questionMapper->fetch($questionId);
142
+ }
143
+ }
144
+ }
145
+
146
+ $view = new WpProQuiz_View_QuestionEdit();
147
+ $view->categories = $cateoryMapper->fetchAll();
148
+ $view->quiz = $quizMapper->fetch($quizId);
149
+ $view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false);
150
+ $view->question = $question;
151
+ $view->answerData = $this->setAnswerObject($question);
152
+
153
+ $view->header = $questionId ? __('Edit question', 'wp-pro-quiz') : __('New question', 'wp-pro-quiz');
154
+
155
+ if ($view->question->isAnswerPointsActivated()) {
156
+ $view->question->setPoints(1);
157
+ }
158
+
159
+ $view->show();
160
+ }
161
+
162
+ private function saveTemplate()
163
+ {
164
+ $questionModel = $this->getPostQuestionModel(0, 0);
165
+
166
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
167
+ $template = new WpProQuiz_Model_Template();
168
+
169
+ if ($this->_post['templateSaveList'] == '0') {
170
+ $template->setName(trim($this->_post['templateName']));
171
+ } else {
172
+ $template = $templateMapper->fetchById($this->_post['templateSaveList'], false);
173
+ }
174
+
175
+ $template->setType(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION);
176
+
177
+ $template->setData(array(
178
+ 'question' => $questionModel
179
+ ));
180
+
181
+ return $templateMapper->save($template);
182
+ }
183
+
184
+ private function getPostQuestionModel($quizId, $questionId)
185
+ {
186
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
187
+
188
+ $post = WpProQuiz_Controller_Request::getPost();
189
+
190
+ $post['id'] = $questionId;
191
+ $post['quizId'] = $quizId;
192
+ $post['title'] = isset($post['title']) ? trim($post['title']) : '';
193
+
194
+ $clearPost = $this->clearPost($post);
195
+
196
+ $post['answerData'] = $clearPost['answerData'];
197
+
198
+ if (empty($post['title'])) {
199
+ $count = $questionMapper->count($quizId);
200
+
201
+ $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $count + 1);
202
+ }
203
+
204
+ if ($post['answerType'] === 'assessment_answer') {
205
+ $post['answerPointsActivated'] = 1;
206
+ }
207
+
208
+ if (isset($post['answerPointsActivated'])) {
209
+ if (isset($post['answerPointsDiffModusActivated'])) {
210
+ $post['points'] = $clearPost['maxPoints'];
211
+ } else {
212
+ $post['points'] = $clearPost['points'];
213
+ }
214
+ }
215
+
216
+ $post['categoryId'] = $post['category'] > 0 ? $post['category'] : 0;
217
+
218
+ return new WpProQuiz_Model_Question($post);
219
+ }
220
+
221
+ public function copyQuestion($quizId)
222
+ {
223
+
224
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
225
+ wp_die(__('You do not have sufficient permissions to access this page.'));
226
+ }
227
+
228
+ $m = new WpProQuiz_Model_QuestionMapper();
229
+
230
+ $questions = $m->fetchById($this->_post['copyIds']);
231
+
232
+ foreach ($questions as $question) {
233
+ $question->setId(0);
234
+ $question->setQuizId($quizId);
235
+
236
+ $m->save($question);
237
+ }
238
+
239
+ WpProQuiz_View_View::admin_notices(__('questions copied', 'wp-pro-quiz'), 'info');
240
+
241
+ $this->showAction();
242
+ }
243
+
244
+ public function loadQuestion($quizId)
245
+ {
246
+
247
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
248
+ echo json_encode(array());
249
+ exit;
250
+ }
251
+
252
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
253
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
254
+ $data = array();
255
+
256
+ $quiz = $quizMapper->fetchAll();
257
+
258
+ foreach ($quiz as $qz) {
259
+
260
+ if ($qz->getId() == $quizId) {
261
+ continue;
262
+ }
263
+
264
+ $question = $questionMapper->fetchAll($qz->getId());
265
+ $questionArray = array();
266
+
267
+ foreach ($question as $qu) {
268
+ $questionArray[] = array(
269
+ 'name' => $qu->getTitle(),
270
+ 'id' => $qu->getId()
271
+ );
272
+ }
273
+
274
+ $data[] = array(
275
+ 'name' => $qz->getName(),
276
+ 'id' => $qz->getId(),
277
+ 'question' => $questionArray
278
+ );
279
+ }
280
+
281
+ echo json_encode($data);
282
+
283
+ exit;
284
+ }
285
+
286
+ public function saveSort()
287
+ {
288
+
289
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
290
+ exit;
291
+ }
292
+
293
+ $mapper = new WpProQuiz_Model_QuestionMapper();
294
+ $map = $this->_post['sort'];
295
+
296
+ foreach ($map as $k => $v) {
297
+ $mapper->updateSort($v, $k);
298
+ }
299
+
300
+ exit;
301
+ }
302
+
303
+ public function deleteAction($id)
304
+ {
305
+
306
+ if (!current_user_can('wpProQuiz_delete_quiz')) {
307
+ wp_die(__('You do not have sufficient permissions to access this page.'));
308
+ }
309
+
310
+ $mapper = new WpProQuiz_Model_QuestionMapper();
311
+ $mapper->setOnlineOff($id);
312
+
313
+ $this->showAction();
314
+ }
315
+
316
+ public function deleteMultiAction()
317
+ {
318
+ if (!current_user_can('wpProQuiz_delete_quiz')) {
319
+ wp_die(__('You do not have sufficient permissions to access this page.'));
320
+ }
321
+
322
+ $mapper = new WpProQuiz_Model_QuestionMapper();
323
+
324
+ if (!empty($_POST['ids'])) {
325
+ foreach ($_POST['ids'] as $id) {
326
+ $mapper->setOnlineOff($id);
327
+ }
328
+ }
329
+
330
+ $this->showAction();
331
+ }
332
+
333
+ private function setAnswerObject(WpProQuiz_Model_Question $question = null)
334
+ {
335
+ //Defaults
336
+ $data = array(
337
+ 'sort_answer' => array(new WpProQuiz_Model_AnswerTypes()),
338
+ 'classic_answer' => array(new WpProQuiz_Model_AnswerTypes()),
339
+ 'matrix_sort_answer' => array(new WpProQuiz_Model_AnswerTypes()),
340
+ 'cloze_answer' => array(new WpProQuiz_Model_AnswerTypes()),
341
+ 'free_answer' => array(new WpProQuiz_Model_AnswerTypes()),
342
+ 'assessment_answer' => array(new WpProQuiz_Model_AnswerTypes())
343
+ );
344
+
345
+ if ($question !== null) {
346
+ $type = $question->getAnswerType();
347
+ $type = ($type == 'single' || $type == 'multiple') ? 'classic_answer' : $type;
348
+ $answerData = $question->getAnswerData();
349
+
350
+ if (isset($data[$type]) && $answerData !== null) {
351
+ $data[$type] = $question->getAnswerData();
352
+ }
353
+ }
354
+
355
+ return $data;
356
+ }
357
+
358
+ public function clearPost($post)
359
+ {
360
+
361
+ if ($post['answerType'] == 'cloze_answer' && isset($post['answerData']['cloze'])) {
362
+ preg_match_all('#\{(.*?)(?:\|(\d+))?(?:[\s]+)?\}#im', $post['answerData']['cloze']['answer'], $matches);
363
+
364
+ $points = 0;
365
+ $maxPoints = 0;
366
+
367
+ foreach ($matches[2] as $match) {
368
+ if (empty($match)) {
369
+ $match = 1;
370
+ }
371
+
372
+ $points += $match;
373
+ $maxPoints = max($maxPoints, $match);
374
+ }
375
+
376
+ return array(
377
+ 'points' => $points,
378
+ 'maxPoints' => $maxPoints,
379
+ 'answerData' => array(new WpProQuiz_Model_AnswerTypes($post['answerData']['cloze']))
380
+ );
381
+ }
382
+
383
+ if ($post['answerType'] == 'assessment_answer' && isset($post['answerData']['assessment'])) {
384
+ preg_match_all('#\{(.*?)\}#im', $post['answerData']['assessment']['answer'], $matches);
385
+
386
+ $points = 0;
387
+ $maxPoints = 0;
388
+
389
+ foreach ($matches[1] as $match) {
390
+ preg_match_all('#\[([^\|\]]+)(?:\|(\d+))?\]#im', $match, $ms);
391
+
392
+ $points += count($ms[1]);
393
+ $maxPoints = max($maxPoints, count($ms[1]));
394
+ }
395
+
396
+ return array(
397
+ 'points' => $points,
398
+ 'maxPoints' => $maxPoints,
399
+ 'answerData' => array(new WpProQuiz_Model_AnswerTypes($post['answerData']['assessment']))
400
+ );
401
+ }
402
+
403
+ unset($post['answerData']['cloze']);
404
+ unset($post['answerData']['assessment']);
405
+
406
+ if (isset($post['answerData']['none'])) {
407
+ unset($post['answerData']['none']);
408
+ }
409
+
410
+ $answerData = array();
411
+ $points = 0;
412
+ $maxPoints = 0;
413
+
414
+ foreach ($post['answerData'] as $k => $v) {
415
+ if (trim($v['answer']) == '') {
416
+ if ($post['answerType'] != 'matrix_sort_answer') {
417
+ continue;
418
+ } else {
419
+ if (trim($v['sort_string']) == '') {
420
+ continue;
421
+ }
422
+ }
423
+ }
424
+
425
+ $answerType = new WpProQuiz_Model_AnswerTypes($v);
426
+ $points += $answerType->getPoints();
427
+
428
+ $maxPoints = max($maxPoints, $answerType->getPoints());
429
+
430
+ $answerData[] = $answerType;
431
+ }
432
+
433
+ return array('points' => $points, 'maxPoints' => $maxPoints, 'answerData' => $answerData);
434
+ }
435
+
436
+ public function clear($a)
437
+ {
438
+ foreach ($a as $k => $v) {
439
+ if (is_array($v)) {
440
+ $a[$k] = $this->clear($a[$k]);
441
+ }
442
+
443
+ if (is_string($a[$k])) {
444
+ $a[$k] = trim($a[$k]);
445
+
446
+ if ($a[$k] != '') {
447
+ continue;
448
+ }
449
+ }
450
+
451
+ if (empty($a[$k])) {
452
+ unset($a[$k]);
453
+ }
454
+ }
455
+
456
+ return $a;
457
+ }
458
+
459
+ private function getCurrentPage()
460
+ {
461
+ $pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0;
462
+
463
+ return max(1, $pagenum);
464
+ }
465
+
466
+ public function showAction()
467
+ {
468
+ if (!current_user_can('wpProQuiz_show')) {
469
+ wp_die(__('You do not have sufficient permissions to access this page.'));
470
+ }
471
+
472
+ $m = new WpProQuiz_Model_QuizMapper();
473
+ $mm = new WpProQuiz_Model_QuestionMapper();
474
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
475
+
476
+ $view = new WpProQuiz_View_QuestionOverall();
477
+ $view->quiz = $m->fetch($this->_quizId);
478
+
479
+ $per_page = (int)get_user_option('wp_pro_quiz_question_overview_per_page');
480
+ if (empty($per_page) || $per_page < 1) {
481
+ $per_page = 20;
482
+ }
483
+
484
+ $current_page = $this->getCurrentPage();
485
+ $search = isset($_GET['s']) ? trim($_GET['s']) : '';
486
+ $orderBy = isset($_GET['orderby']) ? trim($_GET['orderby']) : '';
487
+ $order = isset($_GET['order']) ? trim($_GET['order']) : '';
488
+ $offset = ($current_page - 1) * $per_page;
489
+ $limit = $per_page;
490
+ $filter = array();
491
+
492
+ if (isset($_GET['cat'])) {
493
+ $filter['cat'] = $_GET['cat'];
494
+ }
495
+
496
+ $result = $mm->fetchTable($this->_quizId, $orderBy, $order, $search, $limit, $offset, $filter);
497
+
498
+ $view->questionItems = $result['questions'];
499
+ $view->questionCount = $result['count'];
500
+ $view->categoryItems = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUESTION);
501
+ $view->perPage = $per_page;
502
+
503
+ $view->show();
504
+ }
505
+
506
+ public static function ajaxSetQuestionMultipleCategories($data)
507
+ {
508
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
509
+ return json_encode(array());
510
+ }
511
+
512
+ $quizMapper = new WpProQuiz_Model_QuestionMapper();
513
+
514
+ $quizMapper->setMultipeCategories($data['questionIds'], $data['categoryId']);
515
+
516
+ return json_encode(array());
517
+ }
518
+
519
+ public static function ajaxLoadQuestionsSort($data)
520
+ {
521
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
522
+ return json_encode(array());
523
+ }
524
+
525
+ $quizMapper = new WpProQuiz_Model_QuestionMapper();
526
+
527
+ $questions = $quizMapper->fetchAllList($data['quizId'], array('id', 'title'), true);
528
+
529
+ return json_encode($questions);
530
+ }
531
+
532
+ public static function ajaxSaveSort($data)
533
+ {
534
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
535
+ return json_encode(array());
536
+ }
537
+
538
+ $mapper = new WpProQuiz_Model_QuestionMapper();
539
+
540
+ foreach ($data['sort'] as $k => $v) {
541
+ $mapper->updateSort($v, $k);
542
+ }
543
+
544
+ return json_encode(array());
545
+ }
546
+
547
+ public static function ajaxLoadCopyQuestion($data)
548
+ {
549
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
550
+ echo json_encode(array());
551
+ exit;
552
+ }
553
+
554
+ $quizId = $data['quizId'];
555
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
556
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
557
+ $data = array();
558
+
559
+ $quiz = $quizMapper->fetchAll();
560
+
561
+ foreach ($quiz as $qz) {
562
+
563
+ if ($qz->getId() == $quizId) {
564
+ continue;
565
+ }
566
+
567
+ $question = $questionMapper->fetchAll($qz->getId());
568
+ $questionArray = array();
569
+
570
+ foreach ($question as $qu) {
571
+ $questionArray[] = array(
572
+ 'name' => $qu->getTitle(),
573
+ 'id' => $qu->getId()
574
+ );
575
+ }
576
+
577
+ $data[] = array(
578
+ 'name' => $qz->getName(),
579
+ 'id' => $qz->getId(),
580
+ 'question' => $questionArray
581
+ );
582
+ }
583
+
584
+ return json_encode($data);
585
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
  }
lib/controller/WpProQuiz_Controller_Quiz.php CHANGED
@@ -1,980 +1,866 @@
1
- <?php
2
- class WpProQuiz_Controller_Quiz extends WpProQuiz_Controller_Controller {
3
- private $view;
4
-
5
- public function route() {
6
- $action = isset($_GET['action']) ? $_GET['action'] : 'show';
7
-
8
- switch ($action) {
9
- case 'show':
10
- $this->showAction();
11
- break;
12
- case 'addEdit':
13
- $this->addEditQuiz();
14
- break;
15
- // case 'add':
16
- // $this->createAction();
17
- // break;
18
- // case 'edit':
19
- // if(isset($_GET['id']))
20
- // $this->editAction($_GET['id']);
21
- // break;
22
- case 'delete':
23
- if(isset($_GET['id']))
24
- $this->deleteAction($_GET['id']);
25
- break;
26
- case 'deleteMulti':
27
- $this->deleteMultiAction();
28
- break;
29
- case 'reset_lock':
30
- $this->resetLock($_GET['id']);
31
- break;
32
- default:
33
- $this->showAction();
34
- break;
35
- }
36
- }
37
-
38
- public function routeAction() {
39
- $action = isset($_GET['action']) ? $_GET['action'] : 'show';
40
-
41
- switch ($action) {
42
- default:
43
- $this->showActionHook();
44
- break;
45
- }
46
- }
47
-
48
- private function showActionHook() {
49
- if(! empty($_REQUEST['_wp_http_referer']) ){
50
- wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) );
51
- exit;
52
- }
53
-
54
- if(!class_exists('WP_List_Table')){
55
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
56
- }
57
-
58
- add_filter( 'manage_' . get_current_screen()->id . '_columns', array('WpProQuiz_View_QuizOverallTable', 'getColumnDefs'));
59
-
60
- add_screen_option( 'per_page', array(
61
- 'label' => __( 'Quiz', 'wp-pro-quiz' ),
62
- 'default' => 20,
63
- 'option' => 'wp_pro_quiz_quiz_overview_per_page' ) );
64
- }
65
-
66
- private function addEditQuiz() {
67
- $quizId = isset($_GET['quizId']) ? (int)$_GET['quizId'] : 0;
68
-
69
- if($quizId) {
70
- if(!current_user_can('wpProQuiz_edit_quiz')) {
71
- wp_die(__('You do not have sufficient permissions to access this page.'));
72
- }
73
- } else {
74
- if(!current_user_can('wpProQuiz_add_quiz')) {
75
- wp_die(__('You do not have sufficient permissions to access this page.'));
76
- }
77
- }
78
-
79
- $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
80
- $quizMapper = new WpProQuiz_Model_QuizMapper();
81
- $formMapper = new WpProQuiz_Model_FormMapper();
82
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
83
- $cateoryMapper = new WpProQuiz_Model_CategoryMapper();
84
-
85
- $quiz = new WpProQuiz_Model_Quiz();
86
- $forms = null;
87
- $prerequisiteQuizList = array();
88
-
89
-
90
- if($quizId && $quizMapper->exists($quizId) == 0) {
91
- WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
92
-
93
- return;
94
- }
95
-
96
- if(isset($this->_post['template']) || (isset($this->_post['templateLoad']) && isset($this->_post['templateLoadId']))) {
97
- if(isset($this->_post['template']))
98
- $template = $this->saveTemplate();
99
- else
100
- $template = $templateMapper->fetchById($this->_post['templateLoadId']);
101
-
102
- $data = $template->getData();
103
-
104
- if($data !== null) {
105
- $quiz = $data['quiz'];
106
- $quiz->setId($quizId);
107
-
108
- $forms = $data['forms'];
109
- $prerequisiteQuizList = $data['prerequisiteQuizList'];
110
- }
111
- } else if(isset($this->_post['submit'])) {
112
-
113
- if(isset($this->_post['resultGradeEnabled'])) {
114
- $this->_post['result_text'] = $this->filterResultTextGrade($this->_post);
115
- }
116
-
117
- $this->_post['categoryId'] = $this->_post['category'] > 0 ? $this->_post['category'] : 0;
118
-
119
- $this->_post['adminEmail'] = new WpProQuiz_Model_Email($this->_post['adminEmail']);
120
- $this->_post['userEmail'] = new WpProQuiz_Model_Email($this->_post['userEmail']);
121
-
122
- $quiz = new WpProQuiz_Model_Quiz($this->_post);
123
- $quiz->setId($quizId);
124
-
125
- if(isset($this->_post['plugin']))
126
- $quiz->getPluginContainer()->set($this->_post['plugin']);
127
-
128
- if($this->checkValidit($this->_post)) {
129
- if($quizId)
130
- WpProQuiz_View_View::admin_notices(__('Quiz edited', 'wp-pro-quiz'), 'info');
131
- else
132
- WpProQuiz_View_View::admin_notices(__('quiz created', 'wp-pro-quiz'), 'info');
133
-
134
- $quizMapper->save($quiz);
135
-
136
- $quizId = $quiz->getId();
137
-
138
- $prerequisiteMapper->delete($quizId);
139
-
140
- if($quiz->isPrerequisite() && !empty($this->_post['prerequisiteList'])) {
141
- $prerequisiteMapper->save($quizId, $this->_post['prerequisiteList']);
142
- $quizMapper->activateStatitic($this->_post['prerequisiteList'], 1440);
143
- }
144
-
145
- if(!$this->formHandler($quiz->getId(), $this->_post)) {
146
- $quiz->setFormActivated(false);
147
- $quizMapper->save($quiz);
148
- }
149
-
150
- $forms = $formMapper->fetch($quizId);
151
- $prerequisiteQuizList = $prerequisiteMapper->fetchQuizIds($quizId);
152
-
153
- } else {
154
- WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled', 'wp-pro-quiz'));
155
- }
156
- } else if($quizId) {
157
- $quiz = $quizMapper->fetch($quizId);
158
- $forms = $formMapper->fetch($quizId);
159
- $prerequisiteQuizList = $prerequisiteMapper->fetchQuizIds($quizId);
160
- }
161
-
162
- $this->view = new WpProQuiz_View_QuizEdit();
163
-
164
- $this->view->quiz = $quiz;
165
- $this->view->forms = $forms;
166
- $this->view->prerequisiteQuizList = $prerequisiteQuizList;
167
- $this->view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false);
168
- $this->view->quizList = $quizMapper->fetchAllAsArray(array('id', 'name'), $quizId ? array($quizId) : array());
169
- $this->view->captchaIsInstalled = class_exists('ReallySimpleCaptcha');
170
- $this->view->categories = $cateoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);
171
-
172
- $this->view->header = $quizId ? __('Edit quiz', 'wp-pro-quiz') : __('Create quiz', 'wp-pro-quiz');
173
-
174
- $this->view->show();
175
- }
176
-
177
- // public function checkLock() {
178
- //
179
- //
180
- // if($userId > 0) {
181
- // $quizIds = $prerequisiteMapper->getNoPrerequisite($quizId, $userId);
182
- // } else {
183
- // $checkIds = $prerequisiteMapper->fetchQuizIds($quizId);
184
- //
185
- // if(isset($this->_post['wpProQuiz_result'])) {
186
- // $r = json_encode($this->_post['wpProQuiz_result'], true);
187
- //
188
- // if($r !== null && is_array($r)) {
189
- // foreach($checkIds as $id) {
190
- // if(!isset($r[$id]) || !$r[$id]) {
191
- // $quizIds[] = $id;
192
- // }
193
- // }
194
- // }
195
- // } else {
196
- // $quizIds = $checkIds;
197
- // }
198
- // }
199
- //
200
- // $names = $quizMapper->fetchCol($quizIds, 'name');
201
- //
202
- // }
203
-
204
- public function isLockQuiz($quizId) {
205
- $quizId = (int)$this->_post['quizId'];
206
- $userId = get_current_user_id();
207
- $data = array();
208
-
209
- $lockMapper = new WpProQuiz_Model_LockMapper();
210
- $quizMapper = new WpProQuiz_Model_QuizMapper();
211
- $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
212
-
213
- $quiz = $quizMapper->fetch($this->_post['quizId']);
214
-
215
- if($quiz === null || $quiz->getId() <= 0) {
216
- return null;
217
- }
218
-
219
- if($this->isPreLockQuiz($quiz)) {
220
- $lockIp = $lockMapper->isLock($this->_post['quizId'], $this->getIp(), $userId, WpProQuiz_Model_Lock::TYPE_QUIZ);
221
- $lockCookie = false;
222
- $cookieTime = $quiz->getQuizRunOnceTime();
223
-
224
- if(isset($this->_cookie['wpProQuiz_lock']) && $userId == 0 && $quiz->isQuizRunOnceCookie()) {
225
- $cookieJson = json_decode($this->_cookie['wpProQuiz_lock'], true);
226
-
227
- if($cookieJson !== false) {
228
- if(isset($cookieJson[$this->_post['quizId']]) && $cookieJson[$this->_post['quizId']] == $cookieTime) {
229
- $lockCookie = true;
230
- }
231
- }
232
- }
233
-
234
- $data['lock'] = array(
235
- 'is' => ($lockIp || $lockCookie),
236
- 'pre' => true
237
- );
238
- }
239
-
240
- if($quiz->isPrerequisite()) {
241
- $quizIds = array();
242
-
243
- if($userId > 0) {
244
- $quizIds = $prerequisiteMapper->getNoPrerequisite($quizId, $userId);
245
- } else {
246
- $checkIds = $prerequisiteMapper->fetchQuizIds($quizId);
247
-
248
- if(isset($this->_cookie['wpProQuiz_result'])) {
249
- $r = json_decode($this->_cookie['wpProQuiz_result'], true);
250
-
251
- if($r !== null && is_array($r)) {
252
- foreach($checkIds as $id) {
253
- if(!isset($r[$id]) || !$r[$id]) {
254
- $quizIds[] = $id;
255
- }
256
- }
257
- }
258
- } else {
259
- $quizIds = $checkIds;
260
- }
261
- }
262
-
263
- if(!empty($quizIds)) {
264
- $names = $quizMapper->fetchCol($quizIds, 'name');
265
-
266
- if(!empty($names)) {
267
- $data['prerequisite'] = implode(', ', $names);
268
- }
269
- }
270
-
271
- }
272
-
273
- if($quiz->isStartOnlyRegisteredUser()) {
274
- $data['startUserLock'] = (int)!is_user_logged_in();
275
- }
276
-
277
- return $data;
278
- }
279
-
280
- public function loadQuizData() {
281
- $quizId = (int)$_POST['quizId'];
282
- $userId = get_current_user_id();
283
-
284
- $quizMapper = new WpProQuiz_Model_QuizMapper();
285
- $toplistController = new WpProQuiz_Controller_Toplist();
286
- $statisticController = new WpProQuiz_Controller_Statistics();
287
-
288
- $quiz = $quizMapper->fetch($quizId);
289
- $data = array();
290
-
291
- if($quiz === null || $quiz->getId() <= 0) {
292
- return array();
293
- }
294
-
295
- $data['toplist'] = $toplistController->getAddToplist($quiz);
296
- $data['averageResult'] = $statisticController->getAverageResult($quizId);
297
-
298
- return $data;
299
- }
300
-
301
- private function resetLock($quizId) {
302
-
303
- if(!current_user_can('wpProQuiz_edit_quiz')) {
304
- exit;
305
- }
306
-
307
- $lm = new WpProQuiz_Model_LockMapper();
308
- $qm = new WpProQuiz_Model_QuizMapper();
309
-
310
- $q = $qm->fetch($quizId);
311
-
312
- if($q->getId() > 0) {
313
-
314
- $q->setQuizRunOnceTime(time());
315
-
316
- $qm->save($q);
317
-
318
- $lm->deleteByQuizId($quizId, WpProQuiz_Model_Lock::TYPE_QUIZ);
319
- }
320
-
321
- exit;
322
- }
323
-
324
- private function getCurrentPage() {
325
- $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
326
-
327
- return max( 1, $pagenum );
328
- }
329
-
330
- private function showAction() {
331
- if(!current_user_can('wpProQuiz_show')) {
332
- wp_die(__('You do not have sufficient permissions to access this page.'));
333
- }
334
-
335
- $this->view = new WpProQuiz_View_QuizOverall();
336
-
337
- $m = new WpProQuiz_Model_QuizMapper();
338
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
339
-
340
- $per_page = (int) get_user_option( 'wp_pro_quiz_quiz_overview_per_page' );
341
- if ( empty( $per_page ) || $per_page < 1 )
342
- $per_page = 20;
343
-
344
- // $per_page = 50;
345
- $current_page = $this->getCurrentPage();
346
- $search = isset($_GET['s']) ? trim($_GET['s']) : '';
347
- $orderBy = isset($_GET['orderby']) ? trim($_GET['orderby']) : '';
348
- $order = isset($_GET['order']) ? trim($_GET['order']) : '';
349
- $offset = ( $current_page-1 )* $per_page;
350
- $limit = $per_page;
351
- $filter = array();
352
-
353
- if(isset($_GET['cat']))
354
- $filter['cat'] = $_GET['cat'];
355
-
356
- $result = $m->fetchTable($orderBy, $order, $search, $limit, $offset, $filter);
357
-
358
- $this->view->quizItems = $result['quiz'];
359
- $this->view->quizCount = $result['count'];
360
- $this->view->categoryItems = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);;
361
- $this->view->perPage = $per_page;
362
-
363
- $this->view->show();
364
- }
365
-
366
- private function editAction($id) {
367
-
368
- if(!current_user_can('wpProQuiz_edit_quiz')) {
369
- wp_die(__('You do not have sufficient permissions to access this page.'));
370
- }
371
-
372
- $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
373
- $quizMapper = new WpProQuiz_Model_QuizMapper();
374
- $formMapper = new WpProQuiz_Model_FormMapper();
375
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
376
- $m = new WpProQuiz_Model_QuizMapper();
377
-
378
- $this->view = new WpProQuiz_View_QuizEdit();
379
- $this->view->header = __('Edit quiz', 'wp-pro-quiz');
380
-
381
- $forms = $formMapper->fetch($id);
382
- $prerequisiteQuizList = $prerequisiteMapper->fetchQuizIds($id);
383
-
384
-
385
- if($m->exists($id) == 0) {
386
- WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
387
- return;
388
- }
389
-
390
- if(isset($this->_post['submit'])) {
391
-
392
- if(isset($this->_post['resultGradeEnabled'])) {
393
- $this->_post['result_text'] = $this->filterResultTextGrade($this->_post);
394
- }
395
-
396
- $quiz = new WpProQuiz_Model_Quiz($this->_post);
397
- $quiz->setId($id);
398
-
399
- if($this->checkValidit($this->_post)) {
400
-
401
- WpProQuiz_View_View::admin_notices(__('Quiz edited', 'wp-pro-quiz'), 'info');
402
-
403
- $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
404
-
405
- $prerequisiteMapper->delete($id);
406
-
407
- if($quiz->isPrerequisite() && !empty($this->_post['prerequisiteList'])) {
408
- $prerequisiteMapper->save($id, $this->_post['prerequisiteList']);
409
- $quizMapper->activateStatitic($this->_post['prerequisiteList'], 1440);
410
- }
411
-
412
- if(!$this->formHandler($quiz->getId(), $this->_post)) {
413
- $quiz->setFormActivated(false);
414
- }
415
-
416
- $quizMapper->save($quiz);
417
-
418
- $this->showAction();
419
-
420
- return;
421
- } else {
422
- WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled', 'wp-pro-quiz'));
423
- }
424
- } else if(isset($this->_post['template']) || isset($this->_post['templateLoad'])) {
425
- if(isset($this->_post['template']))
426
- $template = $this->saveTemplate();
427
- else
428
- $template = $templateMapper->fetchById($this->_post['templateLoadId']);
429
-
430
- $data = $template->getData();
431
-
432
- if($data !== null) {
433
- $quiz = $data['quiz'];
434
- $forms = $data['forms'];
435
- $prerequisiteQuizList = $data['prerequisiteQuizList'];
436
- }
437
- } else {
438
- $quiz = $m->fetch($id);
439
- }
440
-
441
- $this->view->quiz = $quiz;
442
- $this->view->prerequisiteQuizList = $prerequisiteQuizList;
443
- $this->view->quizList = $m->fetchAllAsArray(array('id', 'name'), array($id));
444
- $this->view->captchaIsInstalled = class_exists('ReallySimpleCaptcha');
445
- $this->view->forms = $forms;
446
- $this->view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false);
447
- $this->view->show();
448
- }
449
-
450
- private function createAction() {
451
-
452
- if(!current_user_can('wpProQuiz_add_quiz')) {
453
- wp_die(__('You do not have sufficient permissions to access this page.'));
454
- }
455
-
456
- $this->view = new WpProQuiz_View_QuizEdit();
457
- $this->view->header = __('Create quiz', 'wp-pro-quiz');
458
-
459
- $forms = null;
460
- $prerequisiteQuizList = array();
461
-
462
- $m = new WpProQuiz_Model_QuizMapper();
463
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
464
-
465
- if(isset($this->_post['submit'])) {
466
-
467
- if(isset($this->_post['resultGradeEnabled'])) {
468
- $this->_post['result_text'] = $this->filterResultTextGrade($this->_post);
469
- }
470
-
471
- $quiz = new WpProQuiz_Model_Quiz($this->_post);
472
- $quizMapper = new WpProQuiz_Model_QuizMapper();
473
-
474
- if($this->checkValidit($this->_post)) {
475
- WpProQuiz_View_View::admin_notices(__('Create quiz', 'wp-pro-quiz'), 'info');
476
- $quizMapper->save($quiz);
477
-
478
- $id = $quizMapper->getInsertId();
479
- $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
480
-
481
- if($quiz->isPrerequisite() && !empty($this->_post['prerequisiteList'])) {
482
- $prerequisiteMapper->save($id, $this->_post['prerequisiteList']);
483
- $quizMapper->activateStatitic($this->_post['prerequisiteList'], 1440);
484
- }
485
-
486
- if(!$this->formHandler($id, $this->_post)) {
487
- $quiz->setFormActivated(false);
488
- $quizMapper->save($quiz);
489
- }
490
-
491
- $this->showAction();
492
- return;
493
- } else {
494
- WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled', 'wp-pro-quiz'));
495
- }
496
- } else if(isset($this->_post['template']) || isset($this->_post['templateLoad'])) {
497
- if(isset($this->_post['template']))
498
- $template = $this->saveTemplate();
499
- else
500
- $template = $templateMapper->fetchById($this->_post['templateLoadId']);
501
-
502
- $data = $template->getData();
503
-
504
- if($data !== null) {
505
- $quiz = $data['quiz'];
506
- $forms = $data['forms'];
507
- $prerequisiteQuizList = $data['prerequisiteQuizList'];
508
- }
509
- } else {
510
- $quiz = new WpProQuiz_Model_Quiz();
511
- }
512
-
513
- $this->view->quiz = $quiz;
514
- $this->view->prerequisiteQuizList = $prerequisiteQuizList;
515
- $this->view->quizList = $m->fetchAllAsArray(array('id', 'name'));
516
- $this->view->captchaIsInstalled = class_exists('ReallySimpleCaptcha');
517
- $this->view->forms = $forms;
518
- $this->view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false);
519
- $this->view->show();
520
- }
521
-
522
- private function saveTemplate() {
523
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
524
-
525
- if(isset($this->_post['resultGradeEnabled'])) {
526
- $this->_post['result_text'] = $this->filterResultTextGrade($this->_post);
527
- }
528
-
529
- $this->_post['categoryId'] = $this->_post['category'] > 0 ? $this->_post['category'] : 0;
530
-
531
- $this->_post['adminEmail'] = new WpProQuiz_Model_Email($this->_post['adminEmail']);
532
- $this->_post['userEmail'] = new WpProQuiz_Model_Email($this->_post['userEmail']);
533
-
534
- $quiz = new WpProQuiz_Model_Quiz($this->_post);
535
-
536
- if($quiz->isPrerequisite() && !empty($this->_post['prerequisiteList']) && !$quiz->isStatisticsOn()) {
537
- $quiz->setStatisticsOn(true);
538
- $quiz->setStatisticsIpLock(1440);
539
- }
540
-
541
- $form = $this->_post['form'];
542
-
543
- unset($form[0]);
544
-
545
- $forms = array();
546
-
547
- foreach($form as $f) {
548
- $f['fieldname'] = trim($f['fieldname']);
549
-
550
- if(empty($f['fieldname']))
551
- continue;
552
-
553
- if((int) $f['form_id'] && (int) $f['form_delete']) {
554
- continue;
555
- }
556
-
557
- if($f['type'] == WpProQuiz_Model_Form::FORM_TYPE_SELECT || $f['type'] == WpProQuiz_Model_Form::FORM_TYPE_RADIO) {
558
- if(!empty($f['data'])) {
559
- $items = explode("\n", $f['data']);
560
- $f['data'] = array();
561
-
562
- foreach ($items as $item) {
563
- $item = trim($item);
564
-
565
- if(!empty($item))
566
- $f['data'][] = $item;
567
- }
568
- }
569
- }
570
-
571
- if(empty($f['data']) || !is_array($f['data']))
572
- $f['data'] = null;
573
-
574
- $forms[] = new WpProQuiz_Model_Form($f);
575
- }
576
-
577
- WpProQuiz_View_View::admin_notices(__('Template stored', 'wp-pro-quiz'), 'info');
578
-
579
- $data = array(
580
- 'quiz' => $quiz,
581
- 'forms' => $forms,
582
- 'prerequisiteQuizList' => isset($this->_post['prerequisiteList']) ? $this->_post['prerequisiteList'] : array()
583
- );
584
-
585
- $template = new WpProQuiz_Model_Template();
586
-
587
- if($this->_post['templateSaveList'] == '0') {
588
- $template->setName(trim($this->_post['templateName']));
589
- } else {
590
- $template = $templateMapper->fetchById($this->_post['templateSaveList'], false);
591
- }
592
-
593
- $template->setType(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ);
594
- $template->setData($data);
595
-
596
- $templateMapper->save($template);
597
-
598
- return $template;
599
- }
600
-
601
- private function formHandler($quizId, $post) {
602
- if(!isset($post['form']))
603
- return false;
604
-
605
- $form = $post['form'];
606
-
607
- unset($form[0]);
608
-
609
- if(empty($form))
610
- return false;
611
-
612
- $formMapper = new WpProQuiz_Model_FormMapper();
613
-
614
- $deleteIds = array();
615
- $forms = array();
616
- $sort = 0;
617
-
618
- foreach($form as $f) {
619
- $f['fieldname'] = trim($f['fieldname']);
620
-
621
- if(empty($f['fieldname']))
622
- continue;
623
-
624
- if((int) $f['form_id'] && (int) $f['form_delete']) {
625
- $deleteIds[] = (int) $f['form_id'];
626
- continue;
627
- }
628
-
629
- $f['sort'] = $sort++;
630
- $f['quizId'] = $quizId;
631
-
632
- if($f['type'] == WpProQuiz_Model_Form::FORM_TYPE_SELECT || $f['type'] == WpProQuiz_Model_Form::FORM_TYPE_RADIO) {
633
- if(!empty($f['data'])) {
634
- $items = explode("\n", $f['data']);
635
- $f['data'] = array();
636
-
637
- foreach ($items as $item) {
638
- $item = trim($item);
639
-
640
- if(!empty($item))
641
- $f['data'][] = $item;
642
- }
643
- }
644
- }
645
-
646
- if(empty($f['data']) || !is_array($f['data']))
647
- $f['data'] = null;
648
-
649
- $forms[] = new WpProQuiz_Model_Form($f);
650
- }
651
-
652
- if(!empty($deleteIds))
653
- $formMapper->deleteForm($deleteIds, $quizId);
654
-
655
- $formMapper->update($forms);
656
-
657
- return !empty($forms);
658
- }
659
-
660
- private function deleteAction($id) {
661
- if(!current_user_can('wpProQuiz_delete_quiz')) {
662
- wp_die(__('You do not have sufficient permissions to access this page.'));
663
- }
664
-
665
- $m = new WpProQuiz_Model_QuizMapper();
666
-
667
- $m->deleteAll($id);
668
-
669
- WpProQuiz_View_View::admin_notices(__('Quiz deleted', 'wp-pro-quiz'), 'info');
670
-
671
- $this->showAction();
672
- }
673
-
674
- private function deleteMultiAction() {
675
- if(!current_user_can('wpProQuiz_delete_quiz')) {
676
- wp_die(__('You do not have sufficient permissions to access this page.'));
677
- }
678
-
679
- $m = new WpProQuiz_Model_QuizMapper();
680
-
681
- if(!empty($_POST['ids'])) {
682
- foreach($_POST['ids'] as $id) {
683
- $m->deleteAll($id);
684
- }
685
- }
686
-
687
- WpProQuiz_View_View::admin_notices(__('Quiz deleted', 'wp-pro-quiz'), 'info');
688
-
689
- $this->showAction();
690
- }
691
-
692
- private function checkValidit($post) {
693
- return (isset($post['name']) && !empty($post['name']) && isset($post['text']) && !empty($post['text']));
694
- }
695
-
696
- private function filterResultTextGrade($post) {
697
- $activ = array_keys($post['resultTextGrade']['activ'], '1');
698
- $result = array();
699
-
700
- foreach($activ as $k) {
701
- $result['text'][] = $post['resultTextGrade']['text'][$k];
702
- $result['prozent'][] = (float)str_replace(',', '.', $post['resultTextGrade']['prozent'][$k]);
703
- }
704
-
705
- return $result;
706
- }
707
-
708
- private function setResultCookie(WpProQuiz_Model_Quiz $quiz) {
709
- $prerequisite = new WpProQuiz_Model_PrerequisiteMapper();
710
-
711
- if(get_current_user_id() == 0 && $prerequisite->isQuizId($quiz->getId())) {
712
- $cookieData = array();
713
-
714
- if(isset($this->_cookie['wpProQuiz_result'])) {
715
- $d = json_decode($this->_cookie['wpProQuiz_result'], true);
716
-
717
- if($d !== null && is_array($d)) {
718
- $cookieData = $d;
719
- }
720
- }
721
-
722
- $cookieData[$quiz->getId()] = 1;
723
-
724
- $url = parse_url(get_bloginfo( 'url' ));
725
-
726
- setcookie('wpProQuiz_result', json_encode($cookieData), time() + 60*60*24*300, empty($url['path']) ? '/' : $url['path']);
727
- }
728
- }
729
-
730
- public function completedQuiz() {
731
-
732
- $lockMapper = new WpProQuiz_Model_LockMapper();
733
- $quizMapper = new WpProQuiz_Model_QuizMapper();
734
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
735
- $formMapper = new WpProQuiz_Model_FormMapper();
736
-
737
- $is100P = $this->_post['results']['comp']['result'] == 100;
738
-
739
- $userId = get_current_user_id();
740
-
741
- $quiz = $quizMapper->fetch($this->_post['quizId']);
742
-
743
- if($quiz === null || $quiz->getId() <= 0) {
744
- exit;
745
- }
746
-
747
- $categories = $categoryMapper->fetchByQuiz($quiz->getId());
748
- $forms = $formMapper->fetch($quiz->getId());
749
-
750
- $this->setResultCookie($quiz);
751
-
752
- $this->emailNote($quiz, $this->_post['results']['comp'], $categories, $forms,
753
- isset($this->_post['forms']) ? $this->_post['forms'] : array());
754
-
755
- if(!$this->isPreLockQuiz($quiz)) {
756
- $statistics = new WpProQuiz_Controller_Statistics();
757
- $statistics->save($quiz);
758
-
759
- do_action('wp_pro_quiz_completed_quiz');
760
-
761
- if($is100P)
762
- do_action('wp_pro_quiz_completed_quiz_100_percent');
763
-
764
- exit;
765
- }
766
-
767
- $lockMapper->deleteOldLock(60*60*24*7, $this->_post['quizId'], time(), WpProQuiz_Model_Lock::TYPE_QUIZ, 0);
768
-
769
- $lockIp = $lockMapper->isLock($this->_post['quizId'], $this->getIp(), get_current_user_id(), WpProQuiz_Model_Lock::TYPE_QUIZ);
770
- $lockCookie = false;
771
- $cookieTime = $quiz->getQuizRunOnceTime();
772
- $cookieJson = null;
773
-
774
- if(isset($this->_cookie['wpProQuiz_lock']) && get_current_user_id() == 0 && $quiz->isQuizRunOnceCookie()) {
775
- $cookieJson = json_decode($this->_cookie['wpProQuiz_lock'], true);
776
-
777
- if($cookieJson !== false) {
778
- if(isset($cookieJson[$this->_post['quizId']]) && $cookieJson[$this->_post['quizId']] == $cookieTime) {
779
- $lockCookie = true;
780
- }
781
- }
782
- }
783
-
784
- if(!$lockIp && !$lockCookie) {
785
- $statistics = new WpProQuiz_Controller_Statistics();
786
- $statistics->save($quiz);
787
-
788
- do_action('wp_pro_quiz_completed_quiz');
789
-
790
- if($is100P)
791
- do_action('wp_pro_quiz_completed_quiz_100_percent');
792
-
793
- if(get_current_user_id() == 0 && $quiz->isQuizRunOnceCookie()) {
794
- $cookieData = array();
795
-
796
- if($cookieJson !== null || $cookieJson !== false) {
797
- $cookieData = $cookieJson;
798
- }
799
-
800
- $cookieData[$this->_post['quizId']] = $quiz->getQuizRunOnceTime();
801
- $url = parse_url(get_bloginfo( 'url' ));
802
-
803
- setcookie('wpProQuiz_lock', json_encode($cookieData), time() + 60*60*24*60, empty($url['path']) ? '/' : $url['path']);
804
- }
805
-
806
- $lock = new WpProQuiz_Model_Lock();
807
-
808
- $lock->setUserId(get_current_user_id());
809
- $lock->setQuizId($this->_post['quizId']);
810
- $lock->setLockDate(time());
811
- $lock->setLockIp($this->getIp());
812
- $lock->setLockType(WpProQuiz_Model_Lock::TYPE_QUIZ);
813
-
814
- $lockMapper->insert($lock);
815
- }
816
-
817
- exit;
818
- }
819
-
820
- public function isPreLockQuiz(WpProQuiz_Model_Quiz $quiz) {
821
- $userId = get_current_user_id();
822
-
823
- if($quiz->isQuizRunOnce()) {
824
- switch ($quiz->getQuizRunOnceType()) {
825
- case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ALL:
826
- return true;
827
- case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ONLY_USER:
828
- return $userId > 0;
829
- case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ONLY_ANONYM:
830
- return $userId == 0;
831
- }
832
- }
833
-
834
- return false;
835
- }
836
-
837
- private function getIp() {
838
- if(get_current_user_id() > 0)
839
- return '0';
840
- else
841
- return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
842
- }
843
-
844
- private function emailNote(WpProQuiz_Model_Quiz $quiz, $result, $categories, $forms, $inputForms) {
845
- $user = wp_get_current_user();
846
-
847
- $r = array(
848
- '$userId' => $user->ID,
849
- '$username' => $user->display_name,
850
- '$quizname' => $quiz->getName(),
851
- '$result' => $result['result'].'%',
852
- '$points' => $result['points'],
853
- '$ip' => filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP),
854
- '$categories' => empty($result['cats']) ? '' : $this->setCategoryOverview($result['cats'], $categories)
855
- );
856
-
857
- if($quiz->isFormActivated() && $forms !== null) {
858
- foreach($forms as $form) {
859
- $value = '';
860
-
861
- if($form->getType() == WpProQuiz_Model_Form::FORM_TYPE_DATE) {
862
- if(isset($inputForms[$form->getFormId()]))
863
- $value = $inputForms[$form->getFormId()]['day'].'-'.$inputForms[$form->getFormId()]['month']
864
- .'-'.$inputForms[$form->getFormId()]['year'];
865
- } else {
866
- $value = isset($inputForms[$form->getFormId()]) ? $inputForms[$form->getFormId()] : '';
867
- }
868
-
869
- $r['$form{'.$form->getSort().'}'] = esc_html($value);
870
- }
871
- }
872
-
873
- if($user->ID == 0) {
874
- $r['$username'] = $r['$ip'];
875
- }
876
-
877
- if($quiz->isUserEmailNotification()) {
878
- $userEmail = $quiz->getUserEmail();
879
-
880
- $userAdress = null;
881
-
882
- if($userEmail->isToUser() && get_current_user_id() > 0) {
883
- $userAdress = $user->user_email;
884
- } else if($userEmail->isToForm() && $quiz->isFormActivated()) {
885
- foreach($forms as $form) {
886
- if($form->getSort() == $userEmail->getTo()) {
887
- if(isset($inputForms[$form->getFormId()])) {
888
- $userAdress = $inputForms[$form->getFormId()];
889
- }
890
-
891
- break;
892
- }
893
- }
894
- }
895
-
896
- if(!empty($userAdress) && filter_var($userAdress, FILTER_VALIDATE_EMAIL) !== false) {
897
- $msg = str_replace(array_keys($r), $r, $userEmail->getMessage());
898
-
899
- $headers = '';
900
- $email = $userEmail->getFrom();
901
-
902
- if(!empty($email)) {
903
- $headers = 'From: '.$userEmail->getFrom();
904
- }
905
-
906
- if($userEmail->isHtml())
907
- add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
908
-
909
- wp_mail($userAdress, $userEmail->getSubject(), $msg, $headers);
910
-
911
- if($userEmail->isHtml())
912
- remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
913
- }
914
- }
915
-
916
- if($quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL
917
- || (get_current_user_id() > 0 && $quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER)) {
918
-
919
- $adminEmail = $quiz->getAdminEmail();
920
-
921
- $msg = str_replace(array_keys($r), $r, $adminEmail->getMessage());
922
-
923
- $headers = '';
924
- $email = $adminEmail->getFrom();
925
-
926
- if(!empty($email)) {
927
- $headers = 'From: '.$adminEmail->getFrom();
928
- }
929
-
930
- if($adminEmail->isHtml())
931
- add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
932
-
933
- wp_mail($adminEmail->getTo(), $adminEmail->getSubject(), $msg, $headers);
934
-
935
- if($adminEmail->isHtml())
936
- remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
937
- }
938
- }
939
-
940
- public function htmlEmailContent($contentType) {
941
- return 'text/html';
942
- }
943
-
944
- private function setCategoryOverview($catArray, $categories) {
945
- $cats = array();
946
-
947
- foreach($categories as $cat) {
948
- /* @var $cat WpProQuiz_Model_Category */
949
-
950
- if(!$cat->getCategoryId()) {
951
- $cat->setCategoryName(__('Not categorized', 'wp-pro-quiz'));
952
- }
953
-
954
- $cats[$cat->getCategoryId()] = $cat->getCategoryName();
955
- }
956
-
957
- $a = __('Categories', 'wp-pro-quiz').":\n";
958
-
959
- foreach($catArray as $id => $value) {
960
- if(!isset($cats[$id]))
961
- continue;
962
-
963
- $a .= '* '.str_pad($cats[$id], 35, '.').((float)$value)."%\n";
964
- }
965
-
966
- return $a;
967
- }
968
-
969
- public static function ajaxSetQuizMultipleCategories($data, $func) {
970
- if(!current_user_can('wpProQuiz_edit_quiz')) {
971
- return json_encode(array());
972
- }
973
-
974
- $quizMapper = new WpProQuiz_Model_QuizMapper();
975
-
976
- $quizMapper->setMultipeCategories($data['quizIds'], $data['categoryId']);
977
-
978
- return json_encode(array());
979
- }
980
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Quiz extends WpProQuiz_Controller_Controller
4
+ {
5
+ public function route()
6
+ {
7
+ $action = isset($_GET['action']) ? $_GET['action'] : 'show';
8
+
9
+ switch ($action) {
10
+ case 'show':
11
+ $this->showAction();
12
+ break;
13
+ case 'addEdit':
14
+ $this->addEditQuiz();
15
+ break;
16
+ case 'delete':
17
+ if (isset($_GET['id'])) {
18
+ $this->deleteAction($_GET['id']);
19
+ }
20
+ break;
21
+ case 'deleteMulti':
22
+ $this->deleteMultiAction();
23
+ break;
24
+ default:
25
+ $this->showAction();
26
+ break;
27
+ }
28
+ }
29
+
30
+ public function routeAction()
31
+ {
32
+ $action = isset($_GET['action']) ? $_GET['action'] : 'show';
33
+
34
+ switch ($action) {
35
+ default:
36
+ $this->showActionHook();
37
+ break;
38
+ }
39
+ }
40
+
41
+ private function showActionHook()
42
+ {
43
+ if (!empty($_REQUEST['_wp_http_referer'])) {
44
+ wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
45
+ exit;
46
+ }
47
+
48
+ if (!class_exists('WP_List_Table')) {
49
+ require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
50
+ }
51
+
52
+ add_filter('manage_' . get_current_screen()->id . '_columns',
53
+ array('WpProQuiz_View_QuizOverallTable', 'getColumnDefs'));
54
+
55
+ add_screen_option('per_page', array(
56
+ 'label' => __('Quiz', 'wp-pro-quiz'),
57
+ 'default' => 20,
58
+ 'option' => 'wp_pro_quiz_quiz_overview_per_page'
59
+ ));
60
+ }
61
+
62
+ private function addEditQuiz()
63
+ {
64
+ $quizId = isset($_GET['quizId']) ? (int)$_GET['quizId'] : 0;
65
+
66
+ if ($quizId) {
67
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
68
+ wp_die(__('You do not have sufficient permissions to access this page.'));
69
+ }
70
+ } else {
71
+ if (!current_user_can('wpProQuiz_add_quiz')) {
72
+ wp_die(__('You do not have sufficient permissions to access this page.'));
73
+ }
74
+ }
75
+
76
+ $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
77
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
78
+ $formMapper = new WpProQuiz_Model_FormMapper();
79
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
80
+ $cateoryMapper = new WpProQuiz_Model_CategoryMapper();
81
+
82
+ $quiz = new WpProQuiz_Model_Quiz();
83
+ $forms = null;
84
+ $prerequisiteQuizList = array();
85
+
86
+ if ($quizId && $quizMapper->exists($quizId) == 0) {
87
+ WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
88
+
89
+ return;
90
+ }
91
+
92
+ if (isset($this->_post['template']) || (isset($this->_post['templateLoad']) && isset($this->_post['templateLoadId']))) {
93
+ if (isset($this->_post['template'])) {
94
+ $template = $this->saveTemplate();
95
+ } else {
96
+ $template = $templateMapper->fetchById($this->_post['templateLoadId']);
97
+ }
98
+
99
+ $data = $template->getData();
100
+
101
+ if ($data !== null) {
102
+ /** @var WpProQuiz_Model_Quiz $quiz */
103
+ $quiz = $data['quiz'];
104
+ $quiz->setId($quizId);
105
+
106
+ $forms = $data['forms'];
107
+ $prerequisiteQuizList = $data['prerequisiteQuizList'];
108
+ }
109
+ } else {
110
+ if (isset($this->_post['submit'])) {
111
+
112
+ if (isset($this->_post['resultGradeEnabled'])) {
113
+ $this->_post['result_text'] = $this->filterResultTextGrade($this->_post);
114
+ }
115
+
116
+ $this->_post['categoryId'] = $this->_post['category'] > 0 ? $this->_post['category'] : 0;
117
+
118
+ $this->_post['adminEmail'] = new WpProQuiz_Model_Email($this->_post['adminEmail']);
119
+ $this->_post['userEmail'] = new WpProQuiz_Model_Email($this->_post['userEmail']);
120
+
121
+ $quiz = new WpProQuiz_Model_Quiz($this->_post);
122
+ $quiz->setId($quizId);
123
+
124
+ if (isset($this->_post['plugin'])) {
125
+ $quiz->getPluginContainer()->set($this->_post['plugin']);
126
+ }
127
+
128
+ if ($this->checkValidit($this->_post)) {
129
+ if ($quizId) {
130
+ WpProQuiz_View_View::admin_notices(__('Quiz edited', 'wp-pro-quiz'), 'info');
131
+ } else {
132
+ WpProQuiz_View_View::admin_notices(__('quiz created', 'wp-pro-quiz'), 'info');
133
+ }
134
+
135
+ $quizMapper->save($quiz);
136
+
137
+ $quizId = $quiz->getId();
138
+
139
+ $prerequisiteMapper->delete($quizId);
140
+
141
+ if ($quiz->isPrerequisite() && !empty($this->_post['prerequisiteList'])) {
142
+ $prerequisiteMapper->save($quizId, $this->_post['prerequisiteList']);
143
+ $quizMapper->activateStatitic($this->_post['prerequisiteList'], 1440);
144
+ }
145
+
146
+ if (!$this->formHandler($quiz->getId(), $this->_post)) {
147
+ $quiz->setFormActivated(false);
148
+ $quizMapper->save($quiz);
149
+ }
150
+
151
+ $forms = $formMapper->fetch($quizId);
152
+ $prerequisiteQuizList = $prerequisiteMapper->fetchQuizIds($quizId);
153
+
154
+ } else {
155
+ WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled',
156
+ 'wp-pro-quiz'));
157
+ }
158
+ } else {
159
+ if ($quizId) {
160
+ $quiz = $quizMapper->fetch($quizId);
161
+ $forms = $formMapper->fetch($quizId);
162
+ $prerequisiteQuizList = $prerequisiteMapper->fetchQuizIds($quizId);
163
+ }
164
+ }
165
+ }
166
+
167
+ $view = new WpProQuiz_View_QuizEdit();
168
+
169
+ $view->quiz = $quiz;
170
+ $view->forms = $forms;
171
+ $view->prerequisiteQuizList = $prerequisiteQuizList;
172
+ $view->templates = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false);
173
+ $view->quizList = $quizMapper->fetchAllAsArray(array('id', 'name'), $quizId ? array($quizId) : array());
174
+ $view->captchaIsInstalled = class_exists('ReallySimpleCaptcha');
175
+ $view->categories = $cateoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);
176
+
177
+ $view->header = $quizId ? __('Edit quiz', 'wp-pro-quiz') : __('Create quiz', 'wp-pro-quiz');
178
+
179
+ $view->show();
180
+ }
181
+
182
+ public function isLockQuiz()
183
+ {
184
+ $quizId = (int)$this->_post['quizId'];
185
+ $userId = get_current_user_id();
186
+ $data = array();
187
+
188
+ $lockMapper = new WpProQuiz_Model_LockMapper();
189
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
190
+ $prerequisiteMapper = new WpProQuiz_Model_PrerequisiteMapper();
191
+
192
+ $quiz = $quizMapper->fetch($this->_post['quizId']);
193
+
194
+ if ($quiz === null || $quiz->getId() <= 0) {
195
+ return null;
196
+ }
197
+
198
+ if ($this->isPreLockQuiz($quiz)) {
199
+ $lockIp = $lockMapper->isLock($this->_post['quizId'], $this->getIp(), $userId,
200
+ WpProQuiz_Model_Lock::TYPE_QUIZ);
201
+ $lockCookie = false;
202
+ $cookieTime = $quiz->getQuizRunOnceTime();
203
+
204
+ if (isset($this->_cookie['wpProQuiz_lock']) && $userId == 0 && $quiz->isQuizRunOnceCookie()) {
205
+ $cookieJson = json_decode($this->_cookie['wpProQuiz_lock'], true);
206
+
207
+ if ($cookieJson !== false) {
208
+ if (isset($cookieJson[$this->_post['quizId']]) && $cookieJson[$this->_post['quizId']] == $cookieTime) {
209
+ $lockCookie = true;
210
+ }
211
+ }
212
+ }
213
+
214
+ $data['lock'] = array(
215
+ 'is' => ($lockIp || $lockCookie),
216
+ 'pre' => true
217
+ );
218
+ }
219
+
220
+ if ($quiz->isPrerequisite()) {
221
+ $quizIds = array();
222
+
223
+ if ($userId > 0) {
224
+ $quizIds = $prerequisiteMapper->getNoPrerequisite($quizId, $userId);
225
+ } else {
226
+ $checkIds = $prerequisiteMapper->fetchQuizIds($quizId);
227
+
228
+ if (isset($this->_cookie['wpProQuiz_result'])) {
229
+ $r = json_decode($this->_cookie['wpProQuiz_result'], true);
230
+
231
+ if ($r !== null && is_array($r)) {
232
+ foreach ($checkIds as $id) {
233
+ if (!isset($r[$id]) || !$r[$id]) {
234
+ $quizIds[] = $id;
235
+ }
236
+ }
237
+ }
238
+ } else {
239
+ $quizIds = $checkIds;
240
+ }
241
+ }
242
+
243
+ if (!empty($quizIds)) {
244
+ $names = $quizMapper->fetchCol($quizIds, 'name');
245
+
246
+ if (!empty($names)) {
247
+ $data['prerequisite'] = implode(', ', $names);
248
+ }
249
+ }
250
+
251
+ }
252
+
253
+ if ($quiz->isStartOnlyRegisteredUser()) {
254
+ $data['startUserLock'] = (int)!is_user_logged_in();
255
+ }
256
+
257
+ return $data;
258
+ }
259
+
260
+ private function getCurrentPage()
261
+ {
262
+ $pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0;
263
+
264
+ return max(1, $pagenum);
265
+ }
266
+
267
+ private function showAction()
268
+ {
269
+ if (!current_user_can('wpProQuiz_show')) {
270
+ wp_die(__('You do not have sufficient permissions to access this page.'));
271
+ }
272
+
273
+ $view = new WpProQuiz_View_QuizOverall();
274
+
275
+ $m = new WpProQuiz_Model_QuizMapper();
276
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
277
+
278
+ $per_page = (int)get_user_option('wp_pro_quiz_quiz_overview_per_page');
279
+ if (empty($per_page) || $per_page < 1) {
280
+ $per_page = 20;
281
+ }
282
+
283
+ $current_page = $this->getCurrentPage();
284
+ $search = isset($_GET['s']) ? trim($_GET['s']) : '';
285
+ $orderBy = isset($_GET['orderby']) ? trim($_GET['orderby']) : '';
286
+ $order = isset($_GET['order']) ? trim($_GET['order']) : '';
287
+ $offset = ($current_page - 1) * $per_page;
288
+ $limit = $per_page;
289
+ $filter = array();
290
+
291
+ if (isset($_GET['cat'])) {
292
+ $filter['cat'] = $_GET['cat'];
293
+ }
294
+
295
+ $result = $m->fetchTable($orderBy, $order, $search, $limit, $offset, $filter);
296
+
297
+ $view->quizItems = $result['quiz'];
298
+ $view->quizCount = $result['count'];
299
+ $view->categoryItems = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);;
300
+ $view->perPage = $per_page;
301
+
302
+ $view->show();
303
+ }
304
+
305
+ private function saveTemplate()
306
+ {
307
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
308
+
309
+ if (isset($this->_post['resultGradeEnabled'])) {
310
+ $this->_post['result_text'] = $this->filterResultTextGrade($this->_post);
311
+ }
312
+
313
+ $this->_post['categoryId'] = $this->_post['category'] > 0 ? $this->_post['category'] : 0;
314
+
315
+ $this->_post['adminEmail'] = new WpProQuiz_Model_Email($this->_post['adminEmail']);
316
+ $this->_post['userEmail'] = new WpProQuiz_Model_Email($this->_post['userEmail']);
317
+
318
+ $quiz = new WpProQuiz_Model_Quiz($this->_post);
319
+
320
+ if ($quiz->isPrerequisite() && !empty($this->_post['prerequisiteList']) && !$quiz->isStatisticsOn()) {
321
+ $quiz->setStatisticsOn(true);
322
+ $quiz->setStatisticsIpLock(1440);
323
+ }
324
+
325
+ $form = $this->_post['form'];
326
+
327
+ unset($form[0]);
328
+
329
+ $forms = array();
330
+
331
+ foreach ($form as $f) {
332
+ $f['fieldname'] = trim($f['fieldname']);
333
+
334
+ if (empty($f['fieldname'])) {
335
+ continue;
336
+ }
337
+
338
+ if ((int)$f['form_id'] && (int)$f['form_delete']) {
339
+ continue;
340
+ }
341
+
342
+ if ($f['type'] == WpProQuiz_Model_Form::FORM_TYPE_SELECT || $f['type'] == WpProQuiz_Model_Form::FORM_TYPE_RADIO) {
343
+ if (!empty($f['data'])) {
344
+ $items = explode("\n", $f['data']);
345
+ $f['data'] = array();
346
+
347
+ foreach ($items as $item) {
348
+ $item = trim($item);
349
+
350
+ if (!empty($item)) {
351
+ $f['data'][] = $item;
352
+ }
353
+ }
354
+ }
355
+ }
356
+
357
+ if (empty($f['data']) || !is_array($f['data'])) {
358
+ $f['data'] = null;
359
+ }
360
+
361
+ $forms[] = new WpProQuiz_Model_Form($f);
362
+ }
363
+
364
+ WpProQuiz_View_View::admin_notices(__('Template stored', 'wp-pro-quiz'), 'info');
365
+
366
+ $data = array(
367
+ 'quiz' => $quiz,
368
+ 'forms' => $forms,
369
+ 'prerequisiteQuizList' => isset($this->_post['prerequisiteList']) ? $this->_post['prerequisiteList'] : array()
370
+ );
371
+
372
+ $template = new WpProQuiz_Model_Template();
373
+
374
+ if ($this->_post['templateSaveList'] == '0') {
375
+ $template->setName(trim($this->_post['templateName']));
376
+ } else {
377
+ $template = $templateMapper->fetchById($this->_post['templateSaveList'], false);
378
+ }
379
+
380
+ $template->setType(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ);
381
+ $template->setData($data);
382
+
383
+ $templateMapper->save($template);
384
+
385
+ return $template;
386
+ }
387
+
388
+ private function formHandler($quizId, $post)
389
+ {
390
+ if (!isset($post['form'])) {
391
+ return false;
392
+ }
393
+
394
+ $form = $post['form'];
395
+
396
+ unset($form[0]);
397
+
398
+ if (empty($form)) {
399
+ return false;
400
+ }
401
+
402
+ $formMapper = new WpProQuiz_Model_FormMapper();
403
+
404
+ $deleteIds = array();
405
+ $forms = array();
406
+ $sort = 0;
407
+
408
+ foreach ($form as $f) {
409
+ $f['fieldname'] = trim($f['fieldname']);
410
+
411
+ if (empty($f['fieldname'])) {
412
+ continue;
413
+ }
414
+
415
+ if ((int)$f['form_id'] && (int)$f['form_delete']) {
416
+ $deleteIds[] = (int)$f['form_id'];
417
+ continue;
418
+ }
419
+
420
+ $f['sort'] = $sort++;
421
+ $f['quizId'] = $quizId;
422
+
423
+ if ($f['type'] == WpProQuiz_Model_Form::FORM_TYPE_SELECT || $f['type'] == WpProQuiz_Model_Form::FORM_TYPE_RADIO) {
424
+ if (!empty($f['data'])) {
425
+ $items = explode("\n", $f['data']);
426
+ $f['data'] = array();
427
+
428
+ foreach ($items as $item) {
429
+ $item = trim($item);
430
+
431
+ if (!empty($item)) {
432
+ $f['data'][] = $item;
433
+ }
434
+ }
435
+ }
436
+ }
437
+
438
+ if (empty($f['data']) || !is_array($f['data'])) {
439
+ $f['data'] = null;
440
+ }
441
+
442
+ $forms[] = new WpProQuiz_Model_Form($f);
443
+ }
444
+
445
+ if (!empty($deleteIds)) {
446
+ $formMapper->deleteForm($deleteIds, $quizId);
447
+ }
448
+
449
+ $formMapper->update($forms);
450
+
451
+ return !empty($forms);
452
+ }
453
+
454
+ private function deleteAction($id)
455
+ {
456
+ if (!current_user_can('wpProQuiz_delete_quiz')) {
457
+ wp_die(__('You do not have sufficient permissions to access this page.'));
458
+ }
459
+
460
+ $m = new WpProQuiz_Model_QuizMapper();
461
+
462
+ $m->deleteAll($id);
463
+
464
+ WpProQuiz_View_View::admin_notices(__('Quiz deleted', 'wp-pro-quiz'), 'info');
465
+
466
+ $this->showAction();
467
+ }
468
+
469
+ private function deleteMultiAction()
470
+ {
471
+ if (!current_user_can('wpProQuiz_delete_quiz')) {
472
+ wp_die(__('You do not have sufficient permissions to access this page.'));
473
+ }
474
+
475
+ $m = new WpProQuiz_Model_QuizMapper();
476
+
477
+ if (!empty($_POST['ids'])) {
478
+ foreach ($_POST['ids'] as $id) {
479
+ $m->deleteAll($id);
480
+ }
481
+ }
482
+
483
+ WpProQuiz_View_View::admin_notices(__('Quiz deleted', 'wp-pro-quiz'), 'info');
484
+
485
+ $this->showAction();
486
+ }
487
+
488
+ private function checkValidit($post)
489
+ {
490
+ return (isset($post['name']) && !empty($post['name']) && isset($post['text']) && !empty($post['text']));
491
+ }
492
+
493
+ private function filterResultTextGrade($post)
494
+ {
495
+ $activ = array_keys($post['resultTextGrade']['activ'], '1');
496
+ $result = array();
497
+
498
+ foreach ($activ as $k) {
499
+ $result['text'][] = $post['resultTextGrade']['text'][$k];
500
+ $result['prozent'][] = (float)str_replace(',', '.', $post['resultTextGrade']['prozent'][$k]);
501
+ }
502
+
503
+ return $result;
504
+ }
505
+
506
+ private function setResultCookie(WpProQuiz_Model_Quiz $quiz)
507
+ {
508
+ $prerequisite = new WpProQuiz_Model_PrerequisiteMapper();
509
+
510
+ if (get_current_user_id() == 0 && $prerequisite->isQuizId($quiz->getId())) {
511
+ $cookieData = array();
512
+
513
+ if (isset($this->_cookie['wpProQuiz_result'])) {
514
+ $d = json_decode($this->_cookie['wpProQuiz_result'], true);
515
+
516
+ if ($d !== null && is_array($d)) {
517
+ $cookieData = $d;
518
+ }
519
+ }
520
+
521
+ $cookieData[$quiz->getId()] = 1;
522
+
523
+ $url = parse_url(get_bloginfo('url'));
524
+
525
+ setcookie('wpProQuiz_result', json_encode($cookieData), time() + 60 * 60 * 24 * 300,
526
+ empty($url['path']) ? '/' : $url['path']);
527
+ }
528
+ }
529
+
530
+ public function isPreLockQuiz(WpProQuiz_Model_Quiz $quiz)
531
+ {
532
+ $userId = get_current_user_id();
533
+
534
+ if ($quiz->isQuizRunOnce()) {
535
+ switch ($quiz->getQuizRunOnceType()) {
536
+ case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ALL:
537
+ return true;
538
+ case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ONLY_USER:
539
+ return $userId > 0;
540
+ case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ONLY_ANONYM:
541
+ return $userId == 0;
542
+ }
543
+ }
544
+
545
+ return false;
546
+ }
547
+
548
+ private function getIp()
549
+ {
550
+ if (get_current_user_id() > 0) {
551
+ return '0';
552
+ } else {
553
+ return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
554
+ }
555
+ }
556
+
557
+ /**
558
+ * @param WpProQuiz_Model_Quiz $quiz
559
+ * @param $result
560
+ * @param WpProQuiz_Model_Category[] $categories
561
+ * @param WpProQuiz_Model_Form[] $forms
562
+ * @param $inputForms
563
+ */
564
+ private function emailNote(WpProQuiz_Model_Quiz $quiz, $result, $categories, $forms, $inputForms)
565
+ {
566
+ $user = wp_get_current_user();
567
+
568
+ $r = array(
569
+ '$userId' => $user->ID,
570
+ '$username' => $user->display_name,
571
+ '$quizname' => $quiz->getName(),
572
+ '$result' => $result['result'] . '%',
573
+ '$points' => $result['points'],
574
+ '$ip' => filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP),
575
+ '$categories' => empty($result['cats']) ? '' : $this->setCategoryOverview($result['cats'], $categories)
576
+ );
577
+
578
+ if ($quiz->isFormActivated() && $forms !== null) {
579
+ foreach ($forms as $form) {
580
+ $value = '';
581
+
582
+ if ($form->getType() == WpProQuiz_Model_Form::FORM_TYPE_DATE) {
583
+ if (isset($inputForms[$form->getFormId()])) {
584
+ $value = $inputForms[$form->getFormId()]['day'] . '-' . $inputForms[$form->getFormId()]['month']
585
+ . '-' . $inputForms[$form->getFormId()]['year'];
586
+ }
587
+ } else {
588
+ $value = isset($inputForms[$form->getFormId()]) ? $inputForms[$form->getFormId()] : '';
589
+ }
590
+
591
+ $r['$form{' . $form->getSort() . '}'] = esc_html($value);
592
+ }
593
+ }
594
+
595
+ if ($user->ID == 0) {
596
+ $r['$username'] = $r['$ip'];
597
+ }
598
+
599
+ if ($quiz->isUserEmailNotification()) {
600
+ $userEmail = $quiz->getUserEmail();
601
+
602
+ $userAdress = null;
603
+
604
+ if ($userEmail->isToUser() && get_current_user_id() > 0) {
605
+ $userAdress = $user->user_email;
606
+ } else {
607
+ if ($userEmail->isToForm() && $quiz->isFormActivated()) {
608
+ foreach ($forms as $form) {
609
+ if ($form->getSort() == $userEmail->getTo()) {
610
+ if (isset($inputForms[$form->getFormId()])) {
611
+ $userAdress = $inputForms[$form->getFormId()];
612
+ }
613
+
614
+ break;
615
+ }
616
+ }
617
+ }
618
+ }
619
+
620
+ if (!empty($userAdress) && filter_var($userAdress, FILTER_VALIDATE_EMAIL) !== false) {
621
+ $msg = str_replace(array_keys($r), $r, $userEmail->getMessage());
622
+
623
+ $headers = '';
624
+ $email = $userEmail->getFrom();
625
+
626
+ if (!empty($email)) {
627
+ $headers = 'From: ' . $userEmail->getFrom();
628
+ }
629
+
630
+ if ($userEmail->isHtml()) {
631
+ add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
632
+ }
633
+
634
+ wp_mail($userAdress, $userEmail->getSubject(), $msg, $headers);
635
+
636
+ if ($userEmail->isHtml()) {
637
+ remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
638
+ }
639
+ }
640
+ }
641
+
642
+ if ($quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL
643
+ || (get_current_user_id() > 0 && $quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER)
644
+ ) {
645
+
646
+ $adminEmail = $quiz->getAdminEmail();
647
+
648
+ $msg = str_replace(array_keys($r), $r, $adminEmail->getMessage());
649
+
650
+ $headers = '';
651
+ $email = $adminEmail->getFrom();
652
+
653
+ if (!empty($email)) {
654
+ $headers = 'From: ' . $adminEmail->getFrom();
655
+ }
656
+
657
+ if ($adminEmail->isHtml()) {
658
+ add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
659
+ }
660
+
661
+ wp_mail($adminEmail->getTo(), $adminEmail->getSubject(), $msg, $headers);
662
+
663
+ if ($adminEmail->isHtml()) {
664
+ remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
665
+ }
666
+ }
667
+ }
668
+
669
+ public function htmlEmailContent()
670
+ {
671
+ return 'text/html';
672
+ }
673
+
674
+ private function setCategoryOverview($catArray, $categories)
675
+ {
676
+ $cats = array();
677
+
678
+ foreach ($categories as $cat) {
679
+ /* @var $cat WpProQuiz_Model_Category */
680
+
681
+ if (!$cat->getCategoryId()) {
682
+ $cat->setCategoryName(__('Not categorized', 'wp-pro-quiz'));
683
+ }
684
+
685
+ $cats[$cat->getCategoryId()] = $cat->getCategoryName();
686
+ }
687
+
688
+ $a = __('Categories', 'wp-pro-quiz') . ":\n";
689
+
690
+ foreach ($catArray as $id => $value) {
691
+ if (!isset($cats[$id])) {
692
+ continue;
693
+ }
694
+
695
+ $a .= '* ' . str_pad($cats[$id], 35, '.') . ((float)$value) . "%\n";
696
+ }
697
+
698
+ return $a;
699
+ }
700
+
701
+ public static function ajaxSetQuizMultipleCategories($data)
702
+ {
703
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
704
+ return json_encode(array());
705
+ }
706
+
707
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
708
+
709
+ $quizMapper->setMultipeCategories($data['quizIds'], $data['categoryId']);
710
+
711
+ return json_encode(array());
712
+ }
713
+
714
+ public static function ajaxLoadQuizData($data)
715
+ {
716
+ $quizId = (int)$data['quizId'];
717
+
718
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
719
+ $toplistController = new WpProQuiz_Controller_Toplist();
720
+ $statisticController = new WpProQuiz_Controller_Statistics();
721
+
722
+ $quiz = $quizMapper->fetch($quizId);
723
+ $data = array();
724
+
725
+ if ($quiz === null || $quiz->getId() <= 0) {
726
+ return json_encode(array());
727
+ }
728
+
729
+ $data['toplist'] = $toplistController->getAddToplist($quiz);
730
+ $data['averageResult'] = $statisticController->getAverageResult($quizId);
731
+
732
+ return json_encode($data);
733
+ }
734
+
735
+ public static function ajaxQuizCheckLock()
736
+ {
737
+ // workaround ...
738
+ $_POST = $_POST['data'];
739
+
740
+ $quizController = new WpProQuiz_Controller_Quiz();
741
+
742
+ return json_encode($quizController->isLockQuiz());
743
+ }
744
+
745
+ public static function ajaxResetLock($data)
746
+ {
747
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
748
+ return json_encode(array());
749
+ }
750
+
751
+ $quizId = (int)$data['quizId'];
752
+
753
+ $lm = new WpProQuiz_Model_LockMapper();
754
+ $qm = new WpProQuiz_Model_QuizMapper();
755
+
756
+ $q = $qm->fetch($quizId);
757
+
758
+ if ($q->getId() > 0) {
759
+ $q->setQuizRunOnceTime(time());
760
+
761
+ $qm->save($q);
762
+
763
+ $lm->deleteByQuizId($quizId, WpProQuiz_Model_Lock::TYPE_QUIZ);
764
+ }
765
+
766
+ return json_encode(array());
767
+ }
768
+
769
+ public static function ajaxCompletedQuiz($data)
770
+ {
771
+ // workaround ...
772
+ $_POST = $_POST['data'];
773
+
774
+ $ctr = new WpProQuiz_Controller_Quiz();
775
+
776
+ $lockMapper = new WpProQuiz_Model_LockMapper();
777
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
778
+ $categoryMapper = new WpProQuiz_Model_CategoryMapper();
779
+ $formMapper = new WpProQuiz_Model_FormMapper();
780
+
781
+ $is100P = $data['results']['comp']['result'] == 100;
782
+
783
+ $quiz = $quizMapper->fetch($data['quizId']);
784
+
785
+ if ($quiz === null || $quiz->getId() <= 0) {
786
+ return json_encode(array());
787
+ }
788
+
789
+ $categories = $categoryMapper->fetchByQuiz($quiz->getId());
790
+ $forms = $formMapper->fetch($quiz->getId());
791
+
792
+ $ctr->setResultCookie($quiz);
793
+
794
+ $ctr->emailNote($quiz, $data['results']['comp'], $categories, $forms,
795
+ isset($data['forms']) ? $data['forms'] : array());
796
+
797
+ if (!$ctr->isPreLockQuiz($quiz)) {
798
+ $statistics = new WpProQuiz_Controller_Statistics();
799
+ $statistics->save($quiz);
800
+
801
+ do_action('wp_pro_quiz_completed_quiz');
802
+
803
+ if ($is100P) {
804
+ do_action('wp_pro_quiz_completed_quiz_100_percent');
805
+ }
806
+
807
+ return json_encode(array());
808
+ }
809
+
810
+ $lockMapper->deleteOldLock(60 * 60 * 24 * 7, $data['quizId'], time(), WpProQuiz_Model_Lock::TYPE_QUIZ,
811
+ 0);
812
+
813
+ $lockIp = $lockMapper->isLock($data['quizId'], $ctr->getIp(), get_current_user_id(),
814
+ WpProQuiz_Model_Lock::TYPE_QUIZ);
815
+ $lockCookie = false;
816
+ $cookieTime = $quiz->getQuizRunOnceTime();
817
+ $cookieJson = null;
818
+
819
+ if (isset($ctr->_cookie['wpProQuiz_lock']) && get_current_user_id() == 0 && $quiz->isQuizRunOnceCookie()) {
820
+ $cookieJson = json_decode($ctr->_cookie['wpProQuiz_lock'], true);
821
+
822
+ if ($cookieJson !== false) {
823
+ if (isset($cookieJson[$data['quizId']]) && $cookieJson[$data['quizId']] == $cookieTime) {
824
+ $lockCookie = true;
825
+ }
826
+ }
827
+ }
828
+
829
+ if (!$lockIp && !$lockCookie) {
830
+ $statistics = new WpProQuiz_Controller_Statistics();
831
+ $statistics->save($quiz);
832
+
833
+ do_action('wp_pro_quiz_completed_quiz');
834
+
835
+ if ($is100P) {
836
+ do_action('wp_pro_quiz_completed_quiz_100_percent');
837
+ }
838
+
839
+ if (get_current_user_id() == 0 && $quiz->isQuizRunOnceCookie()) {
840
+ $cookieData = array();
841
+
842
+ if ($cookieJson !== null || $cookieJson !== false) {
843
+ $cookieData = $cookieJson;
844
+ }
845
+
846
+ $cookieData[$data['quizId']] = $quiz->getQuizRunOnceTime();
847
+ $url = parse_url(get_bloginfo('url'));
848
+
849
+ setcookie('wpProQuiz_lock', json_encode($cookieData), time() + 60 * 60 * 24 * 60,
850
+ empty($url['path']) ? '/' : $url['path']);
851
+ }
852
+
853
+ $lock = new WpProQuiz_Model_Lock();
854
+
855
+ $lock->setUserId(get_current_user_id());
856
+ $lock->setQuizId($data['quizId']);
857
+ $lock->setLockDate(time());
858
+ $lock->setLockIp($ctr->getIp());
859
+ $lock->setLockType(WpProQuiz_Model_Lock::TYPE_QUIZ);
860
+
861
+ $lockMapper->insert($lock);
862
+ }
863
+
864
+ return json_encode(array());
865
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
866
  }
lib/controller/WpProQuiz_Controller_QuizCompleted.php DELETED
@@ -1,231 +0,0 @@
1
- <?php
2
- class WpProQuiz_Controller_QuizCompleted {
3
-
4
- private $data = array();
5
-
6
- public function __construct($data) {
7
- $this->data = $data;
8
- }
9
-
10
- public static function ajaxQuizCompleted($data, $func) {
11
- $completed = new WpProQuiz_Controller_QuizCompleted($data);
12
-
13
- return $completed->quizCompleted();
14
- }
15
-
16
- public function quizCompleted() {
17
- $lockMapper = new WpProQuiz_Model_LockMapper();
18
- $quizMapper = new WpProQuiz_Model_QuizMapper();
19
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
20
-
21
- $statistics = new WpProQuiz_Controller_Statistics();
22
-
23
- $quiz = $quizMapper->fetch($this->data['quizId']);
24
-
25
- if($quiz === null || $quiz->getId() <= 0) {
26
- return;
27
- }
28
-
29
- $categories = $categoryMapper->fetchByQuiz($quiz->getId());
30
- $userId = get_current_user_id();
31
- $resultInPercent = floor($this->data['results']['comp']['result']);
32
-
33
-
34
- $this->setResultCookie($quiz);
35
- $this->emailNote($quiz, $this->data['results']['comp'], $categories);
36
-
37
- if(!$this->isPreLockQuiz($quiz)) {
38
- $statistics->save();
39
-
40
- do_action('wp_pro_quiz_completed_quiz');
41
- do_action('wp_pro_quiz_completed_quiz_'.$resultInPercent.'_percent');
42
-
43
- return;
44
- }
45
-
46
- $lockMapper->deleteOldLock(60*60*24*7, $this->_post['quizId'], time(), WpProQuiz_Model_Lock::TYPE_QUIZ, 0);
47
-
48
- $lockIp = $lockMapper->isLock($this->_post['quizId'], $this->getIp(), get_current_user_id(), WpProQuiz_Model_Lock::TYPE_QUIZ);
49
- $lockCookie = false;
50
- $cookieTime = $quiz->getQuizRunOnceTime();
51
- $cookieJson = null;
52
-
53
- if(isset($this->_cookie['wpProQuiz_lock']) && get_current_user_id() == 0 && $quiz->isQuizRunOnceCookie()) {
54
- $cookieJson = json_decode($this->_cookie['wpProQuiz_lock'], true);
55
-
56
- if($cookieJson !== false) {
57
- if(isset($cookieJson[$this->_post['quizId']]) && $cookieJson[$this->_post['quizId']] == $cookieTime) {
58
- $lockCookie = true;
59
- }
60
- }
61
- }
62
-
63
- if(!$lockIp && !$lockCookie) {
64
- $statistics->save();
65
-
66
- do_action('wp_pro_quiz_completed_quiz');
67
- do_action('wp_pro_quiz_completed_quiz_'.$resultInPercent.'_percent');
68
-
69
- if(get_current_user_id() == 0 && $quiz->isQuizRunOnceCookie()) {
70
- $cookieData = array();
71
-
72
- if($cookieJson !== null || $cookieJson !== false) {
73
- $cookieData = $cookieJson;
74
- }
75
-
76
- $cookieData[$this->_post['quizId']] = $quiz->getQuizRunOnceTime();
77
- $url = parse_url(get_bloginfo( 'url' ));
78
-
79
- setcookie('wpProQuiz_lock', json_encode($cookieData), time() + 60*60*24*60, empty($url['path']) ? '/' : $url['path']);
80
- }
81
-
82
- $lock = new WpProQuiz_Model_Lock();
83
-
84
- $lock->setUserId(get_current_user_id());
85
- $lock->setQuizId($this->_post['quizId']);
86
- $lock->setLockDate(time());
87
- $lock->setLockIp($this->getIp());
88
- $lock->setLockType(WpProQuiz_Model_Lock::TYPE_QUIZ);
89
-
90
- $lockMapper->insert($lock);
91
- }
92
-
93
- return;
94
- }
95
-
96
- private function setResultCookie(WpProQuiz_Model_Quiz $quiz) {
97
- $prerequisite = new WpProQuiz_Model_PrerequisiteMapper();
98
-
99
- if(get_current_user_id() == 0 && $prerequisite->isQuizId($quiz->getId())) {
100
- $cookieData = array();
101
-
102
- if(isset($this->_cookie['wpProQuiz_result'])) {
103
- $d = json_decode($this->_cookie['wpProQuiz_result'], true);
104
-
105
- if($d !== null && is_array($d)) {
106
- $cookieData = $d;
107
- }
108
- }
109
-
110
- $cookieData[$quiz->getId()] = 1;
111
-
112
- $url = parse_url(get_bloginfo( 'url' ));
113
-
114
- setcookie('wpProQuiz_result', json_encode($cookieData), time() + 60*60*24*300, empty($url['path']) ? '/' : $url['path']);
115
- }
116
- }
117
-
118
- private function emailNote(WpProQuiz_Model_Quiz $quiz, $result, $categories) {
119
- $globalMapper = new WpProQuiz_Model_GlobalSettingsMapper();
120
-
121
- $adminEmail = $globalMapper->getEmailSettings();
122
- $userEmail = $globalMapper->getUserEmailSettings();
123
-
124
- $user = wp_get_current_user();
125
-
126
- $r = array(
127
- '$userId' => $user->ID,
128
- '$username' => $user->display_name,
129
- '$quizname' => $quiz->getName(),
130
- '$result' => $result['result'].'%',
131
- '$points' => $result['points'],
132
- '$ip' => filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP),
133
- '$categories' => empty($result['cats']) ? '' : $this->setCategoryOverview($result['cats'], $categories)
134
- );
135
-
136
- if($user->ID == 0) {
137
- $r['$username'] = $r['$ip'];
138
- }
139
-
140
- if($quiz->isUserEmailNotification()) {
141
- $msg = str_replace(array_keys($r), $r, $userEmail['message']);
142
-
143
- $headers = '';
144
-
145
- if(!empty($userEmail['from'])) {
146
- $headers = 'From: '.$userEmail['from'];
147
- }
148
-
149
- if($userEmail['html'])
150
- add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
151
-
152
- wp_mail($user->user_email, $userEmail['subject'], $msg, $headers);
153
-
154
- if($userEmail['html'])
155
- remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
156
- }
157
-
158
- if($quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL
159
- || (get_current_user_id() > 0 && $quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER)) {
160
-
161
- $msg = str_replace(array_keys($r), $r, $adminEmail['message']);
162
-
163
- $headers = '';
164
-
165
- if(!empty($adminEmail['from'])) {
166
- $headers = 'From: '.$adminEmail['from'];
167
- }
168
-
169
- if(isset($adminEmail['html']) && $adminEmail['html'])
170
- add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
171
-
172
- wp_mail($adminEmail['to'], $adminEmail['subject'], $msg, $headers);
173
-
174
- if(isset($adminEmail['html']) && $adminEmail['html'])
175
- remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
176
- }
177
- }
178
-
179
- public function htmlEmailContent($contentType) {
180
- return 'text/html';
181
- }
182
-
183
- private function setCategoryOverview($catArray, $categories) {
184
- $cats = array();
185
-
186
- foreach($categories as $cat) {
187
- /* @var $cat WpProQuiz_Model_Category */
188
-
189
- if(!$cat->getCategoryId()) {
190
- $cat->setCategoryName(__('Not categorized', 'wp-pro-quiz'));
191
- }
192
-
193
- $cats[$cat->getCategoryId()] = $cat->getCategoryName();
194
- }
195
-
196
- $a = __('Categories', 'wp-pro-quiz').":\n";
197
-
198
- foreach($catArray as $id => $value) {
199
- if(!isset($cats[$id]))
200
- continue;
201
-
202
- $a .= '* '.str_pad($cats[$id], 35, '.').((float)$value)."%\n";
203
- }
204
-
205
- return $a;
206
- }
207
-
208
- private function isPreLockQuiz(WpProQuiz_Model_Quiz $quiz) {
209
- $userId = get_current_user_id();
210
-
211
- if($quiz->isQuizRunOnce()) {
212
- switch ($quiz->getQuizRunOnceType()) {
213
- case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ALL:
214
- return true;
215
- case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ONLY_USER:
216
- return $userId > 0;
217
- case WpProQuiz_Model_Quiz::QUIZ_RUN_ONCE_TYPE_ONLY_ANONYM:
218
- return $userId == 0;
219
- }
220
- }
221
-
222
- return false;
223
- }
224
-
225
- private function getIp() {
226
- if(get_current_user_id() > 0)
227
- return '0';
228
- else
229
- return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
230
- }
231
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/controller/WpProQuiz_Controller_Request.php CHANGED
@@ -1,36 +1,43 @@
1
- <?php
2
- class WpProQuiz_Controller_Request {
3
- static protected $_post = null;
4
- static protected $_cookie = null;
5
-
6
- public static function getPost() {
7
- if(self::$_post == null) {
8
- self::$_post = self::clear($_POST);
9
- }
10
-
11
- return self::$_post;
12
- }
13
-
14
- public static function getPostValue($name) {
15
- if(self::$_post == null) {
16
- self::$_post = self::clear($_POST);
17
- }
18
-
19
- return isset(self::$_post[$name]) ? self::$_post[$name] : null;
20
- }
21
-
22
- public static function getCookie() {
23
- if(self::$_post == null) {
24
- self::$_cookie = self::clear($_COOKIE);
25
- }
26
-
27
- return self::$_cookie;
28
- }
29
-
30
- private static function clear($data) {
31
- if($data !== null)
32
- return stripslashes_deep($data);
33
-
34
- return array();
35
- }
 
 
 
 
 
 
 
36
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Request
4
+ {
5
+ static protected $_post = null;
6
+ static protected $_cookie = null;
7
+
8
+ public static function getPost()
9
+ {
10
+ if (self::$_post == null) {
11
+ self::$_post = self::clear($_POST);
12
+ }
13
+
14
+ return self::$_post;
15
+ }
16
+
17
+ public static function getPostValue($name)
18
+ {
19
+ if (self::$_post == null) {
20
+ self::$_post = self::clear($_POST);
21
+ }
22
+
23
+ return isset(self::$_post[$name]) ? self::$_post[$name] : null;
24
+ }
25
+
26
+ public static function getCookie()
27
+ {
28
+ if (self::$_post == null) {
29
+ self::$_cookie = self::clear($_COOKIE);
30
+ }
31
+
32
+ return self::$_cookie;
33
+ }
34
+
35
+ private static function clear($data)
36
+ {
37
+ if ($data !== null) {
38
+ return stripslashes_deep($data);
39
+ }
40
+
41
+ return array();
42
+ }
43
  }
lib/controller/WpProQuiz_Controller_Statistics.php CHANGED
@@ -1,795 +1,444 @@
1
- <?php
2
- class WpProQuiz_Controller_Statistics extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
- $action = (isset($_GET['action'])) ? $_GET['action'] : 'show';
6
-
7
- switch ($action) {
8
- case 'show':
9
- default:
10
- $this->show($_GET['id']);
11
- }
12
- }
13
-
14
- public function getAverageResult($quizId) {
15
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
16
- // $quizMapper = new WpProQuiz_Model_QuizMapper();
17
-
18
- // $r = $statisticRefMapper->fetchByQuiz($quizId);
19
- // $maxPoints = $quizMapper->sumQuestionPoints($quizId);
20
- // $sumQuestion = $quizMapper->countQuestion($quizId);
21
-
22
- // if($r['count'] > 0) {
23
- // return round((100 * $r['points'] / ($r['count'] * $maxPoints / $sumQuestion)), 2);
24
- // }
25
-
26
- $result = $statisticRefMapper->fetchFrontAvg($quizId);
27
-
28
- if(isset($result['g_points']) && $result['g_points'])
29
- return round(100 * $result['points'] / $result['g_points'], 2);
30
-
31
- return 0;
32
- }
33
-
34
- /**
35
- * @deprecated
36
- */
37
- private function show($quizId) {
38
-
39
- if(!current_user_can('wpProQuiz_show_statistics')) {
40
- wp_die(__('You do not have sufficient permissions to access this page.'));
41
- }
42
-
43
- $this->showNew($quizId);
44
- return;
45
-
46
- $view = new WpProQuiz_View_Statistics();
47
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
48
- $quizMapper = new WpProQuiz_Model_QuizMapper();
49
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
50
- $formMapper = new WpProQuiz_Model_FormMapper();
51
-
52
- $questions = $questionMapper->fetchAll($quizId);
53
- $category = $categoryMapper->fetchAll();
54
- $categoryEmpty = new WpProQuiz_Model_Category();
55
-
56
- $categoryEmpty->setCategoryName(__('No category', 'wp-pro-quiz'));
57
-
58
- $list = array();
59
- $cats = array();
60
-
61
- foreach($category as $c) {
62
- $cats[$c->getCategoryId()] = $c;
63
- }
64
-
65
- $cats[0] = $categoryEmpty;
66
-
67
- foreach($questions as $q) {
68
- $list[$q->getCategoryId()][] = $q;
69
- }
70
-
71
-
72
- $view->quiz = $quizMapper->fetch($quizId);
73
- $view->questionList = $list;
74
- $view->categoryList = $cats;
75
- $view->forms = $formMapper->fetch($quizId);
76
-
77
- if(has_action('pre_user_query', 'ure_exclude_administrators')) {
78
- remove_action('pre_user_query', 'ure_exclude_administrators');
79
-
80
- $users = get_users(array('fields' => array('ID','user_login','display_name')));
81
-
82
- add_action('pre_user_query', 'ure_exclude_administrators');
83
-
84
- } else {
85
- $users = get_users(array('fields' => array('ID','user_login','display_name')));
86
- }
87
-
88
- array_unshift($users, (object)array('ID' => 0));
89
-
90
- $view->users = $users;
91
- $view->show();
92
- }
93
-
94
- private function showNew($quizId) {
95
- $view = new WpProQuiz_View_StatisticsNew();
96
-
97
- $quizMapper = new WpProQuiz_Model_QuizMapper();
98
-
99
- $quiz = $quizMapper->fetch($quizId);
100
-
101
- if(has_action('pre_user_query', 'ure_exclude_administrators')) {
102
- remove_action('pre_user_query', 'ure_exclude_administrators');
103
-
104
- $users = get_users(array('fields' => array('ID','user_login','display_name')));
105
-
106
- add_action('pre_user_query', 'ure_exclude_administrators');
107
-
108
- } else {
109
- $users = get_users(array('fields' => array('ID','user_login','display_name')));
110
- }
111
-
112
- $view->quiz = $quiz;
113
- $view->users = $users;
114
- $view->show();
115
- }
116
-
117
- /**
118
- *
119
- * @param WpProQuiz_Model_Quiz $quiz
120
- * @return void|boolean
121
- */
122
- public function save($quiz = null) {
123
- $quizId = $this->_post['quizId'];
124
- $array = $this->_post['results'];
125
- $lockIp = $this->getIp();
126
- $userId = get_current_user_id();
127
-
128
- if($lockIp === false)
129
- return false;
130
-
131
- if($quiz === null) {
132
- $quizMapper = new WpProQuiz_Model_QuizMapper();
133
- $quiz = $quizMapper->fetch($quizId);
134
- }
135
-
136
- if(!$quiz->isStatisticsOn())
137
- return false;
138
-
139
- $values = $this->makeDataList($quizId, $array, $userId, $quiz->getQuizModus());
140
- $formValues = $this->makeFormData($quiz, $userId, isset($this->_post['forms']) ? $this->_post['forms'] : null);
141
-
142
- if($values === false)
143
- return;
144
-
145
- if($quiz->getStatisticsIpLock() > 0) {
146
- $lockMapper = new WpProQuiz_Model_LockMapper();
147
- $lockTime = $quiz->getStatisticsIpLock() * 60;
148
-
149
- $lockMapper->deleteOldLock($lockTime, $quiz->getId(), time(), WpProQuiz_Model_Lock::TYPE_STATISTIC);
150
-
151
- if($lockMapper->isLock($quizId, $lockIp, $userId, WpProQuiz_Model_Lock::TYPE_STATISTIC))
152
- return false;
153
-
154
- $lock = new WpProQuiz_Model_Lock();
155
- $lock ->setQuizId($quizId)
156
- ->setLockIp($lockIp)
157
- ->setUserId($userId)
158
- ->setLockType(WpProQuiz_Model_Lock::TYPE_STATISTIC)
159
- ->setLockDate(time());
160
-
161
- $lockMapper->insert($lock);
162
- }
163
-
164
- $statisticRefModel = new WpProQuiz_Model_StatisticRefModel();
165
-
166
- $statisticRefModel->setCreateTime(time());
167
- $statisticRefModel->setUserId($userId);
168
- $statisticRefModel->setQuizId($quizId);
169
- $statisticRefModel->setFormData($formValues);
170
-
171
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
172
- $statisticRefMapper->statisticSave($statisticRefModel, $values);
173
-
174
- return true;
175
- }
176
-
177
- /**
178
- * @param WpProQuiz_Model_Quiz $quiz
179
- * @param int $userId
180
- */
181
- private function makeFormData($quiz, $userId, $data) {
182
- if(!$quiz->isFormActivated() || empty($data))
183
- return null;
184
-
185
- $formMapper = new WpProQuiz_Model_FormMapper();
186
-
187
- $forms = $formMapper->fetch($quiz->getId());
188
-
189
- if(empty($forms))
190
- return null;
191
-
192
- $formArray = array();
193
-
194
- foreach($forms as $form) {
195
- if($form->getType() != WpProQuiz_Model_Form::FORM_TYPE_DATE) {
196
- $str = isset($data[$form->getFormId()]) ? $data[$form->getFormId()] : '';
197
-
198
- if(!WpProQuiz_Helper_Form::valid($form, $str))
199
- return null;
200
-
201
- $formArray[$form->getFormId()] = trim($str);
202
- } else {
203
- $date = isset($data[$form->getFormId()]) ? $data[$form->getFormId()] : array();
204
-
205
- $dateStr = WpProQuiz_Helper_Form::validData($form, $date);
206
-
207
- if($dateStr === null)
208
- return null;
209
-
210
- $formArray[$form->getFormId()] = $dateStr;
211
- }
212
- }
213
-
214
- return $formArray;
215
- }
216
-
217
- private function makeDataList($quizId, $array, $userId, $modus) {
218
-
219
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
220
-
221
- $question = $questionMapper->fetchAllList($quizId, array('id', 'points'));
222
-
223
- $ids = array();
224
-
225
- foreach($question as $q) {
226
- if(!isset($array[$q['id']]))
227
- continue;
228
-
229
- $ids[] = $q['id'];
230
- $v = $array[$q['id']];
231
-
232
- if(!isset($v) || $v['points'] > $q['points'] || $v['points'] < 0) {
233
- return false;
234
- }
235
- }
236
-
237
- $avgTime = null;
238
-
239
- if($modus == WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE) {
240
- $avgTime = ceil($array['comp']['quizTime'] / count($question));
241
- }
242
-
243
- unset($array['comp']);
244
-
245
- $ak = array_keys($array);
246
-
247
- if(array_diff($ids, $ak) !== array_diff($ak, $ids))
248
- return false;
249
-
250
- $values = array();
251
-
252
- foreach($array as $k => $v) {
253
- $s = new WpProQuiz_Model_Statistic();
254
- $s->setQuizId($quizId);
255
- $s->setQuestionId($k);
256
- $s->setUserId($userId);
257
- $s->setHintCount(isset($v['tip']) ? 1 : 0);
258
- $s->setSolvedCount(isset($v['solved']) && $v['solved'] ? 1 : 0);
259
- $s->setCorrectCount($v['correct'] ? 1 : 0);
260
- $s->setIncorrectCount($v['correct'] ? 0 : 1);
261
- $s->setPoints($v['points']);
262
- $s->setQuestionTime($avgTime === null ? $v['time'] : $avgTime);
263
- $s->setAnswerData(isset($v['data']) ? $v['data'] : null);
264
-
265
- $values[] = $s;
266
- }
267
-
268
- return $values;
269
- }
270
-
271
- private function getIp() {
272
- if(get_current_user_id() > 0)
273
- return '0';
274
- else
275
- return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
276
- }
277
-
278
- /**
279
- * @deprecated
280
- */
281
- public static function ajaxLoadStatistic($data, $func) {
282
- if(!current_user_can('wpProQuiz_show_statistics')) {
283
- return json_encode(array());
284
- }
285
-
286
- $userId = $data['userId'];
287
- $quizId = $data['quizId'];
288
- $testId = $data['testId'];
289
-
290
- $maxPoints = 0;
291
- $sumQuestion = 0;
292
-
293
- $inTest = false;
294
-
295
- $category = array();
296
- $categoryList = array();
297
- $testJson = array();
298
-
299
- $formData = null;
300
-
301
- $statisticMapper = new WpProQuiz_Model_StatisticMapper();
302
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
303
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
304
-
305
- $tests = $statisticRefMapper->fetchAll($quizId, $userId, $testId);
306
-
307
- $i = 1;
308
- foreach($tests as $test) {
309
- if($testId == $test->getStatisticRefId())
310
- $inTest = true;
311
-
312
- $testJson[] = array(
313
- 'id' => $test->getStatisticRefId(),
314
- 'date' => '#'.$i++.' '.WpProQuiz_Helper_Until::convertTime($test->getCreateTime(), get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A'))
315
- );
316
- }
317
-
318
- if(!$inTest) {
319
- $data['testId'] = $testId = 0;
320
- }
321
-
322
- if(!$testId) {
323
- $statistics = $statisticRefMapper->fetchAvg($quizId, $userId);
324
- } else {
325
- $statistics = $statisticMapper->fetchAllByRef($testId);
326
- $refModel = $statisticRefMapper->fetchByRefId($testId);
327
- $formData = $refModel->getFormData();
328
- }
329
-
330
- $questionData = $questionMapper->fetchAllList($quizId, array('id', 'category_id', 'points'));
331
-
332
- $empty = array(
333
- 'questionId' => 0,
334
- 'correct' => 0,
335
- 'incorrect' => 0,
336
- 'hint' => 0,
337
- 'points' => 0,
338
- 'result' => 0,
339
- 'questionTime' => 0
340
- );
341
-
342
- $ca = $sa = array();
343
-
344
- $ga = $empty;
345
-
346
- foreach($questionData as $cc) {
347
- $categoryList[$cc['id']] = $cc['category_id'];
348
-
349
- $c = &$category[$cc['category_id']];
350
-
351
- if(empty($c)) {
352
- $c = $cc;
353
- $c['sum'] = 1;
354
- } else {
355
- $c['points'] += $cc['points'];
356
- $c['sum']++;
357
- }
358
-
359
- $maxPoints += $cc['points'];
360
- $sumQuestion++;
361
-
362
- $sa[$cc['id']] = self::calcTotal($empty);
363
- $sa[$cc['id']]['questionId'] = $cc['id'];
364
-
365
- $ca[$cc['category_id']] = self::calcTotal($empty);
366
- }
367
-
368
- foreach($statistics as $statistic) {
369
- $s = $statistic->getCorrectCount() + $statistic->getIncorrectCount();
370
-
371
- if($s > 0) {
372
- $correct = $statistic->getCorrectCount().' ('.round((100 * $statistic->getCorrectCount() / $s), 2).'%)';
373
- $incorrect = $statistic->getIncorrectCount().' ('.round((100 * $statistic->getIncorrectCount() / $s), 2).'%)';
374
- } else {
375
- $incorrect = $correct = '0 (0%)';
376
- }
377
-
378
- $ga['correct'] += $statistic->getCorrectCount();
379
- $ga['incorrect'] += $statistic->getIncorrectCount();
380
- $ga['hint'] += $statistic->getHintCount();
381
- $ga['points'] += $statistic->getPoints();
382
- $ga['questionTime'] += $statistic->getQuestionTime();
383
-
384
- $cats = &$ca[$categoryList[$statistic->getQuestionId()]];
385
-
386
- if(!is_array($cats)) {
387
- $cats = $empty;
388
- }
389
-
390
- $cats['correct'] += $statistic->getCorrectCount();
391
- $cats['incorrect'] += $statistic->getIncorrectCount();
392
- $cats['hint'] += $statistic->getHintCount();
393
- $cats['points'] += $statistic->getPoints();
394
- $cats['questionTime'] += $statistic->getQuestionTime();
395
-
396
-
397
- $sa[$statistic->getQuestionId()] = array(
398
- 'questionId' => $statistic->getQuestionId(),
399
- 'correct' => $correct,
400
- 'incorrect' => $incorrect,
401
- 'hint' => $statistic->getHintCount(),
402
- 'points' => $statistic->getPoints(),
403
- 'questionTime' => self::convertToTimeString($statistic->getQuestionTime())
404
- );
405
- }
406
-
407
- foreach($ca as $catIndex => $cat) {
408
- $ca[$catIndex] = self::calcTotal($cat, $category[$catIndex]['points'], $category[$catIndex]['sum']);
409
- }
410
-
411
- $sa[0] = self::calcTotal($ga, $maxPoints, $sumQuestion);
412
-
413
- return json_encode(array(
414
- 'question' => $sa,
415
- 'category' => $ca,
416
- 'tests' => $testJson,
417
- 'testId' => $data['testId'],
418
- 'formData' => $formData
419
- ));
420
- }
421
-
422
- /**
423
- * @deprecated
424
- */
425
- public static function ajaxReset($data, $func) {
426
- if(!current_user_can('wpProQuiz_reset_statistics')) {
427
- return;
428
- }
429
-
430
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
431
-
432
- $quizId = $data['quizId'];
433
- $userId = $data['userId'];
434
- $testId = $data['testId'];
435
-
436
- switch ($data['type']) {
437
- case 0:
438
- $statisticRefMapper->deleteUserTest($quizId, $userId, $testId);
439
- break;
440
- case 1:
441
- $statisticRefMapper->deleteUser($quizId, $userId);
442
- break;
443
- case 2:
444
- $statisticRefMapper->deleteAll($quizId);
445
- break;
446
- }
447
- }
448
-
449
- /**
450
- * @deprecated
451
- */
452
- public static function ajaxLoadStatsticOverview($data, $func) {
453
- if(!current_user_can('wpProQuiz_show_statistics')) {
454
- return json_encode(array());
455
- }
456
-
457
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
458
-
459
- $quizMapper = new WpProQuiz_Model_QuizMapper();
460
-
461
- $quizId = $data['quizId'];
462
-
463
- $page = (isset($data['page']) && $data['page'] > 0) ? $data['page'] : 1;
464
- $limit = $data['pageLimit'];
465
- $start = $limit * ($page - 1);
466
-
467
- $statistics = $statisticRefMapper->fetchOverview($quizId, (bool)$data['onlyCompleted'], $start, $limit);
468
-
469
- $d = array('items' => array());
470
-
471
- $maxPoints = $quizMapper->sumQuestionPoints($quizId);
472
- $sumQuestion = $quizMapper->countQuestion($quizId);
473
-
474
- foreach($statistics as $statistic) {
475
-
476
- $sum = $statistic->getCorrectCount() + $statistic->getIncorrectCount();
477
-
478
- if($sum > 0) {
479
- $correct = $statistic->getCorrectCount().' ('.round((100 * $statistic->getCorrectCount() / $sum), 2).'%)';
480
- $incorrect = $statistic->getIncorrectCount().' ('.round((100 * $statistic->getIncorrectCount() / $sum), 2).'%)';
481
- $hint = $statistic->getHintCount();
482
- $result = round((100 * $statistic->getPoints() / ($sum * $maxPoints / $sumQuestion)), 2).'%';
483
- $points = $statistic->getPoints();
484
- $questionTime = self::convertToTimeString($statistic->getQuestionTime());
485
- } else {
486
- $questionTime = $points = $result = $hint = $correct = $incorrect = '---';
487
- }
488
-
489
-
490
- $d['items'][] = array(
491
- 'userId' => $statistic->getUserId(),
492
- 'userName' => $statistic->getUserName(),
493
- 'points' => $points,
494
- 'correct' => $correct,
495
- 'incorrect' => $incorrect,
496
- 'hint' => $hint,
497
- 'result' => $result,
498
- 'questionTime' => $questionTime
499
- );
500
- }
501
-
502
- if(isset($data['nav']) && $data['nav']) {
503
- $count = $statisticRefMapper->countOverview($quizId, (bool)$data['onlyCompleted']);
504
- $d['page'] = ceil(($count > 0 ? $count : 1) / $limit);
505
- }
506
-
507
- return json_encode($d);
508
-
509
- }
510
-
511
- /**
512
- * @deprecated
513
- */
514
- private static function calcTotal($a, $maxPoints = null, $sumQuestion = null) {
515
- $s = $a['correct'] + $a['incorrect'];
516
-
517
- if($s > 0) {
518
- $a['correct'] = $a['correct'].' ('.round((100 * $a['correct'] / $s), 2).'%)';
519
- $a['incorrect'] = $a['incorrect'].' ('.round((100 * $a['incorrect'] / $s), 2).'%)';
520
-
521
- if($maxPoints !== null)
522
- $a['result'] = round((100 * $a['points'] / ($s * $maxPoints / $sumQuestion)), 2).'%';
523
- } else {
524
- $a['result'] = $a['correct'] = $a['incorrect'] = '0 (0%)';
525
- }
526
-
527
- $a['questionTime'] = self::convertToTimeString($a['questionTime']);
528
-
529
- return $a;
530
- }
531
-
532
- /**
533
- * @deprecated
534
- */
535
- private static function convertToTimeString($s) {
536
- $h = floor($s / 3600);
537
- $s -= $h * 3600;
538
- $m = floor($s / 60);
539
- $s -= $m * 60;
540
-
541
- return sprintf("%02d:%02d:%02d", $h, $m, $s);
542
- }
543
-
544
- /**
545
- * @deprecated
546
- */
547
- public static function ajaxLoadFormOverview($data, $func) {
548
- if(!current_user_can('wpProQuiz_show_statistics')) {
549
- return json_encode(array());
550
- }
551
-
552
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
553
- $quizMapper = new WpProQuiz_Model_QuizMapper();
554
-
555
- $quizId = $data['quizId'];
556
-
557
- $page = (isset($data['page']) && $data['page'] > 0) ? $data['page'] : 1;
558
- $limit = $data['pageLimit'];
559
- $start = $limit * ($page - 1);
560
-
561
- $statisticModel = $statisticRefMapper->fetchFormOverview($quizId, $start, $limit, $data['onlyUser']);
562
-
563
- $items = array();
564
-
565
- $maxPoints = $quizMapper->sumQuestionPoints($quizId);
566
- $sumQuestion = $quizMapper->countQuestion($quizId);
567
-
568
- foreach($statisticModel as $model) {
569
- /*@var $model WpProQuiz_Model_StatisticFormOverview */
570
-
571
- if(!$model->getUserId())
572
- $model->setUserName(__('Anonymous', 'wp-pro-quiz'));
573
-
574
- $sum = $model->getCorrectCount() + $model->getIncorrectCount();
575
- $result = round((100 * $model->getPoints() / ($sum * $maxPoints / $sumQuestion)), 2).'%';
576
-
577
- $items[] = array(
578
- 'userName' => $model->getUserName(),
579
- 'userId' => $model->getUserId(),
580
- 'testId' => $model->getStatisticRefId(),
581
- 'date' => WpProQuiz_Helper_Until::convertTime($model->getCreateTime(), get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A')),
582
- 'result' => $result
583
- );
584
- }
585
-
586
- $d = array('items' => $items);
587
-
588
- if(isset($data['nav']) && $data['nav']) {
589
- $count = $statisticRefMapper->countFormOverview($quizId, $data['onlyUser']);
590
- $d['page'] = ceil(($count > 0 ? $count : 1) / $limit);
591
- }
592
-
593
- return json_encode($d);
594
- }
595
-
596
- public static function ajaxLoadHistory($data, $func) {
597
- if(!current_user_can('wpProQuiz_show_statistics')) {
598
- return json_encode(array());
599
- }
600
-
601
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
602
- $quizMapper = new WpProQuiz_Model_QuizMapper();
603
- $formMapper = new WpProQuiz_Model_FormMapper();
604
-
605
- $quizId = $data['quizId'];
606
-
607
- $forms = $formMapper->fetch($quizId);
608
-
609
- $page = (isset($data['page']) && $data['page'] > 0) ? $data['page'] : 1;
610
- $limit = $data['pageLimit'];
611
- $start = $limit * ($page - 1);
612
-
613
- $startTime = (int)$data['dateFrom'];
614
- $endTime = (int)$data['dateTo'] ? $data['dateTo'] + 86400 : 0;
615
-
616
- $statisticModel = $statisticRefMapper->fetchHistory($quizId, $start, $limit, $data['users'], $startTime, $endTime);
617
-
618
- foreach($statisticModel as $model) {
619
- /* @var $model WpProQuiz_Model_StatisticHistory */
620
-
621
- if(!$model->getUserId())
622
- $model->setUserName(__('Anonymous', 'wp-pro-quiz'));
623
- else if($model->getUserName() == '')
624
- $model->setUserName(__('Deleted user', 'wp-pro-quiz'));
625
-
626
- $sum = $model->getCorrectCount() + $model->getIncorrectCount();
627
- $result = round(100 * $model->getPoints() / $model->getGPoints(), 2).'%';
628
-
629
- $model->setResult($result);
630
- $model->setFormatTime(WpProQuiz_Helper_Until::convertTime($model->getCreateTime(), get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A')));
631
-
632
- $model->setFormatCorrect($model->getCorrectCount().' ('.round(100 * $model->getCorrectCount() / $sum, 2).'%)');
633
- $model->setFormatIncorrect($model->getIncorrectCount().' ('.round(100 * $model->getIncorrectCount() / $sum, 2).'%)');
634
-
635
- $formData = $model->getFormData();
636
- $formOverview = array();
637
-
638
- foreach($forms as $form) {
639
- /* @var $form WpProQuiz_Model_Form */
640
- if($form->isShowInStatistic()) {
641
- $formOverview[] = $formData != null && isset($formData[$form->getFormId()])
642
- ? WpProQuiz_Helper_Form::formToString($form, $formData[$form->getFormId()])
643
- : '----';
644
- }
645
- }
646
-
647
- $model->setFormOverview($formOverview);
648
- }
649
-
650
- $view = new WpProQuiz_View_StatisticsAjax();
651
- $view->historyModel = $statisticModel;
652
- $view->forms = $forms;
653
-
654
- $html = $view->getHistoryTable();
655
- $navi = null;
656
-
657
- if(isset($data['generateNav']) && $data['generateNav']) {
658
- $count = $statisticRefMapper->countHistory($quizId, $data['users'], $startTime, $endTime);
659
- $navi = ceil(($count > 0 ? $count : 1) / $limit);
660
- }
661
-
662
- return json_encode(array(
663
- 'html' => $html,
664
- 'navi' => $navi
665
- ));
666
- }
667
-
668
- public static function ajaxLoadStatisticUser($data, $func) {
669
- if(!current_user_can('wpProQuiz_show_statistics')) {
670
- return json_encode(array());
671
- }
672
-
673
- $quizId = $data['quizId'];
674
- $userId = $data['userId'];
675
- $refId = $data['refId'];
676
- $avg = (bool)$data['avg'];
677
- $refIdUserId = $avg ? $userId : $refId;
678
-
679
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
680
- $statisticUserMapper = new WpProQuiz_Model_StatisticUserMapper();
681
- $formMapper = new WpProQuiz_Model_FormMapper();
682
-
683
- $statisticUsers = $statisticUserMapper->fetchUserStatistic($refIdUserId, $quizId, $avg);
684
-
685
- $output = array();
686
-
687
- foreach($statisticUsers as $statistic) {
688
- /* @var $statistic WpProQuiz_Model_StatisticUser */
689
-
690
- if(!isset($output[$statistic->getCategoryId()])) {
691
- $output[$statistic->getCategoryId()] = array(
692
- 'questions' => array(),
693
- 'categoryId' => $statistic->getCategoryId(),
694
- 'categoryName' => $statistic->getCategoryId() ? $statistic->getCategoryName() : __('No category', 'wp-pro-quiz')
695
- );
696
- }
697
-
698
- $o = &$output[$statistic->getCategoryId()];
699
-
700
- $o['questions'][] = array(
701
- 'correct' => $statistic->getCorrectCount(),
702
- 'incorrect' => $statistic->getIncorrectCount(),
703
- 'hintCount' => $statistic->getIncorrectCount(),
704
- 'time' => $statistic->getQuestionTime(),
705
- 'points' => $statistic->getPoints(),
706
- 'gPoints' => $statistic->getGPoints(),
707
- 'statistcAnswerData' => $statistic->getStatisticAnswerData(),
708
- 'questionName' => $statistic->getQuestionName(),
709
- 'questionAnswerData' => $statistic->getQuestionAnswerData(),
710
- 'answerType' => $statistic->getAnswerType(),
711
- 'solvedCount' => $statistic->getSolvedCount()
712
- );
713
- }
714
-
715
- $view = new WpProQuiz_View_StatisticsAjax();
716
-
717
- $view->avg = $avg;
718
- $view->statisticModel = $statisticRefMapper->fetchByRefId($refIdUserId, $quizId, $avg);
719
-
720
- $view->userName = __('Anonymous', 'wp-pro-quiz');
721
-
722
- if($view->statisticModel->getUserId()) {
723
- $userInfo = get_userdata($view->statisticModel->getUserId());
724
-
725
- if($userInfo !== false)
726
- $view->userName = $userInfo->user_login.' ('.$userInfo->display_name.')';
727
- else
728
- $view->userName = __('Deleted user', 'wp-pro-quiz');
729
- }
730
-
731
- if(!$avg) {
732
- $view->forms = $formMapper->fetch($quizId);
733
- }
734
-
735
- $view->userStatistic = $output;
736
-
737
- $html = $view->getUserTable();
738
-
739
- return json_encode(array(
740
- 'html' => $html
741
- ));
742
- }
743
-
744
- public static function ajaxRestStatistic($data, $func) {
745
- if(!current_user_can('wpProQuiz_reset_statistics')) {
746
- return;
747
- }
748
-
749
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
750
-
751
- switch ($data['type']) {
752
- case 0: //RefId or UserId
753
- if($data['refId'])
754
- $statisticRefMapper->deleteByRefId($data['refId']);
755
- else if($data['userId'] != '')
756
- $statisticRefMapper->deleteByUserIdQuizId($data['userId'], $data['quizId']);
757
- break;
758
- case 1: //alles
759
- $statisticRefMapper->deleteAll($data['quizId']);
760
- break;
761
- }
762
- }
763
-
764
- public static function ajaxLoadStatsticOverviewNew($data, $func) {
765
- if(!current_user_can('wpProQuiz_show_statistics')) {
766
- return json_encode(array());
767
- }
768
-
769
- $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
770
- $quizMapper = new WpProQuiz_Model_QuizMapper();
771
-
772
- $quizId = $data['quizId'];
773
-
774
- $page = (isset($data['page']) && $data['page'] > 0) ? $data['page'] : 1;
775
- $limit = $data['pageLimit'];
776
- $start = $limit * ($page - 1);
777
-
778
- $statisticModel = $statisticRefMapper->fetchStatisticOverview($quizId, $data['onlyCompleted'], $start, $limit);
779
-
780
- $view = new WpProQuiz_View_StatisticsAjax();
781
- $view->statisticModel = $statisticModel;
782
-
783
- $navi = null;
784
-
785
- if(isset($data['generateNav']) && $data['generateNav']) {
786
- $count = $statisticRefMapper->countOverviewNew($quizId, $data['onlyCompleted']);
787
- $navi = ceil(($count > 0 ? $count : 1) / $limit);
788
- }
789
-
790
- return json_encode(array(
791
- 'navi' => $navi,
792
- 'html' => $view->getOverviewTable()
793
- ));
794
- }
795
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Statistics extends WpProQuiz_Controller_Controller
4
+ {
5
+ public function route()
6
+ {
7
+ $action = (isset($_GET['action'])) ? $_GET['action'] : 'show';
8
+
9
+ switch ($action) {
10
+ case 'show':
11
+ default:
12
+ $this->showNew($_GET['id']);
13
+ }
14
+ }
15
+
16
+ public function getAverageResult($quizId)
17
+ {
18
+ $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
19
+
20
+ $result = $statisticRefMapper->fetchFrontAvg($quizId);
21
+
22
+ if (isset($result['g_points']) && $result['g_points']) {
23
+ return round(100 * $result['points'] / $result['g_points'], 2);
24
+ }
25
+
26
+ return 0;
27
+ }
28
+
29
+ private function showNew($quizId)
30
+ {
31
+ if (!current_user_can('wpProQuiz_show_statistics')) {
32
+ wp_die(__('You do not have sufficient permissions to access this page.'));
33
+ }
34
+
35
+ $view = new WpProQuiz_View_StatisticsNew();
36
+
37
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
38
+
39
+ $quiz = $quizMapper->fetch($quizId);
40
+
41
+ if (has_action('pre_user_query', 'ure_exclude_administrators')) {
42
+ remove_action('pre_user_query', 'ure_exclude_administrators');
43
+
44
+ $users = get_users(array('fields' => array('ID', 'user_login', 'display_name')));
45
+
46
+ add_action('pre_user_query', 'ure_exclude_administrators');
47
+
48
+ } else {
49
+ $users = get_users(array('fields' => array('ID', 'user_login', 'display_name')));
50
+ }
51
+
52
+ $view->quiz = $quiz;
53
+ $view->users = $users;
54
+ $view->show();
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @param WpProQuiz_Model_Quiz $quiz
60
+ * @return void|boolean
61
+ */
62
+ public function save($quiz = null)
63
+ {
64
+ $quizId = $this->_post['quizId'];
65
+ $array = $this->_post['results'];
66
+ $lockIp = $this->getIp();
67
+ $userId = get_current_user_id();
68
+
69
+ if ($lockIp === false) {
70
+ return false;
71
+ }
72
+
73
+ if ($quiz === null) {
74
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
75
+ $quiz = $quizMapper->fetch($quizId);
76
+ }
77
+
78
+ if (!$quiz->isStatisticsOn()) {
79
+ return false;
80
+ }
81
+
82
+ $values = $this->makeDataList($quizId, $array, $quiz->getQuizModus());
83
+ $formValues = $this->makeFormData($quiz, isset($this->_post['forms']) ? $this->_post['forms'] : null);
84
+
85
+ if ($values === false) {
86
+ return false;
87
+ }
88
+
89
+ if ($quiz->getStatisticsIpLock() > 0) {
90
+ $lockMapper = new WpProQuiz_Model_LockMapper();
91
+ $lockTime = $quiz->getStatisticsIpLock() * 60;
92
+
93
+ $lockMapper->deleteOldLock($lockTime, $quiz->getId(), time(), WpProQuiz_Model_Lock::TYPE_STATISTIC);
94
+
95
+ if ($lockMapper->isLock($quizId, $lockIp, $userId, WpProQuiz_Model_Lock::TYPE_STATISTIC)) {
96
+ return false;
97
+ }
98
+
99
+ $lock = new WpProQuiz_Model_Lock();
100
+ $lock->setQuizId($quizId)
101
+ ->setLockIp($lockIp)
102
+ ->setUserId($userId)
103
+ ->setLockType(WpProQuiz_Model_Lock::TYPE_STATISTIC)
104
+ ->setLockDate(time());
105
+
106
+ $lockMapper->insert($lock);
107
+ }
108
+
109
+ $statisticRefModel = new WpProQuiz_Model_StatisticRefModel();
110
+
111
+ $statisticRefModel->setCreateTime(time());
112
+ $statisticRefModel->setUserId($userId);
113
+ $statisticRefModel->setQuizId($quizId);
114
+ $statisticRefModel->setFormData($formValues);
115
+
116
+ $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
117
+ $statisticRefMapper->statisticSave($statisticRefModel, $values);
118
+
119
+ return true;
120
+ }
121
+
122
+ /**
123
+ * @param WpProQuiz_Model_Quiz $quiz
124
+ * @param $data
125
+ * @return array|null
126
+ */
127
+ private function makeFormData($quiz, $data)
128
+ {
129
+ if (!$quiz->isFormActivated() || empty($data)) {
130
+ return null;
131
+ }
132
+
133
+ $formMapper = new WpProQuiz_Model_FormMapper();
134
+
135
+ $forms = $formMapper->fetch($quiz->getId());
136
+
137
+ if (empty($forms)) {
138
+ return null;
139
+ }
140
+
141
+ $formArray = array();
142
+
143
+ foreach ($forms as $form) {
144
+ if ($form->getType() != WpProQuiz_Model_Form::FORM_TYPE_DATE) {
145
+ $str = isset($data[$form->getFormId()]) ? $data[$form->getFormId()] : '';
146
+
147
+ if (!WpProQuiz_Helper_Form::valid($form, $str)) {
148
+ return null;
149
+ }
150
+
151
+ $formArray[$form->getFormId()] = trim($str);
152
+ } else {
153
+ $date = isset($data[$form->getFormId()]) ? $data[$form->getFormId()] : array();
154
+
155
+ $dateStr = WpProQuiz_Helper_Form::validData($form, $date);
156
+
157
+ if ($dateStr === null) {
158
+ return null;
159
+ }
160
+
161
+ $formArray[$form->getFormId()] = $dateStr;
162
+ }
163
+ }
164
+
165
+ return $formArray;
166
+ }
167
+
168
+ private function makeDataList($quizId, $array, $modus)
169
+ {
170
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
171
+
172
+ $question = $questionMapper->fetchAllList($quizId, array('id', 'points'));
173
+
174
+ $ids = array();
175
+
176
+ foreach ($question as $q) {
177
+ if (!isset($array[$q['id']])) {
178
+ continue;
179
+ }
180
+
181
+ $ids[] = $q['id'];
182
+ $v = $array[$q['id']];
183
+
184
+ if (!isset($v) || $v['points'] > $q['points'] || $v['points'] < 0) {
185
+ return false;
186
+ }
187
+ }
188
+
189
+ $avgTime = null;
190
+
191
+ if ($modus == WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE) {
192
+ $avgTime = ceil($array['comp']['quizTime'] / count($question));
193
+ }
194
+
195
+ unset($array['comp']);
196
+
197
+ $ak = array_keys($array);
198
+
199
+ if (array_diff($ids, $ak) !== array_diff($ak, $ids)) {
200
+ return false;
201
+ }
202
+
203
+ $values = array();
204
+
205
+ foreach ($array as $k => $v) {
206
+ $s = new WpProQuiz_Model_Statistic();
207
+ $s->setQuestionId($k);
208
+ $s->setHintCount(isset($v['tip']) ? 1 : 0);
209
+ $s->setSolvedCount(isset($v['solved']) && $v['solved'] ? 1 : 0);
210
+ $s->setCorrectCount($v['correct'] ? 1 : 0);
211
+ $s->setIncorrectCount($v['correct'] ? 0 : 1);
212
+ $s->setPoints($v['points']);
213
+ $s->setQuestionTime($avgTime === null ? $v['time'] : $avgTime);
214
+ $s->setAnswerData(isset($v['data']) ? $v['data'] : null);
215
+
216
+ $values[] = $s;
217
+ }
218
+
219
+ return $values;
220
+ }
221
+
222
+ private function getIp()
223
+ {
224
+ if (get_current_user_id() > 0) {
225
+ return '0';
226
+ } else {
227
+ return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
228
+ }
229
+ }
230
+
231
+ public static function ajaxLoadHistory($data)
232
+ {
233
+ if (!current_user_can('wpProQuiz_show_statistics')) {
234
+ return json_encode(array());
235
+ }
236
+
237
+ $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
238
+ $formMapper = new WpProQuiz_Model_FormMapper();
239
+
240
+ $quizId = $data['quizId'];
241
+
242
+ $forms = $formMapper->fetch($quizId);
243
+
244
+ $page = (isset($data['page']) && $data['page'] > 0) ? $data['page'] : 1;
245
+ $limit = $data['pageLimit'];
246
+ $start = $limit * ($page - 1);
247
+
248
+ $startTime = (int)$data['dateFrom'];
249
+ $endTime = (int)$data['dateTo'] ? $data['dateTo'] + 86400 : 0;
250
+
251
+ $statisticModel = $statisticRefMapper->fetchHistory($quizId, $start, $limit, $data['users'], $startTime,
252
+ $endTime);
253
+
254
+ foreach ($statisticModel as $model) {
255
+ /* @var $model WpProQuiz_Model_StatisticHistory */
256
+
257
+ if (!$model->getUserId()) {
258
+ $model->setUserName(__('Anonymous', 'wp-pro-quiz'));
259
+ } else {
260
+ if ($model->getUserName() == '') {
261
+ $model->setUserName(__('Deleted user', 'wp-pro-quiz'));
262
+ }
263
+ }
264
+
265
+ $sum = $model->getCorrectCount() + $model->getIncorrectCount();
266
+ $result = round(100 * $model->getPoints() / $model->getGPoints(), 2) . '%';
267
+
268
+ $model->setResult($result);
269
+ $model->setFormatTime(WpProQuiz_Helper_Until::convertTime($model->getCreateTime(),
270
+ get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A')));
271
+
272
+ $model->setFormatCorrect($model->getCorrectCount() . ' (' . round(100 * $model->getCorrectCount() / $sum,
273
+ 2) . '%)');
274
+ $model->setFormatIncorrect($model->getIncorrectCount() . ' (' . round(100 * $model->getIncorrectCount() / $sum,
275
+ 2) . '%)');
276
+
277
+ $formData = $model->getFormData();
278
+ $formOverview = array();
279
+
280
+ foreach ($forms as $form) {
281
+ /* @var $form WpProQuiz_Model_Form */
282
+ if ($form->isShowInStatistic()) {
283
+ $formOverview[] = $formData != null && isset($formData[$form->getFormId()])
284
+ ? WpProQuiz_Helper_Form::formToString($form, $formData[$form->getFormId()])
285
+ : '----';
286
+ }
287
+ }
288
+
289
+ $model->setFormOverview($formOverview);
290
+ }
291
+
292
+ $view = new WpProQuiz_View_StatisticsAjax();
293
+ $view->historyModel = $statisticModel;
294
+ $view->forms = $forms;
295
+
296
+ $html = $view->getHistoryTable();
297
+ $navi = null;
298
+
299
+ if (isset($data['generateNav']) && $data['generateNav']) {
300
+ $count = $statisticRefMapper->countHistory($quizId, $data['users'], $startTime, $endTime);
301
+ $navi = ceil(($count > 0 ? $count : 1) / $limit);
302
+ }
303
+
304
+ return json_encode(array(
305
+ 'html' => $html,
306
+ 'navi' => $navi
307
+ ));
308
+ }
309
+
310
+ public static function ajaxLoadStatisticUser($data)
311
+ {
312
+ if (!current_user_can('wpProQuiz_show_statistics')) {
313
+ return json_encode(array());
314
+ }
315
+
316
+ $quizId = $data['quizId'];
317
+ $userId = $data['userId'];
318
+ $refId = $data['refId'];
319
+ $avg = (bool)$data['avg'];
320
+ $refIdUserId = $avg ? $userId : $refId;
321
+
322
+ $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
323
+ $statisticUserMapper = new WpProQuiz_Model_StatisticUserMapper();
324
+ $formMapper = new WpProQuiz_Model_FormMapper();
325
+
326
+ $statisticUsers = $statisticUserMapper->fetchUserStatistic($refIdUserId, $quizId, $avg);
327
+
328
+ $output = array();
329
+
330
+ foreach ($statisticUsers as $statistic) {
331
+ /* @var $statistic WpProQuiz_Model_StatisticUser */
332
+
333
+ if (!isset($output[$statistic->getCategoryId()])) {
334
+ $output[$statistic->getCategoryId()] = array(
335
+ 'questions' => array(),
336
+ 'categoryId' => $statistic->getCategoryId(),
337
+ 'categoryName' => $statistic->getCategoryId() ? $statistic->getCategoryName() : __('No category',
338
+ 'wp-pro-quiz')
339
+ );
340
+ }
341
+
342
+ $o = &$output[$statistic->getCategoryId()];
343
+
344
+ $o['questions'][] = array(
345
+ 'correct' => $statistic->getCorrectCount(),
346
+ 'incorrect' => $statistic->getIncorrectCount(),
347
+ 'hintCount' => $statistic->getIncorrectCount(),
348
+ 'time' => $statistic->getQuestionTime(),
349
+ 'points' => $statistic->getPoints(),
350
+ 'gPoints' => $statistic->getGPoints(),
351
+ 'statistcAnswerData' => $statistic->getStatisticAnswerData(),
352
+ 'questionName' => $statistic->getQuestionName(),
353
+ 'questionAnswerData' => $statistic->getQuestionAnswerData(),
354
+ 'answerType' => $statistic->getAnswerType(),
355
+ 'solvedCount' => $statistic->getSolvedCount()
356
+ );
357
+ }
358
+
359
+ $view = new WpProQuiz_View_StatisticsAjax();
360
+
361
+ $view->avg = $avg;
362
+ $view->statisticModel = $statisticRefMapper->fetchByRefId($refIdUserId, $quizId, $avg);
363
+
364
+ $view->userName = __('Anonymous', 'wp-pro-quiz');
365
+
366
+ if ($view->statisticModel->getUserId()) {
367
+ $userInfo = get_userdata($view->statisticModel->getUserId());
368
+
369
+ if ($userInfo !== false) {
370
+ $view->userName = $userInfo->user_login . ' (' . $userInfo->display_name . ')';
371
+ } else {
372
+ $view->userName = __('Deleted user', 'wp-pro-quiz');
373
+ }
374
+ }
375
+
376
+ if (!$avg) {
377
+ $view->forms = $formMapper->fetch($quizId);
378
+ }
379
+
380
+ $view->userStatistic = $output;
381
+
382
+ $html = $view->getUserTable();
383
+
384
+ return json_encode(array(
385
+ 'html' => $html
386
+ ));
387
+ }
388
+
389
+ public static function ajaxRestStatistic($data)
390
+ {
391
+ if (!current_user_can('wpProQuiz_reset_statistics')) {
392
+ return;
393
+ }
394
+
395
+ $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
396
+
397
+ switch ($data['type']) {
398
+ case 0: //RefId or UserId
399
+ if ($data['refId']) {
400
+ $statisticRefMapper->deleteByRefId($data['refId']);
401
+ } else {
402
+ if ($data['userId'] != '') {
403
+ $statisticRefMapper->deleteByUserIdQuizId($data['userId'], $data['quizId']);
404
+ }
405
+ }
406
+ break;
407
+ case 1: //alles
408
+ $statisticRefMapper->deleteAll($data['quizId']);
409
+ break;
410
+ }
411
+ }
412
+
413
+ public static function ajaxLoadStatsticOverviewNew($data)
414
+ {
415
+ if (!current_user_can('wpProQuiz_show_statistics')) {
416
+ return json_encode(array());
417
+ }
418
+
419
+ $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper();
420
+
421
+ $quizId = $data['quizId'];
422
+
423
+ $page = (isset($data['page']) && $data['page'] > 0) ? $data['page'] : 1;
424
+ $limit = $data['pageLimit'];
425
+ $start = $limit * ($page - 1);
426
+
427
+ $statisticModel = $statisticRefMapper->fetchStatisticOverview($quizId, $data['onlyCompleted'], $start, $limit);
428
+
429
+ $view = new WpProQuiz_View_StatisticsAjax();
430
+ $view->statisticModel = $statisticModel;
431
+
432
+ $navi = null;
433
+
434
+ if (isset($data['generateNav']) && $data['generateNav']) {
435
+ $count = $statisticRefMapper->countOverviewNew($quizId, $data['onlyCompleted']);
436
+ $navi = ceil(($count > 0 ? $count : 1) / $limit);
437
+ }
438
+
439
+ return json_encode(array(
440
+ 'navi' => $navi,
441
+ 'html' => $view->getOverviewTable()
442
+ ));
443
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  }
lib/controller/WpProQuiz_Controller_StyleManager.php CHANGED
@@ -1,21 +1,25 @@
1
- <?php
2
- class WpProQuiz_Controller_StyleManager extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
- $this->show();
6
- }
7
-
8
- private function show() {
9
-
10
- wp_enqueue_style(
11
- 'wpProQuiz_front_style',
12
- plugins_url('css/wpProQuiz_front.min.css', WPPROQUIZ_FILE),
13
- array(),
14
- WPPROQUIZ_VERSION
15
- );
16
-
17
- $view = new WpProQuiz_View_StyleManager();
18
-
19
- $view->show();
20
- }
 
 
 
 
21
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_StyleManager extends WpProQuiz_Controller_Controller
4
+ {
5
+
6
+ public function route()
7
+ {
8
+ $this->show();
9
+ }
10
+
11
+ private function show()
12
+ {
13
+
14
+ wp_enqueue_style(
15
+ 'wpProQuiz_front_style',
16
+ plugins_url('css/wpProQuiz_front.min.css', WPPROQUIZ_FILE),
17
+ array(),
18
+ WPPROQUIZ_VERSION
19
+ );
20
+
21
+ $view = new WpProQuiz_View_StyleManager();
22
+
23
+ $view->show();
24
+ }
25
  }
lib/controller/WpProQuiz_Controller_Template.php CHANGED
@@ -1,30 +1,34 @@
1
- <?php
2
- class WpProQuiz_Controller_Template {
3
- public static function ajaxEditTemplate($data, $func) {
4
- if(!current_user_can('wpProQuiz_edit_quiz')) {
5
- return json_encode(array());
6
- }
7
-
8
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
9
-
10
- $template = new WpProQuiz_Model_Template($data);
11
-
12
- $templateMapper->updateName($template->getTemplateId(), $template->getName());
13
-
14
- return json_encode(array());
15
- }
16
-
17
- public static function ajaxDeleteTemplate($data, $func) {
18
- if(!current_user_can('wpProQuiz_edit_quiz')) {
19
- return json_encode(array());
20
- }
21
-
22
- $templateMapper = new WpProQuiz_Model_TemplateMapper();
23
-
24
- $template = new WpProQuiz_Model_Template($data);
25
-
26
- $templateMapper->delete($template->getTemplateId());
27
-
28
- return json_encode(array());
29
- }
 
 
 
 
30
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Template
4
+ {
5
+ public static function ajaxEditTemplate($data)
6
+ {
7
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
8
+ return json_encode(array());
9
+ }
10
+
11
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
12
+
13
+ $template = new WpProQuiz_Model_Template($data);
14
+
15
+ $templateMapper->updateName($template->getTemplateId(), $template->getName());
16
+
17
+ return json_encode(array());
18
+ }
19
+
20
+ public static function ajaxDeleteTemplate($data)
21
+ {
22
+ if (!current_user_can('wpProQuiz_edit_quiz')) {
23
+ return json_encode(array());
24
+ }
25
+
26
+ $templateMapper = new WpProQuiz_Model_TemplateMapper();
27
+
28
+ $template = new WpProQuiz_Model_Template($data);
29
+
30
+ $templateMapper->delete($template->getTemplateId());
31
+
32
+ return json_encode(array());
33
+ }
34
  }
lib/controller/WpProQuiz_Controller_Toplist.php CHANGED
@@ -1,283 +1,289 @@
1
- <?php
2
- class WpProQuiz_Controller_Toplist extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
-
6
- $quizId = $_GET['id'];
7
- $action = isset($_GET['action']) ? $_GET['action'] : 'show';
8
-
9
- switch($action) {
10
- case 'load_toplist':
11
- $this->loadToplist($quizId);
12
- break;
13
- case 'show':
14
- default:
15
- $this->showAdminToplist($quizId);
16
- break;
17
- }
18
- }
19
-
20
- private function loadToplist($quizId) {
21
- if(!current_user_can('wpProQuiz_toplist_edit')) {
22
- echo json_encode(array());
23
- return;
24
- }
25
-
26
- $toplistMapper = new WpProQuiz_Model_ToplistMapper();
27
- $j = array('data' => array());
28
- $limit = (int)$this->_post['limit'];
29
- $start = $limit * ($this->_post['page'] - 1);
30
- $isNav = isset($this->_post['nav']);
31
-
32
- if(isset($this->_post['a'])) {
33
- switch ($this->_post['a']) {
34
- case 'deleteAll':
35
- $toplistMapper->delete($quizId);
36
- break;
37
- case 'delete':
38
- if(!empty($this->_post['toplistIds']))
39
- $toplistMapper->delete($quizId, $this->_post['toplistIds']);
40
- break;
41
- }
42
-
43
- $start = 0;
44
- $isNav = true;
45
- }
46
-
47
- $toplist = $toplistMapper->fetch($quizId, $limit, $this->_post['sort'], $start);
48
-
49
- foreach($toplist as $tp) {
50
- $j['data'][] = array(
51
- 'id' => $tp->getToplistId(),
52
- 'name' => $tp->getName(),
53
- 'email' => $tp->getEmail(),
54
- 'type' => $tp->getUserId() ? 'R' : 'UR',
55
- 'date' => WpProQuiz_Helper_Until::convertTime($tp->getDate(), get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A')),
56
- 'points' => $tp->getPoints(),
57
- 'result' => $tp->getResult()
58
- );
59
- }
60
-
61
- if($isNav) {
62
-
63
- $count = $toplistMapper->count($quizId);
64
- $pages = ceil($count / $limit);
65
- $j['nav'] = array(
66
- 'count' => $count,
67
- 'pages' => $pages ? $pages : 1
68
- );
69
- }
70
-
71
- echo json_encode($j);
72
- }
73
-
74
- private function editAdminToplist() {
75
- $toplistId = $this->_post['toplistId'];
76
- $username = trim($this->_post['name']);
77
- $email = trim($this->_post['email']);
78
-
79
- if(empty($name) || empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
80
- return array('error' => __('No name or e-mail entered.', 'wp-pro-quiz'));
81
- }
82
-
83
-
84
- }
85
-
86
- private function showAdminToplist($quizId) {
87
- if(!current_user_can('wpProQuiz_toplist_edit')) {
88
- wp_die(__('You do not have sufficient permissions to access this page.'));
89
- }
90
-
91
- $view = new WpProQuiz_View_AdminToplist();
92
- $quizMapper = new WpProQuiz_Model_QuizMapper();
93
-
94
- $quiz = $quizMapper->fetch($quizId);
95
-
96
- $view->quiz = $quiz;
97
- $view->show();
98
- }
99
-
100
- public function getAddToplist(WpProQuiz_Model_Quiz $quiz) {
101
- $userId = get_current_user_id();
102
-
103
- if(!$quiz->isToplistActivated())
104
- return null;
105
-
106
- $data = array(
107
- 'userId' => $userId,
108
- 'token' => wp_create_nonce('wpProQuiz_toplist'),
109
- 'canAdd' => $this->preCheck($quiz->getToplistDataAddPermissions(), $userId),
110
- );
111
-
112
- if($quiz->isToplistDataCaptcha() && $userId == 0) {
113
- $captcha = WpProQuiz_Helper_Captcha::getInstance();
114
-
115
- if($captcha->isSupported()) {
116
- $data['captcha']['img'] = WPPROQUIZ_CAPTCHA_URL.'/'.$captcha->createImage();
117
- $data['captcha']['code'] = $captcha->getPrefix();
118
- }
119
- }
120
-
121
- return $data;
122
- }
123
-
124
- public function addInToplist() {
125
- $quizId = isset($this->_post['quizId']) ? $this->_post['quizId'] : 0;
126
- $prefix = !empty($this->_post['prefix']) ? trim($this->_post['prefix']) : '';
127
- $quizMapper = new WpProQuiz_Model_QuizMapper();
128
-
129
- $quiz = $quizMapper->fetch($quizId);
130
-
131
- $r = $this->handleAddInToplist($quiz);
132
-
133
- if($quiz->isToplistActivated() && $quiz->isToplistDataCaptcha() && get_current_user_id() == 0) {
134
- $captcha = WpProQuiz_Helper_Captcha::getInstance();
135
-
136
- if($captcha->isSupported()) {
137
- $captcha->remove($prefix);
138
- $captcha->cleanup();
139
-
140
- if($r !== true) {
141
- $r['captcha']['img'] = WPPROQUIZ_CAPTCHA_URL.'/'.$captcha->createImage();
142
- $r['captcha']['code'] = $captcha->getPrefix();
143
- }
144
- }
145
- }
146
-
147
- if($r === true)
148
- $r = array('text' => __('You signed up successfully.', 'wp-pro-quiz'), 'clear' => true);
149
-
150
-
151
- echo json_encode($r);
152
- }
153
-
154
- private function handleAddInToplist(WpProQuiz_Model_Quiz $quiz) {
155
- if(!wp_verify_nonce($this->_post['token'], 'wpProQuiz_toplist')) {
156
- return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
157
- }
158
-
159
- if(!isset($this->_post['points']) || !isset($this->_post['totalPoints'])) {
160
- return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
161
- }
162
-
163
- $quizId = $quiz->getId();
164
- $userId = get_current_user_id();
165
- $points = (int)$this->_post['points'];
166
- $totalPoints = (int)$this->_post['totalPoints'];
167
- $name = !empty($this->_post['name']) ? trim($this->_post['name']) : '';
168
- $email = !empty($this->_post['email']) ? trim($this->_post['email']) : '';
169
- $ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
170
- $captchaAnswer = !empty($this->_post['captcha']) ? trim($this->_post['captcha']) : '';
171
- $prefix = !empty($this->_post['prefix']) ? trim($this->_post['prefix']) : '';
172
-
173
- $quizMapper = new WpProQuiz_Model_QuizMapper();
174
- $toplistMapper = new WpProQuiz_Model_ToplistMapper();
175
-
176
- if($quiz == null || $quiz->getId() == 0 || !$quiz->isToplistActivated()) {
177
- return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
178
- }
179
-
180
- if(!$this->preCheck($quiz->getToplistDataAddPermissions(), $userId)) {
181
- return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
182
- }
183
-
184
- $numPoints = $quizMapper->sumQuestionPoints($quizId);
185
-
186
- if($totalPoints > $numPoints || $points > $numPoints) {
187
- return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
188
- }
189
-
190
- $clearTime = null;
191
-
192
- if($quiz->isToplistDataAddMultiple()) {
193
- $clearTime = $quiz->getToplistDataAddBlock() * 60;
194
- }
195
-
196
- if($userId > 0) {
197
- if($toplistMapper->countUser($quizId, $userId, $clearTime)) {
198
- return array('text' => __('You can not enter again.', 'wp-pro-quiz'), 'clear' => true);
199
- }
200
-
201
- $user = wp_get_current_user();
202
- $email = $user->user_email;
203
- $name = $user->display_name;
204
-
205
- } else {
206
- if($toplistMapper->countFree($quizId, $name, $email, $ip, $clearTime)) {
207
- return array('text' => __('You can not enter again.', 'wp-pro-quiz'), 'clear' => true);
208
- }
209
-
210
- if(empty($name) || empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
211
- return array('text' => __('No name or e-mail entered.', 'wp-pro-quiz'), 'clear' => false);
212
- }
213
-
214
- if(strlen($name) > 15) {
215
- return array('text' => __('Your name can not exceed 15 characters.', 'wp-pro-quiz'), 'clear' => false);
216
- }
217
-
218
- if($quiz->isToplistDataCaptcha()) {
219
- $captcha = WpProQuiz_Helper_Captcha::getInstance();
220
-
221
- if($captcha->isSupported()) {
222
- if(!$captcha->check($prefix, $captchaAnswer)) {
223
- return array('text' => __('You entered wrong captcha code.', 'wp-pro-quiz'), 'clear' => false);
224
- }
225
- }
226
- }
227
- }
228
-
229
- $toplist = new WpProQuiz_Model_Toplist();
230
- $toplist->setQuizId($quizId)
231
- ->setUserId($userId)
232
- ->setDate(time())
233
- ->setName($name)
234
- ->setEmail($email)
235
- ->setPoints($points)
236
- ->setResult(round($points / $totalPoints * 100, 2))
237
- ->setIp($ip);
238
-
239
- $toplistMapper->save($toplist);
240
-
241
- return true;
242
- }
243
-
244
- private function preCheck($type, $userId) {
245
- switch($type) {
246
- case WpProQuiz_Model_Quiz::QUIZ_TOPLIST_TYPE_ALL:
247
- return true;
248
- case WpProQuiz_Model_Quiz::QUIZ_TOPLIST_TYPE_ONLY_ANONYM:
249
- return $userId == 0;
250
- case WpProQuiz_Model_Quiz::QUIZ_TOPLIST_TYPE_ONLY_USER:
251
- return $userId > 0;
252
- }
253
-
254
- return false;
255
- }
256
-
257
- public function showFrontToplist() {
258
- $quizIds = empty($this->_post['quizIds']) ? array() : array_unique((array)$this->_post['quizIds']);
259
- $toplistMapper = new WpProQuiz_Model_ToplistMapper();
260
- $quizMapper = new WpProQuiz_Model_QuizMapper();
261
- $r = array();
262
- $j = array();
263
-
264
- foreach($quizIds as $quizId) {
265
- $quiz = $quizMapper->fetch($quizId);
266
- if($quiz == null || $quiz->getId() == 0)
267
- continue;
268
-
269
- $toplist = $toplistMapper->fetch($quizId, $quiz->getToplistDataShowLimit(), $quiz->getToplistDataSort());
270
-
271
- foreach($toplist as $tp) {
272
- $j[$quizId][] = array(
273
- 'name' => $tp->getName(),
274
- 'date' => WpProQuiz_Helper_Until::convertTime($tp->getDate(), get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A')),
275
- 'points' => $tp->getPoints(),
276
- 'result' => $tp->getResult()
277
- );
278
- }
279
- }
280
-
281
- echo json_encode($j);
282
- }
 
 
 
 
 
 
283
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_Toplist extends WpProQuiz_Controller_Controller
4
+ {
5
+ public function route()
6
+ {
7
+
8
+ $quizId = $_GET['id'];
9
+ $action = isset($_GET['action']) ? $_GET['action'] : 'show';
10
+
11
+ switch ($action) {
12
+ default:
13
+ $this->showAdminToplist($quizId);
14
+ break;
15
+ }
16
+ }
17
+
18
+ private function showAdminToplist($quizId)
19
+ {
20
+ if (!current_user_can('wpProQuiz_toplist_edit')) {
21
+ wp_die(__('You do not have sufficient permissions to access this page.'));
22
+ }
23
+
24
+ $view = new WpProQuiz_View_AdminToplist();
25
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
26
+
27
+ $quiz = $quizMapper->fetch($quizId);
28
+
29
+ $view->quiz = $quiz;
30
+ $view->show();
31
+ }
32
+
33
+ public function getAddToplist(WpProQuiz_Model_Quiz $quiz)
34
+ {
35
+ $userId = get_current_user_id();
36
+
37
+ if (!$quiz->isToplistActivated()) {
38
+ return null;
39
+ }
40
+
41
+ $data = array(
42
+ 'userId' => $userId,
43
+ 'token' => wp_create_nonce('wpProQuiz_toplist'),
44
+ 'canAdd' => $this->preCheck($quiz->getToplistDataAddPermissions(), $userId),
45
+ );
46
+
47
+ if ($quiz->isToplistDataCaptcha() && $userId == 0) {
48
+ $captcha = WpProQuiz_Helper_Captcha::getInstance();
49
+
50
+ if ($captcha->isSupported()) {
51
+ $data['captcha']['img'] = WPPROQUIZ_CAPTCHA_URL . '/' . $captcha->createImage();
52
+ $data['captcha']['code'] = $captcha->getPrefix();
53
+ }
54
+ }
55
+
56
+ return $data;
57
+ }
58
+
59
+ private function handleAddInToplist(WpProQuiz_Model_Quiz $quiz)
60
+ {
61
+ if (!wp_verify_nonce($this->_post['token'], 'wpProQuiz_toplist')) {
62
+ return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
63
+ }
64
+
65
+ if (!isset($this->_post['points']) || !isset($this->_post['totalPoints'])) {
66
+ return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
67
+ }
68
+
69
+ $quizId = $quiz->getId();
70
+ $userId = get_current_user_id();
71
+ $points = (int)$this->_post['points'];
72
+ $totalPoints = (int)$this->_post['totalPoints'];
73
+ $name = !empty($this->_post['name']) ? trim($this->_post['name']) : '';
74
+ $email = !empty($this->_post['email']) ? trim($this->_post['email']) : '';
75
+ $ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
76
+ $captchaAnswer = !empty($this->_post['captcha']) ? trim($this->_post['captcha']) : '';
77
+ $prefix = !empty($this->_post['prefix']) ? trim($this->_post['prefix']) : '';
78
+
79
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
80
+ $toplistMapper = new WpProQuiz_Model_ToplistMapper();
81
+
82
+ if ($quiz == null || $quiz->getId() == 0 || !$quiz->isToplistActivated()) {
83
+ return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
84
+ }
85
+
86
+ if (!$this->preCheck($quiz->getToplistDataAddPermissions(), $userId)) {
87
+ return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
88
+ }
89
+
90
+ $numPoints = $quizMapper->sumQuestionPoints($quizId);
91
+
92
+ if ($totalPoints > $numPoints || $points > $numPoints) {
93
+ return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
94
+ }
95
+
96
+ $clearTime = null;
97
+
98
+ if ($quiz->isToplistDataAddMultiple()) {
99
+ $clearTime = $quiz->getToplistDataAddBlock() * 60;
100
+ }
101
+
102
+ if ($userId > 0) {
103
+ if ($toplistMapper->countUser($quizId, $userId, $clearTime)) {
104
+ return array('text' => __('You can not enter again.', 'wp-pro-quiz'), 'clear' => true);
105
+ }
106
+
107
+ $user = wp_get_current_user();
108
+ $email = $user->user_email;
109
+ $name = $user->display_name;
110
+
111
+ } else {
112
+ if ($toplistMapper->countFree($quizId, $name, $email, $ip, $clearTime)) {
113
+ return array('text' => __('You can not enter again.', 'wp-pro-quiz'), 'clear' => true);
114
+ }
115
+
116
+ if (empty($name) || empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
117
+ return array('text' => __('No name or e-mail entered.', 'wp-pro-quiz'), 'clear' => false);
118
+ }
119
+
120
+ if (strlen($name) > 15) {
121
+ return array('text' => __('Your name can not exceed 15 characters.', 'wp-pro-quiz'), 'clear' => false);
122
+ }
123
+
124
+ if ($quiz->isToplistDataCaptcha()) {
125
+ $captcha = WpProQuiz_Helper_Captcha::getInstance();
126
+
127
+ if ($captcha->isSupported()) {
128
+ if (!$captcha->check($prefix, $captchaAnswer)) {
129
+ return array('text' => __('You entered wrong captcha code.', 'wp-pro-quiz'), 'clear' => false);
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ $toplist = new WpProQuiz_Model_Toplist();
136
+ $toplist->setQuizId($quizId)
137
+ ->setUserId($userId)
138
+ ->setDate(time())
139
+ ->setName($name)
140
+ ->setEmail($email)
141
+ ->setPoints($points)
142
+ ->setResult(round($points / $totalPoints * 100, 2))
143
+ ->setIp($ip);
144
+
145
+ $toplistMapper->save($toplist);
146
+
147
+ return true;
148
+ }
149
+
150
+ private function preCheck($type, $userId)
151
+ {
152
+ switch ($type) {
153
+ case WpProQuiz_Model_Quiz::QUIZ_TOPLIST_TYPE_ALL:
154
+ return true;
155
+ case WpProQuiz_Model_Quiz::QUIZ_TOPLIST_TYPE_ONLY_ANONYM:
156
+ return $userId == 0;
157
+ case WpProQuiz_Model_Quiz::QUIZ_TOPLIST_TYPE_ONLY_USER:
158
+ return $userId > 0;
159
+ }
160
+
161
+ return false;
162
+ }
163
+
164
+ public static function ajaxAdminToplist($data)
165
+ {
166
+ if (!current_user_can('wpProQuiz_toplist_edit')) {
167
+ return json_encode(array());
168
+ }
169
+
170
+ $toplistMapper = new WpProQuiz_Model_ToplistMapper();
171
+
172
+ $j = array('data' => array());
173
+ $limit = (int)$data['limit'];
174
+ $start = $limit * ($data['page'] - 1);
175
+ $isNav = isset($data['nav']);
176
+ $quizId = $data['quizId'];
177
+
178
+ if (isset($data['a'])) {
179
+ switch ($data['a']) {
180
+ case 'deleteAll':
181
+ $toplistMapper->delete($quizId);
182
+ break;
183
+ case 'delete':
184
+ if (!empty($data['toplistIds'])) {
185
+ $toplistMapper->delete($quizId, $data['toplistIds']);
186
+ }
187
+ break;
188
+ }
189
+
190
+ $start = 0;
191
+ $isNav = true;
192
+ }
193
+
194
+ $toplist = $toplistMapper->fetch($quizId, $limit, $data['sort'], $start);
195
+
196
+ foreach ($toplist as $tp) {
197
+ $j['data'][] = array(
198
+ 'id' => $tp->getToplistId(),
199
+ 'name' => $tp->getName(),
200
+ 'email' => $tp->getEmail(),
201
+ 'type' => $tp->getUserId() ? 'R' : 'UR',
202
+ 'date' => WpProQuiz_Helper_Until::convertTime($tp->getDate(),
203
+ get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A')),
204
+ 'points' => $tp->getPoints(),
205
+ 'result' => $tp->getResult()
206
+ );
207
+ }
208
+
209
+ if ($isNav) {
210
+
211
+ $count = $toplistMapper->count($quizId);
212
+ $pages = ceil($count / $limit);
213
+ $j['nav'] = array(
214
+ 'count' => $count,
215
+ 'pages' => $pages ? $pages : 1
216
+ );
217
+ }
218
+
219
+ return json_encode($j);
220
+ }
221
+
222
+ public static function ajaxAddInToplist($data)
223
+ {
224
+ // workaround ...
225
+ $_POST = $_POST['data'];
226
+
227
+ $ctn = new WpProQuiz_Controller_Toplist();
228
+
229
+ $quizId = isset($data['quizId']) ? $data['quizId'] : 0;
230
+ $prefix = !empty($data['prefix']) ? trim($data['prefix']) : '';
231
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
232
+
233
+ $quiz = $quizMapper->fetch($quizId);
234
+
235
+ $r = $ctn->handleAddInToplist($quiz);
236
+
237
+ if ($quiz->isToplistActivated() && $quiz->isToplistDataCaptcha() && get_current_user_id() == 0) {
238
+ $captcha = WpProQuiz_Helper_Captcha::getInstance();
239
+
240
+ if ($captcha->isSupported()) {
241
+ $captcha->remove($prefix);
242
+ $captcha->cleanup();
243
+
244
+ if ($r !== true) {
245
+ $r['captcha']['img'] = WPPROQUIZ_CAPTCHA_URL . '/' . $captcha->createImage();
246
+ $r['captcha']['code'] = $captcha->getPrefix();
247
+ }
248
+ }
249
+ }
250
+
251
+ if ($r === true) {
252
+ $r = array('text' => __('You signed up successfully.', 'wp-pro-quiz'), 'clear' => true);
253
+ }
254
+
255
+ return json_encode($r);
256
+ }
257
+
258
+ public static function ajaxShowFrontToplist($data)
259
+ {
260
+ // workaround ...
261
+ $_POST = $_POST['data'];
262
+
263
+ $quizIds = empty($data['quizIds']) ? array() : array_unique((array)$data['quizIds']);
264
+ $toplistMapper = new WpProQuiz_Model_ToplistMapper();
265
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
266
+ $j = array();
267
+
268
+ foreach ($quizIds as $quizId) {
269
+ $quiz = $quizMapper->fetch($quizId);
270
+ if ($quiz == null || $quiz->getId() == 0) {
271
+ continue;
272
+ }
273
+
274
+ $toplist = $toplistMapper->fetch($quizId, $quiz->getToplistDataShowLimit(), $quiz->getToplistDataSort());
275
+
276
+ foreach ($toplist as $tp) {
277
+ $j[$quizId][] = array(
278
+ 'name' => $tp->getName(),
279
+ 'date' => WpProQuiz_Helper_Until::convertTime($tp->getDate(),
280
+ get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A')),
281
+ 'points' => $tp->getPoints(),
282
+ 'result' => $tp->getResult()
283
+ );
284
+ }
285
+ }
286
+
287
+ return json_encode($j);
288
+ }
289
  }
lib/controller/WpProQuiz_Controller_WpqSupport.php CHANGED
@@ -1,13 +1,17 @@
1
- <?php
2
- class WpProQuiz_Controller_WpqSupport extends WpProQuiz_Controller_Controller {
3
-
4
- public function route() {
5
- $this->showView();
6
- }
7
-
8
- private function showView() {
9
- $view = new WpProQuiz_View_WpqSupport();
10
-
11
- $view->show();
12
- }
 
 
 
 
13
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Controller_WpqSupport extends WpProQuiz_Controller_Controller
4
+ {
5
+
6
+ public function route()
7
+ {
8
+ $this->showView();
9
+ }
10
+
11
+ private function showView()
12
+ {
13
+ $view = new WpProQuiz_View_WpqSupport();
14
+
15
+ $view->show();
16
+ }
17
  }
lib/helper/WpProQuiz_Helper_Captcha.php CHANGED
@@ -1,76 +1,93 @@
1
- <?php
2
- class WpProQuiz_Helper_Captcha {
3
-
4
- private static $INSTANCE = null;
5
-
6
- private $_captcha = null;
7
- private $_supp = false;
8
- private $_prefix = '';
9
-
10
- public function __construct() {
11
- if(!class_exists('ReallySimpleCaptcha'))
12
- return;
13
-
14
- $this->_captcha = new ReallySimpleCaptcha();
15
-
16
- $this->_captcha->tmp_dir = WPPROQUIZ_CAPTCHA_DIR.'/';
17
- $this->_captcha->file_mode = 0666;
18
- $this->_captcha->answer_file_mode = 0666;
19
-
20
- if(!$this->_captcha->make_tmp_dir()) {
21
- $this->_supp = false;
22
- return;
23
- }
24
-
25
- $this->_supp = true;
26
- }
27
-
28
- public function getPrefix() {
29
- return $this->_prefix;
30
- }
31
-
32
- public function isSupported() {
33
- return $this->_supp;
34
- }
35
-
36
- public function createImage() {
37
- if(!$this->isSupported())
38
- return false;
39
-
40
- $w = $this->_captcha->generate_random_word();
41
- $this->_prefix = mt_rand();
42
- return $this->_captcha->generate_image($this->_prefix, $w);
43
- }
44
-
45
- public function remove($prefix) {
46
- if(!$this->isSupported())
47
- return;
48
-
49
- $this->_captcha->remove($prefix);
50
- }
51
-
52
- public function check($prefix, $answer) {
53
- if(!$this->isSupported())
54
- return;
55
-
56
- return $this->_captcha->check($prefix, $answer);
57
- }
58
-
59
- public function cleanup() {
60
- if(!$this->isSupported())
61
- return;
62
-
63
- $this->_captcha->cleanup();
64
- }
65
-
66
- /**
67
- * @return WpProQuiz_Helper_Captcha
68
- */
69
- public static function getInstance() {
70
- if(WpProQuiz_Helper_Captcha::$INSTANCE == null) {
71
- WpProQuiz_Helper_Captcha::$INSTANCE = new WpProQuiz_Helper_Captcha();
72
- }
73
-
74
- return WpProQuiz_Helper_Captcha::$INSTANCE;
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Helper_Captcha
4
+ {
5
+
6
+ private static $INSTANCE = null;
7
+
8
+ private $_captcha = null;
9
+ private $_supp = false;
10
+ private $_prefix = '';
11
+
12
+ public function __construct()
13
+ {
14
+ if (!class_exists('ReallySimpleCaptcha')) {
15
+ return;
16
+ }
17
+
18
+ $this->_captcha = new ReallySimpleCaptcha();
19
+
20
+ $this->_captcha->tmp_dir = WPPROQUIZ_CAPTCHA_DIR . '/';
21
+ $this->_captcha->file_mode = 0666;
22
+ $this->_captcha->answer_file_mode = 0666;
23
+
24
+ if (!$this->_captcha->make_tmp_dir()) {
25
+ $this->_supp = false;
26
+
27
+ return;
28
+ }
29
+
30
+ $this->_supp = true;
31
+ }
32
+
33
+ public function getPrefix()
34
+ {
35
+ return $this->_prefix;
36
+ }
37
+
38
+ public function isSupported()
39
+ {
40
+ return $this->_supp;
41
+ }
42
+
43
+ public function createImage()
44
+ {
45
+ if (!$this->isSupported()) {
46
+ return false;
47
+ }
48
+
49
+ $w = $this->_captcha->generate_random_word();
50
+ $this->_prefix = mt_rand();
51
+
52
+ return $this->_captcha->generate_image($this->_prefix, $w);
53
+ }
54
+
55
+ public function remove($prefix)
56
+ {
57
+ if (!$this->isSupported()) {
58
+ return;
59
+ }
60
+
61
+ $this->_captcha->remove($prefix);
62
+ }
63
+
64
+ public function check($prefix, $answer)
65
+ {
66
+ if (!$this->isSupported()) {
67
+ return;
68
+ }
69
+
70
+ return $this->_captcha->check($prefix, $answer);
71
+ }
72
+
73
+ public function cleanup()
74
+ {
75
+ if (!$this->isSupported()) {
76
+ return;
77
+ }
78
+
79
+ $this->_captcha->cleanup();
80
+ }
81
+
82
+ /**
83
+ * @return WpProQuiz_Helper_Captcha
84
+ */
85
+ public static function getInstance()
86
+ {
87
+ if (WpProQuiz_Helper_Captcha::$INSTANCE == null) {
88
+ WpProQuiz_Helper_Captcha::$INSTANCE = new WpProQuiz_Helper_Captcha();
89
+ }
90
+
91
+ return WpProQuiz_Helper_Captcha::$INSTANCE;
92
+ }
93
  }
lib/helper/WpProQuiz_Helper_DbUpgrade.php CHANGED
@@ -1,1099 +1,1137 @@
1
- <?php
2
- class WpProQuiz_Helper_DbUpgrade {
3
-
4
- const WPPROQUIZ_DB_VERSION = 25;
5
-
6
- private $_wpdb;
7
- private $_prefix;
8
-
9
- public function __construct() {
10
- global $wpdb;
11
-
12
- $this->_wpdb = $wpdb;
13
- }
14
-
15
- public function upgrade($version) {
16
- @set_time_limit(300);
17
-
18
- if($version === false || ((int)$version) > WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION) {
19
- $this->install();
20
- return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
21
- }
22
-
23
- $version = (int) $version;
24
-
25
- if($version === WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION)
26
- return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
27
-
28
- do {
29
- $f = 'upgradeDbV'.$version;
30
-
31
- if(method_exists($this, $f)) {
32
- $version = $this->$f();
33
- } else {
34
- die("WpProQuiz upgrade error");
35
- }
36
- } while ($version < WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION);
37
-
38
- return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
39
- }
40
-
41
- public function delete() {
42
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_category`');
43
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_form`');
44
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock`');
45
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master`');
46
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_prerequisite`');
47
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question`');
48
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic`');
49
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic_ref`');
50
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_template`');
51
- $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_toplist`');
52
- }
53
-
54
- private function install() {
55
-
56
- $this->delete();
57
-
58
- $this->databaseDelta();
59
- }
60
-
61
- public function databaseDelta() {
62
- if(!function_exists('dbDelta'))
63
- require_once(ABSPATH.'wp-admin/includes/upgrade.php');
64
-
65
- dbDelta("
66
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_category (
67
- category_id int(10) unsigned NOT NULL AUTO_INCREMENT,
68
- category_name varchar(200) NOT NULL,
69
- type enum('QUESTION','QUIZ') NOT NULL DEFAULT 'QUESTION',
70
- PRIMARY KEY (category_id)
71
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
72
-
73
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_form (
74
- form_id int(11) NOT NULL AUTO_INCREMENT,
75
- quiz_id int(11) NOT NULL,
76
- fieldname varchar(100) NOT NULL,
77
- type tinyint(4) NOT NULL,
78
- required tinyint(1) unsigned NOT NULL,
79
- sort tinyint(4) NOT NULL,
80
- show_in_statistic tinyint(1) unsigned NOT NULL,
81
- data mediumtext,
82
- PRIMARY KEY (form_id),
83
- KEY quiz_id (quiz_id)
84
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
85
-
86
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_lock (
87
- quiz_id int(11) NOT NULL,
88
- lock_ip varchar(100) NOT NULL,
89
- user_id bigint(20) unsigned NOT NULL,
90
- lock_type tinyint(3) unsigned NOT NULL,
91
- lock_date int(11) NOT NULL,
92
- PRIMARY KEY (quiz_id,lock_ip,user_id,lock_type)
93
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
94
-
95
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_master (
96
- id int(11) NOT NULL AUTO_INCREMENT,
97
- name varchar(200) NOT NULL,
98
- text text NOT NULL,
99
- result_text text NOT NULL,
100
- result_grade_enabled tinyint(1) NOT NULL,
101
- title_hidden tinyint(1) NOT NULL,
102
- btn_restart_quiz_hidden tinyint(1) NOT NULL,
103
- btn_view_question_hidden tinyint(1) NOT NULL,
104
- question_random tinyint(1) NOT NULL,
105
- answer_random tinyint(1) NOT NULL,
106
- time_limit int(11) NOT NULL,
107
- statistics_on tinyint(1) NOT NULL,
108
- statistics_ip_lock int(10) unsigned NOT NULL,
109
- show_points tinyint(1) NOT NULL,
110
- quiz_run_once tinyint(1) NOT NULL,
111
- quiz_run_once_type tinyint(4) NOT NULL,
112
- quiz_run_once_cookie tinyint(1) NOT NULL,
113
- quiz_run_once_time int(10) unsigned NOT NULL,
114
- numbered_answer tinyint(1) NOT NULL,
115
- hide_answer_message_box tinyint(1) NOT NULL,
116
- disabled_answer_mark tinyint(1) NOT NULL,
117
- show_max_question tinyint(1) NOT NULL,
118
- show_max_question_value int(10) unsigned NOT NULL,
119
- show_max_question_percent tinyint(1) NOT NULL,
120
- toplist_activated tinyint(1) NOT NULL,
121
- toplist_data text NOT NULL,
122
- show_average_result tinyint(1) NOT NULL,
123
- prerequisite tinyint(1) NOT NULL,
124
- quiz_modus tinyint(3) unsigned NOT NULL,
125
- show_review_question tinyint(1) NOT NULL,
126
- quiz_summary_hide tinyint(1) NOT NULL,
127
- skip_question_disabled tinyint(1) NOT NULL,
128
- email_notification tinyint(3) unsigned NOT NULL,
129
- user_email_notification tinyint(1) unsigned NOT NULL,
130
- show_category_score tinyint(1) unsigned NOT NULL,
131
- hide_result_correct_question tinyint(1) unsigned NOT NULL DEFAULT '0',
132
- hide_result_quiz_time tinyint(1) unsigned NOT NULL DEFAULT '0',
133
- hide_result_points tinyint(1) unsigned NOT NULL DEFAULT '0',
134
- autostart tinyint(1) unsigned NOT NULL DEFAULT '0',
135
- forcing_question_solve tinyint(1) unsigned NOT NULL DEFAULT '0',
136
- hide_question_position_overview tinyint(1) unsigned NOT NULL DEFAULT '0',
137
- hide_question_numbering tinyint(1) unsigned NOT NULL DEFAULT '0',
138
- form_activated tinyint(1) unsigned NOT NULL,
139
- form_show_position tinyint(3) unsigned NOT NULL,
140
- start_only_registered_user tinyint(1) unsigned NOT NULL,
141
- questions_per_page tinyint(3) unsigned NOT NULL,
142
- sort_categories tinyint(1) unsigned NOT NULL,
143
- show_category tinyint(1) unsigned NOT NULL,
144
- category_id int(10) unsigned NOT NULL,
145
- admin_email text NOT NULL,
146
- user_email text NOT NULL,
147
- plugin_container text,
148
- PRIMARY KEY (id)
149
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
150
-
151
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_prerequisite (
152
- prerequisite_quiz_id int(11) NOT NULL,
153
- quiz_id int(11) NOT NULL,
154
- PRIMARY KEY (prerequisite_quiz_id,quiz_id)
155
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
156
-
157
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_question (
158
- id int(11) NOT NULL AUTO_INCREMENT,
159
- quiz_id int(11) NOT NULL,
160
- online tinyint(1) unsigned NOT NULL,
161
- sort smallint(5) unsigned NOT NULL,
162
- title varchar(200) NOT NULL,
163
- points int(11) NOT NULL,
164
- question text NOT NULL,
165
- correct_msg text NOT NULL,
166
- incorrect_msg text NOT NULL,
167
- correct_same_text tinyint(1) NOT NULL,
168
- tip_enabled tinyint(1) NOT NULL,
169
- tip_msg text NOT NULL,
170
- answer_type varchar(50) NOT NULL,
171
- show_points_in_box tinyint(1) NOT NULL,
172
- answer_points_activated tinyint(1) NOT NULL,
173
- answer_data longtext NOT NULL,
174
- category_id int(10) unsigned NOT NULL,
175
- answer_points_diff_modus_activated tinyint(1) unsigned NOT NULL,
176
- disable_correct tinyint(1) unsigned NOT NULL,
177
- matrix_sort_answer_criteria_width tinyint(3) unsigned NOT NULL,
178
- PRIMARY KEY (id),
179
- KEY quiz_id (quiz_id),
180
- KEY category_id (category_id)
181
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
182
-
183
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_statistic (
184
- statistic_ref_id int(10) unsigned NOT NULL,
185
- question_id int(11) NOT NULL,
186
- correct_count int(10) unsigned NOT NULL,
187
- incorrect_count int(10) unsigned NOT NULL,
188
- hint_count int(10) unsigned NOT NULL,
189
- solved_count tinyint(1) NOT NULL,
190
- points int(10) unsigned NOT NULL,
191
- question_time int(10) unsigned NOT NULL,
192
- answer_data text,
193
- PRIMARY KEY (statistic_ref_id,question_id)
194
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
195
-
196
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_statistic_ref (
197
- statistic_ref_id int(10) unsigned NOT NULL AUTO_INCREMENT,
198
- quiz_id int(11) NOT NULL,
199
- user_id bigint(20) unsigned NOT NULL,
200
- create_time int(11) NOT NULL,
201
- is_old tinyint(1) unsigned NOT NULL,
202
- form_data text,
203
- PRIMARY KEY (statistic_ref_id),
204
- KEY quiz_id (quiz_id,user_id),
205
- KEY time (create_time)
206
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
207
-
208
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_template (
209
- template_id int(11) NOT NULL AUTO_INCREMENT,
210
- name varchar(200) NOT NULL,
211
- type tinyint(3) unsigned NOT NULL,
212
- data text NOT NULL,
213
- PRIMARY KEY (template_id)
214
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
215
-
216
- CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_toplist (
217
- toplist_id int(11) NOT NULL AUTO_INCREMENT,
218
- quiz_id int(11) NOT NULL,
219
- date int(10) unsigned NOT NULL,
220
- user_id bigint(20) unsigned NOT NULL,
221
- name varchar(30) NOT NULL,
222
- email varchar(200) NOT NULL,
223
- points int(10) unsigned NOT NULL,
224
- result float unsigned NOT NULL,
225
- ip varchar(100) NOT NULL,
226
- PRIMARY KEY (toplist_id,quiz_id)
227
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
228
- ");
229
- }
230
-
231
- private function upgradeDbV1() {
232
-
233
- $this->_wpdb->query('
234
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
235
- ADD `back_button` TINYINT( 1 ) NOT NULL AFTER `answer_random`,
236
- ADD `check_answer` TINYINT( 1 ) NOT NULL AFTER `answer_random`,
237
- ADD `result_text` TEXT NOT NULL AFTER `text`
238
- ');
239
-
240
- return 2;
241
- }
242
-
243
- private function upgradeDbV2() {
244
- return 3;
245
- }
246
-
247
- private function upgradeDbV3() {
248
-
249
- $this->_wpdb->query('
250
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
251
- ADD `incorrect_count` INT UNSIGNED NOT NULL AFTER `incorrect_msg` ,
252
- ADD `correct_count` INT UNSIGNED NOT NULL AFTER `incorrect_msg` ,
253
- ADD `correct_same_text` TINYINT( 1 ) NOT NULL AFTER `incorrect_msg`
254
- ');
255
-
256
- $this->_wpdb->query('
257
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
258
- ADD `statistics_on` TINYINT( 1 ) NOT NULL ,
259
- ADD `statistics_ip_lock` INT UNSIGNED NOT NULL
260
- ');
261
-
262
- $this->_wpdb->query('
263
- CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock` (
264
- `quiz_id` int(11) NOT NULL,
265
- `lock_ip` varchar(100) NOT NULL,
266
- `lock_date` int(11) NOT NULL,
267
- PRIMARY KEY (`quiz_id`,`lock_ip`)
268
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
269
- ');
270
-
271
- $this->_wpdb->query('
272
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
273
- ADD INDEX ( `quiz_id` )
274
- ');
275
-
276
- return 4;
277
- }
278
-
279
- private function upgradeDbV4() {
280
-
281
- $this->_wpdb->query('
282
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
283
- ADD `tip_enabled` TINYINT( 1 ) NOT NULL AFTER `incorrect_count` ,
284
- ADD `tip_msg` TEXT NOT NULL AFTER `tip_enabled` ,
285
- ADD `tip_count` INT NOT NULL AFTER `tip_msg`
286
- ');
287
-
288
- return 5;
289
- }
290
-
291
- private function upgradeFixDbV4() {
292
- if($this->_wpdb->prefix != 'wp_') {
293
- $this->_wpdb->query('SELECT * FROM `'.$this->_wpdb->prefix.'wp_pro_quiz_question` LIMIT 0,1');
294
-
295
- $names = $this->_wpdb->get_col_info('name');
296
-
297
- if(!in_array('tip_enabled', $names)) {
298
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question` ADD `tip_enabled` TINYINT( 1 ) NOT NULL AFTER `incorrect_count`');
299
- }
300
-
301
- if(!in_array('tip_msg', $names)) {
302
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question` ADD `tip_msg` TEXT NOT NULL AFTER `tip_enabled`');
303
- }
304
-
305
- if(!in_array('tip_count', $names)) {
306
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question` ADD `tip_count` INT NOT NULL AFTER `tip_msg`');
307
- }
308
- }
309
- }
310
-
311
- private function upgradeDbV5() {
312
-
313
- $this->upgradeFixDbV4();
314
-
315
- $this->_wpdb->query('
316
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
317
- ADD `result_grade_enabled` TINYINT( 1 ) NOT NULL AFTER `result_text`
318
- ');
319
-
320
- return 6;
321
- }
322
-
323
- private function upgradeDbV6() {
324
-
325
- $this->_wpdb->query('
326
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
327
- ADD `points` INT NOT NULL AFTER `title`
328
- ');
329
-
330
- $this->_wpdb->query('
331
- UPDATE `'.$this->_wpdb->prefix.'wp_pro_quiz_question` SET `points` = 1
332
- ');
333
-
334
- $this->_wpdb->query('
335
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
336
- ADD `show_points` TINYINT( 1 ) NOT NULL
337
- ');
338
-
339
- return 7;
340
- }
341
-
342
- private function upgradeDbV7() {
343
- $this->_wpdb->query('
344
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
345
- CHANGE `name` `name` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
346
- CHANGE `text` `text` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
347
- CHANGE `result_text` `result_text` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
348
- ');
349
-
350
- $this->_wpdb->query('
351
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
352
- CHANGE `title` `title` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
353
- CHANGE `question` `question` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
354
- CHANGE `correct_msg` `correct_msg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
355
- CHANGE `incorrect_msg` `incorrect_msg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
356
- CHANGE `tip_msg` `tip_msg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
357
- CHANGE `answer_type` `answer_type` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
358
- CHANGE `answer_json` `answer_json` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
359
- ');
360
-
361
- $this->_wpdb->query('
362
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_lock`
363
- CHANGE `lock_ip` `lock_ip` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
364
- ');
365
-
366
- $this->_wpdb->query('
367
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_lock` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
368
- ');
369
-
370
- $this->_wpdb->query('
371
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
372
- ');
373
-
374
- $this->_wpdb->query('
375
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
376
- ');
377
-
378
- return 8;
379
- }
380
-
381
- private function upgradeDbV8() {
382
-
383
- $this->_wpdb->query('
384
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
385
- ADD `btn_restart_quiz_hidden` TINYINT( 1 ) NOT NULL AFTER `title_hidden` ,
386
- ADD `btn_view_question_hidden` TINYINT( 1 ) NOT NULL AFTER `btn_restart_quiz_hidden`
387
- ');
388
-
389
- return 9;
390
- }
391
-
392
- private function upgradeFixDbV8() {
393
- if($this->_wpdb->prefix != 'wp_') {
394
- $this->_wpdb->query('SELECT * FROM `'.$this->_wpdb->prefix.'wp_pro_quiz_master` LIMIT 0,1');
395
-
396
- $names = $this->_wpdb->get_col_info('name');
397
-
398
- if(!in_array('btn_restart_quiz_hidden', $names)) {
399
- $this->_wpdb->query('
400
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
401
- ADD `btn_restart_quiz_hidden` TINYINT( 1 ) NOT NULL AFTER `title_hidden`
402
- ');
403
- }
404
-
405
- if(!in_array('btn_view_question_hidden', $names)) {
406
- $this->_wpdb->query('
407
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
408
- ADD `btn_view_question_hidden` TINYINT( 1 ) NOT NULL AFTER `btn_restart_quiz_hidden`
409
- ');
410
- }
411
- }
412
- }
413
-
414
- private function upgradeDbV9() {
415
-
416
- $this->upgradeFixDbV8();
417
-
418
- $this->_wpdb->query('
419
- TRUNCATE `'.$this->_wpdb->prefix.'wp_pro_quiz_lock`
420
- ');
421
-
422
- $this->_wpdb->query('
423
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_lock`
424
- ADD `user_id` BIGINT UNSIGNED NOT NULL AFTER `lock_ip` ,
425
- ADD `lock_type` TINYINT UNSIGNED NOT NULL AFTER `user_id`
426
- ');
427
-
428
- $this->_wpdb->query('
429
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_lock`
430
- DROP PRIMARY KEY ,
431
- ADD PRIMARY KEY ( `quiz_id` , `lock_ip` , `user_id` , `lock_type` )
432
- ');
433
-
434
- $this->_wpdb->query('
435
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
436
- ADD `quiz_run_once` TINYINT( 1 ) NOT NULL ,
437
- ADD `quiz_run_once_type` TINYINT NOT NULL ,
438
- ADD `quiz_run_once_cookie` TINYINT( 1 ) NOT NULL ,
439
- ADD `quiz_run_once_time` INT UNSIGNED NOT NULL
440
- ');
441
-
442
- $this->_wpdb->query('
443
- CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic` (
444
- `quiz_id` int(11) NOT NULL,
445
- `question_id` int(11) NOT NULL,
446
- `user_id` bigint(20) unsigned NOT NULL,
447
- `correct_count` int(10) unsigned NOT NULL,
448
- `incorrect_count` int(10) unsigned NOT NULL,
449
- `hint_count` int(10) unsigned NOT NULL,
450
- PRIMARY KEY (`quiz_id`,`question_id`,`user_id`)
451
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
452
- ');
453
-
454
- $this->_wpdb->query('
455
- INSERT INTO `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic` (quiz_id, question_id, user_id, correct_count, incorrect_count, hint_count)
456
- SELECT
457
- question.quiz_id, id, 0, question.correct_count, question.incorrect_count, tip_count
458
- FROM
459
- `'.$this->_wpdb->prefix.'wp_pro_quiz_question` as question
460
- WHERE
461
- question.correct_count > 0 OR question.incorrect_count > 0 OR tip_count > 0
462
- ');
463
-
464
- return 10;
465
- }
466
-
467
- private function upgradeDbV10() {
468
-
469
- $this->_wpdb->query('
470
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
471
- ADD `question_on_single_page` TINYINT( 1 ) NOT NULL ,
472
- ADD `numbered_answer` TINYINT( 1 ) NOT NULL
473
- ');
474
-
475
- return 11;
476
- }
477
-
478
- private function upgradeDbV11() {
479
-
480
- $this->_wpdb->query('
481
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
482
- ADD `points_per_answer` TINYINT( 1 ) NOT NULL ,
483
- ADD `points_answer` INT UNSIGNED NOT NULL ,
484
- ADD `show_points_in_box` TINYINT( 1 ) NOT NULL
485
- ');
486
-
487
- $this->_wpdb->query('
488
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic`
489
- ADD `correct_answer_count` INT UNSIGNED NOT NULL
490
- ');
491
-
492
- $this->_wpdb->query('UPDATE `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic` SET `correct_answer_count` = `correct_count`');
493
-
494
- $this->_wpdb->query('UPDATE `'.$this->_wpdb->prefix.'wp_pro_quiz_question` SET `points_answer` = `points`');
495
-
496
- return 12;
497
- }
498
-
499
- private function upgradeDbV12() {
500
-
501
- $this->_wpdb->query('
502
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
503
- ADD `hide_answer_message_box` TINYINT( 1 ) NOT NULL ,
504
- ADD `disabled_answer_mark` TINYINT( 1 ) NOT NULL ,
505
- ADD `show_max_question` TINYINT( 1 ) NOT NULL ,
506
- ADD `show_max_question_value` INT UNSIGNED NOT NULL ,
507
- ADD `show_max_question_percent` TINYINT( 1 ) NOT NULL
508
- ');
509
-
510
- return 13;
511
- }
512
-
513
- private function upgradeDbV13() {
514
-
515
- //WordPress SVN Bug
516
-
517
- $this->_wpdb->query('SELECT * FROM `'.$this->_wpdb->prefix.'wp_pro_quiz_master` LIMIT 0,1');
518
-
519
- $names = $this->_wpdb->get_col_info('name');
520
-
521
- if(!in_array('hide_answer_message_box', $names)) {
522
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` ADD `hide_answer_message_box` TINYINT( 1 ) NOT NULL');
523
- }
524
-
525
- if(!in_array('disabled_answer_mark', $names)) {
526
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` ADD `disabled_answer_mark` TINYINT( 1 ) NOT NULL');
527
- }
528
-
529
- if(!in_array('show_max_question', $names)) {
530
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` ADD `show_max_question` TINYINT( 1 ) NOT NULL');
531
- }
532
-
533
- if(!in_array('show_max_question_value', $names)) {
534
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` ADD `show_max_question_value` INT UNSIGNED NOT NULL');
535
- }
536
-
537
- if(!in_array('show_max_question_percent', $names)) {
538
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` ADD `show_max_question_percent` TINYINT( 1 ) NOT NULL');
539
- }
540
-
541
- return 14;
542
- }
543
-
544
- private function upgradeDbV14() {
545
-
546
- $this->_wpdb->query('
547
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
548
- CHANGE `sort` `sort` SMALLINT UNSIGNED NOT NULL
549
- ');
550
-
551
- return 15;
552
- }
553
-
554
- private function upgradeDbV15() {
555
-
556
- $this->_wpdb->query('
557
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
558
- ADD `answer_points_activated` tinyint(1) NOT NULL,
559
- ADD `answer_data` longtext NOT NULL
560
- ');
561
-
562
- $this->_wpdb->query('
563
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_statistic`
564
- ADD `points` int(10) unsigned NOT NULL
565
- ');
566
-
567
- $this->_wpdb->query('
568
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
569
- ADD `toplist_activated` tinyint(1) NOT NULL,
570
- ADD `toplist_data` text NOT NULL,
571
- ADD `show_average_result` tinyint(1) NOT NULL,
572
- ADD `prerequisite` tinyint(1) NOT NULL
573
- ');
574
-
575
- $this->_wpdb->query('
576
- CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_prerequisite` (
577
- `prerequisite_quiz_id` int(11) NOT NULL,
578
- `quiz_id` int(11) NOT NULL,
579
- PRIMARY KEY (`prerequisite_quiz_id`,`quiz_id`)
580
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
581
- ');
582
-
583
- $this->_wpdb->query('
584
- CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_toplist` (
585
- `toplist_id` int(11) NOT NULL AUTO_INCREMENT,
586
- `quiz_id` int(11) NOT NULL,
587
- `date` int(10) unsigned NOT NULL,
588
- `user_id` bigint(20) unsigned NOT NULL,
589
- `name` varchar(30) NOT NULL,
590
- `email` varchar(200) NOT NULL,
591
- `points` int(10) unsigned NOT NULL,
592
- `result` float unsigned NOT NULL,
593
- `ip` varchar(100) NOT NULL,
594
- PRIMARY KEY (`toplist_id`,`quiz_id`)
595
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
596
- ');
597
-
598
-
599
- $results = $this->_wpdb->get_results('SELECT id, answer_type, answer_json, points_per_answer, points_answer FROM `'.$this->_wpdb->prefix.'wp_pro_quiz_question`', ARRAY_A);
600
-
601
- foreach($results as $row) {
602
-
603
- $data = json_decode($row['answer_json'], true);
604
- $newData = array();
605
-
606
- if($data === null) {
607
- continue;
608
- }
609
-
610
- if($row['answer_type'] == 'single' || $row['answer_type'] == 'multiple') {
611
- foreach($data['classic_answer']['answer'] as $k => $v) {
612
- $x = new WpProQuiz_Model_AnswerTypes();
613
-
614
- $x->setAnswer($v);
615
-
616
- if(isset($data['classic_answer']['correct']) && in_array($k, $data['classic_answer']['correct'])) {
617
- $x->setCorrect(true);
618
-
619
- if($row['points_per_answer']) {
620
- $x->setPoints($row['points_answer']);
621
- }
622
-
623
- } else {
624
- $x->setCorrect(false);
625
-
626
- if($row['points_per_answer']) {
627
- $x->setPoints(0);
628
- }
629
- }
630
-
631
- if(isset($data['classic_answer']['html']) && in_array($k, $data['classic_answer']['html'])) {
632
- $x->setHtml(true);
633
- } else {
634
- $x->setHtml(false);
635
- }
636
-
637
- $newData[] = $x;
638
-
639
- }
640
- } elseif($row['answer_type'] == 'cloze_answer') {
641
- $x = new WpProQuiz_Model_AnswerTypes();
642
-
643
- $x->setAnswer($data['answer_cloze']['text']);
644
-
645
- $newData[] = $x;
646
- } elseif($row['answer_type'] == 'matrix_sort_answer') {
647
- foreach($data['answer_matrix_sort']['answer'] as $k => $v) {
648
- $x = new WpProQuiz_Model_AnswerTypes();
649
-
650
- $x->setAnswer($v);
651
- $x->setSortString($data['answer_matrix_sort']['sort_string'][$k]);
652
-
653
- if($row['points_per_answer']) {
654
- $x->setPoints($row['points_answer']);
655
- }
656
-
657
- if(isset($data['answer_matrix_sort']['answer_html']) && in_array($k, $data['answer_matrix_sort']['answer_html'])) {
658
- $x->setHtml(true);
659
- } else {
660
- $x->setHtml(false);
661
- }
662
-
663
- if(isset($data['answer_matrix_sort']['sort_string_html']) && in_array($k, $data['answer_matrix_sort']['sort_string_html'])) {
664
- $x->setSortStringHtml(true);
665
- } else {
666
- $x->setSortStringHtml(false);
667
- }
668
-
669
- $newData[] = $x;
670
-
671
- }
672
- } elseif($row['answer_type'] == 'free_answer') {
673
- $x = new WpProQuiz_Model_AnswerTypes();
674
-
675
- $x->setAnswer($data['free_answer']['correct']);
676
-
677
- $newData[] = $x;
678
- } elseif($row['answer_type'] == 'sort_answer') {
679
- foreach($data['answer_sort']['answer'] as $k => $v) {
680
- $x = new WpProQuiz_Model_AnswerTypes();
681
-
682
- $x->setAnswer($v);
683
-
684
- if($row['points_per_answer']) {
685
- $x->setPoints($row['points_answer']);
686
- }
687
-
688
- if(isset($data['answer_sort']['html']) && in_array($k, $data['answer_sort']['html'])) {
689
- $x->setHtml(true);
690
- } else {
691
- $x->setHtml(false);
692
- }
693
-
694
- $newData[] = $x;
695
- }
696
- }
697
-
698
-
699
- $this->_wpdb->update(
700
- $this->_wpdb->prefix.'wp_pro_quiz_question',
701
- array(
702
- 'answer_data' => serialize($newData)
703
- ),
704
- array(
705
- 'id' => $row['id']
706
- )
707
- );
708
-
709
- }
710
-
711
- $this->_wpdb->query(
712
- 'UPDATE '.$this->_wpdb->prefix.'wp_pro_quiz_question
713
- SET
714
- answer_points_activated = points_per_answer
715
- WHERE
716
- answer_type <> \'free_answer\''
717
- );
718
-
719
-
720
- //Statistics
721
- $this->_wpdb->query(
722
- 'UPDATE
723
- '.$this->_wpdb->prefix.'wp_pro_quiz_statistic AS s
724
- SET
725
- s.points = ( SELECT q.points_answer FROM '.$this->_wpdb->prefix.'wp_pro_quiz_question AS q WHERE q.id = s.question_id ) * s.correct_answer_count
726
- WHERE
727
- s.correct_answer_count > 0'
728
- );
729
-
730
-
731
- return 16;
732
- }
733
-
734
- private function upgradeDbV16() {
735
- $this->_wpdb->query('
736
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_question
737
- DROP `correct_count`,
738
- DROP `incorrect_count`,
739
- DROP `tip_count`,
740
- DROP `answer_json`,
741
- DROP `points_per_answer`,
742
- DROP `points_answer`;
743
- ');
744
-
745
- $this->_wpdb->query('
746
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic
747
- DROP `correct_answer_count`;
748
- ');
749
-
750
- return 17;
751
- }
752
-
753
- private function upgradeDbV17() {
754
-
755
- $this->_wpdb->query('
756
- CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_category` (
757
- `category_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
758
- `category_name` varchar(200) NOT NULL,
759
- PRIMARY KEY (`category_id`)
760
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
761
- ');
762
-
763
- $this->_wpdb->query('
764
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
765
- ADD `quiz_modus` TINYINT UNSIGNED NOT NULL ,
766
- ADD `show_review_question` TINYINT( 1 ) NOT NULL ,
767
- ADD `quiz_summary_hide` TINYINT( 1 ) NOT NULL ,
768
- ADD `skip_question_disabled` TINYINT( 1 ) NOT NULL ,
769
- ADD `email_notification` TINYINT UNSIGNED NOT NULL
770
- ');
771
-
772
- $this->_wpdb->query('
773
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
774
- ADD `category_id` INT UNSIGNED NOT NULL ,
775
- ADD INDEX ( `category_id` )
776
- ');
777
-
778
- $this->_wpdb->update($this->_wpdb->prefix.'wp_pro_quiz_master',
779
- array(
780
- 'quiz_modus' => WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE,
781
- 'back_button' => 0,
782
- 'check_answer' => 0),
783
- array('question_on_single_page' => 1));
784
-
785
- $this->_wpdb->update($this->_wpdb->prefix.'wp_pro_quiz_master',
786
- array(
787
- 'quiz_modus' => WpProQuiz_Model_Quiz::QUIZ_MODUS_CHECK,
788
- 'back_button' => 0),
789
- array('check_answer' => 1));
790
-
791
- $this->_wpdb->update($this->_wpdb->prefix.'wp_pro_quiz_master',
792
- array('quiz_modus' => WpProQuiz_Model_Quiz::QUIZ_MODUS_BACK_BUTTON),
793
- array('back_button' => 1));
794
-
795
- $this->_wpdb->query('
796
- ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
797
- DROP `check_answer`,
798
- DROP `back_button`,
799
- DROP `question_on_single_page`
800
- ');
801
-
802
- return 18;
803
- }
804
-
805
- private function upgradeDbV18() {
806
-
807
- //Clear
808
-
809
- $this->_wpdb->query('
810
- DELETE s
811
- FROM '.$this->_wpdb->prefix.'wp_pro_quiz_statistic AS s
812
- LEFT JOIN '.$this->_wpdb->prefix.'wp_pro_quiz_master AS m ON ( s.quiz_id = m.id )
813
- LEFT JOIN '.$this->_wpdb->prefix.'wp_pro_quiz_question AS q ON ( s.question_id = q.id )
814
- WHERE m.id IS NULL OR q.id IS NULL
815
- ');
816
-
817
-
818
- //Start - Update Statistic
819
- $this->_wpdb->query('
820
- CREATE TABLE IF NOT EXISTS '.$this->_wpdb->prefix.'wp_pro_quiz_statistic_ref (
821
- `statistic_ref_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
822
- `quiz_id` int(11) NOT NULL,
823
- `user_id` bigint(20) unsigned NOT NULL,
824
- `create_time` int(11) NOT NULL,
825
- `is_old` tinyint(1) unsigned NOT NULL,
826
- PRIMARY KEY (`statistic_ref_id`),
827
- KEY `quiz_id` (`quiz_id`,`user_id`),
828
- KEY `time` (`create_time`)
829
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
830
- ');
831
-
832
- $this->_wpdb->query('
833
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic
834
- ADD `statistic_ref_id` INT UNSIGNED NOT NULL FIRST
835
- ');
836
-
837
- $this->_wpdb->query('
838
- INSERT INTO '.$this->_wpdb->prefix.'wp_pro_quiz_statistic_ref
839
-
840
- (quiz_id, user_id, create_time, is_old)
841
-
842
- SELECT s.quiz_id, s.user_id, '.time().' AS create_time, 1 AS is_old
843
- FROM '.$this->_wpdb->prefix.'wp_pro_quiz_statistic AS s
844
- GROUP BY quiz_id, user_id
845
- ');
846
-
847
- $this->_wpdb->query('
848
- UPDATE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic AS s
849
- LEFT JOIN '.$this->_wpdb->prefix.'wp_pro_quiz_statistic_ref AS sf
850
- ON s.quiz_id = sf.quiz_id AND s.user_id = sf.user_id
851
-
852
- SET s.statistic_ref_id = sf.statistic_ref_id
853
- ');
854
-
855
- $this->_wpdb->query('
856
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic
857
- DROP PRIMARY KEY ,
858
- ADD PRIMARY KEY ( `statistic_ref_id` , `question_id` ) ,
859
- DROP `quiz_id` ,
860
- DROP `user_id` ,
861
- ADD `question_time` INT UNSIGNED NOT NULL
862
- ');
863
-
864
- //end
865
-
866
- //Master
867
- $this->_wpdb->query("
868
- ALTER TABLE ".$this->_wpdb->prefix."wp_pro_quiz_master
869
- ADD `user_email_notification` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
870
- ADD `show_category_score` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
871
- ADD `hide_result_correct_question` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
872
- ADD `hide_result_quiz_time` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
873
- ADD `hide_result_points` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'
874
- ");
875
-
876
- $this->_wpdb->query('SELECT * FROM '.$this->_wpdb->prefix.'wp_pro_quiz_master LIMIT 0,1');
877
-
878
- $names = $this->_wpdb->get_col_info('name');
879
-
880
- if(in_array('check_answer', $names)) {
881
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` DROP `check_answer` ');
882
- }
883
-
884
- if(in_array('back_button', $names)) {
885
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` DROP `back_button` ');
886
- }
887
-
888
- if(in_array('question_on_single_page', $names)) {
889
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master` DROP `question_on_single_page` ');
890
- }
891
-
892
- return 19;
893
- }
894
-
895
- private function upgradeDbV19() {
896
- $this->_wpdb->query('
897
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_question
898
- ADD `answer_points_diff_modus_activated` TINYINT( 1 ) UNSIGNED NOT NULL,
899
- ADD `disable_correct` TINYINT( 1 ) UNSIGNED NOT NULL
900
- ');
901
-
902
- $this->_wpdb->query('
903
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_master
904
- ADD `autostart` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ,
905
- ADD `forcing_question_solve` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\',
906
- ADD `hide_question_position_overview` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\',
907
- ADD `hide_question_numbering` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\'
908
- ');
909
-
910
- return 20;
911
- }
912
-
913
- private function upgradeDbV20() {
914
- $this->_wpdb->query('SELECT * FROM '.$this->_wpdb->prefix.'wp_pro_quiz_master LIMIT 0,1');
915
-
916
- $names = $this->_wpdb->get_col_info('name');
917
-
918
- if(!in_array('autostart', $names)) {
919
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
920
- ADD `autostart` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
921
- }
922
-
923
- if(!in_array('forcing_question_solve', $names)) {
924
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
925
- ADD `forcing_question_solve` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
926
- }
927
-
928
- if(!in_array('hide_question_position_overview', $names)) {
929
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
930
- ADD `hide_question_position_overview` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
931
- }
932
-
933
- if(!in_array('hide_question_numbering', $names)) {
934
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
935
- ADD `hide_question_numbering` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
936
- }
937
-
938
- $this->_wpdb->query('SELECT * FROM '.$this->_wpdb->prefix.'wp_pro_quiz_question LIMIT 0,1');
939
-
940
- $names = $this->_wpdb->get_col_info('name');
941
-
942
- if(!in_array('answer_points_diff_modus_activated', $names)) {
943
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
944
- ADD `answer_points_diff_modus_activated` TINYINT( 1 ) UNSIGNED NOT NULL ');
945
- }
946
-
947
- if(!in_array('disable_correct', $names)) {
948
- $this->_wpdb->query('ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
949
- ADD `disable_correct` TINYINT( 1 ) UNSIGNED NOT NULL ');
950
- }
951
-
952
- return 21;
953
- }
954
-
955
- private function upgradeDbV21() {
956
- $this->_wpdb->query('
957
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_master
958
- ADD `form_activated` TINYINT( 1 ) UNSIGNED NOT NULL ,
959
- ADD `form_show_position` TINYINT UNSIGNED NOT NULL ,
960
- ADD `start_only_registered_user` TINYINT( 1 ) UNSIGNED NOT NULL ,
961
- ADD `questions_per_page` TINYINT UNSIGNED NOT NULL ,
962
- ADD `sort_categories` TINYINT( 1 ) UNSIGNED NOT NULL ,
963
- ADD `show_category` TINYINT( 1 ) UNSIGNED NOT NULL
964
- ');
965
-
966
- $this->_wpdb->query('
967
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic
968
- ADD `answer_data` TEXT NULL DEFAULT NULL
969
- ');
970
-
971
- $this->_wpdb->query('
972
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic_ref
973
- ADD `form_data` TEXT NULL DEFAULT NULL
974
- ');
975
-
976
- $this->_wpdb->query('
977
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_question
978
- ADD `online` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `quiz_id` ,
979
- ADD `matrix_sort_answer_criteria_width` TINYINT( 3 ) UNSIGNED NOT NULL
980
- ');
981
-
982
- $this->_wpdb->query('
983
- CREATE TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_form` (
984
- `form_id` int(11) NOT NULL AUTO_INCREMENT,
985
- `quiz_id` int(11) NOT NULL,
986
- `fieldname` varchar(100) NOT NULL,
987
- `type` tinyint(4) NOT NULL,
988
- `required` tinyint(1) unsigned NOT NULL,
989
- `sort` tinyint(4) NOT NULL,
990
- `data` mediumtext,
991
- PRIMARY KEY (`form_id`),
992
- KEY `quiz_id` (`quiz_id`)
993
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
994
- ');
995
-
996
- $this->_wpdb->query('
997
- CREATE TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_template` (
998
- `template_id` int(11) NOT NULL AUTO_INCREMENT,
999
- `name` varchar(200) NOT NULL,
1000
- `type` tinyint(3) unsigned NOT NULL,
1001
- `data` text NOT NULL,
1002
- PRIMARY KEY (`template_id`)
1003
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1004
- ');
1005
-
1006
- //Check
1007
- $this->databaseDelta();
1008
-
1009
- $this->_wpdb->query('UPDATE '.$this->_wpdb->prefix.'wp_pro_quiz_question
1010
- SET online = 1');
1011
-
1012
- return 22;
1013
- }
1014
-
1015
- private function upgradeDbV22() {
1016
- $this->_wpdb->query('
1017
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_category
1018
- ADD `type` ENUM( \'QUESTION\', \'QUIZ\' ) NOT NULL DEFAULT \'QUESTION\';
1019
- ');
1020
-
1021
- $this->_wpdb->query('
1022
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_master
1023
- ADD `category_id` INT UNSIGNED NOT NULL ;
1024
- ');
1025
-
1026
- $this->_wpdb->query('UPDATE '.$this->_wpdb->prefix.'wp_pro_quiz_master
1027
- SET category_id = 0');
1028
-
1029
- $this->_wpdb->query('UPDATE '.$this->_wpdb->prefix.'wp_pro_quiz_category
1030
- SET type = \'QUESTION\'');
1031
-
1032
- return 23;
1033
- }
1034
-
1035
- private function upgradeDbV23() {
1036
- $this->_wpdb->query('
1037
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_master
1038
- ADD `admin_email` TEXT NOT NULL ,
1039
- ADD `user_email` TEXT NOT NULL ;
1040
- ');
1041
-
1042
- $mapper = new WpProQuiz_Model_GlobalSettingsMapper();
1043
- $adminEmail = $mapper->getEmailSettings();
1044
- $userEmail = $mapper->getUserEmailSettings();
1045
-
1046
- $adminEmailNew = new WpProQuiz_Model_Email();
1047
- $adminEmailNew->setTo($adminEmail['to']);
1048
- $adminEmailNew->setFrom($adminEmail['from']);
1049
- $adminEmailNew->setSubject($adminEmail['subject']);
1050
- $adminEmailNew->setHtml($adminEmail['html']);
1051
- $adminEmailNew->setMessage($adminEmail['message']);
1052
-
1053
- $userEmailNew = new WpProQuiz_Model_Email();
1054
- $userEmailNew->setFrom($userEmail['from']);
1055
- $userEmailNew->setToUser(true);
1056
- $userEmailNew->setSubject($userEmail['subject']);
1057
- $userEmailNew->setHtml($userEmail['html']);
1058
- $userEmailNew->setMessage($userEmail['message']);
1059
-
1060
- $this->_wpdb->update($this->_wpdb->prefix.'wp_pro_quiz_master',
1061
- array('admin_email' => @serialize($adminEmailNew)),
1062
- array('email_notification' => 1),
1063
- array('%s'), array('%d'));
1064
-
1065
- $this->_wpdb->update($this->_wpdb->prefix.'wp_pro_quiz_master',
1066
- array('admin_email' => @serialize($adminEmailNew)),
1067
- array('email_notification' => 2),
1068
- array('%s'), array('%d'));
1069
-
1070
- $this->_wpdb->update($this->_wpdb->prefix.'wp_pro_quiz_master',
1071
- array('user_email' => @serialize($userEmailNew)),
1072
- array('user_email_notification' => 1),
1073
- array('%s'), array('%d'));
1074
-
1075
- return 24;
1076
- }
1077
-
1078
- private function upgradeDbV24() {
1079
- $this->_wpdb->query('
1080
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_form
1081
- ADD `show_in_statistic` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `sort` ;
1082
- ');
1083
-
1084
- $this->_wpdb->query('
1085
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic
1086
- ADD `solved_count` TINYINT( 1 ) NOT NULL AFTER `hint_count` ;
1087
- ');
1088
-
1089
- $this->_wpdb->query('UPDATE '.$this->_wpdb->prefix.'wp_pro_quiz_statistic
1090
- SET solved_count = -1');
1091
-
1092
- $this->_wpdb->query('
1093
- ALTER TABLE '.$this->_wpdb->prefix.'wp_pro_quiz_master
1094
- ADD `plugin_container` TEXT NULL DEFAULT NULL ;
1095
- ');
1096
-
1097
- return 25;
1098
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1099
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Helper_DbUpgrade
4
+ {
5
+
6
+ const WPPROQUIZ_DB_VERSION = 25;
7
+
8
+ private $_wpdb;
9
+ private $_prefix;
10
+
11
+ public function __construct()
12
+ {
13
+ global $wpdb;
14
+
15
+ $this->_wpdb = $wpdb;
16
+ }
17
+
18
+ public function upgrade($version)
19
+ {
20
+ @set_time_limit(300);
21
+
22
+ if ($version === false || ((int)$version) > WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION) {
23
+ $this->install();
24
+
25
+ return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
26
+ }
27
+
28
+ $version = (int)$version;
29
+
30
+ if ($version === WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION) {
31
+ return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
32
+ }
33
+
34
+ do {
35
+ $f = 'upgradeDbV' . $version;
36
+
37
+ if (method_exists($this, $f)) {
38
+ $version = $this->$f();
39
+ } else {
40
+ die("WpProQuiz upgrade error");
41
+ }
42
+ } while ($version < WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION);
43
+
44
+ return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
45
+ }
46
+
47
+ public function delete()
48
+ {
49
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_category`');
50
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_form`');
51
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock`');
52
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`');
53
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_prerequisite`');
54
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`');
55
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic`');
56
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic_ref`');
57
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_template`');
58
+ $this->_wpdb->query('DROP TABLE IF EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_toplist`');
59
+ }
60
+
61
+ private function install()
62
+ {
63
+
64
+ $this->delete();
65
+
66
+ $this->databaseDelta();
67
+ }
68
+
69
+ public function databaseDelta()
70
+ {
71
+ if (!function_exists('dbDelta')) {
72
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
73
+ }
74
+
75
+ dbDelta("
76
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_category (
77
+ category_id int(10) unsigned NOT NULL AUTO_INCREMENT,
78
+ category_name varchar(200) NOT NULL,
79
+ type enum('QUESTION','QUIZ') NOT NULL DEFAULT 'QUESTION',
80
+ PRIMARY KEY (category_id)
81
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
82
+
83
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_form (
84
+ form_id int(11) NOT NULL AUTO_INCREMENT,
85
+ quiz_id int(11) NOT NULL,
86
+ fieldname varchar(100) NOT NULL,
87
+ type tinyint(4) NOT NULL,
88
+ required tinyint(1) unsigned NOT NULL,
89
+ sort tinyint(4) NOT NULL,
90
+ show_in_statistic tinyint(1) unsigned NOT NULL,
91
+ data mediumtext,
92
+ PRIMARY KEY (form_id),
93
+ KEY quiz_id (quiz_id)
94
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
95
+
96
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_lock (
97
+ quiz_id int(11) NOT NULL,
98
+ lock_ip varchar(100) NOT NULL,
99
+ user_id bigint(20) unsigned NOT NULL,
100
+ lock_type tinyint(3) unsigned NOT NULL,
101
+ lock_date int(11) NOT NULL,
102
+ PRIMARY KEY (quiz_id,lock_ip,user_id,lock_type)
103
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
104
+
105
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_master (
106
+ id int(11) NOT NULL AUTO_INCREMENT,
107
+ name varchar(200) NOT NULL,
108
+ text text NOT NULL,
109
+ result_text text NOT NULL,
110
+ result_grade_enabled tinyint(1) NOT NULL,
111
+ title_hidden tinyint(1) NOT NULL,
112
+ btn_restart_quiz_hidden tinyint(1) NOT NULL,
113
+ btn_view_question_hidden tinyint(1) NOT NULL,
114
+ question_random tinyint(1) NOT NULL,
115
+ answer_random tinyint(1) NOT NULL,
116
+ time_limit int(11) NOT NULL,
117
+ statistics_on tinyint(1) NOT NULL,
118
+ statistics_ip_lock int(10) unsigned NOT NULL,
119
+ show_points tinyint(1) NOT NULL,
120
+ quiz_run_once tinyint(1) NOT NULL,
121
+ quiz_run_once_type tinyint(4) NOT NULL,
122
+ quiz_run_once_cookie tinyint(1) NOT NULL,
123
+ quiz_run_once_time int(10) unsigned NOT NULL,
124
+ numbered_answer tinyint(1) NOT NULL,
125
+ hide_answer_message_box tinyint(1) NOT NULL,
126
+ disabled_answer_mark tinyint(1) NOT NULL,
127
+ show_max_question tinyint(1) NOT NULL,
128
+ show_max_question_value int(10) unsigned NOT NULL,
129
+ show_max_question_percent tinyint(1) NOT NULL,
130
+ toplist_activated tinyint(1) NOT NULL,
131
+ toplist_data text NOT NULL,
132
+ show_average_result tinyint(1) NOT NULL,
133
+ prerequisite tinyint(1) NOT NULL,
134
+ quiz_modus tinyint(3) unsigned NOT NULL,
135
+ show_review_question tinyint(1) NOT NULL,
136
+ quiz_summary_hide tinyint(1) NOT NULL,
137
+ skip_question_disabled tinyint(1) NOT NULL,
138
+ email_notification tinyint(3) unsigned NOT NULL,
139
+ user_email_notification tinyint(1) unsigned NOT NULL,
140
+ show_category_score tinyint(1) unsigned NOT NULL,
141
+ hide_result_correct_question tinyint(1) unsigned NOT NULL DEFAULT '0',
142
+ hide_result_quiz_time tinyint(1) unsigned NOT NULL DEFAULT '0',
143
+ hide_result_points tinyint(1) unsigned NOT NULL DEFAULT '0',
144
+ autostart tinyint(1) unsigned NOT NULL DEFAULT '0',
145
+ forcing_question_solve tinyint(1) unsigned NOT NULL DEFAULT '0',
146
+ hide_question_position_overview tinyint(1) unsigned NOT NULL DEFAULT '0',
147
+ hide_question_numbering tinyint(1) unsigned NOT NULL DEFAULT '0',
148
+ form_activated tinyint(1) unsigned NOT NULL,
149
+ form_show_position tinyint(3) unsigned NOT NULL,
150
+ start_only_registered_user tinyint(1) unsigned NOT NULL,
151
+ questions_per_page tinyint(3) unsigned NOT NULL,
152
+ sort_categories tinyint(1) unsigned NOT NULL,
153
+ show_category tinyint(1) unsigned NOT NULL,
154
+ category_id int(10) unsigned NOT NULL,
155
+ admin_email text NOT NULL,
156
+ user_email text NOT NULL,
157
+ plugin_container text,
158
+ PRIMARY KEY (id)
159
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
160
+
161
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_prerequisite (
162
+ prerequisite_quiz_id int(11) NOT NULL,
163
+ quiz_id int(11) NOT NULL,
164
+ PRIMARY KEY (prerequisite_quiz_id,quiz_id)
165
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
166
+
167
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_question (
168
+ id int(11) NOT NULL AUTO_INCREMENT,
169
+ quiz_id int(11) NOT NULL,
170
+ online tinyint(1) unsigned NOT NULL,
171
+ sort smallint(5) unsigned NOT NULL,
172
+ title varchar(200) NOT NULL,
173
+ points int(11) NOT NULL,
174
+ question text NOT NULL,
175
+ correct_msg text NOT NULL,
176
+ incorrect_msg text NOT NULL,
177
+ correct_same_text tinyint(1) NOT NULL,
178
+ tip_enabled tinyint(1) NOT NULL,
179
+ tip_msg text NOT NULL,
180
+ answer_type varchar(50) NOT NULL,
181
+ show_points_in_box tinyint(1) NOT NULL,
182
+ answer_points_activated tinyint(1) NOT NULL,
183
+ answer_data longtext NOT NULL,
184
+ category_id int(10) unsigned NOT NULL,
185
+ answer_points_diff_modus_activated tinyint(1) unsigned NOT NULL,
186
+ disable_correct tinyint(1) unsigned NOT NULL,
187
+ matrix_sort_answer_criteria_width tinyint(3) unsigned NOT NULL,
188
+ PRIMARY KEY (id),
189
+ KEY quiz_id (quiz_id),
190
+ KEY category_id (category_id)
191
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
192
+
193
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_statistic (
194
+ statistic_ref_id int(10) unsigned NOT NULL,
195
+ question_id int(11) NOT NULL,
196
+ correct_count int(10) unsigned NOT NULL,
197
+ incorrect_count int(10) unsigned NOT NULL,
198
+ hint_count int(10) unsigned NOT NULL,
199
+ solved_count tinyint(1) NOT NULL,
200
+ points int(10) unsigned NOT NULL,
201
+ question_time int(10) unsigned NOT NULL,
202
+ answer_data text,
203
+ PRIMARY KEY (statistic_ref_id,question_id)
204
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
205
+
206
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_statistic_ref (
207
+ statistic_ref_id int(10) unsigned NOT NULL AUTO_INCREMENT,
208
+ quiz_id int(11) NOT NULL,
209
+ user_id bigint(20) unsigned NOT NULL,
210
+ create_time int(11) NOT NULL,
211
+ is_old tinyint(1) unsigned NOT NULL,
212
+ form_data text,
213
+ PRIMARY KEY (statistic_ref_id),
214
+ KEY quiz_id (quiz_id,user_id),
215
+ KEY time (create_time)
216
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
217
+
218
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_template (
219
+ template_id int(11) NOT NULL AUTO_INCREMENT,
220
+ name varchar(200) NOT NULL,
221
+ type tinyint(3) unsigned NOT NULL,
222
+ data text NOT NULL,
223
+ PRIMARY KEY (template_id)
224
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
225
+
226
+ CREATE TABLE {$this->_wpdb->prefix}wp_pro_quiz_toplist (
227
+ toplist_id int(11) NOT NULL AUTO_INCREMENT,
228
+ quiz_id int(11) NOT NULL,
229
+ date int(10) unsigned NOT NULL,
230
+ user_id bigint(20) unsigned NOT NULL,
231
+ name varchar(30) NOT NULL,
232
+ email varchar(200) NOT NULL,
233
+ points int(10) unsigned NOT NULL,
234
+ result float unsigned NOT NULL,
235
+ ip varchar(100) NOT NULL,
236
+ PRIMARY KEY (toplist_id,quiz_id)
237
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
238
+ ");
239
+ }
240
+
241
+ private function upgradeDbV1()
242
+ {
243
+
244
+ $this->_wpdb->query('
245
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
246
+ ADD `back_button` TINYINT( 1 ) NOT NULL AFTER `answer_random`,
247
+ ADD `check_answer` TINYINT( 1 ) NOT NULL AFTER `answer_random`,
248
+ ADD `result_text` TEXT NOT NULL AFTER `text`
249
+ ');
250
+
251
+ return 2;
252
+ }
253
+
254
+ private function upgradeDbV2()
255
+ {
256
+ return 3;
257
+ }
258
+
259
+ private function upgradeDbV3()
260
+ {
261
+
262
+ $this->_wpdb->query('
263
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
264
+ ADD `incorrect_count` INT UNSIGNED NOT NULL AFTER `incorrect_msg` ,
265
+ ADD `correct_count` INT UNSIGNED NOT NULL AFTER `incorrect_msg` ,
266
+ ADD `correct_same_text` TINYINT( 1 ) NOT NULL AFTER `incorrect_msg`
267
+ ');
268
+
269
+ $this->_wpdb->query('
270
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
271
+ ADD `statistics_on` TINYINT( 1 ) NOT NULL ,
272
+ ADD `statistics_ip_lock` INT UNSIGNED NOT NULL
273
+ ');
274
+
275
+ $this->_wpdb->query('
276
+ CREATE TABLE IF NOT EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock` (
277
+ `quiz_id` int(11) NOT NULL,
278
+ `lock_ip` varchar(100) NOT NULL,
279
+ `lock_date` int(11) NOT NULL,
280
+ PRIMARY KEY (`quiz_id`,`lock_ip`)
281
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
282
+ ');
283
+
284
+ $this->_wpdb->query('
285
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
286
+ ADD INDEX ( `quiz_id` )
287
+ ');
288
+
289
+ return 4;
290
+ }
291
+
292
+ private function upgradeDbV4()
293
+ {
294
+
295
+ $this->_wpdb->query('
296
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
297
+ ADD `tip_enabled` TINYINT( 1 ) NOT NULL AFTER `incorrect_count` ,
298
+ ADD `tip_msg` TEXT NOT NULL AFTER `tip_enabled` ,
299
+ ADD `tip_count` INT NOT NULL AFTER `tip_msg`
300
+ ');
301
+
302
+ return 5;
303
+ }
304
+
305
+ private function upgradeFixDbV4()
306
+ {
307
+ if ($this->_wpdb->prefix != 'wp_') {
308
+ $this->_wpdb->query('SELECT * FROM `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` LIMIT 0,1');
309
+
310
+ $names = $this->_wpdb->get_col_info('name');
311
+
312
+ if (!in_array('tip_enabled', $names)) {
313
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` ADD `tip_enabled` TINYINT( 1 ) NOT NULL AFTER `incorrect_count`');
314
+ }
315
+
316
+ if (!in_array('tip_msg', $names)) {
317
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` ADD `tip_msg` TEXT NOT NULL AFTER `tip_enabled`');
318
+ }
319
+
320
+ if (!in_array('tip_count', $names)) {
321
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` ADD `tip_count` INT NOT NULL AFTER `tip_msg`');
322
+ }
323
+ }
324
+ }
325
+
326
+ private function upgradeDbV5()
327
+ {
328
+
329
+ $this->upgradeFixDbV4();
330
+
331
+ $this->_wpdb->query('
332
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
333
+ ADD `result_grade_enabled` TINYINT( 1 ) NOT NULL AFTER `result_text`
334
+ ');
335
+
336
+ return 6;
337
+ }
338
+
339
+ private function upgradeDbV6()
340
+ {
341
+
342
+ $this->_wpdb->query('
343
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
344
+ ADD `points` INT NOT NULL AFTER `title`
345
+ ');
346
+
347
+ $this->_wpdb->query('
348
+ UPDATE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` SET `points` = 1
349
+ ');
350
+
351
+ $this->_wpdb->query('
352
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
353
+ ADD `show_points` TINYINT( 1 ) NOT NULL
354
+ ');
355
+
356
+ return 7;
357
+ }
358
+
359
+ private function upgradeDbV7()
360
+ {
361
+ $this->_wpdb->query('
362
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
363
+ CHANGE `name` `name` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
364
+ CHANGE `text` `text` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
365
+ CHANGE `result_text` `result_text` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
366
+ ');
367
+
368
+ $this->_wpdb->query('
369
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
370
+ CHANGE `title` `title` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
371
+ CHANGE `question` `question` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
372
+ CHANGE `correct_msg` `correct_msg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
373
+ CHANGE `incorrect_msg` `incorrect_msg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
374
+ CHANGE `tip_msg` `tip_msg` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
375
+ CHANGE `answer_type` `answer_type` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
376
+ CHANGE `answer_json` `answer_json` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
377
+ ');
378
+
379
+ $this->_wpdb->query('
380
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock`
381
+ CHANGE `lock_ip` `lock_ip` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
382
+ ');
383
+
384
+ $this->_wpdb->query('
385
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
386
+ ');
387
+
388
+ $this->_wpdb->query('
389
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
390
+ ');
391
+
392
+ $this->_wpdb->query('
393
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
394
+ ');
395
+
396
+ return 8;
397
+ }
398
+
399
+ private function upgradeDbV8()
400
+ {
401
+
402
+ $this->_wpdb->query('
403
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
404
+ ADD `btn_restart_quiz_hidden` TINYINT( 1 ) NOT NULL AFTER `title_hidden` ,
405
+ ADD `btn_view_question_hidden` TINYINT( 1 ) NOT NULL AFTER `btn_restart_quiz_hidden`
406
+ ');
407
+
408
+ return 9;
409
+ }
410
+
411
+ private function upgradeFixDbV8()
412
+ {
413
+ if ($this->_wpdb->prefix != 'wp_') {
414
+ $this->_wpdb->query('SELECT * FROM `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` LIMIT 0,1');
415
+
416
+ $names = $this->_wpdb->get_col_info('name');
417
+
418
+ if (!in_array('btn_restart_quiz_hidden', $names)) {
419
+ $this->_wpdb->query('
420
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
421
+ ADD `btn_restart_quiz_hidden` TINYINT( 1 ) NOT NULL AFTER `title_hidden`
422
+ ');
423
+ }
424
+
425
+ if (!in_array('btn_view_question_hidden', $names)) {
426
+ $this->_wpdb->query('
427
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
428
+ ADD `btn_view_question_hidden` TINYINT( 1 ) NOT NULL AFTER `btn_restart_quiz_hidden`
429
+ ');
430
+ }
431
+ }
432
+ }
433
+
434
+ private function upgradeDbV9()
435
+ {
436
+
437
+ $this->upgradeFixDbV8();
438
+
439
+ $this->_wpdb->query('
440
+ TRUNCATE `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock`
441
+ ');
442
+
443
+ $this->_wpdb->query('
444
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock`
445
+ ADD `user_id` BIGINT UNSIGNED NOT NULL AFTER `lock_ip` ,
446
+ ADD `lock_type` TINYINT UNSIGNED NOT NULL AFTER `user_id`
447
+ ');
448
+
449
+ $this->_wpdb->query('
450
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_lock`
451
+ DROP PRIMARY KEY ,
452
+ ADD PRIMARY KEY ( `quiz_id` , `lock_ip` , `user_id` , `lock_type` )
453
+ ');
454
+
455
+ $this->_wpdb->query('
456
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
457
+ ADD `quiz_run_once` TINYINT( 1 ) NOT NULL ,
458
+ ADD `quiz_run_once_type` TINYINT NOT NULL ,
459
+ ADD `quiz_run_once_cookie` TINYINT( 1 ) NOT NULL ,
460
+ ADD `quiz_run_once_time` INT UNSIGNED NOT NULL
461
+ ');
462
+
463
+ $this->_wpdb->query('
464
+ CREATE TABLE IF NOT EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic` (
465
+ `quiz_id` int(11) NOT NULL,
466
+ `question_id` int(11) NOT NULL,
467
+ `user_id` bigint(20) unsigned NOT NULL,
468
+ `correct_count` int(10) unsigned NOT NULL,
469
+ `incorrect_count` int(10) unsigned NOT NULL,
470
+ `hint_count` int(10) unsigned NOT NULL,
471
+ PRIMARY KEY (`quiz_id`,`question_id`,`user_id`)
472
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
473
+ ');
474
+
475
+ $this->_wpdb->query('
476
+ INSERT INTO `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic` (quiz_id, question_id, user_id, correct_count, incorrect_count, hint_count)
477
+ SELECT
478
+ question.quiz_id, id, 0, question.correct_count, question.incorrect_count, tip_count
479
+ FROM
480
+ `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` as question
481
+ WHERE
482
+ question.correct_count > 0 OR question.incorrect_count > 0 OR tip_count > 0
483
+ ');
484
+
485
+ return 10;
486
+ }
487
+
488
+ private function upgradeDbV10()
489
+ {
490
+
491
+ $this->_wpdb->query('
492
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
493
+ ADD `question_on_single_page` TINYINT( 1 ) NOT NULL ,
494
+ ADD `numbered_answer` TINYINT( 1 ) NOT NULL
495
+ ');
496
+
497
+ return 11;
498
+ }
499
+
500
+ private function upgradeDbV11()
501
+ {
502
+
503
+ $this->_wpdb->query('
504
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
505
+ ADD `points_per_answer` TINYINT( 1 ) NOT NULL ,
506
+ ADD `points_answer` INT UNSIGNED NOT NULL ,
507
+ ADD `show_points_in_box` TINYINT( 1 ) NOT NULL
508
+ ');
509
+
510
+ $this->_wpdb->query('
511
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic`
512
+ ADD `correct_answer_count` INT UNSIGNED NOT NULL
513
+ ');
514
+
515
+ $this->_wpdb->query('UPDATE `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic` SET `correct_answer_count` = `correct_count`');
516
+
517
+ $this->_wpdb->query('UPDATE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question` SET `points_answer` = `points`');
518
+
519
+ return 12;
520
+ }
521
+
522
+ private function upgradeDbV12()
523
+ {
524
+
525
+ $this->_wpdb->query('
526
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
527
+ ADD `hide_answer_message_box` TINYINT( 1 ) NOT NULL ,
528
+ ADD `disabled_answer_mark` TINYINT( 1 ) NOT NULL ,
529
+ ADD `show_max_question` TINYINT( 1 ) NOT NULL ,
530
+ ADD `show_max_question_value` INT UNSIGNED NOT NULL ,
531
+ ADD `show_max_question_percent` TINYINT( 1 ) NOT NULL
532
+ ');
533
+
534
+ return 13;
535
+ }
536
+
537
+ private function upgradeDbV13()
538
+ {
539
+
540
+ //WordPress SVN Bug
541
+
542
+ $this->_wpdb->query('SELECT * FROM `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` LIMIT 0,1');
543
+
544
+ $names = $this->_wpdb->get_col_info('name');
545
+
546
+ if (!in_array('hide_answer_message_box', $names)) {
547
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` ADD `hide_answer_message_box` TINYINT( 1 ) NOT NULL');
548
+ }
549
+
550
+ if (!in_array('disabled_answer_mark', $names)) {
551
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` ADD `disabled_answer_mark` TINYINT( 1 ) NOT NULL');
552
+ }
553
+
554
+ if (!in_array('show_max_question', $names)) {
555
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` ADD `show_max_question` TINYINT( 1 ) NOT NULL');
556
+ }
557
+
558
+ if (!in_array('show_max_question_value', $names)) {
559
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` ADD `show_max_question_value` INT UNSIGNED NOT NULL');
560
+ }
561
+
562
+ if (!in_array('show_max_question_percent', $names)) {
563
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` ADD `show_max_question_percent` TINYINT( 1 ) NOT NULL');
564
+ }
565
+
566
+ return 14;
567
+ }
568
+
569
+ private function upgradeDbV14()
570
+ {
571
+
572
+ $this->_wpdb->query('
573
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
574
+ CHANGE `sort` `sort` SMALLINT UNSIGNED NOT NULL
575
+ ');
576
+
577
+ return 15;
578
+ }
579
+
580
+ private function upgradeDbV15()
581
+ {
582
+
583
+ $this->_wpdb->query('
584
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
585
+ ADD `answer_points_activated` tinyint(1) NOT NULL,
586
+ ADD `answer_data` longtext NOT NULL
587
+ ');
588
+
589
+ $this->_wpdb->query('
590
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic`
591
+ ADD `points` int(10) unsigned NOT NULL
592
+ ');
593
+
594
+ $this->_wpdb->query('
595
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
596
+ ADD `toplist_activated` tinyint(1) NOT NULL,
597
+ ADD `toplist_data` text NOT NULL,
598
+ ADD `show_average_result` tinyint(1) NOT NULL,
599
+ ADD `prerequisite` tinyint(1) NOT NULL
600
+ ');
601
+
602
+ $this->_wpdb->query('
603
+ CREATE TABLE IF NOT EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_prerequisite` (
604
+ `prerequisite_quiz_id` int(11) NOT NULL,
605
+ `quiz_id` int(11) NOT NULL,
606
+ PRIMARY KEY (`prerequisite_quiz_id`,`quiz_id`)
607
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
608
+ ');
609
+
610
+ $this->_wpdb->query('
611
+ CREATE TABLE IF NOT EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_toplist` (
612
+ `toplist_id` int(11) NOT NULL AUTO_INCREMENT,
613
+ `quiz_id` int(11) NOT NULL,
614
+ `date` int(10) unsigned NOT NULL,
615
+ `user_id` bigint(20) unsigned NOT NULL,
616
+ `name` varchar(30) NOT NULL,
617
+ `email` varchar(200) NOT NULL,
618
+ `points` int(10) unsigned NOT NULL,
619
+ `result` float unsigned NOT NULL,
620
+ `ip` varchar(100) NOT NULL,
621
+ PRIMARY KEY (`toplist_id`,`quiz_id`)
622
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
623
+ ');
624
+
625
+ $results = $this->_wpdb->get_results('SELECT id, answer_type, answer_json, points_per_answer, points_answer FROM `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`',
626
+ ARRAY_A);
627
+
628
+ foreach ($results as $row) {
629
+
630
+ $data = json_decode($row['answer_json'], true);
631
+ $newData = array();
632
+
633
+ if ($data === null) {
634
+ continue;
635
+ }
636
+
637
+ if ($row['answer_type'] == 'single' || $row['answer_type'] == 'multiple') {
638
+ foreach ($data['classic_answer']['answer'] as $k => $v) {
639
+ $x = new WpProQuiz_Model_AnswerTypes();
640
+
641
+ $x->setAnswer($v);
642
+
643
+ if (isset($data['classic_answer']['correct']) && in_array($k, $data['classic_answer']['correct'])) {
644
+ $x->setCorrect(true);
645
+
646
+ if ($row['points_per_answer']) {
647
+ $x->setPoints($row['points_answer']);
648
+ }
649
+
650
+ } else {
651
+ $x->setCorrect(false);
652
+
653
+ if ($row['points_per_answer']) {
654
+ $x->setPoints(0);
655
+ }
656
+ }
657
+
658
+ if (isset($data['classic_answer']['html']) && in_array($k, $data['classic_answer']['html'])) {
659
+ $x->setHtml(true);
660
+ } else {
661
+ $x->setHtml(false);
662
+ }
663
+
664
+ $newData[] = $x;
665
+
666
+ }
667
+ } elseif ($row['answer_type'] == 'cloze_answer') {
668
+ $x = new WpProQuiz_Model_AnswerTypes();
669
+
670
+ $x->setAnswer($data['answer_cloze']['text']);
671
+
672
+ $newData[] = $x;
673
+ } elseif ($row['answer_type'] == 'matrix_sort_answer') {
674
+ foreach ($data['answer_matrix_sort']['answer'] as $k => $v) {
675
+ $x = new WpProQuiz_Model_AnswerTypes();
676
+
677
+ $x->setAnswer($v);
678
+ $x->setSortString($data['answer_matrix_sort']['sort_string'][$k]);
679
+
680
+ if ($row['points_per_answer']) {
681
+ $x->setPoints($row['points_answer']);
682
+ }
683
+
684
+ if (isset($data['answer_matrix_sort']['answer_html']) && in_array($k,
685
+ $data['answer_matrix_sort']['answer_html'])
686
+ ) {
687
+ $x->setHtml(true);
688
+ } else {
689
+ $x->setHtml(false);
690
+ }
691
+
692
+ if (isset($data['answer_matrix_sort']['sort_string_html']) && in_array($k,
693
+ $data['answer_matrix_sort']['sort_string_html'])
694
+ ) {
695
+ $x->setSortStringHtml(true);
696
+ } else {
697
+ $x->setSortStringHtml(false);
698
+ }
699
+
700
+ $newData[] = $x;
701
+
702
+ }
703
+ } elseif ($row['answer_type'] == 'free_answer') {
704
+ $x = new WpProQuiz_Model_AnswerTypes();
705
+
706
+ $x->setAnswer($data['free_answer']['correct']);
707
+
708
+ $newData[] = $x;
709
+ } elseif ($row['answer_type'] == 'sort_answer') {
710
+ foreach ($data['answer_sort']['answer'] as $k => $v) {
711
+ $x = new WpProQuiz_Model_AnswerTypes();
712
+
713
+ $x->setAnswer($v);
714
+
715
+ if ($row['points_per_answer']) {
716
+ $x->setPoints($row['points_answer']);
717
+ }
718
+
719
+ if (isset($data['answer_sort']['html']) && in_array($k, $data['answer_sort']['html'])) {
720
+ $x->setHtml(true);
721
+ } else {
722
+ $x->setHtml(false);
723
+ }
724
+
725
+ $newData[] = $x;
726
+ }
727
+ }
728
+
729
+ $this->_wpdb->update(
730
+ $this->_wpdb->prefix . 'wp_pro_quiz_question',
731
+ array(
732
+ 'answer_data' => serialize($newData)
733
+ ),
734
+ array(
735
+ 'id' => $row['id']
736
+ )
737
+ );
738
+
739
+ }
740
+
741
+ $this->_wpdb->query(
742
+ 'UPDATE ' . $this->_wpdb->prefix . 'wp_pro_quiz_question
743
+ SET
744
+ answer_points_activated = points_per_answer
745
+ WHERE
746
+ answer_type <> \'free_answer\''
747
+ );
748
+
749
+ //Statistics
750
+ $this->_wpdb->query(
751
+ 'UPDATE
752
+ ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic AS s
753
+ SET
754
+ s.points = ( SELECT q.points_answer FROM ' . $this->_wpdb->prefix . 'wp_pro_quiz_question AS q WHERE q.id = s.question_id ) * s.correct_answer_count
755
+ WHERE
756
+ s.correct_answer_count > 0'
757
+ );
758
+
759
+ return 16;
760
+ }
761
+
762
+ private function upgradeDbV16()
763
+ {
764
+ $this->_wpdb->query('
765
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_question
766
+ DROP `correct_count`,
767
+ DROP `incorrect_count`,
768
+ DROP `tip_count`,
769
+ DROP `answer_json`,
770
+ DROP `points_per_answer`,
771
+ DROP `points_answer`;
772
+ ');
773
+
774
+ $this->_wpdb->query('
775
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic
776
+ DROP `correct_answer_count`;
777
+ ');
778
+
779
+ return 17;
780
+ }
781
+
782
+ private function upgradeDbV17()
783
+ {
784
+
785
+ $this->_wpdb->query('
786
+ CREATE TABLE IF NOT EXISTS `' . $this->_wpdb->prefix . 'wp_pro_quiz_category` (
787
+ `category_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
788
+ `category_name` varchar(200) NOT NULL,
789
+ PRIMARY KEY (`category_id`)
790
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
791
+ ');
792
+
793
+ $this->_wpdb->query('
794
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
795
+ ADD `quiz_modus` TINYINT UNSIGNED NOT NULL ,
796
+ ADD `show_review_question` TINYINT( 1 ) NOT NULL ,
797
+ ADD `quiz_summary_hide` TINYINT( 1 ) NOT NULL ,
798
+ ADD `skip_question_disabled` TINYINT( 1 ) NOT NULL ,
799
+ ADD `email_notification` TINYINT UNSIGNED NOT NULL
800
+ ');
801
+
802
+ $this->_wpdb->query('
803
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
804
+ ADD `category_id` INT UNSIGNED NOT NULL ,
805
+ ADD INDEX ( `category_id` )
806
+ ');
807
+
808
+ $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master',
809
+ array(
810
+ 'quiz_modus' => WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE,
811
+ 'back_button' => 0,
812
+ 'check_answer' => 0
813
+ ),
814
+ array('question_on_single_page' => 1));
815
+
816
+ $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master',
817
+ array(
818
+ 'quiz_modus' => WpProQuiz_Model_Quiz::QUIZ_MODUS_CHECK,
819
+ 'back_button' => 0
820
+ ),
821
+ array('check_answer' => 1));
822
+
823
+ $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master',
824
+ array('quiz_modus' => WpProQuiz_Model_Quiz::QUIZ_MODUS_BACK_BUTTON),
825
+ array('back_button' => 1));
826
+
827
+ $this->_wpdb->query('
828
+ ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
829
+ DROP `check_answer`,
830
+ DROP `back_button`,
831
+ DROP `question_on_single_page`
832
+ ');
833
+
834
+ return 18;
835
+ }
836
+
837
+ private function upgradeDbV18()
838
+ {
839
+
840
+ //Clear
841
+
842
+ $this->_wpdb->query('
843
+ DELETE s
844
+ FROM ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic AS s
845
+ LEFT JOIN ' . $this->_wpdb->prefix . 'wp_pro_quiz_master AS m ON ( s.quiz_id = m.id )
846
+ LEFT JOIN ' . $this->_wpdb->prefix . 'wp_pro_quiz_question AS q ON ( s.question_id = q.id )
847
+ WHERE m.id IS NULL OR q.id IS NULL
848
+ ');
849
+
850
+ //Start - Update Statistic
851
+ $this->_wpdb->query('
852
+ CREATE TABLE IF NOT EXISTS ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic_ref (
853
+ `statistic_ref_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
854
+ `quiz_id` int(11) NOT NULL,
855
+ `user_id` bigint(20) unsigned NOT NULL,
856
+ `create_time` int(11) NOT NULL,
857
+ `is_old` tinyint(1) unsigned NOT NULL,
858
+ PRIMARY KEY (`statistic_ref_id`),
859
+ KEY `quiz_id` (`quiz_id`,`user_id`),
860
+ KEY `time` (`create_time`)
861
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
862
+ ');
863
+
864
+ $this->_wpdb->query('
865
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic
866
+ ADD `statistic_ref_id` INT UNSIGNED NOT NULL FIRST
867
+ ');
868
+
869
+ $this->_wpdb->query('
870
+ INSERT INTO ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic_ref
871
+
872
+ (quiz_id, user_id, create_time, is_old)
873
+
874
+ SELECT s.quiz_id, s.user_id, ' . time() . ' AS create_time, 1 AS is_old
875
+ FROM ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic AS s
876
+ GROUP BY quiz_id, user_id
877
+ ');
878
+
879
+ $this->_wpdb->query('
880
+ UPDATE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic AS s
881
+ LEFT JOIN ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic_ref AS sf
882
+ ON s.quiz_id = sf.quiz_id AND s.user_id = sf.user_id
883
+
884
+ SET s.statistic_ref_id = sf.statistic_ref_id
885
+ ');
886
+
887
+ $this->_wpdb->query('
888
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic
889
+ DROP PRIMARY KEY ,
890
+ ADD PRIMARY KEY ( `statistic_ref_id` , `question_id` ) ,
891
+ DROP `quiz_id` ,
892
+ DROP `user_id` ,
893
+ ADD `question_time` INT UNSIGNED NOT NULL
894
+ ');
895
+
896
+ //end
897
+
898
+ //Master
899
+ $this->_wpdb->query("
900
+ ALTER TABLE " . $this->_wpdb->prefix . "wp_pro_quiz_master
901
+ ADD `user_email_notification` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
902
+ ADD `show_category_score` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
903
+ ADD `hide_result_correct_question` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
904
+ ADD `hide_result_quiz_time` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
905
+ ADD `hide_result_points` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'
906
+ ");
907
+
908
+ $this->_wpdb->query('SELECT * FROM ' . $this->_wpdb->prefix . 'wp_pro_quiz_master LIMIT 0,1');
909
+
910
+ $names = $this->_wpdb->get_col_info('name');
911
+
912
+ if (in_array('check_answer', $names)) {
913
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` DROP `check_answer` ');
914
+ }
915
+
916
+ if (in_array('back_button', $names)) {
917
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` DROP `back_button` ');
918
+ }
919
+
920
+ if (in_array('question_on_single_page', $names)) {
921
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master` DROP `question_on_single_page` ');
922
+ }
923
+
924
+ return 19;
925
+ }
926
+
927
+ private function upgradeDbV19()
928
+ {
929
+ $this->_wpdb->query('
930
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_question
931
+ ADD `answer_points_diff_modus_activated` TINYINT( 1 ) UNSIGNED NOT NULL,
932
+ ADD `disable_correct` TINYINT( 1 ) UNSIGNED NOT NULL
933
+ ');
934
+
935
+ $this->_wpdb->query('
936
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master
937
+ ADD `autostart` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ,
938
+ ADD `forcing_question_solve` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\',
939
+ ADD `hide_question_position_overview` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\',
940
+ ADD `hide_question_numbering` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\'
941
+ ');
942
+
943
+ return 20;
944
+ }
945
+
946
+ private function upgradeDbV20()
947
+ {
948
+ $this->_wpdb->query('SELECT * FROM ' . $this->_wpdb->prefix . 'wp_pro_quiz_master LIMIT 0,1');
949
+
950
+ $names = $this->_wpdb->get_col_info('name');
951
+
952
+ if (!in_array('autostart', $names)) {
953
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
954
+ ADD `autostart` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
955
+ }
956
+
957
+ if (!in_array('forcing_question_solve', $names)) {
958
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
959
+ ADD `forcing_question_solve` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
960
+ }
961
+
962
+ if (!in_array('hide_question_position_overview', $names)) {
963
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
964
+ ADD `hide_question_position_overview` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
965
+ }
966
+
967
+ if (!in_array('hide_question_numbering', $names)) {
968
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_master`
969
+ ADD `hide_question_numbering` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT \'0\' ');
970
+ }
971
+
972
+ $this->_wpdb->query('SELECT * FROM ' . $this->_wpdb->prefix . 'wp_pro_quiz_question LIMIT 0,1');
973
+
974
+ $names = $this->_wpdb->get_col_info('name');
975
+
976
+ if (!in_array('answer_points_diff_modus_activated', $names)) {
977
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
978
+ ADD `answer_points_diff_modus_activated` TINYINT( 1 ) UNSIGNED NOT NULL ');
979
+ }
980
+
981
+ if (!in_array('disable_correct', $names)) {
982
+ $this->_wpdb->query('ALTER TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_question`
983
+ ADD `disable_correct` TINYINT( 1 ) UNSIGNED NOT NULL ');
984
+ }
985
+
986
+ return 21;
987
+ }
988
+
989
+ private function upgradeDbV21()
990
+ {
991
+ $this->_wpdb->query('
992
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master
993
+ ADD `form_activated` TINYINT( 1 ) UNSIGNED NOT NULL ,
994
+ ADD `form_show_position` TINYINT UNSIGNED NOT NULL ,
995
+ ADD `start_only_registered_user` TINYINT( 1 ) UNSIGNED NOT NULL ,
996
+ ADD `questions_per_page` TINYINT UNSIGNED NOT NULL ,
997
+ ADD `sort_categories` TINYINT( 1 ) UNSIGNED NOT NULL ,
998
+ ADD `show_category` TINYINT( 1 ) UNSIGNED NOT NULL
999
+ ');
1000
+
1001
+ $this->_wpdb->query('
1002
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic
1003
+ ADD `answer_data` TEXT NULL DEFAULT NULL
1004
+ ');
1005
+
1006
+ $this->_wpdb->query('
1007
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic_ref
1008
+ ADD `form_data` TEXT NULL DEFAULT NULL
1009
+ ');
1010
+
1011
+ $this->_wpdb->query('
1012
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_question
1013
+ ADD `online` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `quiz_id` ,
1014
+ ADD `matrix_sort_answer_criteria_width` TINYINT( 3 ) UNSIGNED NOT NULL
1015
+ ');
1016
+
1017
+ $this->_wpdb->query('
1018
+ CREATE TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_form` (
1019
+ `form_id` int(11) NOT NULL AUTO_INCREMENT,
1020
+ `quiz_id` int(11) NOT NULL,
1021
+ `fieldname` varchar(100) NOT NULL,
1022
+ `type` tinyint(4) NOT NULL,
1023
+ `required` tinyint(1) unsigned NOT NULL,
1024
+ `sort` tinyint(4) NOT NULL,
1025
+ `data` mediumtext,
1026
+ PRIMARY KEY (`form_id`),
1027
+ KEY `quiz_id` (`quiz_id`)
1028
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1029
+ ');
1030
+
1031
+ $this->_wpdb->query('
1032
+ CREATE TABLE `' . $this->_wpdb->prefix . 'wp_pro_quiz_template` (
1033
+ `template_id` int(11) NOT NULL AUTO_INCREMENT,
1034
+ `name` varchar(200) NOT NULL,
1035
+ `type` tinyint(3) unsigned NOT NULL,
1036
+ `data` text NOT NULL,
1037
+ PRIMARY KEY (`template_id`)
1038
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1039
+ ');
1040
+
1041
+ //Check
1042
+ $this->databaseDelta();
1043
+
1044
+ $this->_wpdb->query('UPDATE ' . $this->_wpdb->prefix . 'wp_pro_quiz_question
1045
+ SET online = 1');
1046
+
1047
+ return 22;
1048
+ }
1049
+
1050
+ private function upgradeDbV22()
1051
+ {
1052
+ $this->_wpdb->query('
1053
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_category
1054
+ ADD `type` ENUM( \'QUESTION\', \'QUIZ\' ) NOT NULL DEFAULT \'QUESTION\';
1055
+ ');
1056
+
1057
+ $this->_wpdb->query('
1058
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master
1059
+ ADD `category_id` INT UNSIGNED NOT NULL ;
1060
+ ');
1061
+
1062
+ $this->_wpdb->query('UPDATE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master
1063
+ SET category_id = 0');
1064
+
1065
+ $this->_wpdb->query('UPDATE ' . $this->_wpdb->prefix . 'wp_pro_quiz_category
1066
+ SET type = \'QUESTION\'');
1067
+
1068
+ return 23;
1069
+ }
1070
+
1071
+ private function upgradeDbV23()
1072
+ {
1073
+ $this->_wpdb->query('
1074
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master
1075
+ ADD `admin_email` TEXT NOT NULL ,
1076
+ ADD `user_email` TEXT NOT NULL ;
1077
+ ');
1078
+
1079
+ $mapper = new WpProQuiz_Model_GlobalSettingsMapper();
1080
+ $adminEmail = $mapper->getEmailSettings();
1081
+ $userEmail = $mapper->getUserEmailSettings();
1082
+
1083
+ $adminEmailNew = new WpProQuiz_Model_Email();
1084
+ $adminEmailNew->setTo($adminEmail['to']);
1085
+ $adminEmailNew->setFrom($adminEmail['from']);
1086
+ $adminEmailNew->setSubject($adminEmail['subject']);
1087
+ $adminEmailNew->setHtml($adminEmail['html']);
1088
+ $adminEmailNew->setMessage($adminEmail['message']);
1089
+
1090
+ $userEmailNew = new WpProQuiz_Model_Email();
1091
+ $userEmailNew->setFrom($userEmail['from']);
1092
+ $userEmailNew->setToUser(true);
1093
+ $userEmailNew->setSubject($userEmail['subject']);
1094
+ $userEmailNew->setHtml($userEmail['html']);
1095
+ $userEmailNew->setMessage($userEmail['message']);
1096
+
1097
+ $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master',
1098
+ array('admin_email' => @serialize($adminEmailNew)),
1099
+ array('email_notification' => 1),
1100
+ array('%s'), array('%d'));
1101
+
1102
+ $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master',
1103
+ array('admin_email' => @serialize($adminEmailNew)),
1104
+ array('email_notification' => 2),
1105
+ array('%s'), array('%d'));
1106
+
1107
+ $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master',
1108
+ array('user_email' => @serialize($userEmailNew)),
1109
+ array('user_email_notification' => 1),
1110
+ array('%s'), array('%d'));
1111
+
1112
+ return 24;
1113
+ }
1114
+
1115
+ private function upgradeDbV24()
1116
+ {
1117
+ $this->_wpdb->query('
1118
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_form
1119
+ ADD `show_in_statistic` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `sort` ;
1120
+ ');
1121
+
1122
+ $this->_wpdb->query('
1123
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic
1124
+ ADD `solved_count` TINYINT( 1 ) NOT NULL AFTER `hint_count` ;
1125
+ ');
1126
+
1127
+ $this->_wpdb->query('UPDATE ' . $this->_wpdb->prefix . 'wp_pro_quiz_statistic
1128
+ SET solved_count = -1');
1129
+
1130
+ $this->_wpdb->query('
1131
+ ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master
1132
+ ADD `plugin_container` TEXT NULL DEFAULT NULL ;
1133
+ ');
1134
+
1135
+ return 25;
1136
+ }
1137
  }
lib/helper/WpProQuiz_Helper_Export.php CHANGED
@@ -1,54 +1,64 @@
1
- <?php
2
- class WpProQuiz_Helper_Export {
3
-
4
- const WPPROQUIZ_EXPORT_VERSION = 4;
5
-
6
- public function export($ids) {
7
- $export = array();
8
-
9
- $export['version'] = WPPROQUIZ_VERSION;
10
- $export['exportVersion'] = WpProQuiz_Helper_Export::WPPROQUIZ_EXPORT_VERSION;
11
- $export['date'] = time();
12
-
13
- $v = str_pad(WPPROQUIZ_VERSION, 5, '0', STR_PAD_LEFT);
14
- $v .= str_pad(WpProQuiz_Helper_Export::WPPROQUIZ_EXPORT_VERSION, 5, '0', STR_PAD_LEFT);
15
- $code = 'WPQ'.$v;
16
-
17
- $export['master'] = $this->getQuizMaster($ids);
18
-
19
- foreach($export['master'] as $master) {
20
- $export['question'][$master->getId()] = $this->getQuestion($master->getId());
21
- $export['forms'][$master->getId()] = $this->getForms($master->getId());
22
- }
23
-
24
- return $code.base64_encode(serialize($export));
25
- }
26
-
27
- private function getQuizMaster($ids) {
28
- $m = new WpProQuiz_Model_QuizMapper();
29
-
30
- $r = array();
31
-
32
- foreach($ids as $id) {
33
- $master = $m->fetch($id);
34
-
35
- if($master->getId() > 0) {
36
- $r[] = $master;
37
- }
38
- }
39
-
40
- return $r;
41
- }
42
-
43
- public function getQuestion($quizId) {
44
- $m = new WpProQuiz_Model_QuestionMapper();
45
-
46
- return $m->fetchAll($quizId);
47
- }
48
-
49
- private function getForms($quizId) {
50
- $formMapper = new WpProQuiz_Model_FormMapper();
51
-
52
- return $formMapper->fetch($quizId);
53
- }
 
 
 
 
 
 
 
 
 
 
54
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Helper_Export
4
+ {
5
+
6
+ const WPPROQUIZ_EXPORT_VERSION = 4;
7
+
8
+ public function export($ids)
9
+ {
10
+ $export = array();
11
+
12
+ $export['version'] = WPPROQUIZ_VERSION;
13
+ $export['exportVersion'] = WpProQuiz_Helper_Export::WPPROQUIZ_EXPORT_VERSION;
14
+ $export['date'] = time();
15
+
16
+ $v = str_pad(WPPROQUIZ_VERSION, 5, '0', STR_PAD_LEFT);
17
+ $v .= str_pad(WpProQuiz_Helper_Export::WPPROQUIZ_EXPORT_VERSION, 5, '0', STR_PAD_LEFT);
18
+ $code = 'WPQ' . $v;
19
+
20
+ $export['master'] = $this->getQuizMaster($ids);
21
+
22
+ foreach ($export['master'] as $master) {
23
+ $export['question'][$master->getId()] = $this->getQuestion($master->getId());
24
+ $export['forms'][$master->getId()] = $this->getForms($master->getId());
25
+ }
26
+
27
+ return $code . base64_encode(serialize($export));
28
+ }
29
+
30
+ /**
31
+ * @param $ids
32
+ * @return WpProQuiz_Model_Quiz[]
33
+ */
34
+ private function getQuizMaster($ids)
35
+ {
36
+ $m = new WpProQuiz_Model_QuizMapper();
37
+
38
+ $r = array();
39
+
40
+ foreach ($ids as $id) {
41
+ $master = $m->fetch($id);
42
+
43
+ if ($master->getId() > 0) {
44
+ $r[] = $master;
45
+ }
46
+ }
47
+
48
+ return $r;
49
+ }
50
+
51
+ public function getQuestion($quizId)
52
+ {
53
+ $m = new WpProQuiz_Model_QuestionMapper();
54
+
55
+ return $m->fetchAll($quizId);
56
+ }
57
+
58
+ private function getForms($quizId)
59
+ {
60
+ $formMapper = new WpProQuiz_Model_FormMapper();
61
+
62
+ return $formMapper->fetch($quizId);
63
+ }
64
  }
lib/helper/WpProQuiz_Helper_ExportXml.php CHANGED
@@ -1,294 +1,341 @@
1
- <?php
2
- class WpProQuiz_Helper_ExportXml {
3
-
4
- public function export($ids) {
5
-
6
- $dom = new DOMDocument('1.0', 'utf-8');
7
-
8
- $root = $dom->createElement('wpProQuiz');
9
-
10
- $dom->appendChild($root);
11
-
12
- $header = $dom->createElement('header');
13
- $header->setAttribute('version', WPPROQUIZ_VERSION);
14
- $header->setAttribute('exportVersion', 1);
15
-
16
- $root->appendChild($header);
17
- $data = $dom->createElement('data');
18
-
19
- $quizMapper = new WpProQuiz_Model_QuizMapper();
20
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
21
- $formMapper = new WpProQuiz_Model_FormMapper();
22
-
23
- foreach($ids as $id) {
24
- $quizModel = $quizMapper->fetch($id);
25
-
26
- if($quizModel->getId() <= 0)
27
- continue;
28
-
29
- $questionModel = $questionMapper->fetchAll($quizModel->getId());
30
- $forms = array();
31
-
32
- if($quizModel->isFormActivated())
33
- $forms = $formMapper->fetch($quizModel->getId());
34
-
35
- $quizElement = $this->getQuizElement($dom, $quizModel, $forms);
36
-
37
- $quizElement->appendChild($questionsElement = $dom->createElement('questions'));
38
-
39
- foreach($questionModel as $model) {
40
- $questionElement = $this->createQuestionElement($dom, $model);
41
- $questionsElement->appendChild($questionElement);
42
- }
43
-
44
- $data->appendChild($quizElement);
45
- }
46
-
47
- $root->appendChild($data);
48
-
49
- return $dom->saveXML();
50
- }
51
-
52
- /**
53
- * @param DOMDocument $dom
54
- * @param WpProQuiz_Model_Quiz $quiz
55
- */
56
- private function getQuizElement($dom, $quiz, $forms) {
57
- $quizElement = $dom->createElement('quiz');
58
-
59
- $title = $dom->createElement('title');
60
- $title->appendChild($dom->createCDATASection($quiz->getName()));
61
- $title->setAttribute('titleHidden', $this->booleanToTrueOrFalse($quiz->isTitleHidden()));
62
- $quizElement->appendChild($title);
63
-
64
- $quizElement->appendChild($text = $dom->createElement('text'));
65
- $text->appendChild($dom->createCDATASection($quiz->getText()));
66
-
67
- $quizElement->appendChild($dom->createElement('category', $quiz->getCategoryName()));
68
-
69
- if(is_array($quiz->getResultText())) {
70
- $resultArray = $quiz->getResultText();
71
- $result = $dom->createElement('resultText');
72
- $result->setAttribute('gradeEnabled', $this->booleanToTrueOrFalse($quiz->isResultGradeEnabled()));
73
-
74
- for($i = 0; $i < count($resultArray); $i++) {
75
- $r = $dom->createElement('text');
76
- $r->appendChild($dom->createCDATASection($resultArray['text'][$i]));
77
- $r->setAttribute('prozent', $resultArray['prozent'][$i]);
78
-
79
- $result->appendChild($r);
80
- }
81
-
82
- $quizElement->appendChild($result);
83
- } else {
84
- $result = $dom->createElement('resultText');
85
- $result->setAttribute('gradeEnabled', $this->booleanToTrueOrFalse($quiz->isResultGradeEnabled()));
86
- $result->appendChild($dom->createCDATASection($quiz->getResultText()));
87
-
88
- $quizElement->appendChild($result);
89
- }
90
-
91
-
92
- $quizElement->appendChild($dom->createElement('btnRestartQuizHidden', $this->booleanToTrueOrFalse($quiz->isBtnRestartQuizHidden())));
93
- $quizElement->appendChild($dom->createElement('btnViewQuestionHidden', $this->booleanToTrueOrFalse($quiz->isBtnViewQuestionHidden())));
94
- $quizElement->appendChild($dom->createElement('questionRandom', $this->booleanToTrueOrFalse($quiz->isQuestionRandom())));
95
- $quizElement->appendChild($dom->createElement('answerRandom', $this->booleanToTrueOrFalse($quiz->isAnswerRandom())));
96
- $quizElement->appendChild($dom->createElement('timeLimit', $quiz->getTimeLimit()));
97
- $quizElement->appendChild($dom->createElement('showPoints', $this->booleanToTrueOrFalse($quiz->isShowPoints())));
98
-
99
- $statistic = $dom->createElement('statistic');
100
- $statistic->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isStatisticsOn()));
101
- $statistic->setAttribute('ipLock', $quiz->getStatisticsIpLock());
102
- $quizElement->appendChild($statistic);
103
-
104
-
105
- $quizElement->appendChild($quizRunOnce = $dom->createElement('quizRunOnce', $this->booleanToTrueOrFalse($quiz->isQuizRunOnce())));
106
- $quizRunOnce->setAttribute('type', $quiz->getQuizRunOnceType());
107
- $quizRunOnce->setAttribute('cookie', $this->booleanToTrueOrFalse($quiz->isQuizRunOnceCookie()));
108
- $quizRunOnce->setAttribute('time', $quiz->getQuizRunOnceTime());
109
-
110
- $quizElement->appendChild($dom->createElement('numberedAnswer', $this->booleanToTrueOrFalse($quiz->isNumberedAnswer())));
111
- $quizElement->appendChild($dom->createElement('hideAnswerMessageBox', $this->booleanToTrueOrFalse($quiz->isHideAnswerMessageBox())));
112
- $quizElement->appendChild($dom->createElement('disabledAnswerMark', $this->booleanToTrueOrFalse($quiz->isDisabledAnswerMark())));
113
-
114
- $quizElement->appendChild($showMaxQuestion = $dom->createElement('showMaxQuestion', $this->booleanToTrueOrFalse($quiz->isShowMaxQuestion())));
115
- $showMaxQuestion->setAttribute('showMaxQuestionValue', $quiz->getShowMaxQuestionValue());
116
- $showMaxQuestion->setAttribute('showMaxQuestionPercent', $this->booleanToTrueOrFalse($quiz->isShowMaxQuestionPercent()));
117
-
118
-
119
- //Toplist
120
- $toplist = $dom->createElement('toplist');
121
- $toplist->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isToplistActivated()));
122
- $toplist->appendChild($dom->createElement('toplistDataAddPermissions', $quiz->getToplistDataAddPermissions()));
123
- $toplist->appendChild($dom->createElement('toplistDataSort', $quiz->getToplistDataSort()));
124
- $toplist->appendChild($dom->createElement('toplistDataAddMultiple', $this->booleanToTrueOrFalse($quiz->isToplistDataAddMultiple())));
125
- $toplist->appendChild($dom->createElement('toplistDataAddBlock', $quiz->getToplistDataAddBlock()));
126
- $toplist->appendChild($dom->createElement('toplistDataShowLimit', $quiz->getToplistDataShowLimit()));
127
- $toplist->appendChild($dom->createElement('toplistDataShowIn', $quiz->getToplistDataShowIn()));
128
- $toplist->appendChild($dom->createElement('toplistDataCaptcha', $this->booleanToTrueOrFalse($quiz->isToplistDataCaptcha())));
129
- $toplist->appendChild($dom->createElement('toplistDataAddAutomatic', $this->booleanToTrueOrFalse($quiz->isToplistDataAddAutomatic())));
130
-
131
- $quizElement->appendChild($toplist);
132
-
133
- $quizElement->appendChild($dom->createElement('showAverageResult', $this->booleanToTrueOrFalse($quiz->isShowAverageResult())));
134
- $quizElement->appendChild($dom->createElement('prerequisite', $this->booleanToTrueOrFalse($quiz->isPrerequisite())));
135
- $quizElement->appendChild($dom->createElement('showReviewQuestion', $this->booleanToTrueOrFalse($quiz->isShowReviewQuestion())));
136
- $quizElement->appendChild($dom->createElement('quizSummaryHide', $this->booleanToTrueOrFalse($quiz->isQuizSummaryHide())));
137
- $quizElement->appendChild($dom->createElement('skipQuestionDisabled', $this->booleanToTrueOrFalse($quiz->isSkipQuestionDisabled())));
138
- $quizElement->appendChild($dom->createElement('emailNotification', $quiz->getEmailNotification()));
139
- $quizElement->appendChild($dom->createElement('userEmailNotification', $this->booleanToTrueOrFalse($quiz->isUserEmailNotification())));
140
- $quizElement->appendChild($dom->createElement('showCategoryScore', $this->booleanToTrueOrFalse($quiz->isShowCategoryScore())));
141
- $quizElement->appendChild($dom->createElement('hideResultCorrectQuestion', $this->booleanToTrueOrFalse($quiz->isHideResultCorrectQuestion())));
142
- $quizElement->appendChild($dom->createElement('hideResultQuizTime', $this->booleanToTrueOrFalse($quiz->isHideResultQuizTime())));
143
- $quizElement->appendChild($dom->createElement('hideResultPoints', $this->booleanToTrueOrFalse($quiz->isHideResultPoints())));
144
- $quizElement->appendChild($dom->createElement('autostart', $this->booleanToTrueOrFalse($quiz->isAutostart())));
145
- $quizElement->appendChild($dom->createElement('forcingQuestionSolve', $this->booleanToTrueOrFalse($quiz->isForcingQuestionSolve())));
146
- $quizElement->appendChild($dom->createElement('hideQuestionPositionOverview', $this->booleanToTrueOrFalse($quiz->isHideQuestionPositionOverview())));
147
- $quizElement->appendChild($dom->createElement('hideQuestionNumbering', $this->booleanToTrueOrFalse($quiz->isHideQuestionNumbering())));
148
-
149
- //0.27
150
- $quizElement->appendChild($dom->createElement('sortCategories', $this->booleanToTrueOrFalse($quiz->isSortCategories())));
151
- $quizElement->appendChild($dom->createElement('showCategory', $this->booleanToTrueOrFalse($quiz->isShowCategory())));
152
- $quizModus = $dom->createElement('quizModus', $quiz->getQuizModus());
153
- $quizModus->setAttribute('questionsPerPage', $quiz->getQuestionsPerPage());
154
- $quizElement->appendChild($quizModus);
155
-
156
- $quizElement->appendChild($dom->createElement('startOnlyRegisteredUser', $this->booleanToTrueOrFalse($quiz->isStartOnlyRegisteredUser())));
157
-
158
- $formsElement = $dom->createElement('forms');
159
- $formsElement->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isFormActivated()));
160
- $formsElement->setAttribute('position', $quiz->getFormShowPosition());
161
-
162
- //0.29
163
- if($quiz->getAdminEmail() !== null) {
164
- /* @var $adminEmail WpProQuiz_Model_Email */
165
- $adminEmail = $quiz->getAdminEmail();
166
- $adminEmailXml = $dom->createElement('adminEmail');
167
-
168
- /*
169
- * $qElement->appendChild($title = $dom->createElement('title'));
170
- $title->appendChild($dom->createCDATASection($question->getTitle()));
171
- */
172
-
173
- $adminEmailXml->appendChild($dom->createElement('to', $adminEmail->getTo()));
174
- $adminEmailXml->appendChild($dom->createElement('form', $adminEmail->getFrom()));
175
- $adminEmailXml->appendChild($dom->createElement('subject', $adminEmail->getSubject()));
176
- $adminEmailXml->appendChild($dom->createElement('html', $this->booleanToTrueOrFalse($adminEmail->isHtml())));
177
- $adminEmailXml->appendChild($message = $dom->createElement('message'));
178
- $message->appendChild($dom->createCDATASection($adminEmail->getMessage()));
179
-
180
- $quizElement->appendChild($adminEmailXml);
181
- }
182
-
183
- if($quiz->getUserEmail() !== null) {
184
- /* @var $adminEmail WpProQuiz_Model_Email */
185
- $userEmail = $quiz->getUserEmail();
186
- $userEmaillXml = $dom->createElement('userEmail');
187
-
188
- $userEmaillXml->appendChild($dom->createElement('to', $userEmail->getTo()));
189
- $userEmaillXml->appendChild($dom->createElement('toUser', $this->booleanToTrueOrFalse($userEmail->isToUser())));
190
- $userEmaillXml->appendChild($dom->createElement('toForm', $this->booleanToTrueOrFalse($userEmail->isToForm())));
191
- $userEmaillXml->appendChild($dom->createElement('form', $userEmail->getFrom()));
192
- $userEmaillXml->appendChild($dom->createElement('subject', $userEmail->getSubject()));
193
- $userEmaillXml->appendChild($dom->createElement('html', $this->booleanToTrueOrFalse($userEmail->isHtml())));
194
- $userEmaillXml->appendChild($message = $dom->createElement('message'));
195
- $message->appendChild($dom->createCDATASection($userEmail->getMessage()));
196
-
197
- $quizElement->appendChild($userEmaillXml);
198
- }
199
-
200
- foreach($forms as $form) {
201
- /** @var WpProQuiz_Model_Form $form **/
202
-
203
- $formElement = $dom->createElement('form');
204
- $formElement->setAttribute('type', $form->getType());
205
- $formElement->setAttribute('required', $this->booleanToTrueOrFalse($form->isRequired()));
206
- $formElement->setAttribute('fieldname', $form->getFieldname());
207
-
208
- if($form->getData() !== null) {
209
- $data = $form->getData();
210
-
211
- foreach($data as $d) {
212
- $formDataElement = $dom->createElement('formData', $d);
213
- $formElement->appendChild($formDataElement);
214
- }
215
- }
216
-
217
- $formsElement->appendChild($formElement);
218
- }
219
-
220
- $quizElement->appendChild($formsElement);
221
-
222
- return $quizElement;
223
- }
224
-
225
- /**
226
- * @param DOMDocument $dom
227
- * @param WpProQuiz_Model_Question $question
228
- * @return DOMDocument
229
- */
230
- private function createQuestionElement($dom, $question) {
231
- $qElement = $dom->createElement('question');
232
- $qElement->setAttribute('answerType', $question->getAnswerType());
233
-
234
- $qElement->appendChild($title = $dom->createElement('title'));
235
- $title->appendChild($dom->createCDATASection($question->getTitle()));
236
-
237
- $qElement->appendChild($dom->createElement('points', $question->getPoints()));
238
-
239
- $qElement->appendChild($questionText = $dom->createElement('questionText'));
240
- $questionText->appendChild($dom->createCDATASection($question->getQuestion()));
241
-
242
- $qElement->appendChild($correctMsg = $dom->createElement('correctMsg'));
243
- $correctMsg->appendChild($dom->createCDATASection($question->getCorrectMsg()));
244
-
245
- $qElement->appendChild($incorrectMsg = $dom->createElement('incorrectMsg'));
246
- $incorrectMsg->appendChild($dom->createCDATASection($question->getIncorrectMsg()));
247
-
248
- $qElement->appendChild($tipMsg = $dom->createElement('tipMsg'));
249
- $tipMsg->setAttribute('enabled', $this->booleanToTrueOrFalse($question->isTipEnabled()));
250
- $tipMsg->appendChild($dom->createCDATASection($question->getTipMsg()));
251
-
252
- $qElement->appendChild($dom->createElement('category', $question->getCategoryName()));
253
-
254
- $qElement->appendChild($dom->createElement('correctSameText', $this->booleanToTrueOrFalse($question->isCorrectSameText())));
255
- $qElement->appendChild($dom->createElement('showPointsInBox', $this->booleanToTrueOrFalse($question->isShowPointsInBox())));
256
- $qElement->appendChild($dom->createElement('answerPointsActivated', $this->booleanToTrueOrFalse($question->isAnswerPointsActivated())));
257
- $qElement->appendChild($dom->createElement('answerPointsDiffModusActivated', $this->booleanToTrueOrFalse($question->isAnswerPointsDiffModusActivated())));
258
- $qElement->appendChild($dom->createElement('disableCorrect', $this->booleanToTrueOrFalse($question->isDisableCorrect())));
259
-
260
- $answersElement = $dom->createElement('answers');
261
-
262
- $answerData = $question->getAnswerData();
263
-
264
- if(is_array($answerData)) {
265
- foreach ($answerData as $answer) {
266
- $answerElement = $dom->createElement('answer');
267
- $answerElement->setAttribute('points', $answer->getPoints());
268
- $answerElement->setAttribute('correct', $this->booleanToTrueOrFalse($answer->isCorrect()));
269
-
270
- $answerText = $dom->createElement('answerText');
271
- $answerText->setAttribute('html', $this->booleanToTrueOrFalse($answer->isHtml()));
272
- $answerText->appendChild($dom->createCDATASection($answer->getAnswer()));
273
-
274
- $answerElement->appendChild($answerText);
275
-
276
- $sortText = $dom->createElement('stortText');
277
- $sortText->setAttribute('html', $this->booleanToTrueOrFalse($answer->isSortStringHtml()));
278
- $sortText->appendChild($dom->createCDATASection($answer->getSortString()));
279
-
280
- $answerElement->appendChild($sortText);
281
-
282
- $answersElement->appendChild($answerElement);
283
- }
284
- }
285
-
286
- $qElement->appendChild($answersElement);
287
-
288
- return $qElement;
289
- }
290
-
291
- private function booleanToTrueOrFalse($v) {
292
- return $v ? 'true' : 'false';
293
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Helper_ExportXml
4
+ {
5
+
6
+ public function export($ids)
7
+ {
8
+
9
+ $dom = new DOMDocument('1.0', 'utf-8');
10
+
11
+ $root = $dom->createElement('wpProQuiz');
12
+
13
+ $dom->appendChild($root);
14
+
15
+ $header = $dom->createElement('header');
16
+ $header->setAttribute('version', WPPROQUIZ_VERSION);
17
+ $header->setAttribute('exportVersion', 1);
18
+
19
+ $root->appendChild($header);
20
+ $data = $dom->createElement('data');
21
+
22
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
23
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
24
+ $formMapper = new WpProQuiz_Model_FormMapper();
25
+
26
+ foreach ($ids as $id) {
27
+ $quizModel = $quizMapper->fetch($id);
28
+
29
+ if ($quizModel->getId() <= 0) {
30
+ continue;
31
+ }
32
+
33
+ $questionModel = $questionMapper->fetchAll($quizModel->getId());
34
+ $forms = array();
35
+
36
+ if ($quizModel->isFormActivated()) {
37
+ $forms = $formMapper->fetch($quizModel->getId());
38
+ }
39
+
40
+ $quizElement = $this->getQuizElement($dom, $quizModel, $forms);
41
+
42
+ $quizElement->appendChild($questionsElement = $dom->createElement('questions'));
43
+
44
+ foreach ($questionModel as $model) {
45
+ $questionElement = $this->createQuestionElement($dom, $model);
46
+ $questionsElement->appendChild($questionElement);
47
+ }
48
+
49
+ $data->appendChild($quizElement);
50
+ }
51
+
52
+ $root->appendChild($data);
53
+
54
+ return $dom->saveXML();
55
+ }
56
+
57
+ /**
58
+ * @param DOMDocument $dom
59
+ * @param WpProQuiz_Model_Quiz $quiz
60
+ * @param $forms
61
+ * @return DOMElement
62
+ */
63
+ private function getQuizElement($dom, $quiz, $forms)
64
+ {
65
+ $quizElement = $dom->createElement('quiz');
66
+
67
+ $title = $dom->createElement('title');
68
+ $title->appendChild($dom->createCDATASection($quiz->getName()));
69
+ $title->setAttribute('titleHidden', $this->booleanToTrueOrFalse($quiz->isTitleHidden()));
70
+ $quizElement->appendChild($title);
71
+
72
+ $quizElement->appendChild($text = $dom->createElement('text'));
73
+ $text->appendChild($dom->createCDATASection($quiz->getText()));
74
+
75
+ $quizElement->appendChild($dom->createElement('category', $quiz->getCategoryName()));
76
+
77
+ if (is_array($quiz->getResultText())) {
78
+ $resultArray = $quiz->getResultText();
79
+ $result = $dom->createElement('resultText');
80
+ $result->setAttribute('gradeEnabled', $this->booleanToTrueOrFalse($quiz->isResultGradeEnabled()));
81
+
82
+ for ($i = 0; $i < count($resultArray); $i++) {
83
+ $r = $dom->createElement('text');
84
+ $r->appendChild($dom->createCDATASection($resultArray['text'][$i]));
85
+ $r->setAttribute('prozent', $resultArray['prozent'][$i]);
86
+
87
+ $result->appendChild($r);
88
+ }
89
+
90
+ $quizElement->appendChild($result);
91
+ } else {
92
+ $result = $dom->createElement('resultText');
93
+ $result->setAttribute('gradeEnabled', $this->booleanToTrueOrFalse($quiz->isResultGradeEnabled()));
94
+ $result->appendChild($dom->createCDATASection($quiz->getResultText()));
95
+
96
+ $quizElement->appendChild($result);
97
+ }
98
+
99
+ $quizElement->appendChild($dom->createElement('btnRestartQuizHidden',
100
+ $this->booleanToTrueOrFalse($quiz->isBtnRestartQuizHidden())));
101
+ $quizElement->appendChild($dom->createElement('btnViewQuestionHidden',
102
+ $this->booleanToTrueOrFalse($quiz->isBtnViewQuestionHidden())));
103
+ $quizElement->appendChild($dom->createElement('questionRandom',
104
+ $this->booleanToTrueOrFalse($quiz->isQuestionRandom())));
105
+ $quizElement->appendChild($dom->createElement('answerRandom',
106
+ $this->booleanToTrueOrFalse($quiz->isAnswerRandom())));
107
+ $quizElement->appendChild($dom->createElement('timeLimit', $quiz->getTimeLimit()));
108
+ $quizElement->appendChild($dom->createElement('showPoints',
109
+ $this->booleanToTrueOrFalse($quiz->isShowPoints())));
110
+
111
+ $statistic = $dom->createElement('statistic');
112
+ $statistic->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isStatisticsOn()));
113
+ $statistic->setAttribute('ipLock', $quiz->getStatisticsIpLock());
114
+ $quizElement->appendChild($statistic);
115
+
116
+ $quizElement->appendChild($quizRunOnce = $dom->createElement('quizRunOnce',
117
+ $this->booleanToTrueOrFalse($quiz->isQuizRunOnce())));
118
+ $quizRunOnce->setAttribute('type', $quiz->getQuizRunOnceType());
119
+ $quizRunOnce->setAttribute('cookie', $this->booleanToTrueOrFalse($quiz->isQuizRunOnceCookie()));
120
+ $quizRunOnce->setAttribute('time', $quiz->getQuizRunOnceTime());
121
+
122
+ $quizElement->appendChild($dom->createElement('numberedAnswer',
123
+ $this->booleanToTrueOrFalse($quiz->isNumberedAnswer())));
124
+ $quizElement->appendChild($dom->createElement('hideAnswerMessageBox',
125
+ $this->booleanToTrueOrFalse($quiz->isHideAnswerMessageBox())));
126
+ $quizElement->appendChild($dom->createElement('disabledAnswerMark',
127
+ $this->booleanToTrueOrFalse($quiz->isDisabledAnswerMark())));
128
+
129
+ $quizElement->appendChild($showMaxQuestion = $dom->createElement('showMaxQuestion',
130
+ $this->booleanToTrueOrFalse($quiz->isShowMaxQuestion())));
131
+ $showMaxQuestion->setAttribute('showMaxQuestionValue', $quiz->getShowMaxQuestionValue());
132
+ $showMaxQuestion->setAttribute('showMaxQuestionPercent',
133
+ $this->booleanToTrueOrFalse($quiz->isShowMaxQuestionPercent()));
134
+
135
+ //Toplist
136
+ $toplist = $dom->createElement('toplist');
137
+ $toplist->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isToplistActivated()));
138
+ $toplist->appendChild($dom->createElement('toplistDataAddPermissions', $quiz->getToplistDataAddPermissions()));
139
+ $toplist->appendChild($dom->createElement('toplistDataSort', $quiz->getToplistDataSort()));
140
+ $toplist->appendChild($dom->createElement('toplistDataAddMultiple',
141
+ $this->booleanToTrueOrFalse($quiz->isToplistDataAddMultiple())));
142
+ $toplist->appendChild($dom->createElement('toplistDataAddBlock', $quiz->getToplistDataAddBlock()));
143
+ $toplist->appendChild($dom->createElement('toplistDataShowLimit', $quiz->getToplistDataShowLimit()));
144
+ $toplist->appendChild($dom->createElement('toplistDataShowIn', $quiz->getToplistDataShowIn()));
145
+ $toplist->appendChild($dom->createElement('toplistDataCaptcha',
146
+ $this->booleanToTrueOrFalse($quiz->isToplistDataCaptcha())));
147
+ $toplist->appendChild($dom->createElement('toplistDataAddAutomatic',
148
+ $this->booleanToTrueOrFalse($quiz->isToplistDataAddAutomatic())));
149
+
150
+ $quizElement->appendChild($toplist);
151
+
152
+ $quizElement->appendChild($dom->createElement('showAverageResult',
153
+ $this->booleanToTrueOrFalse($quiz->isShowAverageResult())));
154
+ $quizElement->appendChild($dom->createElement('prerequisite',
155
+ $this->booleanToTrueOrFalse($quiz->isPrerequisite())));
156
+ $quizElement->appendChild($dom->createElement('showReviewQuestion',
157
+ $this->booleanToTrueOrFalse($quiz->isShowReviewQuestion())));
158
+ $quizElement->appendChild($dom->createElement('quizSummaryHide',
159
+ $this->booleanToTrueOrFalse($quiz->isQuizSummaryHide())));
160
+ $quizElement->appendChild($dom->createElement('skipQuestionDisabled',
161
+ $this->booleanToTrueOrFalse($quiz->isSkipQuestionDisabled())));
162
+ $quizElement->appendChild($dom->createElement('emailNotification', $quiz->getEmailNotification()));
163
+ $quizElement->appendChild($dom->createElement('userEmailNotification',
164
+ $this->booleanToTrueOrFalse($quiz->isUserEmailNotification())));
165
+ $quizElement->appendChild($dom->createElement('showCategoryScore',
166
+ $this->booleanToTrueOrFalse($quiz->isShowCategoryScore())));
167
+ $quizElement->appendChild($dom->createElement('hideResultCorrectQuestion',
168
+ $this->booleanToTrueOrFalse($quiz->isHideResultCorrectQuestion())));
169
+ $quizElement->appendChild($dom->createElement('hideResultQuizTime',
170
+ $this->booleanToTrueOrFalse($quiz->isHideResultQuizTime())));
171
+ $quizElement->appendChild($dom->createElement('hideResultPoints',
172
+ $this->booleanToTrueOrFalse($quiz->isHideResultPoints())));
173
+ $quizElement->appendChild($dom->createElement('autostart', $this->booleanToTrueOrFalse($quiz->isAutostart())));
174
+ $quizElement->appendChild($dom->createElement('forcingQuestionSolve',
175
+ $this->booleanToTrueOrFalse($quiz->isForcingQuestionSolve())));
176
+ $quizElement->appendChild($dom->createElement('hideQuestionPositionOverview',
177
+ $this->booleanToTrueOrFalse($quiz->isHideQuestionPositionOverview())));
178
+ $quizElement->appendChild($dom->createElement('hideQuestionNumbering',
179
+ $this->booleanToTrueOrFalse($quiz->isHideQuestionNumbering())));
180
+
181
+ //0.27
182
+ $quizElement->appendChild($dom->createElement('sortCategories',
183
+ $this->booleanToTrueOrFalse($quiz->isSortCategories())));
184
+ $quizElement->appendChild($dom->createElement('showCategory',
185
+ $this->booleanToTrueOrFalse($quiz->isShowCategory())));
186
+ $quizModus = $dom->createElement('quizModus', $quiz->getQuizModus());
187
+ $quizModus->setAttribute('questionsPerPage', $quiz->getQuestionsPerPage());
188
+ $quizElement->appendChild($quizModus);
189
+
190
+ $quizElement->appendChild($dom->createElement('startOnlyRegisteredUser',
191
+ $this->booleanToTrueOrFalse($quiz->isStartOnlyRegisteredUser())));
192
+
193
+ $formsElement = $dom->createElement('forms');
194
+ $formsElement->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isFormActivated()));
195
+ $formsElement->setAttribute('position', $quiz->getFormShowPosition());
196
+
197
+ //0.29
198
+ if ($quiz->getAdminEmail() !== null) {
199
+ /* @var $adminEmail WpProQuiz_Model_Email */
200
+ $adminEmail = $quiz->getAdminEmail();
201
+ $adminEmailXml = $dom->createElement('adminEmail');
202
+
203
+ /*
204
+ * $qElement->appendChild($title = $dom->createElement('title'));
205
+ $title->appendChild($dom->createCDATASection($question->getTitle()));
206
+ */
207
+
208
+ $adminEmailXml->appendChild($dom->createElement('to', $adminEmail->getTo()));
209
+ $adminEmailXml->appendChild($dom->createElement('form', $adminEmail->getFrom()));
210
+ $adminEmailXml->appendChild($dom->createElement('subject', $adminEmail->getSubject()));
211
+ $adminEmailXml->appendChild($dom->createElement('html',
212
+ $this->booleanToTrueOrFalse($adminEmail->isHtml())));
213
+ $adminEmailXml->appendChild($message = $dom->createElement('message'));
214
+ $message->appendChild($dom->createCDATASection($adminEmail->getMessage()));
215
+
216
+ $quizElement->appendChild($adminEmailXml);
217
+ }
218
+
219
+ if ($quiz->getUserEmail() !== null) {
220
+ /* @var $adminEmail WpProQuiz_Model_Email */
221
+ $userEmail = $quiz->getUserEmail();
222
+ $userEmaillXml = $dom->createElement('userEmail');
223
+
224
+ $userEmaillXml->appendChild($dom->createElement('to', $userEmail->getTo()));
225
+ $userEmaillXml->appendChild($dom->createElement('toUser',
226
+ $this->booleanToTrueOrFalse($userEmail->isToUser())));
227
+ $userEmaillXml->appendChild($dom->createElement('toForm',
228
+ $this->booleanToTrueOrFalse($userEmail->isToForm())));
229
+ $userEmaillXml->appendChild($dom->createElement('form', $userEmail->getFrom()));
230
+ $userEmaillXml->appendChild($dom->createElement('subject', $userEmail->getSubject()));
231
+ $userEmaillXml->appendChild($dom->createElement('html', $this->booleanToTrueOrFalse($userEmail->isHtml())));
232
+ $userEmaillXml->appendChild($message = $dom->createElement('message'));
233
+ $message->appendChild($dom->createCDATASection($userEmail->getMessage()));
234
+
235
+ $quizElement->appendChild($userEmaillXml);
236
+ }
237
+
238
+ foreach ($forms as $form) {
239
+ /** @var WpProQuiz_Model_Form $form * */
240
+
241
+ $formElement = $dom->createElement('form');
242
+ $formElement->setAttribute('type', $form->getType());
243
+ $formElement->setAttribute('required', $this->booleanToTrueOrFalse($form->isRequired()));
244
+ $formElement->setAttribute('fieldname', $form->getFieldname());
245
+
246
+ if ($form->getData() !== null) {
247
+ $data = $form->getData();
248
+
249
+ foreach ($data as $d) {
250
+ $formDataElement = $dom->createElement('formData', $d);
251
+ $formElement->appendChild($formDataElement);
252
+ }
253
+ }
254
+
255
+ $formsElement->appendChild($formElement);
256
+ }
257
+
258
+ $quizElement->appendChild($formsElement);
259
+
260
+ return $quizElement;
261
+ }
262
+
263
+ /**
264
+ * @param DOMDocument $dom
265
+ * @param WpProQuiz_Model_Question $question
266
+ * @return DOMDocument
267
+ */
268
+ private function createQuestionElement($dom, $question)
269
+ {
270
+ $qElement = $dom->createElement('question');
271
+ $qElement->setAttribute('answerType', $question->getAnswerType());
272
+
273
+ $qElement->appendChild($title = $dom->createElement('title'));
274
+ $title->appendChild($dom->createCDATASection($question->getTitle()));
275
+
276
+ $qElement->appendChild($dom->createElement('points', $question->getPoints()));
277
+
278
+ $qElement->appendChild($questionText = $dom->createElement('questionText'));
279
+ $questionText->appendChild($dom->createCDATASection($question->getQuestion()));
280
+
281
+ $qElement->appendChild($correctMsg = $dom->createElement('correctMsg'));
282
+ $correctMsg->appendChild($dom->createCDATASection($question->getCorrectMsg()));
283
+
284
+ $qElement->appendChild($incorrectMsg = $dom->createElement('incorrectMsg'));
285
+ $incorrectMsg->appendChild($dom->createCDATASection($question->getIncorrectMsg()));
286
+
287
+ $qElement->appendChild($tipMsg = $dom->createElement('tipMsg'));
288
+ $tipMsg->setAttribute('enabled', $this->booleanToTrueOrFalse($question->isTipEnabled()));
289
+ $tipMsg->appendChild($dom->createCDATASection($question->getTipMsg()));
290
+
291
+ $qElement->appendChild($dom->createElement('category', $question->getCategoryName()));
292
+
293
+ $qElement->appendChild($dom->createElement('correctSameText',
294
+ $this->booleanToTrueOrFalse($question->isCorrectSameText())));
295
+ $qElement->appendChild($dom->createElement('showPointsInBox',
296
+ $this->booleanToTrueOrFalse($question->isShowPointsInBox())));
297
+ $qElement->appendChild($dom->createElement('answerPointsActivated',
298
+ $this->booleanToTrueOrFalse($question->isAnswerPointsActivated())));
299
+ $qElement->appendChild($dom->createElement('answerPointsDiffModusActivated',
300
+ $this->booleanToTrueOrFalse($question->isAnswerPointsDiffModusActivated())));
301
+ $qElement->appendChild($dom->createElement('disableCorrect',
302
+ $this->booleanToTrueOrFalse($question->isDisableCorrect())));
303
+
304
+ $answersElement = $dom->createElement('answers');
305
+
306
+ $answerData = $question->getAnswerData();
307
+
308
+ if (is_array($answerData)) {
309
+ foreach ($answerData as $answer) {
310
+ /** @var WpProQuiz_Model_AnswerTypes $answer */
311
+
312
+ $answerElement = $dom->createElement('answer');
313
+ $answerElement->setAttribute('points', $answer->getPoints());
314
+ $answerElement->setAttribute('correct', $this->booleanToTrueOrFalse($answer->isCorrect()));
315
+
316
+ $answerText = $dom->createElement('answerText');
317
+ $answerText->setAttribute('html', $this->booleanToTrueOrFalse($answer->isHtml()));
318
+ $answerText->appendChild($dom->createCDATASection($answer->getAnswer()));
319
+
320
+ $answerElement->appendChild($answerText);
321
+
322
+ $sortText = $dom->createElement('stortText');
323
+ $sortText->setAttribute('html', $this->booleanToTrueOrFalse($answer->isSortStringHtml()));
324
+ $sortText->appendChild($dom->createCDATASection($answer->getSortString()));
325
+
326
+ $answerElement->appendChild($sortText);
327
+
328
+ $answersElement->appendChild($answerElement);
329
+ }
330
+ }
331
+
332
+ $qElement->appendChild($answersElement);
333
+
334
+ return $qElement;
335
+ }
336
+
337
+ private function booleanToTrueOrFalse($v)
338
+ {
339
+ return $v ? 'true' : 'false';
340
+ }
341
  }
lib/helper/WpProQuiz_Helper_Form.php CHANGED
@@ -1,103 +1,117 @@
1
- <?php
2
- class WpProQuiz_Helper_Form {
3
-
4
- /**
5
- *
6
- * @param WpProQuiz_Model_Form $form
7
- * @param mixed $data
8
- *
9
- * @return bool
10
- */
11
- public static function valid($form, $data) {
12
-
13
- if(is_string($data))
14
- $data = trim($data);
15
-
16
- if($form->isRequired() && empty($data))
17
- return false;
18
-
19
- switch ($form->getType()) {
20
- case WpProQuiz_Model_Form::FORM_TYPE_TEXT:
21
- case WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA:
22
- return true;
23
- case WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX:
24
- return empty($data) ? true : $data == '1';
25
- case WpProQuiz_Model_Form::FORM_TYPE_EMAIL:
26
- return empty($data) ? true : filter_var($data, FILTER_VALIDATE_EMAIL) !== false;
27
- case WpProQuiz_Model_Form::FORM_TYPE_NUMBER:
28
- return empty($data) ? true : is_numeric($data);
29
- case WpProQuiz_Model_Form::FORM_TYPE_RADIO:
30
- case WpProQuiz_Model_Form::FORM_TYPE_SELECT:
31
- return empty($data) ? true : in_array($data, $form->getData());
32
- case WpProQuiz_Model_Form::FORM_TYPE_YES_NO:
33
- return empty($data) ? true : ($data == 0 || $data == 1);
34
- case WpProQuiz_Model_Form::FORM_TYPE_DATE:
35
- return true;
36
-
37
- }
38
- }
39
-
40
- /**
41
- *
42
- * @param WpProQuiz_Model_Form $form
43
- * @param array $data
44
- */
45
- public static function validData($form, $data) {
46
- if($form->isRequired() && empty($data))
47
- return null;
48
-
49
- $check = 0;
50
- $format = $data['day'].'-'.$data['month'].'-'.$data['year'];
51
-
52
- if($data['day'] > 0 && $data['day'] <= 31) {
53
- $check++;
54
- }
55
-
56
- if($data['month'] > 0 && $data['month'] <= 12) {
57
- $check++;
58
- }
59
-
60
- if($data['year'] >= 1900 && $data['year'] <= date('Y')) {
61
- $check++;
62
- }
63
-
64
- if($form->isRequired()) {
65
- if($check == 3)
66
- return $format;
67
-
68
- return null;
69
- }
70
-
71
- if($check == 0)
72
- return '';
73
-
74
- if($check == 3)
75
- return $format;
76
-
77
- return null;
78
- }
79
-
80
- public static function formToString(WpProQuiz_Model_Form $form, $str) {
81
- switch ($form->getType()) {
82
- case WpProQuiz_Model_Form::FORM_TYPE_TEXT:
83
- case WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA:
84
- case WpProQuiz_Model_Form::FORM_TYPE_EMAIL:
85
- case WpProQuiz_Model_Form::FORM_TYPE_NUMBER:
86
- case WpProQuiz_Model_Form::FORM_TYPE_RADIO:
87
- case WpProQuiz_Model_Form::FORM_TYPE_SELECT:
88
- return esc_html($str);
89
- break;
90
- case WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX:
91
- return $str == '1' ? __('ticked', 'wp-pro-quiz') : __('not ticked', 'wp-pro-quiz');
92
- break;
93
- case WpProQuiz_Model_Form::FORM_TYPE_YES_NO:
94
- return $str == 1 ? __('Yes') : __('No');
95
- break;
96
- case WpProQuiz_Model_Form::FORM_TYPE_DATE:
97
- return empty($str) ? '' : date_format(date_create($str), get_option('date_format'));
98
- break;
99
- }
100
-
101
- return '';
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
1
+ <?php
2
+
3
+ class WpProQuiz_Helper_Form
4
+ {
5
+
6
+ /**
7
+ *
8
+ * @param WpProQuiz_Model_Form $form
9
+ * @param mixed $data
10
+ *
11
+ * @return bool
12
+ */
13
+ public static function valid($form, $data)
14
+ {
15
+
16
+ if (is_string($data)) {
17
+ $data = trim($data);
18
+ }
19
+
20
+ if ($form->isRequired() && empty($data)) {
21
+ return false;
22
+ }
23
+
24
+ switch ($form->getType()) {
25
+ case WpProQuiz_Model_Form::FORM_TYPE_TEXT:
26
+ case WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA:
27
+ return true;
28
+ case WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX:
29
+ return empty($data) ? true : $data == '1';
30
+ case WpProQuiz_Model_Form::FORM_TYPE_EMAIL:
31
+ return empty($data) ? true : filter_var($data, FILTER_VALIDATE_EMAIL) !== false;
32
+ case WpProQuiz_Model_Form::FORM_TYPE_NUMBER:
33
+ return empty($data) ? true : is_numeric($data);
34
+ case WpProQuiz_Model_Form::FORM_TYPE_RADIO:
35
+ case WpProQuiz_Model_Form::FORM_TYPE_SELECT:
36
+ return empty($data) ? true : in_array($data, $form->getData());
37
+ case WpProQuiz_Model_Form::FORM_TYPE_YES_NO:
38
+ return empty($data) ? true : ($data == 0 || $data == 1);
39
+ case WpProQuiz_Model_Form::FORM_TYPE_DATE:
40
+ return true;
41
+
42
+ }
43
+
44
+ return false;
45
+ }
46
+
47
+ /**
48
+ *
49
+ * @param WpProQuiz_Model_Form $form
50
+ * @param array $data
51
+ * @return null|string
52
+ */
53
+ public static function validData($form, $data)
54
+ {
55
+ if ($form->isRequired() && empty($data)) {
56
+ return null;
57
+ }
58
+
59
+ $check = 0;
60
+ $format = $data['day'] . '-' . $data['month'] . '-' . $data['year'];
61
+
62
+ if ($data['day'] > 0 && $data['day'] <= 31) {
63
+ $check++;
64
+ }
65
+
66
+ if ($data['month'] > 0 && $data['month'] <= 12) {
67
+ $check++;
68
+ }
69
+
70
+ if ($data['year'] >= 1900 && $data['year'] <= date('Y')) {
71
+ $check++;
72
+ }
73
+
74
+ if ($form->isRequired()) {
75
+ if ($check == 3) {
76
+ return $format;
77
+ }
78
+
79
+ return null;
80
+ }
81
+
82
+ if ($check == 0) {
83
+ return '';
84
+ }
85
+
86
+ if ($check == 3) {
87
+ return $format;
88
+ }
89
+
90
+ return null;
91
+ }
92
+
93
+ public static function formToString(WpProQuiz_Model_Form $form, $str)
94
+ {
95
+ switch ($form->getType()) {
96
+ case WpProQuiz_Model_Form::FORM_TYPE_TEXT:
97
+ case WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA:
98
+ case WpProQuiz_Model_Form::FORM_TYPE_EMAIL:
99
+ case WpProQuiz_Model_Form::FORM_TYPE_NUMBER:
100
+ case WpProQuiz_Model_Form::FORM_TYPE_RADIO:
101
+ case WpProQuiz_Model_Form::FORM_TYPE_SELECT:
102
+ return esc_html($str);
103
+ break;
104
+ case WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX:
105
+ return $str == '1' ? __('ticked', 'wp-pro-quiz') : __('not ticked', 'wp-pro-quiz');
106
+ break;
107
+ case WpProQuiz_Model_Form::FORM_TYPE_YES_NO:
108
+ return $str == 1 ? __('Yes') : __('No');
109
+ break;
110
+ case WpProQuiz_Model_Form::FORM_TYPE_DATE:
111
+ return empty($str) ? '' : date_format(date_create($str), get_option('date_format'));
112
+ break;
113
+ }
114
+
115
+ return '';
116
+ }
117
  }
lib/helper/WpProQuiz_Helper_Import.php CHANGED
@@ -1,205 +1,230 @@
1
- <?php
2
- class WpProQuiz_Helper_Import {
3
-
4
- private $_content = null;
5
- private $_error = false;
6
-
7
- public function setImportFileUpload($file) {
8
- if(!is_uploaded_file($file['tmp_name'])) {
9
- $this->setError(__('File was not uploaded', 'wp-pro-quiz'));
10
- return false;
11
- }
12
-
13
- return $this->setImportString(file_get_contents($file['tmp_name']));
14
- }
15
-
16
- public function setImportString($str) {
17
- $this->_content = trim($str);
18
-
19
- return $this->checkCode();
20
- }
21
-
22
- private function setError($str) {
23
- $this->_error = $str;
24
- }
25
-
26
- public function getError() {
27
- return $this->_error;
28
- }
29
-
30
- private function checkCode() {
31
- $code = substr($this->_content, 0, 13);
32
-
33
- $c = substr($code, 0, 3);
34
- $v1 = substr($code, 3, 5);
35
- $v2 = substr($code, 8, 5);
36
-
37
- if($c !== 'WPQ') {
38
- $this->setError(__('File have wrong format', 'wp-pro-quiz'));
39
- return false;
40
- }
41
-
42
- if($v2 < 3) {
43
- $this->setError(__('File is not compatible with the current version'));
44
- return false;
45
- }
46
-
47
- return true;
48
- }
49
-
50
- public function getContent() {
51
- return $this->_content;
52
- }
53
-
54
- public function getImportData() {
55
-
56
- if($this->_content === null) {
57
- $this->setError(__('File cannot be processed', 'wp-pro-quiz'));
58
- return false;
59
- }
60
-
61
- $data = substr($this->_content, 13);
62
-
63
- $b = base64_decode($data);
64
-
65
- if($b === null) {
66
- $this->setError(__('File cannot be processed', 'wp-pro-quiz'));
67
- return false;
68
- }
69
-
70
- $check = $this->saveUnserialize($b, $o);
71
-
72
- if($check === false || !is_array($o)) {
73
- $this->setError(__('File cannot be processed', 'wp-pro-quiz'));
74
- return false;
75
- }
76
-
77
- unset($b);
78
-
79
- return $o;
80
- }
81
-
82
- public function saveImport($ids = false) {
83
- $data = $this->getImportData();
84
-
85
- if($data === false) {
86
- return false;
87
- }
88
-
89
- switch($data['exportVersion']) {
90
- case '3':
91
- case '4':
92
- return $this->importData($data, $ids, $data['exportVersion']);
93
- break;
94
- }
95
-
96
- return false;
97
- }
98
-
99
- private function importData($o, $ids = false, $version = '1') {
100
- $quizMapper = new WpProQuiz_Model_QuizMapper();
101
- $questionMapper = new WpProQuiz_Model_QuestionMapper();
102
- $categoryMapper = new WpProQuiz_Model_CategoryMapper();
103
- $formMapper = new WpProQuiz_Model_FormMapper();
104
-
105
- $categoryArray = $categoryMapper->getCategoryArrayForImport();
106
- $categoryArrayQuiz = $categoryMapper->getCategoryArrayForImport(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ);
107
-
108
- foreach($o['master'] as $master) {
109
- if(get_class($master) !== 'WpProQuiz_Model_Quiz') {
110
- continue;
111
- }
112
-
113
- $oldId = $master->getId();
114
-
115
- if($ids !== false) {
116
- if(!in_array($oldId, $ids)) {
117
- continue;
118
- }
119
- }
120
-
121
- $master->setId(0);
122
-
123
- if($version == 3) {
124
- if($master->isQuestionOnSinglePage()) {
125
- $master->setQuizModus(WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE);