Quiz And Survey Master (Formerly Quiz Master Next) - Version 7.0.0

Version Description

(July 22, 2020) = * Enhancement: Complete UI overhaul QSM admin view including new Dashboard * Enhancement: A new wizard to create quizzes effortlessly * Enhancement: Separate field for question title when you edit questions * Enhancement: Updated UI of several pages in admin panel * Enhancement: Added new template for results page in admin panel * Enhancement: Added background email feature to improve performance while displaying results. * Bug: Fixed issue where recaptcha appears on every page * Bug: Fixed a database error where some users were not able to create a quiz (Error Code: 0001) * Bug: Fixed cross-site scripting vulnerability (discovered by Vishnupriya Ilango of Fortinet's FortiGuard Labs.) * Bug: Fixed issues while duplicating a quiz

Download this release

Release Info

Developer expresstech
Plugin Icon 128x128 Quiz And Survey Master (Formerly Quiz Master Next)
Version 7.0.0
Comparing to
See all releases

Code changes from version 6.4.12 to 7.0.0

Files changed (57) hide show
  1. assets/default_image.png +0 -0
  2. assets/down-1.png +0 -0
  3. assets/right.png +0 -0
  4. assets/sample-quiz.png +0 -0
  5. assets/simple-quiz.png +0 -0
  6. assets/survey-quiz.png +0 -0
  7. assets/time-based-quiz.png +0 -0
  8. assets/up-1.png +0 -0
  9. assets/wrong.png +0 -0
  10. css/admin-dashboard.css +486 -0
  11. css/common.css +9 -0
  12. css/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  13. css/qsm-admin-contact.css +5 -5
  14. css/qsm-admin-question.css +339 -16
  15. css/qsm-admin.css +695 -26
  16. js/admin.js +202 -7
  17. js/qsm-admin-contact.js +8 -0
  18. js/qsm-admin-emails.js +4 -3
  19. js/qsm-admin-question.js +332 -79
  20. js/qsm-admin-results.js +5 -6
  21. js/qsm-admin.js +81 -30
  22. js/qsm-quiz.js +259 -79
  23. mlw_quizmaster2.php +19 -13
  24. php/admin/addons-page.php +10 -19
  25. php/admin/admin-dashboard.php +567 -0
  26. php/admin/admin-results-details-page.php +182 -70
  27. php/admin/admin-results-page.php +39 -33
  28. php/admin/functions.php +473 -1
  29. php/admin/help-page.php +9 -9
  30. php/admin/options-page-contact-tab.php +2 -2
  31. php/admin/options-page-email-tab.php +57 -86
  32. php/admin/options-page-option-tab.php +3 -0
  33. php/admin/options-page-questions-tab.php +419 -127
  34. php/admin/options-page-results-page-tab.php +61 -97
  35. php/admin/options-page-style-tab.php +1 -1
  36. php/admin/options-page-text-tab.php +188 -79
  37. php/admin/quiz-options-page.php +38 -32
  38. php/admin/quizzes-page.php +621 -452
  39. php/admin/settings-page.php +26 -0
  40. php/admin/stats-page.php +20 -6
  41. php/classes/class-qmn-background-process.php +58 -0
  42. php/classes/class-qmn-plugin-helper.php +28 -12
  43. php/classes/class-qmn-quiz-creator.php +17 -11
  44. php/classes/class-qmn-quiz-manager.php +103 -32
  45. php/classes/class-qsm-fields.php +171 -22
  46. php/classes/class-qsm-install.php +335 -225
  47. php/classes/class-qsm-settings.php +2 -1
  48. php/classes/class-qsm-tracking.php +1 -1
  49. php/classes/lib/wp-async-request.php +160 -0
  50. php/classes/lib/wp-background-process.php +503 -0
  51. php/question-types.php +31 -14
  52. php/rest-api.php +35 -13
  53. php/shortcodes.php +5 -2
  54. php/template-variables.php +99 -20
  55. readme.txt +14 -2
  56. templates/qmn_primary.css +25 -0
  57. uninstall.php +2 -0
assets/default_image.png ADDED
Binary file
assets/down-1.png ADDED
Binary file
assets/right.png ADDED
Binary file
assets/sample-quiz.png ADDED
Binary file
assets/simple-quiz.png ADDED
Binary file
assets/survey-quiz.png ADDED
Binary file
assets/time-based-quiz.png ADDED
Binary file
assets/up-1.png ADDED
Binary file
assets/wrong.png ADDED
Binary file
css/admin-dashboard.css ADDED
@@ -0,0 +1,486 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .welcome-panel-column .dashicons {
2
+ /* font-size: 30px; */
3
+ color: #606a73;
4
+ font-size: 23px;
5
+ margin-right: 5px;
6
+ }
7
+ .welcome-panel .qsm-welcome-panel-close{
8
+ position: absolute;
9
+ top: -20px;
10
+ right: 10px;
11
+ padding: 10px 15px 10px 21px;
12
+ font-size: 13px;
13
+ line-height: 1.23076923;
14
+ text-decoration: none;
15
+ }
16
+ .welcome-panel .qsm-welcome-panel-dismiss{
17
+ position: absolute;
18
+ bottom: 10px;
19
+ right: 10px;
20
+ padding: 10px 15px 10px 21px;
21
+ font-size: 13px;
22
+ line-height: 1.23076923;
23
+ text-decoration: none;
24
+ }
25
+ .welcome-panel .qsm-welcome-panel-dismiss:before {
26
+ background: 0 0;
27
+ color: #72777c;
28
+ content: "\f153";
29
+ display: block;
30
+ font: normal 16px/20px dashicons;
31
+ speak: none;
32
+ height: 20px;
33
+ text-align: center;
34
+ width: 20px;
35
+ -webkit-font-smoothing: antialiased;
36
+ -moz-osx-font-smoothing: grayscale;
37
+ position: absolute;
38
+ top: 9px;
39
+ left: 0;
40
+ transition: all .1s ease-in-out;
41
+ }
42
+ .welcome-panel .qsm-welcome-panel-dismiss:hover:before {
43
+ color: #c00;
44
+ }
45
+ .welcome-panel .qsm-welcome-panel-close img{
46
+ width: 100px;
47
+ }
48
+ .welcome-panel .welcome-panel-close:before{
49
+ content: none !important;
50
+ }
51
+ .welcome-panel .current_version{
52
+ color: #344AD4;
53
+ text-align: center;
54
+ font-size: 16px;
55
+ font-weight: bold;
56
+ margin: 0;
57
+ padding: 0;
58
+ position: relative;
59
+ top: -30px;
60
+ }
61
+ .popuar-addon-ul{
62
+ columns: 2;
63
+ -webkit-columns: 2;
64
+ -moz-columns: 2;
65
+ }
66
+ .popuar-addon-ul li img{
67
+ max-width: 100%;
68
+ }
69
+ .pa-all-addon {
70
+ text-align: right;
71
+ margin-bottom: 10px;
72
+ }
73
+ .pa-all-addon a{
74
+ text-decoration: none;
75
+ font-size: 14px;
76
+ font-weight: bold;
77
+ }
78
+ .what-new-ul li {
79
+ margin-bottom: 20px;
80
+ border-bottom: 1px solid #ccbfbf;
81
+ padding-bottom: 20px;
82
+ }
83
+ .what-new-ul li:last-child{
84
+ border-bottom: medium none;
85
+ margin-bottom: 0;
86
+ padding-bottom: 0;
87
+ }
88
+ .what-new-ul li a{
89
+ font-size: 14px;
90
+ color: #222;
91
+ font-weight: 500;
92
+ transition: 0.2 all;
93
+ -webkit-transition: 0.2 all;
94
+ -ms-transition: 0.2 all;
95
+ }
96
+ .what-new-ul li a:hover{
97
+ color: #0073aa;
98
+ }
99
+ .what-new-ul li .post-description{
100
+ margin-top: 10px;
101
+ }
102
+ .what-new-ul li .post-description p{
103
+ margin: 0;
104
+ padding: 0;
105
+ }
106
+ .changelog-ul li{
107
+ border-bottom: 1px solid #ede8e8;
108
+ padding-bottom: 10px;
109
+ margin-bottom: 10px;
110
+ }
111
+ .changelog-ul li:last-child{
112
+ border-bottom: medium none;
113
+ padding-bottom: 0;
114
+ margin-bottom: 0;
115
+ }
116
+ .changelog-ul li span{
117
+ padding: 3px 5px;
118
+ border-radius: 5px;
119
+ display: inline-block;
120
+ color: #fff;
121
+ }
122
+ .changelog-ul li .enhancement{
123
+ background: #FEB325;
124
+ }
125
+ .changelog-ul li .bug{
126
+ background: #FE2525;
127
+ }
128
+ .changelog-ul li .feature{
129
+ background: #25BDFE;
130
+ }
131
+ .recently-taken-quiz-ul li{
132
+ position: relative;
133
+ min-height: 50px;
134
+ margin: 0;
135
+ border-bottom: 1px solid #ede8e8;
136
+ padding: 0 12px 12px 0;
137
+ margin-bottom: 20px;
138
+ }
139
+ .recently-taken-quiz-ul li:last-child{
140
+ margin-bottom: 0;
141
+ border-bottom: medium none;
142
+ padding-bottom: 0;
143
+ }
144
+ .recently-taken-quiz-ul li img.avatar{
145
+ position: absolute;
146
+ top: 0px;
147
+ width: 60px;
148
+ }
149
+ .recently-taken-quiz-ul li .row-actions-c{
150
+ margin: 0;
151
+ padding: 0;
152
+ visibility: hidden;
153
+ }
154
+ .recently-taken-quiz-ul li .row-actions-c .rtq-delete-result{
155
+ color: #a00;
156
+ }
157
+ .recently-taken-quiz-ul li:hover .row-actions-c{
158
+ visibility: visible;
159
+ }
160
+ .recently-taken-quiz-ul li .rtq-main-wrapper{
161
+ padding-left: 75px;
162
+ }
163
+ .recently-taken-quiz-ul li .rtq-main-wrapper .rtq_user_info,
164
+ .recently-taken-quiz-ul li .rtq-main-wrapper .rtq-result-info{
165
+ display: block;
166
+ margin-bottom: 3px;
167
+ }
168
+ .recently-taken-quiz-ul li .rtq-main-wrapper span {
169
+ font-size: 14px;
170
+ color: #837878;
171
+ }
172
+ .recently-taken-quiz-ul li .rtq-main-wrapper .rtq_user_info a:first-child{
173
+ text-transform: capitalize;
174
+ }
175
+
176
+ /**
177
+ * QSM Quiz Wizard
178
+ */
179
+ #model-wizard .qsm-popup__container{
180
+ padding: 0;
181
+ background: #F3F3F3;
182
+ min-width: 70vw;
183
+ max-width: 1040px;
184
+ border-radius: 0;
185
+ max-height: 85vh;
186
+ overflow: hidden;
187
+ position: relative;
188
+ }
189
+ #model-wizard .qsm-popup__content{
190
+ margin: 0;
191
+ max-height: 65vh;
192
+ overflow-y: auto;
193
+ padding-bottom: 59px;
194
+ }
195
+ #model-wizard .qsm-popup__header{
196
+ background: #fff;
197
+ padding: 20px 10px 20px 10px;
198
+ border-bottom: 1px solid #dfd4d4;
199
+ }
200
+ #model-wizard .qsm-popup__title{
201
+ font-size: 24px;
202
+ color: #515559;
203
+ font-weight: normal;
204
+ }
205
+ #model-wizard .qsm-popup__content .qsm-wizard-template-section{
206
+ width: 65%;
207
+ padding: 35px 20px 20px 20px;
208
+ border-right: 1px solid #dfd4d4;
209
+ float: left;
210
+ box-sizing: border-box;
211
+ }
212
+ #model-wizard .qsm-popup__content .quiz_name{
213
+ width: 100%;
214
+ padding: 5px 10px 5px 10px;
215
+ border-radius: 0;
216
+ border: 1px solid #dfd4d4;
217
+ }
218
+ #model-wizard .qsm-popup__content .quiz_name.qsm-required{
219
+ border-color: #ff0000;
220
+ outline: none !important;
221
+ box-shadow: none;
222
+ }
223
+ #model-wizard .qsm-popup__content .template-inner-wrap h6{
224
+ font-size: 15px;
225
+ margin-top: 30px;
226
+ margin-bottom: 10px;
227
+ text-transform: uppercase;
228
+ }
229
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list{
230
+ width: 100%;
231
+ display: inline-block;
232
+ }
233
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner{
234
+ width: 31%;
235
+ margin-right: 2%;
236
+ float: left;
237
+ border: 1px solid #dfd4d4;
238
+ height: 210px;
239
+ text-align: center;
240
+ margin-bottom: 2%;
241
+ position: relative;
242
+ cursor: pointer;
243
+ box-sizing: border-box;
244
+ }
245
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:hover,
246
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner.selected-quiz-template{
247
+ border-color: #1E8CBE;
248
+ -webkit-box-shadow: -2px -1px 13px -1px rgba(30,140,190,1);
249
+ -moz-box-shadow: -2px -1px 13px -1px rgba(30,140,190,1);
250
+ box-shadow: -2px -1px 13px -1px rgba(30,140,190,1);
251
+ transition: 0.2s all;
252
+ -ms-transition: 0.2s all;
253
+ -o-transition: 0.2s all;
254
+ -webkit-transition: 0.2s all;
255
+ }
256
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(3n+3){
257
+ width: 33%;
258
+ margin-right: 0%;
259
+ }
260
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner .template-center-vertical{
261
+ /*position: absolute;
262
+ top: 50%;
263
+ left: 50%;
264
+ -ms-transform: translate(-50%, -50%);
265
+ transform: translate(-50%, -50%); */
266
+ margin-top: 21px;
267
+ height: 96px;
268
+ }
269
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:first-child .template-center-vertical{
270
+ height: auto;
271
+ position: absolute;
272
+ top: 50%;
273
+ left: 50%;
274
+ -ms-transform: translate(-50%, -50%);
275
+ transform: translate(-50%, -50%);
276
+ margin-top: 0;
277
+ }
278
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner .dashicons{
279
+ font-size: 75px;
280
+ color: #9EA3A8;
281
+ display: inline-block;
282
+ height: auto;
283
+ width: auto;
284
+ }
285
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner p.start_scratch{
286
+ font-size: 14px;
287
+ text-transform: uppercase;
288
+ letter-spacing: 1px;
289
+ color: #9EA3A8;
290
+ }
291
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner h3{
292
+ margin: 0;
293
+ padding: 10px;
294
+ border-top: 1px solid #dfd4d4;
295
+ font-size: 15px;
296
+ position: absolute;
297
+ width: 100%;
298
+ box-sizing: border-box;
299
+ bottom: 0;
300
+ }
301
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner.inner-json{
302
+ background: #fff;
303
+ }
304
+ #model-wizard .qsm-popup__footer{
305
+ text-align: right;
306
+ background: #fff;
307
+ padding: 15px;
308
+ border-top: 1px solid #dfd4d4;
309
+ margin-top: -4px;
310
+ position: absolute;
311
+ bottom: 0;
312
+ width: 100%;
313
+ box-sizing: border-box;
314
+ }
315
+ #model-wizard .qsm-popup__close{
316
+ cursor: pointer;
317
+ font-size: 20px;
318
+ color: #515559;
319
+ margin-right: 10px;
320
+ }
321
+ #model-wizard .qsm-wizard-setting-section{
322
+ background: #fff;
323
+ width: 35%;
324
+ float: left;
325
+ }
326
+ #new-quiz-form{
327
+ display: inline-block;
328
+ width: 100%;
329
+ }
330
+ #model-wizard .qsm-wizard-setting-section .ui-accordion .ui-accordion-header{
331
+ background: #fff;
332
+ color: #000;
333
+ border-radius: 0;
334
+ border: none;
335
+ font-size: 16px;
336
+ font-weight: bold;
337
+ padding-left: 20px;
338
+ border-bottom: 1px solid #dfd4d4;
339
+ padding-right: 20px;
340
+ outline: 0 !important;
341
+ }
342
+ #accordion .ui-accordion-header-icon {
343
+ position: absolute;
344
+ right: 24px;
345
+ top: 15px;
346
+ }
347
+ #accordion.ui-accordion .ui-accordion-content{
348
+ border: medium none;
349
+ border-bottom: 1px solid #dfd4d4;
350
+ padding: 20px;
351
+ }
352
+ #accordion .ui-icon.iconOpen {
353
+ background:url('../assets/up-1.png') no-repeat !important;
354
+ background-size: cover !important;
355
+ }
356
+ #accordion .ui-icon.iconClosed {
357
+ background: url(../assets/down-1.png) no-repeat !important;
358
+ background-size: cover !important;
359
+ }
360
+ #accordion ui-accordion-header:focus {
361
+ outline:0 !important;
362
+ border: none !important;
363
+ }
364
+ #quiz_settings_wrapper tr{
365
+ /*display: inline-block;*/
366
+ width: 100%;
367
+ }
368
+ #quiz_settings_wrapper tr th,
369
+ #quiz_settings_wrapper tr td{
370
+ width: 100%;
371
+ display: inline-block;
372
+ box-sizing: border-box;
373
+ clear: both;
374
+ text-align: left;
375
+ }
376
+ #quiz_settings_wrapper tr td{
377
+ padding: 10px 0 20px 0;
378
+ }
379
+ #quiz_settings_wrapper tr:last-child td {
380
+ padding-bottom: 0;
381
+ }
382
+ #quiz_settings_wrapper tr td label{
383
+ margin-right: 15px;
384
+ font-size: 14px;
385
+ }
386
+ #quiz_settings_wrapper tr th label{
387
+ font-size: 14px;
388
+ font-weight: bold;
389
+ }
390
+ #recomm_addons_wrapper ul{
391
+ columns: 2;
392
+ -webkit-columns: 2;
393
+ -moz-columns: 2;
394
+ }
395
+ #recomm_addons_wrapper ul li{
396
+ position: relative;
397
+ }
398
+ #recomm_addons_wrapper ul li span.ra-attr{
399
+ position: absolute;
400
+ right: 0;
401
+ padding: 5px;
402
+ font-size: 10px;
403
+ color: #fff;
404
+ background: gray;
405
+ border-radius: 5px;
406
+ top: 0;
407
+ text-transform: capitalize;
408
+ }
409
+ #recomm_addons_wrapper ul li span.ra-attr.qra-att-recommended{
410
+ background: #25BDFE;
411
+ }
412
+ #recomm_addons_wrapper ul li span.ra-attr.qra-att-required{
413
+ background: #31B400;
414
+ }
415
+ #recomm_addons_wrapper ul li img{
416
+ max-width: 100%;
417
+ }
418
+ #quiz_settings_wrapper .qsm-opt-tr .qsm-tooltips-icon{
419
+ display: none;
420
+ }
421
+ div#quiz_settings_wrapper #timer_limit {
422
+ width: 100px;
423
+ }
424
+ @media screen and (min-width: 1200px){
425
+ #quiz_settings_wrapper tr td fieldset > br{
426
+ display: none;
427
+ }
428
+ }
429
+ @media (min-width: 768px) and (max-width: 1200px){
430
+ #quiz_settings_wrapper tr td label{
431
+ vertical-align: top;
432
+ margin-bottom: 15px;
433
+ display: inline-block;
434
+ }
435
+ #model-wizard .qsm-popup__container{
436
+ width: 90%;
437
+ }
438
+ }
439
+ @media (min-width: 768px) and (max-width: 991px){
440
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner{
441
+ width: 48%;
442
+ }
443
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(2n+2){
444
+ margin-right: 0;
445
+ width: 50%;
446
+ }
447
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(3n+3){
448
+ margin-right: 2%;
449
+ width: 48%;
450
+ }
451
+ }
452
+ @media screen and (max-width: 767px){
453
+ #model-wizard .qsm-popup__container{
454
+ width: 90%;
455
+ }
456
+ #model-wizard .qsm-popup__content .qsm-wizard-template-section{
457
+ width: 100%;
458
+ }
459
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(2n+2),
460
+ #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner{
461
+ width: 100% !important;
462
+ }
463
+ #model-wizard .qsm-wizard-setting-section{
464
+ width: 100%;
465
+ height: auto !important;
466
+ }
467
+ #quiz_settings_wrapper tr td label{
468
+ margin-bottom: 20px;
469
+ display: inline-block;
470
+ vertical-align: top;
471
+ }
472
+ #model-wizard .qsm-popup__title{
473
+ font-size: 16px;
474
+ }
475
+ .welcome-panel h2{
476
+ width: calc(100% - 100px);
477
+ }
478
+ }
479
+ @media only screen and (max-width: 1800px) and (min-width: 1500px){
480
+ #wpbody-content #dashboard-widgets #postbox-container-1 {
481
+ width: 50%;
482
+ }
483
+ #wpbody-content #dashboard-widgets #postbox-container-2 {
484
+ width: 50%;
485
+ }
486
+ }
css/common.css CHANGED
@@ -123,6 +123,15 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover{
123
  }
124
  .qsm-quiz-container .qsm-contact-type-checkbox input{
125
  display: inline-block;
 
 
 
 
 
 
 
 
 
126
  }
127
  .quiz_section iframe{
128
  width: 100% !important;
123
  }
124
  .qsm-quiz-container .qsm-contact-type-checkbox input{
125
  display: inline-block;
126
+ }
127
+ .quiz_section .mlw_qmn_new_question{
128
+ font-weight: bold;
129
+ display: block;
130
+ width: 100%;
131
+ margin-bottom: 10px;
132
+ }
133
+ .quiz_section .mlw_qmn_question.qsm_remove_bold{
134
+ font-weight: normal;
135
  }
136
  .quiz_section iframe{
137
  width: 100% !important;
css/images/ui-bg_inset-hard_100_fcfdfd_1x100.png ADDED
Binary file
css/qsm-admin-contact.css CHANGED
@@ -1,5 +1,5 @@
1
  .contact-form {
2
- background-color: #0d97d8;
3
  box-sizing: border-box;
4
  margin: 20px 0;
5
  overflow: hidden;
@@ -7,13 +7,13 @@
7
 
8
  .contact-form-field {
9
  padding: 25px 10px 10px;
10
- margin: 15px 10px;
11
- background: #fff;
12
- border: 5px solid #1DD969;
13
  }
14
 
15
  .contact-form-field.new {
16
- background: #ffff66;
17
  }
18
 
19
  .contact-form-field.deleting {
1
  .contact-form {
2
+ background-color: #fff;
3
  box-sizing: border-box;
4
  margin: 20px 0;
5
  overflow: hidden;
7
 
8
  .contact-form-field {
9
  padding: 25px 10px 10px;
10
+ margin: 15px 15px;
11
+ background: #f1f1f1;
12
+ border: 1px solid #dfd4d4;
13
  }
14
 
15
  .contact-form-field.new {
16
+ background: #f1f1f1;
17
  }
18
 
19
  .contact-form-field.deleting {
css/qsm-admin-question.css CHANGED
@@ -13,10 +13,14 @@
13
 
14
  .page {
15
  width: 100%;
16
- background-color: #0d97d8;
17
  margin: 20px 0;
18
- padding-bottom: 15px;
19
- box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.4)
 
 
 
 
20
  }
21
 
22
  .page-header {
@@ -24,8 +28,62 @@
24
  align-items: center;
25
  justify-content: space-between;
26
  background-color: #fff;
27
- padding: 10px 35px;
28
- border-bottom: 5px solid #1DD969;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
  .page-header a {
@@ -33,13 +91,13 @@
33
  }
34
 
35
  .page-header-buttons {
36
- text-align: center;
37
  }
38
 
39
  .question, .question-bank-question {
40
- padding: 10px;
41
- background-color: #fff;
42
- border: 5px solid #1DD969;
43
  margin: 15px 10px 0;
44
  }
45
 
@@ -53,6 +111,33 @@
53
  justify-content: space-between;
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  .question-content > div {
57
  margin: 0 10px;
58
  }
@@ -72,18 +157,29 @@
72
  margin: 0 10px;
73
  }
74
 
 
 
 
 
75
  .page-new, .question-new {
76
- background-color: yellow !important;
77
  }
78
 
79
  .correct-header {
80
  text-align: right;
 
81
  }
82
 
83
  .answers-single {
84
  display: flex;
85
  justify-content: space-between;
86
  margin-bottom: 5px;
 
 
 
 
 
 
87
  }
88
 
89
  .answers-single > div {
@@ -91,23 +187,73 @@
91
  }
92
 
93
  .answer-text-div {
94
- width: 100%;
 
 
 
 
95
  }
96
 
97
  .qsm-row {
98
- display: block;
99
  width: 100%;
100
- margin-bottom: 10px;
101
  font-size: 16px;
102
  }
103
 
 
 
 
 
104
  .qsm-row > label {
105
- font-weight: bold;
106
  display: block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
 
109
  .qsm-row select, .qsm-row input[type=text], .qsm-row textarea {
110
  width: 100%;
 
111
  }
112
 
113
  .qsm-popup {
@@ -318,12 +464,12 @@ from { transform: translateY(15%); }
318
  /**
319
  * Css for change-answer-editor-label
320
  */
321
- .change-answer-editor-label{
322
  display: inline-block;
323
  float: right;
324
  font-size: 14px;
325
  font-weight: normal !important;
326
- }
327
  .change-answer-editor-label > #change-answer-editor{
328
  width: auto;
329
  }
@@ -352,6 +498,134 @@ a.import-button.button.disable_import::before {
352
  margin-right: 10px;
353
  }
354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  @media screen and (max-width: 575px){
356
  .qsm-popup__container{
357
  min-width: auto;
@@ -361,4 +635,53 @@ a.import-button.button.disable_import::before {
361
 
362
  .question_info_tag{
363
  float: right;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  }
13
 
14
  .page {
15
  width: 100%;
16
+ background-color: #fff;
17
  margin: 20px 0;
18
+ padding-bottom: 60px;
19
+ /*box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.4)*/
20
+ position: relative;
21
+ padding-left: 15px;
22
+ padding-right: 15px;
23
+ box-sizing: border-box;
24
  }
25
 
26
  .page-header {
28
  align-items: center;
29
  justify-content: space-between;
30
  background-color: #fff;
31
+ padding: 25px 15px 10px 10px;
32
+ /*border-bottom: 5px solid #1DD969;*/
33
+ }
34
+
35
+ .page-header .dashicons{
36
+ color: #A6ABAF;
37
+ font-size: 25px;
38
+ }
39
+
40
+ .page-header .dashicons.dashicons-trash{
41
+ color: #dc3232;
42
+ }
43
+ .page-header .edit-page-button{margin: 0 10px;}
44
+ .page-header .edit-page-button span{color: #1F8CBE;}
45
+ .page-header span.page-number {
46
+ font-size: 18px;
47
+ color: #A6ABAF;
48
+ margin-left: 10px;
49
+ display: inline-block;
50
+ font-style: italic;
51
+ margin-top: 3px;
52
+ }
53
+ .page-header span.page-name {
54
+
55
+ }
56
+
57
+ .page-footer{
58
+ position: absolute;
59
+ bottom: 15px;
60
+ width: 100%;
61
+ right: 25px;
62
+ }
63
+
64
+ .page-footer a.button,
65
+ .new-answer-button a#new-answer-button{
66
+ border: 1px solid #cbcbcb;
67
+ color: #7b7575;
68
+ background: #F7F7F7;
69
+ }
70
+
71
+ .new-answer-button a#new-answer-button:hover{
72
+ opacity: 0.9;
73
+ }
74
+
75
+ .page-footer a.button .dashicons,
76
+ .new-answer-button a#new-answer-button .dashicons{
77
+ line-height: 32px;
78
+ }
79
+
80
+ .question-create-page{
81
+ text-align: center;
82
+ }
83
+
84
+ .question-create-page .new-page-button .dashicons{
85
+ line-height: 30px;
86
+ font-size: 16px;
87
  }
88
 
89
  .page-header a {
91
  }
92
 
93
  .page-header-buttons {
94
+ text-align: right;
95
  }
96
 
97
  .question, .question-bank-question {
98
+ padding: 15px 10px;
99
+ background-color: #F3F3F3;
100
+ border: 1px solid #cbcbcb;
101
  margin: 15px 10px 0;
102
  }
103
 
111
  justify-content: space-between;
112
  }
113
 
114
+ .question-content .dashicons{
115
+ font-size: 22px;
116
+ color: #1F8CBE;
117
+ }
118
+
119
+ .question-content .dashicons.dashicons-trash{
120
+ color: #dc3232;
121
+ }
122
+
123
+ .question-content .dashicons.dashicons-move{
124
+ color: #A6ABAF;
125
+ font-size: 22px;
126
+ }
127
+
128
+ .question-content .question-content-text{
129
+ color: #1F8CBE;
130
+ font-size: 16px;
131
+ font-weight: 500;
132
+ }
133
+
134
+ .question-content .question-category{
135
+ color: #939697;
136
+ font-size: 14px;
137
+ font-weight: normal;
138
+ font-style: italic;
139
+ }
140
+
141
  .question-content > div {
142
  margin: 0 10px;
143
  }
157
  margin: 0 10px;
158
  }
159
 
160
+ .question-bank-question > div:nth-child(2){
161
+ width: 100%;
162
+ }
163
+
164
  .page-new, .question-new {
165
+ background-color: #fff !important;
166
  }
167
 
168
  .correct-header {
169
  text-align: right;
170
+ display: none;
171
  }
172
 
173
  .answers-single {
174
  display: flex;
175
  justify-content: space-between;
176
  margin-bottom: 5px;
177
+ padding: 10px 10px;
178
+ background: #FAFAFA;
179
+ }
180
+
181
+ .answers-single:nth-child(2n+2){
182
+ background: #FFF;
183
  }
184
 
185
  .answers-single > div {
187
  }
188
 
189
  .answer-text-div {
190
+ width: 85%;
191
+ }
192
+
193
+ .answers-single > div:nth-child(4){
194
+ width: 12%;
195
  }
196
 
197
  .qsm-row {
198
+ display: inline-block;
199
  width: 100%;
200
+ margin-bottom: 13px;
201
  font-size: 16px;
202
  }
203
 
204
+ #post-body-content .qsm-row{
205
+ margin-bottom: 20px;
206
+ }
207
+
208
  .qsm-row > label {
209
+ font-weight: normal;
210
  display: block;
211
+ margin-bottom: 7px;
212
+ color: #7b7575;
213
+ }
214
+
215
+ .questionElements .qsm-row > label {
216
+ position: relative;
217
+ }
218
+
219
+ .questionElements .qsm-row > label > .qsm-tooltips-icon {
220
+ position: relative;
221
+ top: 2px;
222
+ }
223
+
224
+ .questionElements .qsm-question-doc{
225
+ text-decoration: none;
226
+ position: absolute;
227
+ right: 0;
228
+ color: #969696;
229
+ }
230
+
231
+ #categorydiv .qsm-question-doc{
232
+ right: 15px;
233
+ }
234
+
235
+ .questionElements .qsm-question-doc:hover{
236
+ color: #0073aa;
237
+ }
238
+
239
+ .questionElements .qsm-row > label > .qsm-question-doc span.dashicons{
240
+ font-size: 17px;
241
+ width: auto;
242
+ height: auto;
243
+ line-height: 23px;
244
+ }
245
+
246
+ .questionElements .qsm-tooltips-icon .qsm-tooltips{
247
+ bottom: 26px;
248
+ }
249
+
250
+ .questionElements .qsm-tooltips-icon{
251
+ cursor: help;
252
  }
253
 
254
  .qsm-row select, .qsm-row input[type=text], .qsm-row textarea {
255
  width: 100%;
256
+ max-width: 100%;
257
  }
258
 
259
  .qsm-popup {
464
  /**
465
  * Css for change-answer-editor-label
466
  */
467
+ /*.change-answer-editor-label{
468
  display: inline-block;
469
  float: right;
470
  font-size: 14px;
471
  font-weight: normal !important;
472
+ }*/
473
  .change-answer-editor-label > #change-answer-editor{
474
  width: auto;
475
  }
498
  margin-right: 10px;
499
  }
500
 
501
+ .ui-state-highlight {
502
+ background: #F3F3F3;
503
+ border: 1px dashed #cbcbcb;
504
+ height: 50px;
505
+ margin: 15px 10px 0;
506
+ opacity: 0.8;
507
+ }
508
+
509
+ .questionElements #poststuff{
510
+ display: inline-block;
511
+ width: 100%;
512
+ background: #fff;
513
+ padding: 10px;
514
+ box-sizing: border-box;
515
+ padding-bottom: 0;
516
+ }
517
+
518
+ .questionElements{
519
+ padding: 15px 10px;
520
+ background-color: #fff;
521
+ border: 1px solid #cbcbcb;
522
+ margin: 0 10px 0;
523
+ box-sizing: border-box;
524
+ border-top: medium none;
525
+ }
526
+
527
+ .questionElements .question-title{
528
+ padding: 3px 8px;
529
+ font-size: 1.7em;
530
+ line-height: 100%;
531
+ /* height: 1.7em; */
532
+ width: 100%;
533
+ outline: 0;
534
+ margin: 0 0 3px;
535
+ background-color: #fff;
536
+ }
537
+
538
+ .questionElements #major-publishing-actions{
539
+ display: inline-block;
540
+ width: 100%;
541
+ box-sizing: border-box;
542
+ clear: both;
543
+ margin-bottom: -3px;
544
+ }
545
+
546
+ .questionElements #minor-publishing{
547
+ padding: 10px 12px 12px;
548
+ }
549
+
550
+ #advanceddiv input[type="number"]{
551
+ width: 100% !important;
552
+ }
553
+
554
+ .qsm-row .answer-header{
555
+ font-weight: 500;
556
+ font-size: 20px;
557
+ margin-bottom: 30px;
558
+ margin-top: 15px;
559
+ color: #23282d;
560
+ }
561
+ .qsm-row .new-answer-button{
562
+ text-align: center;
563
+ margin-top: 15px;
564
+ }
565
+
566
+ #advanceddiv{
567
+ margin-bottom: 0;
568
+ }
569
+
570
+ #answers .delete-answer-button{
571
+ text-decoration: none;
572
+ color: #dc3232;
573
+ vertical-align: middle;
574
+ }
575
+
576
+ .answers-single .correct-answer{
577
+ margin-right: 0;
578
+ vertical-align: -webkit-baseline-middle;
579
+ }
580
+
581
+ .questionElements #postbox-container-1 select{
582
+ border: 1px solid #dddddd;
583
+ }
584
+
585
+ .question-content-text * {
586
+ font-size: 16px;
587
+ }
588
+
589
+ .question-type-description{
590
+ color: #31708f;
591
+ background: #d9edf7;
592
+ border-color: #bce8f1;
593
+ padding: 30px 15px;
594
+ border-radius: 4px;
595
+ font-family: Verdana, sans-serif;
596
+ font-size: 15px;
597
+ line-height: 21px;
598
+ text-align: center;
599
+ margin: 0;
600
+ }
601
+
602
+ #delete-action .deletion{
603
+ text-decoration: underline;
604
+ }
605
+
606
+ #category_area > label{
607
+ display: none;
608
+ }
609
+
610
+ #category_area{
611
+ margin-top: 10px;
612
+ }
613
+
614
+ a#qsm-category-add-toggle {
615
+ margin-top: 10px;
616
+ display: block;
617
+ text-decoration: underline;
618
+ cursor: pointer;
619
+ }
620
+
621
+ .quiz_form_type_0.quiz_quiz_systen_3 #question_type_13_description,
622
+ .quiz_form_type_0.quiz_quiz_systen_1 #question_type_13_description{
623
+ display: none !important;
624
+ }
625
+
626
+ #qsm-question-id{
627
+ float: right;
628
+ }
629
  @media screen and (max-width: 575px){
630
  .qsm-popup__container{
631
  min-width: auto;
635
 
636
  .question_info_tag{
637
  float: right;
638
+ }
639
+ @media (min-width: 783px) and (max-width: 1199px){
640
+ #poststuff #post-body.columns-2 #side-sortables{
641
+ min-width: unset;
642
+ width: 100%;
643
+ }
644
+ .questionElements .postbox{
645
+ min-width: unset;
646
+ width: 100%;
647
+ }
648
+ #post-body.columns-2 #postbox-container-1{
649
+ width: 250px;
650
+ float: left;
651
+ margin-left: 10px;
652
+ }
653
+ .questionElements{
654
+ overflow: hidden;
655
+ }
656
+ }
657
+ @media screen and (max-width: 782px){
658
+ /*List of questions*/
659
+ .question-content .question-content-text{
660
+ font-size: 14px;
661
+ }
662
+ body .question-content > div{
663
+ margin: 0 5px;
664
+ }
665
+ .page-footer a.button{
666
+ font-size: 10px;
667
+ min-height: 25px;
668
+ padding: 0 5px;
669
+ }
670
+ .page-footer a.button .dashicons{
671
+ display: none;
672
+ }
673
+ .question-controls .search-box{
674
+ height: auto;
675
+ }
676
+ .questionElements .postbox{
677
+ max-width: 100%;
678
+ width: 100%;
679
+ min-width: unset;
680
+ }
681
+ .questionElements .category{
682
+ margin-bottom: 10px;
683
+ }
684
+ .answer-text-div{
685
+ width: 135%;
686
+ }
687
  }
css/qsm-admin.css CHANGED
@@ -6,6 +6,63 @@ Quizzes/Surveys Page
6
  font-size: 16px !important;
7
  }*/
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  span.qsm-quiz-name {
10
  font-size: 14px;
11
  font-weight: 600;
@@ -26,12 +83,15 @@ span.qsm-quiz-name {
26
  }
27
 
28
  .qsm-news-ads {
29
- background-color: #0d97d8;
 
 
 
30
  }
31
 
32
  .qsm-news-ads-title {
33
  text-align: center;
34
- border-bottom: 5px solid #1DD969;
35
  margin: 0;
36
  padding: 10px 0;
37
  background-color: #fff;
@@ -61,7 +121,7 @@ span.qsm-quiz-name {
61
  }
62
 
63
  .qsm-quiz-page-addon{
64
- width: 83%;
65
  float: left;
66
  }
67
 
@@ -71,16 +131,22 @@ span.qsm-quiz-name {
71
  }
72
 
73
  @media screen and (min-width: 1200px) {
74
- .qsm-quizzes-page-content {
75
- flex-direction: row;
76
- }
77
-
78
  .qsm-quiz-page-wrapper-with-ads {
79
- margin-right: 10px;
 
80
  }
81
-
82
- .qsm-news-ads {
83
- flex-basis: 15%;
 
 
 
 
 
 
 
 
84
  }
85
  }
86
 
@@ -117,10 +183,19 @@ Results Pages & Emails Tab
117
  .results-page,
118
  .email {
119
  width: 100%;
120
- background-color: #0d97d8;
121
  margin: 20px 0;
122
- padding-bottom: 15px;
123
- box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.4)
 
 
 
 
 
 
 
 
 
124
  }
125
 
126
  .results-page-header,
@@ -130,14 +205,14 @@ Results Pages & Emails Tab
130
  justify-content: flex-end;
131
  background-color: #fff;
132
  padding: 10px 35px;
133
- border-bottom: 5px solid #1DD969;
134
  }
135
 
136
  .delete-page-button,
137
  .delete-email-button {
138
  background: none;
139
  border: none;
140
- color: #1DD969;
141
  cursor: pointer;
142
  transition-duration: 200ms;
143
  }
@@ -158,12 +233,17 @@ Results Pages & Emails Tab
158
  .email-when,
159
  .email-show {
160
  padding: 10px;
161
- background-color: #fff;
162
- border: 5px solid #1DD969;
163
  margin: 15px 0;
164
  min-width: 60%;
165
  }
166
 
 
 
 
 
 
167
  .results-page-content-header,
168
  .email-content-header {
169
  margin-bottom: 10px;
@@ -227,7 +307,8 @@ Results Pages & Emails Tab
227
  .results-page-show,
228
  .email-when,
229
  .email-show {
230
- min-width: 35%;
 
231
  }
232
 
233
  .results-page-condition,
@@ -448,14 +529,70 @@ Misc.
448
  }
449
 
450
  /* Info Widget */
 
 
 
 
 
451
  .qsm-info-widget {
452
  text-align: center;
453
- border: 5px solid #1DD969;
454
- margin: 10px 5px;
455
- background: #fff;
456
- padding: 10px 5px;
457
  transition-duration: 0.5s;
458
  max-width: 330px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  }
460
 
461
  .qsm-info-widget:hover {
@@ -468,8 +605,12 @@ Misc.
468
  padding: 10px 10px 10px 10px;
469
  }
470
 
 
 
 
 
471
  .qsm_tab_content label{
472
- margin-right: 20px;
473
  }
474
 
475
  /* Popup */
@@ -631,6 +772,9 @@ body .qsm-popup__btn-primary {
631
  font-size: 14px !important;
632
  margin-bottom: 10px;
633
  cursor: pointer;
 
 
 
634
  }
635
  .sc-opener span.dashicons{
636
  position: relative;
@@ -655,6 +799,11 @@ body .qsm-popup__btn-primary {
655
 
656
  .remove-ads-adv-link{
657
  text-align: center;
 
 
 
 
 
658
  }
659
 
660
  .remove-ads-adv-link a{
@@ -685,8 +834,10 @@ body .qsm-popup__btn-primary {
685
 
686
  h3.addon_category_name {
687
  width: 100%;
688
- background: #d7d1d1;
689
- padding: 15px;
 
 
690
  }
691
  /*Design of new radio taggle*/
692
  .buttonset.ui-buttonset .ui-button.ui-state-active {
@@ -810,10 +961,509 @@ input:checked + .slider:before {
810
  .slider.round:before {
811
  border-radius: 50%;
812
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  @media screen and (max-width: 767px){
814
  .qsm-quiz-row td:nth-of-type(2n){
815
  display: none;
816
  }
 
 
 
 
817
  .qsm-quiz-page-wrapper thead th:nth-of-type(2n),
818
  .qsm-quiz-page-wrapper tfoot th:nth-of-type(2n),
819
  .qsm-quiz-page-wrapper-with-ads thead th:nth-of-type(2n),
@@ -859,4 +1509,23 @@ input:checked + .slider:before {
859
  padding-left: 15px;
860
  padding-bottom: 15px;
861
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  }
6
  font-size: 16px !important;
7
  }*/
8
 
9
+
10
+ @-moz-keyframes qsm-spinner-loader {
11
+ 0% {
12
+ -moz-transform: rotate(0deg);
13
+ transform: rotate(0deg);
14
+ }
15
+ 100% {
16
+ -moz-transform: rotate(360deg);
17
+ transform: rotate(360deg);
18
+ }
19
+ }
20
+ @-webkit-keyframes qsm-spinner-loader {
21
+ 0% {
22
+ -webkit-transform: rotate(0deg);
23
+ transform: rotate(0deg);
24
+ }
25
+ 100% {
26
+ -webkit-transform: rotate(360deg);
27
+ transform: rotate(360deg);
28
+ }
29
+ }
30
+
31
+ @keyframes qsm-spinner-loader {
32
+ 0% {
33
+ -moz-transform: rotate(0deg);
34
+ -ms-transform: rotate(0deg);
35
+ -webkit-transform: rotate(0deg);
36
+ transform: rotate(0deg);
37
+ }
38
+ 100% {
39
+ -moz-transform: rotate(360deg);
40
+ -ms-transform: rotate(360deg);
41
+ -webkit-transform: rotate(360deg);
42
+ transform: rotate(360deg);
43
+ }
44
+ }
45
+
46
+ /* :not(:required) hides this rule from IE9 and below */
47
+ .qsm-spinner-loader:not(:required) {
48
+ -moz-animation: qsm-spinner-loader 1500ms infinite linear;
49
+ -webkit-animation: qsm-spinner-loader 1500ms infinite linear;
50
+ animation: qsm-spinner-loader 1500ms infinite linear;
51
+ -moz-border-radius: 0.5em;
52
+ -webkit-border-radius: 0.5em;
53
+ border-radius: 0.5em;
54
+ -moz-box-shadow: rgba(0, 0, 51, 0.3) 1.5em 0 0 0, rgba(0, 0, 51, 0.3) 1.1em 1.1em 0 0, rgba(0, 0, 51, 0.3) 0 1.5em 0 0, rgba(0, 0, 51, 0.3) -1.1em 1.1em 0 0, rgba(0, 0, 51, 0.3) -1.5em 0 0 0, rgba(0, 0, 51, 0.3) -1.1em -1.1em 0 0, rgba(0, 0, 51, 0.3) 0 -1.5em 0 0, rgba(0, 0, 51, 0.3) 1.1em -1.1em 0 0;
55
+ -webkit-box-shadow: rgba(0, 0, 51, 0.3) 1.5em 0 0 0, rgba(0, 0, 51, 0.3) 1.1em 1.1em 0 0, rgba(0, 0, 51, 0.3) 0 1.5em 0 0, rgba(0, 0, 51, 0.3) -1.1em 1.1em 0 0, rgba(0, 0, 51, 0.3) -1.5em 0 0 0, rgba(0, 0, 51, 0.3) -1.1em -1.1em 0 0, rgba(0, 0, 51, 0.3) 0 -1.5em 0 0, rgba(0, 0, 51, 0.3) 1.1em -1.1em 0 0;
56
+ box-shadow: rgba(0, 0, 51, 0.3) 1.5em 0 0 0, rgba(0, 0, 51, 0.3) 1.1em 1.1em 0 0, rgba(0, 0, 51, 0.3) 0 1.5em 0 0, rgba(0, 0, 51, 0.3) -1.1em 1.1em 0 0, rgba(0, 0, 51, 0.3) -1.5em 0 0 0, rgba(0, 0, 51, 0.3) -1.1em -1.1em 0 0, rgba(0, 0, 51, 0.3) 0 -1.5em 0 0, rgba(0, 0, 51, 0.3) 1.1em -1.1em 0 0;
57
+ display: inline-block;
58
+ font-size: 10px;
59
+ width: 1em;
60
+ height: 1em;
61
+ margin: 1.5em;
62
+ overflow: hidden;
63
+ text-indent: 100%;
64
+ }
65
+
66
  span.qsm-quiz-name {
67
  font-size: 14px;
68
  font-weight: 600;
83
  }
84
 
85
  .qsm-news-ads {
86
+ background-color: #fff;
87
+ border: 1px solid #dfd4d4;
88
+ margin-top: 30px;
89
+ display: none;
90
  }
91
 
92
  .qsm-news-ads-title {
93
  text-align: center;
94
+ border-bottom: 1px solid #dfd4d4;
95
  margin: 0;
96
  padding: 10px 0;
97
  background-color: #fff;
121
  }
122
 
123
  .qsm-quiz-page-addon{
124
+ width: 100%;
125
  float: left;
126
  }
127
 
131
  }
132
 
133
  @media screen and (min-width: 1200px) {
134
+
 
 
 
135
  .qsm-quiz-page-wrapper-with-ads {
136
+ margin-right: 0;
137
+ width: 100%;
138
  }
139
+ .qsm-news-ads .qsm-info-widget{
140
+ float: left;
141
+ max-width: unset;
142
+ width: 31.3%;
143
+ }
144
+ .qsm-news-ads .qsm-info-widget:nth-child(3n+5){
145
+ clear: both;
146
+ }
147
+ .qsm-news-ads .remove-ads-adv-link{
148
+ width: 100%;
149
+ float: left;
150
  }
151
  }
152
 
183
  .results-page,
184
  .email {
185
  width: 100%;
186
+ background-color: #fff;
187
  margin: 20px 0;
188
+ /*padding-bottom: 15px;*/
189
+ box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.06);
190
+ }
191
+
192
+ .results-page .results-page-content,
193
+ .email .email-content{
194
+ background: #fff;
195
+ padding-right: 15px;
196
+ padding-left: 15px;
197
+ width: 100%;
198
+ box-sizing: border-box;
199
  }
200
 
201
  .results-page-header,
205
  justify-content: flex-end;
206
  background-color: #fff;
207
  padding: 10px 35px;
208
+ border-bottom: 1px solid #dfd4d4;
209
  }
210
 
211
  .delete-page-button,
212
  .delete-email-button {
213
  background: none;
214
  border: none;
215
+ color: #dc3232;
216
  cursor: pointer;
217
  transition-duration: 200ms;
218
  }
233
  .email-when,
234
  .email-show {
235
  padding: 10px;
236
+ background-color: #f1f1f1;
237
+ border: 1px solid #dfd4d4;
238
  margin: 15px 0;
239
  min-width: 60%;
240
  }
241
 
242
+ .results-page-when,
243
+ .email-when{
244
+ margin-right: 15px;
245
+ }
246
+
247
  .results-page-content-header,
248
  .email-content-header {
249
  margin-bottom: 10px;
307
  .results-page-show,
308
  .email-when,
309
  .email-show {
310
+ width: calc( 50% - 15px );
311
+ min-width: unset;
312
  }
313
 
314
  .results-page-condition,
529
  }
530
 
531
  /* Info Widget */
532
+ .qsm-quiz-page-addon .qsm-info-widget {
533
+ margin-top: 0;
534
+ background: #fff;
535
+ margin-left: 0;
536
+ }
537
  .qsm-info-widget {
538
  text-align: center;
539
+ border: 1px solid #dfd4d4;
540
+ margin: 30px 1% 0 1%;
541
+ background: #f1f1f1;
542
+ padding: 10px 15px;
543
  transition-duration: 0.5s;
544
  max-width: 330px;
545
+ box-sizing: border-box;
546
+ }
547
+
548
+ .admin_page_mlw_quiz_options .qsm-info-widget {
549
+ background: #fff;
550
+ margin: 0 0 20px 0;
551
+ cursor: pointer;
552
+ }
553
+
554
+ .admin_page_mlw_quiz_options .qsm-info-widget:hover,
555
+ .admin_page_mlw_quiz_options div.mlw_qmn_themeBlockActive.qsm-info-widget{
556
+ background-color: #333;
557
+ color: #fff;
558
+ }
559
+
560
+ #mlw_qmn_theme_block_primary{
561
+ background-color: #3498db;
562
+ color: #fff;
563
+ }
564
+
565
+ #mlw_qmn_theme_block_amethyst{
566
+ background-color: #9b59b6;
567
+ color: #fff;
568
+ }
569
+
570
+ #mlw_qmn_theme_block_emerald{
571
+ background-color: #2ecc71;
572
+ color: #fff;
573
+ }
574
+
575
+ #mlw_qmn_theme_block_turquoise{
576
+ background-color: #1abc9c;
577
+ color: #fff;
578
+ }
579
+
580
+ #mlw_qmn_theme_block_gray{
581
+ background-color: #ccc;
582
+ color: #fff;
583
+ }
584
+
585
+ .mlw_qmn_themeBlockActive.qsm-info-widget{
586
+ transform: scale(1.1);
587
+ border: 2px solid #d5a8a8;
588
+ }
589
+
590
+ .qsm-info-widget a.button-primary {
591
+ margin-top: 15px;
592
+ }
593
+
594
+ .qsm-quiz-page-addon a.button-primary {
595
+ margin-top: 0 !important;
596
  }
597
 
598
  .qsm-info-widget:hover {
605
  padding: 10px 10px 10px 10px;
606
  }
607
 
608
+ .admin_page_mlw_quiz_options .qsm_tab_content > form > .button-primary:nth-child(3) {
609
+ display: none;
610
+ }
611
+
612
  .qsm_tab_content label{
613
+ margin-right: 5px;
614
  }
615
 
616
  /* Popup */
772
  font-size: 14px !important;
773
  margin-bottom: 10px;
774
  cursor: pointer;
775
+ display: inline-block;
776
+ color: #0073aa !important;
777
+ font-weight: 500;
778
  }
779
  .sc-opener span.dashicons{
780
  position: relative;
799
 
800
  .remove-ads-adv-link{
801
  text-align: center;
802
+ margin-top: 30px;
803
+ }
804
+
805
+ .qsm-info-widget h3{
806
+ line-height: 132%;
807
  }
808
 
809
  .remove-ads-adv-link a{
834
 
835
  h3.addon_category_name {
836
  width: 100%;
837
+ background: transparent;
838
+ padding: 15px 0;
839
+ border-bottom: 1px solid #d7d1d1;
840
+ margin-bottom: 30px;
841
  }
842
  /*Design of new radio taggle*/
843
  .buttonset.ui-buttonset .ui-button.ui-state-active {
961
  .slider.round:before {
962
  border-radius: 50%;
963
  }
964
+
965
+ input#sc-shortcode-model-text,
966
+ input#sc-shortcode-model-text-link {
967
+ height: 30px;
968
+ }
969
+ div#modal-6 lable {
970
+ display: block;
971
+ font-size: 14px;
972
+ margin-bottom: 5px;
973
+ font-weight: 500;
974
+ color: #999;
975
+ font-style: italic;
976
+ }
977
+ #modal-6 .button > span.dashicons {
978
+ line-height: 29px;
979
+ }
980
+ .qsm-list-shortcode-view span.dashicons{
981
+ font-size: 24px;
982
+ }
983
+ /**
984
+ * No quiz screen design
985
+ */
986
+ .qsm-no-quiz-wrapper {
987
+ text-align: center;
988
+ max-width: 100%;
989
+ width: 100%;
990
+ }
991
+ .qsm-no-quiz-wrapper .dashicons.dashicons-format-chat{
992
+ font-size: 200px;
993
+ display: block;
994
+ /* line-height: 200px; */
995
+ width: auto;
996
+ height: auto;
997
+ }
998
+ .qsm-no-quiz-wrapper h2{
999
+ margin-bottom: 30px;
1000
+ }
1001
+ .qsm-no-quiz-wrapper .buttons{
1002
+ margin-bottom: 30px;
1003
+ }
1004
+ .qsm-no-quiz-wrapper .buttons a{
1005
+ margin-right: 20px;
1006
+ }
1007
+ .qsm-no-quiz-wrapper .buttons a:last-child{
1008
+ color: #8b8888
1009
+ }
1010
+ .qsm-no-quiz-wrapper .buttons a:last-child .dashicons{
1011
+ line-height: 46px;
1012
+ }
1013
+ .qsm-no-quiz-wrapper h3{
1014
+ color: #8b8888;
1015
+ margin-bottom: 30px;
1016
+ }
1017
+ /**
1018
+ * Option page design
1019
+ */
1020
+ span.qsm-ph_text {
1021
+ width: 100px;
1022
+ display: inline-block;
1023
+ }
1024
+ tr .qsm-opt-desc{
1025
+ color: #666;
1026
+ font-style: italic;
1027
+ font-size: 14px;
1028
+ margin-top: 5px;
1029
+ display: block;
1030
+ }
1031
+ #quiz_settings_wrapper .qsm-opt-desc{
1032
+ display: none !important;
1033
+ }
1034
+ .form-table td fieldset label {
1035
+ margin-right: 20px !important;
1036
+ }
1037
+ .form-table .qsm-opt-tr{
1038
+ position: relative;
1039
+ padding-right: 24px;
1040
+ padding-top: 15px;
1041
+ }
1042
+ td.scheduled_time_start {
1043
+ padding-bottom: 0 !important;
1044
+ }
1045
+ .qsm-opt-tr .qsm-tooltips-icon{
1046
+ margin: 0 0 0 0;
1047
+ position: relative;
1048
+ right: 0;
1049
+ top: 4px;
1050
+ color: #666;
1051
+ display: inline-block;
1052
+ font-size: 1.2em;
1053
+ font-style: normal;
1054
+ cursor: help;
1055
+ width: auto;
1056
+ height: auto;
1057
+ }
1058
+ .qsm-tooltips-icon .qsm-tooltips {
1059
+ background-color: #333;
1060
+ border-radius: 3px;
1061
+ color: #ffffff;
1062
+ display: none;
1063
+ font-size: 12px;
1064
+ padding: 10px 5px;
1065
+ line-height: 1.5;
1066
+ opacity: 0;
1067
+ left: 50%;
1068
+ position: absolute;
1069
+ text-align: center;
1070
+ bottom: 25px;
1071
+ width: 200px;
1072
+ transform: translateX(-50%);
1073
+ transition: opacity 0.5s ease 0s;
1074
+ font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
1075
+ }
1076
+ .qsm-tooltips-icon .qsm-tooltips a{
1077
+ color: #fff;
1078
+ }
1079
+ .qsm-tooltips-icon .qsm-tooltips:before {
1080
+ border-color: #333 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
1081
+ border-style: solid;
1082
+ border-width: 8px 7px 0;
1083
+ bottom: -8px;
1084
+ content: "";
1085
+ left: 50%;
1086
+ transform: translateX(-50%);
1087
+ position: absolute;
1088
+ }
1089
+ .qsm-tooltips-icon:hover .qsm-tooltips,
1090
+ .qsm-tooltips:hover{
1091
+ display: block;
1092
+ opacity: 1;
1093
+ z-index: 9999;
1094
+ }
1095
+ /**
1096
+ * Text Tab design
1097
+ */
1098
+ .qsm-text-main-wrap{
1099
+ display: inline-block;
1100
+ width: 100%;
1101
+ }
1102
+ .qsm-text-main-wrap #post-body-content{
1103
+ background: #fff;
1104
+ box-sizing: border-box;
1105
+ }
1106
+ .qsm-text-main-wrap #postbox-container-1{
1107
+ position: relative;
1108
+ background: #fff;
1109
+ box-sizing: border-box;
1110
+ }
1111
+ .qsm-text-main-wrap #postbox-container-1 .qsm-text-header h5{
1112
+ font-size: 14px;
1113
+ margin: 0;
1114
+ font-weight: bold;
1115
+ }
1116
+ .qsm-text-main-wrap #postbox-container-1 .qsm-text-header .description{
1117
+ color: #666;
1118
+ }
1119
+ .qsm-text-main-wrap .qsm-text-header{
1120
+ padding: 20px;
1121
+ border-bottom: 1px solid #f1f1f1;
1122
+ }
1123
+ .qsm-text-main-wrap .qsm-text-header .message-dropdown{
1124
+ display: inline-block;
1125
+ }
1126
+ .qsm-text-main-wrap .qsm-text-header .message-dropdown label{
1127
+ font-size: 14px;
1128
+ font-weight: bold;
1129
+ }
1130
+ .qsm-text-main-wrap .qsm-text-header .save-text-changes{
1131
+ float: right;
1132
+ }
1133
+ .qsm-text-main-wrap .qsm-text-conent{
1134
+ padding: 20px;
1135
+ border-bottom: 1px solid #f1f1f1;
1136
+ position: relative;
1137
+ }
1138
+ .qsm-text-conent.qsm-text-allowed-variables span.qsm-text-template-span{
1139
+ display: inline-block;
1140
+ margin-bottom: 10px;
1141
+ margin-right: 10px;
1142
+ position: relative;
1143
+ }
1144
+ #show-all-variable-content span.qsm-text-template-span {
1145
+ display: inline-block;
1146
+ position: relative;
1147
+ text-align: center;
1148
+ }
1149
+ #show-all-variable-content .popup-template-span-wrap{
1150
+ margin-bottom: 20px;
1151
+ margin-right: 3%;
1152
+ width: 30%;
1153
+ display: inline-block;
1154
+ }
1155
+ #show-all-variable-content .popup-template-span-wrap:nth-child(3n+3) .qsm-text-template-span .qsm-tooltips-icon .qsm-tooltips{
1156
+ left: calc( 100% - 100px );
1157
+ }
1158
+ #show-all-variable-content .popup-template-span-wrap:nth-child(3n+3) .qsm-text-template-span .qsm-tooltips-icon .qsm-tooltips:before{
1159
+ left: 93%;
1160
+ }
1161
+ #show-all-variable-content .qsm-text-template-span .qsm-tooltips-icon{
1162
+ margin-left: 5px;
1163
+ }
1164
+ .qsm-text-template-span button{
1165
+ border-color: #ccc !important;
1166
+ }
1167
+ .qsm-text-template-span .qsm-tooltips-icon{
1168
+ vertical-align: middle;
1169
+ line-height: 30px;
1170
+ color: #9E9E9E;
1171
+ margin-left: 5px;
1172
+ }
1173
+ .qsm-text-template-span .qsm-tooltips-icon .qsm-tooltips{
1174
+ left: calc( 100% - 10px );
1175
+ bottom: 30px;
1176
+ }
1177
+ .qsm-text-label-wrapper > h2 {
1178
+ font-size: 24px;
1179
+ border-bottom: 1px solid #ccc;
1180
+ padding-bottom: 10px;
1181
+ line-height: normal;
1182
+ }
1183
+ .qsm-text-label-wrapper form > button:nth-child(3){
1184
+ display: none;
1185
+ }
1186
+ .qsm-text-label-wrapper .section_heading{
1187
+ margin-top: 0;
1188
+ }
1189
+ #show-all-variable .qsm-popup__container{
1190
+ min-width: 50vw;
1191
+ max-width: 1040px;
1192
+ padding: 0;
1193
+ }
1194
+ #show-all-variable-content{
1195
+ margin-bottom: 0 !important;
1196
+ padding: 20px;
1197
+ margin: 0;
1198
+ }
1199
+ #show-all-variable .qsm-popup__header{
1200
+ border-bottom: 1px solid #f1f1f1;
1201
+ padding: 20px;
1202
+ }
1203
+ #show-all-variable .qsm-popup__header .qsm-popup__title{
1204
+ color: #23282d;
1205
+ margin-bottom: 7px;
1206
+ }
1207
+ #show-all-variable .qsm-popup__footer{
1208
+ border-top: 1px solid #f1f1f1;
1209
+ padding: 20px;
1210
+ }
1211
+ .qsm-view-preview-btn{
1212
+ text-decoration: none;
1213
+ line-height: normal;
1214
+ margin-left: 5px;
1215
+ }
1216
+ .qsm-view-preview-btn span.dashicons{
1217
+ line-height: 12px;
1218
+ vertical-align: middle;
1219
+ font-size: 25px;
1220
+ }
1221
+ .mlw_quiz_options a.button.button-default.qsm-btn-quiz-edit {
1222
+ margin-left: 10px;
1223
+ /*margin-top: 9px;*/
1224
+ box-shadow: none;
1225
+ float: right;
1226
+ margin-right: 10px;
1227
+ }
1228
+ .mlw_quiz_options a.button.button-default.qsm-btn-quiz-edit:hover{
1229
+ opacity: 0.8;
1230
+ }
1231
+ .mlw_quiz_options a.button.button-default.qsm-btn-quiz-edit span.dashicons{
1232
+ line-height: 27px;
1233
+ }
1234
+ .mlw_quiz_options .nav-tab-wrapper{
1235
+ margin-top: 20px;
1236
+ }
1237
+ .mlw_quiz_options .edit-quiz-name{
1238
+ float: right;
1239
+ /*margin-top: 9px;*/
1240
+ }
1241
+ .qsm_text_customize_label{
1242
+ position: fixed;
1243
+ bottom: 20px;
1244
+ right: 25px;
1245
+ background: #fff;
1246
+ color: #5c5959;
1247
+ padding: 10px 20px;
1248
+ box-sizing: border-box;
1249
+ z-index: 99;
1250
+ border-radius: 5px;
1251
+ border: 1px solid #cdbaba;
1252
+ cursor: pointer;
1253
+ }
1254
+ .qsm-text-tab-message-loader{
1255
+ position: absolute;
1256
+ top: 50%;
1257
+ left: 50%;
1258
+ z-index: 99;
1259
+ transform: translate(-50%, -50%);
1260
+ }
1261
+ .qsm_text_customize_label .dashicons{
1262
+ font-size: 14px;
1263
+ line-height: 20px;
1264
+ }
1265
+ /**
1266
+ * Admin result page design
1267
+ */
1268
+ .overview-main-wrapper {
1269
+ display: flex;
1270
+ width: 100%;
1271
+ }
1272
+ .overview-main-wrapper .overview-inner-wrap{
1273
+ margin-right: 2%;
1274
+ width: 33.33%;
1275
+ }
1276
+ .overview-main-wrapper .overview-inner-wrap .inside{
1277
+ min-height: 105px;
1278
+ }
1279
+ .overview-main-wrapper .overview-inner-wrap:last-child{
1280
+ margin-right: 0;
1281
+ }
1282
+ .overview-main-wrapper .overview-inner-wrap h2.hndle,
1283
+ .comment-inner-wrap h2.hndle,
1284
+ .response-inner-wrap h2.hndle{
1285
+ margin: 0;
1286
+ padding: 10px;
1287
+ }
1288
+ .overview-main-wrapper .candidate-detail-wrap.overview-inner-wrap .result-candidate-span{
1289
+ display: block;
1290
+ margin-bottom: 5px;
1291
+ }
1292
+ .overview-main-wrapper .candidate-detail-wrap.overview-inner-wrap .result-candidate-span:last-child{
1293
+ margin-bottom: 0;
1294
+ }
1295
+ .overview-main-wrapper .overview-inner-wrap.candidate-detail-wrap .result-candidate-span> label{
1296
+ font-weight: bold;
1297
+ }
1298
+ .overview-main-wrapper .overview-inner-wrap.candidate-detail-wrap .result-candidate-span > span{
1299
+ float: right;
1300
+ }
1301
+ .overview-main-wrapper .overview-inner-wrap .timer-div-wrapper{
1302
+ display: -webkit-box;
1303
+ display: -moz-box;
1304
+ display: -ms-flexbox;
1305
+ display: -webkit-flex;
1306
+ display: flex;
1307
+ -webkit-flex-flow: row wrap;
1308
+ justify-content: center;
1309
+ -webkit-justify-content: center;
1310
+ flex-wrap: nowrap;
1311
+ }
1312
+ .overview-main-wrapper .overview-inner-wrap .timer-div-wrapper > div{
1313
+ padding: 15px 30px;
1314
+ background: #F1F1F1;
1315
+ margin-right: 10px;
1316
+ max-width: 120px;
1317
+ width: 100%;
1318
+ }
1319
+ .overview-main-wrapper .overview-inner-wrap .timer-div-wrapper > div:last-child{
1320
+ margin-right: 0;
1321
+ }
1322
+ .overview-main-wrapper .overview-inner-wrap .timer-div-wrapper span.timer-span{
1323
+ display: block;
1324
+ font-size: 36px;
1325
+ font-weight: bold;
1326
+ text-align: center;
1327
+ }
1328
+ .overview-main-wrapper .overview-inner-wrap .timer-div-wrapper span.timer-text{
1329
+ display: block;
1330
+ font-size: 16px;
1331
+ font-weight: bold;
1332
+ text-align: center;
1333
+ }
1334
+ .response-inner-wrap .inside{
1335
+ padding: 10px;
1336
+ margin: 0;
1337
+ }
1338
+ .response-inner-wrap .inside .qmn_question_answer{
1339
+ background-color: #f1f1f1;
1340
+ padding: 10px;
1341
+ margin-bottom: 0;
1342
+ background-repeat: no-repeat;
1343
+ background-position: 95% center;
1344
+ padding-right: 12%;
1345
+ }
1346
+ .response-inner-wrap .inside .qmn_question_answer:nth-child(2n){
1347
+ background-color: #fff;
1348
+ }
1349
+ .response-inner-wrap .inside .qmn_question_answer.qmn_question_answer_incorrect{
1350
+ background-image: url(../assets/wrong.png);
1351
+ }
1352
+ .response-inner-wrap .inside .qmn_question_answer.qmn_question_answer_correct{
1353
+ background-image: url(../assets/right.png);
1354
+ }
1355
+ .old_template_result_wrap{
1356
+ padding: 15px;
1357
+ background: #fff;
1358
+ }
1359
+ .result-page-title{
1360
+ text-align: left;
1361
+ display: inline-block;
1362
+ float: left;
1363
+ font-size: 23px;
1364
+ font-weight: 400;
1365
+ margin: 0;
1366
+ line-height: 30px;
1367
+ }
1368
+ .result-tab-content a.button > span.dashicons {
1369
+ line-height: 29px;
1370
+ font-size: 18px;
1371
+ margin-left: -4px;
1372
+ margin-right: -4px;
1373
+ }
1374
+ .result-page-wrapper .tablenav-pages{
1375
+ margin-left: 10px;
1376
+ }
1377
+ .result-page-wrapper .tablenav.top{
1378
+ margin-bottom: 20px;
1379
+ margin-top: 20px;
1380
+ }
1381
+ .inner-sidebar1 .handlediv{
1382
+ display: none !important;
1383
+ }
1384
+ .inner-sidebar1 .hndle{
1385
+ padding-left: 10px;
1386
+ padding-top: 10px;
1387
+ margin: 0;
1388
+ padding-bottom: 10px;
1389
+ }
1390
+ .inner-sidebar1 .inside h3,
1391
+ .inner-sidebar1 .inside h4{
1392
+ margin-bottom: 10px;
1393
+ }
1394
+ .qsm-quiz-email-tab,
1395
+ .qsm-quiz-result-tab{
1396
+ max-width: 1200px;
1397
+ width: 100%;
1398
+ }
1399
+ .qsm-quiz-email-tab .qsm-show-all-variable-text span.dashicons,
1400
+ .qsm-quiz-result-tab .qsm-show-all-variable-text span.dashicons{
1401
+ font-size: 16px;
1402
+ line-height: 22px;
1403
+ }
1404
+ .qsm-quiz-email-tab .qsm-show-all-variable-text,
1405
+ .qsm-quiz-result-tab .qsm-show-all-variable-text{
1406
+ position: fixed;
1407
+ bottom: 20px;
1408
+ right: 25px;
1409
+ background: #fff;
1410
+ color: #5c5959;
1411
+ padding: 10px 20px;
1412
+ box-sizing: border-box;
1413
+ z-index: 99;
1414
+ border-radius: 5px;
1415
+ border: 1px solid #cdbaba;
1416
+ cursor: pointer;
1417
+ text-decoration: none;
1418
+ }
1419
+ .popup-template-span-wrap .popup-copied-des {
1420
+ color: green;
1421
+ }
1422
+ .popup-template-span-wrap .popup-copied-des span.dashicons{
1423
+ line-height: 28px;
1424
+ }
1425
+ .comment-inner-wrap{
1426
+ display: none;
1427
+ }
1428
+ @media (min-width: 768px) and (max-width: 1199px){
1429
+ .qsm-news-ads .qsm-info-widget{
1430
+ float: left;
1431
+ max-width: unset;
1432
+ width: 31.3%;
1433
+ }
1434
+ .qsm-news-ads .qsm-info-widget:nth-child(3n+5){
1435
+ clear: both;
1436
+ }
1437
+ .remove-ads-adv-link{
1438
+ width: 100%;
1439
+ display: inline-block;
1440
+ margin-bottom: 30px;
1441
+ }
1442
+ }
1443
+ @media screen and (max-width: 782px){
1444
+ .form-table td fieldset label {
1445
+ margin-top: -1px !important;
1446
+ vertical-align: top;
1447
+ }
1448
+ .qsm-tooltips-icon .qsm-tooltips{
1449
+ left: -90px;
1450
+ }
1451
+ .qsm-opt-tr .qsm-tooltips-icon{
1452
+ right: 13px;
1453
+ }
1454
+ .qsm-tooltips-icon .qsm-tooltips:before{
1455
+ left: auto;
1456
+ right: -3px;
1457
+ }
1458
+ }
1459
  @media screen and (max-width: 767px){
1460
  .qsm-quiz-row td:nth-of-type(2n){
1461
  display: none;
1462
  }
1463
+ .qsm-quiz-page-wrapper,
1464
+ .qsm-quiz-page-wrapper-with-ads {
1465
+ overflow-x: auto;
1466
+ }
1467
  .qsm-quiz-page-wrapper thead th:nth-of-type(2n),
1468
  .qsm-quiz-page-wrapper tfoot th:nth-of-type(2n),
1469
  .qsm-quiz-page-wrapper-with-ads thead th:nth-of-type(2n),
1509
  padding-left: 15px;
1510
  padding-bottom: 15px;
1511
  }
1512
+ .qsm-news-ads .qsm-info-widget{
1513
+ width: calc( 100% - 30px );
1514
+ max-width: 100%;
1515
+ box-sizing: border-box;
1516
+ margin: 15px 15px 0 15px;
1517
+ }
1518
+ .form-table .qsm-opt-tr{
1519
+ padding-bottom: 10px;
1520
+ }
1521
+ .overview-main-wrapper{
1522
+ display: block;
1523
+ }
1524
+ .overview-main-wrapper .overview-inner-wrap{
1525
+ margin-right: 0;
1526
+ width: 100%;
1527
+ }
1528
+ .result-page-title{
1529
+ margin-bottom: 10px;
1530
+ }
1531
  }
js/admin.js CHANGED
@@ -102,14 +102,209 @@ var QSMAdmin;
102
  }
103
  }
104
  );
105
- });
106
- /**/
107
- if(jQuery('.buttonset').length > 0){
108
- jQuery('.buttonset').buttonset();
109
- }
110
  jQuery('.category_selection_random').change(function(){
111
  var checked_data = jQuery(this).val().toString();
112
  jQuery('.catergory_comma_values').val(checked_data);
113
  });
114
- });
115
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
  }
104
  );
105
+ });
 
 
 
 
106
  jQuery('.category_selection_random').change(function(){
107
  var checked_data = jQuery(this).val().toString();
108
  jQuery('.catergory_comma_values').val(checked_data);
109
  });
110
+ jQuery('.row-actions-c > .rtq-delete-result').click(function(e){
111
+ e.preventDefault();
112
+ var $this = jQuery(this);
113
+ if(confirm('are you sure?')){
114
+ var action = 'qsm_dashboard_delete_result';
115
+ var result_id = jQuery(this).data('result_id');
116
+ $.post(ajaxurl, {result_id: result_id, action: action },
117
+ function (data) {
118
+ if(data == 'failed'){
119
+ alert('Error to delete the result!');
120
+ }else{
121
+ $this.parents('li').slideUp();
122
+ $this.parents('li').remove();
123
+ }
124
+ }
125
+ );
126
+ }
127
+ });
128
+ jQuery('.load-quiz-wizard').click(function(e){
129
+ e.preventDefault();
130
+ MicroModal.show('model-wizard');
131
+ var height = jQuery(".qsm-wizard-template-section").css("height");
132
+ jQuery(".qsm-wizard-setting-section").css("height", height);
133
+ if(jQuery( "#accordion" ).length > 0){
134
+ var icons = {
135
+ header: "iconClosed", // custom icon class
136
+ activeHeader: "iconOpen" // custom icon class
137
+ };
138
+ jQuery( "#accordion" ).accordion({
139
+ collapsible: true,
140
+ icons: icons,
141
+ heightStyle: "content"
142
+ });
143
+ jQuery('.template-list .template-list-inner:first-child').trigger('click');
144
+ }
145
+ });
146
+ //Get quiz options
147
+ jQuery('.template-list-inner').click(function(){
148
+ var action = 'qsm_wizard_template_quiz_options';
149
+ var settings = jQuery(this).data('settings');
150
+ var addons = jQuery(this).data('addons');
151
+ jQuery('.template-list .template-list-inner').removeClass('selected-quiz-template');
152
+ jQuery(this).addClass('selected-quiz-template');
153
+ jQuery('#quiz_settings_wrapper').html('').html('<div class="qsm-spinner-loader"></div>');
154
+ jQuery('#recomm_addons_wrapper').html('').html('<div class="qsm-spinner-loader"></div>');
155
+ $.post(ajaxurl, {settings: settings, addons: addons, action: action },
156
+ function (data) {
157
+ var diff_html = data.split('=====');
158
+ jQuery('#quiz_settings_wrapper').html('');
159
+ jQuery('#quiz_settings_wrapper').html(diff_html[0]);
160
+ jQuery('#recomm_addons_wrapper').html('');
161
+ jQuery('#recomm_addons_wrapper').html(diff_html[1]);
162
+ jQuery( "#accordion" ).accordion();
163
+ $( '#quiz_settings_wrapper select' ).each(function(){
164
+ var name = $(this).attr('name');
165
+ var value = $(this).val();
166
+ if( $( '.' + name + '_' + value ).length > 0 ){
167
+ $( '.' + name + '_' + value ).show();
168
+ }
169
+ });
170
+ }
171
+ );
172
+ });
173
+
174
+ jQuery( '#create-quiz-button' ).on( 'click', function( event ) {
175
+ event.preventDefault();
176
+ if( jQuery('#new-quiz-form').find('.quiz_name').val() === ''){
177
+ jQuery('#new-quiz-form').find('.quiz_name').addClass('qsm-required');
178
+ jQuery('#new-quiz-form').find('.quiz_name').focus();
179
+ return;
180
+ }
181
+ jQuery( '#new-quiz-form' ).submit();
182
+ });
183
+
184
+ //Hide/Show legacy option
185
+ jQuery('#legacy_options').parents('tr').nextAll('tr').hide();
186
+ jQuery(document).on('click','#legacy_options', function(e){
187
+ e.preventDefault();
188
+ if( jQuery('#legacy_options').parents('tr').next('tr').is(':visible') ){
189
+ jQuery(this).text('').text('Show Legacy options');
190
+ jQuery('#legacy_options').parents('tr').nextAll('tr').hide();
191
+ }else{
192
+ jQuery(this).text('').text('Hide Legacy options');
193
+ jQuery('#legacy_options').parents('tr').nextAll('tr').show();
194
+ }
195
+ });
196
+
197
+ //Dismiss the welcome panel
198
+ jQuery('.qsm-welcome-panel-dismiss').click(function(e){
199
+ e.preventDefault();
200
+ jQuery( '#welcome_panel' ).addClass('hidden');
201
+ jQuery('#screen-options-wrap').find('#welcome_panel-hide').prop('checked', false);
202
+ postboxes.save_state( 'toplevel_page_qsm_dashboard' );
203
+ });
204
+ //Get the message in text tab
205
+ jQuery( document ).on( 'change', '#qsm_question_text_message_id' , function(){
206
+ var text_id = jQuery(this).val();
207
+ jQuery('.qsm-text-main-wrap .qsm-text-tab-message-loader').show();
208
+ jQuery.post(ajaxurl, {text_id: text_id, 'quiz_id': qsmTextTabObject.quiz_id, action: 'qsm_get_question_text_message'},function (response) {
209
+ var data = jQuery.parseJSON( response );
210
+ if( data.success === true ){
211
+ var text_msg = data.text_message;
212
+ text_msg = text_msg.replace(/\n/g,"<br>");
213
+ tinyMCE.get( 'qsm_question_text_message' ).setContent( text_msg );
214
+ jQuery( '.qsm-text-allowed-variables > .qsm-text-variable-wrap' ).html('').html( data.allowed_variable_text );
215
+ jQuery('.qsm-text-main-wrap .qsm-text-tab-message-loader').hide();
216
+ } else {
217
+ console.log( data.message );
218
+ }
219
+ });
220
+ });
221
+ //Save the message in text tab
222
+ jQuery( document ).on( 'click', '#qsm_save_text_message' , function(){
223
+ var $this = jQuery(this);
224
+ $this.siblings('.spinner').addClass('is-active');
225
+ var text_id = jQuery( '#qsm_question_text_message_id' ).val();
226
+ var message = wp.editor.getContent( 'qsm_question_text_message' );
227
+ jQuery.post(ajaxurl, {text_id: text_id, 'message': message, 'quiz_id': qsmTextTabObject.quiz_id, action: 'qsm_update_text_message'},function (response) {
228
+ var data = jQuery.parseJSON( response );
229
+ if( data.success === true ){
230
+ //Do nothing
231
+ } else {
232
+ console.log( data.message );
233
+ }
234
+ $this.siblings('.spinner').removeClass('is-active');
235
+ });
236
+ });
237
+ //On click append on tiny mce
238
+ jQuery( document ).on( 'click', '.qsm-text-allowed-variables button.button' , function(){
239
+ var content = jQuery(this).text();
240
+ tinyMCE.activeEditor.execCommand('mceInsertContent', false, content);
241
+ });
242
+ //Show all the variable list
243
+ jQuery('.qsm-show-all-variable-text').click(function (e) {
244
+ e.preventDefault();
245
+ MicroModal.show('show-all-variable');
246
+ });
247
+ //Hide/show tr based on selection
248
+ $( '.qsm_tab_content select' ).each(function(){
249
+ var name = $(this).attr('name');
250
+ var value = $(this).val();
251
+ if( $( '.' + name + '_' + value ).length > 0 ){
252
+ $( '.' + name + '_' + value ).show();
253
+ }
254
+ });
255
+ $(document).on('change', '.qsm_tab_content select, #quiz_settings_wrapper select', function(){
256
+ var name = $(this).attr('name');
257
+ var value = $(this).val();
258
+ $( '.qsm_hidden_tr' ).hide();
259
+ if( $( '.' + name + '_' + value ).length > 0 ){
260
+ $( '.' + name + '_' + value ).show();
261
+ }
262
+ });
263
+ if( $('.qsm-text-label-wrapper').length > 0 ){
264
+ var element_position = $('.qsm-text-label-wrapper').offset().top;
265
+ $(window).scroll(function() {
266
+ var y_scroll_pos = window.pageYOffset;
267
+ var scroll_pos_test = element_position;
268
+ if(y_scroll_pos > scroll_pos_test) {
269
+ $('.qsm_text_customize_label').fadeOut('slow');
270
+ }else{
271
+ $('.qsm_text_customize_label').fadeIn('slow');
272
+ }
273
+ });
274
+ }
275
+ $(document).on('click','.qsm_text_customize_label', function(){
276
+ $('html, body').animate({
277
+ scrollTop: $(".qsm-text-label-wrapper").offset().top - 30
278
+ }, 2000);
279
+ });
280
+ //New template design hide show
281
+ var new_template_result_detail = $('.new_template_result_detail:checked').val();
282
+ if( new_template_result_detail == 1 ){
283
+ $('.new_template_result_detail:checked').parents('tr').next('tr').hide();
284
+ }
285
+ $(document).on('change','.new_template_result_detail', function(){
286
+ if( $(this).val() == 1 ){
287
+ $(this).parents('tr').next('tr').hide();
288
+ }else{
289
+ $(this).parents('tr').next('tr').show();
290
+ }
291
+ });
292
+ $(document).on('click', '.qsm-text-template-span > .button', function(e){
293
+ e.preventDefault();
294
+ var $temp = $("<input>");
295
+ $("body").append($temp);
296
+ $temp.val( jQuery(this).text() ).select();
297
+ document.execCommand("copy");
298
+ $temp.remove();
299
+ var button_width = $(this).width();
300
+ var button_txt = $(this).text();
301
+ $(this).css('width', button_width);
302
+ $(this).text('').html('<span class="popup-copied-des"><span class="dashicons dashicons-yes"></span> Copied!</span>');
303
+ var this_par = $(this);
304
+ setTimeout(function(){
305
+ this_par.css('width', 'auto');
306
+ this_par.text('').text(button_txt);
307
+ }, 1000);
308
+ });
309
+ });
310
+ }(jQuery));
js/qsm-admin-contact.js CHANGED
@@ -167,8 +167,16 @@ var QSMContact;
167
  };
168
  $(function() {
169
  QSMContact.load();
 
 
 
170
  $( '.add-contact-field' ).on( 'click', function() {
171
  QSMContact.newField();
 
 
 
 
 
172
  });
173
  $( '.save-contact' ).on( 'click', function() {
174
  QSMContact.save();
167
  };
168
  $(function() {
169
  QSMContact.load();
170
+ if( $('.contact-form > .contact-form-field').length === 0 ){
171
+ $('.save-contact').hide();
172
+ }
173
  $( '.add-contact-field' ).on( 'click', function() {
174
  QSMContact.newField();
175
+ if( $('.contact-form > .contact-form-field').length === 0 ){
176
+ $('.save-contact').hide();
177
+ }else{
178
+ $('.save-contact').show();
179
+ }
180
  });
181
  $( '.save-contact' ).on( 'click', function() {
182
  QSMContact.save();
js/qsm-admin-emails.js CHANGED
@@ -36,22 +36,23 @@ var QSMAdminEmails;
36
  data: data,
37
  headers: { 'X-WP-Nonce': qsmEmailsObject.nonce },
38
  })
39
- .done(function( results ) {
40
  if ( results.status ) {
41
  QSMAdmin.displayAlert( 'Emails were saved!', 'success' );
42
  } else {
43
  QSMAdmin.displayAlert( 'There was an error when saving the emails. Please try again.', 'error' );
44
- }
45
  })
46
  .fail(QSMAdmin.displayjQueryError);
47
  },
48
  loadEmails: function() {
49
- QSMAdmin.displayAlert( 'Loading emails...', 'info' );
50
  $.ajax({
51
  url: wpApiSettings.root + 'quiz-survey-master/v1/quizzes/' + qsmEmailsObject.quizID + '/emails',
52
  headers: { 'X-WP-Nonce': qsmEmailsObject.nonce },
53
  })
54
  .done(function( emails ) {
 
55
  emails.forEach( function( email, i, emails ) {
56
  QSMAdminEmails.addEmail( email.conditions, email.to, email.subject, email.content, email.replyTo );
57
  });
36
  data: data,
37
  headers: { 'X-WP-Nonce': qsmEmailsObject.nonce },
38
  })
39
+ .done(function( results ) {
40
  if ( results.status ) {
41
  QSMAdmin.displayAlert( 'Emails were saved!', 'success' );
42
  } else {
43
  QSMAdmin.displayAlert( 'There was an error when saving the emails. Please try again.', 'error' );
44
+ }
45
  })
46
  .fail(QSMAdmin.displayjQueryError);
47
  },
48
  loadEmails: function() {
49
+ //QSMAdmin.displayAlert( 'Loading emails...', 'info' );
50
  $.ajax({
51
  url: wpApiSettings.root + 'quiz-survey-master/v1/quizzes/' + qsmEmailsObject.quizID + '/emails',
52
  headers: { 'X-WP-Nonce': qsmEmailsObject.nonce },
53
  })
54
  .done(function( emails ) {
55
+ $( '#emails' ).find( '.qsm-spinner-loader' ).remove();
56
  emails.forEach( function( email, i, emails ) {
57
  QSMAdminEmails.addEmail( email.conditions, email.to, email.subject, email.content, email.replyTo );
58
  });
js/qsm-admin-question.js CHANGED
@@ -5,13 +5,17 @@
5
  var QSMQuestion;
6
  var import_button;
7
  (function ($) {
 
 
 
8
  QSMQuestion = {
9
  question: Backbone.Model.extend({
10
  defaults: {
11
  id: null,
12
  quizID: 1,
13
  type: '0',
14
- name: 'Your new question!',
 
15
  answerInfo: '',
16
  comments: '1',
17
  hint: '',
@@ -22,7 +26,18 @@ var import_button;
22
  }
23
  }),
24
  questions: null,
 
 
 
 
 
 
 
 
 
 
25
  questionCollection: null,
 
26
  categories: [],
27
  /**
28
  * Counts the total number of questions and then updates #total-questions span.
@@ -46,8 +61,12 @@ var import_button;
46
  },
47
  openQuestionBank: function( pageID ) {
48
  QSMQuestion.loadQuestionBank();
49
- $( '#add-question-bank-page' ).val( pageID );
50
- MicroModal.show( 'modal-2' );
 
 
 
 
51
  },
52
  loadQuestionBank: function( action = '' ) {
53
  if( action == 'change' ){
@@ -108,9 +127,12 @@ var import_button;
108
  $( '#question-bank' ).prepend('<button class="button button-primary" id="qsm-import-selected-question">Import All Selected Questions</button>');
109
  }
110
  },
111
- addQuestionToQuestionBank: function( question ) {
112
  var questionText = QSMQuestion.prepareQuestionText( question.name );
113
  var template = wp.template( 'single-question-bank-question' );
 
 
 
114
  $( '#question-bank' ).append( template( { id: question.id, question: questionText, category: question.category, quiz_name: question.quiz_name } ) );
115
  },
116
  addQuestionFromQuestionBank: function( questionID ) {
@@ -153,17 +175,21 @@ var import_button;
153
  $( '#categories' ).prepend( template( { category: category } ) );
154
  },
155
  loadQuestions: function() {
156
- QSMAdmin.displayAlert( 'Loading questions...', 'info' );
157
  QSMQuestion.questions.fetch({
158
  headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
159
  data: { quizID: qsmQuestionSettings.quizID },
160
  success: QSMQuestion.loadSuccess,
161
  error: QSMAdmin.displayError
162
- });
163
  },
164
  loadSuccess: function() {
165
  QSMAdmin.clearAlerts();
 
166
  var question;
 
 
 
167
  if ( qsmQuestionSettings.pages.length > 0 ) {
168
  for ( var i = 0; i < qsmQuestionSettings.pages.length; i++ ) {
169
  for ( var j = 0; j < qsmQuestionSettings.pages[ i ].length; j++ ) {
@@ -172,13 +198,28 @@ var import_button;
172
  }
173
  }
174
  } else {
175
- QSMQuestion.questions.each( QSMQuestion.addQuestionToPage );
 
176
  }
 
 
 
 
 
177
  QSMQuestion.countTotal();
178
  },
 
 
 
 
 
 
 
179
  savePages: function() {
180
  QSMAdmin.displayAlert( 'Saving pages and questions...', 'info' );
181
  var pages = [];
 
 
182
 
183
  // Cycles through each page and add page + questions to pages variable
184
  _.each( jQuery( '.page' ), function( page ) {
@@ -193,10 +234,17 @@ var import_button;
193
  singlePage.push( jQuery( question ).data( 'question-id' ) )
194
  });
195
  pages.push( singlePage );
 
 
 
 
 
 
196
  });
197
  var data = {
198
  action: 'qsm_save_pages',
199
  pages: pages,
 
200
  quiz_id : qsmQuestionSettings.quizID,
201
  nonce : qsmQuestionSettings.saveNonce,
202
  };
@@ -210,24 +258,42 @@ var import_button;
210
  },
211
  savePagesSuccess: function() {
212
  QSMAdmin.displayAlert( 'Questions and pages were saved!', 'success' );
 
213
  },
214
- addNewPage: function() {
215
  var template = wp.template( 'page' );
216
- $( '.questions' ).append( template() );
 
 
 
 
 
 
 
 
217
  $( '.page' ).sortable({
218
  items: '.question',
219
  opacity: 70,
220
  cursor: 'move',
221
  placeholder: "ui-state-highlight",
222
- connectWith: '.page'
 
 
 
 
 
 
 
 
223
  });
224
  setTimeout( QSMQuestion.removeNew, 250 );
225
  },
226
  addNewQuestion: function( model ) {
227
  QSMAdmin.displayAlert( 'Question created!', 'success' );
228
- QSMQuestion.addQuestionToPage( model );
229
- QSMQuestion.openEditPopup( model.id );
230
  QSMQuestion.countTotal();
 
231
  },
232
  addQuestionToPage: function( model ) {
233
  var page = model.get( 'page' ) + 1;
@@ -235,7 +301,7 @@ var import_button;
235
  var page_exists = $( '.page:nth-child(' + page + ')' ).length;
236
  var count = 0;
237
  while ( ! page_exists ) {
238
- QSMQuestion.addNewPage();
239
  page_exists = $( '.page:nth-child(' + page + ')' ).length;
240
  count++;
241
  if ( count > 5 ) {
@@ -243,7 +309,13 @@ var import_button;
243
  console.log( 'count reached' );
244
  }
245
  }
246
- var questionName = QSMQuestion.prepareQuestionText( model.get( 'name' ) );
 
 
 
 
 
 
247
  $( '.page:nth-child(' + page + ')' ).append( template( { id: model.id, category : model.get('category'), question: questionName } ) );
248
  setTimeout( QSMQuestion.removeNew, 250 );
249
  },
@@ -275,19 +347,22 @@ var import_button;
275
  }
276
  );
277
  },
278
- saveQuestion: function( questionID ) {
279
  QSMAdmin.displayAlert( 'Saving question...', 'info' );
280
  var model = QSMQuestion.questions.get( questionID );
281
  var hint = $( '#hint' ).val();
282
  var name = wp.editor.getContent( 'question-text' );
283
- if(name == ''){
284
- alert('Enter question title');
 
 
285
  return false;
286
  }
 
287
  var answerInfo = $( '#correct_answer_info' ).val();
288
  var type = $( "#question_type" ).val();
289
- var comments = $( "#comments" ).val();
290
- var required = $( "#required" ).val();
291
  var category = $( ".category-radio:checked" ).val();
292
  var autofill = $( "#hide_autofill" ).val();
293
  var limit_text = $( "#limit_text" ).val();
@@ -314,6 +389,7 @@ var import_button;
314
  answer = wp.editor.getContent( ta_id );
315
  }else{
316
  answer = $answer.find( '.answer-text' ).val().trim();
 
317
  }
318
 
319
  var points = $answer.find( '.answer-points' ).val();
@@ -322,23 +398,42 @@ var import_button;
322
  correct = 1;
323
  }
324
  answers.push( [ answer, points, correct ] );
325
- });
326
- model.save(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  {
328
  type: type,
329
  name: name,
 
330
  answerInfo: answerInfo,
331
  comments: comments,
332
  hint: hint,
333
  category: category,
334
- required: required,
335
  answers: answers,
336
  answerEditor: answerType,
337
- autofill: autofill,
338
- limit_text: limit_text,
339
- limit_multiple_response: limit_multiple_response,
340
- file_upload_limit: file_upload_limit,
341
- file_upload_type: type_arr.join(","),
 
342
  },
343
  {
344
  headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
@@ -347,19 +442,26 @@ var import_button;
347
  type: 'POST'
348
  }
349
  );
350
- MicroModal.close('modal-1');
351
  },
352
- saveSuccess: function( model ) {
353
  QSMAdmin.displayAlert( 'Question was saved!', 'success' );
354
  var template = wp.template( 'question' );
355
  var page = model.get( 'page' ) + 1;
356
- $( '.question[data-question-id=' + model.id + ']' ).replaceWith( template( { id: model.id, type : model.get('type'), category : model.get('category'), question: model.get('name') } ) );
357
- setTimeout( QSMQuestion.removeNew, 250 );
 
 
 
 
 
 
 
 
358
  },
359
- addNewAnswer: function( answer ) {
360
-
361
  var answerTemplate = wp.template( 'single-answer' );
362
- $( '#answers' ).append( answerTemplate( { answer: decodeEntities( answer[0] ), points: answer[1], correct: answer[2], count: answer[3], question_id: answer[4], answerType: answer[5] } ) );
363
  if(answer[5] == 'rich' && qsmQuestionSettings.qsm_user_ve === 'true'){
364
  var textarea_id = 'answer-' + answer[4] + '-' + answer[3];
365
  wp.editor.remove( textarea_id );
@@ -377,7 +479,27 @@ var import_button;
377
  tinyMCE.get( textarea_id ).setContent( anser );
378
  }
379
  },
380
- openEditPopup: function( questionID ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  QSMQuestion.prepareCategories();
382
  QSMQuestion.processCategories();
383
  var question = QSMQuestion.questions.get( questionID );
@@ -385,16 +507,20 @@ var import_button;
385
  $( '#edit_question_id' ).val( questionID );
386
  var question_editor = ''
387
  if(qsmQuestionSettings.qsm_user_ve === 'true'){
 
 
 
388
  question_editor = tinyMCE.get( 'question-text' );
389
  }
390
  if ($('#wp-question-text-wrap').hasClass('html-active')) {
391
  jQuery( "#question-text" ).val( questionText );
392
  } else if ( question_editor ) {
 
393
  tinyMCE.get( 'question-text' ).setContent( questionText );
394
  } else {
395
  jQuery( "#question-text" ).val( questionText );
396
  }
397
-
398
  $( '#answers' ).empty();
399
  var answers = question.get( 'answers' );
400
  var answerEditor = question.get( 'answerEditor' );
@@ -439,19 +565,25 @@ var import_button;
439
  QSMQuestion.addNewAnswer( answer );
440
  al++;
441
  });
442
- //Hide the question settings based on question type
443
- if(question.get( 'type' ) == 11){
444
- jQuery('#file-upload-type-div').show();
445
- jQuery('#file-upload-limit').show();
446
- }else{
447
- jQuery('#file-upload-type-div').hide();
448
- jQuery('#file-upload-limit').hide();
449
  }
 
 
 
 
 
 
 
450
  $( '#hint' ).val( question.get( 'hint' ) );
451
  $( '#correct_answer_info' ).val( question.get( 'answerInfo' ) );
452
  $( "#question_type" ).val( question.get( 'type' ) );
453
  $( "#comments" ).val( question.get( 'comments' ) );
454
- $( "#required" ).val( question.get( 'required' ) );
 
 
455
  $( "#hide_autofill" ).val( disableAutofill );
456
  $( "#limit_text" ).val( get_limit_text );
457
  $( "#limit_multiple_response" ).val( get_limit_mr );
@@ -459,10 +591,42 @@ var import_button;
459
  $( "#change-answer-editor" ).val( answerEditor );
460
  $( ".category-radio" ).removeAttr( 'checked' );
461
  $( "#edit-question-id" ).text('').text(questionID);
 
462
  if ( 0 !== question.get( 'category' ).length ) {
463
  $( ".category-radio" ).val( [question.get( 'category' )] );
464
- }
465
- MicroModal.show( 'modal-1' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  },
467
  removeNew: function() {
468
  $( '.page-new' ).removeClass( 'page-new' );
@@ -485,6 +649,8 @@ var import_button;
485
  };
486
 
487
  $(function() {
 
 
488
  QSMQuestion.questionCollection = Backbone.Collection.extend({
489
  url: wpApiSettings.root + 'quiz-survey-master/v1/questions',
490
  model: QSMQuestion.question
@@ -498,6 +664,7 @@ var import_button;
498
  $( '.questions' ).on( 'click', '.new-question-button', function( event ) {
499
  event.preventDefault();
500
  QSMQuestion.createQuestion( $( this ).parents( '.page' ).index() );
 
501
  });
502
 
503
  $( '.questions' ).on( 'click', '.add-question-bank-button', function( event ) {
@@ -519,33 +686,51 @@ var import_button;
519
 
520
  $( '.questions' ).on( 'click', '.edit-question-button', function( event ) {
521
  event.preventDefault();
522
- QSMQuestion.openEditPopup( $( this ).parents( '.question' ).data( 'question-id' ) );
 
 
 
 
523
  });
524
 
525
- $( '.questions' ).on( 'click', '.duplicate-question-button', function( event ) {
526
  event.preventDefault();
527
  QSMQuestion.duplicateQuestion( $( this ).parents( '.question' ).data( 'question-id' ) );
 
528
  });
529
  $( '.questions' ).on( 'click', '.delete-question-button', function( event ) {
530
- event.preventDefault();
531
- $( this ).parents( '.question' ).remove();
532
- QSMQuestion.countTotal();
533
- $('.save-page-button').trigger('click');
 
 
534
  });
535
  $( '.questions' ).on( 'click', '.delete-page-button', function( event ) {
536
  event.preventDefault();
537
- $( this ).parents( '.page' ).remove();
 
 
 
538
  });
539
- $( '#answers' ).on( 'click', '.delete-answer-button', function( event ) {
540
  event.preventDefault();
541
  $( this ).parents( '.answers-single' ).remove();
542
  });
543
- $( '#save-popup-button' ).on( 'click', function( event ) {
544
  event.preventDefault();
545
- QSMQuestion.saveQuestion( $( this ).parent().siblings( 'main' ).children( '#edit_question_id' ).val() );
546
- $('.save-page-button').trigger('click');
547
  });
548
- $( '#new-answer-button' ).on( 'click', function( event ) {
 
 
 
 
 
 
 
 
 
549
  event.preventDefault();
550
  var answer_length = $( '#answers' ).find('.answers-single').length;
551
  if( answer_length > 1 && $('#question_type').val() == 13 ){
@@ -563,7 +748,7 @@ var import_button;
563
  $(this).text('').text('Adding Question');
564
  import_button = $(this);
565
  QSMQuestion.addQuestionFromQuestionBank( $( this ).parents( '.question-bank-question' ).data( 'question-id' ) );
566
- $('.import-button').addClass('disable_import');
567
  });
568
 
569
  //Click on selected question button.
@@ -579,15 +764,32 @@ var import_button;
579
  QSMQuestion.addQuestionFromQuestionBank( $( this ).data( 'question-id' ) );
580
  $(this).find('.import-button').text('').text('Add Question');
581
  });
582
- $('.import-button').addClass('disable_import');
583
- $('#question-bank').find('[name="qsm-question-checkbox[]"]').attr('checked',false)
584
  }
585
  });
586
 
587
  $( '.save-page-button' ).on( 'click', function( event ) {
588
  event.preventDefault();
 
589
  QSMQuestion.savePages();
590
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
 
592
  $( document ).on( 'change', '#change-answer-editor', function( event ) {
593
  var newVal = $(this).val();
@@ -625,18 +827,8 @@ var import_button;
625
  }
626
  });
627
 
628
- $( '.questions' ).sortable({
629
- opacity: 70,
630
- cursor: 'move',
631
- placeholder: "ui-state-highlight"
632
- });
633
- $( '.page' ).sortable({
634
- items: '.question',
635
- opacity: 70,
636
- cursor: 'move',
637
- placeholder: "ui-state-highlight",
638
- connectWith: '.page'
639
- });
640
  if(qsmQuestionSettings.qsm_user_ve === 'true'){
641
  QSMQuestion.prepareEditor();
642
  }
@@ -655,17 +847,27 @@ var import_button;
655
  }
656
  });
657
  });
 
658
  //Hide the question settings based on question type
659
  $(document).on('change','#question_type', function(){
660
  var question_val = $(this).val();
661
- if(question_val == 11){
662
- jQuery('#file-upload-type-div').show();
663
- jQuery('#file-upload-limit').show();
 
 
 
 
 
 
 
 
 
664
  }else{
665
- jQuery('#file-upload-type-div').hide();
666
- jQuery('#file-upload-limit').hide();
667
  }
668
- });
669
  });
670
  var decodeEntities = (function () {
671
  //create a new html document (doesn't execute script tags in child elements)
@@ -691,4 +893,55 @@ var import_button;
691
  }
692
  return decodeHTMLEntities;
693
  })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
694
  }(jQuery));
5
  var QSMQuestion;
6
  var import_button;
7
  (function ($) {
8
+ $.QSMSanitize = function(input) {
9
+ return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g, '');
10
+ };
11
  QSMQuestion = {
12
  question: Backbone.Model.extend({
13
  defaults: {
14
  id: null,
15
  quizID: 1,
16
  type: '0',
17
+ name: '',
18
+ question_title: 'Your new question!',
19
  answerInfo: '',
20
  comments: '1',
21
  hint: '',
26
  }
27
  }),
28
  questions: null,
29
+ page: Backbone.Model.extend({
30
+ defaults: {
31
+ id: null,
32
+ quizID: 1,
33
+ pagekey: qsmRandomID(8),
34
+ hide_prevbtn: 0,
35
+ questions: null,
36
+ }
37
+ }),
38
+ qpages: null,
39
  questionCollection: null,
40
+ pageCollection: null,
41
  categories: [],
42
  /**
43
  * Counts the total number of questions and then updates #total-questions span.
61
  },
62
  openQuestionBank: function( pageID ) {
63
  QSMQuestion.loadQuestionBank();
64
+ $( '#add-question-bank-page' ).val( pageID );
65
+ MicroModal.show( 'modal-2',{
66
+ onClose: function(){
67
+ $('.save-page-button').trigger('click');
68
+ }
69
+ });
70
  },
71
  loadQuestionBank: function( action = '' ) {
72
  if( action == 'change' ){
127
  $( '#question-bank' ).prepend('<button class="button button-primary" id="qsm-import-selected-question">Import All Selected Questions</button>');
128
  }
129
  },
130
+ addQuestionToQuestionBank: function( question ) {
131
  var questionText = QSMQuestion.prepareQuestionText( question.name );
132
  var template = wp.template( 'single-question-bank-question' );
133
+ if( question.question_title !== "undefined" && question.question_title !== "" ){
134
+ questionText = question.question_title;
135
+ }
136
  $( '#question-bank' ).append( template( { id: question.id, question: questionText, category: question.category, quiz_name: question.quiz_name } ) );
137
  },
138
  addQuestionFromQuestionBank: function( questionID ) {
175
  $( '#categories' ).prepend( template( { category: category } ) );
176
  },
177
  loadQuestions: function() {
178
+ QSMAdmin.displayAlert( 'Loading questions...', 'info' );
179
  QSMQuestion.questions.fetch({
180
  headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
181
  data: { quizID: qsmQuestionSettings.quizID },
182
  success: QSMQuestion.loadSuccess,
183
  error: QSMAdmin.displayError
184
+ });
185
  },
186
  loadSuccess: function() {
187
  QSMAdmin.clearAlerts();
188
+ $('.qsm-showing-loader').remove();
189
  var question;
190
+ _.each(qsmQuestionSettings.qpages, function( page ){
191
+ QSMQuestion.qpages.add(page);
192
+ });
193
  if ( qsmQuestionSettings.pages.length > 0 ) {
194
  for ( var i = 0; i < qsmQuestionSettings.pages.length; i++ ) {
195
  for ( var j = 0; j < qsmQuestionSettings.pages[ i ].length; j++ ) {
198
  }
199
  }
200
  } else {
201
+ //We have removed this code in 7.0.0 because not allow to delete the single page.
202
+ //QSMQuestion.questions.each( QSMQuestion.addQuestionToPage );
203
  }
204
+ //Create Default pages and one question.
205
+ if( qsmQuestionSettings.pages.length == 0 && QSMQuestion.questions.length == 0){
206
+ $('.new-page-button').trigger('click');
207
+ $('.questions .new-question-button').trigger('click');
208
+ }
209
  QSMQuestion.countTotal();
210
  },
211
+ updateQPage: function(pageID) {
212
+ QSMAdmin.displayAlert( 'Saving page info', 'info' );
213
+ var pageInfo = QSMQuestion.qpages.get(pageID);
214
+ jQuery('#page-options').find(':input, select, textarea').each(function(i, field){
215
+ pageInfo.set(field.name, field.value);
216
+ });
217
+ },
218
  savePages: function() {
219
  QSMAdmin.displayAlert( 'Saving pages and questions...', 'info' );
220
  var pages = [];
221
+ var qpages = [];
222
+ var pageInfo = null;
223
 
224
  // Cycles through each page and add page + questions to pages variable
225
  _.each( jQuery( '.page' ), function( page ) {
234
  singlePage.push( jQuery( question ).data( 'question-id' ) )
235
  });
236
  pages.push( singlePage );
237
+ /**
238
+ * Prepare qpages Object
239
+ */
240
+ pageInfo = QSMQuestion.qpages.get(jQuery( page ).data('page-id'));
241
+ pageInfo.set('questions', singlePage);
242
+ qpages.push(pageInfo.attributes);
243
  });
244
  var data = {
245
  action: 'qsm_save_pages',
246
  pages: pages,
247
+ qpages: qpages,
248
  quiz_id : qsmQuestionSettings.quizID,
249
  nonce : qsmQuestionSettings.saveNonce,
250
  };
258
  },
259
  savePagesSuccess: function() {
260
  QSMAdmin.displayAlert( 'Questions and pages were saved!', 'success' );
261
+ $('#save-edit-quiz-pages').removeClass('is-active');
262
  },
263
+ addNewPage: function(pageID) {
264
  var template = wp.template( 'page' );
265
+ if (typeof pageID == 'undefined' || pageID == '') {
266
+ var newPageID = QSMQuestion.qpages.length + 1;
267
+ var pageID = newPageID;
268
+ var pageInfo = QSMQuestion.qpages.add({id: newPageID, quizID: qsmQuestionSettings.quizID, pagekey: qsmRandomID(8), hide_prevbtn: 0});
269
+ }
270
+ var pageInfo = QSMQuestion.qpages.get(pageID);
271
+ $( '.questions' ).append( template(pageInfo) );
272
+ var page = $( '.questions' ).find('.page').length;
273
+ $('.page:nth-child(' + page + ')').find('.page-number').text('Page ' + page);
274
  $( '.page' ).sortable({
275
  items: '.question',
276
  opacity: 70,
277
  cursor: 'move',
278
  placeholder: "ui-state-highlight",
279
+ connectWith: '.page',
280
+ stop: function(evt, ui) {
281
+ setTimeout(
282
+ function(){
283
+ $('.save-page-button').trigger('click');
284
+ },
285
+ 200
286
+ )
287
+ }
288
  });
289
  setTimeout( QSMQuestion.removeNew, 250 );
290
  },
291
  addNewQuestion: function( model ) {
292
  QSMAdmin.displayAlert( 'Question created!', 'success' );
293
+ QSMQuestion.addQuestionToPage( model );
294
+ QSMQuestion.openEditPopup( model.id, $( '.question[data-question-id=' + model.id + ']' ).find('.edit-question-button') );
295
  QSMQuestion.countTotal();
296
+ $('#new-answer-button').trigger('click');
297
  },
298
  addQuestionToPage: function( model ) {
299
  var page = model.get( 'page' ) + 1;
301
  var page_exists = $( '.page:nth-child(' + page + ')' ).length;
302
  var count = 0;
303
  while ( ! page_exists ) {
304
+ QSMQuestion.addNewPage(page);
305
  page_exists = $( '.page:nth-child(' + page + ')' ).length;
306
  count++;
307
  if ( count > 5 ) {
309
  console.log( 'count reached' );
310
  }
311
  }
312
+ var questionName = QSMQuestion.prepareQuestionText( model.get( 'name' ) );
313
+ var new_question_title = model.get('question_title');
314
+ if( new_question_title === null || typeof new_question_title === "undefined" || new_question_title === "" ){
315
+ //Do nothing
316
+ }else{
317
+ questionName = new_question_title;
318
+ }
319
  $( '.page:nth-child(' + page + ')' ).append( template( { id: model.id, category : model.get('category'), question: questionName } ) );
320
  setTimeout( QSMQuestion.removeNew, 250 );
321
  },
347
  }
348
  );
349
  },
350
+ saveQuestion: function( questionID, CurrentElement ) {
351
  QSMAdmin.displayAlert( 'Saving question...', 'info' );
352
  var model = QSMQuestion.questions.get( questionID );
353
  var hint = $( '#hint' ).val();
354
  var name = wp.editor.getContent( 'question-text' );
355
+ //Save new question title
356
+ var question_title = $('#question_title').val();
357
+ if(name == '' && question_title == ''){
358
+ alert('Enter Question title or description');
359
  return false;
360
  }
361
+ var advanced_option = {};
362
  var answerInfo = $( '#correct_answer_info' ).val();
363
  var type = $( "#question_type" ).val();
364
+ var comments = $( "#comments" ).val();
365
+ advanced_option['required'] = $("#required").attr("checked") ? 0 : 1;
366
  var category = $( ".category-radio:checked" ).val();
367
  var autofill = $( "#hide_autofill" ).val();
368
  var limit_text = $( "#limit_text" ).val();
389
  answer = wp.editor.getContent( ta_id );
390
  }else{
391
  answer = $answer.find( '.answer-text' ).val().trim();
392
+ answer = $.QSMSanitize( answer );
393
  }
394
 
395
  var points = $answer.find( '.answer-points' ).val();
398
  correct = 1;
399
  }
400
  answers.push( [ answer, points, correct ] );
401
+ });
402
+ $('.questionElements .advanced-content > .qsm-row ').each(function(){
403
+ if( $(this).find('input[type="text"]').length > 0){
404
+ var element_id = $(this).find('input[type="text"]').attr('id');
405
+ advanced_option[element_id] = $(this).find('input[type="text"]').val();
406
+ } else if( $(this).find('input[type="number"]').length > 0 ){
407
+ var element_id = $(this).find('input[type="number"]').attr('id');
408
+ advanced_option[element_id] = $(this).find('input[type="number"]').val();
409
+ }else if( $(this).find('select').length > 0 ){
410
+ var element_id = $(this).find('select').attr('id');
411
+ advanced_option[element_id] = $(this).find('select').val();
412
+ } else if( $(this).find('input[type="checkbox"]').length > 0 ){
413
+ var element_id = $(this).find('input[type="checkbox"]').attr('name');
414
+ var multi_value = $(this).find('input[type="checkbox"]:checked').map(function() { return this.value;}).get().join(',');
415
+ element_id = element_id.replace('[]','');
416
+ advanced_option[element_id] = multi_value;
417
+ }
418
+ });
419
+ model.save(
420
  {
421
  type: type,
422
  name: name,
423
+ question_title: question_title,
424
  answerInfo: answerInfo,
425
  comments: comments,
426
  hint: hint,
427
  category: category,
428
+ //required: required,
429
  answers: answers,
430
  answerEditor: answerType,
431
+ //autofill: autofill,
432
+ //limit_text: limit_text,
433
+ //limit_multiple_response: limit_multiple_response,
434
+ //file_upload_limit: file_upload_limit,
435
+ //file_upload_type: type_arr.join(","),
436
+ other_settings: advanced_option
437
  },
438
  {
439
  headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
442
  type: 'POST'
443
  }
444
  );
445
+ //CurrentElement.parents('.questionElements').slideUp('slow');
446
  },
447
+ saveSuccess: function( model ) {
448
  QSMAdmin.displayAlert( 'Question was saved!', 'success' );
449
  var template = wp.template( 'question' );
450
  var page = model.get( 'page' ) + 1;
451
+ var questionName = model.get('name');
452
+ var new_question_title = model.get('question_title');
453
+ if( new_question_title !== '' ){
454
+ questionName = $.QSMSanitize(new_question_title);
455
+ }
456
+ $( '.question[data-question-id=' + model.id + ']' ).replaceWith( template( { id: model.id, type : model.get('type'), category : model.get('category'), question: questionName } ) );
457
+ setTimeout(function () {
458
+ $('#save-edit-question-spinner').removeClass('is-active');
459
+ }, 250);
460
+ setTimeout(QSMQuestion.removeNew, 250);
461
  },
462
+ addNewAnswer: function( answer ) {
 
463
  var answerTemplate = wp.template( 'single-answer' );
464
+ $( '#answers' ).append( answerTemplate( { answer: decodeEntities( answer[0] ), points: answer[1], correct: answer[2], count: answer[3], question_id: answer[4], answerType: answer[5], form_type: qsmQuestionSettings.form_type, quiz_system: qsmQuestionSettings.quiz_system } ) );
465
  if(answer[5] == 'rich' && qsmQuestionSettings.qsm_user_ve === 'true'){
466
  var textarea_id = 'answer-' + answer[4] + '-' + answer[3];
467
  wp.editor.remove( textarea_id );
479
  tinyMCE.get( textarea_id ).setContent( anser );
480
  }
481
  },
482
+ openEditPopup: function( questionID, CurrentElement ) {
483
+ if( CurrentElement.parents('.question').next('.questionElements').length > 0 ){
484
+ if( CurrentElement.parents('.question').next('.questionElements').is(":visible") ){
485
+ CurrentElement.parents('.question').next('.questionElements').slideUp('slow');
486
+ $( '.questions' ).sortable('enable');+
487
+ $( '.page' ).sortable('enable');
488
+ }else{
489
+ CurrentElement.parents('.question').next('.questionElements').slideDown('slow');
490
+ }
491
+ return;
492
+ }else{
493
+ $('.questions .questionElements').slideDown('slow');
494
+ $('.questions .questionElements').remove();
495
+ }
496
+ //Copy and remove popup div
497
+ var questionElements = $('#modal-1-content').html();
498
+ $('#modal-1-content').children().remove();
499
+ CurrentElement.parents('.question').after( "<div style='display: none;' class='questionElements'>"+ questionElements +"</div>" );
500
+
501
+ //Show question id on question edit screen
502
+ $( '#qsm-question-id' ).text( 'ID: ' + questionID );
503
  QSMQuestion.prepareCategories();
504
  QSMQuestion.processCategories();
505
  var question = QSMQuestion.questions.get( questionID );
507
  $( '#edit_question_id' ).val( questionID );
508
  var question_editor = ''
509
  if(qsmQuestionSettings.qsm_user_ve === 'true'){
510
+ var question_content = 'question-text';
511
+ wp.editor.remove( question_content );
512
+ QSMQuestion.prepareEditor();
513
  question_editor = tinyMCE.get( 'question-text' );
514
  }
515
  if ($('#wp-question-text-wrap').hasClass('html-active')) {
516
  jQuery( "#question-text" ).val( questionText );
517
  } else if ( question_editor ) {
518
+
519
  tinyMCE.get( 'question-text' ).setContent( questionText );
520
  } else {
521
  jQuery( "#question-text" ).val( questionText );
522
  }
523
+
524
  $( '#answers' ).empty();
525
  var answers = question.get( 'answers' );
526
  var answerEditor = question.get( 'answerEditor' );
565
  QSMQuestion.addNewAnswer( answer );
566
  al++;
567
  });
568
+ //get new question type
569
+ var get_question_title = question.get( 'question_title' );
570
+ if( get_question_title === null || typeof get_question_title === "undefined" ){
571
+ get_question_title = '';
 
 
 
572
  }
573
+
574
+ //Hide the question settings based on question type
575
+ $('.qsm_hide_for_other').hide();
576
+ if( $('.qsm_show_question_type_' + question.get('type')).length > 0 ){
577
+ $('.qsm_show_question_type_' + question.get('type')).show();
578
+ }
579
+ qsm_hide_show_question_desc( question.get('type') );
580
  $( '#hint' ).val( question.get( 'hint' ) );
581
  $( '#correct_answer_info' ).val( question.get( 'answerInfo' ) );
582
  $( "#question_type" ).val( question.get( 'type' ) );
583
  $( "#comments" ).val( question.get( 'comments' ) );
584
+ //Changed checked logic based on new structure for required.
585
+ $("input#required[value='" + question.get( 'required' ) + "']").prop('checked', true);
586
+
587
  $( "#hide_autofill" ).val( disableAutofill );
588
  $( "#limit_text" ).val( get_limit_text );
589
  $( "#limit_multiple_response" ).val( get_limit_mr );
591
  $( "#change-answer-editor" ).val( answerEditor );
592
  $( ".category-radio" ).removeAttr( 'checked' );
593
  $( "#edit-question-id" ).text('').text(questionID);
594
+ $( "#question_title" ).val( get_question_title );
595
  if ( 0 !== question.get( 'category' ).length ) {
596
  $( ".category-radio" ).val( [question.get( 'category' )] );
597
+ }
598
+ //Append extra settings
599
+ var all_setting = question.get('settings');
600
+ if( all_setting === null || typeof all_setting === "undefined" ){
601
+ }else{
602
+ $.each(all_setting, function( index, value ) {
603
+ if($('#' + index + '_area').length > 0){
604
+ if($('#' + index + '_area').find('input[type="checkbox"]').length > 1){
605
+ var fut_arr = value.split(",");
606
+ $.each(fut_arr,function(i){
607
+ $("input[name='"+ index +"[]']:checkbox[value='"+ fut_arr[i] +"']").attr("checked","true");
608
+ });
609
+ }else{
610
+ if( value != null)
611
+ $('#' + index).val(value);
612
+ }
613
+ }
614
+ });
615
+ }
616
+ CurrentElement.parents('.question').next('.questionElements').slideDown('slow');
617
+ $('#modal-1-content').html( questionElements );
618
+ //MicroModal.show( 'modal-1' );
619
+ $( '.questions' ).sortable('disable');
620
+ $( '.page' ).sortable('disable');
621
+ },
622
+ openEditPagePopup: function( pageID ) {
623
+ var page = QSMQuestion.qpages.get(pageID);
624
+ $('#edit_page_id').val(pageID);
625
+ $("#edit-page-id").text('').text(pageID);
626
+ jQuery('#page-options').find(':input, select, textarea').each(function(i, field){
627
+ field.value = page.get(field.name);
628
+ });
629
+ MicroModal.show('modal-page-1');
630
  },
631
  removeNew: function() {
632
  $( '.page-new' ).removeClass( 'page-new' );
649
  };
650
 
651
  $(function() {
652
+ QSMQuestion.pageCollection = Backbone.Collection.extend({model: QSMQuestion.page});
653
+ QSMQuestion.qpages = new QSMQuestion.pageCollection();
654
  QSMQuestion.questionCollection = Backbone.Collection.extend({
655
  url: wpApiSettings.root + 'quiz-survey-master/v1/questions',
656
  model: QSMQuestion.question
664
  $( '.questions' ).on( 'click', '.new-question-button', function( event ) {
665
  event.preventDefault();
666
  QSMQuestion.createQuestion( $( this ).parents( '.page' ).index() );
667
+ $('.save-page-button').trigger('click');
668
  });
669
 
670
  $( '.questions' ).on( 'click', '.add-question-bank-button', function( event ) {
686
 
687
  $( '.questions' ).on( 'click', '.edit-question-button', function( event ) {
688
  event.preventDefault();
689
+ QSMQuestion.openEditPopup( $( this ).parents( '.question' ).data( 'question-id' ), $(this) );
690
+ });
691
+ $('.questions').on('click', '.edit-page-button', function (event) {
692
+ event.preventDefault();
693
+ QSMQuestion.openEditPagePopup($(this).parents('.page').data('page-id'));
694
  });
695
 
696
+ $( document ).on( 'click', '.questions .duplicate-question-button', function( event ) {
697
  event.preventDefault();
698
  QSMQuestion.duplicateQuestion( $( this ).parents( '.question' ).data( 'question-id' ) );
699
+ $('.save-page-button').trigger('click');
700
  });
701
  $( '.questions' ).on( 'click', '.delete-question-button', function( event ) {
702
+ event.preventDefault();
703
+ if( confirm('Are you sure?') ){
704
+ $( this ).parents( '.question' ).remove();
705
+ QSMQuestion.countTotal();
706
+ $('.save-page-button').trigger('click');
707
+ }
708
  });
709
  $( '.questions' ).on( 'click', '.delete-page-button', function( event ) {
710
  event.preventDefault();
711
+ if( confirm('Are you sure?') ){
712
+ $( this ).parents( '.page' ).remove();
713
+ $('.save-page-button').trigger('click');
714
+ }
715
  });
716
+ $( document ).on( 'click', '#answers .delete-answer-button', function( event ) {
717
  event.preventDefault();
718
  $( this ).parents( '.answers-single' ).remove();
719
  });
720
+ $( document ).on( 'click', '#delete-action .deletion', function( event ) {
721
  event.preventDefault();
722
+ $( this ).parents( '.questionElements' ).slideUp('slow');
 
723
  });
724
+ $( document ).on( 'click', '#save-popup-button', function( event ) {
725
+ event.preventDefault();
726
+ $('#save-edit-question-spinner').addClass('is-active');
727
+ var model_html = $('#modal-1-content').html();
728
+ $('#modal-1-content').children().remove();
729
+ QSMQuestion.saveQuestion( $( this ).parents('.questionElements').children( '#edit_question_id' ).val(), $(this) );
730
+ $('.save-page-button').trigger('click');
731
+ $('#modal-1-content').html( model_html );
732
+ });
733
+ $( document ).on( 'click', '#new-answer-button', function( event ) {
734
  event.preventDefault();
735
  var answer_length = $( '#answers' ).find('.answers-single').length;
736
  if( answer_length > 1 && $('#question_type').val() == 13 ){
748
  $(this).text('').text('Adding Question');
749
  import_button = $(this);
750
  QSMQuestion.addQuestionFromQuestionBank( $( this ).parents( '.question-bank-question' ).data( 'question-id' ) );
751
+ $('.import-button').addClass('disable_import');
752
  });
753
 
754
  //Click on selected question button.
764
  QSMQuestion.addQuestionFromQuestionBank( $( this ).data( 'question-id' ) );
765
  $(this).find('.import-button').text('').text('Add Question');
766
  });
767
+ $('.import-button').addClass('disable_import');
768
+ $('#question-bank').find('[name="qsm-question-checkbox[]"]').attr('checked',false);
769
  }
770
  });
771
 
772
  $( '.save-page-button' ).on( 'click', function( event ) {
773
  event.preventDefault();
774
+ $('#save-edit-quiz-pages').addClass('is-active');
775
  QSMQuestion.savePages();
776
  });
777
+ $('#save-page-popup-button').on('click', function (event) {
778
+ event.preventDefault();
779
+ var pageID = $(this).parent().siblings('main').children('#edit_page_id').val();
780
+ var pageKey = jQuery('#pagekey').val();
781
+ if (pageKey.replace(/^\s+|\s+$/g, "").length == 0) {
782
+ alert('Page Name is required!');
783
+ return false;
784
+ } else if (null == pageKey.match(/^[A-Za-z0-9\-\s]+$/)) {
785
+ alert('Please use only Alphanumeric characters.');
786
+ return false;
787
+ } else {
788
+ QSMQuestion.updateQPage(pageID);
789
+ QSMQuestion.savePages();
790
+ MicroModal.close('modal-page-1');
791
+ }
792
+ });
793
 
794
  $( document ).on( 'change', '#change-answer-editor', function( event ) {
795
  var newVal = $(this).val();
827
  }
828
  });
829
 
830
+ qsm_init_sortable();
831
+
 
 
 
 
 
 
 
 
 
 
832
  if(qsmQuestionSettings.qsm_user_ve === 'true'){
833
  QSMQuestion.prepareEditor();
834
  }
847
  }
848
  });
849
  });
850
+
851
  //Hide the question settings based on question type
852
  $(document).on('change','#question_type', function(){
853
  var question_val = $(this).val();
854
+ $('.qsm_hide_for_other').hide();
855
+ if( $('.qsm_show_question_type_' + question_val).length > 0 ){
856
+ $('.qsm_show_question_type_' + question_val).show();
857
+ }
858
+ qsm_hide_show_question_desc( question_val );
859
+ });
860
+
861
+ //Add new category
862
+ $( document ).on('click', '#qsm-category-add-toggle', function(){
863
+ if( $( '#qsm-category-add' ).is(":visible") ){
864
+ $('#new_category_new').attr('checked', false);
865
+ $( '#qsm-category-add' ).slideUp('slow');
866
  }else{
867
+ $('#new_category_new').attr('checked', true);
868
+ $( '#qsm-category-add' ).slideDown('slow');
869
  }
870
+ });
871
  });
872
  var decodeEntities = (function () {
873
  //create a new html document (doesn't execute script tags in child elements)
893
  }
894
  return decodeHTMLEntities;
895
  })();
896
+
897
+ function qsm_hide_show_question_desc(question_type){
898
+ $('.question-type-description').hide();
899
+ if( $('#question_type_' + question_type + '_description').length > 0 ){
900
+ $('#question_type_' + question_type + '_description').show();
901
+ }
902
+ }
903
+
904
+ function qsm_init_sortable(){
905
+ $( '.questions' ).sortable({
906
+ opacity: 70,
907
+ cursor: 'move',
908
+ placeholder: "ui-state-highlight",
909
+ stop: function(evt, ui) {
910
+ $('.questions > .page').each(function(){
911
+ var page = parseInt($(this).index()) + 1;
912
+ $(this).find('.page-number').text( 'Page ' + page );
913
+ });
914
+ setTimeout(
915
+ function(){
916
+ $('.save-page-button').trigger('click');
917
+ },
918
+ 200
919
+ )
920
+ }
921
+ });
922
+ $( '.page' ).sortable({
923
+ items: '.question',
924
+ opacity: 70,
925
+ cursor: 'move',
926
+ placeholder: "ui-state-highlight",
927
+ connectWith: '.page',
928
+ stop: function(evt, ui) {
929
+ setTimeout(
930
+ function(){
931
+ $('.save-page-button').trigger('click');
932
+ },
933
+ 200
934
+ )
935
+ }
936
+ });
937
+ }
938
+ function qsmRandomID(length) {
939
+ var result = '';
940
+ var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
941
+ var charactersLength = characters.length;
942
+ for (var i = 0; i < length; i++) {
943
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
944
+ }
945
+ return result;
946
+ }
947
  }(jQuery));
js/qsm-admin-results.js CHANGED
@@ -39,23 +39,23 @@ var QSMAdminResults;
39
  data: data,
40
  headers: { 'X-WP-Nonce': qsmResultsObject.nonce },
41
  })
42
- .done(function( results ) {
43
  if ( results.status ) {
44
  QSMAdmin.displayAlert( 'Results pages were saved!', 'success' );
45
  } else {
46
  QSMAdmin.displayAlert( 'There was an error when saving the results pages. Please try again.', 'error' );
47
- }
48
- $('.save-pages').next('.spinner').removeClass('is-active');
49
  })
50
  .fail(QSMAdmin.displayjQueryError);
51
  },
52
  loadResults: function() {
53
- QSMAdmin.displayAlert( 'Loading results pages...', 'info' );
54
  $.ajax({
55
  url: wpApiSettings.root + 'quiz-survey-master/v1/quizzes/' + qsmResultsObject.quizID + '/results',
56
  headers: { 'X-WP-Nonce': qsmResultsObject.nonce },
57
  })
58
  .done(function( pages ) {
 
59
  pages.forEach( function( page, i, pages ) {
60
  QSMAdminResults.addResultsPage( page.conditions, page.page, page.redirect );
61
  });
@@ -114,8 +114,7 @@ var QSMAdminResults;
114
  QSMAdminResults.newResultsPage();
115
  });
116
  $( '.save-pages' ).on( 'click', function( event ) {
117
- event.preventDefault();
118
- $(this).next('.spinner').addClass('is-active');
119
  QSMAdminResults.saveResults();
120
  });
121
  $( '#results-pages' ).on( 'click', '.new-condition', function( event ) {
39
  data: data,
40
  headers: { 'X-WP-Nonce': qsmResultsObject.nonce },
41
  })
42
+ .done(function( results ) {
43
  if ( results.status ) {
44
  QSMAdmin.displayAlert( 'Results pages were saved!', 'success' );
45
  } else {
46
  QSMAdmin.displayAlert( 'There was an error when saving the results pages. Please try again.', 'error' );
47
+ }
 
48
  })
49
  .fail(QSMAdmin.displayjQueryError);
50
  },
51
  loadResults: function() {
52
+ //QSMAdmin.displayAlert( 'Loading results pages...', 'info' );
53
  $.ajax({
54
  url: wpApiSettings.root + 'quiz-survey-master/v1/quizzes/' + qsmResultsObject.quizID + '/results',
55
  headers: { 'X-WP-Nonce': qsmResultsObject.nonce },
56
  })
57
  .done(function( pages ) {
58
+ $( '#results-pages' ).find( '.qsm-spinner-loader' ).remove();
59
  pages.forEach( function( page, i, pages ) {
60
  QSMAdminResults.addResultsPage( page.conditions, page.page, page.redirect );
61
  });
114
  QSMAdminResults.newResultsPage();
115
  });
116
  $( '.save-pages' ).on( 'click', function( event ) {
117
+ event.preventDefault();
 
118
  QSMAdminResults.saveResults();
119
  });
120
  $( '#results-pages' ).on( 'click', '.new-condition', function( event ) {
js/qsm-admin.js CHANGED
@@ -7,14 +7,17 @@ var QSMQuizzesSurveys;
7
  QSMQuizzesSurveys = {
8
  load: function() {
9
  if ( 0 !== qsmQuizObject.length ) {
10
- $.each( qsmQuizObject, function( i, val ) {
11
- QSMQuizzesSurveys.addQuizRow( val );
12
- });
13
- $( '#the-list tr' ).filter( ':even' ).addClass( 'alternate' );
14
  } else {
15
- var template = wp.template( 'no-quiz' );
16
- $( '.qsm-quizzes-page-content' ).hide();
17
- $( '#new_quiz_button' ).parent().after( template() );
 
 
 
 
 
 
18
  }
19
  },
20
  addQuizRow: function( quizData ) {
@@ -76,30 +79,70 @@ var QSMQuizzesSurveys;
76
  },
77
  };
78
  $(function() {
79
- $( '#new_quiz_button, #new_quiz_button_two' ).on( 'click', function( event ) {
80
  event.preventDefault();
81
  MicroModal.show( 'modal-2' );
82
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  $( '#show_import_export_popup' ).on( 'click', function( event ) {
84
  event.preventDefault();
85
  MicroModal.show( 'modal-export-import' );
86
  });
87
- $( '#quiz_search' ).keyup( function() {
88
  QSMQuizzesSurveys.searchQuizzes( $( this ).val() );
89
- });
90
- $( '#the-list' ).on( 'click', '.qsm-action-link-delete', function( event ) {
91
  event.preventDefault();
92
  QSMQuizzesSurveys.deleteQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
93
  });
94
- $( '#the-list' ).on( 'click', '.qsm-action-link-duplicate', function( event ) {
95
  event.preventDefault();
96
  QSMQuizzesSurveys.duplicateQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
97
  });
98
- $( '#the-list' ).on( 'click', '.qsm-edit-name', function( event ) {
99
  event.preventDefault();
100
  QSMQuizzesSurveys.editQuizName( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
101
  });
102
- $( '#the-list' ).on( 'click', '.qsm-action-link-reset', function( event ) {
103
  event.preventDefault();
104
  QSMQuizzesSurveys.openResetPopup( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
105
  });
@@ -108,8 +151,13 @@ var QSMQuizzesSurveys;
108
  $( '#reset_quiz_form' ).submit();
109
  });
110
  $( '#create-quiz-button' ).on( 'click', function( event ) {
111
- event.preventDefault();
112
- $( '#new-quiz-form' ).submit();
 
 
 
 
 
113
  });
114
  $( '#duplicate-quiz-button' ).on( 'click', function( event ) {
115
  event.preventDefault();
@@ -120,20 +168,23 @@ var QSMQuizzesSurveys;
120
  $( '#delete-quiz-form' ).submit();
121
  });
122
  QSMQuizzesSurveys.load();
123
- $(document).on('click','.sc-opener',function(){
124
- var $this = $(this);
125
- var shortcode_text = $this.next('.sc-content').text();
126
- $('#sc-shortcode-model-text').val(shortcode_text);
127
- MicroModal.show( 'modal-6' );
128
- });
129
- $(document).on('click','#sc-copy-shortcode', function(){
130
-
131
- var copyText = document.getElementById("sc-shortcode-model-text");
132
-
133
- copyText.select();
134
- /* Copy the text inside the text field */
135
- document.execCommand("copy");
136
-
137
  });
 
 
 
 
 
138
  });
139
  }(jQuery));
7
  QSMQuizzesSurveys = {
8
  load: function() {
9
  if ( 0 !== qsmQuizObject.length ) {
10
+ // Do nothing
 
 
 
11
  } else {
12
+ var queryString = window.location.search;
13
+ var urlParams = new URLSearchParams(queryString);
14
+ if( urlParams.has('paged') || urlParams.has('s') ){
15
+ //do nothing
16
+ }else{
17
+ var template = wp.template( 'no-quiz' );
18
+ $( '.qsm-quizzes-page-content' ).hide();
19
+ $( '#new_quiz_button' ).parent().after( template() );
20
+ }
21
  }
22
  },
23
  addQuizRow: function( quizData ) {
79
  },
80
  };
81
  $(function() {
82
+ $( '#new_quiz_button_two' ).on( 'click', function( event ) {
83
  event.preventDefault();
84
  MicroModal.show( 'modal-2' );
85
  });
86
+ $( document ).on( 'click', '.qsm-wizard-noquiz',function( event ) {
87
+ event.preventDefault();
88
+ $('#new_quiz_button').trigger('click');
89
+ });
90
+ $( document ).on( 'click', '#new_quiz_button', function( e ) {
91
+ e.preventDefault();
92
+ MicroModal.show('model-wizard');
93
+ var height = jQuery(".qsm-wizard-template-section").css("height");
94
+ jQuery(".qsm-wizard-setting-section").css("height", height);
95
+ if(jQuery( "#accordion" ).length > 0){
96
+ var icons = {
97
+ header: "iconClosed", // custom icon class
98
+ activeHeader: "iconOpen" // custom icon class
99
+ };
100
+ jQuery( "#accordion" ).accordion({
101
+ collapsible: true,
102
+ icons: icons,
103
+ heightStyle: "content"
104
+ });
105
+ jQuery('.template-list .template-list-inner:first-child').trigger('click');
106
+ }
107
+ });
108
+ //Get quiz options
109
+ $('.template-list-inner').click(function(){
110
+ var action = 'qsm_wizard_template_quiz_options';
111
+ var settings = $(this).data('settings');
112
+ var addons = $(this).data('addons');
113
+ $('.template-list .template-list-inner').removeClass('selected-quiz-template');
114
+ $(this).addClass('selected-quiz-template');
115
+ $.post(ajaxurl, {settings: settings, addons: addons, action: action },
116
+ function (data) {
117
+ var diff_html = data.split('=====');
118
+ $('#quiz_settings_wrapper').html('');
119
+ $('#quiz_settings_wrapper').html(diff_html[0]);
120
+ $('#recomm_addons_wrapper').html('');
121
+ $('#recomm_addons_wrapper').html(diff_html[1]);
122
+ $( "#accordion" ).accordion();
123
+ }
124
+ );
125
+ });
126
  $( '#show_import_export_popup' ).on( 'click', function( event ) {
127
  event.preventDefault();
128
  MicroModal.show( 'modal-export-import' );
129
  });
130
+ /*$( '#quiz_search' ).keyup( function() {
131
  QSMQuizzesSurveys.searchQuizzes( $( this ).val() );
132
+ });*/
133
+ $( document ).on( 'click', '#the-list .qsm-action-link-delete', function( event ) {
134
  event.preventDefault();
135
  QSMQuizzesSurveys.deleteQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
136
  });
137
+ $( document ).on( 'click', '#the-list .qsm-action-link-duplicate', function( event ) {
138
  event.preventDefault();
139
  QSMQuizzesSurveys.duplicateQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
140
  });
141
+ $( document ).on( 'click', '#the-list .qsm-edit-name', function( event ) {
142
  event.preventDefault();
143
  QSMQuizzesSurveys.editQuizName( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
144
  });
145
+ $( document ).on( 'click', '#the-list .qsm-action-link-reset', function( event ) {
146
  event.preventDefault();
147
  QSMQuizzesSurveys.openResetPopup( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
148
  });
151
  $( '#reset_quiz_form' ).submit();
152
  });
153
  $( '#create-quiz-button' ).on( 'click', function( event ) {
154
+ if( $('#new-quiz-form').find('.quiz_name').val() === ''){
155
+ $('#new-quiz-form').find('.quiz_name').addClass('qsm-required');
156
+ $('#new-quiz-form').find('.quiz_name').focus();
157
+ return;
158
+ }
159
+ event.preventDefault();
160
+ $( '#new-quiz-form' ).submit();
161
  });
162
  $( '#duplicate-quiz-button' ).on( 'click', function( event ) {
163
  event.preventDefault();
168
  $( '#delete-quiz-form' ).submit();
169
  });
170
  QSMQuizzesSurveys.load();
171
+ $(document).on('click','.qsm-list-shortcode-view',function(e){
172
+ e.preventDefault();
173
+ var embed_text = $(this).siblings('.sc-embed').text();
174
+ var link_text = $(this).siblings('.sc-link').text();
175
+ $('#sc-shortcode-model-text').val( embed_text );
176
+ $('#sc-shortcode-model-text-link').val( link_text );
177
+ MicroModal.show( 'modal-6' );
178
+ });
179
+ $(document).on('click','#sc-copy-shortcode', function(){
180
+ var copyText = document.getElementById("sc-shortcode-model-text");
181
+ copyText.select();
182
+ document.execCommand("copy");
 
 
183
  });
184
+ $(document).on('click','#sc-copy-shortcode-link', function(){
185
+ var copyText = document.getElementById("sc-shortcode-model-text-link");
186
+ copyText.select();
187
+ document.execCommand("copy");
188
+ });
189
  });
190
  }(jQuery));
js/qsm-quiz.js CHANGED
@@ -8,6 +8,7 @@
8
  **************************/
9
 
10
  var QSM;
 
11
  (function ($) {
12
  QSM = {
13
  /**
@@ -16,10 +17,15 @@ var QSM;
16
  init: function() {
17
  // Makes sure we have quizzes on this page
18
  if ( typeof qmn_quiz_data != 'undefined' && qmn_quiz_data) {
 
 
19
  // Cycle through all quizzes
20
  _.each( qmn_quiz_data, function( quiz ) {
21
  quizID = parseInt( quiz.quiz_id );
22
  QSM.initPagination( quizID );
 
 
 
23
  if ( quiz.hasOwnProperty( 'timer_limit' ) && 0 != quiz.timer_limit ) {
24
  QSM.initTimer( quizID );
25
  }
@@ -35,58 +41,58 @@ var QSM;
35
  initTimer: function( quizID ) {
36
 
37
  // Gets our form
38
- var $quizForm = QSM.getQuizForm( quizID );
39
 
40
  // Creates timer status key.
41
  qmn_quiz_data[ quizID ].timerStatus = false;
42
 
43
  // If we are using the newer pagination system...
44
- if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
45
  // If there is a first page...
46
- if ( qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page ) {
47
  // ... attach an event handler to the click event to activate the timer.
48
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
49
  event.preventDefault();
50
- if(qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')){
51
- var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
52
-
53
- if( $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.qmn_pagination > .current_page_hidden').val() == start_timer){
54
- QSM.activateTimer( quizID );
55
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.stoptimer-p').show();
56
- }
57
- }else{
58
- if ( ! qmn_quiz_data[ quizID ].timerStatus && qmnValidatePage( 'quizForm' + quizID ) ) {
59
- QSM.activateTimer( quizID );
60
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.stoptimer-p').show();
61
  }
62
  }
63
  });
64
  // ...else, activate the timer on page load.
65
  } else {
66
- QSM.activateTimer( quizID );
67
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.stoptimer-p').show();
68
  }
69
  // ...else, we must be using the questions per page option.
70
  } else {
71
- if ( qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page ) {
72
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
73
  event.preventDefault();
74
- if(qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')){
75
- var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
76
- if( $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.qmn_pagination > .current_page_hidden').val() == start_timer){
77
- QSM.activateTimer( quizID );
78
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.stoptimer-p').show();
79
- }
80
- }else{
81
- if ( ! qmn_quiz_data[ quizID ].timerStatus && ( 0 == $( '.quiz_begin:visible' ).length || ( 1 == $( '.quiz_begin:visible' ).length && qmnValidatePage( 'quizForm' + quizID ) ) ) ) {
82
- QSM.activateTimer( quizID );
83
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.stoptimer-p').show();
84
- }
85
- }
 
86
  });
87
  } else {
88
- QSM.activateTimer( quizID );
89
- $( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.stoptimer-p').show();
90
  }
91
  }
92
  },
@@ -257,15 +263,15 @@ var QSM;
257
  */
258
  initPagination: function( quizID ) {
259
  var $quizForm = QSM.getQuizForm( quizID );
260
- if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
261
  $quizForm.children( '.qsm-page' ).hide();
262
  template = wp.template( 'qsm-pagination' );
263
  $quizForm.append( template() );
264
- if( $quizForm.find( '.qsm-pagination > .current_page_hidden' ).length == 0){
265
- $quizForm.find( '.qsm-pagination' ).append( '<input type="hidden" value="0" name="current_page" class="current_page_hidden" />');
266
- }
267
  if ( '1' == qmn_quiz_data[ quizID ].progress_bar ) {
268
- $('#quizForm' + quizID).find('.qsm-progress-bar').show();
269
  qmn_quiz_data[ quizID ].bar = new ProgressBar.Line('#quizForm' + quizID + ' .qsm-progress-bar', {
270
  strokeWidth: 2,
271
  easing: 'easeInOut',
@@ -291,7 +297,7 @@ var QSM;
291
  from: {color: '#3498db'},
292
  to: {color: '#ED6A5A'},
293
  step: function(state, bar) {
294
- //bar.setText(Math.round(bar.value() * 100) + ' %');
295
  }
296
  });
297
  }
@@ -299,14 +305,14 @@ var QSM;
299
  $quizForm.find( '.qsm-pagination .qsm-next' ).on( 'click', function( event ) {
300
  event.preventDefault();
301
  QSM.nextPage( quizID );
302
- var $container = jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' );
303
- qsmScrollTo( $container );
304
  });
305
  $quizForm.find( '.qsm-pagination .qsm-previous' ).on( 'click', function( event ) {
306
  event.preventDefault();
307
  QSM.prevPage( quizID );
308
- var $container = jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' );
309
- qsmScrollTo( $container );
310
  });
311
  }
312
  },
@@ -318,20 +324,32 @@ var QSM;
318
  goToPage: function( quizID, pageNumber ) {
319
  var $quizForm = QSM.getQuizForm( quizID );
320
  var $pages = $quizForm.children( '.qsm-page' );
 
321
  $pages.hide();
322
- $quizForm.children( '.qsm-page:nth-of-type(' + pageNumber + ')' ).show();
323
- $quizForm.find('.current_page_hidden').val( pageNumber - 1 );
 
 
 
 
 
 
324
  $quizForm.find( '.qsm-previous' ).hide();
325
  $quizForm.find( '.qsm-next' ).hide();
326
  $quizForm.find( '.qsm-submit-btn' ).hide();
 
327
  if ( pageNumber < $pages.length ) {
328
  $quizForm.find( '.qsm-next' ).show();
329
  } else {
330
  $quizForm.find( '.qsm-submit-btn' ).show();
 
331
  }
332
  if ( 1 < pageNumber ) {
333
  $quizForm.find( '.qsm-previous' ).show();
334
  }
 
 
 
335
  if ( '1' == qmn_quiz_data[ quizID ].progress_bar ) {
336
  var current_page = jQuery('#quizForm' + quizID).find('.current_page_hidden').val();
337
  var total_page_length = $pages.length - 1;
@@ -411,6 +429,148 @@ var QSM;
411
  }
412
  };
413
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  // On load code
415
  $(function() {
416
 
@@ -542,7 +702,7 @@ function qmnValidation( element, quiz_form_id ) {
542
  result = false;
543
  }
544
  }
545
- if( jQuery( this ).attr( 'class' ).indexOf( 'mlwRequiredFileUpload' ) > -1 ) {
546
  var selected_file = jQuery( this ).get(0).files.length;
547
  if ( selected_file === 0 ) {
548
  qmnDisplayError( empty_error, jQuery( this ), quiz_form_id );
@@ -562,12 +722,12 @@ function qmnValidation( element, quiz_form_id ) {
562
  result = false;
563
  }
564
  }
565
- //Google recaptcha validation
566
  if( jQuery( this ).attr( 'class' ).indexOf( 'g-recaptcha-response' ) > -1 ) {
567
- if(grecaptcha.getResponse() == "") {
568
- alert('ReCaptcha is missing');
569
- result = false;
570
- }
571
  }
572
  }
573
  }
@@ -615,6 +775,9 @@ function qmnFormSubmit( quiz_form_id ) {
615
 
616
 
617
  qsmEndTimeTakenTimer();
 
 
 
618
  if ( qmn_quiz_data[quiz_id].hasOwnProperty( 'timer_limit' ) ) {
619
  QSM.endTimer( quiz_id );
620
  }
@@ -705,9 +868,9 @@ function qmnNextSlide( pagination, go_to_top, quiz_form_id ) {
705
  var slide_number = +$container.find( '.slide_number_hidden' ).val();
706
  var previous = +$container.find( '.previous_amount_hidden' ).val();
707
  var section_totals = +$container.find( '.total_sections_hidden' ).val();
708
- if(pagination == 1){
709
- section_totals = section_totals - 1;
710
- }
711
  jQuery( quiz_form_id + " .quiz_section" ).hide();
712
  for ( var i = 0; i < pagination; i++ ) {
713
  if (i === 0 && previous === 1 && slide_number > 1) {
@@ -719,27 +882,31 @@ function qmnNextSlide( pagination, go_to_top, quiz_form_id ) {
719
  slide_number = 1;
720
  }
721
  $container.find( ".mlw_qmn_quiz_link.mlw_previous" ).hide();
722
-
723
- if (qmn_quiz_data[ quiz_id ].first_page) {
724
- if (slide_number > 1) {
725
- $container.find(".mlw_qmn_quiz_link.mlw_previous").show();
726
- }
727
- } else {
728
- if (slide_number > pagination) {
729
- $container.find(".mlw_qmn_quiz_link.mlw_previous").show();
730
- }
731
- }
732
- if (slide_number == section_totals) {
733
- $container.find(".mlw_qmn_quiz_link.mlw_next").hide();
734
- if(pagination == 1){
735
- jQuery(quiz_form_id + " .quiz_section.quiz_end").show();
736
- }
737
- }
738
- if (slide_number < section_totals) {
739
- $container.find(".mlw_qmn_quiz_link.mlw_next").show();
740
- }
741
- jQuery(quiz_form_id + " .quiz_section.slide" + slide_number).show();
742
- }
 
 
 
 
743
 
744
  jQuery( quiz_form_id ).closest( '.qmn_quiz_container' ).find( '.slide_number_hidden' ).val( slide_number );
745
  jQuery( quiz_form_id ).closest( '.qmn_quiz_container' ).find( '.previous_amount_hidden' ).val( 0 );
@@ -778,6 +945,8 @@ function qmnPrevSlide( pagination, go_to_top, quiz_form_id ) {
778
  var section_totals = +$container.find( '.total_sections_hidden' ).val();
779
 
780
  jQuery( quiz_form_id + " .quiz_section" ).hide();
 
 
781
  for (var i = 0; i < pagination; i++) {
782
  if (i === 0 && previous === 0) {
783
  slide_number = slide_number - pagination;
@@ -806,6 +975,9 @@ function qmnPrevSlide( pagination, go_to_top, quiz_form_id ) {
806
  $container.find( ".mlw_qmn_quiz_link.mlw_next" ).show();
807
  }
808
  jQuery( quiz_form_id + " .quiz_section.slide" + slide_number ).show();
 
 
 
809
  }
810
 
811
  qmnUpdatePageNumber( -1, quiz_form_id );
@@ -879,7 +1051,6 @@ function qmnUpdatePageNumber( amount, quiz_form_id ) {
879
  }
880
 
881
  function qmnInitPagination( quiz_id ) {
882
-
883
  var qmn_section_total = +qmn_quiz_data[quiz_id].pagination.total_questions + 1;
884
  if ( qmn_quiz_data[quiz_id].pagination.section_comments === '0' ) {
885
  qmn_section_total += 1;
@@ -954,6 +1125,7 @@ function qmnInitPagination( quiz_id ) {
954
  } else {
955
  qmnNextSlide( qmn_quiz_data[quiz_id].pagination.amount, 0, '#quizForm' + quiz_id );
956
  }
 
957
  }
958
 
959
  function qmnSocialShare( network, mlw_qmn_social_text, mlw_qmn_title, facebook_id, share_url ) {
@@ -1037,9 +1209,9 @@ jQuery(function() {
1037
  success: function (response) {
1038
  $this.find('.quick-question-res-p').remove();
1039
  if(response == 'correct'){
1040
- $this.append('<p style="color: green" class="quick-question-res-p"><b>Correct!</b> You have selected correct answer.</p>')
1041
  }else if(response == 'incorrect'){
1042
- $this.append('<p style="color: red" class="quick-question-res-p"><b>Wrong!</b> You have selected wrong answer.</p>')
1043
  }
1044
  },
1045
  error: function (errorThrown) {
@@ -1137,7 +1309,15 @@ jQuery(function() {
1137
  // Triggger the click event on the quiz form's submit button.
1138
  jQuery( '.qsm-submit-btn' ).trigger( 'click' );
1139
  jQuery('#modal-3').removeClass('is-open');
1140
- } );
 
 
 
 
 
 
 
 
1141
  });
1142
 
1143
  var qsmTimerInterval = setInterval( qmnTimeTakenTimer, 1000 );
8
  **************************/
9
 
10
  var QSM;
11
+ var QSMPageTimer;
12
  (function ($) {
13
  QSM = {
14
  /**
17
  init: function() {
18
  // Makes sure we have quizzes on this page
19
  if ( typeof qmn_quiz_data != 'undefined' && qmn_quiz_data) {
20
+ // hide the recaptcha by default
21
+ $( '.g-recaptcha' ).hide();
22
  // Cycle through all quizzes
23
  _.each( qmn_quiz_data, function( quiz ) {
24
  quizID = parseInt( quiz.quiz_id );
25
  QSM.initPagination( quizID );
26
+ if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
27
+ QSMPageTimer.endPageTimer(quizID, true);
28
+ }
29
  if ( quiz.hasOwnProperty( 'timer_limit' ) && 0 != quiz.timer_limit ) {
30
  QSM.initTimer( quizID );
31
  }
41
  initTimer: function( quizID ) {
42
 
43
  // Gets our form
44
+ var $quizForm = QSM.getQuizForm(quizID);
45
 
46
  // Creates timer status key.
47
  qmn_quiz_data[ quizID ].timerStatus = false;
48
 
49
  // If we are using the newer pagination system...
50
+ if (0 < $quizForm.children('.qsm-page').length) {
51
  // If there is a first page...
52
+ if (qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page) {
53
  // ... attach an event handler to the click event to activate the timer.
54
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.mlw_next').on('click', function (event) {
55
  event.preventDefault();
56
+ if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
57
+ var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
58
+ if ($('#quizForm' + quizID).closest('.qmn_quiz_container').find('.qmn_pagination > .current_page_hidden').val() == start_timer) {
59
+ QSM.activateTimer(quizID);
60
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
61
+ }
62
+ } else {
63
+ if ( ! qmn_quiz_data[ quizID ].timerStatus && qmnValidatePage( 'quizForm' + quizID ) ) {
64
+ QSM.activateTimer(quizID);
65
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
 
66
  }
67
  }
68
  });
69
  // ...else, activate the timer on page load.
70
  } else {
71
+ QSM.activateTimer(quizID);
72
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
73
  }
74
  // ...else, we must be using the questions per page option.
75
  } else {
76
+ if (qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page) {
77
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.mlw_next').on('click', function (event) {
78
  event.preventDefault();
79
+ if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
80
+ var start_timer = parseInt(qmn_quiz_data[quizID].advanced_timer.start_timer_page);
81
+
82
+ if ($('#quizForm' + quizID).closest('.qmn_quiz_container').find('.qmn_pagination > .current_page_hidden').val() == start_timer) {
83
+ QSM.activateTimer(quizID);
84
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
85
+ }
86
+ } else {
87
+ if (!qmn_quiz_data[ quizID ].timerStatus && (0 == $('.quiz_begin:visible').length || (1 == $('.quiz_begin:visible').length && qmnValidatePage('quizForm' + quizID)))) {
88
+ QSM.activateTimer(quizID);
89
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
90
+ }
91
+ }
92
  });
93
  } else {
94
+ QSM.activateTimer(quizID);
95
+ $('#quizForm' + quizID).closest('.qmn_quiz_container').find('.stoptimer-p').show();
96
  }
97
  }
98
  },
263
  */
264
  initPagination: function( quizID ) {
265
  var $quizForm = QSM.getQuizForm( quizID );
266
+ if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
267
  $quizForm.children( '.qsm-page' ).hide();
268
  template = wp.template( 'qsm-pagination' );
269
  $quizForm.append( template() );
270
+ if( $quizForm.find( '.qsm-pagination > .current_page_hidden' ).length == 0){
271
+ $quizForm.find( '.qsm-pagination' ).append( '<input type="hidden" value="0" name="current_page" class="current_page_hidden" />');
272
+ }
273
  if ( '1' == qmn_quiz_data[ quizID ].progress_bar ) {
274
+ $('#quizForm' + quizID).find('.qsm-progress-bar').show();
275
  qmn_quiz_data[ quizID ].bar = new ProgressBar.Line('#quizForm' + quizID + ' .qsm-progress-bar', {
276
  strokeWidth: 2,
277
  easing: 'easeInOut',
297
  from: {color: '#3498db'},
298
  to: {color: '#ED6A5A'},
299
  step: function(state, bar) {
300
+ //bar.setText(Math.round(bar.value() * 100) + ' %');
301
  }
302
  });
303
  }
305
  $quizForm.find( '.qsm-pagination .qsm-next' ).on( 'click', function( event ) {
306
  event.preventDefault();
307
  QSM.nextPage( quizID );
308
+ var $container = jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' );
309
+ qsmScrollTo( $container );
310
  });
311
  $quizForm.find( '.qsm-pagination .qsm-previous' ).on( 'click', function( event ) {
312
  event.preventDefault();
313
  QSM.prevPage( quizID );
314
+ var $container = jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' );
315
+ qsmScrollTo( $container );
316
  });
317
  }
318
  },
324
  goToPage: function( quizID, pageNumber ) {
325
  var $quizForm = QSM.getQuizForm( quizID );
326
  var $pages = $quizForm.children( '.qsm-page' );
327
+ var $currentPage = $quizForm.children( '.qsm-page:nth-of-type(' + pageNumber + ')' );
328
  $pages.hide();
329
+ $currentPage.show();
330
+
331
+ if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
332
+ QSMPageTimer.endPageTimer(quizID);
333
+ QSMPageTimer.initPageTimer(quizID, $currentPage);
334
+ }
335
+
336
+ $quizForm.find('.current_page_hidden').val( pageNumber - 1 );
337
  $quizForm.find( '.qsm-previous' ).hide();
338
  $quizForm.find( '.qsm-next' ).hide();
339
  $quizForm.find( '.qsm-submit-btn' ).hide();
340
+ $quizForm.find( '.g-recaptcha' ).hide();
341
  if ( pageNumber < $pages.length ) {
342
  $quizForm.find( '.qsm-next' ).show();
343
  } else {
344
  $quizForm.find( '.qsm-submit-btn' ).show();
345
+ $quizForm.find( '.g-recaptcha' ).show();
346
  }
347
  if ( 1 < pageNumber ) {
348
  $quizForm.find( '.qsm-previous' ).show();
349
  }
350
+ if (1 == $currentPage.data('prevbtn')) {
351
+ $quizForm.find( '.qsm-previous' ).hide();
352
+ }
353
  if ( '1' == qmn_quiz_data[ quizID ].progress_bar ) {
354
  var current_page = jQuery('#quizForm' + quizID).find('.current_page_hidden').val();
355
  var total_page_length = $pages.length - 1;
429
  }
430
  };
431
 
432
+ QSMPageTimer = {
433
+ /**
434
+ * Init Page Timer
435
+ */
436
+ initPageTimer: function (quizID, $currentpage) {
437
+ var $quizForm = QSM.getQuizForm(quizID);
438
+ var pid = $currentpage.data('pid');
439
+ if (undefined != pid) {
440
+ var $qpages = qmn_quiz_data[ quizID ].qpages;
441
+ var $curr_page_opt = $qpages[pid];
442
+ if ($curr_page_opt.hasOwnProperty('pagetimer') && 0 != $curr_page_opt.pagetimer) {
443
+ var $timer_box = $currentpage.find('.qsm-pagetimer');
444
+ var seconds = 0;
445
+ var timerStarted = localStorage.getItem('mlw_started_q' + quizID + '_page' + pid);
446
+ var timerStoped = localStorage.getItem('mlw_stoped_q' + quizID + '_page' + pid);
447
+ var timerRemaning = localStorage.getItem('mlw_time_q' + quizID + '_page' + pid);
448
+ if (timerStoped != 'undefined' && timerStoped > 0) {
449
+ seconds = timerStoped;
450
+ } else {
451
+ if ('yes' == timerStarted) {
452
+ if (0 < timerRemaning) {
453
+ seconds = parseInt(timerRemaning);
454
+ }
455
+ } else {
456
+ seconds = parseFloat($curr_page_opt.pagetimer) * 60;
457
+ }
458
+ }
459
+ qmn_quiz_data[ quizID ].qpages[ pid ].timerRemaning = seconds;
460
+ /* Makes the timer appear. */
461
+ $timer_box.show();
462
+ $timer_box.text(QSMPageTimer.secondsToTimer(seconds));
463
+ /* Sets up timer interval. */
464
+ qmn_quiz_data[ quizID ].qpages[ pid ].timerInterval = setInterval(QSMPageTimer.timer, 1000, quizID, pid, $timer_box);
465
+ }
466
+ $currentpage.find('.page_intro_wrapper video').each(function(){
467
+ var $this = jQuery(this);
468
+ var src = $this.find('source').attr('src');
469
+ $this.attr('src', src)
470
+ $this.load();
471
+ $this.get(0).play();
472
+ });
473
+ }
474
+ },
475
+ /**
476
+ * Reduces the timer by one second and checks if timer is 0
477
+ * @param int quizID The ID of the quiz.
478
+ */
479
+ timer: function (quizID, pid, $timer_box) {
480
+ var $quizForm = QSM.getQuizForm(quizID);
481
+ var $page = qmn_quiz_data[ quizID ].qpages[pid];
482
+ qmn_quiz_data[ quizID ].qpages[ pid ].timerRemaning -= 1;
483
+ if (0 > qmn_quiz_data[ quizID ].qpages[ pid ].timerRemaning) {
484
+ qmn_quiz_data[ quizID ].qpages[ pid ].timerRemaning = 0;
485
+ }
486
+ var total_seconds = parseFloat($page.pagetimer) * 60;
487
+ var secondsRemaining = qmn_quiz_data[ quizID ].qpages[ pid ].timerRemaning;
488
+ var display = QSMPageTimer.secondsToTimer(secondsRemaining);
489
+ $timer_box.text(display);
490
+ var pageTimeTaken = total_seconds - secondsRemaining;
491
+ jQuery('#pagetime_'+pid).val(pageTimeTaken);
492
+ /* Sets our local storage values for the timer being started and current timer value. */
493
+ localStorage.setItem('mlw_started_q' + quizID + '_page' + pid, "yes");
494
+ localStorage.setItem('mlw_time_q' + quizID + '_page' + pid, secondsRemaining);
495
+ if ($page.hasOwnProperty('pagetimer_warning') && 0 != $page.pagetimer_warning) {
496
+ var page_warning_sec = parseFloat($page.pagetimer_warning) * 60;
497
+ if (page_warning_sec == secondsRemaining) {
498
+ $timer_box.parents('.qsm-page').find('.qsm-pagetimer-warning').fadeIn();
499
+ }
500
+ }
501
+ /* If timer is run out, disable fields. */
502
+ if (0 >= secondsRemaining) {
503
+ clearInterval(qmn_quiz_data[ quizID ].qpages[ pid ].timerInterval);
504
+
505
+ $(".qsm-page:visible input:radio").attr('disabled', true);
506
+ $(".qsm-page:visible input:checkbox").attr('disabled', true);
507
+ $(".qsm-page:visible select").attr('disabled', true);
508
+ $(".qsm-page:visible .mlw_qmn_question_comment").attr('disabled', true);
509
+ $(".qsm-page:visible .mlw_answer_open_text").attr('disabled', true);
510
+ $(".qsm-page:visible .mlw_answer_number").attr('disabled', true);
511
+
512
+ QSMPageTimer.endPageTimer(quizID);
513
+ MicroModal.show('modal-page-1');
514
+ return;
515
+ }
516
+ },
517
+ /**
518
+ * Clears timer interval
519
+ * @param int quizID The ID of the quiz
520
+ */
521
+ endPageTimer: function (quizID, clearStorage = false) {
522
+ jQuery.each(qmn_quiz_data[quizID].qpages, function (i, value) {
523
+ if (value.hasOwnProperty('pagetimer') && 0 != value.pagetimer) {
524
+ if (clearStorage) {
525
+ localStorage.removeItem('mlw_started_q' + quizID + '_page' + value.id);
526
+ localStorage.removeItem('mlw_stoped_q' + quizID + '_page' + value.id);
527
+ localStorage.removeItem('mlw_time_q' + quizID + '_page' + value.id);
528
+ }
529
+ var secondsRemaining = qmn_quiz_data[ quizID ].qpages[ value.id ].timerRemaning;
530
+ localStorage.setItem('mlw_stoped_q' + quizID + '_page' + value.id, secondsRemaining);
531
+ localStorage.setItem('mlw_time_q' + quizID + '_page' + value.id, 'completed');
532
+ if (typeof qmn_quiz_data[ quizID ].qpages[ value.id ].timerInterval != 'undefined') {
533
+ clearInterval(qmn_quiz_data[ quizID ].qpages[ value.id ].timerInterval);
534
+ }
535
+ }
536
+ });
537
+ },
538
+ /**
539
+ * Converts seconds to 00:00:00 format
540
+ * @param int seconds The number of seconds
541
+ * @return string A string in H:M:S format
542
+ */
543
+ secondsToTimer: function (seconds) {
544
+ var formattedTime = '';
545
+ seconds = parseInt(seconds);
546
+ var hours = Math.floor(seconds / 3600);
547
+ if (0 === hours) {
548
+ formattedTime = '00:';
549
+ } else if (10 > hours) {
550
+ formattedTime = '0' + hours + ':';
551
+ } else {
552
+ formattedTime = hours + ':';
553
+ }
554
+ var minutes = Math.floor((seconds % 3600) / 60);
555
+ if (0 === minutes) {
556
+ formattedTime = formattedTime + '00:';
557
+ } else if (10 > minutes) {
558
+ formattedTime = formattedTime + '0' + minutes + ':';
559
+ } else {
560
+ formattedTime = formattedTime + minutes + ':';
561
+ }
562
+ var remainder = Math.floor((seconds % 60));
563
+ if (0 === remainder) {
564
+ formattedTime = formattedTime + '00';
565
+ } else if (10 > remainder) {
566
+ formattedTime = formattedTime + '0' + remainder;
567
+ } else {
568
+ formattedTime = formattedTime + remainder;
569
+ }
570
+ return formattedTime;
571
+ },
572
+ }
573
+
574
  // On load code
575
  $(function() {
576
 
702
  result = false;
703
  }
704
  }
705
+ if( jQuery( this ).attr( 'class' ).indexOf( 'mlwRequiredFileUpload' ) > -1 ) {
706
  var selected_file = jQuery( this ).get(0).files.length;
707
  if ( selected_file === 0 ) {
708
  qmnDisplayError( empty_error, jQuery( this ), quiz_form_id );
722
  result = false;
723
  }
724
  }
725
+ //Google recaptcha validation
726
  if( jQuery( this ).attr( 'class' ).indexOf( 'g-recaptcha-response' ) > -1 ) {
727
+ if(grecaptcha.getResponse() == "") {
728
+ alert('ReCaptcha is missing');
729
+ result = false;
730
+ }
731
  }
732
  }
733
  }
775
 
776
 
777
  qsmEndTimeTakenTimer();
778
+ if (qmn_quiz_data[quizID].hasOwnProperty('advanced_timer')) {
779
+ QSMPageTimer.endPageTimer(quiz_id);
780
+ }
781
  if ( qmn_quiz_data[quiz_id].hasOwnProperty( 'timer_limit' ) ) {
782
  QSM.endTimer( quiz_id );
783
  }
868
  var slide_number = +$container.find( '.slide_number_hidden' ).val();
869
  var previous = +$container.find( '.previous_amount_hidden' ).val();
870
  var section_totals = +$container.find( '.total_sections_hidden' ).val();
871
+ if(pagination == 1){
872
+ section_totals = section_totals - 1;
873
+ }
874
  jQuery( quiz_form_id + " .quiz_section" ).hide();
875
  for ( var i = 0; i < pagination; i++ ) {
876
  if (i === 0 && previous === 1 && slide_number > 1) {
882
  slide_number = 1;
883
  }
884
  $container.find( ".mlw_qmn_quiz_link.mlw_previous" ).hide();
885
+ if (qmn_quiz_data[ quiz_id ].first_page) {
886
+ if (slide_number > 1) {
887
+ $container.find(".mlw_qmn_quiz_link.mlw_previous").show();
888
+ }
889
+ } else {
890
+ if (slide_number > pagination) {
891
+ $container.find(".mlw_qmn_quiz_link.mlw_previous").show();
892
+ }
893
+ }
894
+ if (slide_number == section_totals) {
895
+ $container.find(".mlw_qmn_quiz_link.mlw_next").hide();
896
+ $container.find(".g-recaptcha").show();
897
+ if(pagination == 1){
898
+ jQuery(quiz_form_id + " .quiz_section.quiz_end").show();
899
+ }
900
+ }
901
+ if (slide_number < section_totals) {
902
+ $container.find(".mlw_qmn_quiz_link.mlw_next").show();
903
+ $container.find(".g-recaptcha").hide();
904
+ }
905
+ jQuery(quiz_form_id + " .quiz_section.slide" + slide_number).show();
906
+ if (1 == jQuery(quiz_form_id + " .quiz_section.slide" + slide_number).data('prevbtn')) {
907
+ $container.find(".mlw_qmn_quiz_link.mlw_previous").hide();
908
+ }
909
+ }
910
 
911
  jQuery( quiz_form_id ).closest( '.qmn_quiz_container' ).find( '.slide_number_hidden' ).val( slide_number );
912
  jQuery( quiz_form_id ).closest( '.qmn_quiz_container' ).find( '.previous_amount_hidden' ).val( 0 );
945
  var section_totals = +$container.find( '.total_sections_hidden' ).val();
946
 
947
  jQuery( quiz_form_id + " .quiz_section" ).hide();
948
+ jQuery( quiz_form_id + " .g-recaptcha" ).hide();
949
+
950
  for (var i = 0; i < pagination; i++) {
951
  if (i === 0 && previous === 0) {
952
  slide_number = slide_number - pagination;
975
  $container.find( ".mlw_qmn_quiz_link.mlw_next" ).show();
976
  }
977
  jQuery( quiz_form_id + " .quiz_section.slide" + slide_number ).show();
978
+ if (1 == jQuery(quiz_form_id + " .quiz_section.slide" + slide_number).data('prevbtn')) {
979
+ $container.find(".mlw_qmn_quiz_link.mlw_previous").hide();
980
+ }
981
  }
982
 
983
  qmnUpdatePageNumber( -1, quiz_form_id );
1051
  }
1052
 
1053
  function qmnInitPagination( quiz_id ) {
 
1054
  var qmn_section_total = +qmn_quiz_data[quiz_id].pagination.total_questions + 1;
1055
  if ( qmn_quiz_data[quiz_id].pagination.section_comments === '0' ) {
1056
  qmn_section_total += 1;
1125
  } else {
1126
  qmnNextSlide( qmn_quiz_data[quiz_id].pagination.amount, 0, '#quizForm' + quiz_id );
1127
  }
1128
+
1129
  }
1130
 
1131
  function qmnSocialShare( network, mlw_qmn_social_text, mlw_qmn_title, facebook_id, share_url ) {
1209
  success: function (response) {
1210
  $this.find('.quick-question-res-p').remove();
1211
  if(response == 'correct'){
1212
+ $this.append('<p style="color: green" class="quick-question-res-p">' + qmn_ajax_object.quick_result_correct_text + '</p>')
1213
  }else if(response == 'incorrect'){
1214
+ $this.append('<p style="color: red" class="quick-question-res-p">' + qmn_ajax_object.quick_result_wrong_text + '</p>')
1215
  }
1216
  },
1217
  error: function (errorThrown) {
1309
  // Triggger the click event on the quiz form's submit button.
1310
  jQuery( '.qsm-submit-btn' ).trigger( 'click' );
1311
  jQuery('#modal-3').removeClass('is-open');
1312
+ });
1313
+
1314
+ jQuery('.pagetime-goto-nextpage').click(function (e) {
1315
+ e.preventDefault();
1316
+ var quiz_id = jQuery(this).data('quiz_id');
1317
+ QSM.nextPage(quiz_id);
1318
+ var $container = jQuery('#quizForm' + quiz_id).closest('.qmn_quiz_container');
1319
+ qsmScrollTo($container);
1320
+ });
1321
  });
1322
 
1323
  var qsmTimerInterval = setInterval( qmnTimeTakenTimer, 1000 );
mlw_quizmaster2.php CHANGED
@@ -2,14 +2,14 @@
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
- * Version: 6.4.12
6
  * Author: ExpressTech
7
  * Author URI: https://quizandsurveymaster.com/
8
  * Plugin URI: https://expresstech.io/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author QSM Team
12
- * @version 6.4.12
13
  * @package QSM
14
  */
15
 
@@ -37,7 +37,7 @@ class MLWQuizMasterNext {
37
  * @var string
38
  * @since 4.0.0
39
  */
40
- public $version = '6.4.12';
41
 
42
  /**
43
  * QSM Alert Manager Object
@@ -123,6 +123,7 @@ class MLWQuizMasterNext {
123
  include 'php/admin/functions.php';
124
  include 'php/admin/stats-page.php';
125
  include 'php/admin/quizzes-page.php';
 
126
  include 'php/admin/quiz-options-page.php';
127
  include 'php/admin/admin-results-page.php';
128
  include 'php/admin/admin-results-details-page.php';
@@ -138,7 +139,6 @@ class MLWQuizMasterNext {
138
  include 'php/admin/options-page-email-tab.php';
139
  include 'php/admin/options-page-results-page-tab.php';
140
  include 'php/admin/options-page-style-tab.php';
141
- include 'php/admin/options-page-preview-tab.php';
142
  include 'php/admin/addons-page.php';
143
  include 'php/admin/settings-page.php';
144
  include 'php/classes/class-qsm-tracking.php';
@@ -272,17 +272,23 @@ class MLWQuizMasterNext {
272
  */
273
  public function setup_admin_menu() {
274
  if ( function_exists( 'add_menu_page' ) ) {
275
- add_menu_page( 'Quiz And Survey Master', __( 'Quizzes/Surveys', 'quiz-master-next' ), 'edit_posts', __FILE__, 'qsm_generate_quizzes_surveys_page', 'dashicons-feedback' );
 
 
 
 
276
  add_submenu_page( NULL, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'edit_posts', 'mlw_quiz_options', 'qsm_generate_quiz_options' );
277
- add_submenu_page( __FILE__, __( 'Results', 'quiz-master-next' ), __( 'Results', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_results', 'qsm_generate_admin_results_page' );
278
  add_submenu_page( NULL, __( 'Result Details', 'quiz-master-next' ), __( 'Result Details', 'quiz-master-next' ), 'moderate_comments', 'qsm_quiz_result_details', 'qsm_generate_result_details' );
279
- add_submenu_page( __FILE__, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'manage_options', 'qmn_global_settings', array( 'QMNGlobalSettingsPage', 'display_page' ) );
280
- add_submenu_page( __FILE__, __( 'Tools', 'quiz-master-next' ), __( 'Tools', 'quiz-master-next' ), 'manage_options', 'qsm_quiz_tools', 'qsm_generate_quiz_tools' );
281
- add_submenu_page( __FILE__, __( 'Stats', 'quiz-master-next' ), __( 'Stats', 'quiz-master-next' ), 'moderate_comments', 'qmn_stats', 'qmn_generate_stats_page' );
282
- add_submenu_page( __FILE__, __( 'Addon Settings', 'quiz-master-next' ), '<span style="color:#f39c12;">' . __( 'Addon Settings', 'quiz-master-next' ) . '</span>', 'moderate_comments', 'qmn_addons', 'qmn_addons_page' );
283
- add_submenu_page( __FILE__, __( 'Get a Free Addon', 'quiz-master-next' ), '<span style="color:#f39c12;">' . esc_html__( 'Get a Free Addon!', 'quiz-master-next' ) . '</span>', 'moderate_comments', 'qsm-free-addon', 'qsm_display_optin_page' );
284
- add_submenu_page( __FILE__, __( 'QSM About', 'quiz-master-next' ), __( 'QSM About', 'quiz-master-next' ), 'moderate_comments', 'qsm_about_page', 'qsm_generate_about_page' );
285
- add_submenu_page( __FILE__, __( 'Help', 'quiz-master-next' ), __( 'Help', 'quiz-master-next' ), 'moderate_comments', 'qsm_quiz_help', 'qsm_generate_help_page' );
 
 
286
  }
287
  }
288
 
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 7.0.0
6
  * Author: ExpressTech
7
  * Author URI: https://quizandsurveymaster.com/
8
  * Plugin URI: https://expresstech.io/
9
  * Text Domain: quiz-master-next
10
  *
11
  * @author QSM Team
12
+ * @version 7.0.0
13
  * @package QSM
14
  */
15
 
37
  * @var string
38
  * @since 4.0.0
39
  */
40
+ public $version = '7.0.0';
41
 
42
  /**
43
  * QSM Alert Manager Object
123
  include 'php/admin/functions.php';
124
  include 'php/admin/stats-page.php';
125
  include 'php/admin/quizzes-page.php';
126
+ include 'php/admin/admin-dashboard.php';
127
  include 'php/admin/quiz-options-page.php';
128
  include 'php/admin/admin-results-page.php';
129
  include 'php/admin/admin-results-details-page.php';
139
  include 'php/admin/options-page-email-tab.php';
140
  include 'php/admin/options-page-results-page-tab.php';
141
  include 'php/admin/options-page-style-tab.php';
 
142
  include 'php/admin/addons-page.php';
143
  include 'php/admin/settings-page.php';
144
  include 'php/classes/class-qsm-tracking.php';
272
  */
273
  public function setup_admin_menu() {
274
  if ( function_exists( 'add_menu_page' ) ) {
275
+ global $qsm_quiz_list_page;
276
+ $qsm_dashboard_page = add_menu_page( 'Quiz And Survey Master', __( 'Quiz And Survey Master', 'quiz-master-next' ), 'edit_posts', 'qsm_dashboard', 'qsm_generate_dashboard_page', 'dashicons-feedback' );
277
+ add_submenu_page( 'qsm_dashboard', __( 'Dashboard', 'quiz-master-next' ), __( 'Dashboard', 'quiz-master-next' ), 'edit_posts', 'qsm_dashboard', 'qsm_generate_dashboard_page' );
278
+ $qsm_quiz_list_page = add_submenu_page( 'qsm_dashboard', __( 'Quizzes/Surveys', 'quiz-master-next' ), __( 'Quizzes/Surveys', 'quiz-master-next' ), 'edit_posts', 'mlw_quiz_list', 'qsm_generate_quizzes_surveys_page' );
279
+ add_action("load-$qsm_quiz_list_page", 'qsm_generate_quizzes_surveys_page_screen_options');
280
  add_submenu_page( NULL, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'edit_posts', 'mlw_quiz_options', 'qsm_generate_quiz_options' );
281
+ add_submenu_page( 'qsm_dashboard', __( 'Results', 'quiz-master-next' ), __( 'Results', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_results', 'qsm_generate_admin_results_page' );
282
  add_submenu_page( NULL, __( 'Result Details', 'quiz-master-next' ), __( 'Result Details', 'quiz-master-next' ), 'moderate_comments', 'qsm_quiz_result_details', 'qsm_generate_result_details' );
283
+ add_submenu_page( 'qsm_dashboard', __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'manage_options', 'qmn_global_settings', array( 'QMNGlobalSettingsPage', 'display_page' ) );
284
+ add_submenu_page( 'qsm_dashboard', __( 'Tools', 'quiz-master-next' ), __( 'Tools', 'quiz-master-next' ), 'manage_options', 'qsm_quiz_tools', 'qsm_generate_quiz_tools' );
285
+ add_submenu_page( 'qsm_dashboard', __( 'Stats', 'quiz-master-next' ), __( 'Stats', 'quiz-master-next' ), 'moderate_comments', 'qmn_stats', 'qmn_generate_stats_page' );
286
+ add_submenu_page( 'qsm_dashboard', __( 'Addon Settings', 'quiz-master-next' ), '<span style="color:#f39c12;">' . __( 'Addon Settings', 'quiz-master-next' ) . '</span>', 'moderate_comments', 'qmn_addons', 'qmn_addons_page' );
287
+ add_submenu_page( 'qsm_dashboard', __( 'Get a Free Addon', 'quiz-master-next' ), '<span style="color:#f39c12;">' . esc_html__( 'Get a Free Addon!', 'quiz-master-next' ) . '</span>', 'moderate_comments', 'qsm-free-addon', 'qsm_display_optin_page' );
288
+ add_submenu_page( 'qsm_dashboard', __( 'QSM About', 'quiz-master-next' ), __( 'QSM About', 'quiz-master-next' ), 'moderate_comments', 'qsm_about_page', 'qsm_generate_about_page' );
289
+ add_submenu_page( 'qsm_dashboard', __( 'Help', 'quiz-master-next' ), __( 'Help', 'quiz-master-next' ), 'moderate_comments', 'qsm_quiz_help', 'qsm_generate_help_page' );
290
+ //Register screen option for dashboard page
291
+ add_action("screen_settings", "qsm_dashboard_screen_options", 10, 2);
292
  }
293
  }
294
 
php/admin/addons-page.php CHANGED
@@ -87,7 +87,7 @@ function qsm_generate_featured_addons() {
87
  }
88
  ?>
89
  </div>
90
- <a href="http://quizandsurveymaster.com/addons/?utm_source=qsm-addons-page&utm_medium=plugin&utm_content=all-addons-bottom&utm_campaign=qsm_plugin" target="_blank" class="button-primary"><?php _e('Browse All Addons', 'quiz-master-next'); ?></a>
91
  </div>
92
  <div class="qsm-news-ads">
93
  <h3 class="qsm-news-ads-title">QSM Bundle</h3>
@@ -149,18 +149,9 @@ function qsm_display_optin_page() {
149
  <div class="about-body">
150
  <img src="" alt="Improved Custom Fields">
151
  </div>
152
- </div> -->
153
- <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
154
- <div class="about-body">
155
- <h3><?php esc_attr_e('Advertisment Be Gone', 'quiz-master-next'); ?></h3>
156
- <p><?php esc_attr_e('The Quiz And Survey Master News widgets from the Quizzes/Surveys page as well as all the green bordered ads at the top of pages will disappear when you activate this addon!', 'quiz-master-next'); ?></p>
157
- <p><a href="https://quizandsurveymaster.com/downloads/advertisement-gone/" target="_blank"><?php esc_attr_e('Read more about this addon on our site >', 'quiz-master-next'); ?></a></p>
158
- </div>
159
- </div>
160
  </div>
161
-
162
- <h2><?php esc_html_e('How to Get Your Free Addon', 'quiz-master-next'); ?></h2>
163
-
164
  <p><?php echo sprintf(__('Getting your addon is dead simple: just subscribe to our newsletter and then you will get the free addon by e-mail. We will not spam you. We usually send out newsletters to talk about new features in <b>Quiz and Survey Master</b>, let you know when new or updated addons are being released and provide informative articles that show you how to use <b>Quiz and Survey Master</b> to its full potential. <a href="%s" %s>View our privacy policy</a>', 'quiz-master-next'), 'https://quizandsurveymaster.com/privacy-policy/', 'target="_blank"'); ?></p>
165
 
166
  <div id="wpas-mailchimp-signup-form-wrapper">
@@ -211,7 +202,7 @@ function qsm_display_optin_page() {
211
  <!-- START - We recommend to place the below code where you want the form in your website html -->
212
  <div class="sib-form" style="text-align: center;">
213
  <div id="sib-form-container" class="sib-form-container">
214
- <div id="error-message" class="sib-form-message-panel" style="font-size:16px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#661d1d; background-color:#ffeded; border-radius:3px; border-width:px; border-color:#ff4949;max-width:540px; border-width:px;">
215
  <div class="sib-form-message-panel__text sib-form-message-panel__text--center">
216
  <svg viewBox="0 0 512 512" class="sib-icon sib-notification__icon">
217
  <path d="M256 40c118.621 0 216 96.075 216 216 0 119.291-96.61 216-216 216-119.244 0-216-96.562-216-216 0-119.203 96.602-216 216-216m0-32C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm-11.49 120h22.979c6.823 0 12.274 5.682 11.99 12.5l-7 168c-.268 6.428-5.556 11.5-11.99 11.5h-8.979c-6.433 0-11.722-5.073-11.99-11.5l-7-168c-.283-6.818 5.167-12.5 11.99-12.5zM256 340c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28z"
@@ -223,7 +214,7 @@ function qsm_display_optin_page() {
223
  </div>
224
  </div>
225
  <div></div>
226
- <div id="success-message" class="sib-form-message-panel" style="font-size:16px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#085229; background-color:#e7faf0; border-radius:3px; border-width:px; border-color:#13ce66;max-width:540px; border-width:px;">
227
  <div class="sib-form-message-panel__text sib-form-message-panel__text--center">
228
  <svg viewBox="0 0 512 512" class="sib-icon sib-notification__icon">
229
  <path d="M256 8C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 464c-118.664 0-216-96.055-216-216 0-118.663 96.055-216 216-216 118.664 0 216 96.055 216 216 0 118.663-96.055 216-216 216zm141.63-274.961L217.15 376.071c-4.705 4.667-12.303 4.637-16.97-.068l-85.878-86.572c-4.667-4.705-4.637-12.303.068-16.97l8.52-8.451c4.705-4.667 12.303-4.637 16.97.068l68.976 69.533 163.441-162.13c4.705-4.667 12.303-4.637 16.97.068l8.451 8.52c4.668 4.705 4.637 12.303-.068 16.97z"
@@ -242,7 +233,7 @@ function qsm_display_optin_page() {
242
  <div class="sib-input sib-form-block">
243
  <div class="form__entry entry_block">
244
  <div class="form__label-row ">
245
- <label class="entry__label" style="font-size:16px; text-align:left; font-weight:700; font-family:&quot;Helvetica&quot;, sans-serif; color:#3c4858; border-width:px;" for="EMAIL" data-required="*">
246
  Enter your email address to subscribe
247
  </label>
248
 
@@ -251,9 +242,9 @@ function qsm_display_optin_page() {
251
  </div>
252
  </div>
253
 
254
- <label class="entry__error entry__error--primary" style="font-size:16px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#661d1d; background-color:#ffeded; border-radius:3px; border-width:px; border-color:#ff4949;">
255
  </label>
256
- <label class="entry__specification" style="font-size:12px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#8390A4; border-width:px;">
257
  Provide your email address to subscribe. For e.g abc@xyz.com
258
  </label>
259
  </div>
@@ -261,7 +252,7 @@ function qsm_display_optin_page() {
261
  </div>
262
  <div style="padding: 16px 0;">
263
  <div class="sib-form-block" style="text-align: left">
264
- <button class="sib-form-block__button sib-form-block__button-with-loader" style="font-size:16px; text-align:left; font-weight:700; font-family:&quot;Helvetica&quot;, sans-serif; color:#FFFFFF; background-color:#3E4857; border-radius:3px; border-width:0px;"
265
  form="sib-form" type="submit">
266
  <svg class="icon clickable__icon progress-indicator__icon sib-hide-loader-icon" viewBox="0 0 512 512">
267
  <path d="M460.116 373.846l-20.823-12.022c-5.541-3.199-7.54-10.159-4.663-15.874 30.137-59.886 28.343-131.652-5.386-189.946-33.641-58.394-94.896-95.833-161.827-99.676C261.028 55.961 256 50.751 256 44.352V20.309c0-6.904 5.808-12.337 12.703-11.982 83.556 4.306 160.163 50.864 202.11 123.677 42.063 72.696 44.079 162.316 6.031 236.832-3.14 6.148-10.75 8.461-16.728 5.01z"
@@ -272,7 +263,7 @@ function qsm_display_optin_page() {
272
  </div>
273
  </div>
274
  <div style="padding: 16px 0;">
275
- <div class="sib-form-block" style="font-size:14px; text-align:center; font-family:&quot;Helvetica&quot;, sans-serif; color:#333; background-color:transparent; border-width:px;">
276
  <div class="sib-text-form-block">
277
  <p>
278
  <a href="https://sendinblue.com" target="_blank">Terms &amp; Privacy policy</a>
87
  }
88
  ?>
89
  </div>
90
+ <a href="http://quizandsurveymaster.com/addons/?utm_source=qsm-addons-page&utm_medium=plugin&utm_content=all-addons-bottom&utm_campaign=qsm_plugin" target="_blank" class="button-primary" style="margin-top: 20px !important;"><?php _e('Browse All Addons', 'quiz-master-next'); ?></a>
91
  </div>
92
  <div class="qsm-news-ads">
93
  <h3 class="qsm-news-ads-title">QSM Bundle</h3>
149
  <div class="about-body">
150
  <img src="" alt="Improved Custom Fields">
151
  </div>
152
+ </div> -->
 
 
 
 
 
 
 
153
  </div>
154
+
 
 
155
  <p><?php echo sprintf(__('Getting your addon is dead simple: just subscribe to our newsletter and then you will get the free addon by e-mail. We will not spam you. We usually send out newsletters to talk about new features in <b>Quiz and Survey Master</b>, let you know when new or updated addons are being released and provide informative articles that show you how to use <b>Quiz and Survey Master</b> to its full potential. <a href="%s" %s>View our privacy policy</a>', 'quiz-master-next'), 'https://quizandsurveymaster.com/privacy-policy/', 'target="_blank"'); ?></p>
156
 
157
  <div id="wpas-mailchimp-signup-form-wrapper">
202
  <!-- START - We recommend to place the below code where you want the form in your website html -->
203
  <div class="sib-form" style="text-align: center;">
204
  <div id="sib-form-container" class="sib-form-container">
205
+ <div id="error-message" class="sib-form-message-panel" style="font-size:16px; text-align:left; font-family:Helvetica, sans-serif; color:#661d1d; background-color:#ffeded; border-radius:3px; border-width:px; border-color:#ff4949;max-width:540px; border-width:px;">
206
  <div class="sib-form-message-panel__text sib-form-message-panel__text--center">
207
  <svg viewBox="0 0 512 512" class="sib-icon sib-notification__icon">
208
  <path d="M256 40c118.621 0 216 96.075 216 216 0 119.291-96.61 216-216 216-119.244 0-216-96.562-216-216 0-119.203 96.602-216 216-216m0-32C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm-11.49 120h22.979c6.823 0 12.274 5.682 11.99 12.5l-7 168c-.268 6.428-5.556 11.5-11.99 11.5h-8.979c-6.433 0-11.722-5.073-11.99-11.5l-7-168c-.283-6.818 5.167-12.5 11.99-12.5zM256 340c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28z"
214
  </div>
215
  </div>
216
  <div></div>
217
+ <div id="success-message" class="sib-form-message-panel" style="font-size:16px; text-align:left; font-family:Helvetica, sans-serif; color:#085229; background-color:#e7faf0; border-radius:3px; border-width:px; border-color:#13ce66;max-width:540px; border-width:px;">
218
  <div class="sib-form-message-panel__text sib-form-message-panel__text--center">
219
  <svg viewBox="0 0 512 512" class="sib-icon sib-notification__icon">
220
  <path d="M256 8C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 464c-118.664 0-216-96.055-216-216 0-118.663 96.055-216 216-216 118.664 0 216 96.055 216 216 0 118.663-96.055 216-216 216zm141.63-274.961L217.15 376.071c-4.705 4.667-12.303 4.637-16.97-.068l-85.878-86.572c-4.667-4.705-4.637-12.303.068-16.97l8.52-8.451c4.705-4.667 12.303-4.637 16.97.068l68.976 69.533 163.441-162.13c4.705-4.667 12.303-4.637 16.97.068l8.451 8.52c4.668 4.705 4.637 12.303-.068 16.97z"
233
  <div class="sib-input sib-form-block">
234
  <div class="form__entry entry_block">
235
  <div class="form__label-row ">
236
+ <label class="entry__label" style="font-size:16px; text-align:left; font-weight:700; font-family:Helvetica, sans-serif; color:#3c4858; border-width:px;" for="EMAIL" data-required="*">
237
  Enter your email address to subscribe
238
  </label>
239
 
242
  </div>
243
  </div>
244
 
245
+ <label class="entry__error entry__error--primary" style="font-size:16px; text-align:left; font-family:Helvetica, sans-serif; color:#661d1d; background-color:#ffeded; border-radius:3px; border-width:px; border-color:#ff4949;">
246
  </label>
247
+ <label class="entry__specification" style="font-size:12px; text-align:left; font-family:Helvetica, sans-serif; color:#8390A4; border-width:px;">
248
  Provide your email address to subscribe. For e.g abc@xyz.com
249
  </label>
250
  </div>
252
  </div>
253
  <div style="padding: 16px 0;">
254
  <div class="sib-form-block" style="text-align: left">
255
+ <button class="sib-form-block__button sib-form-block__button-with-loader" style="font-size:16px; text-align:left; font-weight:700; font-family:Helvetica, sans-serif; color:#FFFFFF; background-color:#3E4857; border-radius:3px; border-width:0px;"
256
  form="sib-form" type="submit">
257
  <svg class="icon clickable__icon progress-indicator__icon sib-hide-loader-icon" viewBox="0 0 512 512">
258
  <path d="M460.116 373.846l-20.823-12.022c-5.541-3.199-7.54-10.159-4.663-15.874 30.137-59.886 28.343-131.652-5.386-189.946-33.641-58.394-94.896-95.833-161.827-99.676C261.028 55.961 256 50.751 256 44.352V20.309c0-6.904 5.808-12.337 12.703-11.982 83.556 4.306 160.163 50.864 202.11 123.677 42.063 72.696 44.079 162.316 6.031 236.832-3.14 6.148-10.75 8.461-16.728 5.01z"
263
  </div>
264
  </div>
265
  <div style="padding: 16px 0;">
266
+ <div class="sib-form-block" style="font-size:14px; text-align:center; font-family:Helvetica, sans-serif; color:#333; background-color:transparent; border-width:px;">
267
  <div class="sib-text-form-block">
268
  <p>
269
  <a href="https://sendinblue.com" target="_blank">Terms &amp; Privacy policy</a>
php/admin/admin-dashboard.php ADDED
@@ -0,0 +1,567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @since 7.0
4
+ * @param string $name
5
+ */
6
+ function qsm_get_widget_data( $name ){
7
+ $get_dashboard_data = get_transient( 'qsm_admin_dashboard_data' );
8
+ if($get_dashboard_data !== false && !empty( $get_dashboard_data ) ){
9
+ $qsm_admin_dd = $get_dashboard_data;
10
+ }else{
11
+ $fetch_api_data = wp_remote_get('https://quizandsurveymaster.com/wp-json/qsmps/get-data');
12
+ if( is_array( $fetch_api_data ) && isset( $fetch_api_data['response'] ) && isset( $fetch_api_data['response']['code'] ) && $fetch_api_data['response']['code'] == 200 ){
13
+ $qsm_admin_dd = wp_remote_retrieve_body( $fetch_api_data );
14
+ $qsm_admin_dd = json_decode( $qsm_admin_dd, true );
15
+ set_transient( 'qsm_admin_dashboard_data', $qsm_admin_dd, 24*60*60 );
16
+ }
17
+ }
18
+ return isset( $qsm_admin_dd[$name] ) ? $qsm_admin_dd[$name] : array();
19
+ }
20
+ /**
21
+ * @since 7.0
22
+ * @param str $widget_id
23
+ * Check widget is opened or closed
24
+ */
25
+ function qsm_check_close_hidden_box( $widget_id ) {
26
+ $current_screen = get_current_screen();
27
+ $page_id = $current_screen->id;
28
+ $user = wp_get_current_user();
29
+ $closed_div = get_user_option( "closedpostboxes_$page_id", $user->ID );
30
+ if ( $closed_div && is_array( $closed_div ) ) {
31
+ echo in_array( $widget_id, $closed_div ) ? 'closed' : '';
32
+ }
33
+
34
+ $hidden_box = get_user_option( "metaboxhidden_$page_id", $user->ID );
35
+ if ( $hidden_box && is_array( $hidden_box ) ) {
36
+ echo in_array( $widget_id, $hidden_box ) ? ' hide-if-js' : '';
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @since 7.0
42
+ * @param str $status
43
+ * @param obj $args
44
+ * @return Create dashboard screen
45
+ */
46
+ function qsm_dashboard_screen_options( $status, $args ) {
47
+ $screen = get_current_screen();
48
+ if ( is_object( $screen ) && trim( $screen->id ) == 'toplevel_page_qsm_dashboard' ) {
49
+ ob_start();
50
+ $page_id = $screen->id;
51
+ $user = wp_get_current_user();
52
+ ?>
53
+ <form id="adv-settings" method="post">
54
+ <fieldset class="metabox-prefs">
55
+ <legend>Boxes</legend>
56
+ <?php
57
+ $hidden_box = get_user_option( "metaboxhidden_$page_id", $user->ID );
58
+ $hidden_box_arr = ! empty( $hidden_box ) ? $hidden_box : array();
59
+ $registered_widget = get_option( 'qsm_dashboard_widget_arr', array() );
60
+ $registered_widget['welcome_panel'] = array(
61
+ 'title' => __('Welcome', 'quiz-master-next')
62
+ );
63
+ if ( $registered_widget ) {
64
+ foreach ( $registered_widget as $key => $value ) {
65
+ ?>
66
+ <label for="<?php echo $key; ?>-hide"><input class="hide-postbox-tog" name="<?php echo $key; ?>-hide" type="checkbox" id="<?php echo $key; ?>-hide" value="<?php echo $key; ?>"
67
+ <?php
68
+ if ( ! in_array( $key, $hidden_box_arr ) ) {
69
+ ?>
70
+ checked="checked"<?php } ?>><?php echo $value['title']; ?></label>
71
+ <?php
72
+ }
73
+ }
74
+ ?>
75
+ </fieldset>
76
+ <?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ); ?>
77
+ </form>
78
+ <?php
79
+ return ob_get_clean();
80
+ }
81
+ return $status;
82
+ }
83
+
84
+ /**
85
+ * @since 7.0
86
+ * @return HTMl Dashboard for QSM
87
+ */
88
+ function qsm_generate_dashboard_page() {
89
+ // Only let admins and editors see this page.
90
+ if ( ! current_user_can( 'edit_posts' ) ) {
91
+ return;
92
+ }
93
+ global $mlwQuizMasterNext;
94
+ wp_enqueue_script( 'micromodal_script', plugins_url( '../../js/micromodal.min.js', __FILE__ ) );
95
+ wp_enqueue_script( 'qsm_admin_script', plugins_url( '../../js/admin.js', __FILE__ ), array( 'jquery', 'micromodal_script', 'jquery-ui-accordion' ), $mlwQuizMasterNext->version );
96
+ wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ) );
97
+ wp_enqueue_style( 'qsm_admin_dashboard_css', plugins_url( '../../css/admin-dashboard.css', __FILE__ ) );
98
+ wp_enqueue_style( 'qsm_ui_css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css' );
99
+ wp_enqueue_script( 'dashboard' );
100
+ if ( wp_is_mobile() ) {
101
+ wp_enqueue_script( 'jquery-touch-punch' );
102
+ }
103
+ ?>
104
+ <div class="wrap">
105
+ <h1><?php _e( 'QSM Dashboard', 'quiz-master-next' ); ?></h1>
106
+ <div id="welcome_panel" class="postbox welcome-panel <?php qsm_check_close_hidden_box( 'welcome_panel' ); ?>">
107
+ <div class="qsm-welcome-panel-close">
108
+ <img src="<?php echo QSM_PLUGIN_URL . '/assets/icon-128x128.png'; ?>">
109
+ <p class="current_version"><?php echo $mlwQuizMasterNext->version; ?></p>
110
+ </div>
111
+ <a class="qsm-welcome-panel-dismiss" href="#" aria-label="Dismiss the welcome panel"><?php _e( 'Dismiss', 'quiz-master-next' ); ?></a>
112
+ <div class="welcome-panel-content">
113
+ <h2><?php _e( 'Welcome to Quiz And Survey Master!', 'quiz-master-next' ); ?></h2>
114
+ <p class="about-description"><?php _e( 'Formerly Quiz Master Next', 'quiz-master-next' ); ?></p>
115
+ <div class="welcome-panel-column-container">
116
+ <div class="welcome-panel-column">
117
+ <h3><?php _e( 'Get Started', 'quiz-master-next' ); ?></h3>
118
+ <a class="button button-primary button-hero load-quiz-wizard hide-if-no-customize" href="#"><?php _e( 'Create New Quiz/Survey', 'quiz-master-next' ); ?></a>
119
+ <p class="hide-if-no-customize">
120
+ or, <a href="admin.php?page=mlw_quiz_list"><?php _e( 'Edit previously created quizzes', 'quiz-master-next' ); ?></a>
121
+ </p>
122
+ </div>
123
+ <div class="welcome-panel-column">
124
+ <h3><?php _e( 'Next Steps', 'quiz-master-next' ); ?></h3>
125
+ <ul>
126
+ <li><a target="_blank" href="https://quizandsurveymaster.com/docs/" class="welcome-icon"><span class="dashicons dashicons-media-document"></span>&nbsp;&nbsp;<?php _e( 'Read Documentation', 'quiz-master-next' ); ?></a></li>
127
+ <li><a target="_blank" href="https://demo.quizandsurveymaster.com/" class="welcome-icon"><span class="dashicons dashicons-format-video"></span>&nbsp;&nbsp;<?php _e( 'See demos', 'quiz-master-next' ); ?></a></li>
128
+ <li><a target="_blank" href="https://quizandsurveymaster.com/addons/" class="welcome-icon"><span class="dashicons dashicons-plugins-checked"></span>&nbsp;&nbsp;<?php _e( 'Extend QSM with PRO Addons', 'quiz-master-next' ); ?></a></li>
129
+ </ul>
130
+ </div>
131
+ <div class="welcome-panel-column welcome-panel-last">
132
+ <h3><?php _e( 'Useful Links', 'quiz-master-next' ); ?></h3>
133
+ <ul>
134
+ <li><a target="_blank" href="https://support.quizandsurveymaster.com/" class="welcome-icon"><span class="dashicons dashicons-admin-users"></span>&nbsp;&nbsp;<?php _e( 'Support Forum', 'quiz-master-next' ); ?></a></li>
135
+ <li><a target="_blank" href="https://github.com/QuizandSurveyMaster/quiz_master_next" class="welcome-icon"><span class="dashicons dashicons-editor-code"></span>&nbsp;&nbsp;<?php _e( 'Github Repository', 'quiz-master-next' ); ?></a></li>
136
+ </ul>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ <?php do_action( 'qsm_welcome_panel' ); ?>
141
+ </div>
142
+ <?php
143
+ $qsm_dashboard_widget = array(
144
+ 'dashboard_popular_addon' => array(
145
+ 'sidebar' => 'normal',
146
+ 'callback' => 'qsm_dashboard_popular_addon',
147
+ 'title' => 'Popular Addons',
148
+ ),
149
+ 'dashboard_recent_taken_quiz' => array(
150
+ 'sidebar' => 'normal',
151
+ 'callback' => 'qsm_dashboard_recent_taken_quiz',
152
+ 'title' => 'Recent Taken Quiz',
153
+ ),
154
+ 'dashboard_what_new' => array(
155
+ 'sidebar' => 'side',
156
+ 'callback' => 'qsm_dashboard_what_new',
157
+ 'title' => 'Latest news',
158
+ ),
159
+ 'dashboard_chagelog' => array(
160
+ 'sidebar' => 'side',
161
+ 'callback' => 'qsm_dashboard_chagelog',
162
+ 'title' => 'Changelog',
163
+ ),
164
+ );
165
+ $qsm_dashboard_widget = apply_filters( 'qsm_dashboard_widget', $qsm_dashboard_widget );
166
+ update_option( 'qsm_dashboard_widget_arr', $qsm_dashboard_widget );
167
+
168
+ // Get the metabox positions
169
+ $current_screen = get_current_screen();
170
+ $page_id = $current_screen->id;
171
+ $user = wp_get_current_user();
172
+ $box_positions = get_user_option( "meta-box-order_$page_id", $user->ID );
173
+ ?>
174
+ <div id="dashboard-widgets-wrap">
175
+ <div id="dashboard-widgets" class="metabox-holder">
176
+ <div id="postbox-container-1" class="postbox-container">
177
+ <div id="normal-sortables" class="meta-box-sortables ui-sortable">
178
+ <?php
179
+ $normal_widgets = $side_widgets = array();
180
+ if ( $box_positions && is_array( $box_positions ) && isset( $box_positions['normal'] ) && $box_positions['normal'] != '' ) {
181
+ $normal_widgets = explode( ',', $box_positions['normal'] );
182
+ foreach ( $normal_widgets as $value ) {
183
+ if ( isset( $qsm_dashboard_widget[ $value ] ) ) {
184
+ call_user_func( $qsm_dashboard_widget[ $value ]['callback'], $value );
185
+ }
186
+ }
187
+ }
188
+ if ( $box_positions && is_array( $box_positions ) && isset( $box_positions['side'] ) && $box_positions['side'] != '' ) {
189
+ $side_widgets = explode( ',', $box_positions['side'] );
190
+ }
191
+ $all_widgets = array_merge( $normal_widgets, $side_widgets );
192
+ if ( $qsm_dashboard_widget ) {
193
+ foreach ( $qsm_dashboard_widget as $widgte_id => $normal_widget ) {
194
+ if ( ! in_array( $widgte_id, $all_widgets ) && $normal_widget['sidebar'] == 'normal' ) {
195
+ call_user_func( $normal_widget['callback'], $widgte_id );
196
+ }
197
+ }
198
+ }
199
+ ?>
200
+ </div>
201
+ </div>
202
+ <div id="postbox-container-2" class="postbox-container">
203
+ <div id="side-sortables" class="meta-box-sortables ui-sortable">
204
+ <?php
205
+ $normal_widgets = array();
206
+ if ( $box_positions && is_array( $box_positions ) && isset( $box_positions['side'] ) && $box_positions['side'] != '' ) {
207
+ $normal_widgets = explode( ',', $box_positions['side'] );
208
+ foreach ( $normal_widgets as $value ) {
209
+ if ( isset( $qsm_dashboard_widget[ $value ] ) ) {
210
+ call_user_func( $qsm_dashboard_widget[ $value ]['callback'], $value );
211
+ }
212
+ }
213
+ }
214
+ if ( $qsm_dashboard_widget ) {
215
+ foreach ( $qsm_dashboard_widget as $widgte_id => $normal_widget ) {
216
+ if ( ! in_array( $widgte_id, $all_widgets ) && $normal_widget['sidebar'] == 'side' ) {
217
+ call_user_func( $normal_widget['callback'], $widgte_id );
218
+ }
219
+ }
220
+ }
221
+ ?>
222
+ </div>
223
+ </div>
224
+ </div>
225
+ <?php
226
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
227
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
228
+ ?>
229
+ </div><!-- dashboard-widgets-wrap -->
230
+ </div>
231
+ <!-- Popup for new wizard -->
232
+ <?php echo qsm_create_new_quiz_wizard(); ?>
233
+ <?php
234
+ }
235
+
236
+ /**
237
+ * @since 7.0
238
+ * @global Obj $mlwQuizMasterNext
239
+ * Generate the post settings and required plugin in popup
240
+ */
241
+ function qsm_wizard_template_quiz_options() {
242
+ global $mlwQuizMasterNext;
243
+ $settings = isset( $_POST['settings'] ) ? $_POST['settings'] : array();
244
+ $addons = isset( $_POST['addons'] ) ? $_POST['addons'] : array();
245
+ $all_settings = $mlwQuizMasterNext->quiz_settings->load_setting_fields( 'quiz_options' );
246
+ $recommended_addon_str = '';
247
+ if ( $settings ) {
248
+ foreach ( $settings as $key => $single_setting ) {
249
+ $key = array_search( $key, array_column( $all_settings, 'id' ) );
250
+ $field = $all_settings[ $key ];
251
+ $field['label'] = $single_setting['option_name'];
252
+ $field['default'] = $single_setting['value'];
253
+ QSM_Fields::generate_field( $field, $single_setting['value'] );
254
+ }
255
+ } else {
256
+ echo __( 'No settings are found!', 'quiz-master-next' );
257
+ }
258
+ echo '=====';
259
+ if ( $addons ) {
260
+ $recommended_addon_str .= '<ul>';
261
+ foreach ( $addons as $single_addon ) {
262
+ $recommended_addon_str .= '<li>';
263
+ if ( isset( $single_addon['attribute'] ) && $single_addon['attribute'] != '' ) {
264
+ $attr = $single_addon['attribute'];
265
+ $recommended_addon_str .= '<span class="ra-attr qra-att-' . $attr . '">' . $attr . '</span>';
266
+ }
267
+ $link = isset( $single_addon['link'] ) ? $single_addon['link'] : '';
268
+ $recommended_addon_str .= '<a target="_blank" href="' . $link . '">';
269
+ if ( isset( $single_addon['img'] ) && $single_addon['img'] != '' ) {
270
+ $img = $single_addon['img'];
271
+ $recommended_addon_str .= '<img src="' . $img . '"/>';
272
+ }
273
+ $recommended_addon_str .= '</a>';
274
+ $recommended_addon_str .= '</li>';
275
+ }
276
+ $recommended_addon_str .= '</ul>';
277
+ } else {
278
+ $recommended_addon_str .= __( 'No addons are found!', 'quiz-master-next' );
279
+ }
280
+ echo $recommended_addon_str;
281
+ exit;
282
+ }
283
+ add_action( 'wp_ajax_qsm_wizard_template_quiz_options', 'qsm_wizard_template_quiz_options' );
284
+
285
+ /**
286
+ * @since 7.0
287
+ * @param str $widget_id
288
+ * Generate popular addon
289
+ */
290
+ function qsm_dashboard_popular_addon( $widget_id ) {
291
+ $addon_array = qsm_get_widget_data('products');
292
+ ?>
293
+ <div id="<?php echo $widget_id; ?>" class="postbox <?php qsm_check_close_hidden_box( $widget_id ); ?>">
294
+ <button type="button" class="handlediv" aria-expanded="true">
295
+ <span class="screen-reader-text">Toggle panel: <?php _e( 'Most Popular Addon this Week', 'quiz-master-next' ); ?></span>
296
+ <span class="toggle-indicator" aria-hidden="true"></span>
297
+ </button>
298
+ <h2 class="hndle ui-sortable-handle"><span><?php _e( 'Most Popular Addon this Week', 'quiz-master-next' ); ?></span></h2>
299
+ <div class="inside">
300
+ <div class="main">
301
+ <ul class="popuar-addon-ul">
302
+ <?php
303
+ if ( $addon_array ) {
304
+ foreach ( $addon_array as $key => $single_arr ) {
305
+ ?>
306
+ <li>
307
+ <a href="<?php echo $single_arr['link']; ?>" target="_blank">
308
+ <img src="<?php echo $single_arr['img']; ?>" title="<?php echo $single_arr['name']; ?>">
309
+ </a>
310
+ </li>
311
+ <?php
312
+ }
313
+ }
314
+ ?>
315
+ </ul>
316
+ <div class="pa-all-addon">
317
+ <a href="https://quizandsurveymaster.com/addons/" target="_blank"><?php _e( 'SEE ALL ADDONS', 'quiz-master-next' ); ?></a>
318
+ </div>
319
+ </div>
320
+ </div>
321
+ </div>
322
+ <?php
323
+ }
324
+
325
+ /**
326
+ * @since 7.0
327
+ * @global obj $wpdb
328
+ * @param str $widget_id
329
+ * Generate recent taken quiz widget
330
+ */
331
+ function qsm_dashboard_recent_taken_quiz( $widget_id ) {
332
+ global $wpdb;
333
+ ?>
334
+ <div id="<?php echo $widget_id; ?>" class="postbox <?php qsm_check_close_hidden_box( $widget_id ); ?>">
335
+ <button type="button" class="handlediv" aria-expanded="true">
336
+ <span class="screen-reader-text">Toggle panel: <?php _e( 'Recently Taken Quizzes', 'quiz-master-next' ); ?></span>
337
+ <span class="toggle-indicator" aria-hidden="true"></span>
338
+ </button>
339
+ <h2 class="hndle ui-sortable-handle"><span><?php _e( 'Recently Taken Quizzes', 'quiz-master-next' ); ?></span></h2>
340
+ <div class="inside">
341
+ <div class="main">
342
+ <ul class="recently-taken-quiz-ul">
343
+ <?php
344
+ $mlw_resutl_data = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}mlw_results WHERE deleted='0' ORDER BY result_id DESC LIMIT 2", ARRAY_A );
345
+ if ( $mlw_resutl_data ) {
346
+ foreach ( $mlw_resutl_data as $key => $single_result_arr ) {
347
+ ?>
348
+ <li>
349
+ <?php
350
+ if ( isset( $single_result_arr['user'] ) && $single_result_arr['user'] != '' ) {
351
+ echo '<img src="' . get_avatar_url( $single_result_arr['user'] ) . '" class="avatar avatar-50 photo">';
352
+ } else {
353
+ echo '<img src="' . QSM_PLUGIN_URL . '/assets/default_image.png" class="avatar avatar-50 photo">';
354
+ }
355
+ ?>
356
+ <div class="rtq-main-wrapper">
357
+ <span class="rtq_user_info">
358
+ <?php
359
+ if ( isset( $single_result_arr['user'] ) && $single_result_arr['user'] != 0 ) {
360
+ $edit_link = get_edit_profile_url( $single_result_arr['user'] );
361
+ $actual_user = get_userdata( $single_result_arr['user'] );
362
+ $user_name = $single_result_arr['name'] == 'None' ? $actual_user->data->display_name : $single_result_arr['name'];
363
+ echo '<a href="' . $edit_link . '">' . $user_name . '</a>';
364
+ } else {
365
+ echo __('Guest', 'quiz-master-next');
366
+ }
367
+ _e( ' took quiz ', 'quiz-master-next' );
368
+ echo '<a href="admin.php?page=mlw_quiz_options&quiz_id=' . $single_result_arr['quiz_id'] . '">' . $single_result_arr['quiz_name'] . '</a>';
369
+ ?>
370
+ </span>
371
+ <span class="rtq-result-info">
372
+ <?php
373
+ $quotes_list = '';
374
+ $form_type = isset( $single_result_arr['form_type'] ) ? $single_result_arr['form_type'] : 0;
375
+ if( $form_type == 1 || $form_type == 2 ){
376
+ $quotes_list .= __( 'Not Graded', 'quiz-master-next' );
377
+ }else{
378
+ if ( $single_result_arr['quiz_system'] == 0 ) {
379
+ $quotes_list .= $single_result_arr['correct'] . ' out of ' . $single_result_arr['total'] . ' or ' . $single_result_arr['correct_score'] . '%';
380
+ }
381
+ if ( $single_result_arr['quiz_system'] == 1 ) {
382
+ $quotes_list .= $single_result_arr['point_score'] . ' Points';
383
+ }
384
+ if ( $single_result_arr['quiz_system'] == 3 ) {
385
+ $quotes_list .= $single_result_arr['correct'] . ' out of ' . $single_result_arr['total'] . ' or ' . $single_result_arr['correct_score'] . '%<br/>';
386
+ $quotes_list .= $single_result_arr['point_score'] . ' Points';
387
+ }
388
+ }
389
+ echo $quotes_list;
390
+ ?>
391
+ |
392
+ <?php
393
+ $mlw_complete_time = '';
394
+ $mlw_qmn_results_array = @unserialize( $single_result_arr['quiz_results'] );
395
+ if ( is_array( $mlw_qmn_results_array ) ) {
396
+ $mlw_complete_hours = floor( $mlw_qmn_results_array[0] / 3600 );
397
+ if ( $mlw_complete_hours > 0 ) {
398
+ $mlw_complete_time .= "$mlw_complete_hours hours ";
399
+ }
400
+ $mlw_complete_minutes = floor( ( $mlw_qmn_results_array[0] % 3600 ) / 60 );
401
+ if ( $mlw_complete_minutes > 0 ) {
402
+ $mlw_complete_time .= "$mlw_complete_minutes minutes ";
403
+ }
404
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
405
+ $mlw_complete_time .= "$mlw_complete_seconds seconds";
406
+ }
407
+ _e( ' Time to complete ', 'quiz-master-next' );
408
+ echo $mlw_complete_time;
409
+ ?>
410
+ </span>
411
+ <span class="rtq-time-taken"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $single_result_arr['time_taken'] ) ); ?></span>
412
+ <p class="row-actions-c">
413
+ <a href="admin.php?page=qsm_quiz_result_details&result_id=<?php echo $single_result_arr['result_id']; ?>">View</a> | <a href="#" data-result_id="<?php echo $single_result_arr['result_id']; ?>" class="trash rtq-delete-result">Delete</a>
414
+ </p>
415
+ </div>
416
+ </li>
417
+ <?php
418
+ }
419
+ }
420
+ ?>
421
+ </ul>
422
+ <p>
423
+ <a href="admin.php?page=mlw_quiz_results">
424
+ <?php
425
+ $mlw_resutl_data = $wpdb->get_row( "SELECT DISTINCT COUNT(result_id) as total_result FROM {$wpdb->prefix}mlw_results WHERE deleted='0'", ARRAY_A );
426
+ echo isset( $mlw_resutl_data['total_result'] ) ? __( 'See All Results ', 'quiz-master-next' ) : '';
427
+ ?>
428
+ </a>
429
+ <?php
430
+ echo isset( $mlw_resutl_data['total_result'] ) ? '(' . $mlw_resutl_data['total_result'] . ')' : '';
431
+ ?>
432
+ </p>
433
+ </div>
434
+ </div>
435
+ </div>
436
+ <?php
437
+ }
438
+
439
+ /**
440
+ * @since 7.0
441
+ * @param str $widget_id
442
+ * Generate posts
443
+ */
444
+ function qsm_dashboard_what_new( $widget_id ) {
445
+ ?>
446
+ <div id="<?php echo $widget_id; ?>" class="postbox <?php qsm_check_close_hidden_box( $widget_id ); ?>">
447
+ <button type="button" class="handlediv" aria-expanded="true">
448
+ <span class="screen-reader-text">Toggle panel: <?php _e( "'what's New", 'quiz-master-next' ); ?></span>
449
+ <span class="toggle-indicator" aria-hidden="true"></span>
450
+ </button>
451
+ <h2 class="hndle ui-sortable-handle"><span><?php _e( "What's New", 'quiz-master-next' ); ?></span></h2>
452
+ <div class="inside">
453
+ <div class="main">
454
+ <ul class="what-new-ul">
455
+ <?php
456
+ $feed_posts_array = qsm_get_widget_data('blog_post');
457
+ if ( ! empty( $feed_posts_array ) ) {
458
+ foreach ( $feed_posts_array as $key => $single_feed_arr ) {
459
+ ?>
460
+ <li>
461
+ <a href="<?php echo $single_feed_arr['link']; ?>" target="_blank">
462
+ <?php echo $single_feed_arr['title']; ?>
463
+ </a>
464
+ <div class="post-description">
465
+ <?php echo $single_feed_arr['excerpt']; ?>
466
+ </div>
467
+ </li>
468
+ <?php
469
+ }
470
+ }
471
+ ?>
472
+ </ul>
473
+ </div>
474
+ </div>
475
+ </div>
476
+ <?php
477
+ }
478
+
479
+ /**
480
+ * @since 7.0
481
+ * @param str $widget_id
482
+ * Generate change log
483
+ */
484
+ function qsm_dashboard_chagelog( $widget_id ) {
485
+ $change_log = qsm_get_widget_data('change_log');
486
+ global $mlwQuizMasterNext;
487
+ ?>
488
+ <div id="<?php echo $widget_id; ?>" class="postbox <?php qsm_check_close_hidden_box( $widget_id ); ?>">
489
+ <button type="button" class="handlediv" aria-expanded="true">
490
+ <span class="screen-reader-text">Toggle panel: <?php _e( 'Changelog', 'quiz-master-next' ); ?></span>
491
+ <span class="toggle-indicator" aria-hidden="true"></span>
492
+ </button>
493
+ <h2 class="hndle ui-sortable-handle"><span><?php _e( 'Changelog ( '. $mlwQuizMasterNext->version .' )', 'quiz-master-next' ); ?></span></h2>
494
+ <div class="inside">
495
+ <div class="main">
496
+ <?php if($change_log){
497
+ $change_log_count = count( $change_log );
498
+ ?>
499
+ <ul class="changelog-ul">
500
+ <?php
501
+ $i = 0;
502
+ foreach ($change_log as $single_change_log) {
503
+ if( $single_change_log != ''){
504
+ if( $i == 5 )
505
+ break;
506
+
507
+ $expload_str = explode(':', $single_change_log);
508
+ $cl_type = $expload_str[0];
509
+ $cl_str = $expload_str[1];
510
+ ?>
511
+ <li><span class="<?php echo trim(strtolower($cl_type)); ?>"><?php echo trim( $cl_type ); ?></span> <?php echo $cl_str; ?></li>
512
+ <?php
513
+ $i++;
514
+ }
515
+ }
516
+ ?>
517
+ </ul>
518
+ <?php if( $change_log_count > 5 ){ ?>
519
+ <div class="pa-all-addon" style="border-top: 1px solid #ede8e8;padding-top: 15px;">
520
+ <a href="https://wordpress.org/plugins/quiz-master-next/#developers" target="_blank"><?php _e('View Complete Changelog', 'quiz-master-next'); ?></a>
521
+ </div>
522
+ <?php
523
+ }
524
+ } ?>
525
+ </div>
526
+ </div>
527
+ </div>
528
+ <?php
529
+ }
530
+
531
+ /**
532
+ * @since 7.0
533
+ * Create new quiz and redirect to newly created quiz
534
+ */
535
+ function qsm_create_new_quiz_from_wizard() {
536
+ // Create new quiz.
537
+ if ( isset( $_POST['qsm_new_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_new_quiz_nonce'], 'qsm_new_quiz' ) ) {
538
+ global $mlwQuizMasterNext;
539
+ $quiz_name = sanitize_text_field( htmlspecialchars( stripslashes( $_POST['quiz_name'] ), ENT_QUOTES ) );
540
+ unset( $_POST['qsm_new_quiz_nonce'] );
541
+ unset( $_POST['_wp_http_referer'] );
542
+ $setting_arr = array(
543
+ 'quiz_options' => serialize( $_POST ),
544
+ );
545
+ $mlwQuizMasterNext->quizCreator->create_quiz( $quiz_name, serialize( $setting_arr ) );
546
+ }
547
+ }
548
+ add_action( 'admin_init', 'qsm_create_new_quiz_from_wizard' );
549
+
550
+
551
+ /**
552
+ * @since 7.0
553
+ * @param Object $upgrader_object
554
+ * @param Array $options
555
+ * Reset the transient on QSM plugin update
556
+ */
557
+ function qsm_reset_transient_dashboard( $upgrader_object, $options ) {
558
+ $current_plugin_path_name = QSM_PLUGIN_BASENAME;
559
+ if ($options['action'] == 'update' && $options['type'] == 'plugin' ){
560
+ foreach($options['plugins'] as $each_plugin) {
561
+ if ( $each_plugin == $current_plugin_path_name ){
562
+ delete_transient( 'qsm_admin_dashboard_data' );
563
+ }
564
+ }
565
+ }
566
+ }
567
+ add_action( 'upgrader_process_complete', 'qsm_reset_transient_dashboard', 10, 2 );
php/admin/admin-results-details-page.php CHANGED
@@ -11,6 +11,7 @@ function qsm_generate_result_details() {
11
  return;
12
  }
13
  global $mlwQuizMasterNext;
 
14
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
15
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'results';
16
  $tab_array = $mlwQuizMasterNext->pluginHelper->get_results_tabs();
@@ -21,8 +22,8 @@ function qsm_generate_result_details() {
21
  }
22
  </style>
23
  <div class="wrap">
24
- <h2><?php _e('Quiz Results', 'quiz-master-next'); ?></h2>
25
- <h2 class="nav-tab-wrapper">
26
  <?php
27
  foreach( $tab_array as $tab ) {
28
  $active_class = '';
@@ -86,79 +87,190 @@ function qsm_generate_results_details_tab() {
86
  $next_results = $wpdb->get_var( "SELECT result_id FROM {$wpdb->prefix}mlw_results WHERE result_id = (SELECT MIN(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 AND result_id > $result_id)" );
87
 
88
  // If there is previous or next results, show buttons.
89
- echo '<div style="text-align:right; margin-top: 10px;">';
 
 
90
  if ( ! is_null( $previous_results ) && $previous_results ) {
91
- echo "<a class='button' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $previous_results ) . "\" >View Previous Results</a> ";
92
- }
93
- if ( ! is_null( $next_results ) && $next_results ) {
94
- echo " <a class='button' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $next_results ) . "\" >View Next Results</a>";
95
- }
 
 
 
 
96
  echo '</div>';
97
 
98
  // Get template for admin results.
99
  $settings = (array) get_option( 'qmn-settings' );
100
- if ( isset( $settings['results_details_template'] ) ) {
101
- $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
102
- } else {
103
- $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
104
- <p>%CONTACT_ALL%</p>
105
- <p>Name Provided: %USER_NAME%</p>
106
- <p>Business Provided: %USER_BUSINESS%</p>
107
- <p>Phone Provided: %USER_PHONE%</p>
108
- <p>Email Provided: %USER_EMAIL%</p>
109
- <p>Score Received: %AMOUNT_CORRECT%/%TOTAL_QUESTIONS% or %CORRECT_SCORE%% or %POINT_SCORE% points</p>
110
- <h2>Answers Provided:</h2>
111
- <p>The user took %TIMER% to complete quiz.</p>
112
- <p>Comments entered were: %COMMENT_SECTION%</p>
113
- <p>The answers were as follows:</p>
114
- %QUESTIONS_ANSWERS%";
115
- }
116
-
117
- // Prepare responses array.
118
- if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
119
- $results = unserialize($results_data->quiz_results);
120
- if ( ! isset( $results["contact"] ) ) {
121
- $results["contact"] = array();
122
- }
123
- } else {
124
- $template = str_replace( "%QUESTIONS_ANSWERS%" , $results_data->quiz_results, $template);
125
- $template = str_replace( "%TIMER%" , '', $template);
126
- $template = str_replace( "%COMMENT_SECTION%" , '', $template);
127
- $results = array(
128
- 0,
129
- array(),
130
- '',
131
- 'contact' => array()
132
- );
133
- }
134
-
135
- // Prepare full results array.
136
- $results_array = array(
137
- 'quiz_id' => $results_data->quiz_id,
138
- 'quiz_name' => $results_data->quiz_name,
139
- 'quiz_system' => $results_data->quiz_system,
140
- 'user_name' => $results_data->name,
141
- 'user_business' => $results_data->business,
142
- 'user_email' => $results_data->email,
143
- 'user_phone' => $results_data->phone,
144
- 'user_id' => $results_data->user,
145
- 'timer' => $results[0],
146
- 'time_taken' => $results_data->time_taken,
147
- 'total_points' => $results_data->point_score,
148
- 'total_score' => $results_data->correct_score,
149
- 'total_correct' => $results_data->correct,
150
- 'total_questions' => $results_data->total,
151
- 'comments' => $results[2],
152
- 'question_answers_array' => $results[1],
153
- 'contact' => $results["contact"],
154
- 'results' => $results,
155
- );
156
-
157
- // Pass through template variable filter
158
- $template = apply_filters( 'mlw_qmn_template_variable_results_page', $template, $results_array );
159
- $template = str_replace( "\n" , "<br>", $template );
160
- echo $template;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
 
 
 
 
 
 
 
 
 
 
162
  // Hook for below admin results
163
  do_action( 'qsm_below_admin_results', $results_array );
164
  }
@@ -172,7 +284,7 @@ function qsm_generate_results_details_tab() {
172
  */
173
  function qsm_results_details_tab() {
174
  global $mlwQuizMasterNext;
175
- $mlwQuizMasterNext->pluginHelper->register_results_settings_tab( __( "Results", 'quiz-master-next' ), "qsm_generate_results_details_tab" );
176
  }
177
  add_action( "plugins_loaded", 'qsm_results_details_tab' );
178
  ?>
11
  return;
12
  }
13
  global $mlwQuizMasterNext;
14
+ wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
15
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
16
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'results';
17
  $tab_array = $mlwQuizMasterNext->pluginHelper->get_results_tabs();
22
  }
23
  </style>
24
  <div class="wrap">
25
+ <h2 style="display: none;"><?php _e('Quiz Results', 'quiz-master-next'); ?></h2>
26
+ <h2 class="nav-tab-wrapper" style="display: none;">
27
  <?php
28
  foreach( $tab_array as $tab ) {
29
  $active_class = '';
87
  $next_results = $wpdb->get_var( "SELECT result_id FROM {$wpdb->prefix}mlw_results WHERE result_id = (SELECT MIN(result_id) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 AND result_id > $result_id)" );
88
 
89
  // If there is previous or next results, show buttons.
90
+ echo '<div style="text-align:right; margin-top: 20px; margin-bottom: 20px;">';
91
+ echo '<h3 class="result-page-title">Quiz Result - '. $results_data->quiz_name .'</h3>';
92
+ echo '<a style="margin-right: 15px;" href="?page=mlw_quiz_results" class="button button-primary" title="Return to results">'. __( 'Back to Results', 'quiz-master-next' ) .'</a>';
93
  if ( ! is_null( $previous_results ) && $previous_results ) {
94
+ echo "<a class='button button-primary' title='View Previous Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $previous_results ) . "\" ><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
95
+ }else{
96
+ echo "<a class='button button-primary' title='View Previous Result' href='#' disbled=disabled><span class='dashicons dashicons-arrow-left-alt2'></span></a> ";
97
+ }
98
+ if ( ! is_null( $next_results ) && $next_results ) {
99
+ echo " <a class='button button-primary' title='View Next Result' href=\"?page=qsm_quiz_result_details&&result_id=" . intval( $next_results ) . "\" ><span class='dashicons dashicons-arrow-right-alt2'></span></a>";
100
+ }else{
101
+ echo " <a class='button button-primary' title='View Next Result' href='#' disabled=disabled><span class='dashicons dashicons-arrow-right-alt2'></span></a>";
102
+ }
103
  echo '</div>';
104
 
105
  // Get template for admin results.
106
  $settings = (array) get_option( 'qmn-settings' );
107
+ $new_template_result_detail = '1';
108
+ $results["contact"] = array();
109
+ if (isset($settings['new_template_result_detail'])){
110
+ $new_template_result_detail = esc_attr( $settings['new_template_result_detail'] );
111
+ }
112
+ if( $new_template_result_detail == 1 ){
113
+ $template = '';
114
+ if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
115
+ $template .= '<div class="overview-main-wrapper">';
116
+ //User detail
117
+ $template .= '<div class="candidate-detail-wrap overview-inner-wrap">';
118
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>User Detail</span></h2>';
119
+ $template .= '<div class="inside">';
120
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Name:', 'quiz-master-next' ) .'</label><span>'. $results_data->name .'</span></span>';
121
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Business:', 'quiz-master-next' ) .'</label><span>'. $results_data->business .'</span></span>';
122
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Phone:', 'quiz-master-next' ) .'</label><span>'. $results_data->phone .'</span></span>';
123
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Email:', 'quiz-master-next' ) .'</label><span>'. $results_data->email .'</span></span>';
124
+ $template .= '</div>';
125
+ $template .= '</div>';
126
+ $template .= '</div>';
127
+ if( isset( $results_data->form_type ) && $results_data->form_type == 0 ){
128
+ //Scoreboard design
129
+ $template .= '<div class="candidate-detail-wrap overview-inner-wrap">';
130
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Scorecard</span></h2>';
131
+ $template .= '<div class="inside">';
132
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Correct Answers:', 'quiz-master-next' ) .'</label><span>%AMOUNT_CORRECT% Out of %TOTAL_QUESTIONS%</span></span>';
133
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Points:', 'quiz-master-next' ) .'</label><span>%POINT_SCORE%</span></span>';
134
+ $template .= '<span class="result-candidate-span"><label>'. __( 'Percentage:', 'quiz-master-next' ) .'</label><span>%CORRECT_SCORE%%</span></span>';
135
+ $template .= '</div>';
136
+ $template .= '</div>';
137
+ $template .= '</div>';
138
+ }
139
+ //Timer design
140
+ $template .= '<div class="overview-inner-wrap">';
141
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Time Taken</span></h2>';
142
+ $template .= '<div class="inside">';
143
+ $template .= '<div class="timer-div-wrapper">';
144
+ $mlw_qmn_results_array = @unserialize($results_data->quiz_results);
145
+ if ( is_array( $mlw_qmn_results_array ) ) {
146
+ $mlw_complete_hours = floor($mlw_qmn_results_array[0] / 3600);
147
+ if ( $mlw_complete_hours > 0 ) {
148
+ $template .= '<div>';
149
+ $template .= '<span class="hours timer-span">' . str_pad($mlw_complete_hours, 2, '0', STR_PAD_LEFT) . '</span>';
150
+ $hour_label = $mlw_complete_hours == 1 ? __( 'hour', 'quiz-master-next' ) : __( 'hours', 'quiz-master-next' );
151
+ $template .= '<span class="timer-text">'. $hour_label .'</span>';
152
+ $template .= '</div>';
153
+ }else{
154
+ $template .= '<div>';
155
+ $template .= '<span class="hours timer-span">00</span>';
156
+ $template .= '<span class="timer-text">hours</span>';
157
+ $template .= '</div>';
158
+ }
159
+ $mlw_complete_minutes = floor(($mlw_qmn_results_array[0] % 3600) / 60);
160
+ if ( $mlw_complete_minutes > 0 ) {
161
+ $template .= '<div>';
162
+ $template .= '<span class="minutes timer-span">' . str_pad($mlw_complete_minutes, 2, '0', STR_PAD_LEFT) . '</span>';
163
+ $min_label = $mlw_complete_minutes == 1 ? __( 'minute', 'quiz-master-next' ) : __( 'minutes', 'quiz-master-next' );
164
+ $template .= '<span class="timer-text">' . $min_label . '</span>';
165
+ $template .= '</div>';
166
+ } else {
167
+ $template .= '<div>';
168
+ $template .= '<span class="minutes timer-span">00</span>';
169
+ $template .= '<span class="timer-text">minutes</span>';
170
+ $template .= '</div>';
171
+ }
172
+ $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60;
173
+ $template .= '<div>';
174
+ $template .= '<span class="seconds timer-span">' . str_pad($mlw_complete_seconds, 2, '0', STR_PAD_LEFT) . '</span>';
175
+ $sec_label = $mlw_complete_seconds == 1 ? __( 'second', 'quiz-master-next' ) : __( 'seconds', 'quiz-master-next' );
176
+ $template .= '<span class="timer-text">' . $sec_label . '</span>';
177
+ $template .= '</div>';
178
+ }
179
+ $template .= '</div>';
180
+ $template .= '</div>';
181
+ $template .= '</div>';
182
+ $template .= '</div>';
183
+ $template .= '</div>';
184
+ //Comment entered text
185
+ $template .= '<div class="comment-inner-wrap" style="display: none;">';
186
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>User Comments</span></h2>';
187
+ $template .= '<div class="inside">';
188
+ $template .= '%COMMENT_SECTION%';
189
+ $template .= '</div>';
190
+ $template .= '</div>';
191
+ $template .= '</div>';
192
+ //Response div
193
+ $template .= '<div class="response-inner-wrap">';
194
+ $template .= '<div id="submitdiv" class="postbox "><h2 class="hndle ui-sortable-handle"><span>Responses</span></h2>';
195
+ $template .= '<div class="inside">';
196
+ $template .= '%QUESTIONS_ANSWERS%';
197
+ $template .= '</div>';
198
+ $template .= '</div>';
199
+ $template .= '</div>';
200
+ }else{
201
+ $template = 'Data is missing.';
202
+ }
203
+ }else{
204
+ //Old template design
205
+ if ( isset( $settings['results_details_template'] ) ) {
206
+ $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
207
+ } else {
208
+ $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
209
+ <p>%CONTACT_ALL%</p>
210
+ <p>Name Provided: %USER_NAME%</p>
211
+ <p>Business Provided: %USER_BUSINESS%</p>
212
+ <p>Phone Provided: %USER_PHONE%</p>
213
+ <p>Email Provided: %USER_EMAIL%</p>
214
+ <p>Score Received: %AMOUNT_CORRECT%/%TOTAL_QUESTIONS% or %CORRECT_SCORE%% or %POINT_SCORE% points</p>
215
+ <h2>Answers Provided:</h2>
216
+ <p>The user took %TIMER% to complete quiz.</p>
217
+ <p>Comments entered were: %COMMENT_SECTION%</p>
218
+ <p>The answers were as follows:</p>
219
+ %QUESTIONS_ANSWERS%";
220
+ }
221
+ }
222
+
223
+ // Prepare responses array.
224
+ if ( is_serialized( $results_data->quiz_results ) && is_array( @unserialize( $results_data->quiz_results ) ) ) {
225
+ $results = unserialize($results_data->quiz_results);
226
+ if ( ! isset( $results["contact"] ) ) {
227
+ $results["contact"] = array();
228
+ }
229
+ } else {
230
+ $template = str_replace( "%QUESTIONS_ANSWERS%" , $results_data->quiz_results, $template);
231
+ $template = str_replace( "%TIMER%" , '', $template);
232
+ $template = str_replace( "%COMMENT_SECTION%" , '', $template);
233
+ $results = array(
234
+ 0,
235
+ array(),
236
+ '',
237
+ 'contact' => array()
238
+ );
239
+ }
240
+
241
+ // Prepare full results array.
242
+ $results_array = array(
243
+ 'quiz_id' => $results_data->quiz_id,
244
+ 'quiz_name' => $results_data->quiz_name,
245
+ 'quiz_system' => $results_data->quiz_system,
246
+ 'form_type' => $results_data->form_type,
247
+ 'user_name' => $results_data->name,
248
+ 'user_business' => $results_data->business,
249
+ 'user_email' => $results_data->email,
250
+ 'user_phone' => $results_data->phone,
251
+ 'user_id' => $results_data->user,
252
+ 'timer' => isset($results[0]) ? $results[0] : 0,
253
+ 'time_taken' => $results_data->time_taken,
254
+ 'total_points' => $results_data->point_score,
255
+ 'total_score' => $results_data->correct_score,
256
+ 'total_correct' => $results_data->correct,
257
+ 'total_questions' => $results_data->total,
258
+ 'comments' => isset( $results[2] ) ? $results[2] : '',
259
+ 'question_answers_array' => isset( $results[1] ) ? $results[1] : array(),
260
+ 'contact' => $results["contact"],
261
+ 'results' => $results,
262
+ );
263
 
264
+ // Pass through template variable filter
265
+ $template = apply_filters( 'mlw_qmn_template_variable_results_page', $template, $results_array );
266
+ $template = str_replace( "\n" , "<br>", $template );
267
+ if( $new_template_result_detail == 0 ){
268
+ echo '<div class="old_template_result_wrap">';
269
+ }
270
+ echo wp_kses_post( $template );
271
+ if( $new_template_result_detail == 0 ){
272
+ echo '</div>';
273
+ }
274
  // Hook for below admin results
275
  do_action( 'qsm_below_admin_results', $results_array );
276
  }
284
  */
285
  function qsm_results_details_tab() {
286
  global $mlwQuizMasterNext;
287
+ $mlwQuizMasterNext->pluginHelper->register_results_settings_tab( "Results", "qsm_generate_results_details_tab" );
288
  }
289
  add_action( "plugins_loaded", 'qsm_results_details_tab' );
290
  ?>
php/admin/admin-results-page.php CHANGED
@@ -118,7 +118,7 @@ function qsm_results_overview_tab_content() {
118
  if ( isset( $_POST["bulk_delete"] ) && wp_verify_nonce( $_POST['bulk_delete_nonce'], 'bulk_delete') ) {
119
 
120
  // Ensure the POST variable is an array
121
- if ( is_array( $_POST["delete_results"] ) ) {
122
 
123
  // Cycle through the POST array which should be an array of the result ids of the results the user wishes to delete
124
  foreach( $_POST["delete_results"] as $result ) {
@@ -285,30 +285,31 @@ function qsm_results_overview_tab_content() {
285
  </span>
286
  <br class="clear">
287
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  </div>
289
- <form action='' method="get">
290
- <?php
291
- if ( isset( $_GET['quiz_id'] ) ) {
292
- ?>
293
- <input type="hidden" name="quiz_id" value="<?php echo esc_attr( intval( $_GET['quiz_id'] ) ); ?>" />
294
- <?php
295
- }
296
- ?>
297
- <input type="hidden" name="page" value="mlw_quiz_results">
298
- <p class="search-box">
299
- <label for="qsm_search_phrase"><?php esc_html_e( 'Search Results', 'quiz-master-next' ); ?></label>
300
- <input type="search" id="qsm_search_phrase" name="qsm_search_phrase" value="">
301
- <label for="qmn_order_by"><?php esc_html_e( 'Order By', 'quiz-master-next' ); ?></label>
302
- <select id="qmn_order_by" name="qmn_order_by">
303
- <option value="quiz_name"><?php esc_html_e( 'Quiz Name', 'quiz-master-next' ); ?></option>
304
- <option value="name"><?php esc_html_e( 'User Name', 'quiz-master-next' ); ?></option>
305
- <option value="point_score"><?php esc_html_e( 'Points', 'quiz-master-next' ); ?></option>
306
- <option value="correct_score"><?php esc_html_e( 'Correct Percent', 'quiz-master-next' ); ?></option>
307
- <option value="default"><?php esc_html_e( 'Default (Time)', 'quiz-master-next' ); ?></option>
308
- </select>
309
- <button class="button"><?php esc_html_e( 'Search Results', 'quiz-master-next' ); ?></button>
310
- </p>
311
- </form>
312
  <form action="" method="post" name="bulk_delete_form">
313
  <input type="hidden" name="bulk_delete" value="confirmation" />
314
  <input type="hidden" name="bulk_permanent_delete" id="bulk_permanent_delete" value="0" />
@@ -358,15 +359,20 @@ function qsm_results_overview_tab_content() {
358
  $quotes_list .= "<tr{$alternate}>";
359
  $quotes_list .= "<td><input type='checkbox' class='qmn_delete_checkbox' name='delete_results[]' value='".$mlw_quiz_info->result_id. "' /></td>";
360
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span><div class='row-actions'><span style='color:green;font-size:16px;'><a href='admin.php?page=qsm_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a> | <a style='color: red;' onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></div></td>";
361
- if ( $mlw_quiz_info->quiz_system == 0 ) {
362
- $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
363
- }
364
- if ( $mlw_quiz_info->quiz_system == 1 ) {
365
- $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
366
- }
367
- if ( $mlw_quiz_info->quiz_system == 2 ) {
368
- $quotes_list .= "<td><span style='font-size:16px;'>".__('Not Graded','quiz-master-next' )."</span></td>";
369
- }
 
 
 
 
 
370
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_complete_time ."</span></td>";
371
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
372
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
118
  if ( isset( $_POST["bulk_delete"] ) && wp_verify_nonce( $_POST['bulk_delete_nonce'], 'bulk_delete') ) {
119
 
120
  // Ensure the POST variable is an array
121
+ if ( isset( $_POST["delete_results"] ) && is_array( $_POST["delete_results"] ) ) {
122
 
123
  // Cycle through the POST array which should be an array of the result ids of the results the user wishes to delete
124
  foreach( $_POST["delete_results"] as $result ) {
285
  </span>
286
  <br class="clear">
287
  </div>
288
+ <form action='' method="get">
289
+ <?php
290
+ if ( isset( $_GET['quiz_id'] ) ) {
291
+ ?>
292
+ <input type="hidden" name="quiz_id" value="<?php echo esc_attr( intval( $_GET['quiz_id'] ) ); ?>" />
293
+ <?php
294
+ }
295
+ ?>
296
+ <input type="hidden" name="page" value="mlw_quiz_results">
297
+ <p class="search-box">
298
+ <label for="qsm_search_phrase"><?php esc_html_e( 'Search Results', 'quiz-master-next' ); ?></label>
299
+ <input type="search" id="qsm_search_phrase" name="qsm_search_phrase" value="">
300
+ <label for="qmn_order_by"><?php esc_html_e( 'Order By', 'quiz-master-next' ); ?></label>
301
+ <select id="qmn_order_by" name="qmn_order_by">
302
+ <option value="quiz_name"><?php esc_html_e( 'Quiz Name', 'quiz-master-next' ); ?></option>
303
+ <option value="name"><?php esc_html_e( 'User Name', 'quiz-master-next' ); ?></option>
304
+ <option value="point_score"><?php esc_html_e( 'Points', 'quiz-master-next' ); ?></option>
305
+ <option value="correct_score"><?php esc_html_e( 'Correct Percent', 'quiz-master-next' ); ?></option>
306
+ <option value="default"><?php esc_html_e( 'Default (Time)', 'quiz-master-next' ); ?></option>
307
+ </select>
308
+ <button class="button"><?php esc_html_e( 'Search Results', 'quiz-master-next' ); ?></button>
309
+ </p>
310
+ </form>
311
  </div>
312
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  <form action="" method="post" name="bulk_delete_form">
314
  <input type="hidden" name="bulk_delete" value="confirmation" />
315
  <input type="hidden" name="bulk_permanent_delete" id="bulk_permanent_delete" value="0" />
359
  $quotes_list .= "<tr{$alternate}>";
360
  $quotes_list .= "<td><input type='checkbox' class='qmn_delete_checkbox' name='delete_results[]' value='".$mlw_quiz_info->result_id. "' /></td>";
361
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->quiz_name . "</span><div class='row-actions'><span style='color:green;font-size:16px;'><a href='admin.php?page=qsm_quiz_result_details&&result_id=".$mlw_quiz_info->result_id."'>View</a> | <a style='color: red;' onclick=\"deleteResults('".$mlw_quiz_info->result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete</a></span></div></td>";
362
+ $form_type = isset( $mlw_quiz_info->form_type ) ? $mlw_quiz_info->form_type : 0;
363
+ if( $form_type == 1 || $form_type == 2 ){
364
+ $quotes_list .= "<td><span style='font-size:16px;'>".__('Not Graded','quiz-master-next' )."</span></td>";
365
+ } else {
366
+ if ( $mlw_quiz_info->quiz_system == 0 ) {
367
+ $quotes_list .= "<td class='post-title column-title'><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span></td>";
368
+ }
369
+ if ( $mlw_quiz_info->quiz_system == 1 ) {
370
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
371
+ }
372
+ if ( $mlw_quiz_info->quiz_system == 3 ) {
373
+ $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%</span><br/><span style='font-size:16px;'>" . $mlw_quiz_info->point_score . " Points</span></td>";
374
+ }
375
+ }
376
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_complete_time ."</span></td>";
377
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->name ."</span></td>";
378
  $quotes_list .= "<td><span style='font-size:16px;'>" . $mlw_quiz_info->business ."</span></td>";
php/admin/functions.php CHANGED
@@ -26,7 +26,6 @@ function qsm_redirect_to_edit_page($quiz_id){
26
  }
27
 
28
  add_action('admin_init','qsm_add_author_column_in_db');
29
-
30
  /**
31
  * @since 6.4.6
32
  * Insert new column in quiz table
@@ -62,6 +61,35 @@ function qsm_add_author_column_in_db() {
62
  update_option( 'qsm_update_db_column', '1' );
63
 
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
 
@@ -98,6 +126,437 @@ function qsm_change_the_post_type(){
98
  }
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  add_action('admin_init', 'qsm_update_question_type_col_val');
103
 
@@ -127,3 +586,16 @@ function qsm_update_question_type_col_val() {
127
  }
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
  add_action('admin_init','qsm_add_author_column_in_db');
 
29
  /**
30
  * @since 6.4.6
31
  * Insert new column in quiz table
61
  update_option( 'qsm_update_db_column', '1' );
62
 
63
  }
64
+
65
+ //Update result db
66
+ if( get_option('qsm_update_result_db_column', '') != '1' ){
67
+ global $wpdb;
68
+ $result_table_name = $wpdb->prefix . "mlw_results";
69
+ $table_result_col_obj = $wpdb->get_results( $wpdb->prepare(
70
+ 'SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ', $wpdb->dbname, $result_table_name, 'form_type'
71
+ ) );
72
+ if ( empty( $table_result_col_obj ) ) {
73
+ $wpdb->query("ALTER TABLE $result_table_name ADD form_type INT NOT NULL");
74
+ }
75
+ update_option('qsm_update_result_db_column', '1');
76
+ }
77
+
78
+ /**
79
+ * Changed the system word to quiz_system in quiz table
80
+ * @since 7.0.0
81
+ */
82
+ if( get_option('qsm_update_quiz_db_column', '') != '1' ){
83
+ global $wpdb;
84
+ $quiz_table_name = $wpdb->prefix . "mlw_quizzes";
85
+ $table_quiz_col_obj = $wpdb->get_results( $wpdb->prepare(
86
+ 'SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ', $wpdb->dbname, $quiz_table_name, 'system'
87
+ ) );
88
+ if ( !empty( $table_quiz_col_obj ) ) {
89
+ $wpdb->query("ALTER TABLE $quiz_table_name CHANGE `system` `quiz_system` INT(11) NOT NULL;");
90
+ }
91
+ update_option('qsm_update_quiz_db_column', '1');
92
+ }
93
  }
94
 
95
 
126
  }
127
  }
128
 
129
+ /**
130
+ * @since 7.0.0
131
+ * @param arr $single_option
132
+ */
133
+ function qsm_display_question_option($key, $single_option){
134
+ $type = isset($single_option['type']) ? $single_option['type'] : 'text';
135
+ $show = isset($single_option['show']) ? explode(',', $single_option['show']) : array();
136
+ $show_class = '';
137
+ if($show){
138
+ foreach($show as $show_value){
139
+ $show_class .= 'qsm_show_question_type_' . trim( $show_value ) .' ';
140
+ }
141
+ $show_class .= ' qsm_hide_for_other';
142
+ }
143
+ $tooltip = '';
144
+ $document_text = '';
145
+ if( isset($single_option['tooltip']) && $single_option['tooltip'] != '' ){
146
+ $tooltip .= '<span class="dashicons dashicons-editor-help qsm-tooltips-icon">';
147
+ $tooltip .= '<span class="qsm-tooltips">' . $single_option['tooltip'] . '</span>';
148
+ $tooltip .= '</span>';
149
+ }
150
+ if( isset($single_option['documentation_link']) && $single_option['documentation_link'] != '' ){
151
+ $document_text .= '<a class="qsm-question-doc" href="'. $single_option['documentation_link'] .'" target="_blank" title="'. __('View Documentation', 'quiz-master-next') .'">';
152
+ $document_text .= '<span class="dashicons dashicons-media-document"></span>';
153
+ $document_text .= '</a>';
154
+ }
155
+ switch ($type){
156
+ case 'text':
157
+ ?>
158
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
159
+ <label>
160
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
161
+ <?php echo $tooltip; ?>
162
+ <?php echo $document_text; ?>
163
+ </label>
164
+ <input type="text" name="<?php echo $key; ?>" value="<?php echo isset($single_option['default']) ? $single_option['default'] : ''; ?>" id="<?php echo $key ?>" />
165
+ </div>
166
+ <?php
167
+ break;
168
+
169
+ case 'textarea':
170
+ ?>
171
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
172
+ <label>
173
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
174
+ <?php echo $tooltip; ?>
175
+ <?php echo $document_text; ?>
176
+ </label>
177
+ <textarea name="<?php echo $key; ?>" id="<?php echo $key ?>"><?php echo isset($single_option['default']) ? $single_option['default'] : ''; ?></textarea>
178
+ </div>
179
+ <?php
180
+ break;
181
+
182
+ case 'number':
183
+ ?>
184
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
185
+ <label>
186
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
187
+ <?php echo $tooltip; ?>
188
+ <?php echo $document_text; ?>
189
+ </label>
190
+ <input type="number" name="<?php echo $key; ?>" value="<?php echo isset($single_option['default']) ? $single_option['default'] : ''; ?>" id="<?php echo $key ?>" />
191
+ </div>
192
+ <?php
193
+ break;
194
+
195
+ case 'select':
196
+ ?>
197
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
198
+ <label>
199
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
200
+ <?php echo $tooltip; ?>
201
+ <?php echo $document_text; ?>
202
+ </label>
203
+ <select name="<?php echo $key; ?>" id="<?php echo $key ?>">
204
+ <?php
205
+ $default = isset($single_option['default']) ? $single_option['default'] : '';
206
+ if(isset($single_option['options']) && is_array($single_option['options'])){
207
+ foreach ($single_option['options'] as $key => $value) {
208
+ $selected = $key === $default ? 'selected = selected' : '';
209
+ ?>
210
+ <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $value; ?></option>
211
+ <?php
212
+ }
213
+ }
214
+ ?>
215
+ </select>
216
+ </div>
217
+ <?php
218
+ break;
219
+
220
+ case 'textarea':
221
+ ?>
222
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
223
+ <label>
224
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
225
+ <?php echo $tooltip; ?>
226
+ <?php echo $document_text; ?>
227
+ </label>
228
+ <textarea id="<?php echo $key ?>" name="<?php echo $key; ?>"><?php echo isset($single_option['default']) ? $single_option['default'] : ''; ?></textarea>
229
+ </div>
230
+ <?php
231
+ break;
232
+
233
+ case 'category':
234
+ ?>
235
+ <div id="category_area" class="qsm-row <?php echo $show_class; ?>">
236
+ <label>
237
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
238
+ <?php echo $tooltip; ?>
239
+ <?php echo $document_text; ?>
240
+ </label>
241
+ <div id="categories">
242
+ <a id="qsm-category-add-toggle" class="hide-if-no-js">
243
+ <?php _e( '+ Add New Category', 'quiz-master-next' ); ?>
244
+ </a>
245
+ <p id="qsm-category-add" style="display: none;">
246
+ <input type="radio" style="display: none;" name="category" class="category-radio" id="new_category_new" value="new_category"><label for="new_category_new"><input type='text' id='new_category' value='' placeholder="Add new category" /></label>
247
+ </p>
248
+ </div>
249
+ </div>
250
+ <?php
251
+ break;
252
+
253
+ case 'multi_checkbox':
254
+ ?>
255
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
256
+ <label>
257
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
258
+ <?php echo $tooltip; ?>
259
+ <?php echo $document_text; ?>
260
+ </label>
261
+ <?php
262
+ $parent_key = $key;
263
+ $default = isset($single_option['default']) ? $single_option['default'] : '';
264
+ if(isset($single_option['options']) && is_array($single_option['options'])){
265
+ foreach ($single_option['options'] as $key => $value) {
266
+ $selected = $key === $default ? 'checked' : '';
267
+ ?>
268
+ <input name="<?php echo $parent_key; ?>[]" type="checkbox" value="<?php echo $key; ?>" <?php echo $selected; ?> /> <?php echo $value; ?><br/>
269
+ <?php
270
+ }
271
+ }
272
+ ?>
273
+ </div>
274
+ <?php
275
+ break;
276
+
277
+ case 'single_checkbox':
278
+ ?>
279
+ <div id="<?php echo $key; ?>_area" class="qsm-row <?php echo $show_class; ?>">
280
+ <label>
281
+ <?php
282
+ $parent_key = $key;
283
+ $default = isset($single_option['default']) ? $single_option['default'] : '';
284
+ if(isset($single_option['options']) && is_array($single_option['options'])){
285
+ foreach ($single_option['options'] as $key => $value) {
286
+ $selected = $key === $default ? 'checked' : '';
287
+ ?>
288
+ <input name="<?php echo $parent_key; ?>" id="<?php echo $parent_key ?>" type="checkbox" value="<?php echo $key; ?>" <?php echo $selected; ?> />
289
+ <?php
290
+ }
291
+ }
292
+ ?>
293
+ <?php echo isset($single_option['label']) ? $single_option['label'] : ''; ?>
294
+ <?php echo $tooltip; ?>
295
+ <?php echo $document_text; ?>
296
+ </label>
297
+ </div>
298
+ <?php
299
+ break;
300
+
301
+ default:
302
+ //Do nothing
303
+ }
304
+
305
+ }
306
+
307
+ /**
308
+ * @since 7.0
309
+ * New quiz popup
310
+ */
311
+ function qsm_create_new_quiz_wizard(){ ?>
312
+ <div class="qsm-popup qsm-popup-slide" id="model-wizard" aria-hidden="true">
313
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
314
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-2-title">
315
+ <header class="qsm-popup__header">
316
+ <h2 class="qsm-popup__title" id="modal-2-title"><?php _e('Create New Quiz Or Survey', 'quiz-master-next'); ?></h2>
317
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
318
+ </header>
319
+ <main class="qsm-popup__content" id="modal-2-content">
320
+ <?php
321
+ $qsm_quiz_templates = array(
322
+ array(
323
+ 'template_name' => __('Start from scratch', 'quiz-master-next'),
324
+ 'priority' => '1',
325
+ 'options' => array(
326
+ 'form_type' => array(
327
+ 'option_name' => 'Form Type',
328
+ 'value' => 0
329
+ ),
330
+ 'system' => array(
331
+ 'option_name' => 'Graded System',
332
+ 'value' => 0
333
+ ),
334
+ 'require_log_in' => array(
335
+ 'option_name' => 'Require User Login',
336
+ 'value' => 0
337
+ )
338
+ ),
339
+ 'recommended_addon' => array(
340
+ array(
341
+ 'name' => 'Reporting And Analysis',
342
+ 'link' => 'https://quizandsurveymaster.com/downloads/results-analysis/',
343
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/Reporting-And-Analysis.jpg',
344
+ 'attribute' => 'recommended'
345
+ ),
346
+ array(
347
+ 'name' => 'Export & Import',
348
+ 'link' => 'https://quizandsurveymaster.com/downloads/export-import/',
349
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/Export-Import.jpg',
350
+ 'attribute' => 'recommended'
351
+ ),
352
+ )
353
+ ),
354
+ array(
355
+ 'template_name' => __('Simple Quiz', 'quiz-master-next'),
356
+ 'priority' => '2',
357
+ 'template_img' => QSM_PLUGIN_URL . '/assets/simple-quiz.png',
358
+ 'options' => array(
359
+ 'form_type' => array(
360
+ 'option_name' => 'Form Type',
361
+ 'value' => 0
362
+ ),
363
+ 'system' => array(
364
+ 'option_name' => 'Graded System',
365
+ 'value' => 0
366
+ ),
367
+ 'require_log_in' => array(
368
+ 'option_name' => 'Require User Login',
369
+ 'value' => 0
370
+ ),
371
+ 'enable_result_after_timer_end' => array(
372
+ 'option_name' => 'Force Submit',
373
+ 'value' => 0
374
+ )
375
+ ),
376
+ 'recommended_addon' => array(
377
+ array(
378
+ 'name' => 'Payment Integration',
379
+ 'link' => 'https://quizandsurveymaster.com/downloads/paypal-and-stripe-payment-integration/',
380
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/Paypal-and-Stripe-Payment-Integration-300x170.jpg',
381
+ 'attribute' => 'recommended'
382
+ ),
383
+ array(
384
+ 'name' => 'Recaptcha',
385
+ 'link' => 'https://quizandsurveymaster.com/downloads/recaptcha/',
386
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/reCaptcha.jpg',
387
+ 'attribute' => 'recommended'
388
+ ),
389
+ )
390
+ ),
391
+ array(
392
+ 'template_name' => __('Time Based Quiz', 'quiz-master-next'),
393
+ 'priority' => '3',
394
+ 'template_img' => QSM_PLUGIN_URL . '/assets/time-based-quiz.png',
395
+ 'options' => array(
396
+ 'form_type' => array(
397
+ 'option_name' => 'Form Type',
398
+ 'value' => 0
399
+ ),
400
+ 'system' => array(
401
+ 'option_name' => 'Graded System',
402
+ 'value' => 0
403
+ ),
404
+ 'timer_limit' => array(
405
+ 'option_name' => 'Time Limit (in Minute)',
406
+ 'value' => 0
407
+ )
408
+ ),
409
+ 'recommended_addon' => array(
410
+ array(
411
+ 'name' => 'Save and Resume',
412
+ 'link' => 'https://quizandsurveymaster.com/downloads/save-and-resume/',
413
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/Save-and-Resume.jpg',
414
+ 'attribute' => 'recommended'
415
+ ),
416
+ array(
417
+ 'name' => 'Advanced Timer',
418
+ 'link' => 'https://quizandsurveymaster.com/downloads/wordpress-quiz-timer-advanced/',
419
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/35.jpg',
420
+ 'attribute' => 'recommended'
421
+ ),
422
+ )
423
+ ),
424
+ array(
425
+ 'template_name' => __('Survey', 'quiz-master-next'),
426
+ 'priority' => '4',
427
+ 'template_img' => QSM_PLUGIN_URL . '/assets/survey-quiz.png',
428
+ 'options' => array(
429
+ 'form_type' => array(
430
+ 'option_name' => 'Form Type',
431
+ 'value' => 1
432
+ ),
433
+ 'system' => array(
434
+ 'option_name' => 'Graded System',
435
+ 'value' => 0
436
+ ),
437
+ 'progress_bar' => array(
438
+ 'option_name' => 'Progress Bar',
439
+ 'value' => 0
440
+ )
441
+ ),
442
+ 'recommended_addon' => array(
443
+ array(
444
+ 'name' => 'Daily Limit',
445
+ 'link' => 'https://quizandsurveymaster.com/downloads/daily-limit/',
446
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/Daily-Limit.jpg',
447
+ 'attribute' => 'recommended'
448
+ ),
449
+ array(
450
+ 'name' => 'Google Sheet Connector',
451
+ 'link' => 'https://quizandsurveymaster.com/downloads/sync-with-google-sheets/',
452
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/03/first-1.jpg',
453
+ 'attribute' => 'recommended'
454
+ ),
455
+ array(
456
+ 'name' => 'Mailchimp Integration',
457
+ 'link' => 'https://quizandsurveymaster.com/downloads/mailchimp-integration/',
458
+ 'img' => 'https://t6k8i7j6.stackpathcdn.com/wp-content/uploads/edd/2020/04/MailChimp-Integration.jpg',
459
+ 'attribute' => 'recommended'
460
+ ),
461
+ )
462
+ ),
463
+ );
464
+ $qsm_quiz_templates = apply_filters('qsm_wizard_quiz_templates', $qsm_quiz_templates);
465
+ $keys = array_column($qsm_quiz_templates, 'priority');
466
+ array_multisort($keys, SORT_ASC, $qsm_quiz_templates);
467
+ ?>
468
+ <form action="" method="post" id="new-quiz-form">
469
+ <div class="qsm-wizard-template-section">
470
+ <?php wp_nonce_field('qsm_new_quiz', 'qsm_new_quiz_nonce'); ?>
471
+ <input type="text" class="quiz_name" name="quiz_name" value="" placeholder="<?php _e('Enter quiz name here', 'quiz-master-next'); ?>" required/>
472
+ <div class="template-inner-wrap">
473
+ <h6><?php _e('Select Template', 'quiz-master-next'); ?></h6>
474
+ <div class="template-list">
475
+ <?php
476
+ if( $qsm_quiz_templates ){
477
+ foreach ($qsm_quiz_templates as $key => $single_template) {
478
+ if(isset($single_template['priority']) && $single_template['priority'] == 1){ ?>
479
+ <div class="template-list-inner" data-settings='<?php echo isset($single_template['options']) ? json_encode($single_template['options']) : ''; ?>' data-addons='<?php echo isset($single_template['recommended_addon']) ? json_encode($single_template['recommended_addon']) : ''; ?>'>
480
+ <div class="template-center-vertical">
481
+ <span class="dashicons dashicons-plus-alt2"></span>
482
+ <p class="start_scratch"><?php echo isset($single_template['template_name']) ? $single_template['template_name'] : ''; ?></p>
483
+ </div>
484
+ </div>
485
+ <?php
486
+ }else{ ?>
487
+ <div class="template-list-inner inner-json" data-settings='<?php echo isset($single_template['options']) ? json_encode($single_template['options']) : ''; ?>' data-addons='<?php echo isset($single_template['recommended_addon']) ? json_encode($single_template['recommended_addon']) : ''; ?>'>
488
+ <div class="template-center-vertical">
489
+ <?php
490
+ if( isset($single_template['template_img']) ){ ?>
491
+ <img src="<?php echo $single_template['template_img']; ?>" title="<?php echo isset($single_template['template_name']) ? $single_template['template_name'] : ''; ?>">
492
+ <?php
493
+ }
494
+ ?>
495
+ </div>
496
+ <h3><?php echo isset($single_template['template_name']) ? $single_template['template_name'] : ''; ?></h3>
497
+ </div>
498
+ <?php
499
+ }
500
+ }
501
+ }
502
+ ?>
503
+ </div>
504
+ </div>
505
+ </div>
506
+ <div class="qsm-wizard-setting-section">
507
+ <div id="accordion">
508
+ <h3><?php _e('Quiz Settings', 'quiz-master-next'); ?></h3>
509
+ <div id="quiz_settings_wrapper"></div>
510
+ <h3><?php _e('Recommended Addons', 'quiz-master-next'); ?></h3>
511
+ <div id="recomm_addons_wrapper"></div>
512
+ </div>
513
+ </div>
514
+ </form>
515
+ </main>
516
+ <footer class="qsm-popup__footer">
517
+ <button id="create-quiz-button" class="button button-primary"><?php _e('Create Quiz', 'quiz-master-next'); ?></button>
518
+ <button class="button" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
519
+ </footer>
520
+ </div>
521
+ </div>
522
+ </div>
523
+ <?php
524
+ }
525
+
526
+ /**
527
+ * @since 7.0
528
+ * @return array Template Variable
529
+ */
530
+ function qsm_text_template_variable_list(){
531
+ $variable_list = array(
532
+ '%POINT_SCORE%' => __('Score for the quiz when using points', 'quiz-master-next'),
533
+ '%AVERAGE_POINT%' => __('The average amount of points user had per question', 'quiz-master-next'),
534
+ '%AMOUNT_CORRECT%' => __('The number of correct answers the user had', 'quiz-master-next'),
535
+ '%TOTAL_QUESTIONS%' => __('The total number of questions in the quiz', 'quiz-master-next'),
536
+ '%CORRECT_SCORE%' => __('Score for the quiz when using correct answers', 'quiz-master-next'),
537
+ '%USER_NAME%' => __('The name the user entered before the quiz', 'quiz-master-next'),
538
+ '%USER_BUSINESS%' => __('The business the user entered before the quiz', 'quiz-master-next'),
539
+ '%USER_PHONE%' => __('The phone number the user entered before the quiz', 'quiz-master-next'),
540
+ '%USER_EMAIL%' => __('The email the user entered before the quiz', 'quiz-master-next'),
541
+ '%QUIZ_NAME%' => __('The name of the quiz', 'quiz-master-next'),
542
+ '%QUESTIONS_ANSWERS%' => __('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'),
543
+ '%COMMENT_SECTION%' => __('The comments the user entered into comment box if enabled', 'quiz-master-next'),
544
+ '%TIMER%' => __('The amount of time user spent on quiz in seconds', 'quiz-master-next'),
545
+ '%TIMER_MINUTES%' => __('The amount of time user spent on quiz in minutes', 'quiz-master-next'),
546
+ '%CATEGORY_POINTS_X%' => __('X: Category name - The amount of points a specific category earned.', 'quiz-master-next'),
547
+ '%CATEGORY_SCORE_X%' => __('X: Category name - The score a specific category earned.', 'quiz-master-next'),
548
+ '%CATEGORY_AVERAGE_POINTS%' => __('The average points from all categories.', 'quiz-master-next'),
549
+ '%CATEGORY_AVERAGE_SCORE%' => __('The average score from all categories.', 'quiz-master-next'),
550
+ '%QUESTION%' => __('The question that the user answered', 'quiz-master-next'),
551
+ '%USER_ANSWER%' => __('The answer the user gave for the question', 'quiz-master-next'),
552
+ '%CORRECT_ANSWER%' => __('The correct answer for the question', 'quiz-master-next'),
553
+ '%USER_COMMENTS%' => __('The comments the user provided in the comment field for the question', 'quiz-master-next'),
554
+ '%CORRECT_ANSWER_INFO%' => __('Reason why the correct answer is the correct answer', 'quiz-master-next'),
555
+ '%CURRENT_DATE%' => __('The Current Date', 'quiz-master-next'),
556
+ );
557
+ $variable_list = apply_filters('qsm_text_variable_list', $variable_list);
558
+ return $variable_list;
559
+ }
560
 
561
  add_action('admin_init', 'qsm_update_question_type_col_val');
562
 
586
  }
587
  }
588
 
589
+ /**
590
+ * Check and create table if not present
591
+ *
592
+ * @since 7.0.0
593
+ */
594
+ function qsm_check_create_tables(){
595
+ global $wpdb;
596
+ $quiz_table_name = $wpdb->prefix . "mlw_quizzes";
597
+ if( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
598
+ QSM_Install::install();
599
+ }
600
+ }
601
+ add_action('admin_init', 'qsm_check_create_tables');
php/admin/help-page.php CHANGED
@@ -89,12 +89,12 @@ function qsm_get_system_info() {
89
  $parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
90
  }
91
 
92
- $sys_info .= '<h3>Site Information</h3><br />';
93
  $sys_info .= 'Site URL: ' . site_url() . '<br />';
94
  $sys_info .= 'Home URL: ' . home_url() . '<br />';
95
  $sys_info .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . '<br />';
96
 
97
- $sys_info .= '<h3>WordPress Information</h3><br />';
98
  $sys_info .= 'Version: ' . get_bloginfo( 'version' ) . '<br />';
99
  $sys_info .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . '<br />';
100
  $sys_info .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . '<br>';
@@ -103,15 +103,15 @@ function qsm_get_system_info() {
103
  $sys_info .= 'Debug Mode: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . '<br />';
104
  $sys_info .= 'Memory Limit: ' . WP_MEMORY_LIMIT . '<br />';
105
 
106
- $sys_info .= '<h3>Plugins Information</h3><br />';
107
  $plugin_mu = get_mu_plugins();
108
  if ( count( $plugin_mu ) > 0 ) {
109
- $sys_info .= '<h4>Must Use</h4><br />';
110
  foreach ( $plugin_mu as $plugin => $plugin_data ) {
111
  $sys_info .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "<br />";
112
  }
113
  }
114
- $sys_info .= '<h4>Active</h4><br />';
115
  $plugins = get_plugins();
116
  $active_plugins = get_option( 'active_plugins', array() );
117
  foreach ( $plugins as $plugin_path => $plugin ) {
@@ -120,7 +120,7 @@ function qsm_get_system_info() {
120
  }
121
  $sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . '<br />';
122
  }
123
- $sys_info .= '<h4>Inactive</h4><br />';
124
  foreach ( $plugins as $plugin_path => $plugin ) {
125
  if ( in_array( $plugin_path, $active_plugins ) ) {
126
  continue;
@@ -128,7 +128,7 @@ function qsm_get_system_info() {
128
  $sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . '<br />';
129
  }
130
 
131
- $sys_info .= '<h3>Server Information</h3><br />';
132
  $sys_info .= 'PHP : ' . PHP_VERSION . '<br />';
133
  $sys_info .= 'MySQL : ' . $wpdb->db_version() . '<br />';
134
  $sys_info .= 'Webserver : ' . $_SERVER['SERVER_SOFTWARE'] . '<br />';
@@ -140,7 +140,7 @@ function qsm_get_system_info() {
140
  $total_results = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}mlw_results LIMIT 1" );
141
  $total_active_results = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 LIMIT 1" );
142
 
143
- $sys_info .= '<h3>QSM Information</h3><br />';
144
  $sys_info .= 'Initial Version : ' . get_option( 'qmn_original_version' ) . '<br />';
145
  $sys_info .= 'Current Version : ' . $mlwQuizMasterNext->version . '<br />';
146
  $sys_info .= "Total Quizzes : {$total_quizzes}<br />";
@@ -150,7 +150,7 @@ function qsm_get_system_info() {
150
  $sys_info .= "Total Results : {$total_results}<br />";
151
  $sys_info .= "Total Active Results : {$total_active_results}<br />";
152
 
153
- $sys_info .= '<h3>QSM Recent Logs</h3><br />';
154
  $recent_errors = $mlwQuizMasterNext->log_manager->get_logs();
155
  if ( $recent_errors ) {
156
  foreach ( $recent_errors as $error ) {
89
  $parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
90
  }
91
 
92
+ $sys_info .= '<h3>Site Information</h3>';
93
  $sys_info .= 'Site URL: ' . site_url() . '<br />';
94
  $sys_info .= 'Home URL: ' . home_url() . '<br />';
95
  $sys_info .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . '<br />';
96
 
97
+ $sys_info .= '<h3>WordPress Information</h3>';
98
  $sys_info .= 'Version: ' . get_bloginfo( 'version' ) . '<br />';
99
  $sys_info .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . '<br />';
100
  $sys_info .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . '<br>';
103
  $sys_info .= 'Debug Mode: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . '<br />';
104
  $sys_info .= 'Memory Limit: ' . WP_MEMORY_LIMIT . '<br />';
105
 
106
+ $sys_info .= '<h3>Plugins Information</h3>';
107
  $plugin_mu = get_mu_plugins();
108
  if ( count( $plugin_mu ) > 0 ) {
109
+ $sys_info .= '<h4>Must Use</h4>';
110
  foreach ( $plugin_mu as $plugin => $plugin_data ) {
111
  $sys_info .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "<br />";
112
  }
113
  }
114
+ $sys_info .= '<h4>Active</h4>';
115
  $plugins = get_plugins();
116
  $active_plugins = get_option( 'active_plugins', array() );
117
  foreach ( $plugins as $plugin_path => $plugin ) {
120
  }
121
  $sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . '<br />';
122
  }
123
+ $sys_info .= '<h4>Inactive</h4>';
124
  foreach ( $plugins as $plugin_path => $plugin ) {
125
  if ( in_array( $plugin_path, $active_plugins ) ) {
126
  continue;
128
  $sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . '<br />';
129
  }
130
 
131
+ $sys_info .= '<h3>Server Information</h3>';
132
  $sys_info .= 'PHP : ' . PHP_VERSION . '<br />';
133
  $sys_info .= 'MySQL : ' . $wpdb->db_version() . '<br />';
134
  $sys_info .= 'Webserver : ' . $_SERVER['SERVER_SOFTWARE'] . '<br />';
140
  $total_results = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}mlw_results LIMIT 1" );
141
  $total_active_results = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}mlw_results WHERE deleted = 0 LIMIT 1" );
142
 
143
+ $sys_info .= '<h3>QSM Information</h3>';
144
  $sys_info .= 'Initial Version : ' . get_option( 'qmn_original_version' ) . '<br />';
145
  $sys_info .= 'Current Version : ' . $mlwQuizMasterNext->version . '<br />';
146
  $sys_info .= "Total Quizzes : {$total_quizzes}<br />";
150
  $sys_info .= "Total Results : {$total_results}<br />";
151
  $sys_info .= "Total Active Results : {$total_active_results}<br />";
152
 
153
+ $sys_info .= '<h3>QSM Recent Logs</h3>';
154
  $recent_errors = $mlwQuizMasterNext->log_manager->get_logs();
155
  if ( $recent_errors ) {
156
  foreach ( $recent_errors as $error ) {
php/admin/options-page-contact-tab.php CHANGED
@@ -48,8 +48,8 @@ function qsm_options_contact_tab_content() {
48
  */
49
 
50
  ?>
51
- <h2><?php _e( 'Contact', 'quiz-master-next' ); ?></h2>
52
- <p>Need assistance with this tab? <a href="https://quizandsurveymaster.com/docs/creating-quizzes-and-surveys/adding-contact-form-fields/" target="_blank">Check out the documentation</a> for this tab!</p>
53
  <div class="contact-message"></div>
54
  <a class="save-contact button-primary"><?php _e( 'Save Contact Fields', 'quiz-master-next' ); ?></a>
55
  <div class="contact-form"></div>
48
  */
49
 
50
  ?>
51
+ <h2 style="display: none;"><?php _e( 'Contact', 'quiz-master-next' ); ?></h2>
52
+ <p style="text-align: right;"><a href="https://quizandsurveymaster.com/docs/v7/contact-tab/" target="_blank"><?php _e( 'View Documentation', 'quiz-master-next' ); ?></a></p>
53
  <div class="contact-message"></div>
54
  <a class="save-contact button-primary"><?php _e( 'Save Contact Fields', 'quiz-master-next' ); ?></a>
55
  <div class="contact-form"></div>
php/admin/options-page-email-tab.php CHANGED
@@ -39,96 +39,22 @@ function qsm_options_emails_tab_content() {
39
  wp_localize_script( 'qsm_emails_admin_script', 'qsmEmailsObject', $js_data );
40
  wp_enqueue_editor();
41
  wp_enqueue_media();
42
- ?>
43
- <h2><?php esc_html_e( 'Emails', 'quiz-master-next' ); ?></h2>
44
- <p>Need assistance with this tab? <a href="https://quizandsurveymaster.com/docs/creating-quizzes-and-surveys/setting-up-emails/" target="_blank">Check out the documentation</a> for this tab!</p>
45
-
46
- <!-- Template Variable Section -->
47
- <section>
48
- <h3 style="text-align: center;"><?php esc_html_e( 'Template Variables', 'quiz-master-next' ); ?></h3>
49
- <div class="template_list_holder">
50
- <div class="template_variable">
51
- <span class="template_name">%CONTACT_X%</span> - <?php _e( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ); ?>
52
- </div>
53
- <div class="template_variable">
54
- <span class="template_name">%CONTACT_ALL%</span> - <?php _e( 'List user values for all contact fields', 'quiz-master-next' ); ?>
55
- </div>
56
- <div class="template_variable">
57
- <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
58
- </div>
59
- <div class="template_variable">
60
- <span class="template_name">%AVERAGE_POINT%</span> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?>
61
- </div>
62
- <div class="template_variable">
63
- <span class="template_name">%AMOUNT_CORRECT%</span> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?>
64
- </div>
65
- <div class="template_variable">
66
- <span class="template_name">%TOTAL_QUESTIONS%</span> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?>
67
- </div>
68
- <div class="template_variable">
69
- <span class="template_name">%CORRECT_SCORE%</span> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?>
70
- </div>
71
- <div class="template_variable">
72
- <span class="template_name">%USER_NAME%</span> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?>
73
- </div>
74
- <div class="template_variable">
75
- <span class="template_name">%USER_BUSINESS%</span> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?>
76
- </div>
77
- <div class="template_variable">
78
- <span class="template_name">%USER_PHONE%</span> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?>
79
- </div>
80
- <div class="template_variable">
81
- <span class="template_name">%USER_EMAIL%</span> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?>
82
- </div>
83
- <div class="template_variable">
84
- <span class="template_name">%QUIZ_NAME%</span> - <?php _e('The name of the quiz', 'quiz-master-next'); ?>
85
- </div>
86
- <div class="template_variable">
87
- <span class="template_name">%QUESTIONS_ANSWERS%</span> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?>
88
- </div>
89
- <div class="template_variable">
90
- <span class="template_name">%COMMENT_SECTION%</span> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?>
91
- </div>
92
- <div class="template_variable">
93
- <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent on quiz in seconds', 'quiz-master-next'); ?>
94
- </div>
95
- <div class="template_variable">
96
- <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent on quiz in minutes', 'quiz-master-next'); ?>
97
- </div>
98
- <div class="template_variable">
99
- <span class="template_name">%CATEGORY_POINTS_X%</span> - <?php _e('X: Category name - The amount of points a specific category earned.', 'quiz-master-next'); ?>
100
- </div>
101
- <div class="template_variable">
102
- <span class="template_name">%AVERAGE_CATEGORY_POINTS_X%</span> - <?php _e('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next'); ?>
103
- </div>
104
- <div class="template_variable">
105
- <span class="template_name">%CATEGORY_SCORE_X%</span> - <?php _e('X: Category name - The score a specific category earned.', 'quiz-master-next'); ?>
106
- </div>
107
- <div class="template_variable">
108
- <span class="template_name">%CATEGORY_AVERAGE_POINTS%</span> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?>
109
- </div>
110
- <div class="template_variable">
111
- <span class="template_name">%CATEGORY_AVERAGE_SCORE%</span> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?>
112
- </div>
113
- <div class="template_variable">
114
- <span class="template_name">%CURRENT_DATE%</span> - <?php _e('The Current Date', 'quiz-master-next'); ?>
115
- </div>
116
- <div class="template_variable">
117
- <span class="template_name">%QUESTION_ANSWER_X%</span> - <?php _e('X = Question ID. It will show result of particular question.', 'quiz-master-next'); ?>
118
- </div>
119
- <?php do_action('qmn_template_variable_list'); ?>
120
- </div>
121
- <div style="clear:both;"></div>
122
- </section>
123
-
124
  <!-- Emails Section -->
125
- <section>
126
- <h3>Your Emails</h3>
127
  <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
128
- <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
129
- <div id="emails"></div>
 
 
130
  <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
131
  <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
 
 
 
 
 
132
  </section>
133
 
134
  <!-- Templates -->
@@ -185,6 +111,51 @@ function qsm_options_emails_tab_content() {
185
  <input type="text" class="email-condition-value" value="{{ data.value }}">
186
  </div>
187
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  <?php
189
  }
190
  ?>
39
  wp_localize_script( 'qsm_emails_admin_script', 'qsmEmailsObject', $js_data );
40
  wp_enqueue_editor();
41
  wp_enqueue_media();
42
+ ?>
43
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  <!-- Emails Section -->
45
+ <section class="qsm-quiz-email-tab" style="margin-top: 15px;">
 
46
  <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
47
+ <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
48
+ <a style="float: right;" class="qsm-show-all-variable-text" href="#"><?php _e('Insert Template Variables', 'quiz-master-next'); ?> <span class="dashicons dashicons-upload"></span></a>
49
+ <a style="margin: 0 10px; float: right;" href="https://quizandsurveymaster.com/docs/v7/emails-tab/" target="_blank"><?php _e('View Documentation', 'quiz-master-next'); ?></a>
50
+ <div id="emails"><div style="margin-bottom: 30px;margin-top: 35px;" class="qsm-spinner-loader"></div></div>
51
  <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
52
  <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
53
+ <div class="qsm-alerts" style="margin-top: 20px;">
54
+ <?php
55
+ $mlwQuizMasterNext->alertManager->showAlerts();
56
+ ?>
57
+ </div>
58
  </section>
59
 
60
  <!-- Templates -->
111
  <input type="text" class="email-condition-value" value="{{ data.value }}">
112
  </div>
113
  </script>
114
+
115
+ <!--Template popup-->
116
+ <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
117
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
118
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
119
+ <header class="qsm-popup__header" style="display: block;">
120
+ <h2 class="qsm-popup__title"><?php _e('Template Variables', 'quiz-master-next'); ?></h2>
121
+ <span class="description"><?php _e('Use these dynamic variables to customize your quiz or survey. Just copy and paste one or more variables into the content templates and these will be replaced by actual values when user takes a quiz.', 'quiz-master-next'); ?></span>
122
+ </header>
123
+ <main class="qsm-popup__content" id="show-all-variable-content">
124
+ <?php
125
+ $variable_list = qsm_text_template_variable_list();
126
+ $email_exta_variable = array(
127
+ '%CONTACT_X%' => __( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ),
128
+ '%CONTACT_ALL%' => __( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ),
129
+ '%QUESTION_ANSWER_X%' => __('X = Question ID. It will show result of particular question.', 'quiz-master-next')
130
+ );
131
+ $variable_list = array_merge($email_exta_variable, $variable_list);
132
+ $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next');
133
+ unset($variable_list['%QUESTION%']);
134
+ unset($variable_list['%USER_ANSWER%']);
135
+ unset($variable_list['%CORRECT_ANSWER%']);
136
+ unset($variable_list['%USER_COMMENTS%']);
137
+ unset($variable_list['%CORRECT_ANSWER_INFO%']);
138
+ if( $variable_list ){
139
+ foreach ( $variable_list as $key => $s_variable ) { ?>
140
+ <div class="popup-template-span-wrap">
141
+ <span class="qsm-text-template-span">
142
+ <button class="button button-default"><?php echo $key; ?></button>
143
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
144
+ <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
145
+ </span>
146
+ </span>
147
+ </div>
148
+ <?php
149
+ }
150
+ }
151
+ ?>
152
+ </main>
153
+ <footer class="qsm-popup__footer" style="text-align: right;">
154
+ <button class="button button-default" data-micromodal-close="" aria-label="Close this dialog window"><?php _e('Close [Esc]', 'quiz-master-next'); ?></button>
155
+ </footer>
156
+ </div>
157
+ </div>
158
+ </div>
159
  <?php
160
  }
161
  ?>
php/admin/options-page-option-tab.php CHANGED
@@ -24,6 +24,9 @@ add_action( 'plugins_loaded', 'qsm_settings_options_tab', 5 );
24
  function qsm_options_option_tab_content() {
25
  global $wpdb;
26
  global $mlwQuizMasterNext;
 
 
 
27
  $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_options' );
28
  }
29
  ?>
24
  function qsm_options_option_tab_content() {
25
  global $wpdb;
26
  global $mlwQuizMasterNext;
27
+ ?>
28
+ <p style="text-align: right;"><a href="https://quizandsurveymaster.com/docs/v7/options-tab/" target="_blank"><?php _e( 'View Documentation', 'quiz-master-next' ); ?></a></p>
29
+ <?php
30
  $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_options' );
31
  }
32
  ?>
php/admin/options-page-questions-tab.php CHANGED
@@ -31,17 +31,37 @@ function qsm_options_questions_tab_content() {
31
 
32
  global $wpdb;
33
  global $mlwQuizMasterNext;
34
- $question_categories = $wpdb->get_results( "SELECT DISTINCT category FROM {$wpdb->prefix}mlw_questions", 'ARRAY_A' );
35
  $quiz_id = intval( $_GET['quiz_id'] );
36
- $user_id = get_current_user_id();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  $json_data = array(
38
  'quizID' => $quiz_id,
39
  'answerText' => __( 'Answer', 'quiz-master-next' ),
40
  'nonce' => wp_create_nonce( 'wp_rest' ),
41
- 'pages' => $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() ),
42
- 'qsm_user_ve' => get_user_meta($user_id, 'rich_editing', true),
43
- 'saveNonce' => wp_create_nonce('ajax-nonce-sandy-page'),
44
- 'categories' => $question_categories
 
 
 
45
  );
46
 
47
  // Scripts and styles.
@@ -82,22 +102,24 @@ function qsm_options_questions_tab_content() {
82
  <?php
83
  }
84
  ?>
85
- <h3>Questions</h3>
86
- <p>Use this tab to create and modify the different pages of your quiz or survey as well as the questions on each page. Click "Create New Page" to get started! Need more information? Check out the <a href="https://quizandsurveymaster.com/docs/creating-quizzes-and-surveys/adding-and-editing-questions/" target="_blank">documentation for this tab!</a></p>
87
  <div class="question-controls">
88
- <div>
89
- <button class="new-page-button button">Create New Page</button>
90
- <button class="save-page-button button-primary">Save Questions and Pages</button>
91
- </div>
92
- <span>Total Questions: <span id="total-questions"></span></span>
93
- <p class="search-box">
94
- <label class="screen-reader-text" for="question_search">Search Questions:</label>
95
- <input type="search" id="question_search" name="question_search" value="">
96
- <a href="#" class="button">Search Questions</a>
97
- </p>
98
  </div>
99
- <div class="questions"></div>
100
-
 
 
 
 
 
 
101
  <!-- Popup for question bank -->
102
  <div class="qsm-popup qsm-popup-slide qsm-popup-bank" id="modal-2" aria-hidden="true">
103
  <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
@@ -127,132 +149,369 @@ function qsm_options_questions_tab_content() {
127
  <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
128
  </header>
129
  <main class="qsm-popup__content" id="modal-1-content">
130
- <input type="hidden" name="edit_question_id" id="edit_question_id" value="">
131
- <div class="qsm-row">
132
- <label><?php _e( 'Question Type', 'quiz-master-next' ); ?></label>
133
- <select name="question_type" id="question_type">
134
- <?php
135
- foreach ( $question_types as $type ) {
136
- echo "<option value='{$type['slug']}'>{$type['name']}</option>";
137
- }
138
- ?>
139
- </select>
140
- <a class="question_info_tag" target="_blank" href="https://quizandsurveymaster.com/docs/about-quiz-survey-master/question-types/"><?php _e('How to use this option?','quiz_master_next') ?></a>
141
- </div>
142
- <p id="question_type_info"></p>
143
- <div class="qsm-row">
144
- <textarea id="question-text"></textarea>
145
- </div>
146
- <div class="qsm-row">
147
- <label><?php _e( 'Answers', 'quiz-master-next' ); ?></label>
148
- <div class="correct-header"><?php _e( 'Correct', 'quiz-master-next' ); ?></div>
149
- <div class="answers" id="answers">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
- </div>
152
- <a href="#" class="button" id="new-answer-button"><?php _e( 'Add New Answer!', 'quiz-master-next'); ?></a>
153
- <label class="change-answer-editor-label">
154
- <?php _e( 'Answers Type: ', 'quiz-master-next' ); ?>
155
- <select id="change-answer-editor">
156
- <option value="text">Text Answers</option>
157
- <option value="rich">Rich Answers</option>
158
- </select>
159
- </label>
160
- </div>
161
- <p id="show-advanced-option">Show advance options &raquo;</p>
162
- <div class="advanced-content" style="display: none;">
163
- <div id="correct_answer_area" class="qsm-row">
164
- <label><?php _e( 'Correct Answer Info', 'quiz-master-next' ); ?></label>
165
- <input type="text" name="correct_answer_info" value="" id="correct_answer_info" />
166
- </div>
167
- <div id="hint_area" class="qsm-row">
168
- <label><?php _e( 'Hint', 'quiz-master-next' ); ?></label>
169
- <input type="text" name="hint" value="" id="hint"/>
170
- </div>
171
- <div id="comment_area" class="qsm-row">
172
- <label><?php _e( 'Comment Field', 'quiz-master-next' ); ?></label>
173
- <select name="comments" id="comments">
174
- <option value="0"><?php _e('Small Text Field', 'quiz-master-next'); ?></option>
175
- <option value="2"><?php _e('Large Text Field', 'quiz-master-next'); ?></option>
176
- <option value="1" selected="selected"><?php _e('None', 'quiz-master-next'); ?></option>
177
- <select>
178
- </div>
179
- <div id="required_area" class="qsm-row">
180
- <label><?php _e( 'Required?', 'quiz-master-next' ); ?></label>
181
- <select name="required" id="required">
182
- <option value="0" selected="selected"><?php _e( 'Yes', 'quiz-master-next' ); ?></option>
183
- <option value="1"><?php _e( 'No', 'quiz-master-next' ); ?></option>
184
- </select>
185
- </div>
186
- <div id="category_area" class="qsm-row">
187
- <label><?php _e( 'Category', 'quiz-master-next' ); ?></label>
188
- <div id="categories">
189
- <input type="radio" name="category" class="category-radio" id="new_category_new" value="new_category"><label for="new_category_new">New: <input type='text' id='new_category' value='' /></label>
190
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  </div>
192
- <div id="required_area" class="qsm-row">
193
- <label><?php _e( 'Hide Autofill?', 'quiz-master-next' ); ?></label>
194
- <select name="hide_autofill" id="hide_autofill">
195
- <option value="0" selected="selected"><?php _e( 'No', 'quiz-master-next' ); ?></option>
196
- <option value="1"><?php _e( 'Yes', 'quiz-master-next' ); ?></option>
197
- </select>
198
- </div>
199
- <div id="required_area" class="qsm-row">
200
- <label><?php _e( 'Limit Text( Works for text fields )', 'quiz-master-next' ); ?></label>
201
- <input type="number" name="limit_text" value="" id="limit_text"/>
202
- </div>
203
- <div id="required_area" class="qsm-row">
204
- <label><?php _e( 'Limit Multiple choice( Works for Multiple Response )', 'quiz-master-next' ); ?></label>
205
- <input type="number" name="limit_multiple_response" value="" id="limit_multiple_response"/>
206
- </div>
207
- <div id="file-upload-limit" class="qsm-row">
208
- <label><?php _e( 'File upload limit ( in MB )', 'quiz-master-next' ); ?></label>
209
- <input type="number" name="file_upload_limit" value="" id="file_upload_limit"/>
210
- </div>
211
- <div id="file-upload-type-div" class="qsm-row">
212
- <label><?php _e( 'Allow File type', 'quiz-master-next' ); ?></label>
213
- <input type="checkbox" name="file_upload_type[]" value="text/plain" /> <?php _e( 'Text File', 'quiz-master-next' ); ?><br/>
214
- <input type="checkbox" name="file_upload_type[]" value="image" /> <?php _e( 'Image', 'quiz-master-next' ); ?><br/>
215
- <input type="checkbox" name="file_upload_type[]" value="application/pdf" /> <?php _e( 'PDF', 'quiz-master-next' ); ?><br/>
216
- <input type="checkbox" name="file_upload_type[]" value="doc" /> <?php _e( 'Doc', 'quiz-master-next' ); ?><br/>
217
- <input type="checkbox" name="file_upload_type[]" value="excel" /> <?php _e( 'Excel', 'quiz-master-next' ); ?><br/>
218
- <input type="checkbox" name="file_upload_type[]" value="video/mp4" /> <?php _e( 'Video', 'quiz-master-next' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  </div>
220
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  </main>
222
  <footer class="qsm-popup__footer">
223
- <button id="save-popup-button" class="qsm-popup__btn qsm-popup__btn-primary">Save Question</button>
224
- <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window">Cancel</button>
225
  </footer>
226
  </div>
227
  </div>
228
  </div>
229
 
230
- <!--Views-->
231
-
232
  <!-- View for Page -->
233
  <script type="text/template" id="tmpl-page">
234
- <div class="page page-new">
235
  <div class="page-header">
236
- <div><span class="dashicons dashicons-move"></span></div>
 
 
 
237
  <div class="page-header-buttons">
238
- <a href="#" class="new-question-button button">Create New Question</a>
239
- <a href="#" class="add-question-bank-button button">Add Question From Question Bank</a>
240
  </div>
241
- <div><a href="#" class="delete-page-button"><span class="dashicons dashicons-trash"></span></a></div>
242
  </div>
243
- </div>
244
  </script>
245
-
246
  <!-- View for Question -->
247
  <script type="text/template" id="tmpl-question">
248
  <div class="question question-new" data-question-id="{{data.id }}">
249
  <div class="question-content">
250
  <div><span class="dashicons dashicons-move"></span></div>
251
- <div><a href="#" class="edit-question-button"><span class="dashicons dashicons-edit"></span></a></div>
252
- <div><a href="#" class="duplicate-question-button"><span class="dashicons dashicons-controls-repeat"></span></a></div>
 
253
  <div class="question-content-text">{{{data.question}}}</div>
254
- <div><# if ( 0 !== data.category.length ) { #> Category: {{data.category}} <# } #></div>
255
- <div><a href="#" class="delete-question-button"><span class="dashicons dashicons-trash"></span></a><div>
256
  </div>
257
  </div>
258
  </script>
@@ -272,7 +531,7 @@ function qsm_options_questions_tab_content() {
272
  <!-- View for single category -->
273
  <script type="text/template" id="tmpl-single-category">
274
  <div class="category">
275
- <input type="radio" name="category" class="category-radio" value="{{data.category}}"><label>{{data.category}}</label>
276
  </div>
277
  </script>
278
 
@@ -285,10 +544,16 @@ function qsm_options_questions_tab_content() {
285
  <textarea id="answer-{{data.question_id}}-{{data.count}}"></textarea>
286
  <# } else { #>
287
  <input type="text" class="answer-text" value="{{data.answer}}" placeholder="Your answer"/>
288
- <# } #>
289
  </div>
290
- <div><input type="text" class="answer-points" value="{{data.points}}" placeholder="Points"/></div>
291
- <div><input type="checkbox" class="answer-correct" value="1" <# if ( 1 == data.correct ) { #> checked="checked"/> <# } #></div>
 
 
 
 
 
 
292
  </div>
293
  </script>
294
  <?php
@@ -316,7 +581,11 @@ function qsm_ajax_save_pages() {
316
  );
317
  $quiz_id = intval( $_POST['quiz_id'] );
318
  $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
319
- $response = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( 'pages', $_POST['pages'] );
 
 
 
 
320
  if ( $response ) {
321
  $json['status'] = 'success';
322
  }
@@ -392,4 +661,27 @@ function qsm_send_data_sendy(){
392
  echo isset($result['response']) && isset($result['response']['code']) && $result['response']['code'] == 200 ? $result['body'] : '';
393
  exit;
394
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  ?>
31
 
32
  global $wpdb;
33
  global $mlwQuizMasterNext;
34
+ $question_categories = $wpdb->get_results( "SELECT DISTINCT category FROM {$wpdb->prefix}mlw_questions", 'ARRAY_A' );
35
  $quiz_id = intval( $_GET['quiz_id'] );
36
+ $user_id = get_current_user_id();
37
+ $form_type = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'form_type' );
38
+ $quiz_system = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'system' );
39
+ $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('pages', array());
40
+ $db_qpages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('qpages', array());
41
+ $qpages = array();
42
+ if (!empty($pages)) {
43
+ $defaultQPage = array('id' => 1, 'quizID' => $quiz_id, 'pagekey' => '', 'hide_prevbtn' => 0, 'questions' => array());
44
+ foreach ($pages as $k => $val) {
45
+ $qpage = isset($db_qpages[$k]) ? $db_qpages[$k] : $defaultQPage;
46
+ $qpage['id'] = $k + 1;
47
+ $qpage['pagekey'] = (isset($qpage['pagekey']) && !empty($qpage['pagekey'])) ? $qpage['pagekey'] : uniqid();
48
+ $qpage['hide_prevbtn'] = (isset($qpage['hide_prevbtn']) && !empty($qpage['hide_prevbtn'])) ? $qpage['hide_prevbtn'] : 0;
49
+ $qpage['questions'] = $val;
50
+ $qpages[] = $qpage;
51
+ }
52
+ }
53
+ $qpages = apply_filters('qsm_filter_quiz_page_attributes', $qpages, $pages);
54
  $json_data = array(
55
  'quizID' => $quiz_id,
56
  'answerText' => __( 'Answer', 'quiz-master-next' ),
57
  'nonce' => wp_create_nonce( 'wp_rest' ),
58
+ 'pages' => $pages,
59
+ 'qpages' => $qpages,
60
+ 'qsm_user_ve' => get_user_meta($user_id, 'rich_editing', true),
61
+ 'saveNonce' => wp_create_nonce('ajax-nonce-sandy-page'),
62
+ 'categories' => $question_categories,
63
+ 'form_type' => $form_type,
64
+ 'quiz_system' => $quiz_system
65
  );
66
 
67
  // Scripts and styles.
102
  <?php
103
  }
104
  ?>
105
+ <h3 style="display: none;">Questions</h3>
106
+ <p style="text-align: right;"><a href="https://quizandsurveymaster.com/docs/v7/questions-tab/" target="_blank">View Documentation</a></p>
107
  <div class="question-controls">
108
+ <span><b>Total Questions:</b> <span id="total-questions"></span></span>
109
+ <p class="search-box">
110
+ <label class="screen-reader-text" for="question_search">Search Questions:</label>
111
+ <input type="search" id="question_search" name="question_search" value="">
112
+ <a href="#" class="button">Search Questions</a>
113
+ </p>
 
 
 
 
114
  </div>
115
+ <div class="questions quiz_form_type_<?php echo $form_type; ?> quiz_quiz_systen_<?php echo $quiz_system; ?>"><div class="qsm-showing-loader" style="text-align: center;margin-bottom: 20px;"><div class="qsm-spinner-loader"></div></div></div>
116
+ <div class="question-create-page">
117
+ <div>
118
+ <button class="new-page-button button button-primary"><span class="dashicons dashicons-plus-alt2"></span> <?php _e('Create New Page', 'quiz-master-next'); ?></button>
119
+ <button style="display: none;" class="save-page-button button button-primary"><?php _e('Save Questions and Pages', 'quiz-master-next'); ?></button>
120
+ <span class="spinner" id="save-edit-quiz-pages" style="float: none;"></span>
121
+ </div>
122
+ </div>
123
  <!-- Popup for question bank -->
124
  <div class="qsm-popup qsm-popup-slide qsm-popup-bank" id="modal-2" aria-hidden="true">
125
  <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
149
  <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
150
  </header>
151
  <main class="qsm-popup__content" id="modal-1-content">
152
+ <input type="hidden" name="edit_question_id" id="edit_question_id" value="">
153
+ <div id="poststuff">
154
+ <div id="post-body" class="metabox-holder columns-2">
155
+ <div id="post-body-content" style="position: relative;">
156
+ <div class="qsm-row">
157
+ <input type="text" id="question_title" class="question-title" name="question-title" value="" placeholder="<?php _e('Add title','quiz-master-next'); ?>">
158
+ </div>
159
+ <div class="qsm-row">
160
+ <textarea id="question-text"></textarea>
161
+ </div>
162
+ <div class="qsm-row">
163
+ <?php
164
+ $description_arr = array(
165
+ array(
166
+ 'question_type_id' => 11,
167
+ 'description' => __('For this question type, users will see a file upload field on front end.', 'quiz-master-next')
168
+ ),
169
+ array(
170
+ 'question_type_id' => '14',
171
+ 'description' => __('Use %BLANK% variable in the description field to display input boxes.', 'quiz-master-next')
172
+ ),
173
+ array(
174
+ 'question_type_id' => '12',
175
+ 'description' => __('For this question type, users will see a date input field on front end.', 'quiz-master-next')
176
+ ),
177
+ array(
178
+ 'question_type_id' => '3',
179
+ 'description' => __('For this question type, users will see a standard input box on front end.', 'quiz-master-next')
180
+ ),
181
+ array(
182
+ 'question_type_id' => '5',
183
+ 'description' => __('For this question type, users will see a standard textarea input box on front end.', 'quiz-master-next')
184
+ ),
185
+ array(
186
+ 'question_type_id' => '6',
187
+ 'description' => __('Displays a simple section on front end.', 'quiz-master-next')
188
+ ),
189
+ array(
190
+ 'question_type_id' => '7',
191
+ 'description' => __('For this question type, users will see an input box which accepts only number values on front end.', 'quiz-master-next')
192
+ ),
193
+ array(
194
+ 'question_type_id' => '8',
195
+ 'description' => __("For this question type, users will see a checkbox on front end. The text in description field will act like it's label.", 'quiz-master-next')
196
+ ),
197
+ array(
198
+ 'question_type_id' => '9',
199
+ 'description' => __('For this question type, users will see a Captcha field on front end.', 'quiz-master-next')
200
+ ),
201
+ array(
202
+ 'question_type_id' => '13',
203
+ 'description' => __('Use points based grading system for Polar questions.', 'quiz-master-next')
204
+ )
205
+ );
206
+ $description_arr = apply_filters('qsm_question_type_description', $description_arr);
207
+ if( $description_arr ){
208
+ foreach ( $description_arr as $value ) {
209
+ $question_type_id = $value['question_type_id'];
210
+ ?>
211
+ <p id="question_type_<?php echo $question_type_id; ?>_description" class="question-type-description"><?php echo $value['description']; ?></p>
212
+ <?php
213
+ }
214
+ }
215
+ ?>
216
+ </div>
217
+ <?php
218
+ $polar_class = $polar_question_use = '';
219
+ if( $form_type == 0 && ($quiz_system == 1 || $quiz_system == 3) ){
220
+ $polar_class = 'qsm_show_question_type_13';
221
+ $polar_question_use = ',13';
222
+ }
223
+ ?>
224
+ <div id="qsm_optoins_wrapper" class="qsm-row qsm_hide_for_other qsm_show_question_type_0 qsm_show_question_type_1 qsm_show_question_type_2 qsm_show_question_type_4 qsm_show_question_type_10 qsm_show_question_type_14 <?php echo $polar_class; ?>">
225
+ <label class="answer-header">
226
+ <?php _e( 'Answers', 'quiz-master-next' ); ?>
227
+ <a class="qsm-question-doc" href="https://quizandsurveymaster.com/docs/v7/questions-tab/#Answers" target="_blank" title="View Documentation">
228
+ <span class="dashicons dashicons-media-document"></span>
229
+ </a>
230
+ </label>
231
+ <div class="correct-header"><?php _e( 'Correct', 'quiz-master-next' ); ?></div>
232
+ <div class="answers" id="answers">
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  </div>
235
+ <div class="new-answer-button">
236
+ <a href="#" class="button" id="new-answer-button"><span class="dashicons dashicons-plus"></span> <?php _e( 'Add New Answer!', 'quiz-master-next'); ?></a>
237
+ </div>
238
+ </div>
239
+ <?php
240
+ $answer_area_option = array(
241
+ 'correct_answer_info' => array(
242
+ 'label' => __( 'Correct Answer Info', 'quiz-master-next' ),
243
+ 'type' => 'textarea',
244
+ 'default' => '',
245
+ 'show' => '0,1,2,4,10,14' . $polar_question_use,
246
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Correct-Answer-Info'
247
+ )
248
+ );
249
+ $answer_area_option = apply_filters('qsm_question_advanced_option', $answer_area_option);
250
+ foreach($answer_area_option as $qo_key => $single_answer_option){
251
+ echo qsm_display_question_option($qo_key, $single_answer_option);
252
+ }
253
+ ?>
254
  </div>
255
+ <div id="postbox-container-1" class="postbox-container">
256
+ <div id="side-sortables" class="meta-box-sortables ui-sortable" style="">
257
+ <div id="submitdiv" class="postbox ">
258
+ <h2 class="hndle ui-sortable-handle">
259
+ <span><?php _e( 'Publish', 'quiz-master-quiz' ); ?></span>
260
+ <span id="qsm-question-id"></span>
261
+ </h2>
262
+ <div class="inside">
263
+ <div class="submitbox" id="submitpost">
264
+ <div id="minor-publishing">
265
+ <div class="qsm-row">
266
+ <label>
267
+ <?php _e( 'Question Type', 'quiz-master-next' ); ?>
268
+ <?php
269
+ $document_text = '';
270
+ $document_text .= '<a class="qsm-question-doc" href="https://quizandsurveymaster.com/docs/v7/questions-tab/#Question-Type" target="_blank" title="'. __('View Documentation', 'quiz-master-next') .'">';
271
+ $document_text .= '<span class="dashicons dashicons-media-document"></span>';
272
+ $document_text .= '</a>';
273
+ echo $document_text;
274
+ ?>
275
+ </label>
276
+ <select name="question_type" id="question_type">
277
+ <?php
278
+ foreach ( $question_types as $type ) {
279
+ echo "<option value='{$type['slug']}'>{$type['name']}</option>";
280
+ }
281
+ ?>
282
+ </select>
283
+ <a class="question_info_tag hidden" target="_blank" href="https://quizandsurveymaster.com/docs/about-quiz-survey-master/question-types/"><?php _e('How to use this option?','quiz_master_next') ?></a>
284
+ <p class="hidden" id="question_type_info"></p>
285
+ </div>
286
+ <?php
287
+ $simple_question_option = array(
288
+ 'change-answer-editor' => array(
289
+ 'label' => __( 'Answers Type', 'quiz-master-next' ),
290
+ 'type' => 'select',
291
+ 'priority' => '1',
292
+ 'options' => array(
293
+ 'text' => __( 'Text Answers', 'quiz-master-next' ),
294
+ 'rich' => __( 'Rich Answers', 'quiz-master-next' ),
295
+ ),
296
+ 'default' => 'text',
297
+ 'show' => '0,1,2,4,13',
298
+ //'tooltip' => __('You can use text and rich answer for question answers.', 'quiz-master-next'),.
299
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Answer-Type'
300
+ ),
301
+ 'required' => array(
302
+ 'label' => __( 'Required?', 'quiz-master-next' ),
303
+ 'type' => 'single_checkbox',
304
+ 'priority' => '2',
305
+ 'options' => array(
306
+ //'1' => __( 'No', 'quiz-master-next' ),
307
+ '0' => __( 'Yes', 'quiz-master-next' )
308
+ ),
309
+ 'default' => '0'
310
+ ),
311
+ );
312
+ $simple_question_option = apply_filters('qsm_question_format_option', $simple_question_option);
313
+ $keys = array_column($simple_question_option, 'priority');
314
+ array_multisort($keys, SORT_ASC, $simple_question_option);
315
+ foreach($simple_question_option as $qo_key => $single_option){
316
+ echo qsm_display_question_option($qo_key, $single_option);
317
+ }
318
+ ?>
319
+ </div>
320
+ <div id="major-publishing-actions">
321
+ <div id="delete-action">
322
+ <a class="submitdelete deletion" data-micromodal-close aria-label="Close this">Cancel</a>
323
+ </div>
324
+ <div id="publishing-action">
325
+ <span class="spinner" id="save-edit-question-spinner" style="float: none;"></span>
326
+ <button id="save-popup-button" class="button button-primary">Save Question</button>
327
+ </div>
328
+ </div>
329
+ </div>
330
+ </div>
331
+ </div>
332
+ <div id="categorydiv" class="postbox">
333
+ <h2 class="hndle ui-sortable-handle">
334
+ <span><?php _e('Select Category', 'quiz-master-next'); ?></span>
335
+ <a class="qsm-question-doc" href="https://quizandsurveymaster.com/docs/v7/questions-tab/#Category" target="_blank" title="View Documentation"><span class="dashicons dashicons-media-document"></span></a>
336
+ </h2>
337
+ <div class="inside">
338
+ <?php
339
+ $category_question_option = array(
340
+ 'categories' => array(
341
+ 'label' => __( '', 'quiz-master-next' ),
342
+ 'type' => 'category',
343
+ 'priority' => '5',
344
+ 'default' => '',
345
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Category'
346
+ )
347
+ );
348
+ $category_question_option = apply_filters('qsm_question_category_option', $category_question_option);
349
+ $keys = array_column($category_question_option, 'priority');
350
+ array_multisort($keys, SORT_ASC, $category_question_option);
351
+ foreach($category_question_option as $qo_key => $single_cat_option){
352
+ echo qsm_display_question_option($qo_key, $single_cat_option);
353
+ }
354
+ ?>
355
+ </div>
356
+ </div>
357
+ <div id="advanceddiv" class="postbox">
358
+ <h2 class="hndle ui-sortable-handle"><span><?php _e('Advanced Option', 'quiz-master-next'); ?></span></h2>
359
+ <div class="inside">
360
+ <div class="advanced-content">
361
+ <?php
362
+ $advanced_question_option = array(
363
+ 'comments' => array(
364
+ 'label' => __( 'Comment Field', 'quiz-master-next' ),
365
+ 'type' => 'select',
366
+ 'priority' => '3',
367
+ 'options' => array(
368
+ '0' => __( 'Small Text Field', 'quiz-master-next' ),
369
+ '2' => __( 'Large Text Field', 'quiz-master-next' ),
370
+ '1' => __( 'None', 'quiz-master-next' )
371
+ ),
372
+ 'default' => '1',
373
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Comment-Field'
374
+ ),
375
+ 'hint' => array(
376
+ 'label' => __( 'Hint', 'quiz-master-next' ),
377
+ 'type' => 'text',
378
+ 'default' => '',
379
+ 'priority' => '4',
380
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Hints'
381
+ ),
382
+ 'autofill' => array(
383
+ 'label' => __( 'Hide Autofill?', 'quiz-master-next' ),
384
+ 'type' => 'select',
385
+ 'priority' => '6',
386
+ 'options' => array(
387
+ '0' => __( 'No', 'quiz-master-next' ),
388
+ '1' => __( 'Yes', 'quiz-master-next' )
389
+ ),
390
+ 'default' => '0',
391
+ 'show' => '3, 14',
392
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Hide-Autofill'
393
+ ),
394
+ 'limit_text' => array(
395
+ 'label' => __('Limit Text', 'quiz-master-next' ),
396
+ 'type' => 'text',
397
+ 'priority' => '7',
398
+ 'default' => '',
399
+ 'show' => '3, 14',
400
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Limit-Text'
401
+ ),
402
+ 'limit_multiple_response' => array(
403
+ 'label' => __('Limit Multiple choice', 'quiz-master-next' ),
404
+ 'type' => 'text',
405
+ 'priority' => '8',
406
+ 'default' => '',
407
+ 'show' => '4,10',
408
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Limit-Multiple-Choice'
409
+ ),
410
+ 'file_upload_type' => array(
411
+ 'label' => __('Allow File type', 'quiz-master-next' ),
412
+ 'type' => 'multi_checkbox',
413
+ 'priority' => '10',
414
+ 'options' => array(
415
+ 'text/plain' => __( 'Text File', 'quiz-master-next' ),
416
+ 'image' => __( 'Image', 'quiz-master-next' ),
417
+ 'application/pdf' => __( 'PDF File', 'quiz-master-next' ),
418
+ 'doc' => __( 'Doc File', 'quiz-master-next' ),
419
+ 'excel' => __( 'Excel File', 'quiz-master-next' ),
420
+ 'video/mp4' => __( 'Video', 'quiz-master-next' ),
421
+ ),
422
+ 'default' => 'image',
423
+ 'show' => '11',
424
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#Allow-File-Type'
425
+ ),
426
+ 'file_upload_limit' => array(
427
+ 'label' => __('File upload limit ( in MB )', 'quiz-master-next' ),
428
+ 'type' => 'number',
429
+ 'priority' => '9',
430
+ 'default' => '',
431
+ 'show' => '11',
432
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/advanced-options/#File-Upload-Limit'
433
+ ),
434
+ );
435
+ $advanced_question_option = apply_filters('qsm_question_advanced_option', $advanced_question_option);
436
+ $keys = array_column($advanced_question_option, 'priority');
437
+ array_multisort($keys, SORT_ASC, $advanced_question_option);
438
+ foreach($advanced_question_option as $qo_key => $single_option){
439
+ echo qsm_display_question_option($qo_key, $single_option);
440
+ }
441
+ ?>
442
+ </div>
443
+ </div>
444
+ </div>
445
+ </div>
446
  </div>
447
+ </div>
448
+ </div>
449
+ </main>
450
+ </div>
451
+ </div>
452
+ </div>
453
+
454
+ <!--Views-->
455
+
456
+ <!-- Popup for question bank -->
457
+ <div class="qsm-popup qsm-popup-slide qsm-popup-bank" id="modal-page-1" aria-hidden="true">
458
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
459
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
460
+ <header class="qsm-popup__header">
461
+ <h2 class="qsm-popup__title" id="modal-1-title">Edit Page <span style="display: none;">[ ID: <span id="edit-page-id"></span> ]</span></h2>
462
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
463
+ </header>
464
+ <main class="qsm-popup__content" id="modal-page-1-content">
465
+ <input type="hidden" name="edit_page_id" id="edit_page_id" value="">
466
+ <div id="page-options">
467
+ <div class="qsm-row">
468
+ <label><?php _e('Page Name', 'quiz-master-next'); ?></label>
469
+ <input type="text" id="pagekey" name="pagekey" value="">
470
+ </div>
471
+ <div class="qsm-row">
472
+ <label><?php _e('Hide Previous Button?', 'quiz-master-next'); ?></label>
473
+ <select name="hide_prevbtn" id="hide_prevbtn">
474
+ <option value="0" selected="selected"><?php _e( 'No', 'quiz-master-next' ); ?></option>
475
+ <option value="1"><?php _e( 'Yes', 'quiz-master-next' ); ?></option>
476
+ </select>
477
+ </div>
478
+ <?php do_action('qsm_action_quiz_page_attributes_fields');?>
479
+ </div>
480
  </main>
481
  <footer class="qsm-popup__footer">
482
+ <button id="save-page-popup-button" class="qsm-popup__btn qsm-popup__btn-primary">Save Page</button>
483
+ <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window">Close</button>
484
  </footer>
485
  </div>
486
  </div>
487
  </div>
488
 
 
 
489
  <!-- View for Page -->
490
  <script type="text/template" id="tmpl-page">
491
+ <div class="page page-new" data-page-id="{{data.id }}">
492
  <div class="page-header">
493
+ <div><span class="dashicons dashicons-move"></span> <a href="#" class="edit-page-button" title="Edit Page"><span class="dashicons dashicons-admin-generic"></span></a> <span class="page-number"></span></div>
494
+ <div><a href="#" class="delete-page-button" title="Delete Page"><span class="dashicons dashicons-trash"></span></a></div>
495
+ </div>
496
+ <div class="page-footer">
497
  <div class="page-header-buttons">
498
+ <a href="#" class="new-question-button button"><span class="dashicons dashicons-plus"></span> Create New Question</a>
499
+ <a href="#" class="add-question-bank-button button"><span class="dashicons dashicons-plus"></span> Add Question From Question Bank</a>
500
  </div>
 
501
  </div>
502
+ </div>
503
  </script>
504
+
505
  <!-- View for Question -->
506
  <script type="text/template" id="tmpl-question">
507
  <div class="question question-new" data-question-id="{{data.id }}">
508
  <div class="question-content">
509
  <div><span class="dashicons dashicons-move"></span></div>
510
+ <div><a href="#" title="Edit Question" class="edit-question-button"><span class="dashicons dashicons-edit"></span></a></div>
511
+ <div><a href="#" title="Clone Question" class="duplicate-question-button"><span class="dashicons dashicons-admin-page"></span></a></div>
512
+ <div><a href="#" title="Delete Question" class="delete-question-button"><span class="dashicons dashicons-trash"></span></a></div>
513
  <div class="question-content-text">{{{data.question}}}</div>
514
+ <div class="question-category"><# if ( 0 !== data.category.length ) { #> Category: {{data.category}} <# } #></div>
 
515
  </div>
516
  </div>
517
  </script>
531
  <!-- View for single category -->
532
  <script type="text/template" id="tmpl-single-category">
533
  <div class="category">
534
+ <label><input type="radio" name="category" class="category-radio" value="{{data.category}}">{{data.category}}</label>
535
  </div>
536
  </script>
537
 
544
  <textarea id="answer-{{data.question_id}}-{{data.count}}"></textarea>
545
  <# } else { #>
546
  <input type="text" class="answer-text" value="{{data.answer}}" placeholder="Your answer"/>
547
+ <# } #>
548
  </div>
549
+ <# if ( 0 == data.form_type ) { #>
550
+ <# if ( 1 == data.quiz_system || 3 == data.quiz_system ) { #>
551
+ <div><input type="text" class="answer-points" value="{{data.points}}" placeholder="Points"/></div>
552
+ <# } #>
553
+ <# if ( 0 == data.quiz_system || 3 == data.quiz_system ) { #>
554
+ <div><label class="correct-answer"><input type="checkbox" class="answer-correct" value="1" <# if ( 1 == data.correct ) { #> checked="checked" <# } #>/> Correct</label></div>
555
+ <# } #>
556
+ <# } #>
557
  </div>
558
  </script>
559
  <?php
581
  );
582
  $quiz_id = intval( $_POST['quiz_id'] );
583
  $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id );
584
+
585
+ $pages = isset( $_POST['pages'] ) ? $_POST['pages'] : array();
586
+ $qpages = isset($_POST['qpages']) ? $_POST['qpages'] : array();
587
+ $response_qpages = $mlwQuizMasterNext->pluginHelper->update_quiz_setting('qpages', $qpages);
588
+ $response = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( 'pages', $pages );
589
  if ( $response ) {
590
  $json['status'] = 'success';
591
  }
661
  echo isset($result['response']) && isset($result['response']['code']) && $result['response']['code'] == 200 ? $result['body'] : '';
662
  exit;
663
  }
664
+
665
+ add_action( 'wp_ajax_qsm_dashboard_delete_result', 'qsm_dashboard_delete_result' );
666
+ function qsm_dashboard_delete_result(){
667
+ $result_id = isset($_POST['result_id']) ? sanitize_text_field($_POST['result_id']) : 0;
668
+ if($result_id){
669
+ global $wpdb;
670
+ $wpdb->update(
671
+ $wpdb->prefix."mlw_results",
672
+ array(
673
+ 'deleted' => 1,
674
+ ),
675
+ array( 'result_id' => $result_id ),
676
+ array(
677
+ '%d'
678
+ ),
679
+ array( '%d' )
680
+ );
681
+ echo 'success';
682
+ exit;
683
+ }
684
+ echo 'failed';
685
+ exit;
686
+ }
687
  ?>
php/admin/options-page-results-page-tab.php CHANGED
@@ -38,106 +38,21 @@ function qsm_options_results_tab_content() {
38
  wp_enqueue_editor();
39
  wp_enqueue_media();
40
  ?>
41
- <h2><?php esc_html_e( 'Results Pages', 'quiz-master-next' ); ?></h2>
42
- <p>Need assistance with this tab? <a href="https://quizandsurveymaster.com/docs/creating-quizzes-and-surveys/setting-up-results-pages/" target="_blank">Check out the documentation</a> for this tab!</p>
43
-
44
- <!-- Template Variables Section -->
45
- <section>
46
- <h3 style="text-align: center;"><?php esc_html_e( 'Template Variables', 'quiz-master-next' ); ?></h3>
47
- <div class="template_list_holder">
48
- <div class="template_variable">
49
- <span class="template_name">%CONTACT_X%</span> - <?php _e( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ); ?>
50
- </div>
51
- <div class="template_variable">
52
- <span class="template_name">%CONTACT_ALL%</span> - <?php _e( 'List user values for all contact fields', 'quiz-master-next' ); ?>
53
- </div>
54
- <div class="template_variable">
55
- <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
56
- </div>
57
- <div class="template_variable">
58
- <span class="template_name">%AVERAGE_POINT%</span> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?>
59
- </div>
60
- <div class="template_variable">
61
- <span class="template_name">%AMOUNT_CORRECT%</span> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?>
62
- </div>
63
- <div class="template_variable">
64
- <span class="template_name">%TOTAL_QUESTIONS%</span> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?>
65
- </div>
66
- <div class="template_variable">
67
- <span class="template_name">%CORRECT_SCORE%</span> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?>
68
- </div>
69
- <div class="template_variable">
70
- <span class="template_name">%USER_NAME%</span> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?>
71
- </div>
72
- <div class="template_variable">
73
- <span class="template_name">%USER_BUSINESS%</span> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?>
74
- </div>
75
- <div class="template_variable">
76
- <span class="template_name">%USER_PHONE%</span> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?>
77
- </div>
78
- <div class="template_variable">
79
- <span class="template_name">%USER_EMAIL%</span> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?>
80
- </div>
81
- <div class="template_variable">
82
- <span class="template_name">%QUIZ_NAME%</span> - <?php _e('The name of the quiz', 'quiz-master-next'); ?>
83
- </div>
84
- <div class="template_variable">
85
- <span class="template_name">%QUESTIONS_ANSWERS%</span> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?>
86
- </div>
87
- <div class="template_variable">
88
- <span class="template_name">%COMMENT_SECTION%</span> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?>
89
- </div>
90
- <div class="template_variable">
91
- <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent taking quiz in minutes', 'quiz-master-next'); ?>
92
- </div>
93
- <div class="template_variable">
94
- <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent taking quiz in seconds', 'quiz-master-next'); ?>
95
- </div>
96
- <div class="template_variable">
97
- <span class="template_name">%CATEGORY_POINTS_X%</span> - <?php _e('X: Category name - The amount of points a specific category earned.', 'quiz-master-next'); ?>
98
- </div>
99
- <div class="template_variable">
100
- <span class="template_name">%AVERAGE_CATEGORY_POINTS_X%</span> - <?php _e('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next'); ?>
101
- </div>
102
- <div class="template_variable">
103
- <span class="template_name">%CATEGORY_SCORE_X%</span> - <?php _e('X: Category name - The score a specific category earned.', 'quiz-master-next'); ?>
104
- </div>
105
- <div class="template_variable">
106
- <span class="template_name">%CATEGORY_AVERAGE_POINTS%</span> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?>
107
- </div>
108
- <div class="template_variable">
109
- <span class="template_name">%CATEGORY_AVERAGE_SCORE%</span> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?>
110
- </div>
111
- <div class="template_variable">
112
- <span class="template_name">%FACEBOOK_SHARE%</span> - <?php _e('Displays button to share on Facebook.', 'quiz-master-next'); ?>
113
- </div>
114
- <div class="template_variable">
115
- <span class="template_name">%TWITTER_SHARE%</span> - <?php _e('Displays button to share on Twitter.', 'quiz-master-next'); ?>
116
- </div>
117
- <div class="template_variable">
118
- <span class="template_name">%POLL_RESULTS_X%</span> - <?php _e('X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next'); ?>
119
- </div>
120
- <div class="template_variable">
121
- <span class="template_name">%RESULT_ID%</span> - <?php _e('Show result id', 'quiz-master-next'); ?>
122
- </div>
123
- <div class="template_variable">
124
- <span class="template_name">%QUESTION_ANSWER_X%</span> - <?php _e('X = Question ID. It will show result of particular question.', 'quiz-master-next'); ?>
125
- </div>
126
- <?php do_action('qmn_template_variable_list'); ?>
127
- </div>
128
- <div style="clear:both;"></div>
129
- </section>
130
-
131
  <!-- Results Page Section -->
132
- <section>
133
- <h3>Your Pages</h3>
134
- <button class="save-pages button-primary"><?php esc_html_e( 'Save Results Pages', 'quiz-master-next' ); ?></button>
135
- <span class="spinner" style="float: none;"></span>
136
  <button class="add-new-page button"><?php esc_html_e( 'Add New Results Page', 'quiz-master-next' ); ?></button>
137
- <div id="results-pages"></div>
138
- <button class="save-pages button-primary"><?php esc_html_e( 'Save Results Pages', 'quiz-master-next' ); ?></button>
139
- <span class="spinner" style="float: none;"></span>
 
140
  <button class="add-new-page button"><?php esc_html_e( 'Add New Results Page', 'quiz-master-next' ); ?></button>
 
 
 
 
 
141
  </section>
142
 
143
  <!-- Templates -->
@@ -190,6 +105,55 @@ function qsm_options_results_tab_content() {
190
  <input type="text" class="results-page-condition-value" value="{{ data.value }}">
191
  </div>
192
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  <?php
194
  }
195
  ?>
38
  wp_enqueue_editor();
39
  wp_enqueue_media();
40
  ?>
41
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  <!-- Results Page Section -->
43
+ <section class="qsm-quiz-result-tab" style="margin-top: 15px;">
44
+ <button class="save-pages button-primary"><?php esc_html_e( 'Save Results Pages', 'quiz-master-next' ); ?></button>
 
 
45
  <button class="add-new-page button"><?php esc_html_e( 'Add New Results Page', 'quiz-master-next' ); ?></button>
46
+ <a style="float: right;" class="qsm-show-all-variable-text" href="#"><?php _e('Insert Template Variables', 'quiz-master-next'); ?> <span class="dashicons dashicons-upload"></span></a>
47
+ <a style="margin: 0 10px; float: right;" href="https://quizandsurveymaster.com/docs/v7/results-pages-tab/" target="_blank">View Documentation</a>
48
+ <div id="results-pages"><div style="margin-bottom: 30px;margin-top: 35px;" class="qsm-spinner-loader"></div></div>
49
+ <button class="save-pages button-primary"><?php esc_html_e( 'Save Results Pages', 'quiz-master-next' ); ?></button>
50
  <button class="add-new-page button"><?php esc_html_e( 'Add New Results Page', 'quiz-master-next' ); ?></button>
51
+ <div class="qsm-alerts" style="margin-top: 20px;">
52
+ <?php
53
+ $mlwQuizMasterNext->alertManager->showAlerts();
54
+ ?>
55
+ </div>
56
  </section>
57
 
58
  <!-- Templates -->
105
  <input type="text" class="results-page-condition-value" value="{{ data.value }}">
106
  </div>
107
  </script>
108
+ <!--Template popup-->
109
+ <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
110
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
111
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
112
+ <header class="qsm-popup__header" style="display: block;">
113
+ <h2 class="qsm-popup__title"><?php _e('Template Variables', 'quiz-master-next'); ?></h2>
114
+ <span class="description"><?php _e('Use these dynamic variables to customize your quiz or survey. Just copy and paste one or more variables into the content templates and these will be replaced by actual values when user takes a quiz.', 'quiz-master-next'); ?></span>
115
+ </header>
116
+ <main class="qsm-popup__content" id="show-all-variable-content">
117
+ <?php
118
+ $variable_list = qsm_text_template_variable_list();
119
+ $email_exta_variable = array(
120
+ '%CONTACT_X%' => __( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ),
121
+ '%CONTACT_ALL%' => __( 'Value user entered into contact field. X is # of contact field. For example, first contact field would be %CONTACT_1%', 'quiz-master-next' ),
122
+ );
123
+ $variable_list = array_merge($email_exta_variable, $variable_list);
124
+ $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next');
125
+ $variable_list['%FACEBOOK_SHARE%'] = __('Displays button to share on Facebook.', 'quiz-master-next');
126
+ $variable_list['%TWITTER_SHARE%'] = __('Displays button to share on Twitter.', 'quiz-master-next');
127
+ $variable_list['%POLL_RESULTS_X%'] = __('X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next');
128
+ $variable_list['%RESULT_ID%'] = __('Show result id', 'quiz-master-next');
129
+ $variable_list['%QUESTION_ANSWER_X%'] = __('X = Question ID. It will show result of particular question.', 'quiz-master-next');
130
+ unset($variable_list['%QUESTION%']);
131
+ unset($variable_list['%USER_ANSWER%']);
132
+ unset($variable_list['%CORRECT_ANSWER%']);
133
+ unset($variable_list['%USER_COMMENTS%']);
134
+ unset($variable_list['%CORRECT_ANSWER_INFO%']);
135
+ unset($variable_list['%CURRENT_DATE%']);
136
+ if( $variable_list ){
137
+ foreach ( $variable_list as $key => $s_variable ) { ?>
138
+ <div class="popup-template-span-wrap">
139
+ <span class="qsm-text-template-span">
140
+ <button class="button button-default"><?php echo $key; ?></button>
141
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
142
+ <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
143
+ </span>
144
+ </span>
145
+ </div>
146
+ <?php
147
+ }
148
+ }
149
+ ?>
150
+ </main>
151
+ <footer class="qsm-popup__footer" style="text-align: right;">
152
+ <button class="button button-default" data-micromodal-close="" aria-label="Close this dialog window"><?php _e('Close [Esc]', 'quiz-master-next'); ?></button>
153
+ </footer>
154
+ </div>
155
+ </div>
156
+ </div>
157
  <?php
158
  }
159
  ?>
php/admin/options-page-style-tab.php CHANGED
@@ -68,7 +68,7 @@ function qsm_options_styling_tab_content() {
68
  <input type='hidden' name='save_style_options' value='confirmation' />
69
  <input type='hidden' name='style_quiz_id' value='<?php echo esc_attr( $quiz_id ); ?>' />
70
  <input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='<?php echo esc_attr( $mlw_quiz_options->theme_selected ); ?>' />
71
- <h3><?php _e( 'Quiz Styles', 'quiz-master-next' ); ?></h3>
72
  <p><?php _e( 'Choose your style:', 'quiz-master-next' ); ?></p>
73
  <style>
74
  div.mlw_qmn_themeBlockActive {
68
  <input type='hidden' name='save_style_options' value='confirmation' />
69
  <input type='hidden' name='style_quiz_id' value='<?php echo esc_attr( $quiz_id ); ?>' />
70
  <input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='<?php echo esc_attr( $mlw_quiz_options->theme_selected ); ?>' />
71
+ <h3 style="display: none;"><?php _e( 'Quiz Styles', 'quiz-master-next' ); ?></h3>
72
  <p><?php _e( 'Choose your style:', 'quiz-master-next' ); ?></p>
73
  <style>
74
  div.mlw_qmn_themeBlockActive {
php/admin/options-page-text-tab.php CHANGED
@@ -18,89 +18,198 @@ add_action( "plugins_loaded", 'qmn_settings_text_tab', 5 );
18
  *
19
  * @return void
20
  * @since 4.4.0
 
21
  */
22
  function mlw_options_text_tab_content() {
23
  global $wpdb;
24
  global $mlwQuizMasterNext;
25
- wp_enqueue_style( 'qmn_admin_style', plugins_url( '../../css/qsm-admin.css' , __FILE__ ) );
 
26
  ?>
27
- <h3 style="text-align: center;"><?php _e("Template Variables", 'quiz-master-next'); ?></h3>
28
- <div class="template_list_holder">
29
- <div class="template_variable">
30
- <span class="template_name">%POINT_SCORE%</span> - <?php _e('Score for the quiz when using points', 'quiz-master-next'); ?>
31
- </div>
32
- <div class="template_variable">
33
- <span class="template_name">%AVERAGE_POINT%</span> - <?php _e('The average amount of points user had per question', 'quiz-master-next'); ?>
34
- </div>
35
- <div class="template_variable">
36
- <span class="template_name">%AMOUNT_CORRECT%</span> - <?php _e('The number of correct answers the user had', 'quiz-master-next'); ?>
37
- </div>
38
- <div class="template_variable">
39
- <span class="template_name">%TOTAL_QUESTIONS%</span> - <?php _e('The total number of questions in the quiz', 'quiz-master-next'); ?>
40
- </div>
41
- <div class="template_variable">
42
- <span class="template_name">%CORRECT_SCORE%</span> - <?php _e('Score for the quiz when using correct answers', 'quiz-master-next'); ?>
43
- </div>
44
- <div class="template_variable">
45
- <span class="template_name">%USER_NAME%</span> - <?php _e('The name the user entered before the quiz', 'quiz-master-next'); ?>
46
- </div>
47
- <div class="template_variable">
48
- <span class="template_name">%USER_BUSINESS%</span> - <?php _e('The business the user entered before the quiz', 'quiz-master-next'); ?>
49
- </div>
50
- <div class="template_variable">
51
- <span class="template_name">%USER_PHONE%</span> - <?php _e('The phone number the user entered before the quiz', 'quiz-master-next'); ?>
52
- </div>
53
- <div class="template_variable">
54
- <span class="template_name">%USER_EMAIL%</span> - <?php _e('The email the user entered before the quiz', 'quiz-master-next'); ?>
55
- </div>
56
- <div class="template_variable">
57
- <span class="template_name">%QUIZ_NAME%</span> - <?php _e('The name of the quiz', 'quiz-master-next'); ?>
58
- </div>
59
- <div class="template_variable">
60
- <span class="template_name">%QUESTIONS_ANSWERS%</span> - <?php _e('Shows the question, the answer the user provided, and the correct answer', 'quiz-master-next'); ?>
61
- </div>
62
- <div class="template_variable">
63
- <span class="template_name">%COMMENT_SECTION%</span> - <?php _e('The comments the user entered into comment box if enabled', 'quiz-master-next'); ?>
64
- </div>
65
- <div class="template_variable">
66
- <span class="template_name">%TIMER%</span> - <?php _e('The amount of time user spent on quiz in seconds', 'quiz-master-next'); ?>
67
- </div>
68
- <div class="template_variable">
69
- <span class="template_name">%TIMER_MINUTES%</span> - <?php _e('The amount of time user spent on quiz in minutes', 'quiz-master-next'); ?>
70
- </div>
71
- <div class="template_variable">
72
- <span class="template_name">%CATEGORY_POINTS_X%</span> - <?php _e('X: Category name - The amount of points a specific category earned.', 'quiz-master-next'); ?>
73
- </div>
74
- <div class="template_variable">
75
- <span class="template_name">%CATEGORY_SCORE_X%</span> - <?php _e('X: Category name - The score a specific category earned.', 'quiz-master-next'); ?>
76
- </div>
77
- <div class="template_variable">
78
- <span class="template_name">%CATEGORY_AVERAGE_POINTS%</span> - <?php _e('The average points from all categories.', 'quiz-master-next'); ?>
79
- </div>
80
- <div class="template_variable">
81
- <span class="template_name">%CATEGORY_AVERAGE_SCORE%</span> - <?php _e('The average score from all categories.', 'quiz-master-next'); ?>
82
- </div>
83
- <div class="template_variable">
84
- <span class="template_name">%QUESTION%</span> - <?php _e('The question that the user answered', 'quiz-master-next'); ?>
85
- </div>
86
- <div class="template_variable">
87
- <span class="template_name">%USER_ANSWER%</span> - <?php _e('The answer the user gave for the question', 'quiz-master-next'); ?>
88
- </div>
89
- <div class="template_variable">
90
- <span class="template_name">%CORRECT_ANSWER%</span> - <?php _e('The correct answer for the question', 'quiz-master-next'); ?>
91
- </div>
92
- <div class="template_variable">
93
- <span class="template_name">%USER_COMMENTS%</span> - <?php _e('The comments the user provided in the comment field for the question', 'quiz-master-next'); ?>
94
- </div>
95
- <div class="template_variable">
96
- <span class="template_name">%CORRECT_ANSWER_INFO%</span> - <?php _e('Reason why the correct answer is the correct answer', 'quiz-master-next'); ?>
97
- </div>
98
- <div class="template_variable">
99
- <span class="template_name">%CURRENT_DATE%</span> - <?php _e('The Current Date', 'quiz-master-next'); ?>
100
- </div>
101
- <?php do_action('qmn_template_variable_list'); ?>
102
- </div>
103
- <?php
104
- $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_text' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  ?>
18
  *
19
  * @return void
20
  * @since 4.4.0
21
+ * @since 7.0 changed the design
22
  */
23
  function mlw_options_text_tab_content() {
24
  global $wpdb;
25
  global $mlwQuizMasterNext;
26
+ //wp_enqueue_style( 'qmn_admin_style', plugins_url( '../../css/qsm-admin.css' , __FILE__ ) );
27
+ $variable_list = qsm_text_template_variable_list();
28
  ?>
29
+ <div class="qsm-text-main-wrap">
30
+ <p style="text-align: right;"><a href="https://quizandsurveymaster.com/docs/v7/text-tab/" target="_blank"><?php _e( 'View Documentation', 'quiz-master-next' ); ?></a></p>
31
+ <div id="poststuff">
32
+ <div id="post-body" class="metabox-holder columns-2">
33
+ <div id="post-body-content" style="position: relative;">
34
+ <?php
35
+ $quiz_text_arr = $mlwQuizMasterNext->quiz_settings->load_setting_fields( 'quiz_text' );
36
+ $editor_text_arr = $text_text_arr = array();
37
+ if( $quiz_text_arr ){
38
+ foreach ( $quiz_text_arr as $key => $single_text_arr ) {
39
+ if( $single_text_arr['type'] == 'editor' ){
40
+ $editor_text_arr[] = $single_text_arr;
41
+ }else{
42
+ $text_text_arr[] = $single_text_arr;
43
+ }
44
+ }
45
+ }
46
+ ?>
47
+ <div class="qsm-text-header">
48
+ <div class="message-dropdown">
49
+ <div class="qsm-row">
50
+ <label><?php _e('Select Message', 'quiz-master-next'); ?></label>
51
+ <select id="qsm_question_text_message_id">
52
+ <?php if( $editor_text_arr ){
53
+ foreach ( $editor_text_arr as $key => $single_editor_arr ) {
54
+ ?>
55
+ <option value="<?php echo $single_editor_arr['id']; ?>"><?php echo $single_editor_arr['label']; ?></option>
56
+ <?php
57
+ }
58
+ } ?>
59
+ </select>
60
+ </div>
61
+ </div>
62
+ <div class="save-text-changes">
63
+ <span class="spinner" style="float: none;"></span>
64
+ <button id="qsm_save_text_message" class="button button-primary"><?php _e('Save Text Message', 'quiz-master-next'); ?></button>
65
+ </div>
66
+ </div>
67
+ <div class="qsm-text-conent">
68
+ <div class="qsm-text-tab-message-loader" style="display: none;"><div class="qsm-spinner-loader"></div></div>
69
+ <?php
70
+ $value_answer = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', $editor_text_arr[0]['id'] );
71
+ wp_editor( htmlspecialchars_decode( $value_answer, ENT_QUOTES ), 'qsm_question_text_message', array( 'textarea_rows' => 10 ) );
72
+ ?>
73
+ </div>
74
+ </div>
75
+ <div id="postbox-container-1" class="postbox-container">
76
+ <div class="qsm-text-header">
77
+ <h5><?php _e('Allowed Variables', 'quiz-master-next'); ?></h5>
78
+ <span class="description"><?php _e('click to insert the variable', 'quiz-master-next'); ?></span>
79
+ </div>
80
+ <div class="qsm-text-conent qsm-text-allowed-variables">
81
+ <div class="qsm-text-tab-message-loader" style="display: none;"><div class="qsm-spinner-loader"></div></div>
82
+ <div class="qsm-text-variable-wrap">
83
+ <?php
84
+ $allowed_variables = isset( $editor_text_arr[0]['variables'] ) ? $editor_text_arr[0]['variables'] : array();
85
+ if( $allowed_variables ){
86
+ foreach ( $allowed_variables as $variable ) { ?>
87
+ <span class="qsm-text-template-span">
88
+ <button class="button button-default"><?php echo $variable; ?></button>
89
+ <?php if( isset( $variable_list[ $variable ] ) ){
90
+ ?>
91
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
92
+ <span class="qsm-tooltips"><?php echo $variable_list[ $variable ]; ?></span>
93
+ </span>
94
+ <?php } ?>
95
+ </span>
96
+ <?php
97
+ }
98
+ }
99
+ ?>
100
+ </div>
101
+ <div style="display: none;" class="qsm-all-variable-wrap">
102
+ <a class="qsm-show-all-variable-text" href="#"><?php _e( 'Show all Variables', 'quiz-master-next' ); ?></a>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ <div class="qsm_text_customize_label"><?php _e('Customize Labels', 'quiz-master-next'); ?> <span class="dashicons dashicons-arrow-down-alt"></span></div>
109
+ </div>
110
+ <div class="qsm-text-label-wrapper">
111
+ <h2><?php _e("Customize Labels", 'quiz-master-next'); ?></h2>
112
+ <?php
113
+ $mlwQuizMasterNext->pluginHelper->generate_settings_section( 'quiz_text', $text_text_arr );
114
+ ?>
115
+ </div>
116
+ <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
117
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
118
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
119
+ <header class="qsm-popup__header">
120
+ <h2 class="qsm-popup__title"><?php _e('Template Variables', 'quiz-master-next'); ?></h2>
121
+ </header>
122
+ <main class="qsm-popup__content" id="show-all-variable-content">
123
+ <?php
124
+ $variable_list = qsm_text_template_variable_list();
125
+ if( $variable_list ){
126
+ foreach ( $variable_list as $key => $s_variable ) { ?>
127
+ <div class="popup-template-span-wrap">
128
+ <span class="qsm-text-template-span">
129
+ <button class="button button-default"><?php echo $key; ?></button>
130
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
131
+ <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
132
+ </span>
133
+ </span>
134
+ </div>
135
+ <?php
136
+ }
137
+ }
138
+ ?>
139
+ </main>
140
+ <footer class="qsm-popup__footer" style="text-align: right;">
141
+ <button class="button button-default" data-micromodal-close="" aria-label="Close this dialog window"><?php _e('Close', 'quiz-master-next'); ?></button>
142
+ </footer>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ <?php
147
  }
148
+
149
+ /**
150
+ * Get the editor text string
151
+ * @global object $mlwQuizMasterNext
152
+ * @since 7.0
153
+ */
154
+ function qsm_get_question_text_message(){
155
+ global $mlwQuizMasterNext;
156
+ $text_id = isset( $_POST['text_id'] ) ? sanitize_text_field( $_POST['text_id'] ) : '';
157
+ if( $text_id == '' ){
158
+ echo json_encode( array( 'success'=> false, 'message' => 'Text id is missing.') );
159
+ exit;
160
+ } else {
161
+ $settings = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', $text_id );
162
+ $quiz_text_arr = $mlwQuizMasterNext->quiz_settings->load_setting_fields( 'quiz_text' );
163
+ $key = array_search( $text_id, array_column( $quiz_text_arr, 'id' ) );
164
+ $allowed_text = '';
165
+ if( isset( $quiz_text_arr[$key] ) ){
166
+ $variable_list = qsm_text_template_variable_list();
167
+ foreach ( $quiz_text_arr[$key]['variables'] as $variable ) {
168
+ $allowed_text .= '<span class="qsm-text-template-span">';
169
+ $allowed_text .= '<button class="button button-default">'. $variable .'</button>';
170
+ if( isset( $variable_list[ $variable ] ) ){
171
+ $allowed_text .= '<span class="dashicons dashicons-editor-help qsm-tooltips-icon">';
172
+ $allowed_text .= '<span class="qsm-tooltips">'. $variable_list[ $variable ] . '</span>';
173
+ $allowed_text .= '</span>';
174
+ }
175
+ $allowed_text .= '</span>';
176
+ }
177
+ }
178
+ $return = array(
179
+ 'text_message' => $settings,
180
+ 'allowed_variable_text' => $allowed_text,
181
+ 'success' => true,
182
+ );
183
+ echo json_encode($return);
184
+ exit;
185
+ }
186
+ }
187
+ add_action( 'wp_ajax_qsm_get_question_text_message', 'qsm_get_question_text_message' );
188
+
189
+ /**
190
+ * Update the text string in DB
191
+ *
192
+ * @since 7.0
193
+ */
194
+ function qsm_update_text_message(){
195
+ global $mlwQuizMasterNext;
196
+ $text_id = isset( $_POST['text_id'] ) ? sanitize_text_field( $_POST['text_id'] ) : '';
197
+ $message = isset( $_POST['message'] ) ? wp_kses_post( stripslashes( $_POST['message'] ) ) : '';
198
+ $settings = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'quiz_text' );
199
+ $settings[ $text_id ] = $message;
200
+ $results = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( 'quiz_text', $settings );
201
+ if ( false != $results ) {
202
+ $results = array(
203
+ 'success' => true
204
+ );
205
+ }else{
206
+ $results = array(
207
+ 'success' => false,
208
+ 'message' => __( 'There has been an error in this action. Please share this with the developer', 'quiz-master-next' )
209
+ );
210
+ }
211
+ echo json_encode($results);
212
+ exit;
213
+ }
214
+ add_action( 'wp_ajax_qsm_update_text_message', 'qsm_update_text_message' );
215
  ?>
php/admin/quiz-options-page.php CHANGED
@@ -61,7 +61,7 @@ function qsm_generate_quiz_options() {
61
  wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
62
  wp_enqueue_style( 'qmn_jquery_redmond_theme', plugins_url( '../../css/jquery-ui.css', __FILE__ ) );
63
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
64
-
65
  // Edit Quiz Name.
66
  if ( isset( $_POST['qsm_edit_name_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_edit_name_quiz_nonce'], 'qsm_edit_name_quiz' ) ) {
67
  //$quiz_id = intval( $_POST['edit_quiz_id'] );
@@ -69,39 +69,45 @@ function qsm_generate_quiz_options() {
69
  $mlwQuizMasterNext->quizCreator->edit_quiz_name( $quiz_id, $quiz_name );
70
  }
71
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  <div class="wrap">
73
  <div class='mlw_quiz_options'>
74
- <h1 style="display: inline-block;"><?php echo $quiz_name; ?></h1>
75
- <a style="display: inline-block;margin-top: 10px;margin-bottom: 15px;margin-left: 10px;" hre="#" class="edit-quiz-name button button-primary">Edit Name</a>
76
- <?php
77
- // Get quiz post based on quiz id
78
- $args = array(
79
- 'posts_per_page' => 1,
80
- 'post_type' => 'qsm_quiz',
81
- 'meta_query' => array(
82
- array(
83
- 'key' => 'quiz_id',
84
- 'value' => $quiz_id,
85
- 'compare' => '=',
86
- ),
87
- ),
88
- );
89
- $the_query = new WP_Query($args);
90
-
91
- // The Loop
92
- $post_permalink = '';
93
- if ($the_query->have_posts()) {
94
- while ($the_query->have_posts()) {
95
- $the_query->the_post();
96
- $post_permalink = get_the_permalink(get_the_ID());
97
- }
98
- /* Restore original Post Data */
99
- wp_reset_postdata();
100
- }
101
- ?>
102
- <a style="text-decoration: none; position: relative; top: 9px; left: 5px;" target="_blank" href="<?php echo $post_permalink; ?>">
103
- <span style="font-size: 30px;" class="dashicons dashicons-external"></span>
104
- </a>
105
  <?php
106
  // Puts all output from tab into ob_get_contents below.
107
  ob_start();
61
  wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
62
  wp_enqueue_style( 'qmn_jquery_redmond_theme', plugins_url( '../../css/jquery-ui.css', __FILE__ ) );
63
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
64
+ wp_localize_script('qmn_admin_js', 'qsmTextTabObject', array( 'quiz_id' => $quiz_id ));
65
  // Edit Quiz Name.
66
  if ( isset( $_POST['qsm_edit_name_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_edit_name_quiz_nonce'], 'qsm_edit_name_quiz' ) ) {
67
  //$quiz_id = intval( $_POST['edit_quiz_id'] );
69
  $mlwQuizMasterNext->quizCreator->edit_quiz_name( $quiz_id, $quiz_name );
70
  }
71
  ?>
72
+ <?php
73
+ // Get quiz post based on quiz id
74
+ $args = array(
75
+ 'posts_per_page' => 1,
76
+ 'post_type' => 'qsm_quiz',
77
+ 'meta_query' => array(
78
+ array(
79
+ 'key' => 'quiz_id',
80
+ 'value' => $quiz_id,
81
+ 'compare' => '=',
82
+ ),
83
+ ),
84
+ );
85
+ $the_query = new WP_Query($args);
86
+
87
+ // The Loop
88
+ $post_permalink = $edit_link = '';
89
+ if ($the_query->have_posts()) {
90
+ while ($the_query->have_posts()) {
91
+ $the_query->the_post();
92
+ $post_permalink = get_the_permalink(get_the_ID());
93
+ $edit_link = get_edit_post_link(get_the_ID());
94
+ }
95
+ /* Restore original Post Data */
96
+ wp_reset_postdata();
97
+ }
98
+ ?>
99
  <div class="wrap">
100
  <div class='mlw_quiz_options'>
101
+ <h1 style="margin-bottom: 10px;">
102
+ <?php echo $quiz_name; ?>
103
+ <a class="qsm-view-preview-btn" target="_blank" href="<?php echo $post_permalink; ?>">
104
+ <span class="dashicons dashicons-external"></span>
105
+ </a>
106
+ <a class="button button-default qsm-btn-quiz-edit" href="<?php echo $edit_link; ?>">
107
+ <span class="dashicons dashicons-admin-settings"></span> <?php _e('Post Settings', 'quiz-master-next'); ?>
108
+ </a>
109
+ <a href="#" class="edit-quiz-name button button-primary">Edit Name</a>
110
+ </h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  <?php
112
  // Puts all output from tab into ob_get_contents below.
113
  ob_start();
php/admin/quizzes-page.php CHANGED
@@ -4,9 +4,8 @@
4
  *
5
  * @package QSM
6
  */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit;
10
  }
11
 
12
  /**
@@ -16,471 +15,641 @@ if ( ! defined( 'ABSPATH' ) ) {
16
  */
17
  function qsm_generate_quizzes_surveys_page() {
18
 
19
- // Only let admins and editors see this page.
20
- if ( ! current_user_can( 'edit_posts' ) ) {
21
- return;
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- // Retrieve our globals.
25
- global $wpdb;
26
- global $mlwQuizMasterNext;
27
 
28
- // Enqueue our styles and scripts.
29
- wp_enqueue_script( 'micromodal_script', plugins_url( '../../js/micromodal.min.js', __FILE__ ) );
30
- wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
31
- wp_enqueue_script( 'qsm_admin_script', plugins_url( '../../js/qsm-admin.js', __FILE__ ), array( 'wp-util', 'underscore', 'jquery', 'micromodal_script' ), $mlwQuizMasterNext->version );
32
 
33
- // Create new quiz.
34
- if ( isset( $_POST['qsm_new_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_new_quiz_nonce'], 'qsm_new_quiz' ) ) {
35
- $quiz_name = sanitize_textarea_field( htmlspecialchars( stripslashes( $_POST['quiz_name'] ), ENT_QUOTES ) );
36
- $mlwQuizMasterNext->quizCreator->create_quiz( $quiz_name );
37
- }
38
 
39
- // Delete quiz.
40
- if ( isset( $_POST['qsm_delete_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_delete_quiz_nonce'], 'qsm_delete_quiz' ) ) {
41
- $quiz_id = intval( $_POST['delete_quiz_id'] );
42
- $quiz_name = sanitize_text_field( $_POST['delete_quiz_name'] );
43
- $mlwQuizMasterNext->quizCreator->delete_quiz( $quiz_id, $quiz_name );
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- // Duplicate Quiz.
47
- if ( isset( $_POST['qsm_duplicate_quiz_nonce'] ) && wp_verify_nonce( $_POST['qsm_duplicate_quiz_nonce'], 'qsm_duplicate_quiz' ) ) {
48
- $quiz_id = intval( $_POST['duplicate_quiz_id'] );
49
- $quiz_name = sanitize_text_field( htmlspecialchars( $_POST['duplicate_new_quiz_name'], ENT_QUOTES ) );
50
- $mlwQuizMasterNext->quizCreator->duplicate_quiz( $quiz_id, $quiz_name, isset( $_POST['duplicate_questions'] ) );
51
- }
52
 
53
- // Resets stats for a quiz.
54
- if ( isset( $_POST['qsm_reset_stats_nonce'] ) && wp_verify_nonce( $_POST['qsm_reset_stats_nonce'] , 'qsm_reset_stats' ) ) {
55
- $quiz_id = intval( $_POST['reset_quiz_id'] );
56
- $results = $wpdb->update(
57
- $wpdb->prefix . 'mlw_quizzes',
58
- array(
59
- 'quiz_views' => 0,
60
- 'quiz_taken' => 0,
61
- 'last_activity' => date( 'Y-m-d H:i:s' ),
62
- ),
63
- array( 'quiz_id' => $quiz_id ),
64
- array(
65
- '%d',
66
- '%d',
67
- '%s',
68
- ),
69
- array( '%d' )
70
- );
71
- if ( false !== $results ) {
72
- $mlwQuizMasterNext->alertManager->newAlert( __( 'The stats has been reset successfully.', 'quiz-master-next' ), 'success' );
73
- $mlwQuizMasterNext->audit_manager->new_audit( "Quiz Stats Have Been Reset For Quiz Number $quiz_id" );
74
- } else {
75
- $mlwQuizMasterNext->alertManager->newAlert( __( 'Error trying to reset stats. Please try again.', 'quiz-master-next' ), 'error' );
76
- $mlwQuizMasterNext->log_manager->add( 'Error resetting stats', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
77
- }
78
- }
79
-
80
- //Query for post
81
- $post_arr = array(
82
- 'post_type' => 'qsm_quiz',
83
- 'posts_per_page' => -1,
84
- 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private')
85
- );
86
- //Check user role and fetch the quiz
87
- $user = wp_get_current_user();
88
- if ( in_array( 'author', (array) $user->roles ) ) {
89
- $post_arr['author__in'] = [$user->ID];
90
  }
91
- if(isset($_GET['order']) && $_GET['order'] == 'asc'){
92
- $post_arr['orderby'] = isset($_GET['orderby']) && $_GET['orderby'] == 'title' ? 'title' : 'last_activity';
93
- $post_arr['order'] = 'ASC';
94
- // Load our quizzes.
95
- $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, $post_arr['orderby'], 'ASC', (array) $user->roles, $user->ID);
96
- }else if( isset($_GET['order']) && $_GET['order'] == 'desc' ){
97
- $post_arr['orderby'] = isset($_GET['orderby']) && $_GET['orderby'] == 'title' ? 'title' : 'last_activity';
98
- $post_arr['order'] = 'DESC';
99
- // Load our quizzes.
100
- $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, $post_arr['orderby'], 'DESC',(array) $user->roles, $user->ID);
101
- } else{
102
- // Load our quizzes.
103
- $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, '', '',(array) $user->roles, $user->ID);
104
- }
105
 
106
- // Load quiz posts.
107
- $post_to_quiz_array = array();
108
- $my_query = new WP_Query( $post_arr );
109
-
110
- if ( $my_query->have_posts() ) {
111
- while ( $my_query->have_posts() ) {
112
- $my_query->the_post();
113
- $post_to_quiz_array[ get_post_meta( get_the_ID(), 'quiz_id', true ) ] = array(
114
- 'link' => get_the_permalink(get_the_ID()),
115
- 'id' => get_the_ID(),
116
- 'post_status' => get_post_status(get_the_ID()),
117
- );
118
- }
119
- }
120
- wp_reset_postdata();
121
- $quiz_json_array = array();
122
- foreach ( $quizzes as $quiz ) {
123
- if ( ! isset( $post_to_quiz_array[ $quiz->quiz_id ] ) ) {
124
- $current_user = wp_get_current_user();
125
- $quiz_post = array(
126
- 'post_title' => $quiz->quiz_name,
127
- 'post_content' => "[qsm quiz={$quiz->quiz_id}]",
128
- //'post_status' => 'publish',
129
- 'post_author' => $current_user->ID,
130
- 'post_type' => 'qsm_quiz',
131
- );
132
- $quiz_post_id = wp_insert_post( $quiz_post );
133
- add_post_meta( $quiz_post_id, 'quiz_id', $quiz->quiz_id );
134
- $post_to_quiz_array[ $quiz->quiz_id ] = array(
135
- 'link' => get_permalink( $quiz_post_id ),
136
- 'id' => $quiz_post_id,
137
- 'post_status' => get_post_status($quiz_post_id),
138
- );
139
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
- $activity_date = date_i18n( get_option( 'date_format' ), strtotime( $quiz->last_activity ) );
142
- $activity_time = date( 'h:i:s A', strtotime( $quiz->last_activity ) );
143
- $quiz_json_array[] = array(
144
- 'id' => $quiz->quiz_id,
145
- 'name' => esc_html( $quiz->quiz_name ),
146
- 'link' => $post_to_quiz_array[ $quiz->quiz_id ]['link'],
147
- 'postID' => $post_to_quiz_array[ $quiz->quiz_id ]['id'],
148
- 'views' => $quiz->quiz_views,
149
- 'taken' => $quiz->quiz_taken,
150
- 'lastActivity' => $activity_date,
151
- 'lastActivityDateTime' => $activity_date . ' ' .$activity_time,
152
- 'post_status' => $post_to_quiz_array[ $quiz->quiz_id ]['post_status'],
153
- );
154
- }
155
- $total_count = count( $quiz_json_array );
156
- wp_localize_script( 'qsm_admin_script', 'qsmQuizObject', $quiz_json_array );
157
- ?>
158
- <div class="wrap qsm-quizes-page">
159
- <h1>
160
- <?php esc_html_e( 'Quizzes/Surveys', 'quiz-master-next' ); ?>
161
- <a id="new_quiz_button" href="#" class="add-new-h2"><?php _e( 'Add New', 'quiz-master-next' ); ?></a>
162
- </h1>
163
- <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
164
- <?php
165
- if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
166
- ?>
167
- <div class="qsm-info-box">
168
- <p>Your site is using PHP version <?php echo esc_html( PHP_VERSION ); ?>! Starting in QSM 6.0, your version of PHP will no longer be supported. <a href="http://bit.ly/2lyrrm8" target="_blank">Click here to learn more about QSM's minimum PHP version change.</a></p>
169
- </div>
170
- <?php
171
- }
172
- ?>
173
- <div class="qsm-quizzes-page-content">
174
- <div class="<?php if ( 'false' != get_option( 'mlw_advert_shows' ) ) { echo 'qsm-quiz-page-wrapper-with-ads'; } else { echo 'qsm-quiz-page-wrapper'; } ?>">
175
- <p class="search-box">
176
- <label class="screen-reader-text" for="quiz_search"><?php esc_html_e( 'Search', 'quiz-master-next' ); ?></label>
177
- <input type="search" id="quiz_search" name="quiz_search" value="">
178
- <a href="#" class="button"><?php esc_html_e( 'Search', 'quiz-master-next' ); ?></a>
179
- <?php if(class_exists('QSM_Export_Import')){ ?>
180
- <a class="button button-primary" href="<?php echo admin_url() . 'admin.php?page=qmn_addons&tab=export-and-import'; ?>" target="_blank"><?php _e( 'Import & Export', 'quiz-master-next' ); ?></a>
181
- <?php } else{ ?>
182
- <a id="show_import_export_popup" href="#" style="position: relative;top: 0px;" class="add-new-h2 button-primary"><?php _e( 'Import & Export', 'quiz-master-next' ); ?></a>
183
- <?php } ?>
184
- </p>
185
- <div class="tablenav top">
186
- <div class="tablenav-pages">
187
- <span class="displaying-num"><?php echo sprintf( _n( 'One quiz or survey', '%s quizzes or surveys', $total_count, 'quiz-master-next' ), number_format_i18n( $total_count ) ); ?></span>
188
- <br class="clear">
189
- </div>
190
- </div>
191
- <table class="widefat">
192
- <?php
193
- $orderby_slug = '&orderby=title&order=asc';
194
- $orderby_date_slug = '&orderby=date&order=asc';
195
- $orderby_class = $orderby_date_class = 'sortable desc';
196
- //Title order
197
- if( isset($_GET['orderby']) && $_GET['orderby'] === 'title' ){
198
- if(isset($_GET['order']) && $_GET['order'] === 'asc'){
199
- $orderby_slug = '&orderby=title&order=desc';
200
- $orderby_class = 'sorted asc';
201
- }else if( isset($_GET['order']) && $_GET['order'] === 'desc' ){
202
- $orderby_slug = '&orderby=title&order=asc';
203
- $orderby_class = 'sorted desc';
204
- }
205
- } else if( isset($_GET['orderby']) && $_GET['orderby'] === 'date' ){
206
- if(isset($_GET['order']) && $_GET['order'] === 'asc'){
207
- $orderby_date_slug = '&orderby=date&order=desc';
208
- $orderby_date_class = 'sorted asc';
209
- }else if( isset($_GET['order']) && $_GET['order'] === 'desc' ){
210
- $orderby_date_slug = '&orderby=date&order=asc';
211
- $orderby_date_class = 'sorted desc';
212
- }
213
- }
214
- ?>
215
- <thead>
216
- <tr>
217
- <th class="<?php echo $orderby_class; ?>">
218
- <a href="<?php echo '?page=' . QSM_PLUGIN_BASENAME . $orderby_slug; ?>">
219
- <span><?php esc_html_e( 'Name', 'quiz-master-next' ); ?></span>
220
- <span class="sorting-indicator"></span>
221
- </a>
222
- </th>
223
- <th><?php esc_html_e( 'Shortcode', 'quiz-master-next' ); ?></th>
224
- <th><?php esc_html_e( 'Views/Taken', 'quiz-master-next' ); ?></th>
225
- <th class="<?php echo $orderby_date_class; ?>">
226
- <a href="<?php echo '?page=' . QSM_PLUGIN_BASENAME . $orderby_date_slug; ?>">
227
- <span><?php esc_html_e( 'Last Modified', 'quiz-master-next' ); ?></span>
228
- <span class="sorting-indicator"></span>
229
- </a>
230
- </th>
231
- </tr>
232
- </thead>
233
- <tbody id="the-list">
234
 
235
- </tbody>
236
- <tfoot>
237
- <tr>
238
- <th class="<?php echo $orderby_class; ?>">
239
- <a href="<?php echo '?page=' . QSM_PLUGIN_BASENAME . $orderby_slug; ?>">
240
- <span><?php esc_html_e( 'Name', 'quiz-master-next' ); ?></span>
241
- <span class="sorting-indicator"></span>
242
- </a>
243
- </th>
244
- <th><?php esc_html_e( 'Shortcode', 'quiz-master-next' ); ?></th>
245
- <th><?php esc_html_e( 'Views/Taken', 'quiz-master-next' ); ?></th>
246
- <th class="<?php echo $orderby_date_class; ?>">
247
- <a href="<?php echo '?page=' . QSM_PLUGIN_BASENAME . $orderby_date_slug; ?>">
248
- <span><?php esc_html_e( 'Last Modified', 'quiz-master-next' ); ?></span>
249
- <span class="sorting-indicator"></span>
250
- </a>
251
- </th>
252
- </tr>
253
- </tfoot>
254
- </table>
255
- </div>
256
- <?php
257
- if ( 'true' == get_option( 'mlw_advert_shows' ) ) {
258
- ?>
259
- <div class="qsm-news-ads">
260
- <h3 class="qsm-news-ads-title"><?php esc_html_e( 'QSM News', 'quiz-master-next' ); ?></h3>
261
- <!-- <div class="qsm-info-widget">
262
- <h3>Keep your WordPress site healthy and secure!</h3>
263
- <p>Easily monitor your WordPress sites to ensure they stay up, healthy, and secure with our new WordPress plugin, WP Health!</p>
264
- <a target="_blank" href="http://bit.ly/2Mr2SqC" class="button-primary"><?php esc_html_e( 'Learn More', 'quiz-master-next' ); ?></a>
265
- </div>-->
266
- <?php
267
- $xml = qsm_fetch_data_from_xml();
268
- if(isset($xml->qsm_news)){
269
- ?>
270
- <div class="qsm-info-widget">
271
- <h3><?php echo $xml->qsm_news->title; ?></h3>
272
- <p><?php echo $xml->qsm_news->desc; ?></p>
273
- <a target="_blank" href="<?php echo $xml->qsm_news->link; ?>?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin&utm_content=subscribe-to-newsletter" class="button-primary"><?php _e( 'Subscribe Now', 'quiz-master-next' ); ?></a>
274
- </div>
275
- <?php
276
- }
277
- $qmn_rss = array();
278
- if( false === get_transient('qsm_sidebar_feed_data') ){
279
- $qmn_feed = fetch_feed( 'https://quizandsurveymaster.com/feed' );
280
- if ( ! is_wp_error( $qmn_feed ) ) {
281
- $qmn_feed_items = $qmn_feed->get_items( 0, 5 );
282
- foreach ( $qmn_feed_items as $feed_item ) {
283
- $qmn_rss[] = array(
284
- 'link' => $feed_item->get_link(),
285
- 'title' => $feed_item->get_title(),
286
- 'description' => $feed_item->get_description(),
287
- 'date' => $feed_item->get_date( 'F j Y' ),
288
- 'author' => $feed_item->get_author()->get_name(),
289
- );
290
- }
291
- }
292
- set_transient( 'qsm_sidebar_feed_data', $qmn_rss, 60*60*24 );
293
- }else{
294
- $qmn_rss = get_transient('qsm_sidebar_feed_data');
295
- }
296
- foreach ( $qmn_rss as $item ) {
297
- ?>
298
- <div class="qsm-info-widget">
299
- <h3><?php echo esc_html( $item['title'] ); ?></h3>
300
- <p>By <?php echo esc_html( $item['author'] ); ?></p>
301
- <div>
302
- <?php echo esc_html( $item['description'] ); ?>
303
- </div>
304
- <a target='_blank' href="<?php echo esc_attr( $item['link'] ); ?>?utm_source=qsm-quizzes-page&utm_medium=plugin&utm_campaign=qsm_plugin" class="button-primary"><?php _e( 'Read More', 'quiz-master-next' ); ?></a>
305
- </div>
306
- <?php
307
- }
308
- ?>
309
- <div class="remove-ads-adv-link">
310
- <a target="_blank" href="https://quizandsurveymaster.com/downloads/advertisement-gone/"><span class="dashicons dashicons-no-alt"></span> Remove Ads</a>
311
- </div>
312
- </div>
313
- <?php
314
- }
315
- ?>
316
- </div>
317
 
318
- <!-- Popup for resetting stats -->
319
- <div class="qsm-popup qsm-popup-slide" id="modal-1" aria-hidden="true">
320
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
321
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
322
- <header class="qsm-popup__header">
323
- <h2 class="qsm-popup__title" id="modal-1-title">Reset stats for this quiz?</h2>
324
- <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
325
- </header>
326
- <main class="qsm-popup__content" id="modal-1-content">
327
- <p><?php _e('Are you sure you want to reset the stats to 0? All views and taken stats for this quiz will be reset. This is permanent and cannot be undone.', 'quiz-master-next'); ?></p>
328
- <form action="" method="post" id="reset_quiz_form">
329
- <?php wp_nonce_field( 'qsm_reset_stats', 'qsm_reset_stats_nonce' ); ?>
330
- <input type="hidden" id="reset_quiz_id" name="reset_quiz_id" value="0" />
331
- </form>
332
- </main>
333
- <footer class="qsm-popup__footer">
334
- <button id="reset-stats-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Reset All Stats For Quiz', 'quiz-master-next'); ?></button>
335
- <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
336
- </footer>
337
- </div>
338
- </div>
339
- </div>
 
 
340
 
341
- <!-- Popup for new quiz -->
342
- <div class="qsm-popup qsm-popup-slide" id="modal-2" aria-hidden="true">
343
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
344
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-2-title">
345
- <header class="qsm-popup__header">
346
- <h2 class="qsm-popup__title" id="modal-2-title"><?php _e( 'Create New Quiz Or Survey', 'quiz-master-next' ); ?></h2>
347
- <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
348
- </header>
349
- <main class="qsm-popup__content" id="modal-2-content">
350
- <form action="" method="post" id="new-quiz-form">
351
- <?php wp_nonce_field( 'qsm_new_quiz', 'qsm_new_quiz_nonce' ); ?>
352
- <label><?php _e( 'Name', 'quiz-master-next' ); ?></label>
353
- <input type="text" name="quiz_name" value="" />
354
- </form>
355
- </main>
356
- <footer class="qsm-popup__footer">
357
- <button id="create-quiz-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Create', 'quiz-master-next'); ?></button>
358
- <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
359
- </footer>
360
- </div>
361
- </div>
362
- </div>
 
363
 
364
- <!-- Popup for duplicate quiz -->
365
- <div class="qsm-popup qsm-popup-slide" id="modal-4" aria-hidden="true">
366
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
367
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-4-title">
368
- <header class="qsm-popup__header">
369
- <h2 class="qsm-popup__title" id="modal-4-title"><?php _e( 'Duplicate', 'quiz-master-next' ); ?></h2>
370
- <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
371
- </header>
372
- <main class="qsm-popup__content" id="modal-4-content">
373
- <form action='' method='post' id="duplicate-quiz-form">
374
- <label for="duplicate_questions"><?php _e( 'Duplicate questions also?', 'quiz-master-next' ); ?></label><input type="checkbox" name="duplicate_questions" id="duplicate_questions"/><br />
375
- <br />
376
- <label for="duplicate_new_quiz_name"><?php _e( 'Name Of New Quiz Or Survey:', 'quiz-master-next' ); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
377
- <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
378
- <?php wp_nonce_field( 'qsm_duplicate_quiz', 'qsm_duplicate_quiz_nonce' ); ?>
379
- </form>
380
- </main>
381
- <footer class="qsm-popup__footer">
382
- <button id="duplicate-quiz-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Duplicate', 'quiz-master-next'); ?></button>
383
- <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
384
- </footer>
385
- </div>
386
- </div>
387
- </div>
388
 
389
- <!-- Popup for delete quiz -->
390
- <div class="qsm-popup qsm-popup-slide" id="modal-5" aria-hidden="true">
391
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
392
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-5-title">
393
- <header class="qsm-popup__header">
394
- <h2 class="qsm-popup__title" id="modal-5-title"><?php _e( 'Delete', 'quiz-master-next' ); ?></h2>
395
- <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
396
- </header>
397
- <main class="qsm-popup__content" id="modal-5-content">
398
- <form action='' method='post' id="delete-quiz-form">
399
- <h3><b><?php _e( 'Are you sure you want to delete this quiz or survey?', 'quiz-master-next' ); ?></b></h3>
400
- <?php wp_nonce_field( 'qsm_delete_quiz', 'qsm_delete_quiz_nonce' ); ?>
401
- <input type='hidden' id='delete_quiz_id' name='delete_quiz_id' value='' />
402
- <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
403
- </form>
404
- </main>
405
- <footer class="qsm-popup__footer">
406
- <button id="delete-quiz-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Delete', 'quiz-master-next'); ?></button>
407
- <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
408
- </footer>
409
- </div>
410
- </div>
411
- </div>
412
-
413
- <!-- Popup for export import upsell -->
414
- <div class="qsm-popup qsm-popup-slide" id="modal-export-import" aria-hidden="true">
415
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
416
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-5-title">
417
- <header class="qsm-popup__header">
418
- <h2 class="qsm-popup__title" id="modal-5-title"><?php _e( 'Extend QSM', 'quiz-master-next' ); ?></h2>
419
- <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
420
- </header>
421
- <main class="qsm-popup__content" id="modal-5-content">
422
- <h3><b><?php _e( 'Export functionality is provided as Premium addon.', 'quiz-master-next' ); ?></b></h3>
423
- </main>
424
- <footer class="qsm-popup__footer">
425
- <a style="color: white; text-decoration: none;" href="https://quizandsurveymaster.com/downloads/export-import/" target="_blank" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Buy Now', 'quiz-master-next'); ?></a>
426
- <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
427
- </footer>
428
- </div>
429
- </div>
430
- </div>
431
 
432
- <!-- Popup for delete quiz -->
433
- <div class="qsm-popup qsm-popup-slide" id="modal-6" aria-hidden="true">
434
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
435
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-5-title">
436
- <header class="qsm-popup__header">
437
- <h2 class="qsm-popup__title" id="modal-5-title"><?php _e( 'Shortcode', 'quiz-master-next' ); ?></h2>
438
- <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
439
- </header>
440
- <main class="qsm-popup__content" id="modal-5-content">
441
- <input type="text" value="" id="sc-shortcode-model-text" style="width: 72%;padding: 5px;">
442
- <button class="button button-primary" id="sc-copy-shortcode">Copy Shortcode</button>
443
- </main>
444
- </div>
445
- </div>
446
- </div>
447
 
448
- <!-- Templates -->
449
- <script type="text/template" id="tmpl-no-quiz">
450
- <h2><?php _e( 'You do not have any quizzes or surveys. Click "Add New" to get started.', 'quiz-master-next' ); ?></h2>
451
- <h2>Is this your first time using this plugin? Check out our <a href="https://quizandsurveymaster.com/docs" target="_blank">Documentation</a> or watch our Getting Started Video below</h2>
452
- <iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/coE5W_WB-48" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
453
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454
 
455
- <script type="text/template" id="tmpl-quiz-row">
456
- <tr class="qsm-quiz-row" data-id="{{ data.id }}">
457
- <td class="post-title column-title">
458
- <a class="row-title" href="admin.php?page=mlw_quiz_options&&quiz_id={{ data.id }}" aria-label="{{ data.name }}">{{ data.name }} <b style="color: #222; text-transform: capitalize;">{{ data.post_status }}</b></a><a target="_blank" class="quiz-preview-link" href="{{ data.link }}"><span class="dashicons dashicons-external"></span></a>
459
- <div class="row-actions">
460
- <a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&&quiz_id={{ data.id }}"><?php _e( 'Edit', 'quiz-master-next' ); ?></a> |
461
- <a class="qsm-action-link" href="post.php?post={{ data.postID }}&action=edit"><?php _e( 'Post Settings', 'quiz-master-next' ); ?></a> |
462
- <a class="qsm-action-link qsm-action-link-duplicate" href="#"><?php _e( 'Duplicate', 'quiz-master-next' ); ?></a> |
463
- <a class="qsm-action-link qsm-action-link-delete" href="#"><?php _e( 'Delete', 'quiz-master-next' ); ?></a> |
464
- <a class="qsm-action-link" target="_blank" href="{{ data.link }}"><?php _e( 'Preview', 'quiz-master-next' ); ?></a>
465
- </div>
466
- </td>
467
- <td>
468
- <p class="sc-opener"><span class="dashicons dashicons-editor-contract"></span> Embed</p>
469
- <div class="sc-content">[qsm quiz={{ data.id }}]</div>
470
- <p class="sc-opener"><span class="dashicons dashicons-admin-links"></span> Link</p>
471
- <div class="sc-content">[qsm_link id={{ data.id }}]<?php _e( 'Click here', 'quiz-master-next' ); ?>[/qsm_link]</div>
472
- </td>
473
- <td>
474
- {{ data.views }}/{{ data.taken }}
475
- <div class="row-actions">
476
- <a class="qsm-action-link qsm-action-link-reset" href="#"><?php _e( 'Reset', 'quiz-master-next' ); ?></a> |
477
- <a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&&quiz_id={{ data.id }}"><?php _e( 'Results', 'quiz-master-next' ); ?></a>
478
- </div>
479
- </td>
480
- <td><abbr title="{{ data.lastActivityDateTime }}">{{ data.lastActivity }}</abbr></td>
481
- </tr>
482
- </script>
483
- </div>
484
- <?php
 
 
485
  }
486
  ?>
4
  *
5
  * @package QSM
6
  */
7
+ if (!defined('ABSPATH')) {
8
+ exit;
 
9
  }
10
 
11
  /**
15
  */
16
  function qsm_generate_quizzes_surveys_page() {
17
 
18
+ // Only let admins and editors see this page.
19
+ if (!current_user_can('edit_posts')) {
20
+ return;
21
+ }
22
+
23
+ // Retrieve our globals.
24
+ global $wpdb;
25
+ global $mlwQuizMasterNext;
26
+
27
+ // Enqueue our styles and scripts.
28
+ wp_enqueue_script('micromodal_script', plugins_url('../../js/micromodal.min.js', __FILE__));
29
+ wp_enqueue_style('qsm_admin_style', plugins_url('../../css/qsm-admin.css', __FILE__), array(), $mlwQuizMasterNext->version);
30
+ wp_enqueue_script('qsm_admin_script', plugins_url('../../js/qsm-admin.js', __FILE__), array('wp-util', 'underscore', 'jquery', 'micromodal_script', 'jquery-ui-accordion'), $mlwQuizMasterNext->version);
31
+ wp_enqueue_style('qsm_admin_dashboard_css', plugins_url('../../css/admin-dashboard.css', __FILE__));
32
+ wp_enqueue_style('qsm_ui_css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css');
33
+
34
+ // Delete quiz.
35
+ if (isset($_POST['qsm_delete_quiz_nonce']) && wp_verify_nonce($_POST['qsm_delete_quiz_nonce'], 'qsm_delete_quiz')) {
36
+ $quiz_id = intval($_POST['delete_quiz_id']);
37
+ $quiz_name = sanitize_text_field($_POST['delete_quiz_name']);
38
+ $mlwQuizMasterNext->quizCreator->delete_quiz($quiz_id, $quiz_name);
39
+ }
40
+
41
+ // Duplicate Quiz.
42
+ if (isset($_POST['qsm_duplicate_quiz_nonce']) && wp_verify_nonce($_POST['qsm_duplicate_quiz_nonce'], 'qsm_duplicate_quiz')) {
43
+ $quiz_id = intval($_POST['duplicate_quiz_id']);
44
+ $quiz_name = sanitize_text_field(htmlspecialchars($_POST['duplicate_new_quiz_name'], ENT_QUOTES));
45
+ $mlwQuizMasterNext->quizCreator->duplicate_quiz($quiz_id, $quiz_name, isset($_POST['duplicate_questions']) ? sanitize_text_field( $_POST['duplicate_questions'] ) : 0);
46
+ }
47
+
48
+ // Resets stats for a quiz.
49
+ if (isset($_POST['qsm_reset_stats_nonce']) && wp_verify_nonce($_POST['qsm_reset_stats_nonce'], 'qsm_reset_stats')) {
50
+ $quiz_id = intval($_POST['reset_quiz_id']);
51
+ $results = $wpdb->update(
52
+ $wpdb->prefix . 'mlw_quizzes', array(
53
+ 'quiz_views' => 0,
54
+ 'quiz_taken' => 0,
55
+ 'last_activity' => date('Y-m-d H:i:s'),
56
+ ), array('quiz_id' => $quiz_id), array(
57
+ '%d',
58
+ '%d',
59
+ '%s',
60
+ ), array('%d')
61
+ );
62
+ if (false !== $results) {
63
+ $mlwQuizMasterNext->alertManager->newAlert(__('The stats has been reset successfully.', 'quiz-master-next'), 'success');
64
+ $mlwQuizMasterNext->audit_manager->new_audit("Quiz Stats Have Been Reset For Quiz Number $quiz_id");
65
+ } else {
66
+ $mlwQuizMasterNext->alertManager->newAlert(__('Error trying to reset stats. Please try again.', 'quiz-master-next'), 'error');
67
+ $mlwQuizMasterNext->log_manager->add('Error resetting stats', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error');
68
+ }
69
+ }
70
+
71
+ //Pagination.
72
+ $paged = filter_input(INPUT_GET, 'paged') ? absint(filter_input(INPUT_GET, 'paged')) : 1;
73
+ if (!is_numeric($paged))
74
+ $paged = 1;
75
+ $limit = 10; // number of rows in page.
76
+
77
+ $current_user = get_current_user_id();
78
+ $screen = get_current_screen();
79
+ $screen_option = $screen->get_option('per_page', 'option');
80
+ $limit = get_user_meta($current_user, $screen_option, true);
81
+
82
+ if (empty($limit) || $limit < 1) {
83
+ // get the default value if none is set
84
+ $limit = $screen->get_option('per_page', 'default');
85
+ }
86
+ $offset = ( $paged - 1 ) * $limit;
87
+ $where = '';
88
+ $search = '';
89
+ if (isset($_REQUEST['s']) && $_REQUEST['s'] != '') {
90
+ $search = $_REQUEST['s'];
91
+ $where = " quiz_name LIKE '%$search%'";
92
+ }
93
+
94
+ /*if ( isset($_POST['btnSearchQuiz']) || isset($_POST['s']) && $_POST['s'] != '' ) {
95
+ $delete_action = '';
96
+ if (isset($_POST['take_action']) && isset($_POST['qsm-ql-action-top']) || isset($_POST['take_action']) && isset($_POST['qsm-ql-action-bottom'])) {
97
+ $delete_action = 'multiple_delete';
98
+ }
99
+ ?>
100
+ <script type="text/javascript">
101
+ var paged = '<?php echo $paged; ?>';
102
+ var s = ['<?php echo $search; ?>'];
103
+ var action = ['<?php echo $delete_action; ?>'];
104
+ window.location = "?page=mlw_quiz_list&paged=1&s=" + s + "&action=" + action;
105
+ </script>
106
+ <?php
107
+ } */
108
+
109
+ // Multiple Delete quiz.
110
+ if (isset($_POST['qsm_search_multiple_delete_nonce']) && wp_verify_nonce($_POST['qsm_search_multiple_delete_nonce'], 'qsm_search_multiple_delete')) {
111
+ if( ( isset($_POST[ 'qsm-ql-action-top' ]) && $_POST['qsm-ql-action-top'] == 'delete_pr' ) || ( isset($_POST[ 'qsm-ql-action-bottom' ]) && $_POST['qsm-ql-action-bottom'] == 'delete_pr' ) ){
112
+ $quiz_ids_arr = $_POST['chk_remove_all'];
113
+ if($quiz_ids_arr){
114
+ foreach ($quiz_ids_arr as $quiz_id) {
115
+ $mlwQuizMasterNext->quizCreator->delete_quiz($quiz_id, $quiz_id);
116
+ }
117
+ }
118
+ }
119
+ }
120
+
121
+ if (isset($_REQUEST['s']) && $_REQUEST['s'] != '') {
122
+ $search = $_REQUEST['s'];
123
+ $condition = " WHERE deleted='0' AND quiz_name LIKE '%$search%'";
124
+ $qry = "SELECT COUNT('quiz_id') FROM {$wpdb->prefix}mlw_quizzes" . $condition;
125
+ $total = $wpdb->get_var($qry);
126
+ $num_of_pages = ceil($total / $limit);
127
+ } else {
128
+ $condition = " WHERE deleted='0'";
129
+ $total = $wpdb->get_var("SELECT COUNT(`quiz_id`) FROM {$wpdb->prefix}mlw_quizzes " . $condition);
130
+ $num_of_pages = ceil($total / $limit);
131
+ }
132
+
133
+ //Next and previous page.
134
+ $next_page = (int) $paged + 1;
135
 
136
+ if ($next_page > $num_of_pages)
137
+ $next_page = $num_of_pages;
 
138
 
139
+ $prev_page = (int) $paged - 1;
 
 
 
140
 
141
+ if ($prev_page < 1)
142
+ $prev_page = 1;
 
 
 
143
 
144
+ //Query for post
145
+ $post_arr = array(
146
+ 'post_type' => 'qsm_quiz',
147
+ 'posts_per_page' => -1,
148
+ 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private')
149
+ );
150
+ //Check user role and fetch the quiz
151
+ $user = wp_get_current_user();
152
+ if (in_array('author', (array) $user->roles)) {
153
+ $post_arr['author__in'] = [$user->ID];
154
+ }
155
+ if (isset($_GET['order']) && $_GET['order'] == 'asc') {
156
+ $post_arr['orderby'] = isset($_GET['orderby']) && $_GET['orderby'] == 'title' ? 'title' : 'last_activity';
157
+ $post_arr['order'] = 'ASC';
158
+ // Load our quizzes.
159
+ $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, $post_arr['orderby'], 'ASC', (array) $user->roles, $user->ID, $limit, $offset, $where);
160
+ } else if (isset($_GET['order']) && $_GET['order'] == 'desc') {
161
+ $post_arr['orderby'] = isset($_GET['orderby']) && $_GET['orderby'] == 'title' ? 'title' : 'last_activity';
162
+ $post_arr['order'] = 'DESC';
163
+ // Load our quizzes.
164
+ $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, $post_arr['orderby'], 'DESC', (array) $user->roles, $user->ID, $limit, $offset, $where);
165
+ } else {
166
+ // Load our quizzes.
167
+ $quizzes = $mlwQuizMasterNext->pluginHelper->get_quizzes(false, '', '', (array) $user->roles, $user->ID, $limit, $offset, $where);
168
+ }
169
 
170
+ // Load quiz posts.
171
+ $post_to_quiz_array = array();
172
+ $my_query = new WP_Query($post_arr);
 
 
 
173
 
174
+ if ($my_query->have_posts()) {
175
+ while ($my_query->have_posts()) {
176
+ $my_query->the_post();
177
+ $post_to_quiz_array[get_post_meta(get_the_ID(), 'quiz_id', true)] = array(
178
+ 'link' => get_the_permalink(get_the_ID()),
179
+ 'id' => get_the_ID(),
180
+ 'post_status' => get_post_status(get_the_ID()),
181
+ );
182
+ }
183
+ }
184
+ wp_reset_postdata();
185
+ $quiz_json_array = array();
186
+ foreach ($quizzes as $quiz) {
187
+ if (!isset($post_to_quiz_array[$quiz->quiz_id])) {
188
+ $current_user = wp_get_current_user();
189
+ $quiz_post = array(
190
+ 'post_title' => $quiz->quiz_name,
191
+ 'post_content' => "[qsm quiz={$quiz->quiz_id}]",
192
+ //'post_status' => 'publish',
193
+ 'post_author' => $current_user->ID,
194
+ 'post_type' => 'qsm_quiz',
195
+ );
196
+ $quiz_post_id = wp_insert_post($quiz_post);
197
+ add_post_meta($quiz_post_id, 'quiz_id', $quiz->quiz_id);
198
+ $post_to_quiz_array[$quiz->quiz_id] = array(
199
+ 'link' => get_permalink($quiz_post_id),
200
+ 'id' => $quiz_post_id,
201
+ 'post_status' => get_post_status($quiz_post_id),
202
+ );
 
 
 
 
 
 
 
 
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
+ $activity_date = date_i18n(get_option('date_format'), strtotime($quiz->last_activity));
206
+ $activity_time = date('h:i:s A', strtotime($quiz->last_activity));
207
+ $quiz_json_array[] = array(
208
+ 'id' => $quiz->quiz_id,
209
+ 'name' => esc_html($quiz->quiz_name),
210
+ 'link' => $post_to_quiz_array[$quiz->quiz_id]['link'],
211
+ 'postID' => $post_to_quiz_array[$quiz->quiz_id]['id'],
212
+ 'views' => $quiz->quiz_views,
213
+ 'taken' => $quiz->quiz_taken,
214
+ 'lastActivity' => $activity_date,
215
+ 'lastActivityDateTime' => $activity_date . ' ' . $activity_time,
216
+ 'post_status' => $post_to_quiz_array[$quiz->quiz_id]['post_status'],
217
+ );
218
+ }
219
+ $total_count = count($quiz_json_array);
220
+ wp_localize_script('qsm_admin_script', 'qsmQuizObject', $quiz_json_array);
221
+ ?>
222
+ <div class="wrap qsm-quizes-page">
223
+ <h1>
224
+ <?php esc_html_e('Quizzes/Surveys', 'quiz-master-next'); ?>
225
+ <a id="new_quiz_button" href="#" class="add-new-h2"><?php _e('Add New', 'quiz-master-next'); ?></a>
226
+ </h1>
227
+ <?php $mlwQuizMasterNext->alertManager->showAlerts(); ?>
228
+ <?php
229
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
230
+ ?>
231
+ <div class="qsm-info-box">
232
+ <p>Your site is using PHP version <?php echo esc_html(PHP_VERSION); ?>! Starting in QSM 6.0, your version of PHP will no longer be supported. <a href="http://bit.ly/2lyrrm8" target="_blank">Click here to learn more about QSM's minimum PHP version change.</a></p>
233
+ </div>
234
+ <?php
235
+ }
236
+ ?>
237
+ <form method="POST" id="posts-filter">
238
+ <?php wp_nonce_field('qsm_search_multiple_delete', 'qsm_search_multiple_delete_nonce'); ?>
239
+ <div class="qsm-quizzes-page-content">
240
+ <div class="<?php
241
+ if ('false' != get_option('mlw_advert_shows')) {
242
+ echo 'qsm-quiz-page-wrapper-with-ads';
243
+ } else {
244
+ echo 'qsm-quiz-page-wrapper';
245
+ }
246
+ ?>">
247
+ <p class="search-box">
248
+ <label class="screen-reader-text" for="quiz_search"><?php esc_html_e('Search', 'quiz-master-next'); ?></label>
249
+ <input type="search" id="quiz_search" name="s" value="<?php echo isset($_REQUEST['s']) && $_REQUEST['s'] != '' ? $_REQUEST['s'] : ''; ?>">
250
+ <input id="search-submit" class="button" type="submit" name="btnSearchQuiz" value="Search Quiz">
251
+ <?php if (class_exists('QSM_Export_Import')) { ?>
252
+ <a class="button button-primary" href="<?php echo admin_url() . 'admin.php?page=qmn_addons&tab=export-and-import'; ?>" target="_blank"><?php _e('Import & Export', 'quiz-master-next'); ?></a>
253
+ <?php } else { ?>
254
+ <a id="show_import_export_popup" href="#" style="position: relative;top: 0px;" class="add-new-h2 button-primary"><?php _e('Import & Export', 'quiz-master-next'); ?></a>
255
+ <?php } ?>
256
+ </p>
257
+ <div class="tablenav top">
258
+ <div class="alignleft actions bulkactions">
259
+ <select name="qsm-ql-action-top">
260
+ <option selected="selected" value="none"><?php _e('Bulk Actions', 'quiz-master-next'); ?></option>
261
+ <option value="delete_pr"><?php _e('Delete Permanently', 'quiz-master-next'); ?></option>
262
+ </select>
263
+ <input id="take_action" name="take_action" class="button action" type="submit" value="<?php esc_attr_e('Apply', 'quiz-master-next'); ?>" >
264
+ </div>
265
+ <div class="tablenav-pages">
266
+ <span class="displaying-num"><?php echo number_format_i18n($total) . ' ' . sprintf(_n('item', 'items', $total), number_format_i18n($total)); ?></span>
267
+ <span class="pagination-links" <?php
268
+ if ((int) $num_of_pages <= 1) {
269
+ echo 'style="display:none;"';
270
+ }
271
+ ?>>
272
+ <?php if ($paged == '1') { ?>
273
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&laquo;</span>
274
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&lsaquo;</span>
275
+ <?php } else { ?>
276
+ <a class="first-page button" href="<?php echo '?page=mlw_quiz_list&paged=1&s=' . $search; ?>" title="<?php esc_attr_e('Go to the first page', 'quiz-master-next'); ?>">&laquo;</a>
277
+ <a class="prev-page button" href="<?php echo '?page=mlw_quiz_list&paged=' . $prev_page . '&s=' . $search; ?>" title="<?php esc_attr_e('Go to the previous page', 'quiz-master-next'); ?>">&lsaquo;</a>
278
+ <?php } ?>
279
+ <span class="paging-input">
280
+ <span class="total-pages"><?php echo $paged; ?></span>
281
+ <?php _e('of', 'quiz-master-next'); ?>
282
+ <span class="total-pages"><?php echo $num_of_pages; ?></span>
283
+ </span>
284
+ <?php if ($paged == $num_of_pages) { ?>
285
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&rsaquo;</span>
286
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&raquo;</span>
287
+ <?php } else { ?>
288
+ <a class="next-page button" href="<?php echo '?page=mlw_quiz_list&paged=' . $next_page . '&s=' . $search; ?>" title="<?php esc_attr_e('Go to the next page', 'quiz-master-next'); ?>">&rsaquo;</a>
289
+ <a class="last-page button" href="<?php echo '?page=mlw_quiz_list&paged=' . $num_of_pages . '&s=' . $search; ?>" title="<?php esc_attr_e('Go to the last page', 'quiz-master-next'); ?>">&raquo;</a>
290
+ <?php } ?>
291
+ </span>
292
+ </div>
293
+ </div>
294
+ <table class="widefat">
295
+ <?php
296
+ $orderby_slug = '&orderby=title&order=asc';
297
+ $orderby_date_slug = '&orderby=date&order=asc';
298
+ $orderby_class = $orderby_date_class = 'sortable desc';
299
+ //Title order
300
+ if (isset($_GET['orderby']) && $_GET['orderby'] === 'title') {
301
+ if (isset($_GET['order']) && $_GET['order'] === 'asc') {
302
+ $orderby_slug = '&orderby=title&order=desc';
303
+ $orderby_class = 'sorted asc';
304
+ } else if (isset($_GET['order']) && $_GET['order'] === 'desc') {
305
+ $orderby_slug = '&orderby=title&order=asc';
306
+ $orderby_class = 'sorted desc';
307
+ }
308
+ } else if (isset($_GET['orderby']) && $_GET['orderby'] === 'date') {
309
+ if (isset($_GET['order']) && $_GET['order'] === 'asc') {
310
+ $orderby_date_slug = '&orderby=date&order=desc';
311
+ $orderby_date_class = 'sorted asc';
312
+ } else if (isset($_GET['order']) && $_GET['order'] === 'desc') {
313
+ $orderby_date_slug = '&orderby=date&order=asc';
314
+ $orderby_date_class = 'sorted desc';
315
+ }
316
+ }
317
+ ?>
318
+ <thead>
319
+ <tr>
320
+ <td class="manage-column column-cb check-column" id="cb"><input type="checkbox" name="delete-all-shortcodes-1" id="delete-all-shortcodes-1" value="0"></td>
321
+ <th class="<?php echo $orderby_class; ?>">
322
+ <?php
323
+ $paged_slug = isset($_GET['paged']) && $_GET['paged'] != '' ? '&paged=' . $_GET['paged'] : '';
324
+ $searched_slug = isset($_GET['s']) && $_GET['s'] != '&s=' ? $_GET['s'] : '';
325
+ $sorting_url = '?page=mlw_quiz_list' . $paged_slug . $searched_slug;
326
+ ?>
327
+ <a href="<?php echo $sorting_url . $orderby_slug; ?>">
328
+ <span><?php esc_html_e('Title', 'quiz-master-next'); ?></span>
329
+ <span class="sorting-indicator"></span>
330
+ </a>
331
+ </th>
332
+ <th><?php esc_html_e('Shortcode', 'quiz-master-next'); ?></th>
333
+ <th><?php esc_html_e('Views', 'quiz-master-next'); ?></th>
334
+ <th><?php esc_html_e('Participants', 'quiz-master-next'); ?></th>
335
+ <th class="<?php echo $orderby_date_class; ?>">
336
+ <a href="<?php echo $sorting_url . $orderby_date_slug; ?>">
337
+ <span><?php esc_html_e('Last Modified', 'quiz-master-next'); ?></span>
338
+ <span class="sorting-indicator"></span>
339
+ </a>
340
+ </th>
341
+ </tr>
342
+ </thead>
343
+ <tbody id="the-list">
344
+ <?php
345
+ if($quiz_json_array){
346
+ foreach ($quiz_json_array as $key => $single_arr) { ?>
347
+ <tr class="qsm-quiz-row" data-id="<?php echo $single_arr['id']; ?>">
348
+ <th class="check-column">
349
+ <input type="checkbox" class="chk_remove_all" name="chk_remove_all[]" id="chk_remove_all" value="<?php echo $single_arr['id']; ?>">
350
+ </th>
351
+ <td class="post-title column-title">
352
+ <a class="row-title" href="admin.php?page=mlw_quiz_options&&quiz_id=<?php echo $single_arr['id']; ?>" aria-label="<?php echo $single_arr['name']; ?>">
353
+ <?php echo $single_arr['name']; ?> <b style="color: #222; text-transform: capitalize;"><?php echo $single_arr['post_status'] != 'publish' ? '— ' . $single_arr['post_status'] : ''; ?></b>
354
+ </a>
355
+ <div class="row-actions">
356
+ <a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&&quiz_id=<?php echo $single_arr['id']; ?>"><?php _e('Edit', 'quiz-master-next'); ?></a> |
357
+ <a class="qsm-action-link qsm-action-link-duplicate" href="#"><?php _e('Duplicate', 'quiz-master-next'); ?></a> |
358
+ <a class="qsm-action-link qsm-action-link-delete" href="#"><?php _e('Delete', 'quiz-master-next'); ?></a> |
359
+ <a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&quiz_id=<?php echo $single_arr['id']; ?>"><?php _e('View Results', 'quiz-master-next'); ?></a> |
360
+ <a class="qsm-action-link" target="_blank" href="<?php echo $single_arr['link']; ?>"><?php _e('Preview', 'quiz-master-next'); ?></a>
361
+ </div>
362
+ </td>
363
+ <td>
364
+ <a href="#" class="qsm-list-shortcode-view">
365
+ <span class="dashicons dashicons-welcome-view-site"></span>
366
+ </a>
367
+ <div class="sc-content sc-embed">[qsm quiz=<?php echo $single_arr['id']; ?>]</div>
368
+ <div class="sc-content sc-link">[qsm_link id=<?php echo $single_arr['id']; ?>]<?php _e('Click here', 'quiz-master-next'); ?>[/qsm_link]</div>
369
+ </td>
370
+ <td>
371
+ <?php echo $single_arr['views']; ?>
372
+ <div class="row-actions">
373
+ <a class="qsm-action-link qsm-action-link-reset" href="#"><?php _e('Reset', 'quiz-master-next'); ?></a>
374
+ </div>
375
+ </td>
376
+ <td class="comments column-comments" style="text-align: left;">
377
+ <span class="post-com-count post-com-count-approved">
378
+ <span class="comment-count-approved" aria-hidden="true"><?php echo $single_arr['taken']; ?></span>
379
+ <span class="screen-reader-text"><?php echo $single_arr['taken'] . __('Participants','quiz-master-next'); ?> </span>
380
+ </span>
381
+ </td>
382
+ <td>
383
+ <abbr title="<?php echo $single_arr['lastActivityDateTime']; ?>"><?php echo $single_arr['lastActivity']; ?></abbr>
384
+ </td>
385
+ </tr>
386
+ <?php
387
+ }
388
+ }else{ ?>
389
+ <tr>
390
+ <td colspan="6" style="text-align: center;">
391
+ <?php _e('No Quiz found!', 'quiz-master-next'); ?>
392
+ </td>
393
+ </tr>
394
+ <?php
395
+ }
396
+ ?>
397
+ </tbody>
398
+ <tfoot>
399
+ <tr>
400
+ <td class="manage-column column-cb check-column" id="cb"><input type="checkbox" name="delete-all-shortcodes-2" id="delete-all-shortcodes-2" value="0"></td>
401
+ <th class="<?php echo $orderby_class; ?>">
402
+ <a href="<?php echo $sorting_url . $orderby_slug; ?>">
403
+ <span><?php esc_html_e('Title', 'quiz-master-next'); ?></span>
404
+ <span class="sorting-indicator"></span>
405
+ </a>
406
+ </th>
407
+ <th><?php esc_html_e('Shortcode', 'quiz-master-next'); ?></th>
408
+ <th><?php esc_html_e('Views', 'quiz-master-next'); ?></th>
409
+ <th><?php esc_html_e('Participants', 'quiz-master-next'); ?></th>
410
+ <th class="<?php echo $orderby_date_class; ?>">
411
+ <a href="<?php echo $sorting_url . $orderby_date_slug; ?>">
412
+ <span><?php esc_html_e('Last Modified', 'quiz-master-next'); ?></span>
413
+ <span class="sorting-indicator"></span>
414
+ </a>
415
+ </th>
416
+ </tr>
417
+ </tfoot>
418
+ </table>
419
+ <div class="tablenav bottom">
420
+ <select name="qsm-ql-action-bottom">
421
+ <option selected="selected" value="none"><?php _e('Bulk Actions', 'quiz-master-next'); ?></option>
422
+ <option value="delete_pr"><?php _e('Delete Permanently', 'quiz-master-next'); ?></option>
423
+ </select>
424
+ <input id="take_action" name="take_action" class="button action" type="submit" value="<?php esc_attr_e('Apply', 'quiz-master-next'); ?>" >
425
+ <div class="tablenav-pages">
426
+ <span class="displaying-num"><?php echo number_format_i18n($total) . ' ' . sprintf(_n('item', 'items', $total), number_format_i18n($total)); ?></span>
427
+ <span class="pagination-links" <?php
428
+ if ((int) $num_of_pages <= 1) {
429
+ echo 'style="display:none;"';
430
+ }
431
+ ?>>
432
+ <?php if ($paged == '1') { ?>
433
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&laquo;</span>
434
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&lsaquo;</span>
435
+ <?php } else { ?>
436
+ <a class="first-page button" href="<?php echo '?page=mlw_quiz_list&paged=1&s=' . $search; ?>" title="<?php esc_attr_e('Go to the first page', 'quiz-master-next'); ?>">&laquo;</a>
437
+ <a class="prev-page button" href="<?php echo '?page=mlw_quiz_list&paged=' . $prev_page . '&s=' . $search; ?>" title="<?php esc_attr_e('Go to the previous page', 'quiz-master-next'); ?>">&lsaquo;</a>
438
+ <?php } ?>
439
+ <span class="paging-input">
440
+ <span class="total-pages"><?php echo $paged; ?></span>
441
+ <?php _e('of', 'quiz-master-next'); ?>
442
+ <span class="total-pages"><?php echo $num_of_pages; ?></span>
443
+ </span>
444
+ <?php if ($paged == $num_of_pages) { ?>
445
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&rsaquo;</span>
446
+ <span class="tablenav-pages-navspan button disabled" aria-hidden="true">&raquo;</span>
447
+ <?php } else { ?>
448
+ <a class="next-page button" href="<?php echo '?page=mlw_quiz_list&paged=' . $next_page . '&s=' . $search; ?>" title="<?php esc_attr_e('Go to the next page', 'quiz-master-next'); ?>">&rsaquo;</a>
449
+ <a class="last-page button" href="<?php echo '?page=mlw_quiz_list&paged=' . $num_of_pages . '&s=' . $search; ?>" title="<?php esc_attr_e('Go to the last page', 'quiz-master-next'); ?>">&raquo;</a>
450
+ <?php } ?>
451
+ </span>
452
+ </div>
453
+ </div>
454
+ </div>
455
+ </div>
456
+ </form>
457
 
458
+ <!-- Popup for resetting stats -->
459
+ <div class="qsm-popup qsm-popup-slide" id="modal-1" aria-hidden="true">
460
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
461
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-1-title">
462
+ <header class="qsm-popup__header">
463
+ <h2 class="qsm-popup__title" id="modal-1-title">Reset stats for this quiz?</h2>
464
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
465
+ </header>
466
+ <main class="qsm-popup__content" id="modal-1-content">
467
+ <p><?php _e('Are you sure you want to reset the stats to 0? All views and taken stats for this quiz will be reset. This is permanent and cannot be undone.', 'quiz-master-next'); ?></p>
468
+ <form action="" method="post" id="reset_quiz_form">
469
+ <?php wp_nonce_field('qsm_reset_stats', 'qsm_reset_stats_nonce'); ?>
470
+ <input type="hidden" id="reset_quiz_id" name="reset_quiz_id" value="0" />
471
+ </form>
472
+ </main>
473
+ <footer class="qsm-popup__footer">
474
+ <button id="reset-stats-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Reset All Stats For Quiz', 'quiz-master-next'); ?></button>
475
+ <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
476
+ </footer>
477
+ </div>
478
+ </div>
479
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
 
481
+ <!-- Popup for new quiz -->
482
+ <?php echo qsm_create_new_quiz_wizard(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
 
484
+ <!-- Popup for duplicate quiz -->
485
+ <div class="qsm-popup qsm-popup-slide" id="modal-4" aria-hidden="true">
486
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
487
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-4-title">
488
+ <header class="qsm-popup__header">
489
+ <h2 class="qsm-popup__title" id="modal-4-title"><?php _e('Duplicate', 'quiz-master-next'); ?></h2>
490
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
491
+ </header>
492
+ <main class="qsm-popup__content" id="modal-4-content">
493
+ <form action='' method='post' id="duplicate-quiz-form">
494
+ <label for="duplicate_questions"><?php _e('Duplicate questions also?', 'quiz-master-next'); ?></label><input type="checkbox" name="duplicate_questions" id="duplicate_questions"/><br />
495
+ <br />
496
+ <label for="duplicate_new_quiz_name"><?php _e('Name Of New Quiz Or Survey:', 'quiz-master-next'); ?></label><input type="text" id="duplicate_new_quiz_name" name="duplicate_new_quiz_name" />
497
+ <input type="hidden" id="duplicate_quiz_id" name="duplicate_quiz_id" />
498
+ <?php wp_nonce_field('qsm_duplicate_quiz', 'qsm_duplicate_quiz_nonce'); ?>
499
+ </form>
500
+ </main>
501
+ <footer class="qsm-popup__footer">
502
+ <button id="duplicate-quiz-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Duplicate', 'quiz-master-next'); ?></button>
503
+ <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
504
+ </footer>
505
+ </div>
506
+ </div>
507
+ </div>
508
 
509
+ <!-- Popup for delete quiz -->
510
+ <div class="qsm-popup qsm-popup-slide" id="modal-5" aria-hidden="true">
511
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
512
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-5-title">
513
+ <header class="qsm-popup__header">
514
+ <h2 class="qsm-popup__title" id="modal-5-title"><?php _e('Delete', 'quiz-master-next'); ?></h2>
515
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
516
+ </header>
517
+ <main class="qsm-popup__content" id="modal-5-content">
518
+ <form action='' method='post' id="delete-quiz-form">
519
+ <h3><b><?php _e('Are you sure you want to delete this quiz or survey?', 'quiz-master-next'); ?></b></h3>
520
+ <?php wp_nonce_field('qsm_delete_quiz', 'qsm_delete_quiz_nonce'); ?>
521
+ <input type='hidden' id='delete_quiz_id' name='delete_quiz_id' value='' />
522
+ <input type='hidden' id='delete_quiz_name' name='delete_quiz_name' value='' />
523
+ </form>
524
+ </main>
525
+ <footer class="qsm-popup__footer">
526
+ <button id="delete-quiz-button" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Delete', 'quiz-master-next'); ?></button>
527
+ <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
528
+ </footer>
529
+ </div>
530
+ </div>
531
+ </div>
532
 
533
+ <!-- Popup for export import upsell -->
534
+ <div class="qsm-popup qsm-popup-slide" id="modal-export-import" aria-hidden="true">
535
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
536
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-5-title">
537
+ <header class="qsm-popup__header">
538
+ <h2 class="qsm-popup__title" id="modal-5-title"><?php _e('Extend QSM', 'quiz-master-next'); ?></h2>
539
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
540
+ </header>
541
+ <main class="qsm-popup__content" id="modal-5-content">
542
+ <h3><b><?php _e('Export functionality is provided as Premium addon.', 'quiz-master-next'); ?></b></h3>
543
+ </main>
544
+ <footer class="qsm-popup__footer">
545
+ <a style="color: white; text-decoration: none;" href="https://quizandsurveymaster.com/downloads/export-import/" target="_blank" class="qsm-popup__btn qsm-popup__btn-primary"><?php _e('Buy Now', 'quiz-master-next'); ?></a>
546
+ <button class="qsm-popup__btn" data-micromodal-close aria-label="Close this dialog window"><?php _e('Cancel', 'quiz-master-next'); ?></button>
547
+ </footer>
548
+ </div>
549
+ </div>
550
+ </div>
 
 
 
 
 
 
551
 
552
+ <!-- Popup for delete quiz -->
553
+ <div class="qsm-popup qsm-popup-slide" id="modal-6" aria-hidden="true">
554
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close>
555
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-5-title">
556
+ <header class="qsm-popup__header">
557
+ <h2 class="qsm-popup__title" id="modal-5-title"><?php _e('Shortcode', 'quiz-master-next'); ?></h2>
558
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close></a>
559
+ </header>
560
+ <main class="qsm-popup__content" id="modal-5-content">
561
+ <div class="qsm-row" style="margin-bottom: 30px;">
562
+ <lable><?php _e('Embed Shortcode','quiz-master-next'); ?></lable>
563
+ <input type="text" value="" id="sc-shortcode-model-text" style="width: 72%;padding: 5px;">
564
+ <button class="button button-primary" id="sc-copy-shortcode"><span class="dashicons dashicons-admin-page"></span></button>
565
+ </div>
566
+ <div class="qsm-row">
567
+ <lable><?php _e('Link Shortcode','quiz-master-next'); ?></lable>
568
+ <input type="text" value="" id="sc-shortcode-model-text-link" style="width: 72%;padding: 5px;">
569
+ <button class="button button-primary" id="sc-copy-shortcode-link"><span class="dashicons dashicons-admin-page"></span></button>
570
+ </div>
571
+ </main>
572
+ </div>
573
+ </div>
574
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
 
576
+ <!-- Templates -->
577
+ <script type="text/template" id="tmpl-no-quiz">
578
+ <div class="qsm-no-quiz-wrapper">
579
+ <span class="dashicons dashicons-format-chat"></span>
580
+ <h2><?php _e('You do not have any quizzes or surveys yet', 'quiz-master-next'); ?></h2>
581
+ <div class="buttons">
582
+ <a class="button button-primary button-hero qsm-wizard-noquiz" href="#"><?php _e('Create New Quiz/Survey', 'quiz-master-next'); ?></a>
583
+ <a class="button button-secondary button-hero" href="https://quizandsurveymaster.com/docs/" target="_blank"><span class="dashicons dashicons-admin-page"></span> <?php _e('Read Documentation', 'quiz-master-next'); ?></a>
584
+ </div>
585
+ <h3><?php _e('or watch the below video to get started', 'quiz-master-next'); ?></h3>
586
+ <iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/coE5W_WB-48" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
587
+ </div>
588
+ </script>
 
 
589
 
590
+ <script type="text/template" id="tmpl-quiz-row">
591
+ <tr class="qsm-quiz-row" data-id="{{ data.id }}">
592
+ <td class="post-title column-title">
593
+ <a class="row-title" href="admin.php?page=mlw_quiz_options&&quiz_id={{ data.id }}" aria-label="{{ data.name }}">{{ data.name }} <b style="color: #222; text-transform: capitalize;">{{ data.post_status }}</b></a><a target="_blank" class="quiz-preview-link" href="{{ data.link }}"><span class="dashicons dashicons-external"></span></a>
594
+ <div class="row-actions">
595
+ <a class="qsm-action-link" href="admin.php?page=mlw_quiz_options&&quiz_id={{ data.id }}"><?php _e('Edit', 'quiz-master-next'); ?></a> |
596
+ <a class="qsm-action-link" href="post.php?post={{ data.postID }}&action=edit"><?php _e('Post Settings', 'quiz-master-next'); ?></a> |
597
+ <a class="qsm-action-link qsm-action-link-duplicate" href="#"><?php _e('Duplicate', 'quiz-master-next'); ?></a> |
598
+ <a class="qsm-action-link qsm-action-link-delete" href="#"><?php _e('Delete', 'quiz-master-next'); ?></a> |
599
+ <a class="qsm-action-link" target="_blank" href="{{ data.link }}"><?php _e('Preview', 'quiz-master-next'); ?></a>
600
+ </div>
601
+ </td>
602
+ <td>
603
+ <p class="sc-opener"><span class="dashicons dashicons-editor-contract"></span> Embed</p>
604
+ <div class="sc-content">[qsm quiz={{ data.id }}]</div>
605
+ <p class="sc-opener"><span class="dashicons dashicons-admin-links"></span> Link</p>
606
+ <div class="sc-content">[qsm_link id={{ data.id }}]<?php _e('Click here', 'quiz-master-next'); ?>[/qsm_link]</div>
607
+ </td>
608
+ <td>
609
+ {{ data.views }}/{{ data.taken }}
610
+ <div class="row-actions">
611
+ <a class="qsm-action-link qsm-action-link-reset" href="#"><?php _e('Reset', 'quiz-master-next'); ?></a> |
612
+ <a class="qsm-action-link" href="admin.php?page=mlw_quiz_results&&quiz_id={{ data.id }}"><?php _e('Results', 'quiz-master-next'); ?></a>
613
+ </div>
614
+ </td>
615
+ <td><abbr title="{{ data.lastActivityDateTime }}">{{ data.lastActivity }}</abbr></td>
616
+ </tr>
617
+ </script>
618
+ </div>
619
+ <?php
620
+ }
621
 
622
+ /**
623
+ * @since 7.0
624
+ * add per page option in screen option in Quiz list
625
+ * @global string $qsm_quiz_list_page
626
+ */
627
+ function qsm_generate_quizzes_surveys_page_screen_options(){
628
+ global $qsm_quiz_list_page;
629
+ $screen = get_current_screen();
630
+
631
+ // get out of here if we are not on our settings page
632
+ if (!is_object($screen) || $screen->id != $qsm_quiz_list_page)
633
+ return;
634
+
635
+ $args = array(
636
+ 'label' => __('Number of items per page:', 'quiz-master-next'),
637
+ 'default' => 10,
638
+ 'option' => 'qsm_per_page'
639
+ );
640
+ add_screen_option('per_page', $args);
641
+ }
642
+
643
+ add_filter('set-screen-option', 'qsm_set_screen_option', 10, 3);
644
+ /**
645
+ * @since 7.0
646
+ * @param str $status
647
+ * @param arr $option
648
+ * @param str $value
649
+ * @return str Save screen option value
650
+ */
651
+ function qsm_set_screen_option( $status, $option, $value ){
652
+ if ('qsm_per_page' == $option)
653
+ return $value;
654
  }
655
  ?>
php/admin/settings-page.php CHANGED
@@ -52,6 +52,7 @@ class QMNGlobalSettingsPage {
52
  add_settings_field( 'facebook-app-id', __( 'Facebook App Id', 'quiz-master-next' ), array( $this, 'facebook_app_id' ), 'qmn_global_settings', 'qmn-global-section' );
53
  add_settings_field( 'from-name', __( 'From Name (The name emails come from)', 'quiz-master-next' ), array( $this, 'from_name' ), 'qmn_global_settings', 'qmn-global-section' );
54
  add_settings_field( 'from-email', __( 'From Email (The email address that emails come from)', 'quiz-master-next' ), array( $this, 'from_email' ), 'qmn_global_settings', 'qmn-global-section' );
 
55
  add_settings_field( 'results-details', __( 'Template For Admin Results Details', 'quiz-master-next' ), array( $this, 'results_details_template' ), 'qmn_global_settings', 'qmn-global-section' );
56
  }
57
 
@@ -289,6 +290,7 @@ class QMNGlobalSettingsPage {
289
  public static function display_page() {
290
  global $mlwQuizMasterNext;
291
  wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
 
292
  ?>
293
  <div class="wrap">
294
  <h2><?php _e( 'Global Settings', 'quiz-master-next' ); ?></h2>
@@ -300,6 +302,30 @@ class QMNGlobalSettingsPage {
300
  </div>
301
  <?php
302
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
 
305
  $qmnGlobalSettingsPage = new QMNGlobalSettingsPage();
52
  add_settings_field( 'facebook-app-id', __( 'Facebook App Id', 'quiz-master-next' ), array( $this, 'facebook_app_id' ), 'qmn_global_settings', 'qmn-global-section' );
53
  add_settings_field( 'from-name', __( 'From Name (The name emails come from)', 'quiz-master-next' ), array( $this, 'from_name' ), 'qmn_global_settings', 'qmn-global-section' );
54
  add_settings_field( 'from-email', __( 'From Email (The email address that emails come from)', 'quiz-master-next' ), array( $this, 'from_email' ), 'qmn_global_settings', 'qmn-global-section' );
55
+ add_settings_field( 'new-template-result-detail', __( 'New Template For Admin Results Details', 'quiz-master-next' ), array( $this, 'new_template_results_details' ), 'qmn_global_settings', 'qmn-global-section' );
56
  add_settings_field( 'results-details', __( 'Template For Admin Results Details', 'quiz-master-next' ), array( $this, 'results_details_template' ), 'qmn_global_settings', 'qmn-global-section' );
57
  }
58
 
290
  public static function display_page() {
291
  global $mlwQuizMasterNext;
292
  wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
293
+ wp_enqueue_script( 'qsm_admin_js', plugins_url( '../../js/admin.js', __FILE__ ), array( 'jquery' ), $mlwQuizMasterNext->version );
294
  ?>
295
  <div class="wrap">
296
  <h2><?php _e( 'Global Settings', 'quiz-master-next' ); ?></h2>
302
  </div>
303
  <?php
304
  }
305
+
306
+ /**
307
+ * Generates Setting Field For new template for result detail
308
+ *
309
+ * @since 7.0.0
310
+ * @return void
311
+ */
312
+ public function new_template_results_details()
313
+ {
314
+ $settings = (array) get_option( 'qmn-settings' );
315
+ $new_template_result_detail = '1';
316
+ if (isset($settings['new_template_result_detail'])){
317
+ $new_template_result_detail = esc_attr( $settings['new_template_result_detail'] );
318
+ }
319
+ echo '<label style="margin-bottom: 10px;display: inline-block;">';
320
+ echo "<input type='radio' name='qmn-settings[new_template_result_detail]' class='new_template_result_detail' value='1' ". checked($new_template_result_detail, '1', false) ."/>";
321
+ echo __('New Template', 'quiz-master-next');
322
+ echo '</label>';
323
+ echo '<br/>';
324
+ echo '<label>';
325
+ echo "<input type='radio' name='qmn-settings[new_template_result_detail]' class='new_template_result_detail' value='0' ". checked($new_template_result_detail, '0', false) ."/>";
326
+ echo __('Old Template', 'quiz-master-next');
327
+ echo '</label>';
328
+ }
329
  }
330
 
331
  $qmnGlobalSettingsPage = new QMNGlobalSettingsPage();
php/admin/stats-page.php CHANGED
@@ -86,9 +86,9 @@ function qmn_stats_overview_content()
86
  $labels = "";
87
  $value = "";
88
  foreach($data as $stat) {
89
- $labels .= '"",' ;
90
  $value .= "$stat,";
91
- }
92
  ?>
93
  <style>
94
  .postbox:after {
@@ -129,15 +129,29 @@ function qmn_stats_overview_content()
129
  pointStrokeColor : "#fff",
130
  pointHighlightFill : "#fff",
131
  pointHighlightStroke : "rgba(220,220,220,1)",
132
- data : [<?php echo $value; ?>]
133
  }
134
  ]
135
  }
136
  window.onload = function(){
137
  var graph_ctx = document.getElementById("graph_canvas").getContext("2d");
138
- window.stats_graph = new Chart(graph_ctx).Line(graph_data, {
139
- responsive: true
140
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
  </script>
143
  </div>
86
  $labels = "";
87
  $value = "";
88
  foreach($data as $stat) {
89
+ $labels .= '"",';
90
  $value .= "$stat,";
91
+ }
92
  ?>
93
  <style>
94
  .postbox:after {
129
  pointStrokeColor : "#fff",
130
  pointHighlightFill : "#fff",
131
  pointHighlightStroke : "rgba(220,220,220,1)",
132
+ data : [3,0,2,24,0,27,7]
133
  }
134
  ]
135
  }
136
  window.onload = function(){
137
  var graph_ctx = document.getElementById("graph_canvas").getContext("2d");
138
+ window.stats_graph = new Chart(graph_ctx, {
139
+ type: 'line',
140
+ data: {
141
+ labels: [<?php echo $labels; ?>],
142
+ datasets: [{
143
+ label: 'Quiz Submissions', // Name the series
144
+ data: [<?php echo $value; ?>], // Specify the data values array
145
+ fill: false,
146
+ borderColor: '#2196f3', // Add custom color border (Line)
147
+ backgroundColor: '#2196f3', // Add custom color background (Points and Fill)
148
+ borderWidth: 1 // Specify bar border width
149
+ }]},
150
+ options: {
151
+ responsive: true, // Instruct chart js to respond nicely.
152
+ maintainAspectRatio: false, // Add to prevent default behaviour of full-width/height
153
+ }
154
+ });
155
  }
156
  </script>
157
  </div>
php/classes/class-qmn-background-process.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Abstract WP_Async_Request class.
4
+ *
5
+ * Uses https://github.com/A5hleyRich/wp-background-processing
6
+ * updates in the background.
7
+ *
8
+ * @since 7.0
9
+ */
10
+
11
+ defined('ABSPATH') || exit;
12
+
13
+ if (!class_exists('WP_Async_Request', false)) {
14
+ include_once dirname(QSM_SUBMENU) . '/php/classes/lib/wp-async-request.php';
15
+ }
16
+
17
+ if (!class_exists('WP_Background_Process', false)) {
18
+ include_once dirname(QSM_SUBMENU) . '/php/classes/lib/wp-background-process.php';
19
+ }
20
+
21
+ class QSM_Background_Request extends WP_Async_Request {
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $action = 'qsm_email_request';
27
+
28
+ /**
29
+ * Handle
30
+ *
31
+ * Override this method to perform any actions required
32
+ * during the async request.
33
+ */
34
+ protected function handle() {
35
+ $message = $_POST['name'];
36
+ if ($message == 'send_emails') {
37
+ $qmn_array_for_variables = isset( $_POST['variables'] ) ? $_POST['variables'] : array();
38
+ try {
39
+ $this->really_long_running_task();
40
+ QSM_Emails::send_emails($qmn_array_for_variables);
41
+ } catch (Exception $e) {
42
+ if (defined('WP_DEBUG') && WP_DEBUG) {
43
+ trigger_error('Background email triggered fatal error for callback.', E_USER_WARNING);
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Really long running process
51
+ *
52
+ * @return int
53
+ */
54
+ public function really_long_running_task() {
55
+ return sleep(5);
56
+ }
57
+
58
+ }
php/classes/class-qmn-plugin-helper.php CHANGED
@@ -111,7 +111,7 @@ class QMNPluginHelper {
111
  * @param int $user_id Get the quiz based on user id
112
  * @return array All of the quizzes as a numerical array of objects
113
  */
114
- public function get_quizzes( $include_deleted = false, $order_by = 'quiz_id', $order = 'DESC', $user_role = array(), $user_id = '' ) {
115
  global $wpdb;
116
 
117
  // Set order direction
@@ -145,6 +145,9 @@ class QMNPluginHelper {
145
 
146
  // Should we include deleted?
147
  $delete = "WHERE deleted='0'";
 
 
 
148
  if ( $include_deleted ) {
149
  $delete = '';
150
  }
@@ -156,9 +159,18 @@ class QMNPluginHelper {
156
  $user_str = " AND quiz_author_id = '$user_id'";
157
  }
158
  }
159
-
 
 
 
 
 
 
 
 
 
160
  // Get quizzes and return them
161
- $quizzes = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}mlw_quizzes $delete $user_str ORDER BY $order_field $order_direction" );
162
  return $quizzes;
163
  }
164
 
@@ -215,15 +227,19 @@ class QMNPluginHelper {
215
  }
216
 
217
  /**
218
- * Outputs the section of input fields
219
- *
220
- * @since 5.0.0
221
- * @param string $section The section that the settings were registered with
222
- */
223
- public function generate_settings_section( $section = 'quiz_options' ) {
224
- global $mlwQuizMasterNext;
225
- QSM_Fields::generate_section( $mlwQuizMasterNext->quiz_settings->load_setting_fields( $section ), $section );
226
- }
 
 
 
 
227
 
228
  /**
229
  * Registers Quiz Templates
111
  * @param int $user_id Get the quiz based on user id
112
  * @return array All of the quizzes as a numerical array of objects
113
  */
114
+ public function get_quizzes( $include_deleted = false, $order_by = 'quiz_id', $order = 'DESC', $user_role = array(), $user_id = '', $limit = '', $offset = '', $where = '' ) {
115
  global $wpdb;
116
 
117
  // Set order direction
145
 
146
  // Should we include deleted?
147
  $delete = "WHERE deleted='0'";
148
+ if( $where != '' ){
149
+ $delete = $delete . ' AND ' . $where;
150
+ }
151
  if ( $include_deleted ) {
152
  $delete = '';
153
  }
159
  $user_str = " AND quiz_author_id = '$user_id'";
160
  }
161
  }
162
+ if( $where != '' && $user_str != '' ){
163
+ $user_str = $user_str . ' AND ' . $where;
164
+ }
165
+ $where_str = '';
166
+ if( $user_str == '' && $delete === '' && $where != '' ){
167
+ $where_str = "WHERE $where";
168
+ }
169
+ if($limit != ''){
170
+ $limit = ' limit ' . $offset . ', ' . $limit;
171
+ }
172
  // Get quizzes and return them
173
+ $quizzes = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}mlw_quizzes $delete $user_str $where_str ORDER BY $order_field $order_direction $limit" );
174
  return $quizzes;
175
  }
176
 
227
  }
228
 
229
  /**
230
+ * Outputs the section of input fields
231
+ *
232
+ * @since 5.0.0
233
+ * @since 7.0 Added new parameter settings_fields for default setting
234
+ * @param string $section The section that the settings were registered with
235
+ */
236
+ public function generate_settings_section( $section = 'quiz_options', $settings_fields = array() ) {
237
+ global $mlwQuizMasterNext;
238
+ if( empty( $settings_fields ) ){
239
+ $settings_fields = $mlwQuizMasterNext->quiz_settings->load_setting_fields( $section );
240
+ }
241
+ QSM_Fields::generate_section( $settings_fields, $section );
242
+ }
243
 
244
  /**
245
  * Registers Quiz Templates
php/classes/class-qmn-quiz-creator.php CHANGED
@@ -28,8 +28,8 @@ class QMNQuizCreator {
28
  * @since 3.7.1
29
  */
30
  public function __construct() {
31
- if ( isset( $_GET['quiz_id'] ) ) {
32
- $this->quiz_id = intval( $_GET['quiz_id'] );
33
  }
34
  }
35
 
@@ -67,7 +67,7 @@ class QMNQuizCreator {
67
  * @param string $quiz_name The name of the new quiz.
68
  * @return void
69
  */
70
- public function create_quiz( $quiz_name ) {
71
  global $mlwQuizMasterNext;
72
  global $wpdb;
73
  $current_user = wp_get_current_user();
@@ -90,7 +90,7 @@ class QMNQuizCreator {
90
  'email_from_text' => 'Wordpress',
91
  'question_answer_template' => '%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />',
92
  'leaderboard_template' => '',
93
- 'system' => 0,
94
  'randomness_order' => 0,
95
  'loggedin_user_contact' => 0,
96
  'show_score' => 0,
@@ -114,7 +114,7 @@ class QMNQuizCreator {
114
  'timer_limit' => 0,
115
  'quiz_stye' => '',
116
  'question_numbering' => 0,
117
- 'quiz_settings' => '',
118
  'theme_selected' => 'primary',
119
  'last_activity' => current_time( 'mysql' ),
120
  'require_log_in' => 0,
@@ -321,10 +321,14 @@ class QMNQuizCreator {
321
  public function duplicate_quiz($quiz_id, $quiz_name, $is_duplicating_questions)
322
  {
323
  global $mlwQuizMasterNext;
324
- global $wpdb;
325
-
326
- $table_name = $wpdb->prefix . "mlw_quizzes";
327
  $mlw_qmn_duplicate_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE quiz_id=%d", $quiz_id ) );
 
 
 
 
328
  $results = $wpdb->insert(
329
  $table_name,
330
  array(
@@ -344,7 +348,7 @@ class QMNQuizCreator {
344
  'email_from_text' => $mlw_qmn_duplicate_data->email_from_text,
345
  'question_answer_template' => $mlw_qmn_duplicate_data->question_answer_template,
346
  'leaderboard_template' => $mlw_qmn_duplicate_data->leaderboard_template,
347
- 'system' => $mlw_qmn_duplicate_data->system,
348
  'randomness_order' => $mlw_qmn_duplicate_data->randomness_order,
349
  'loggedin_user_contact' => $mlw_qmn_duplicate_data->loggedin_user_contact,
350
  'show_score' => $mlw_qmn_duplicate_data->show_score,
@@ -368,7 +372,7 @@ class QMNQuizCreator {
368
  'timer_limit' => $mlw_qmn_duplicate_data->timer_limit,
369
  'quiz_stye' => $mlw_qmn_duplicate_data->quiz_stye,
370
  'question_numbering' => $mlw_qmn_duplicate_data->question_numbering,
371
- 'quiz_settings' => $mlw_qmn_duplicate_data->quiz_settings,
372
  'theme_selected' => $mlw_qmn_duplicate_data->theme_selected,
373
  'last_activity' => date("Y-m-d H:i:s"),
374
  'require_log_in' => $mlw_qmn_duplicate_data->require_log_in,
@@ -379,7 +383,8 @@ class QMNQuizCreator {
379
  'scheduled_timeframe_text' => $mlw_qmn_duplicate_data->scheduled_timeframe_text,
380
  'quiz_views' => 0,
381
  'quiz_taken' => 0,
382
- 'deleted' => 0
 
383
  ),
384
  array(
385
  '%s',
@@ -434,6 +439,7 @@ class QMNQuizCreator {
434
  '%d',
435
  '%d',
436
  '%d',
 
437
  )
438
  );
439
  $mlw_new_id = $wpdb->insert_id;
28
  * @since 3.7.1
29
  */
30
  public function __construct() {
31
+ if ( isset( $_REQUEST['quiz_id'] ) ) {
32
+ $this->quiz_id = intval( $_REQUEST['quiz_id'] );
33
  }
34
  }
35
 
67
  * @param string $quiz_name The name of the new quiz.
68
  * @return void
69
  */
70
+ public function create_quiz( $quiz_name, $quiz_settings = '' ) {
71
  global $mlwQuizMasterNext;
72
  global $wpdb;
73
  $current_user = wp_get_current_user();
90
  'email_from_text' => 'Wordpress',
91
  'question_answer_template' => '%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />',
92
  'leaderboard_template' => '',
93
+ 'quiz_system' => 0,
94
  'randomness_order' => 0,
95
  'loggedin_user_contact' => 0,
96
  'show_score' => 0,
114
  'timer_limit' => 0,
115
  'quiz_stye' => '',
116
  'question_numbering' => 0,
117
+ 'quiz_settings' => $quiz_settings,
118
  'theme_selected' => 'primary',
119
  'last_activity' => current_time( 'mysql' ),
120
  'require_log_in' => 0,
321
  public function duplicate_quiz($quiz_id, $quiz_name, $is_duplicating_questions)
322
  {
323
  global $mlwQuizMasterNext;
324
+ global $wpdb;
325
+ $current_user = wp_get_current_user();
326
+ $table_name = $wpdb->prefix . "mlw_quizzes";
327
  $mlw_qmn_duplicate_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE quiz_id=%d", $quiz_id ) );
328
+ $quiz_settings = unserialize( $mlw_qmn_duplicate_data->quiz_settings );
329
+ if( $is_duplicating_questions == 0 ){
330
+ $quiz_settings['pages'] = '';
331
+ }
332
  $results = $wpdb->insert(
333
  $table_name,
334
  array(
348
  'email_from_text' => $mlw_qmn_duplicate_data->email_from_text,
349
  'question_answer_template' => $mlw_qmn_duplicate_data->question_answer_template,
350
  'leaderboard_template' => $mlw_qmn_duplicate_data->leaderboard_template,
351
+ 'quiz_system' => isset( $mlw_qmn_duplicate_data->system ) ? $mlw_qmn_duplicate_data->system : isset( $mlw_qmn_duplicate_data->quiz_system ) ? $mlw_qmn_duplicate_data->quiz_system : 0,
352
  'randomness_order' => $mlw_qmn_duplicate_data->randomness_order,
353
  'loggedin_user_contact' => $mlw_qmn_duplicate_data->loggedin_user_contact,
354
  'show_score' => $mlw_qmn_duplicate_data->show_score,
372
  'timer_limit' => $mlw_qmn_duplicate_data->timer_limit,
373
  'quiz_stye' => $mlw_qmn_duplicate_data->quiz_stye,
374
  'question_numbering' => $mlw_qmn_duplicate_data->question_numbering,
375
+ 'quiz_settings' => serialize( $quiz_settings ),
376
  'theme_selected' => $mlw_qmn_duplicate_data->theme_selected,
377
  'last_activity' => date("Y-m-d H:i:s"),
378
  'require_log_in' => $mlw_qmn_duplicate_data->require_log_in,
383
  'scheduled_timeframe_text' => $mlw_qmn_duplicate_data->scheduled_timeframe_text,
384
  'quiz_views' => 0,
385
  'quiz_taken' => 0,
386
+ 'deleted' => 0,
387
+ 'quiz_author_id' => $current_user->ID,
388
  ),
389
  array(
390
  '%s',
439
  '%d',
440
  '%d',
441
  '%d',
442
+ '%d',
443
  )
444
  );
445
  $mlw_new_id = $wpdb->insert_id;
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -14,7 +14,8 @@ if (!defined('ABSPATH')) {
14
  * @since 4.0.0
15
  */
16
  class QMNQuizManager {
17
-
 
18
  /**
19
  * Main Construct Function
20
  *
@@ -53,6 +54,8 @@ class QMNQuizManager {
53
  //remove file of file upload question type
54
  add_action('wp_ajax_qsm_remove_file_fd_question', array($this, 'qsm_remove_file_fd_question'));
55
  add_action('wp_ajax_nopriv_qsm_remove_file_fd_question', array($this, 'qsm_remove_file_fd_question'));
 
 
56
  }
57
 
58
  /**
@@ -95,7 +98,8 @@ class QMNQuizManager {
95
  $upload_dir = wp_upload_dir();
96
  $datafile = $_FILES["file"]["tmp_name"];
97
  $file_name = $_FILES["file"]["name"];
98
- $file = $upload_dir['path'] . '/' . $_FILES['productbd']['name'];
 
99
  $counter = 1;
100
  $rawBaseName = pathinfo($file_name, PATHINFO_FILENAME);
101
  $extension = pathinfo($file_name, PATHINFO_EXTENSION);
@@ -262,6 +266,14 @@ class QMNQuizManager {
262
  window.qmn_quiz_data = new Object();
263
  }
264
  </script>";
 
 
 
 
 
 
 
 
265
  $qmn_json_data = array(
266
  'quiz_id' => $qmn_array_for_variables['quiz_id'],
267
  'quiz_name' => $qmn_array_for_variables['quiz_name'],
@@ -269,6 +281,7 @@ class QMNQuizManager {
269
  'ajax_show_correct' => $qmn_quiz_options->ajax_show_correct,
270
  'progress_bar' => $qmn_quiz_options->progress_bar,
271
  'contact_info_location' => $qmn_quiz_options->contact_info_location,
 
272
  );
273
 
274
  $return_display = apply_filters('qmn_begin_shortcode', $return_display, $qmn_quiz_options, $qmn_array_for_variables);
@@ -496,7 +509,7 @@ class QMNQuizManager {
496
  wp_enqueue_style('qsm_model_css', plugins_url('../../css/qsm-admin.css', __FILE__));
497
  wp_enqueue_script('qsm_model_js', plugins_url('../../js/micromodal.min.js', __FILE__));
498
  wp_enqueue_script('qsm_quiz', plugins_url('../../js/qsm-quiz.js', __FILE__), array('wp-util', 'underscore', 'jquery', 'jquery-ui-tooltip', 'progress-bar'), $mlwQuizMasterNext->version);
499
- wp_localize_script('qsm_quiz', 'qmn_ajax_object', array('ajaxurl' => admin_url('admin-ajax.php'), 'enable_quick_result_mc' => isset($options->enable_quick_result_mc) ? $options->enable_quick_result_mc : '','enable_result_after_timer_end' => isset($options->enable_result_after_timer_end) ? $options->enable_result_after_timer_end : ''));
500
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
501
  global $qmn_total_questions;
502
  $qmn_total_questions = 0;
@@ -538,7 +551,7 @@ class QMNQuizManager {
538
  if (0 == $options->randomness_order && 0 == $options->question_from_total && 0 == $options->pagination && 0 !== count($pages)) {
539
  $quiz_display .= $this->display_pages($options, $quiz_data);
540
  } else {
541
- // ... else, use older system.
542
  $questions = $this->load_questions($quiz_data['quiz_id'], $options, true, $question_amount);
543
  $answers = $this->create_answer_array($questions);
544
  $quiz_display .= $this->display_begin_section($options, $quiz_data);
@@ -580,6 +593,7 @@ class QMNQuizManager {
580
  global $qmn_json_data;
581
  ob_start();
582
  $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('pages', array());
 
583
  $questions = QSM_Questions::load_questions_by_pages($options->quiz_id);
584
  $question_list = '';
585
  $contact_fields = QSM_Contact_Manager::load_fields();
@@ -674,9 +688,14 @@ class QMNQuizManager {
674
  } else {
675
  $total_pages_count = count($pages);
676
  $pages_count = 1;
677
- foreach ($pages as $page) {
 
 
 
 
678
  ?>
679
- <section class="qsm-page <?php echo $animation_effect; ?>">
 
680
  <?php
681
  foreach ($page as $question_id) {
682
  $question_list .= $question_id . 'Q';
@@ -918,7 +937,6 @@ class QMNQuizManager {
918
  do_action('mlw_qmn_end_quiz_section');
919
  $section_display .= ob_get_contents();
920
  ob_end_clean();
921
-
922
  $section_display .= "<input type='submit' class='qsm-btn qsm-submit-btn qmn_btn' value='" . esc_attr(htmlspecialchars_decode($qmn_quiz_options->submit_button_text, ENT_QUOTES)) . "' />";
923
  $section_display .= "</div>";
924
 
@@ -1019,7 +1037,8 @@ class QMNQuizManager {
1019
  if (!$qmn_allowed_visit) {
1020
  return $result_display;
1021
  }
1022
-
 
1023
  // Gathers contact information.
1024
  $qmn_array_for_variables['user_name'] = 'None';
1025
  $qmn_array_for_variables['user_business'] = 'None';
@@ -1043,6 +1062,7 @@ class QMNQuizManager {
1043
  }
1044
  }
1045
 
 
1046
  $mlw_qmn_timer = isset($_POST["timer"]) ? sanitize_text_field(intval($_POST["timer"])) : 0;
1047
  $mlw_qmn_timer_ms = isset($_POST["timer_ms"]) ? sanitize_text_field(intval($_POST["timer_ms"])) : 0;
1048
  $qmn_array_for_variables['user_id'] = get_current_user_id();
@@ -1058,17 +1078,8 @@ class QMNQuizManager {
1058
  $qmn_array_for_variables['comments'] = $this->check_comment_section($qmn_quiz_options, $qmn_array_for_variables);
1059
  $result_display = apply_filters('qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
1060
 
1061
- // Determines redirect/results page.
1062
- $results_pages = $this->display_results_text($qmn_quiz_options, $qmn_array_for_variables);
1063
- $result_display .= $results_pages['display'];
1064
- $result_display = apply_filters('qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
1065
-
1066
- $result_display .= $this->display_social($qmn_quiz_options, $qmn_array_for_variables);
1067
- $result_display = apply_filters('qmn_after_social_media', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
1068
- if ( $this->qsm_plugin_active( 'qsm-save-resume/qsm-save-resume.php' ) != 1 && $qmn_quiz_options->enable_retake_quiz_button == 1 ) {
1069
- $result_display .= '<a style="float: right;" class="button btn-reload-quiz" data-quiz_id="'. $qmn_array_for_variables['quiz_id'] .'" href="#" >'. apply_filters('qsm_retake_quiz_text', 'Retake Quiz') .'</a>';
1070
- }
1071
  $unique_id = md5(date("Y-m-d H:i:s"));
 
1072
  // If the store responses in database option is set to Yes.
1073
  if (0 != $qmn_quiz_options->store_responses) {
1074
 
@@ -1079,6 +1090,7 @@ class QMNQuizManager {
1079
  htmlspecialchars(stripslashes($qmn_array_for_variables['comments']), ENT_QUOTES),
1080
  'contact' => $contact_responses,
1081
  'timer_ms' => intval($qmn_array_for_variables['timer_ms']),
 
1082
  );
1083
  $results_array = apply_filters('qsm_results_array', $results_array, $qmn_array_for_variables);
1084
  $serialized_results = serialize($results_array);
@@ -1086,7 +1098,6 @@ class QMNQuizManager {
1086
  // Inserts the responses in the database.
1087
  global $wpdb;
1088
  $table_name = $wpdb->prefix . "mlw_results";
1089
-
1090
  $results_insert = $wpdb->insert(
1091
  $table_name, array(
1092
  'quiz_id' => $qmn_array_for_variables['quiz_id'],
@@ -1107,6 +1118,7 @@ class QMNQuizManager {
1107
  'quiz_results' => $serialized_results,
1108
  'deleted' => 0,
1109
  'unique_id' => $unique_id,
 
1110
  ), array(
1111
  '%d',
1112
  '%s',
@@ -1126,8 +1138,21 @@ class QMNQuizManager {
1126
  '%s',
1127
  '%d',
1128
  '%s',
 
1129
  )
1130
  );
 
 
 
 
 
 
 
 
 
 
 
 
1131
  }
1132
 
1133
  /*
@@ -1145,15 +1170,16 @@ class QMNQuizManager {
1145
  }
1146
  }
1147
 
1148
- $results_id = $wpdb->insert_id;
1149
-
1150
  // Hook is fired after the responses are submitted. Passes responses, result ID, quiz settings, and response data.
1151
  do_action('qsm_quiz_submitted', $results_array, $results_id, $qmn_quiz_options, $qmn_array_for_variables);
1152
 
1153
  $qmn_array_for_variables = apply_filters( 'qmn_filter_email_content', $qmn_array_for_variables, $results_id);
1154
-
1155
- // Sends the emails.
1156
- QSM_Emails::send_emails($qmn_array_for_variables);
 
 
 
1157
 
1158
  /**
1159
  * Filters for filtering the results text after emails are sent.
@@ -1283,7 +1309,8 @@ class QMNQuizManager {
1283
  "id" => $question['question_id'],
1284
  "points" => $answer_points,
1285
  "category" => $question['category'],
1286
- "question_type" => $question['question_type_new']
 
1287
  ), $options, $quiz_data);
1288
  }
1289
  break;
@@ -1345,7 +1372,9 @@ class QMNQuizManager {
1345
  "correct" => $correct_status,
1346
  "id" => $question['question_id'],
1347
  "points" => $answer_points,
1348
- "category" => $question['category']
 
 
1349
  ), $options, $quiz_data);
1350
  }
1351
  break;
@@ -1727,6 +1756,16 @@ class QMNQuizManager {
1727
 
1728
  return false;
1729
  }
 
 
 
 
 
 
 
 
 
 
1730
  }
1731
 
1732
  global $qmnQuizManager;
@@ -1752,11 +1791,21 @@ function qmn_require_login_check($display, $qmn_quiz_options, $qmn_array_for_var
1752
  return $display;
1753
  }
1754
 
1755
- add_filter('qmn_begin_shortcode', 'qsm_scheduled_timeframe_check', 10, 3);
1756
 
 
 
 
 
 
 
 
 
 
1757
  function qsm_scheduled_timeframe_check($display, $options, $variable_data) {
1758
  global $qmn_allowed_visit;
1759
-
 
1760
  // Checks if the start and end dates have data
1761
  if (!empty($options->scheduled_time_start) && !empty($options->scheduled_time_end)) {
1762
  $start = strtotime($options->scheduled_time_start);
@@ -1764,12 +1813,27 @@ function qsm_scheduled_timeframe_check($display, $options, $variable_data) {
1764
 
1765
  // Checks if the current timestamp is outside of scheduled timeframe
1766
  if (current_time('timestamp') < $start || current_time('timestamp') > $end) {
1767
- $qmn_allowed_visit = false;
1768
- $message = wpautop(htmlspecialchars_decode($options->scheduled_timeframe_text, ENT_QUOTES));
1769
- $message = apply_filters('mlw_qmn_template_variable_quiz_page', $message, $variable_data);
1770
- $display .= str_replace("\n", "<br>", $message);
 
 
 
1771
  }
1772
  }
 
 
 
 
 
 
 
 
 
 
 
 
1773
  return $display;
1774
  }
1775
 
@@ -1913,3 +1977,10 @@ function mlw_qmn_set_html_content_type() {
1913
  function qsm_time_in_milliseconds() {
1914
  return round(microtime(true) * 1000);
1915
  }
 
 
 
 
 
 
 
14
  * @since 4.0.0
15
  */
16
  class QMNQuizManager {
17
+
18
+ protected $qsm_background_email;
19
  /**
20
  * Main Construct Function
21
  *
54
  //remove file of file upload question type
55
  add_action('wp_ajax_qsm_remove_file_fd_question', array($this, 'qsm_remove_file_fd_question'));
56
  add_action('wp_ajax_nopriv_qsm_remove_file_fd_question', array($this, 'qsm_remove_file_fd_question'));
57
+
58
+ add_action('init', array($this, 'qsm_process_background_email'));
59
  }
60
 
61
  /**
98
  $upload_dir = wp_upload_dir();
99
  $datafile = $_FILES["file"]["tmp_name"];
100
  $file_name = $_FILES["file"]["name"];
101
+ $file = $upload_dir['path'] . '/' . $_FILES['file']['name'];
102
+ $file_url = $upload_dir['url'] . '/' . $_FILES['file']['name'];
103
  $counter = 1;
104
  $rawBaseName = pathinfo($file_name, PATHINFO_FILENAME);
105
  $extension = pathinfo($file_name, PATHINFO_EXTENSION);
266
  window.qmn_quiz_data = new Object();
267
  }
268
  </script>";
269
+ $qpages = array();
270
+ $qpages_arr = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('qpages', array());
271
+ if (!empty($qpages_arr)) {
272
+ foreach ($qpages_arr as $key => $qpage) {
273
+ unset($qpage['questions']);
274
+ $qpages[$qpage['id']] = $qpage;
275
+ }
276
+ }
277
  $qmn_json_data = array(
278
  'quiz_id' => $qmn_array_for_variables['quiz_id'],
279
  'quiz_name' => $qmn_array_for_variables['quiz_name'],
281
  'ajax_show_correct' => $qmn_quiz_options->ajax_show_correct,
282
  'progress_bar' => $qmn_quiz_options->progress_bar,
283
  'contact_info_location' => $qmn_quiz_options->contact_info_location,
284
+ 'qpages' => $qpages,
285
  );
286
 
287
  $return_display = apply_filters('qmn_begin_shortcode', $return_display, $qmn_quiz_options, $qmn_array_for_variables);
509
  wp_enqueue_style('qsm_model_css', plugins_url('../../css/qsm-admin.css', __FILE__));
510
  wp_enqueue_script('qsm_model_js', plugins_url('../../js/micromodal.min.js', __FILE__));
511
  wp_enqueue_script('qsm_quiz', plugins_url('../../js/qsm-quiz.js', __FILE__), array('wp-util', 'underscore', 'jquery', 'jquery-ui-tooltip', 'progress-bar'), $mlwQuizMasterNext->version);
512
+ wp_localize_script('qsm_quiz', 'qmn_ajax_object', array('ajaxurl' => admin_url('admin-ajax.php'), 'enable_quick_result_mc' => isset($options->enable_quick_result_mc) ? $options->enable_quick_result_mc : '','enable_result_after_timer_end' => isset($options->enable_result_after_timer_end) ? $options->enable_result_after_timer_end : '', 'quick_result_correct_text' => sprintf('<b>%s</b> %s', __( 'Correct!', 'quiz-master-next' ), __('You have selected correct answer.', 'quiz-master-next')), 'quick_result_wrong_text' => sprintf('<b>%s</b> %s', __( 'Wrong!', 'quiz-master-next' ), __('You have selected wrong answer.', 'quiz-master-next')) ));
513
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
514
  global $qmn_total_questions;
515
  $qmn_total_questions = 0;
551
  if (0 == $options->randomness_order && 0 == $options->question_from_total && 0 == $options->pagination && 0 !== count($pages)) {
552
  $quiz_display .= $this->display_pages($options, $quiz_data);
553
  } else {
554
+ // ... else, use older system.
555
  $questions = $this->load_questions($quiz_data['quiz_id'], $options, true, $question_amount);
556
  $answers = $this->create_answer_array($questions);
557
  $quiz_display .= $this->display_begin_section($options, $quiz_data);
593
  global $qmn_json_data;
594
  ob_start();
595
  $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('pages', array());
596
+ $qpages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting('qpages', array());
597
  $questions = QSM_Questions::load_questions_by_pages($options->quiz_id);
598
  $question_list = '';
599
  $contact_fields = QSM_Contact_Manager::load_fields();
688
  } else {
689
  $total_pages_count = count($pages);
690
  $pages_count = 1;
691
+ foreach ($pages as $key => $page) {
692
+ $qpage = (isset($qpages[$key]) ? $qpages[$key] : array());
693
+ $qpage_id = (isset($qpage['id']) ? $qpage['id'] : $key);
694
+ $page_key = (isset($qpage['pagekey']) ? $qpage['pagekey'] : $key);
695
+ $hide_prevbtn = (isset($qpage['hide_prevbtn']) ? $qpage['hide_prevbtn'] : 0);
696
  ?>
697
+ <section class="qsm-page <?php echo $animation_effect; ?> qsm-page-<?php echo $qpage_id;?>" data-pid="<?php echo $qpage_id;?>" data-prevbtn="<?php echo $hide_prevbtn;?>">
698
+ <?php do_action('qsm_action_before_page', $qpage_id, $qpage);?>
699
  <?php
700
  foreach ($page as $question_id) {
701
  $question_list .= $question_id . 'Q';
937
  do_action('mlw_qmn_end_quiz_section');
938
  $section_display .= ob_get_contents();
939
  ob_end_clean();
 
940
  $section_display .= "<input type='submit' class='qsm-btn qsm-submit-btn qmn_btn' value='" . esc_attr(htmlspecialchars_decode($qmn_quiz_options->submit_button_text, ENT_QUOTES)) . "' />";
941
  $section_display .= "</div>";
942
 
1037
  if (!$qmn_allowed_visit) {
1038
  return $result_display;
1039
  }
1040
+ //Add form type for new quiz system 7.0.0
1041
+ $qmn_array_for_variables['form_type'] = isset( $qmn_quiz_options->form_type ) ? $qmn_quiz_options->form_type : 0;
1042
  // Gathers contact information.
1043
  $qmn_array_for_variables['user_name'] = 'None';
1044
  $qmn_array_for_variables['user_business'] = 'None';
1062
  }
1063
  }
1064
 
1065
+ $mlw_qmn_pagetime = isset($_POST["pagetime"]) ? $_POST["pagetime"] : array();
1066
  $mlw_qmn_timer = isset($_POST["timer"]) ? sanitize_text_field(intval($_POST["timer"])) : 0;
1067
  $mlw_qmn_timer_ms = isset($_POST["timer_ms"]) ? sanitize_text_field(intval($_POST["timer_ms"])) : 0;
1068
  $qmn_array_for_variables['user_id'] = get_current_user_id();
1078
  $qmn_array_for_variables['comments'] = $this->check_comment_section($qmn_quiz_options, $qmn_array_for_variables);
1079
  $result_display = apply_filters('qmn_after_check_comments', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
1080
 
 
 
 
 
 
 
 
 
 
 
1081
  $unique_id = md5(date("Y-m-d H:i:s"));
1082
+ $results_id = 0;
1083
  // If the store responses in database option is set to Yes.
1084
  if (0 != $qmn_quiz_options->store_responses) {
1085
 
1090
  htmlspecialchars(stripslashes($qmn_array_for_variables['comments']), ENT_QUOTES),
1091
  'contact' => $contact_responses,
1092
  'timer_ms' => intval($qmn_array_for_variables['timer_ms']),
1093
+ 'pagetime' => $mlw_qmn_pagetime,
1094
  );
1095
  $results_array = apply_filters('qsm_results_array', $results_array, $qmn_array_for_variables);
1096
  $serialized_results = serialize($results_array);
1098
  // Inserts the responses in the database.
1099
  global $wpdb;
1100
  $table_name = $wpdb->prefix . "mlw_results";
 
1101
  $results_insert = $wpdb->insert(
1102
  $table_name, array(
1103
  'quiz_id' => $qmn_array_for_variables['quiz_id'],
1118
  'quiz_results' => $serialized_results,
1119
  'deleted' => 0,
1120
  'unique_id' => $unique_id,
1121
+ 'form_type' => isset( $qmn_quiz_options->form_type ) ? $qmn_quiz_options->form_type : 0,
1122
  ), array(
1123
  '%d',
1124
  '%s',
1138
  '%s',
1139
  '%d',
1140
  '%s',
1141
+ '%d',
1142
  )
1143
  );
1144
+ $results_id = $wpdb->insert_id;
1145
+ }
1146
+
1147
+ // Determines redirect/results page.
1148
+ $results_pages = $this->display_results_text($qmn_quiz_options, $qmn_array_for_variables);
1149
+ $result_display .= $results_pages['display'];
1150
+ $result_display = apply_filters('qmn_after_results_text', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
1151
+
1152
+ $result_display .= $this->display_social($qmn_quiz_options, $qmn_array_for_variables);
1153
+ $result_display = apply_filters('qmn_after_social_media', $result_display, $qmn_quiz_options, $qmn_array_for_variables);
1154
+ if ($this->qsm_plugin_active('qsm-save-resume/qsm-save-resume.php') != 1 && $qmn_quiz_options->enable_retake_quiz_button == 1) {
1155
+ $result_display .= '<a style="float: right;" class="button btn-reload-quiz" data-quiz_id="' . $qmn_array_for_variables['quiz_id'] . '" href="#" >' . apply_filters('qsm_retake_quiz_text', 'Retake Quiz') . '</a>';
1156
  }
1157
 
1158
  /*
1170
  }
1171
  }
1172
 
 
 
1173
  // Hook is fired after the responses are submitted. Passes responses, result ID, quiz settings, and response data.
1174
  do_action('qsm_quiz_submitted', $results_array, $results_id, $qmn_quiz_options, $qmn_array_for_variables);
1175
 
1176
  $qmn_array_for_variables = apply_filters( 'qmn_filter_email_content', $qmn_array_for_variables, $results_id);
1177
+
1178
+ // Send the emails in background.
1179
+ $this->qsm_background_email->data( array( 'name' => 'send_emails', 'variables' => $qmn_array_for_variables ) )->dispatch();
1180
+
1181
+ // Sends the emails - Defer the emails.
1182
+ //QSM_Emails::send_emails($qmn_array_for_variables);
1183
 
1184
  /**
1185
  * Filters for filtering the results text after emails are sent.
1309
  "id" => $question['question_id'],
1310
  "points" => $answer_points,
1311
  "category" => $question['category'],
1312
+ "question_type" => $question['question_type_new'],
1313
+ "question_title" => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : ''
1314
  ), $options, $quiz_data);
1315
  }
1316
  break;
1372
  "correct" => $correct_status,
1373
  "id" => $question['question_id'],
1374
  "points" => $answer_points,
1375
+ "category" => $question['category'],
1376
+ "question_type" => $question['question_type_new'],
1377
+ "question_title" => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : ''
1378
  ), $options, $quiz_data);
1379
  }
1380
  break;
1756
 
1757
  return false;
1758
  }
1759
+
1760
+ /**
1761
+ * Include background process files
1762
+ *
1763
+ * @singce 7.0
1764
+ */
1765
+ public function qsm_process_background_email(){
1766
+ require_once plugin_dir_path( __FILE__ ) . 'class-qmn-background-process.php';
1767
+ $this->qsm_background_email = new QSM_Background_Request();
1768
+ }
1769
  }
1770
 
1771
  global $qmnQuizManager;
1791
  return $display;
1792
  }
1793
 
1794
+ add_filter('qmn_begin_shortcode', 'qsm_scheduled_timeframe_check', 99, 3);
1795
 
1796
+ /**
1797
+ * @since 7.0.0 Added the condition for start time ( end time blank ) and end time ( start time blank ).
1798
+ *
1799
+ * @global boolean $qmn_allowed_visit
1800
+ * @param HTML $display
1801
+ * @param Object $options
1802
+ * @param Array $variable_data
1803
+ * @return HTML This function check the time frame of quiz.
1804
+ */
1805
  function qsm_scheduled_timeframe_check($display, $options, $variable_data) {
1806
  global $qmn_allowed_visit;
1807
+
1808
+ $checked_pass = FALSE;
1809
  // Checks if the start and end dates have data
1810
  if (!empty($options->scheduled_time_start) && !empty($options->scheduled_time_end)) {
1811
  $start = strtotime($options->scheduled_time_start);
1813
 
1814
  // Checks if the current timestamp is outside of scheduled timeframe
1815
  if (current_time('timestamp') < $start || current_time('timestamp') > $end) {
1816
+ $checked_pass = TRUE;
1817
+ }
1818
+ }
1819
+ if ( !empty( $options->scheduled_time_start ) && empty( $options->scheduled_time_end ) ){
1820
+ $start = strtotime($options->scheduled_time_start);
1821
+ if ( current_time('timestamp') < $start ){
1822
+ $checked_pass = TRUE;
1823
  }
1824
  }
1825
+ if ( empty( $options->scheduled_time_start ) && !empty( $options->scheduled_time_end ) ){
1826
+ $end = strtotime($options->scheduled_time_end) + 86399;
1827
+ if ( current_time('timestamp') > $end ) {
1828
+ $checked_pass = TRUE;
1829
+ }
1830
+ }
1831
+ if( $checked_pass == TRUE ){
1832
+ $qmn_allowed_visit = false;
1833
+ $message = wpautop(htmlspecialchars_decode($options->scheduled_timeframe_text, ENT_QUOTES));
1834
+ $message = apply_filters('mlw_qmn_template_variable_quiz_page', $message, $variable_data);
1835
+ $display .= str_replace("\n", "<br>", $message);
1836
+ }
1837
  return $display;
1838
  }
1839
 
1977
  function qsm_time_in_milliseconds() {
1978
  return round(microtime(true) * 1000);
1979
  }
1980
+
1981
+ add_filter( 'wp_video_extensions', function( $exts ) {
1982
+ $exts[] = 'mov';
1983
+ $exts[] = 'avi';
1984
+ $exts[] = 'wmv';
1985
+ return $exts;
1986
+ });
php/classes/class-qsm-fields.php CHANGED
@@ -20,12 +20,14 @@ class QSM_Fields {
20
 
21
  global $mlwQuizMasterNext;
22
  global $wpdb;
23
-
 
 
24
  // If nonce is correct, save settings
25
  if ( isset( $_POST["save_settings_nonce"] ) && wp_verify_nonce( $_POST['save_settings_nonce'], 'save_settings') ) {
26
 
27
- // Cycle through fields to retrieve all posted values
28
- $settings_array = array();
29
  foreach ( $fields as $field ) {
30
 
31
  // Sanitize the values based on type
@@ -49,12 +51,12 @@ class QSM_Fields {
49
  break;
50
 
51
  default:
52
- $sanitized_value = sanitize_text_field( $_POST[ $field["id"] ] );
53
  break;
54
  }
55
  $settings_array[ $field["id"] ] = $sanitized_value;
56
  }
57
-
58
  // Update the settings and show alert based on outcome
59
  $results = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( $section, $settings_array );
60
  if ( false !== $results ) {
@@ -66,8 +68,13 @@ class QSM_Fields {
66
  }
67
 
68
  // Retrieve the settings for this section
69
- $settings = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( $section );
70
-
 
 
 
 
 
71
  ?>
72
  <form action="" method="post">
73
  <?php wp_nonce_field( 'save_settings','save_settings_nonce' ); ?>
@@ -135,9 +142,19 @@ class QSM_Fields {
135
  public static function generate_text_field( $field, $value ) {
136
  ?>
137
  <tr valign="top">
138
- <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
 
 
 
 
 
 
 
139
  <td>
140
  <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
 
 
 
141
  </td>
142
  </tr>
143
  <?php
@@ -146,7 +163,14 @@ class QSM_Fields {
146
  public static function generate_select_page_field( $field, $value ) {
147
  ?>
148
  <tr valign="top">
149
- <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
 
 
 
 
 
 
 
150
  <td>
151
  <select id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>">
152
  <option value="">Select Page</option>
@@ -156,6 +180,9 @@ class QSM_Fields {
156
  <option value="<?php echo get_page_link( $page->ID ) ?>" <?php selected($value, get_page_link( $page->ID )); ?> ><?php echo $page->post_title ?></option>;
157
  <?php } ?>
158
  </select>
 
 
 
159
  <br/>
160
  <b style="color: red;">Note: </b><?php echo isset($field['note']) ? $field['note'] : ''; ?>
161
  </td>
@@ -213,9 +240,22 @@ class QSM_Fields {
213
  });
214
  </script>
215
  <tr valign="top">
216
- <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
217
- <td>
 
 
 
 
 
 
 
 
 
 
218
  <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
 
 
 
219
  </td>
220
  </tr>
221
  <?php
@@ -231,9 +271,19 @@ class QSM_Fields {
231
  public static function generate_number_field( $field, $value ) {
232
  ?>
233
  <tr valign="top">
234
- <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
 
 
 
 
 
 
 
235
  <td>
236
  <input type="number" step="1" min="0" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
 
 
 
237
  </td>
238
  </tr>
239
  <?php
@@ -247,23 +297,68 @@ class QSM_Fields {
247
  * @param mixed $value The current value of the setting
248
  */
249
  public static function generate_radio_field( $field, $value ) {
 
250
  ?>
251
- <tr valign="top">
252
- <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
253
- <td>
254
- <?php
255
- $green_class = count($field["options"]) > 2 ? 'green' : '';
256
- ?>
257
- <fieldset class="buttonset buttonset-hide <?php echo $green_class; ?>" data-hide='1'>
 
 
 
 
258
  <?php
259
  foreach ( $field["options"] as $option ) {
260
  ?>
261
  <input type="radio" id="<?php echo $field["id"] . '-' . $option["value"]; ?>" name="<?php echo $field["id"]; ?>" <?php checked( $option["value"], $value ); ?> value="<?php echo $option["value"]; ?>" />
262
- <label for="<?php echo $field["id"] . '-' . $option["value"]; ?>"><?php echo $option["label"]; ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  <?php
264
  }
265
  ?>
266
- </fieldset>
 
 
 
267
  </td>
268
  </tr>
269
  <?php
@@ -282,7 +377,14 @@ class QSM_Fields {
282
  $explode_cat = explode(',', $value);
283
  ?>
284
  <tr valign="top">
285
- <th scope="row"><label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label></th>
 
 
 
 
 
 
 
286
  <td>
287
  <?php
288
  $questions = QSM_Questions::load_questions_by_pages( $quiz_id );
@@ -311,10 +413,57 @@ class QSM_Fields {
311
  }
312
  ?>
313
  <input type="hidden" class="catergory_comma_values" name="<?php echo $field["id"]; ?>" value='<?php echo $value; ?>'>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  </td>
315
  </tr>
316
  <?php
317
  }
 
318
  }
319
 
320
  ?>
20
 
21
  global $mlwQuizMasterNext;
22
  global $wpdb;
23
+
24
+ $result_page_fb_image = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'result_page_fb_image' );
25
+
26
  // If nonce is correct, save settings
27
  if ( isset( $_POST["save_settings_nonce"] ) && wp_verify_nonce( $_POST['save_settings_nonce'], 'save_settings') ) {
28
 
29
+ // Cycle through fields to retrieve all posted values
30
+ $settings_array = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( $section );
31
  foreach ( $fields as $field ) {
32
 
33
  // Sanitize the values based on type
51
  break;
52
 
53
  default:
54
+ $sanitized_value = isset( $_POST[ $field["id"] ] ) ? sanitize_text_field( $_POST[ $field["id"] ] ) : '';
55
  break;
56
  }
57
  $settings_array[ $field["id"] ] = $sanitized_value;
58
  }
59
+
60
  // Update the settings and show alert based on outcome
61
  $results = $mlwQuizMasterNext->pluginHelper->update_quiz_setting( $section, $settings_array );
62
  if ( false !== $results ) {
68
  }
69
 
70
  // Retrieve the settings for this section
71
+ $settings = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( $section );
72
+ if( isset( $settings[ 'form_type' ] ) ){
73
+ $settings[ 'form_type' ] = $settings[ 'system' ] == '2' ? 1 : $settings[ 'form_type' ];
74
+ }
75
+ if( isset( $settings[ 'result_page_fb_image' ] ) && $settings[ 'result_page_fb_image' ] == '' ){
76
+ $settings[ 'result_page_fb_image' ] = $result_page_fb_image != '' ? $result_page_fb_image : $settings[ 'result_page_fb_image' ];
77
+ }
78
  ?>
79
  <form action="" method="post">
80
  <?php wp_nonce_field( 'save_settings','save_settings_nonce' ); ?>
142
  public static function generate_text_field( $field, $value ) {
143
  ?>
144
  <tr valign="top">
145
+ <th scope="row" class="qsm-opt-tr">
146
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
147
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
148
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
149
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
150
+ </span>
151
+ <?php } ?>
152
+ </th>
153
  <td>
154
  <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
155
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
156
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
157
+ <?php } ?>
158
  </td>
159
  </tr>
160
  <?php
163
  public static function generate_select_page_field( $field, $value ) {
164
  ?>
165
  <tr valign="top">
166
+ <th scope="row" class="qsm-opt-tr">
167
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
168
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
169
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
170
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
171
+ </span>
172
+ <?php } ?>
173
+ </th>
174
  <td>
175
  <select id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>">
176
  <option value="">Select Page</option>
180
  <option value="<?php echo get_page_link( $page->ID ) ?>" <?php selected($value, get_page_link( $page->ID )); ?> ><?php echo $page->post_title ?></option>;
181
  <?php } ?>
182
  </select>
183
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
184
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
185
+ <?php } ?>
186
  <br/>
187
  <b style="color: red;">Note: </b><?php echo isset($field['note']) ? $field['note'] : ''; ?>
188
  </td>
240
  });
241
  </script>
242
  <tr valign="top">
243
+ <th scope="row" class="qsm-opt-tr">
244
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
245
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
246
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
247
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
248
+ </span>
249
+ <?php } ?>
250
+ </th>
251
+ <td class="<?php echo $field["id"]; ?>">
252
+ <?php if( isset($field['ph_text']) && $field['ph_text'] != ''){ ?>
253
+ <span class="qsm-ph_text"><?php echo $field['ph_text']; ?></span>
254
+ <?php } ?>
255
  <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
256
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
257
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
258
+ <?php } ?>
259
  </td>
260
  </tr>
261
  <?php
271
  public static function generate_number_field( $field, $value ) {
272
  ?>
273
  <tr valign="top">
274
+ <th scope="row" class="qsm-opt-tr">
275
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
276
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
277
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
278
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
279
+ </span>
280
+ <?php } ?>
281
+ </th>
282
  <td>
283
  <input type="number" step="1" min="0" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
284
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
285
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
286
+ <?php } ?>
287
  </td>
288
  </tr>
289
  <?php
297
  * @param mixed $value The current value of the setting
298
  */
299
  public static function generate_radio_field( $field, $value ) {
300
+ $show_option = isset( $field['show_option'] ) ? $field['show_option'] : '';
301
  ?>
302
+ <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ." hidden qsm_hidden_tr'"; } ?>>
303
+ <th scope="row" class="qsm-opt-tr">
304
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
305
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
306
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
307
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
308
+ </span>
309
+ <?php } ?>
310
+ </th>
311
+ <td>
312
+ <fieldset class="buttonset buttonset-hide" data-hide='1'>
313
  <?php
314
  foreach ( $field["options"] as $option ) {
315
  ?>
316
  <input type="radio" id="<?php echo $field["id"] . '-' . $option["value"]; ?>" name="<?php echo $field["id"]; ?>" <?php checked( $option["value"], $value ); ?> value="<?php echo $option["value"]; ?>" />
317
+ <label for="<?php echo $field["id"] . '-' . $option["value"]; ?>"><?php echo $option["label"]; ?></label><br/>
318
+ <?php
319
+ }
320
+ ?>
321
+ </fieldset>
322
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
323
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
324
+ <?php } ?>
325
+ </td>
326
+ </tr>
327
+ <?php
328
+ }
329
+
330
+ /**
331
+ * Generates radio inputs
332
+ *
333
+ * @since 5.0.0
334
+ * @param array $field The array that contains the data for the input field
335
+ * @param mixed $value The current value of the setting
336
+ */
337
+ public static function generate_select_field( $field, $value ) {
338
+ $show_option = isset( $field['show_option'] ) ? $field['show_option'] : '';
339
+ ?>
340
+ <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ."'"; } ?>>
341
+ <th scope="row" class="qsm-opt-tr">
342
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
343
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
344
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
345
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
346
+ </span>
347
+ <?php } ?>
348
+ </th>
349
+ <td>
350
+ <select name="<?php echo $field["id"]; ?>">
351
+ <?php
352
+ foreach ( $field["options"] as $option ) {
353
+ ?>
354
+ <option <?php selected( $option["value"], $value ); ?> value="<?php echo $option["value"]; ?>"><?php echo $option["label"]; ?></option>
355
  <?php
356
  }
357
  ?>
358
+ </select>
359
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
360
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
361
+ <?php } ?>
362
  </td>
363
  </tr>
364
  <?php
377
  $explode_cat = explode(',', $value);
378
  ?>
379
  <tr valign="top">
380
+ <th scope="row" class="qsm-opt-tr">
381
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
382
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
383
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
384
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
385
+ </span>
386
+ <?php } ?>
387
+ </th>
388
  <td>
389
  <?php
390
  $questions = QSM_Questions::load_questions_by_pages( $quiz_id );
413
  }
414
  ?>
415
  <input type="hidden" class="catergory_comma_values" name="<?php echo $field["id"]; ?>" value='<?php echo $value; ?>'>
416
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
417
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
418
+ <?php } ?>
419
+ </td>
420
+ </tr>
421
+ <?php
422
+ }
423
+
424
+ /**
425
+ * @since 7.0
426
+ * @param Array $field
427
+ * @param String $value
428
+ *
429
+ * Generate the hide show div
430
+ */
431
+ public static function generate_hide_show_field( $field, $value ) { ?>
432
+ <tr valign="top">
433
+ <th scope="row" class="qsm-opt-tr">
434
+ <a href="#" id="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></a>
435
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
436
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
437
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
438
+ </span>
439
+ <?php } ?>
440
+ </th>
441
+ <td>
442
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
443
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
444
+ <?php } ?>
445
+ </td>
446
+ </tr>
447
+ <?php
448
+ }
449
+
450
+ /**
451
+ * Generates h2 tag for label
452
+ *
453
+ * @since 7.0.0
454
+ * @param array $field The array that contains the data for the input field
455
+ * @param mixed $value The current value of the setting
456
+ */
457
+ public static function generate_section_heading_field( $field, $value ) {
458
+ ?>
459
+ <tr valign="top">
460
+ <th scope="row"><h2 class="section_heading"><?php echo $field["label"]; ?></h2></th>
461
+ <td>
462
  </td>
463
  </tr>
464
  <?php
465
  }
466
+
467
  }
468
 
469
  ?>
php/classes/class-qsm-install.php CHANGED
@@ -40,11 +40,34 @@ class QSM_Install {
40
  public function register_default_settings() {
41
 
42
  global $mlwQuizMasterNext;
43
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  // Registers system setting
45
  $field_array = array(
46
  'id' => 'system',
47
- 'label' => __('Which system is this quiz graded on?', 'quiz-master-next'),
48
  'type' => 'radio',
49
  'options' => array(
50
  array(
@@ -56,18 +79,21 @@ class QSM_Install {
56
  'value' => 1
57
  ),
58
  array(
59
- 'label' => __('Not Graded', 'quiz-master-next'),
60
- 'value' => 2
61
  )
62
  ),
63
- 'default' => 0
 
 
 
64
  );
65
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
66
 
67
  // Registers progress_bar setting
68
  $field_array = array(
69
  'id' => 'progress_bar',
70
- 'label' => __( 'Show a progress bar?', 'quiz-master-next' ),
71
  'type' => 'radio',
72
  'options' => array(
73
  array(
@@ -86,7 +112,7 @@ class QSM_Install {
86
  // Registers require_log_in setting
87
  $field_array = array(
88
  'id' => 'require_log_in',
89
- 'label' => __('Should the user be required to be logged in to take this quiz?', 'quiz-master-next'),
90
  'type' => 'radio',
91
  'options' => array(
92
  array(
@@ -98,38 +124,41 @@ class QSM_Install {
98
  'value' => 0
99
  )
100
  ),
101
- 'default' => 0
 
102
  );
103
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
104
 
105
  // Registers pagination setting
106
  $field_array = array(
107
  'id' => 'pagination',
108
- 'label' => __('How many questions per page would you like? (Leave 0 to use pages created on Questions tab)', 'quiz-master-next'),
109
  'type' => 'number',
110
  'options' => array(
111
 
112
  ),
113
- 'default' => 0
 
114
  );
115
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
116
 
117
  // Registers timer_limit setting
118
  $field_array = array(
119
  'id' => 'timer_limit',
120
- 'label' => __('How many minutes does the user have to finish the quiz? (Leave 0 for no time limit)', 'quiz-master-next'),
121
  'type' => 'number',
122
  'options' => array(
123
 
124
  ),
125
- 'default' => 0
 
126
  );
127
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
128
 
129
  // Settings for quick result
130
  $field_array = array(
131
  'id' => 'enable_result_after_timer_end',
132
- 'label' => __('Force submit after timer expiry?', 'quiz-master-next'),
133
  'type' => 'radio',
134
  'options' => array(
135
  array(
@@ -148,68 +177,80 @@ class QSM_Install {
148
  // Registers total_user_tries setting
149
  $field_array = array(
150
  'id' => 'total_user_tries',
151
- 'label' => __('How many times can a user take this quiz? (Leave 0 for as many times as the user wants to.)', 'quiz-master-next'),
152
  'type' => 'number',
153
  'options' => array(
154
 
155
  ),
156
- 'default' => 0
 
 
157
  );
158
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
159
 
160
  // Registers limit_total_entries setting
161
  $field_array = array(
162
  'id' => 'limit_total_entries',
163
- 'label' => __('How many total entries can this quiz have? (Leave 0 for unlimited entries)', 'quiz-master-next'),
164
  'type' => 'number',
165
  'options' => array(
166
 
167
  ),
168
- 'default' => 0
 
 
169
  );
170
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
171
 
172
  // Registers question_from_total setting
173
  $field_array = array(
174
  'id' => 'question_from_total',
175
- 'label' => __('How many questions should be loaded for quiz? (Leave 0 to load all questions)', 'quiz-master-next'),
176
  'type' => 'number',
177
  'options' => array(
178
 
179
  ),
180
- 'default' => 0
 
 
181
  );
182
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
183
 
184
  // Registers scheduled_time_start setting
185
  $field_array = array(
186
  'id' => 'scheduled_time_start',
187
- 'label' => __('When should the user be able to start accessing the quiz? (Leave blank if the user can access anytime)', 'quiz-master-next'),
188
  'type' => 'date',
189
  'options' => array(
190
 
191
  ),
192
- 'default' => ''
 
 
 
 
193
  );
194
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
195
 
196
  // Registers scheduled_time_end setting
197
  $field_array = array(
198
  'id' => 'scheduled_time_end',
199
- 'label' => __('When should the user stop accessing the quiz? (Leave blank if the user can access anytime)', 'quiz-master-next'),
200
  'type' => 'date',
201
  'options' => array(
202
 
203
  ),
204
- 'default' => ''
 
 
205
  );
206
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
207
 
208
  // Registers randomness_order setting
209
  $field_array = array(
210
  'id' => 'randomness_order',
211
- 'label' => __('Are the questions random? (Question Order will not apply if this is yes)', 'quiz-master-next'),
212
- 'type' => 'radio',
213
  'options' => array(
214
  array(
215
  'label' => __('Random Questions', 'quiz-master-next'),
@@ -224,46 +265,50 @@ class QSM_Install {
224
  'value' => 3
225
  ),
226
  array(
227
- 'label' => __('No', 'quiz-master-next'),
228
  'value' => 0
229
  )
230
  ),
231
- 'default' => 0
 
232
  );
233
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
234
 
235
  // Registers category setting
236
  $field_array = array(
237
  'id' => 'randon_category',
238
- 'label' => __('Select category for random question', 'quiz-master-next'),
239
  'type' => 'category',
240
- 'default' => ''
 
241
  );
242
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
243
 
244
  // Registers contact_info_location setting
245
  $field_array = array(
246
  'id' => 'contact_info_location',
247
- 'label' => __('Would you like to ask for the contact information at the beginning or at the end of the quiz?', 'quiz-master-next'),
248
  'type' => 'radio',
249
  'options' => array(
250
  array(
251
- 'label' => __('Beginning', 'quiz-master-next'),
252
  'value' => 0
253
  ),
254
  array(
255
- 'label' => __('End', 'quiz-master-next'),
256
  'value' => 1
257
  )
258
  ),
259
- 'default' => 0
 
 
260
  );
261
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
262
 
263
  // Registers loggedin_user_contact setting
264
  $field_array = array(
265
  'id' => 'loggedin_user_contact',
266
- 'label' => __('If a logged-in user takes the quiz, would you like them to be able to edit contact information? If set to no, the fields will not show up for logged in users; however, the users information will be saved for the fields.', 'quiz-master-next'),
267
  'type' => 'radio',
268
  'options' => array(
269
  array(
@@ -275,14 +320,16 @@ class QSM_Install {
275
  'value' => 1
276
  )
277
  ),
278
- 'default' => 0
 
 
279
  );
280
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
281
 
282
  // Registers comment_section setting
283
  $field_array = array(
284
  'id' => 'comment_section',
285
- 'label' => __('Would you like a place for the user to enter comments?', 'quiz-master-next'),
286
  'type' => 'radio',
287
  'options' => array(
288
  array(
@@ -294,14 +341,15 @@ class QSM_Install {
294
  'value' => 1
295
  )
296
  ),
297
- 'default' => 1
 
298
  );
299
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
300
 
301
  // Registers question_numbering setting
302
  $field_array = array(
303
  'id' => 'question_numbering',
304
- 'label' => __('Show question number on quiz?', 'quiz-master-next'),
305
  'type' => 'radio',
306
  'options' => array(
307
  array(
@@ -320,7 +368,7 @@ class QSM_Install {
320
  // Registers store_responses setting
321
  $field_array = array(
322
  'id' => 'store_responses',
323
- 'label' => __( 'Store the responses in the database?', 'quiz-master-next' ),
324
  'type' => 'radio',
325
  'options' => array(
326
  array(
@@ -332,33 +380,15 @@ class QSM_Install {
332
  'value' => 0
333
  )
334
  ),
335
- 'default' => 1
 
336
  );
337
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
338
 
339
- // Registers social_media setting
340
- $field_array = array(
341
- 'id' => 'social_media',
342
- 'label' => __('Show social media sharing buttons? (Twitter & Facebook) This option is for here only for users of older versions. Please use the new template variables %FACEBOOK_SHARE% %TWITTER_SHARE% on your results pages instead of using this option!', 'quiz-master-next'),
343
- 'type' => 'radio',
344
- 'options' => array(
345
- array(
346
- 'label' => __('Yes', 'quiz-master-next'),
347
- 'value' => 1
348
- ),
349
- array(
350
- 'label' => __('No', 'quiz-master-next'),
351
- 'value' => 0
352
- )
353
- ),
354
- 'default' => 0
355
- );
356
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
357
-
358
  // Registers disable_answer_onselect setting
359
  $field_array = array(
360
  'id' => 'disable_answer_onselect',
361
- 'label' => __('Disable question once user selects answer? (Currently only work on multiple choice)', 'quiz-master-next'),
362
  'type' => 'radio',
363
  'options' => array(
364
  array(
@@ -370,125 +400,37 @@ class QSM_Install {
370
  'value' => 0
371
  )
372
  ),
373
- 'default' => 0
 
 
374
  );
375
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
376
 
377
  // Registers ajax_show_correct setting
378
  $field_array = array(
379
  'id' => 'ajax_show_correct',
380
- 'label' => __('Dynamically add class for incorrect/correct answer after user selects answer? (Currently only works on multiple choice)', 'quiz-master-next'),
381
- 'type' => 'radio',
382
- 'options' => array(
383
- array(
384
- 'label' => __('Yes', 'quiz-master-next'),
385
- 'value' => 1
386
- ),
387
- array(
388
- 'label' => __('No', 'quiz-master-next'),
389
- 'value' => 0
390
- )
391
- ),
392
- 'default' => 0
393
- );
394
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
395
-
396
- // Registers user_name setting
397
- $field_array = array(
398
- 'id' => 'user_name',
399
- 'label' => __("Should we ask for the user's name? (Only here for older versions. Use Contact tab for this.)", 'quiz-master-next'),
400
- 'type' => 'radio',
401
- 'options' => array(
402
- array(
403
- 'label' => __('Yes', 'quiz-master-next'),
404
- 'value' => 0
405
- ),
406
- array(
407
- 'label' => __('Require', 'quiz-master-next'),
408
- 'value' => 1
409
- ),
410
- array(
411
- 'label' => __('No', 'quiz-master-next'),
412
- 'value' => 2
413
- )
414
- ),
415
- 'default' => 2
416
- );
417
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
418
-
419
- // Registers user_comp setting
420
- $field_array = array(
421
- 'id' => 'user_comp',
422
- 'label' => __('Should we ask for users business? (Only here for older versions. Use Contact tab for this.)', 'quiz-master-next'),
423
  'type' => 'radio',
424
  'options' => array(
425
  array(
426
  'label' => __('Yes', 'quiz-master-next'),
427
- 'value' => 0
428
- ),
429
- array(
430
- 'label' => __('Require', 'quiz-master-next'),
431
  'value' => 1
432
  ),
433
  array(
434
  'label' => __('No', 'quiz-master-next'),
435
- 'value' => 2
436
- )
437
- ),
438
- 'default' => 2
439
- );
440
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
441
-
442
- // Registers user_email setting
443
- $field_array = array(
444
- 'id' => 'user_email',
445
- 'label' => __('Should we ask for users email? (Only here for older versions. Use Contact tab for this.)', 'quiz-master-next'),
446
- 'type' => 'radio',
447
- 'options' => array(
448
- array(
449
- 'label' => __('Yes', 'quiz-master-next'),
450
- 'value' => 0
451
- ),
452
- array(
453
- 'label' => __('Require', 'quiz-master-next'),
454
- 'value' => 1
455
- ),
456
- array(
457
- 'label' => __('No', 'quiz-master-next'),
458
- 'value' => 2
459
- )
460
- ),
461
- 'default' => 2
462
- );
463
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
464
-
465
- // Registers user_phone setting
466
- $field_array = array(
467
- 'id' => 'user_phone',
468
- 'label' => __('Should we ask for users phone number? (Only here for older versions. Use Contact tab for this.)', 'quiz-master-next'),
469
- 'type' => 'radio',
470
- 'options' => array(
471
- array(
472
- 'label' => __('Yes', 'quiz-master-next'),
473
  'value' => 0
474
- ),
475
- array(
476
- 'label' => __('Require', 'quiz-master-next'),
477
- 'value' => 1
478
- ),
479
- array(
480
- 'label' => __('No', 'quiz-master-next'),
481
- 'value' => 2
482
  )
483
  ),
484
- 'default' => 2
 
 
485
  );
486
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
487
 
488
  // Registers hide_auto fill setting
489
  $field_array = array(
490
  'id' => 'contact_disable_autofill',
491
- 'label' => __('Disable auto fill for contact input?', 'quiz-master-next'),
492
  'type' => 'radio',
493
  'options' => array(
494
  array(
@@ -507,7 +449,7 @@ class QSM_Install {
507
  // Registers show category on front setting
508
  $field_array = array(
509
  'id' => 'show_category_on_front',
510
- 'label' => __('Show category on front?', 'quiz-master-next'),
511
  'type' => 'radio',
512
  'options' => array(
513
  array(
@@ -526,7 +468,7 @@ class QSM_Install {
526
  // Settings for quick result
527
  $field_array = array(
528
  'id' => 'enable_quick_result_mc',
529
- 'label' => __('Show live results for questions inline', 'quiz-master-next'),
530
  'type' => 'radio',
531
  'options' => array(
532
  array(
@@ -538,14 +480,15 @@ class QSM_Install {
538
  'value' => 0
539
  )
540
  ),
541
- 'default' => 0
 
542
  );
543
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
544
 
545
  //Setting for retake quiz
546
  $field_array = array(
547
  'id' => 'enable_retake_quiz_button',
548
- 'label' => __('Show RETAKE QUIZ button on result page', 'quiz-master-next'),
549
  'type' => 'radio',
550
  'options' => array(
551
  array(
@@ -557,14 +500,15 @@ class QSM_Install {
557
  'value' => 0
558
  ),
559
  ),
560
- 'default' => 0
 
561
  );
562
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
563
 
564
  //Setting for pagination of quiz
565
  $field_array = array(
566
  'id' => 'enable_pagination_quiz',
567
- 'label' => __('Enable pagination of quiz', 'quiz-master-next'),
568
  'type' => 'radio',
569
  'options' => array(
570
  array(
@@ -576,14 +520,14 @@ class QSM_Install {
576
  'value' => 0
577
  ),
578
  ),
579
- 'default' => 0
580
  );
581
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
582
 
583
  //Setting for pagination of quiz
584
  $field_array = array(
585
  'id' => 'enable_deselect_option',
586
- 'label' => __('Enable Deselect Option <br/> Note: This option is only for Multiple Choice and Horizontal Multiple Choice', 'quiz-master-next'),
587
  'type' => 'radio',
588
  'options' => array(
589
  array(
@@ -595,15 +539,16 @@ class QSM_Install {
595
  'value' => 0
596
  ),
597
  ),
598
- 'default' => 0
 
599
  );
600
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
601
 
602
  //Setting for animation
603
  $field_array = array(
604
  'id' => 'quiz_animation',
605
- 'label' => __('Select quiz animation', 'quiz-master-next'),
606
- 'type' => 'radio',
607
  'options' => array(
608
  array(
609
  'label' => __('bounce', 'quiz-master-next'),
@@ -654,6 +599,141 @@ class QSM_Install {
654
  );
655
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
  // Registers message_before setting
658
  $field_array = array(
659
  'id' => 'message_before',
@@ -800,130 +880,159 @@ class QSM_Install {
800
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
801
 
802
  // Registers submit_button_text setting
 
 
 
 
 
 
 
 
803
  $field_array = array(
804
  'id' => 'submit_button_text',
805
- 'label' => __('Text for submit button', 'quiz-master-next'),
806
  'type' => 'text',
807
  'default' => 0
808
  );
809
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
810
-
811
- // Registers name_field_text setting
812
  $field_array = array(
813
- 'id' => 'name_field_text',
814
- 'label' => __('Text for name field', 'quiz-master-next'),
815
  'type' => 'text',
816
  'default' => 0
817
  );
818
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
819
 
820
- // Registers business_field_text setting
821
  $field_array = array(
822
- 'id' => 'business_field_text',
823
- 'label' => __('Text for business field', 'quiz-master-next'),
824
  'type' => 'text',
825
  'default' => 0
826
  );
 
 
 
 
 
 
 
 
 
827
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
828
-
829
- // Registers email_field_text setting
830
  $field_array = array(
831
- 'id' => 'email_field_text',
832
- 'label' => __('Text for email field', 'quiz-master-next'),
833
  'type' => 'text',
834
- 'default' => 0
835
  );
836
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
837
 
838
- // Registers phone_field_text setting
839
  $field_array = array(
840
- 'id' => 'phone_field_text',
841
- 'label' => __('Text for phone number field', 'quiz-master-next'),
842
  'type' => 'text',
843
- 'default' => 0
844
  );
845
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
846
 
847
- // Registers comment_field_text setting
848
  $field_array = array(
849
- 'id' => 'comment_field_text',
850
- 'label' => __('Text for comments field', 'quiz-master-next'),
851
  'type' => 'text',
852
- 'default' => 0
853
  );
854
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
855
 
856
- // Registers previous_button_text setting
857
  $field_array = array(
858
- 'id' => 'previous_button_text',
859
- 'label' => __('Text for previous button', 'quiz-master-next'),
860
  'type' => 'text',
 
 
 
 
 
 
 
 
 
861
  'default' => 0
862
  );
863
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
864
-
865
- // Registers next_button_text setting
866
  $field_array = array(
867
- 'id' => 'next_button_text',
868
- 'label' => __('Text for next button', 'quiz-master-next'),
869
  'type' => 'text',
870
  'default' => 0
871
  );
872
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
873
-
874
  // Registers hint_text setting
875
  $field_array = array(
876
  'id' => 'hint_text',
877
- 'label' => __('Text for hint', 'quiz-master-next'),
878
  'type' => 'text',
879
  'default' => 'Hint'
880
  );
881
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
882
-
883
- // Registers empty_error_text setting
884
  $field_array = array(
885
- 'id' => 'empty_error_text',
886
- 'label' => __('Text for when user has not filled in all required fields', 'quiz-master-next'),
887
- 'type' => 'text',
888
- 'default' => 'Please complete all required fields!'
 
 
889
  );
890
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
891
-
892
- // Registers email_error_text setting
893
  $field_array = array(
894
- 'id' => 'email_error_text',
895
- 'label' => __('Text for when user filled in email field with invalid email', 'quiz-master-next'),
896
  'type' => 'text',
897
- 'default' => 'Not a valid e-mail address!'
898
  );
899
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
900
 
901
- // Registers number_error_text setting
902
  $field_array = array(
903
- 'id' => 'number_error_text',
904
- 'label' => __('Text for when user has filled in number field with invalid number', 'quiz-master-next'),
905
  'type' => 'text',
906
- 'default' => 'This field must be a number!'
907
  );
908
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
909
 
910
- // Registers incorrect_error_text setting
911
  $field_array = array(
912
- 'id' => 'incorrect_error_text',
913
- 'label' => __('Text for when user has not filled in captcha correctly', 'quiz-master-next'),
914
  'type' => 'text',
915
- 'default' => 'The entered text is not correct!'
916
  );
917
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
918
-
919
- // result page for sharing
920
  $field_array = array(
921
- 'id' => 'result_page_fb_image',
922
- 'label' => __('Add image link for facebook sharing', 'quiz-master-next'),
923
  'type' => 'text',
924
- 'default' => QSM_PLUGIN_URL . 'assets/icon-200x200.png',
925
  );
926
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
 
927
  }
928
 
929
  /**
@@ -960,7 +1069,7 @@ class QSM_Install {
960
  email_from_text TEXT NOT NULL,
961
  question_answer_template TEXT NOT NULL,
962
  leaderboard_template TEXT NOT NULL,
963
- system INT NOT NULL,
964
  randomness_order INT NOT NULL,
965
  loggedin_user_contact INT NOT NULL,
966
  show_score INT NOT NULL,
@@ -1062,6 +1171,7 @@ class QSM_Install {
1062
  quiz_results MEDIUMTEXT NOT NULL,
1063
  deleted INT NOT NULL,
1064
  unique_id varchar(255) NOT NULL,
 
1065
  PRIMARY KEY (result_id)
1066
  ) $charset_collate;";
1067
 
@@ -1519,7 +1629,7 @@ class QSM_Install {
1519
  */
1520
  public function plugin_action_links( $links ) {
1521
  $action_links = array(
1522
- 'settings' => '<a href="' . admin_url( 'admin.php?page=' . QSM_PLUGIN_BASENAME ) . '" title="' . esc_attr( __( 'Quizzes/Surveys', 'quiz-master-next' ) ) . '">' . __( 'Quizzes/Surveys', 'quiz-master-next' ) . '</a>',
1523
  );
1524
  return array_merge( $action_links, $links );
1525
  }
40
  public function register_default_settings() {
41
 
42
  global $mlwQuizMasterNext;
43
+
44
+ // Registers system setting
45
+ $field_array = array(
46
+ 'id' => 'form_type',
47
+ 'label' => __('Quiz Type', 'quiz-master-next'),
48
+ 'type' => 'select',
49
+ 'options' => array(
50
+ array(
51
+ 'label' => __('Quiz', 'quiz-master-next'),
52
+ 'value' => 0
53
+ ),
54
+ array(
55
+ 'label' => __('Survey', 'quiz-master-next'),
56
+ 'value' => 1
57
+ ),
58
+ array(
59
+ 'label' => __('Simple Form', 'quiz-master-next'),
60
+ 'value' => 2
61
+ )
62
+ ),
63
+ 'default' => 0
64
+ );
65
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
66
+
67
  // Registers system setting
68
  $field_array = array(
69
  'id' => 'system',
70
+ 'label' => __('Grading System', 'quiz-master-next'),
71
  'type' => 'radio',
72
  'options' => array(
73
  array(
79
  'value' => 1
80
  ),
81
  array(
82
+ 'label' => __('Both', 'quiz-master-next'),
83
+ 'value' => 3
84
  )
85
  ),
86
+ 'default' => 0,
87
+ 'help' => __('Select the system for grading the quiz.', 'quiz-master-next'),
88
+ 'tooltip' => __('To know more about our grading systems please ', 'quiz-master-next') . '<a target="_blank" href="https://quizandsurveymaster.com/docs/">'. __('read the documentation.', 'quiz-master-next') .'</a>',
89
+ 'show_option' => 'form_type_0'
90
  );
91
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
92
 
93
  // Registers progress_bar setting
94
  $field_array = array(
95
  'id' => 'progress_bar',
96
+ 'label' => __( 'Show progress bar', 'quiz-master-next' ),
97
  'type' => 'radio',
98
  'options' => array(
99
  array(
112
  // Registers require_log_in setting
113
  $field_array = array(
114
  'id' => 'require_log_in',
115
+ 'label' => __('Require User Login', 'quiz-master-next'),
116
  'type' => 'radio',
117
  'options' => array(
118
  array(
124
  'value' => 0
125
  )
126
  ),
127
+ 'default' => 0,
128
+ 'help' => __('Enabling this allows only logged in users to take the quiz','quiz-master-next')
129
  );
130
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
131
 
132
  // Registers pagination setting
133
  $field_array = array(
134
  'id' => 'pagination',
135
+ 'label' => __('Questions Per Page', 'quiz-master-next'),
136
  'type' => 'number',
137
  'options' => array(
138
 
139
  ),
140
+ 'default' => 0,
141
+ 'help' => __('Override the default pagination created on questions tab','quiz-master-next')
142
  );
143
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
144
 
145
  // Registers timer_limit setting
146
  $field_array = array(
147
  'id' => 'timer_limit',
148
+ 'label' => __('Time Limit', 'quiz-master-next'),
149
  'type' => 'number',
150
  'options' => array(
151
 
152
  ),
153
+ 'default' => 0,
154
+ 'help' => __('Leave 0 for no time limit','quiz-master-next')
155
  );
156
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
157
 
158
  // Settings for quick result
159
  $field_array = array(
160
  'id' => 'enable_result_after_timer_end',
161
+ 'label' => __('Force submit after timer expiry', 'quiz-master-next'),
162
  'type' => 'radio',
163
  'options' => array(
164
  array(
177
  // Registers total_user_tries setting
178
  $field_array = array(
179
  'id' => 'total_user_tries',
180
+ 'label' => __('Limit Attempts', 'quiz-master-next'),
181
  'type' => 'number',
182
  'options' => array(
183
 
184
  ),
185
+ 'default' => 0,
186
+ 'help' => __('Leave 0 for unlimited attempts','quiz-master-next'),
187
+ 'tooltip' => __('Limits how many times a user can take the quiz','quiz-master-next')
188
  );
189
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
190
 
191
  // Registers limit_total_entries setting
192
  $field_array = array(
193
  'id' => 'limit_total_entries',
194
+ 'label' => __('Limit Entries', 'quiz-master-next'),
195
  'type' => 'number',
196
  'options' => array(
197
 
198
  ),
199
+ 'default' => 0,
200
+ 'help' => __('Leave 0 for unlimited entries','quiz-master-next'),
201
+ 'tooltip' => __('Limits how many users can take the quiz.','quiz-master-next')
202
  );
203
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
204
 
205
  // Registers question_from_total setting
206
  $field_array = array(
207
  'id' => 'question_from_total',
208
+ 'label' => __('Limit number of Questions', 'quiz-master-next'),
209
  'type' => 'number',
210
  'options' => array(
211
 
212
  ),
213
+ 'default' => 0,
214
+ 'help' => __('Leave 0 to load all questions','quiz-master-next'),
215
+ 'tooltip' => __('Show only limited number of questions from your quiz.','quiz-master-next')
216
  );
217
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
218
 
219
  // Registers scheduled_time_start setting
220
  $field_array = array(
221
  'id' => 'scheduled_time_start',
222
+ 'label' => __('Quiz Dates', 'quiz-master-next'),
223
  'type' => 'date',
224
  'options' => array(
225
 
226
  ),
227
+ 'default' => '',
228
+ 'help' => '',
229
+ 'ph_text' => __('Start Date','quiz-master-next'),
230
+ 'help' => __('If set, Quiz will be accessible only after this date', 'quiz-master-next'),
231
+ 'tooltip' => __( 'Leave blank for no date limit', 'quiz-master-next' )
232
  );
233
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
234
 
235
  // Registers scheduled_time_end setting
236
  $field_array = array(
237
  'id' => 'scheduled_time_end',
238
+ 'label' => '',
239
  'type' => 'date',
240
  'options' => array(
241
 
242
  ),
243
+ 'default' => '',
244
+ 'help' => __(' If set, Quiz will not be accessible after this date','quiz-master-next'),
245
+ 'ph_text' => __('End Date','quiz-master-next')
246
  );
247
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
248
 
249
  // Registers randomness_order setting
250
  $field_array = array(
251
  'id' => 'randomness_order',
252
+ 'label' => __('Random Questions', 'quiz-master-next'),
253
+ 'type' => 'select',
254
  'options' => array(
255
  array(
256
  'label' => __('Random Questions', 'quiz-master-next'),
265
  'value' => 3
266
  ),
267
  array(
268
+ 'label' => __('Disabled', 'quiz-master-next'),
269
  'value' => 0
270
  )
271
  ),
272
+ 'default' => 0,
273
+ 'tooltip' => __('Randomize the order of questions or answers every time a quiz loads', 'quiz')
274
  );
275
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
276
 
277
  // Registers category setting
278
  $field_array = array(
279
  'id' => 'randon_category',
280
+ 'label' => __('Random Questions Categories', 'quiz-master-next'),
281
  'type' => 'category',
282
+ 'default' => '',
283
+ 'help' => __('Questions will load only from selected categories', 'quiz-master-next')
284
  );
285
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
286
 
287
  // Registers contact_info_location setting
288
  $field_array = array(
289
  'id' => 'contact_info_location',
290
+ 'label' => __('Contact form position', 'quiz-master-next'),
291
  'type' => 'radio',
292
  'options' => array(
293
  array(
294
+ 'label' => __('Show before quiz begins', 'quiz-master-next'),
295
  'value' => 0
296
  ),
297
  array(
298
+ 'label' => __('Show after the quiz ends', 'quiz-master-next'),
299
  'value' => 1
300
  )
301
  ),
302
+ 'default' => 0,
303
+ 'help' => __('Select when to display the contact form','quiz-master-next'),
304
+ 'tooltip' => __('The form can be configured in Contact tab','quiz-master-next')
305
  );
306
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
307
 
308
  // Registers loggedin_user_contact setting
309
  $field_array = array(
310
  'id' => 'loggedin_user_contact',
311
+ 'label' => __('Show contact form to logged in users', 'quiz-master-next'),
312
  'type' => 'radio',
313
  'options' => array(
314
  array(
320
  'value' => 1
321
  )
322
  ),
323
+ 'default' => 0,
324
+ 'help' => __('Logged in users can edit their contact information','quiz-master-next'),
325
+ 'tooltip' => __('The information will still get saved if this option is disabled','quiz-master-next')
326
  );
327
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
328
 
329
  // Registers comment_section setting
330
  $field_array = array(
331
  'id' => 'comment_section',
332
+ 'label' => __('Enable comments', 'quiz-master-next'),
333
  'type' => 'radio',
334
  'options' => array(
335
  array(
341
  'value' => 1
342
  )
343
  ),
344
+ 'default' => 1,
345
+ 'help' => __('Allow users to enter their comments after the quiz','quiz-master-next'),
346
  );
347
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
348
 
349
  // Registers question_numbering setting
350
  $field_array = array(
351
  'id' => 'question_numbering',
352
+ 'label' => __('Show question numbers', 'quiz-master-next'),
353
  'type' => 'radio',
354
  'options' => array(
355
  array(
368
  // Registers store_responses setting
369
  $field_array = array(
370
  'id' => 'store_responses',
371
+ 'label' => __( 'Save Responses', 'quiz-master-next' ),
372
  'type' => 'radio',
373
  'options' => array(
374
  array(
380
  'value' => 0
381
  )
382
  ),
383
+ 'default' => 1,
384
+ 'help' => __('The results will be permanently stored in a database', 'quiz-master-next')
385
  );
386
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  // Registers disable_answer_onselect setting
389
  $field_array = array(
390
  'id' => 'disable_answer_onselect',
391
+ 'label' => __('Disable change of answers', 'quiz-master-next'),
392
  'type' => 'radio',
393
  'options' => array(
394
  array(
400
  'value' => 0
401
  )
402
  ),
403
+ 'default' => 0,
404
+ 'help' => __('Works with multiple choice questions only','quiz-master-next'),
405
+ 'tooltip' => __('The question will be disabled once an answer is selected','quiz-master-next'),
406
  );
407
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
408
 
409
  // Registers ajax_show_correct setting
410
  $field_array = array(
411
  'id' => 'ajax_show_correct',
412
+ 'label' => __('Add class for correct/incorrect answers', 'quiz-master-next'),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  'type' => 'radio',
414
  'options' => array(
415
  array(
416
  'label' => __('Yes', 'quiz-master-next'),
 
 
 
 
417
  'value' => 1
418
  ),
419
  array(
420
  'label' => __('No', 'quiz-master-next'),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  'value' => 0
 
 
 
 
 
 
 
 
422
  )
423
  ),
424
+ 'default' => 0,
425
+ 'help' => __('Works with multiple choice questions only','quiz-master-next'),
426
+ 'tooltip' => __('Dynamically add class for incorrect/correct answer after user selects answer.','quiz-master-next'),
427
  );
428
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
429
 
430
  // Registers hide_auto fill setting
431
  $field_array = array(
432
  'id' => 'contact_disable_autofill',
433
+ 'label' => __('Disable auto fill for contact input', 'quiz-master-next'),
434
  'type' => 'radio',
435
  'options' => array(
436
  array(
449
  // Registers show category on front setting
450
  $field_array = array(
451
  'id' => 'show_category_on_front',
452
+ 'label' => __('Display category name on front end', 'quiz-master-next'),
453
  'type' => 'radio',
454
  'options' => array(
455
  array(
468
  // Settings for quick result
469
  $field_array = array(
470
  'id' => 'enable_quick_result_mc',
471
+ 'label' => __('Show results inline', 'quiz-master-next'),
472
  'type' => 'radio',
473
  'options' => array(
474
  array(
480
  'value' => 0
481
  )
482
  ),
483
+ 'default' => 0,
484
+ 'help' => __('Instantly displays the result for each question','quiz-master-next')
485
  );
486
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
487
 
488
  //Setting for retake quiz
489
  $field_array = array(
490
  'id' => 'enable_retake_quiz_button',
491
+ 'label' => __('Retake Quiz', 'quiz-master-next'),
492
  'type' => 'radio',
493
  'options' => array(
494
  array(
500
  'value' => 0
501
  ),
502
  ),
503
+ 'default' => 0,
504
+ 'help' => __('Show a button on result page to retake the quiz', 'quiz-master-next')
505
  );
506
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
507
 
508
  //Setting for pagination of quiz
509
  $field_array = array(
510
  'id' => 'enable_pagination_quiz',
511
+ 'label' => __('Show current page number', 'quiz-master-next'),
512
  'type' => 'radio',
513
  'options' => array(
514
  array(
520
  'value' => 0
521
  ),
522
  ),
523
+ 'default' => 0,
524
  );
525
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
526
 
527
  //Setting for pagination of quiz
528
  $field_array = array(
529
  'id' => 'enable_deselect_option',
530
+ 'label' => __('Deselect Answer', 'quiz-master-next'),
531
  'type' => 'radio',
532
  'options' => array(
533
  array(
539
  'value' => 0
540
  ),
541
  ),
542
+ 'default' => 0,
543
+ 'help' => __('Users are able deselect an answer and leave it blank. Works with Multiple Choice and Horizintal Multiple Choice questions only','quiz-master-next')
544
  );
545
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
546
 
547
  //Setting for animation
548
  $field_array = array(
549
  'id' => 'quiz_animation',
550
+ 'label' => __('Quiz Animation', 'quiz-master-next'),
551
+ 'type' => 'select',
552
  'options' => array(
553
  array(
554
  'label' => __('bounce', 'quiz-master-next'),
599
  );
600
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
601
 
602
+ // result page for sharing
603
+ $field_array = array(
604
+ 'id' => 'result_page_fb_image',
605
+ 'label' => __('Logo URL', 'quiz-master-next'),
606
+ 'type' => 'text',
607
+ 'default' => QSM_PLUGIN_URL . 'assets/icon-200x200.png',
608
+ 'tooltip' => __('Enter the url of an image which will be used as logo while sharing on facebook.', 'quiz-master-next'),
609
+ 'help' => __('If left blank, this will default to QSM logo', 'quiz-master-next')
610
+ );
611
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
612
+
613
+ //Setting for animation
614
+ $field_array = array(
615
+ 'id' => 'legacy_options',
616
+ 'label' => __('Show Legacy Options', 'quiz-master-next'),
617
+ 'type' => 'hide_show',
618
+ 'default' => '',
619
+ 'help' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next' ),
620
+ //'tooltip' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next')
621
+ );
622
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
623
+
624
+ // Registers social_media setting
625
+ $field_array = array(
626
+ 'id' => 'social_media',
627
+ 'label' => __('Social Sharing Buttons', 'quiz-master-next'),
628
+ 'type' => 'radio',
629
+ 'options' => array(
630
+ array(
631
+ 'label' => __('Yes', 'quiz-master-next'),
632
+ 'value' => 1
633
+ ),
634
+ array(
635
+ 'label' => __('No', 'quiz-master-next'),
636
+ 'value' => 0
637
+ )
638
+ ),
639
+ 'default' => 0,
640
+ 'tooltip' => __('Please use the new template variables instead.%FACEBOOK_SHARE% %TWITTER_SHARE%', 'quiz-master-next')
641
+ );
642
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
643
+
644
+ // Registers user_name setting
645
+ $field_array = array(
646
+ 'id' => 'user_name',
647
+ 'label' => __("Ask user's name", 'quiz-master-next'),
648
+ 'type' => 'radio',
649
+ 'options' => array(
650
+ array(
651
+ 'label' => __('No', 'quiz-master-next'),
652
+ 'value' => 2
653
+ ),
654
+ array(
655
+ 'label' => __('Yes', 'quiz-master-next'),
656
+ 'value' => 0
657
+ ),
658
+ array(
659
+ 'label' => __('Require', 'quiz-master-next'),
660
+ 'value' => 1
661
+ ),
662
+
663
+ ),
664
+ 'default' => 2
665
+ );
666
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
667
+
668
+ // Registers user_comp setting
669
+ $field_array = array(
670
+ 'id' => 'user_comp',
671
+ 'label' => __("Ask user's business", 'quiz-master-next'),
672
+ 'type' => 'radio',
673
+ 'options' => array(
674
+ array(
675
+ 'label' => __('No', 'quiz-master-next'),
676
+ 'value' => 2
677
+ ),
678
+ array(
679
+ 'label' => __('Yes', 'quiz-master-next'),
680
+ 'value' => 0
681
+ ),
682
+ array(
683
+ 'label' => __('Require', 'quiz-master-next'),
684
+ 'value' => 1
685
+ )
686
+ ),
687
+ 'default' => 2
688
+ );
689
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
690
+
691
+ // Registers user_email setting
692
+ $field_array = array(
693
+ 'id' => 'user_email',
694
+ 'label' => __("Ask user's email", 'quiz-master-next'),
695
+ 'type' => 'radio',
696
+ 'options' => array(
697
+ array(
698
+ 'label' => __('No', 'quiz-master-next'),
699
+ 'value' => 2
700
+ ),
701
+ array(
702
+ 'label' => __('Yes', 'quiz-master-next'),
703
+ 'value' => 0
704
+ ),
705
+ array(
706
+ 'label' => __('Require', 'quiz-master-next'),
707
+ 'value' => 1
708
+ )
709
+ ),
710
+ 'default' => 2
711
+ );
712
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
713
+
714
+ // Registers user_phone setting
715
+ $field_array = array(
716
+ 'id' => 'user_phone',
717
+ 'label' => __("Ask user's phone", 'quiz-master-next'),
718
+ 'type' => 'radio',
719
+ 'options' => array(
720
+ array(
721
+ 'label' => __('No', 'quiz-master-next'),
722
+ 'value' => 2
723
+ ),
724
+ array(
725
+ 'label' => __('Yes', 'quiz-master-next'),
726
+ 'value' => 0
727
+ ),
728
+ array(
729
+ 'label' => __('Require', 'quiz-master-next'),
730
+ 'value' => 1
731
+ )
732
+ ),
733
+ 'default' => 2
734
+ );
735
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
736
+
737
  // Registers message_before setting
738
  $field_array = array(
739
  'id' => 'message_before',
880
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
881
 
882
  // Registers submit_button_text setting
883
+ $field_array = array(
884
+ 'id' => 'button_section',
885
+ 'label' => __('Buttons', 'quiz-master-next'),
886
+ 'type' => 'section_heading',
887
+ 'default' => 0
888
+ );
889
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
890
+
891
  $field_array = array(
892
  'id' => 'submit_button_text',
893
+ 'label' => __('Submit Button', 'quiz-master-next'),
894
  'type' => 'text',
895
  'default' => 0
896
  );
897
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
898
+
899
+ // Registers previous_button_text setting
900
  $field_array = array(
901
+ 'id' => 'previous_button_text',
902
+ 'label' => __('Previous button', 'quiz-master-next'),
903
  'type' => 'text',
904
  'default' => 0
905
  );
906
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
907
 
908
+ // Registers next_button_text setting
909
  $field_array = array(
910
+ 'id' => 'next_button_text',
911
+ 'label' => __('Next button', 'quiz-master-next'),
912
  'type' => 'text',
913
  'default' => 0
914
  );
915
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
916
+
917
+ // Registers submit_button_text setting
918
+ $field_array = array(
919
+ 'id' => 'validation_text_section',
920
+ 'label' => __('Validation Messages', 'quiz-master-next'),
921
+ 'type' => 'section_heading',
922
+ 'default' => 0
923
+ );
924
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
925
+
926
+ // Registers empty_error_text setting
927
  $field_array = array(
928
+ 'id' => 'empty_error_text',
929
+ 'label' => __('All required fields', 'quiz-master-next'),
930
  'type' => 'text',
931
+ 'default' => 'Please complete all required fields!'
932
  );
933
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
934
 
935
+ // Registers email_error_text setting
936
  $field_array = array(
937
+ 'id' => 'email_error_text',
938
+ 'label' => __('Invalid email', 'quiz-master-next'),
939
  'type' => 'text',
940
+ 'default' => 'Not a valid e-mail address!'
941
  );
942
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
943
 
944
+ // Registers number_error_text setting
945
  $field_array = array(
946
+ 'id' => 'number_error_text',
947
+ 'label' => __('Invalid number', 'quiz-master-next'),
948
  'type' => 'text',
949
+ 'default' => 'This field must be a number!'
950
  );
951
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
952
 
953
+ // Registers incorrect_error_text setting
954
  $field_array = array(
955
+ 'id' => 'incorrect_error_text',
956
+ 'label' => __('Invalid Captcha', 'quiz-master-next'),
957
  'type' => 'text',
958
+ 'default' => 'The entered text is not correct!'
959
+ );
960
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
961
+
962
+ // Registers submit_button_text setting
963
+ $field_array = array(
964
+ 'id' => 'other_text_section',
965
+ 'label' => __('Other', 'quiz-master-next'),
966
+ 'type' => 'section_heading',
967
  'default' => 0
968
  );
969
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
970
+
971
+ // Registers comment_field_text setting
972
  $field_array = array(
973
+ 'id' => 'comment_field_text',
974
+ 'label' => __('Comments field', 'quiz-master-next'),
975
  'type' => 'text',
976
  'default' => 0
977
  );
978
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
979
+
980
  // Registers hint_text setting
981
  $field_array = array(
982
  'id' => 'hint_text',
983
+ 'label' => __('Hint Text', 'quiz-master-next'),
984
  'type' => 'text',
985
  'default' => 'Hint'
986
  );
987
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
988
+
989
+ //Setting for animation
990
  $field_array = array(
991
+ 'id' => 'legacy_options',
992
+ 'label' => __('Show Legacy Options', 'quiz-master-next'),
993
+ 'type' => 'hide_show',
994
+ 'default' => '',
995
+ 'help' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next' ),
996
+ //'tooltip' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next')
997
  );
998
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
999
+
1000
+ // Registers name_field_text setting
1001
  $field_array = array(
1002
+ 'id' => 'name_field_text',
1003
+ 'label' => __('Name field', 'quiz-master-next'),
1004
  'type' => 'text',
1005
+ 'default' => 0
1006
  );
1007
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1008
 
1009
+ // Registers business_field_text setting
1010
  $field_array = array(
1011
+ 'id' => 'business_field_text',
1012
+ 'label' => __('Business field', 'quiz-master-next'),
1013
  'type' => 'text',
1014
+ 'default' => 0
1015
  );
1016
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1017
 
1018
+ // Registers email_field_text setting
1019
  $field_array = array(
1020
+ 'id' => 'email_field_text',
1021
+ 'label' => __('Email field', 'quiz-master-next'),
1022
  'type' => 'text',
1023
+ 'default' => 0
1024
  );
1025
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1026
+
1027
+ // Registers phone_field_text setting
1028
  $field_array = array(
1029
+ 'id' => 'phone_field_text',
1030
+ 'label' => __('Phone number field', 'quiz-master-next'),
1031
  'type' => 'text',
1032
+ 'default' => 0
1033
  );
1034
  $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1035
+
1036
  }
1037
 
1038
  /**
1069
  email_from_text TEXT NOT NULL,
1070
  question_answer_template TEXT NOT NULL,
1071
  leaderboard_template TEXT NOT NULL,
1072
+ quiz_system INT NOT NULL,
1073
  randomness_order INT NOT NULL,
1074
  loggedin_user_contact INT NOT NULL,
1075
  show_score INT NOT NULL,
1171
  quiz_results MEDIUMTEXT NOT NULL,
1172
  deleted INT NOT NULL,
1173
  unique_id varchar(255) NOT NULL,
1174
+ form_type INT NOT NULL,
1175
  PRIMARY KEY (result_id)
1176
  ) $charset_collate;";
1177
 
1629
  */
1630
  public function plugin_action_links( $links ) {
1631
  $action_links = array(
1632
+ 'settings' => '<a href="' . admin_url( 'admin.php?page=mlw_quiz_list' ) . '" title="' . esc_attr( __( 'Quizzes/Surveys', 'quiz-master-next' ) ) . '">' . __( 'Quizzes/Surveys', 'quiz-master-next' ) . '</a>',
1633
  );
1634
  return array_merge( $action_links, $links );
1635
  }
php/classes/class-qsm-settings.php CHANGED
@@ -289,7 +289,7 @@ class QSM_Quiz_Settings {
289
 
290
  // Prepares new quiz_options section's settings
291
  $settings_array['quiz_options'] = serialize( array(
292
- 'system' => $quiz_options->system,
293
  'loggedin_user_contact' => $quiz_options->loggedin_user_contact,
294
  'contact_info_location' => $quiz_options->contact_info_location,
295
  'user_name' => $quiz_options->user_name,
@@ -418,6 +418,7 @@ class QSM_Quiz_Settings {
418
 
419
  $options = $this->get_setting( 'quiz_options' );
420
  if ( is_array( $options ) ) {
 
421
  $quiz_options = array_merge( $quiz_options, $options );
422
  }
423
 
289
 
290
  // Prepares new quiz_options section's settings
291
  $settings_array['quiz_options'] = serialize( array(
292
+ 'system' => $quiz_options->quiz_system,
293
  'loggedin_user_contact' => $quiz_options->loggedin_user_contact,
294
  'contact_info_location' => $quiz_options->contact_info_location,
295
  'user_name' => $quiz_options->user_name,
418
 
419
  $options = $this->get_setting( 'quiz_options' );
420
  if ( is_array( $options ) ) {
421
+ unset( $options['quiz_name'] );
422
  $quiz_options = array_merge( $quiz_options, $options );
423
  }
424
 
php/classes/class-qsm-tracking.php CHANGED
@@ -144,7 +144,7 @@ class QSM_Tracking {
144
  $data['current_version'] = get_option('mlw_quiz_master_version');
145
 
146
  // Configurations of quizzes and surveys
147
- $data['quiz_options'] = $wpdb->get_results( "SELECT quiz_name, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, comment_section, question_from_total, total_user_tries, certificate_template, pagination, timer_limit, question_numbering, theme_selected, last_activity, require_log_in, limit_total_entries, disable_answer_onselect, ajax_show_correct, quiz_views, quiz_taken FROM {$wpdb->prefix}mlw_quizzes WHERE deleted = 0" );
148
 
149
  // All error logs from QSM
150
  $data['error_logs'] = $mlwQuizMasterNext->log_manager->get_logs();
144
  $data['current_version'] = get_option('mlw_quiz_master_version');
145
 
146
  // Configurations of quizzes and surveys
147
+ $data['quiz_options'] = $wpdb->get_results( "SELECT quiz_name, quiz_system as system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, comment_section, question_from_total, total_user_tries, certificate_template, pagination, timer_limit, question_numbering, theme_selected, last_activity, require_log_in, limit_total_entries, disable_answer_onselect, ajax_show_correct, quiz_views, quiz_taken FROM {$wpdb->prefix}mlw_quizzes WHERE deleted = 0" );
148
 
149
  // All error logs from QSM
150
  $data['error_logs'] = $mlwQuizMasterNext->log_manager->get_logs();
php/classes/lib/wp-async-request.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP Async Request
4
+ *
5
+ * @package WP-Background-Processing
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || exit;
9
+
10
+ /**
11
+ * Abstract WP_Async_Request class.
12
+ */
13
+ abstract class WP_Async_Request {
14
+
15
+ /**
16
+ * Prefix
17
+ *
18
+ * (default value: 'wp')
19
+ *
20
+ * @var string
21
+ * @access protected
22
+ */
23
+ protected $prefix = 'wp';
24
+
25
+ /**
26
+ * Action
27
+ *
28
+ * (default value: 'async_request')
29
+ *
30
+ * @var string
31
+ * @access protected
32
+ */
33
+ protected $action = 'async_request';
34
+
35
+ /**
36
+ * Identifier
37
+ *
38
+ * @var mixed
39
+ * @access protected
40
+ */
41
+ protected $identifier;
42
+
43
+ /**
44
+ * Data
45
+ *
46
+ * (default value: array())
47
+ *
48
+ * @var array
49
+ * @access protected
50
+ */
51
+ protected $data = array();
52
+
53
+ /**
54
+ * Initiate new async request
55
+ */
56
+ public function __construct() {
57
+ $this->identifier = $this->prefix . '_' . $this->action;
58
+
59
+ add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
60
+ add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
61
+ }
62
+
63
+ /**
64
+ * Set data used during the request
65
+ *
66
+ * @param array $data Data.
67
+ *
68
+ * @return $this
69
+ */
70
+ public function data( $data ) {
71
+ $this->data = $data;
72
+
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ * Dispatch the async request
78
+ *
79
+ * @return array|WP_Error
80
+ */
81
+ public function dispatch() {
82
+ $url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
83
+ $args = $this->get_post_args();
84
+
85
+ return wp_remote_post( esc_url_raw( $url ), $args );
86
+ }
87
+
88
+ /**
89
+ * Get query args
90
+ *
91
+ * @return array
92
+ */
93
+ protected function get_query_args() {
94
+ if ( property_exists( $this, 'query_args' ) ) {
95
+ return $this->query_args;
96
+ }
97
+
98
+ return array(
99
+ 'action' => $this->identifier,
100
+ 'nonce' => wp_create_nonce( $this->identifier ),
101
+ );
102
+ }
103
+
104
+ /**
105
+ * Get query URL
106
+ *
107
+ * @return string
108
+ */
109
+ protected function get_query_url() {
110
+ if ( property_exists( $this, 'query_url' ) ) {
111
+ return $this->query_url;
112
+ }
113
+
114
+ return admin_url( 'admin-ajax.php' );
115
+ }
116
+
117
+ /**
118
+ * Get post args
119
+ *
120
+ * @return array
121
+ */
122
+ protected function get_post_args() {
123
+ if ( property_exists( $this, 'post_args' ) ) {
124
+ return $this->post_args;
125
+ }
126
+
127
+ return array(
128
+ 'timeout' => 0.01,
129
+ 'blocking' => false,
130
+ 'body' => $this->data,
131
+ 'cookies' => $_COOKIE,
132
+ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
133
+ );
134
+ }
135
+
136
+ /**
137
+ * Maybe handle
138
+ *
139
+ * Check for correct nonce and pass to handler.
140
+ */
141
+ public function maybe_handle() {
142
+ // Don't lock up other requests while processing
143
+ session_write_close();
144
+
145
+ check_ajax_referer( $this->identifier, 'nonce' );
146
+
147
+ $this->handle();
148
+
149
+ wp_die();
150
+ }
151
+
152
+ /**
153
+ * Handle
154
+ *
155
+ * Override this method to perform any actions required
156
+ * during the async request.
157
+ */
158
+ abstract protected function handle();
159
+
160
+ }
php/classes/lib/wp-background-process.php ADDED
@@ -0,0 +1,503 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php // @codingStandardsIgnoreLine.
2
+ /**
3
+ * Abstract WP_Background_Process class.
4
+ *
5
+ * @package WP-Background-Processing
6
+ * @extends WP_Async_Request
7
+ */
8
+
9
+ defined( 'ABSPATH' ) || exit;
10
+
11
+ /**
12
+ * Abstract WP_Background_Process class.
13
+ */
14
+ abstract class WP_Background_Process extends WP_Async_Request {
15
+
16
+ /**
17
+ * Action
18
+ *
19
+ * (default value: 'background_process')
20
+ *
21
+ * @var string
22
+ * @access protected
23
+ */
24
+ protected $action = 'background_process';
25
+
26
+ /**
27
+ * Start time of current process.
28
+ *
29
+ * (default value: 0)
30
+ *
31
+ * @var int
32
+ * @access protected
33
+ */
34
+ protected $start_time = 0;
35
+
36
+ /**
37
+ * Cron_hook_identifier
38
+ *
39
+ * @var mixed
40
+ * @access protected
41
+ */
42
+ protected $cron_hook_identifier;
43
+
44
+ /**
45
+ * Cron_interval_identifier
46
+ *
47
+ * @var mixed
48
+ * @access protected
49
+ */
50
+ protected $cron_interval_identifier;
51
+
52
+ /**
53
+ * Initiate new background process
54
+ */
55
+ public function __construct() {
56
+ parent::__construct();
57
+
58
+ $this->cron_hook_identifier = $this->identifier . '_cron';
59
+ $this->cron_interval_identifier = $this->identifier . '_cron_interval';
60
+
61
+ add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
62
+ add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
63
+ }
64
+
65
+ /**
66
+ * Dispatch
67
+ *
68
+ * @access public
69
+ * @return void
70
+ */
71
+ public function dispatch() {
72
+ // Schedule the cron healthcheck.
73
+ $this->schedule_event();
74
+
75
+ // Perform remote post.
76
+ return parent::dispatch();
77
+ }
78
+
79
+ /**
80
+ * Push to queue
81
+ *
82
+ * @param mixed $data Data.
83
+ *
84
+ * @return $this
85
+ */
86
+ public function push_to_queue( $data ) {
87
+ $this->data[] = $data;
88
+
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Save queue
94
+ *
95
+ * @return $this
96
+ */
97
+ public function save() {
98
+ $key = $this->generate_key();
99
+
100
+ if ( ! empty( $this->data ) ) {
101
+ update_site_option( $key, $this->data );
102
+ }
103
+
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Update queue
109
+ *
110
+ * @param string $key Key.
111
+ * @param array $data Data.
112
+ *
113
+ * @return $this
114
+ */
115
+ public function update( $key, $data ) {
116
+ if ( ! empty( $data ) ) {
117
+ update_site_option( $key, $data );
118
+ }
119
+
120
+ return $this;
121
+ }
122
+
123
+ /**
124
+ * Delete queue
125
+ *
126
+ * @param string $key Key.
127
+ *
128
+ * @return $this
129
+ */
130
+ public function delete( $key ) {
131
+ delete_site_option( $key );
132
+
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * Generate key
138
+ *
139
+ * Generates a unique key based on microtime. Queue items are
140
+ * given a unique key so that they can be merged upon save.
141
+ *
142
+ * @param int $length Length.
143
+ *
144
+ * @return string
145
+ */
146
+ protected function generate_key( $length = 64 ) {
147
+ $unique = md5( microtime() . rand() );
148
+ $prepend = $this->identifier . '_batch_';
149
+
150
+ return substr( $prepend . $unique, 0, $length );
151
+ }
152
+
153
+ /**
154
+ * Maybe process queue
155
+ *
156
+ * Checks whether data exists within the queue and that
157
+ * the process is not already running.
158
+ */
159
+ public function maybe_handle() {
160
+ // Don't lock up other requests while processing
161
+ session_write_close();
162
+
163
+ if ( $this->is_process_running() ) {
164
+ // Background process already running.
165
+ wp_die();
166
+ }
167
+
168
+ if ( $this->is_queue_empty() ) {
169
+ // No data to process.
170
+ wp_die();
171
+ }
172
+
173
+ check_ajax_referer( $this->identifier, 'nonce' );
174
+
175
+ $this->handle();
176
+
177
+ wp_die();
178
+ }
179
+
180
+ /**
181
+ * Is queue empty
182
+ *
183
+ * @return bool
184
+ */
185
+ protected function is_queue_empty() {
186
+ global $wpdb;
187
+
188
+ $table = $wpdb->options;
189
+ $column = 'option_name';
190
+
191
+ if ( is_multisite() ) {
192
+ $table = $wpdb->sitemeta;
193
+ $column = 'meta_key';
194
+ }
195
+
196
+ $key = $this->identifier . '_batch_%';
197
+
198
+ $count = $wpdb->get_var( $wpdb->prepare( "
199
+ SELECT COUNT(*)
200
+ FROM {$table}
201
+ WHERE {$column} LIKE %s
202
+ ", $key ) );
203
+
204
+ return ! ( $count > 0 );
205
+ }
206
+
207
+ /**
208
+ * Is process running
209
+ *
210
+ * Check whether the current process is already running
211
+ * in a background process.
212
+ */
213
+ protected function is_process_running() {
214
+ if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
215
+ // Process already running.
216
+ return true;
217
+ }
218
+
219
+ return false;
220
+ }
221
+
222
+ /**
223
+ * Lock process
224
+ *
225
+ * Lock the process so that multiple instances can't run simultaneously.
226
+ * Override if applicable, but the duration should be greater than that
227
+ * defined in the time_exceeded() method.
228
+ */
229
+ protected function lock_process() {
230
+ $this->start_time = time(); // Set start time of current process.
231
+
232
+ $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
233
+ $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
234
+
235
+ set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
236
+ }
237
+
238
+ /**
239
+ * Unlock process
240
+ *
241
+ * Unlock the process so that other instances can spawn.
242
+ *
243
+ * @return $this
244
+ */
245
+ protected function unlock_process() {
246
+ delete_site_transient( $this->identifier . '_process_lock' );
247
+
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Get batch
253
+ *
254
+ * @return stdClass Return the first batch from the queue
255
+ */
256
+ protected function get_batch() {
257
+ global $wpdb;
258
+
259
+ $table = $wpdb->options;
260
+ $column = 'option_name';
261
+ $key_column = 'option_id';
262
+ $value_column = 'option_value';
263
+
264
+ if ( is_multisite() ) {
265
+ $table = $wpdb->sitemeta;
266
+ $column = 'meta_key';
267
+ $key_column = 'meta_id';
268
+ $value_column = 'meta_value';
269
+ }
270
+
271
+ $key = $this->identifier . '_batch_%';
272
+
273
+ $query = $wpdb->get_row( $wpdb->prepare( "
274
+ SELECT *
275
+ FROM {$table}
276
+ WHERE {$column} LIKE %s
277
+ ORDER BY {$key_column} ASC
278
+ LIMIT 1
279
+ ", $key ) );
280
+
281
+ $batch = new stdClass();
282
+ $batch->key = $query->$column;
283
+ $batch->data = maybe_unserialize( $query->$value_column );
284
+
285
+ return $batch;
286
+ }
287
+
288
+ /**
289
+ * Handle
290
+ *
291
+ * Pass each queue item to the task handler, while remaining
292
+ * within server memory and time limit constraints.
293
+ */
294
+ protected function handle() {
295
+ $this->lock_process();
296
+
297
+ do {
298
+ $batch = $this->get_batch();
299
+
300
+ foreach ( $batch->data as $key => $value ) {
301
+ $task = $this->task( $value );
302
+
303
+ if ( false !== $task ) {
304
+ $batch->data[ $key ] = $task;
305
+ } else {
306
+ unset( $batch->data[ $key ] );
307
+ }
308
+
309
+ if ( $this->time_exceeded() || $this->memory_exceeded() ) {
310
+ // Batch limits reached.
311
+ break;
312
+ }
313
+ }
314
+
315
+ // Update or delete current batch.
316
+ if ( ! empty( $batch->data ) ) {
317
+ $this->update( $batch->key, $batch->data );
318
+ } else {
319
+ $this->delete( $batch->key );
320
+ }
321
+ } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
322
+
323
+ $this->unlock_process();
324
+
325
+ // Start next batch or complete process.
326
+ if ( ! $this->is_queue_empty() ) {
327
+ $this->dispatch();
328
+ } else {
329
+ $this->complete();
330
+ }
331
+
332
+ wp_die();
333
+ }
334
+
335
+ /**
336
+ * Memory exceeded
337
+ *
338
+ * Ensures the batch process never exceeds 90%
339
+ * of the maximum WordPress memory.
340
+ *
341
+ * @return bool
342
+ */
343
+ protected function memory_exceeded() {
344
+ $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
345
+ $current_memory = memory_get_usage( true );
346
+ $return = false;
347
+
348
+ if ( $current_memory >= $memory_limit ) {
349
+ $return = true;
350
+ }
351
+
352
+ return apply_filters( $this->identifier . '_memory_exceeded', $return );
353
+ }
354
+
355
+ /**
356
+ * Get memory limit
357
+ *
358
+ * @return int
359
+ */
360
+ protected function get_memory_limit() {
361
+ if ( function_exists( 'ini_get' ) ) {
362
+ $memory_limit = ini_get( 'memory_limit' );
363
+ } else {
364
+ // Sensible default.
365
+ $memory_limit = '128M';
366
+ }
367
+
368
+ if ( ! $memory_limit || -1 === $memory_limit ) {
369
+ // Unlimited, set to 32GB.
370
+ $memory_limit = '32000M';
371
+ }
372
+
373
+ return intval( $memory_limit ) * 1024 * 1024;
374
+ }
375
+
376
+ /**
377
+ * Time exceeded.
378
+ *
379
+ * Ensures the batch never exceeds a sensible time limit.
380
+ * A timeout limit of 30s is common on shared hosting.
381
+ *
382
+ * @return bool
383
+ */
384
+ protected function time_exceeded() {
385
+ $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
386
+ $return = false;
387
+
388
+ if ( time() >= $finish ) {
389
+ $return = true;
390
+ }
391
+
392
+ return apply_filters( $this->identifier . '_time_exceeded', $return );
393
+ }
394
+
395
+ /**
396
+ * Complete.
397
+ *
398
+ * Override if applicable, but ensure that the below actions are
399
+ * performed, or, call parent::complete().
400
+ */
401
+ protected function complete() {
402
+ // Unschedule the cron healthcheck.
403
+ $this->clear_scheduled_event();
404
+ }
405
+
406
+ /**
407
+ * Schedule cron healthcheck
408
+ *
409
+ * @access public
410
+ * @param mixed $schedules Schedules.
411
+ * @return mixed
412
+ */
413
+ public function schedule_cron_healthcheck( $schedules ) {
414
+ $interval = apply_filters( $this->identifier . '_cron_interval', 5 );
415
+
416
+ if ( property_exists( $this, 'cron_interval' ) ) {
417
+ $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval );
418
+ }
419
+
420
+ // Adds every 5 minutes to the existing schedules.
421
+ $schedules[ $this->identifier . '_cron_interval' ] = array(
422
+ 'interval' => MINUTE_IN_SECONDS * $interval,
423
+ 'display' => sprintf( __( 'Every %d Minutes' ), $interval ),
424
+ );
425
+
426
+ return $schedules;
427
+ }
428
+
429
+ /**
430
+ * Handle cron healthcheck
431
+ *
432
+ * Restart the background process if not already running
433
+ * and data exists in the queue.
434
+ */
435
+ public function handle_cron_healthcheck() {
436
+ if ( $this->is_process_running() ) {
437
+ // Background process already running.
438
+ exit;
439
+ }
440
+
441
+ if ( $this->is_queue_empty() ) {
442
+ // No data to process.
443
+ $this->clear_scheduled_event();
444
+ exit;
445
+ }
446
+
447
+ $this->handle();
448
+
449
+ exit;
450
+ }
451
+
452
+ /**
453
+ * Schedule event
454
+ */
455
+ protected function schedule_event() {
456
+ if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
457
+ wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
458
+ }
459
+ }
460
+
461
+ /**
462
+ * Clear scheduled event
463
+ */
464
+ protected function clear_scheduled_event() {
465
+ $timestamp = wp_next_scheduled( $this->cron_hook_identifier );
466
+
467
+ if ( $timestamp ) {
468
+ wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
469
+ }
470
+ }
471
+
472
+ /**
473
+ * Cancel Process
474
+ *
475
+ * Stop processing queue items, clear cronjob and delete batch.
476
+ *
477
+ */
478
+ public function cancel_process() {
479
+ if ( ! $this->is_queue_empty() ) {
480
+ $batch = $this->get_batch();
481
+
482
+ $this->delete( $batch->key );
483
+
484
+ wp_clear_scheduled_hook( $this->cron_hook_identifier );
485
+ }
486
+
487
+ }
488
+
489
+ /**
490
+ * Task
491
+ *
492
+ * Override this method to perform any actions required on each
493
+ * queue item. Return the modified item for further processing
494
+ * in the next pass through. Or, return false to remove the
495
+ * item from the queue.
496
+ *
497
+ * @param mixed $item Queue item to iterate over.
498
+ *
499
+ * @return mixed
500
+ */
501
+ abstract protected function task( $item );
502
+
503
+ }
php/question-types.php CHANGED
@@ -42,7 +42,8 @@ function qmn_file_upload_display($id, $question, $answers)
42
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
43
  if ($required == 0) {$mlw_requireClass = "mlwRequiredFileUpload";} else {$mlw_requireClass = "";}
44
  //$question_title = apply_filters('the_content', $question);
45
- $question_display .= qsm_question_title_func($question);
 
46
  $question_display .= "<input type='file' class='mlw_answer_file_upload $mlw_requireClass'/>";
47
  $question_display .= "<div style='display: none;' class='remove-uploaded-file'><span class='dashicons dashicons-trash'></span></div>";
48
  $question_display .= "<input class='mlw_file_upload_hidden_value' type='hidden' name='question".$id."' value='' />";
@@ -104,9 +105,10 @@ function qmn_multiple_choice_display($id, $question, $answers)
104
  global $mlwQuizMasterNext;
105
  $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
106
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
 
107
  if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
108
- //$question_title = apply_filters('the_content', $question);
109
- $question_display .= qsm_question_title_func($question,'multiple_choice');
110
  $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
111
  if (is_array($answers))
112
  {
@@ -201,7 +203,8 @@ function qmn_date_display($id, $question, $answers)
201
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
202
  if ($required == 0) {$mlw_requireClass = "mlwRequiredDate";} else {$mlw_requireClass = "";}
203
  //$question_title = apply_filters('the_content', $question);
204
- $question_display .= qsm_question_title_func($question);
 
205
  $question_display .= "<input type='date' class='mlw_answer_date $mlw_requireClass' name='question".$id."' id='question".$id."' value=''/>";
206
  //$question_display .= "<script>jQuery(document).ready(function () { jQuery('#question".$id."').datepicker(); });</script>";
207
  return apply_filters('qmn_date_display_front',$question_display,$id, $question, $answers);
@@ -272,7 +275,8 @@ function qmn_horizontal_multiple_choice_display($id, $question, $answers)
272
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
273
  if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
274
  //$question_title = apply_filters('the_content', $question);
275
- $question_display .= qsm_question_title_func($question,'horizontal_multiple_choice');
 
276
  $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
277
  if (is_array($answers))
278
  {
@@ -367,7 +371,8 @@ function qmn_drop_down_display($id, $question, $answers)
367
  $require_class = "";
368
  }
369
  //$question_title = apply_filters('the_content', $question);
370
- $question_display .= qsm_question_title_func($question);
 
371
  $question_display .= "<select class='qsm_select $require_class' name='question".$id."'>";
372
  $question_display .= "<option value='No Answer Provided'>" . __('Please select your answer','quiz-master-next') . "</option>";
373
  if (is_array($answers))
@@ -461,7 +466,8 @@ function qmn_small_open_display($id, $question, $answers)
461
  $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' " : '';
462
  if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
463
  //$question_title = apply_filters('the_content', $question);
464
- $question_display .= qsm_question_title_func($question);
 
465
  $question_display .= "<input ". $autofill_att . $limit_text_att . " type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$id."' />";
466
  return apply_filters('qmn_small_open_display_front',$question_display,$id, $question, $answers);
467
  }
@@ -537,7 +543,8 @@ function qmn_multiple_response_display($id, $question, $answers)
537
  $limit_mr_text = 'onchange="qsmCheckMR(this,'. $limit_multiple_response .')"';
538
  if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
539
  //$question_title = apply_filters('the_content', $question);
540
- $question_display .= qsm_question_title_func($question);
 
541
  $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
542
  if (is_array($answers))
543
  {
@@ -638,7 +645,8 @@ function qmn_large_open_display($id, $question, $answers)
638
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
639
  if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
640
  //$question_title = apply_filters('the_content', $question);
641
- $question_display .= qsm_question_title_func($question);
 
642
  $question_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$id."' /></textarea>";
643
  return apply_filters('qmn_large_open_display_front',$question_display,$id, $question, $answers);
644
  }
@@ -754,7 +762,8 @@ function qmn_number_display($id, $question, $answers)
754
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
755
  if ($required == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
756
  //$question_title = apply_filters('the_content', $question);
757
- $question_display .= qsm_question_title_func($question);
 
758
  $question_display .= "<input type='number' class='mlw_answer_number $mlw_requireClass' name='question".$id."' />";
759
  return apply_filters('qmn_number_display_front',$question_display,$id, $question, $answers);
760
  }
@@ -938,7 +947,8 @@ function qmn_horizontal_multiple_response_display($id, $question, $answers)
938
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
939
  if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
940
  //$question_title = apply_filters('the_content', $question);
941
- $question_display .= qsm_question_title_func($question);
 
942
  $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
943
  if (is_array($answers))
944
  {
@@ -1066,7 +1076,8 @@ function qmn_fill_blank_display($id, $question, $answers)
1066
  $question = str_replace( "%BLANK%", $input_text, do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
1067
  }
1068
  //$question_title = apply_filters('the_content', $question);
1069
- $question_display .= qsm_question_title_func($question);
 
1070
  return apply_filters('qmn_fill_blank_display_front',$question_display,$id, $question, $answers);
1071
  }
1072
 
@@ -1264,13 +1275,14 @@ function qmn_polar_review($id, $question, $answers) {
1264
  return $return_array;
1265
  }
1266
 
1267
- function qsm_question_title_func($question,$question_type = ''){
1268
  //$question_title = apply_filters('the_content', $question);
1269
  $question_title = $question;
1270
  global $wp_embed,$mlwQuizMasterNext;
1271
  $question_title = $wp_embed->run_shortcode($question_title);
1272
  $question_title = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i","<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>",$question_title);
1273
  $polar_extra_class = '';
 
1274
  if($question_type == 'polar'){
1275
  $polar_extra_class = 'question-type-polar-s';
1276
  }
@@ -1279,7 +1291,12 @@ function qsm_question_title_func($question,$question_type = ''){
1279
  if( isset($qmn_quiz_options->enable_deselect_option) && $qmn_quiz_options->enable_deselect_option == 1 && ($question_type == 'multiple_choice' || $question_type == 'horizontal_multiple_choice') ){
1280
  $deselect_answer = '<a href="#" class="qsm-deselect-answer">Deselect Answer</a>';
1281
  }
1282
- $question_display = "<span class='mlw_qmn_question {$polar_extra_class}' >" . do_shortcode( htmlspecialchars_decode( $question_title, ENT_QUOTES ) ) . $deselect_answer . "</span>";
 
 
 
 
 
1283
  return $question_display;
1284
  }
1285
  ?>
42
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
43
  if ($required == 0) {$mlw_requireClass = "mlwRequiredFileUpload";} else {$mlw_requireClass = "";}
44
  //$question_title = apply_filters('the_content', $question);
45
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
46
+ $question_display .= qsm_question_title_func($question,'',$new_question_title);
47
  $question_display .= "<input type='file' class='mlw_answer_file_upload $mlw_requireClass'/>";
48
  $question_display .= "<div style='display: none;' class='remove-uploaded-file'><span class='dashicons dashicons-trash'></span></div>";
49
  $question_display .= "<input class='mlw_file_upload_hidden_value' type='hidden' name='question".$id."' value='' />";
105
  global $mlwQuizMasterNext;
106
  $answerEditor = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'answerEditor');
107
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
108
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
109
  if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
110
+ //$question_title = apply_filters('the_content', $question);
111
+ $question_display .= qsm_question_title_func($question,'multiple_choice',$new_question_title);
112
  $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
113
  if (is_array($answers))
114
  {
203
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
204
  if ($required == 0) {$mlw_requireClass = "mlwRequiredDate";} else {$mlw_requireClass = "";}
205
  //$question_title = apply_filters('the_content', $question);
206
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
207
+ $question_display .= qsm_question_title_func($question,'',$new_question_title);
208
  $question_display .= "<input type='date' class='mlw_answer_date $mlw_requireClass' name='question".$id."' id='question".$id."' value=''/>";
209
  //$question_display .= "<script>jQuery(document).ready(function () { jQuery('#question".$id."').datepicker(); });</script>";
210
  return apply_filters('qmn_date_display_front',$question_display,$id, $question, $answers);
275
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
276
  if ($required == 0) {$mlw_requireClass = "mlwRequiredRadio";} else {$mlw_requireClass = "";}
277
  //$question_title = apply_filters('the_content', $question);
278
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
279
+ $question_display .= qsm_question_title_func($question,'horizontal_multiple_choice',$new_question_title);
280
  $question_display .= "<div class='qmn_radio_answers $mlw_requireClass'>";
281
  if (is_array($answers))
282
  {
371
  $require_class = "";
372
  }
373
  //$question_title = apply_filters('the_content', $question);
374
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
375
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
376
  $question_display .= "<select class='qsm_select $require_class' name='question".$id."'>";
377
  $question_display .= "<option value='No Answer Provided'>" . __('Please select your answer','quiz-master-next') . "</option>";
378
  if (is_array($answers))
466
  $limit_text_att = $limit_text ? "maxlength='". $limit_text ."' " : '';
467
  if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
468
  //$question_title = apply_filters('the_content', $question);
469
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
470
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
471
  $question_display .= "<input ". $autofill_att . $limit_text_att . " type='text' class='mlw_answer_open_text $mlw_requireClass' name='question".$id."' />";
472
  return apply_filters('qmn_small_open_display_front',$question_display,$id, $question, $answers);
473
  }
543
  $limit_mr_text = 'onchange="qsmCheckMR(this,'. $limit_multiple_response .')"';
544
  if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
545
  //$question_title = apply_filters('the_content', $question);
546
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
547
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
548
  $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
549
  if (is_array($answers))
550
  {
645
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
646
  if ($required == 0) {$mlw_requireClass = "mlwRequiredText";} else {$mlw_requireClass = "";}
647
  //$question_title = apply_filters('the_content', $question);
648
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
649
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
650
  $question_display .= "<textarea class='mlw_answer_open_text $mlw_requireClass' cols='70' rows='5' name='question".$id."' /></textarea>";
651
  return apply_filters('qmn_large_open_display_front',$question_display,$id, $question, $answers);
652
  }
762
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
763
  if ($required == 0) {$mlw_requireClass = "mlwRequiredNumber";} else {$mlw_requireClass = "";}
764
  //$question_title = apply_filters('the_content', $question);
765
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
766
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
767
  $question_display .= "<input type='number' class='mlw_answer_number $mlw_requireClass' name='question".$id."' />";
768
  return apply_filters('qmn_number_display_front',$question_display,$id, $question, $answers);
769
  }
947
  $required = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'required');
948
  if ($required == 0) {$mlw_requireClass = "mlwRequiredCheck";} else {$mlw_requireClass = "";}
949
  //$question_title = apply_filters('the_content', $question);
950
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
951
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
952
  $question_display .= "<div class='qmn_check_answers $mlw_requireClass'>";
953
  if (is_array($answers))
954
  {
1076
  $question = str_replace( "%BLANK%", $input_text, do_shortcode(htmlspecialchars_decode($question, ENT_QUOTES)));
1077
  }
1078
  //$question_title = apply_filters('the_content', $question);
1079
+ $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting($id, 'question_title');
1080
+ $question_display .= qsm_question_title_func($question, '', $new_question_title);
1081
  return apply_filters('qmn_fill_blank_display_front',$question_display,$id, $question, $answers);
1082
  }
1083
 
1275
  return $return_array;
1276
  }
1277
 
1278
+ function qsm_question_title_func($question,$question_type = '',$new_question_title=''){
1279
  //$question_title = apply_filters('the_content', $question);
1280
  $question_title = $question;
1281
  global $wp_embed,$mlwQuizMasterNext;
1282
  $question_title = $wp_embed->run_shortcode($question_title);
1283
  $question_title = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i","<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>",$question_title);
1284
  $polar_extra_class = '';
1285
+ $question_display = '';
1286
  if($question_type == 'polar'){
1287
  $polar_extra_class = 'question-type-polar-s';
1288
  }
1291
  if( isset($qmn_quiz_options->enable_deselect_option) && $qmn_quiz_options->enable_deselect_option == 1 && ($question_type == 'multiple_choice' || $question_type == 'horizontal_multiple_choice') ){
1292
  $deselect_answer = '<a href="#" class="qsm-deselect-answer">Deselect Answer</a>';
1293
  }
1294
+
1295
+ if($new_question_title != ''){
1296
+ $question_display .= "<span class='mlw_qmn_new_question'>" . sanitize_text_field( htmlspecialchars_decode( $new_question_title, ENT_QUOTES ) ) . "</span>";
1297
+ $polar_extra_class .= ' qsm_remove_bold';
1298
+ }
1299
+ $question_display .= "<span class='mlw_qmn_question {$polar_extra_class}' >" . do_shortcode( htmlspecialchars_decode( $question_title, ENT_QUOTES ) ) . $deselect_answer . "</span>";
1300
  return $question_display;
1301
  }
1302
  ?>
php/rest-api.php CHANGED
@@ -112,6 +112,7 @@ function qsm_rest_get_bank_questions( WP_REST_Request $request ){
112
  'id' => $question['question_id'],
113
  'quizID' => $question['quiz_id'],
114
  'type' => $question['question_type_new'],
 
115
  'name' => $question['question_name'],
116
  'answerInfo' => $question['question_answer_info'],
117
  'comments' => $question['comments'],
@@ -127,6 +128,7 @@ function qsm_rest_get_bank_questions( WP_REST_Request $request ){
127
  'file_upload_limit' => isset($question['settings']['file_upload_limit']) ? $question['settings']['file_upload_limit'] : 0,
128
  'file_upload_type' => isset($question['settings']['file_upload_type']) ? $question['settings']['file_upload_type'] : '',
129
  'quiz_name' => isset($quiz_name['quiz_name']) ? $quiz_name['quiz_name'] : '',
 
130
  );
131
  }
132
  return $question_array;
@@ -152,15 +154,21 @@ function qsm_get_result_of_quiz( WP_REST_Request $request ){
152
  if($mlw_quiz_data){
153
  $result_data = array();
154
  foreach ($mlw_quiz_data as $mlw_quiz_info) {
155
- if ( $mlw_quiz_info->quiz_system == 0 ) {
156
- $quotes_list = "" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%";
157
- }
158
- if ( $mlw_quiz_info->quiz_system == 1 ) {
159
- $quotes_list = "" . $mlw_quiz_info->point_score . " Points";
160
- }
161
- if ( $mlw_quiz_info->quiz_system == 2 ) {
162
  $quotes_list = "".__('Not Graded','quiz-master-next' )."";
163
- }
 
 
 
 
 
 
 
 
 
 
 
164
  //Time to complete
165
  $mlw_complete_time = '';
166
  $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
@@ -350,6 +358,7 @@ function qsm_rest_get_question( WP_REST_Request $request ) {
350
  'required' => $question['settings']['required'],
351
  'answers' => $question['answers'],
352
  'page' => $question['page'],
 
353
  );
354
  }
355
  return $question;
@@ -404,6 +413,8 @@ function qsm_rest_get_questions( WP_REST_Request $request ) {
404
  'file_upload_limit' => isset($question['settings']['file_upload_limit']) ? $question['settings']['file_upload_limit'] : 0,
405
  'file_upload_type' => isset($question['settings']['file_upload_type']) ? $question['settings']['file_upload_type'] : '',
406
  'quiz_name' => isset($quiz_name['quiz_name']) ? $quiz_name['quiz_name'] : '',
 
 
407
  );
408
  }
409
  return $question_array;
@@ -441,7 +452,8 @@ function qsm_rest_create_question( WP_REST_Request $request ) {
441
  );
442
  $settings = array(
443
  'required' => $request['required'],
444
- 'answerEditor' => 'text'
 
445
  );
446
  $intial_answers = $request['answers'];
447
  $answers = array();
@@ -476,7 +488,7 @@ function qsm_rest_create_question( WP_REST_Request $request ) {
476
  * @return array An array that contains the key 'id' for the new question.
477
  */
478
  function qsm_rest_save_question( WP_REST_Request $request ) {
479
-
480
  // Makes sure user is logged in.
481
  if ( is_user_logged_in() ) {
482
  $current_user = wp_get_current_user();
@@ -493,15 +505,25 @@ function qsm_rest_save_question( WP_REST_Request $request ) {
493
  'order' => 1,
494
  'category' => $request['category'],
495
  );
 
 
 
 
 
 
 
 
 
496
  $settings = array(
497
- 'required' => $request['required'],
498
- 'answerEditor' => $request['answerEditor'],
499
  'autofill' => $request['autofill'],
500
  'limit_text' => $request['limit_text'],
501
  'limit_multiple_response' => $request['limit_multiple_response'],
502
  'file_upload_limit' => $request['file_upload_limit'],
503
  'file_upload_type' => $request['file_upload_type'],
504
- );
 
 
505
  $intial_answers = $request['answers'];
506
  $answers = array();
507
  if ( is_array( $intial_answers ) ) {
112
  'id' => $question['question_id'],
113
  'quizID' => $question['quiz_id'],
114
  'type' => $question['question_type_new'],
115
+ 'question_title' => isset($question['settings']['question_title']) ? $question['settings']['question_title'] : 0,
116
  'name' => $question['question_name'],
117
  'answerInfo' => $question['question_answer_info'],
118
  'comments' => $question['comments'],
128
  'file_upload_limit' => isset($question['settings']['file_upload_limit']) ? $question['settings']['file_upload_limit'] : 0,
129
  'file_upload_type' => isset($question['settings']['file_upload_type']) ? $question['settings']['file_upload_type'] : '',
130
  'quiz_name' => isset($quiz_name['quiz_name']) ? $quiz_name['quiz_name'] : '',
131
+ 'question_title' => isset($question['settings']['question_title']) ? $question['settings']['question_title'] : '',
132
  );
133
  }
134
  return $question_array;
154
  if($mlw_quiz_data){
155
  $result_data = array();
156
  foreach ($mlw_quiz_data as $mlw_quiz_info) {
157
+ $form_type = isset( $mlw_quiz_info->form_type ) ? $mlw_quiz_info->form_type : 0;
158
+ if( $form_type == 1 || $form_type == 2 ){
 
 
 
 
 
159
  $quotes_list = "".__('Not Graded','quiz-master-next' )."";
160
+ }else{
161
+ if ( $mlw_quiz_info->quiz_system == 0 ) {
162
+ $quotes_list = "" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%";
163
+ }
164
+ if ( $mlw_quiz_info->quiz_system == 1 ) {
165
+ $quotes_list = "" . $mlw_quiz_info->point_score . " Points";
166
+ }
167
+ if ( $mlw_quiz_info->quiz_system == 3 ) {
168
+ $quotes_list = "" . $mlw_quiz_info->correct ." out of ".$mlw_quiz_info->total." or ".$mlw_quiz_info->correct_score."%<br/>";
169
+ $quotes_list = "" . $mlw_quiz_info->point_score . " Points";
170
+ }
171
+ }
172
  //Time to complete
173
  $mlw_complete_time = '';
174
  $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results);
358
  'required' => $question['settings']['required'],
359
  'answers' => $question['answers'],
360
  'page' => $question['page'],
361
+ 'question_title' => isset($question['settings']['question_title']) ? $question['settings']['question_title'] : '',
362
  );
363
  }
364
  return $question;
413
  'file_upload_limit' => isset($question['settings']['file_upload_limit']) ? $question['settings']['file_upload_limit'] : 0,
414
  'file_upload_type' => isset($question['settings']['file_upload_type']) ? $question['settings']['file_upload_type'] : '',
415
  'quiz_name' => isset($quiz_name['quiz_name']) ? $quiz_name['quiz_name'] : '',
416
+ 'question_title' => isset($question['settings']['question_title']) ? $question['settings']['question_title'] : '',
417
+ 'settings' => $question['settings']
418
  );
419
  }
420
  return $question_array;
452
  );
453
  $settings = array(
454
  'required' => $request['required'],
455
+ 'answerEditor' => 'text',
456
+ 'question_title' => $request['name']
457
  );
458
  $intial_answers = $request['answers'];
459
  $answers = array();
488
  * @return array An array that contains the key 'id' for the new question.
489
  */
490
  function qsm_rest_save_question( WP_REST_Request $request ) {
491
+
492
  // Makes sure user is logged in.
493
  if ( is_user_logged_in() ) {
494
  $current_user = wp_get_current_user();
505
  'order' => 1,
506
  'category' => $request['category'],
507
  );
508
+ $settings = array();
509
+ $settings['answerEditor'] = $request['answerEditor'];
510
+ $settings['question_title'] = sanitize_text_field( $request['question_title'] );
511
+ if( isset($request['other_settings']) && is_array($request['other_settings']) ){
512
+ foreach ($request['other_settings'] as $setting_key => $setting_value) {
513
+ $settings[$setting_key] = $setting_value;
514
+ }
515
+ }
516
+ /* Old code
517
  $settings = array(
518
+ 'required' => $request['required'],
 
519
  'autofill' => $request['autofill'],
520
  'limit_text' => $request['limit_text'],
521
  'limit_multiple_response' => $request['limit_multiple_response'],
522
  'file_upload_limit' => $request['file_upload_limit'],
523
  'file_upload_type' => $request['file_upload_type'],
524
+ 'question_title' => $request['question_title'],
525
+ 'answerEditor' => $request['answerEditor'],
526
+ ); */
527
  $intial_answers = $request['answers'];
528
  $answers = array();
529
  if ( is_array( $intial_answers ) ) {
php/shortcodes.php CHANGED
@@ -167,8 +167,11 @@ function qsm_generate_fb_header_metadata() {
167
  //Fb share description
168
  $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'facebook_sharing_text', '');
169
  $sharing = apply_filters('mlw_qmn_template_variable_results_page', $sharing, $results_array);
170
- $default_fb_image = QSM_PLUGIN_URL . 'assets/icon-200x200.png';
171
- $get_fb_sharing_image = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'result_page_fb_image', '');
 
 
 
172
  if ($get_fb_sharing_image !== '') {
173
  $default_fb_image = $get_fb_sharing_image;
174
  }
167
  //Fb share description
168
  $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'facebook_sharing_text', '');
169
  $sharing = apply_filters('mlw_qmn_template_variable_results_page', $sharing, $results_array);
170
+ $default_fb_image = QSM_PLUGIN_URL . 'assets/icon-200x200.png';
171
+ $get_fb_sharing_image = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'result_page_fb_image', '');
172
+ if( empty( $get_fb_sharing_image ) ) {
173
+ $get_fb_sharing_image = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_text', 'result_page_fb_image', '');
174
+ }
175
  if ($get_fb_sharing_image !== '') {
176
  $default_fb_image = $get_fb_sharing_image;
177
  }
php/template-variables.php CHANGED
@@ -95,7 +95,11 @@ function qsm_variable_single_question_answer( $content, $mlw_quiz_array ){
95
  $question_answer_class = "qmn_question_answer_incorrect";
96
  }
97
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
98
- $mlw_question_answer_display = str_replace( "%QUESTION%" , '<b>' . htmlspecialchars_decode($answer[0], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
 
 
 
 
99
  $mlw_question_answer_display = qsm_question_title_func($mlw_question_answer_display);
100
  if($answer['question_type'] == 11){
101
  $file_extension = substr($answer[1], -4);
@@ -106,10 +110,19 @@ function qsm_variable_single_question_answer( $content, $mlw_quiz_array ){
106
  }
107
  }else{
108
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , "<span class='$user_answer_class'>".htmlspecialchars_decode($answer[1], ENT_QUOTES).'</span>', $mlw_question_answer_display);
109
- }
110
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , htmlspecialchars_decode($answer[2], ENT_QUOTES), $mlw_question_answer_display);
111
- $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $answer[3], $mlw_question_answer_display);
112
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($qmn_questions[$answer['id']], ENT_QUOTES), $mlw_question_answer_display);
 
 
 
 
 
 
 
 
 
113
  $display = "<div class='qmn_question_answer $question_answer_class'>".apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array).'</div>';
114
  $content = str_replace( "%QUESTION_ANSWER_". $question_id ."%" , $display, $content);
115
  }
@@ -349,7 +362,12 @@ function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
349
  global $mlwQuizMasterNext;
350
  global $wpdb;
351
  $display = '';
352
- $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
 
 
 
 
 
353
  $questions = QSM_Questions::load_questions_by_pages( $mlw_quiz_array['quiz_id'] );
354
  $qmn_questions = array();
355
  foreach ( $questions as $question ) {
@@ -358,17 +376,38 @@ function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
358
 
359
  // Cycles through each answer in the responses.
360
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
361
- if ( $answer["correct"] === "correct" ){
362
- $user_answer_class = "qmn_user_correct_answer";
363
- $question_answer_class = "qmn_question_answer_correct";
364
- } else {
365
- $user_answer_class = "qmn_user_incorrect_answer";
366
- $question_answer_class = "qmn_question_answer_incorrect";
367
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
369
- $mlw_question_answer_display = str_replace( "%QUESTION%" , '<b>' . htmlspecialchars_decode($answer[0], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
 
 
 
 
370
  $mlw_question_answer_display = qsm_question_title_func($mlw_question_answer_display);
371
- if($answer['question_type'] == 11){
372
  $file_extension = substr($answer[1], -4);
373
  if($file_extension == '.jpg' || $file_extension == 'jepg' || $file_extension == '.png' || $file_extension == '.gif'){
374
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , "<span class='$user_answer_class'><img src='$answer[1]'/></span>", $mlw_question_answer_display);
@@ -377,10 +416,14 @@ function mlw_qmn_variable_question_answers( $content, $mlw_quiz_array ) {
377
  }
378
  }else{
379
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , "<span class='$user_answer_class'>".htmlspecialchars_decode($answer[1], ENT_QUOTES).'</span>', $mlw_question_answer_display);
380
- }
381
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , htmlspecialchars_decode($answer[2], ENT_QUOTES), $mlw_question_answer_display);
382
- $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $answer[3], $mlw_question_answer_display);
383
- $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($qmn_questions[$answer['id']], ENT_QUOTES), $mlw_question_answer_display);
 
 
 
 
384
  $display .= "<div class='qmn_question_answer $question_answer_class'>".apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array).'</div>';
385
  }
386
  $content = str_replace( "%QUESTIONS_ANSWERS%" , $display, $content);
@@ -693,4 +736,40 @@ function qsm_end_results_rank($result_display, $qmn_quiz_options, $qmn_array_for
693
  $result_display = str_replace("%RANK%", $mlw_rank, $result_display);
694
 
695
  return $result_display;
696
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  $question_answer_class = "qmn_question_answer_incorrect";
96
  }
97
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
98
+ if( isset( $answer['question_title'] ) && $answer['question_title'] != '' ){
99
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , '<b>' . htmlspecialchars_decode($answer['question_title'], ENT_QUOTES) . '</b><br />' . htmlspecialchars_decode($answer[0], ENT_QUOTES), $mlw_question_answer_display);
100
+ }else{
101
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , '<b>' . htmlspecialchars_decode($answer[0], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
102
+ }
103
  $mlw_question_answer_display = qsm_question_title_func($mlw_question_answer_display);
104
  if($answer['question_type'] == 11){
105
  $file_extension = substr($answer[1], -4);
110
  }
111
  }else{
112
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , "<span class='$user_answer_class'>".htmlspecialchars_decode($answer[1], ENT_QUOTES).'</span>', $mlw_question_answer_display);
113
+ }
114
+ global $wpdb;
115
+ $qmn_questions = array();
116
+ $question_id_n = $answer['id'];
117
+ $question_array = $wpdb->get_row( "SELECT question_answer_info FROM {$wpdb->prefix}mlw_questions WHERE question_id = $question_id_n", 'ARRAY_A' );
118
+ $qmn_questions[ $question_id_n ] = $question_array['question_answer_info'];
119
+ $answer_2 = !empty( $answer[2] ) ? $answer[2] : 'NA';
120
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , htmlspecialchars_decode($answer_2, ENT_QUOTES), $mlw_question_answer_display);
121
+ $answer_3 = !empty( $answer[3] ) ? $answer[3] : 'NA';
122
+ $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $answer_3, $mlw_question_answer_display);
123
+ $answer_4 = !empty( $qmn_questions[$answer['id']] ) ? $qmn_questions[$answer['id']] : 'NA';
124
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($answer_4, ENT_QUOTES), $mlw_question_answer_display);
125
+ $mlw_question_answer_display = wp_kses_post( $mlw_question_answer_display );
126
  $display = "<div class='qmn_question_answer $question_answer_class'>".apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array).'</div>';
127
  $content = str_replace( "%QUESTION_ANSWER_". $question_id ."%" , $display, $content);
128
  }
362
  global $mlwQuizMasterNext;
363
  global $wpdb;
364
  $display = '';
365
+ if( isset( $mlw_quiz_array['quiz_settings'] ) && !empty($mlw_quiz_array['quiz_settings']) ){
366
+ $quiz_text_settings = isset( $mlw_quiz_array['quiz_settings']['quiz_text'] ) ? @unserialize( $mlw_quiz_array['quiz_settings']['quiz_text'] ) : array();
367
+ $qmn_question_answer_template = isset( $quiz_text_settings['question_answer_template'] ) ? $quiz_text_settings['question_answer_template'] : $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
368
+ }else{
369
+ $qmn_question_answer_template = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'question_answer_template', '%QUESTION%<br/>Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%' );
370
+ }
371
  $questions = QSM_Questions::load_questions_by_pages( $mlw_quiz_array['quiz_id'] );
372
  $qmn_questions = array();
373
  foreach ( $questions as $question ) {
376
 
377
  // Cycles through each answer in the responses.
378
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
379
+ if( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == 'qsm_quiz_result_details' ){
380
+ $user_answer_class = "";
381
+ $question_answer_class = "";
382
+ if( isset( $mlw_quiz_array['form_type'] ) && $mlw_quiz_array['form_type'] == 0 ){
383
+ if( $mlw_quiz_array['quiz_system'] == 0 || $mlw_quiz_array['quiz_system'] == 3 ){
384
+ if ( $answer["correct"] === "correct" ){
385
+ $user_answer_class = "qmn_user_correct_answer";
386
+ $question_answer_class = "qmn_question_answer_correct";
387
+ } else {
388
+ $user_answer_class = "qmn_user_incorrect_answer";
389
+ $question_answer_class = "qmn_question_answer_incorrect";
390
+ }
391
+ }
392
+ }
393
+ } else {
394
+ if ( $answer["correct"] === "correct" ){
395
+ $user_answer_class = "qmn_user_correct_answer";
396
+ $question_answer_class = "qmn_question_answer_correct";
397
+ } else {
398
+ $user_answer_class = "qmn_user_incorrect_answer";
399
+ $question_answer_class = "qmn_question_answer_incorrect";
400
+ }
401
+ }
402
+
403
  $mlw_question_answer_display = htmlspecialchars_decode($qmn_question_answer_template, ENT_QUOTES);
404
+ if( isset( $answer['question_title'] ) && $answer['question_title'] != '' ){
405
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , '<b>' . htmlspecialchars_decode($answer['question_title'], ENT_QUOTES) . '</b><br />' . htmlspecialchars_decode($answer[0], ENT_QUOTES), $mlw_question_answer_display);
406
+ }else{
407
+ $mlw_question_answer_display = str_replace( "%QUESTION%" , '<b>' . htmlspecialchars_decode($answer[0], ENT_QUOTES) . '</b>', $mlw_question_answer_display);
408
+ }
409
  $mlw_question_answer_display = qsm_question_title_func($mlw_question_answer_display);
410
+ if( isset($answer['question_type']) && $answer['question_type'] == 11 ){
411
  $file_extension = substr($answer[1], -4);
412
  if($file_extension == '.jpg' || $file_extension == 'jepg' || $file_extension == '.png' || $file_extension == '.gif'){
413
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , "<span class='$user_answer_class'><img src='$answer[1]'/></span>", $mlw_question_answer_display);
416
  }
417
  }else{
418
  $mlw_question_answer_display = str_replace( "%USER_ANSWER%" , "<span class='$user_answer_class'>".htmlspecialchars_decode($answer[1], ENT_QUOTES).'</span>', $mlw_question_answer_display);
419
+ }
420
+ $answer_2 = !empty( $answer[2] ) ? $answer[2] : 'NA';
421
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER%" , htmlspecialchars_decode($answer_2, ENT_QUOTES), $mlw_question_answer_display);
422
+ $answer_3 = !empty( $answer[3] ) ? $answer[3] : 'NA';
423
+ $mlw_question_answer_display = str_replace( "%USER_COMMENTS%" , $answer_3, $mlw_question_answer_display);
424
+ $answer_4 = !empty( $qmn_questions[$answer['id']] ) ? $qmn_questions[$answer['id']] : 'NA';
425
+ $mlw_question_answer_display = str_replace( "%CORRECT_ANSWER_INFO%" , htmlspecialchars_decode($answer_4, ENT_QUOTES), $mlw_question_answer_display);
426
+ $mlw_question_answer_display = wp_kses_post( $mlw_question_answer_display );
427
  $display .= "<div class='qmn_question_answer $question_answer_class'>".apply_filters('qmn_variable_question_answers', $mlw_question_answer_display, $mlw_quiz_array).'</div>';
428
  }
429
  $content = str_replace( "%QUESTIONS_ANSWERS%" , $display, $content);
736
  $result_display = str_replace("%RANK%", $mlw_rank, $result_display);
737
 
738
  return $result_display;
739
+ }
740
+
741
+ /**
742
+ *
743
+ * Add iFrame to allowed wp_kses_post tags
744
+ *
745
+ * @since 7.0.0
746
+ *
747
+ * @param array $tags Allowed tags, attributes, and/or entities.
748
+ * @param string $context Context to judge allowed tags by. Allowed values are 'post'.
749
+ *
750
+ * @return array
751
+ */
752
+ function qsm_custom_wpkses_post_tags( $tags, $context ) {
753
+
754
+ if ( 'post' === $context ) {
755
+ $tags['iframe'] = array(
756
+ 'src' => true,
757
+ 'height' => true,
758
+ 'width' => true,
759
+ 'frameborder' => true,
760
+ 'allowfullscreen' => true,
761
+ );
762
+ $tags['video'] = array(
763
+ 'width' => true,
764
+ 'height' => true
765
+ );
766
+ $tags['source'] = array(
767
+ 'src' => true,
768
+ 'type' => true
769
+ );
770
+ }
771
+
772
+ return $tags;
773
+ }
774
+
775
+ add_filter( 'wp_kses_allowed_html', 'qsm_custom_wpkses_post_tags', 10, 2 );
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: quizsurvey,expresstech
3
  Tags: quiz, survey, lead, test, score, exam, questionnaire, question,wordpress quiz plugin
4
  Requires at least: 4.9
5
- Tested up to: 5.4
6
  Requires PHP: 5.4
7
- Stable tag: 6.4.12
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -121,6 +121,18 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  = 6.4.12 (June 22, 2020) =
125
  * Bug: Fixed validation issue in email with spaces.
126
  * Bug: Fixed issues with settings related to number of times a user can take quiz.
2
  Contributors: quizsurvey,expresstech
3
  Tags: quiz, survey, lead, test, score, exam, questionnaire, question,wordpress quiz plugin
4
  Requires at least: 4.9
5
+ Tested up to: 5.4.2
6
  Requires PHP: 5.4
7
+ Stable tag: 7.0.0
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
121
 
122
  == Changelog ==
123
 
124
+ = 7.0.0 (July 22, 2020) =
125
+ * Enhancement: Complete UI overhaul QSM admin view including new Dashboard
126
+ * Enhancement: A new wizard to create quizzes effortlessly
127
+ * Enhancement: Separate field for question title when you edit questions
128
+ * Enhancement: Updated UI of several pages in admin panel
129
+ * Enhancement: Added new template for results page in admin panel
130
+ * Enhancement: Added background email feature to improve performance while displaying results.
131
+ * Bug: Fixed issue where recaptcha appears on every page
132
+ * Bug: Fixed a database error where some users were not able to create a quiz (Error Code: 0001)
133
+ * Bug: Fixed cross-site scripting vulnerability (discovered by Vishnupriya Ilango of Fortinet's FortiGuard Labs.)
134
+ * Bug: Fixed issues while duplicating a quiz
135
+
136
  = 6.4.12 (June 22, 2020) =
137
  * Bug: Fixed validation issue in email with spaces.
138
  * Bug: Fixed issues with settings related to number of times a user can take quiz.
templates/qmn_primary.css CHANGED
@@ -471,4 +471,29 @@ border: 1px solid #e3e3e3;
471
  padding: 5px 5px 0px 5px;
472
  display: inline-block;
473
  cursor: pointer;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
  }
471
  padding: 5px 5px 0px 5px;
472
  display: inline-block;
473
  cursor: pointer;
474
+ }
475
+
476
+ .page-timer-wrapper{
477
+ display: flex;
478
+ max-width: 100%;
479
+ box-sizing: border-box;
480
+ text-align: center;
481
+ align-items: center;
482
+ justify-content: space-between;
483
+ margin-bottom: 10px;
484
+ }
485
+ .page-timer-wrapper .qsm-pagetimer{
486
+ font-size: 18px;
487
+ font-weight: bold;
488
+ line-height: 24px;
489
+ color: #333;
490
+ padding: 5px 10px;
491
+ box-shadow: 0 0 10px 1px #eee;
492
+ border-radius: 5px;
493
+ }
494
+ .page-timer-wrapper .qsm-pagetimer-warning{
495
+ box-sizing: border-box;
496
+ color: red;
497
+ font-size: 18px;
498
+ line-height: 24px;
499
  }
uninstall.php CHANGED
@@ -55,6 +55,8 @@ $qsm_options = array(
55
  'qmn-tracking-notice',
56
  'mlw_qmn_review_notice',
57
  'qsm_upated_question_type_val',
 
 
58
  );
59
 
60
  // Remove the orphaned options now.
55
  'qmn-tracking-notice',
56
  'mlw_qmn_review_notice',
57
  'qsm_upated_question_type_val',
58
+ 'qsm_update_quiz_db_column',
59
+ 'qsm_update_result_db_column'
60
  );
61
 
62
  // Remove the orphaned options now.