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

Version Description

(July 29, 2021) = * Feature: Added option to add multiple categories to single question. * Feature: Added option to display quiz results based on category points. * Enhancement: Extended category based template variables to support multiple categories. * Bug: Fixed issue with quiz duplication.

Download this release

Release Info

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

Code changes from version 7.2.3 to 7.3.0

css/qsm-admin-question.css CHANGED
@@ -10,40 +10,47 @@
10
  float: right;
11
  }
12
 
13
- #unlink-question-button {
 
14
  float: right;
15
  margin-left: 5px;
16
  }
17
 
18
  #modal-7,
19
- #modal-8 {
 
20
  max-width: 500px;
21
  }
22
 
23
  #modal-7 hr,
24
- #modal-8 hr {
 
25
  margin: 0 -30px;
26
  }
27
 
28
  #modal-7 header,
29
- #modal-8 header {
 
30
  margin: -10px 0 10px 0;
31
  }
32
 
33
  #modal-7 .qsm-popup__close,
34
- #modal-8 .qsm-popup__close {
 
35
  margin: -10px -10px 0 0;
36
  font-size: 20px;
37
  }
38
 
39
  #modal-7-title,
40
- #modal-8-title {
41
- color: gray;
 
42
  opacity: 70%;
43
  }
44
 
45
  #modal-7 footer .dashicons,
46
- #modal-8 footer .dashicons {
 
47
  font-size: 20px;
48
  margin-right: 3px;
49
  vertical-align: middle;
@@ -51,26 +58,38 @@
51
  }
52
 
53
  #modal-7 .qsm-popup__container,
54
- #modal-8 .qsm-popup__container {
 
55
  max-width: 560px;
56
  padding-bottom: 20px;
57
  }
58
 
59
  .modal-7-table,
60
- .modal-8-table {
 
61
  font-size: 16px;
62
  }
63
 
64
  #modal-7 footer,
65
- #modal-8 footer {
 
66
  margin-top: 15px;
67
  }
68
 
69
  .modal-7-table tr td,
70
- .modal-8-table tr td {
 
71
  vertical-align: top;
72
  padding: 0 10px 5px 0
73
  }
 
 
 
 
 
 
 
 
74
  @media screen and (min-width:700px) {
75
  .question-controls {
76
  flex-direction: row;
@@ -746,6 +765,13 @@ a#qsm-category-add-toggle {
746
  cursor: pointer;
747
  }
748
 
 
 
 
 
 
 
 
749
  .quiz_form_type_0.quiz_quiz_systen_3 #question_type_13_description,
750
  .quiz_form_type_0.quiz_quiz_systen_1 #question_type_13_description {
751
  display: none !important;
@@ -755,6 +781,17 @@ a#qsm-category-add-toggle {
755
  float: right;
756
  }
757
 
 
 
 
 
 
 
 
 
 
 
 
758
  .qsm-show-correct-info-box,
759
  .qsm-show-question-desc-box {
760
  background: #fff;
10
  float: right;
11
  }
12
 
13
+ #unlink-question-button,
14
+ #save-multi-category-button {
15
  float: right;
16
  margin-left: 5px;
17
  }
18
 
19
  #modal-7,
20
+ #modal-8,
21
+ #modal-9 {
22
  max-width: 500px;
23
  }
24
 
25
  #modal-7 hr,
26
+ #modal-8 hr,
27
+ #modal-9 hr {
28
  margin: 0 -30px;
29
  }
30
 
31
  #modal-7 header,
32
+ #modal-8 header,
33
+ #modal-9 header {
34
  margin: -10px 0 10px 0;
35
  }
36
 
37
  #modal-7 .qsm-popup__close,
38
+ #modal-8 .qsm-popup__close,
39
+ #modal-9 .qsm-popup__close {
40
  margin: -10px -10px 0 0;
41
  font-size: 20px;
42
  }
43
 
44
  #modal-7-title,
45
+ #modal-8-title,
46
+ #modal-9-title {
47
+ color: #00449e;
48
  opacity: 70%;
49
  }
50
 
51
  #modal-7 footer .dashicons,
52
+ #modal-8 footer .dashicons,
53
+ #modal-9 footer .dashicons {
54
  font-size: 20px;
55
  margin-right: 3px;
56
  vertical-align: middle;
58
  }
59
 
60
  #modal-7 .qsm-popup__container,
61
+ #modal-8 .qsm-popup__container,
62
+ #modal-9 .qsm-popup__container {
63
  max-width: 560px;
64
  padding-bottom: 20px;
65
  }
66
 
67
  .modal-7-table,
68
+ .modal-8-table,
69
+ .modal-9-table {
70
  font-size: 16px;
71
  }
72
 
73
  #modal-7 footer,
74
+ #modal-8 footer,
75
+ #modal-9 footer {
76
  margin-top: 15px;
77
  }
78
 
79
  .modal-7-table tr td,
80
+ .modal-8-table tr td,
81
+ .modal-9-table tr td {
82
  vertical-align: top;
83
  padding: 0 10px 5px 0
84
  }
85
+
86
+ #modal-9-content .info {
87
+ width: 100%;
88
+ margin-bottom: -20px;
89
+ color: red;
90
+ font-size: 15px;
91
+ }
92
+
93
  @media screen and (min-width:700px) {
94
  .question-controls {
95
  flex-direction: row;
765
  cursor: pointer;
766
  }
767
 
768
+ .add-multiple-category {
769
+ text-align: center;
770
+ display: block;
771
+ width: 100%;
772
+ cursor: pointer;
773
+ }
774
+
775
  .quiz_form_type_0.quiz_quiz_systen_3 #question_type_13_description,
776
  .quiz_form_type_0.quiz_quiz_systen_1 #question_type_13_description {
777
  display: none !important;
781
  float: right;
782
  }
783
 
784
+ div#multi_categories_wrapper {
785
+ display: inline-block;
786
+ width: 100%;
787
+ max-height: 250px;
788
+ box-sizing: border-box;
789
+ border: 1px solid #DDD;
790
+ padding: 15px;
791
+ overflow: hidden;
792
+ overflow-y: auto;
793
+ }
794
+
795
  .qsm-show-correct-info-box,
796
  .qsm-show-question-desc-box {
797
  background: #fff;
css/qsm-admin.css CHANGED
@@ -651,7 +651,7 @@ Results Pages & Emails Tab
651
  display: flex;
652
  flex-direction: column;
653
  margin-bottom: 15px;
654
- justify-content: space-around;
655
  }
656
 
657
  .results-page-condition>select,
@@ -712,7 +712,7 @@ Results Pages & Emails Tab
712
  .results-page-condition>input,
713
  .email-condition>select,
714
  .email-condition>input {
715
- max-width: 30%;
716
  }
717
 
718
  .delete-condition-button {
@@ -1624,8 +1624,8 @@ td.scheduled_time_start {
1624
 
1625
  #show-all-variable-content .popup-template-span-wrap {
1626
  margin-bottom: 20px;
1627
- margin-right: 3%;
1628
- width: 30%;
1629
  display: inline-block;
1630
  }
1631
 
@@ -1962,119 +1962,6 @@ td.scheduled_time_start {
1962
  }
1963
 
1964
  .popup-template-span-wrap .popup-copied-des {
1965
- color: green;
1966
- }
1967
- .popup-template-span-wrap .popup-copied-des span.dashicons{
1968
- line-height: 28px;
1969
- }
1970
- .comment-inner-wrap{
1971
- /* display: none;*/
1972
- }
1973
- @media (min-width: 768px) and (max-width: 1199px){
1974
- .qsm-news-ads .qsm-info-widget{
1975
- float: left;
1976
- max-width: unset;
1977
- width: 31.3%;
1978
- }
1979
- .qsm-news-ads .qsm-info-widget:nth-child(3n+5){
1980
- clear: both;
1981
- }
1982
- .remove-ads-adv-link{
1983
- width: 100%;
1984
- display: inline-block;
1985
- margin-bottom: 30px;
1986
- }
1987
- }
1988
- @media screen and (max-width: 782px){
1989
- .form-table td fieldset label {
1990
- margin-top: -1px !important;
1991
- vertical-align: top;
1992
- }
1993
- .qsm-tooltips-icon .qsm-tooltips{
1994
- left: -90px;
1995
- }
1996
- .qsm-opt-tr .qsm-tooltips-icon{
1997
- right: 13px;
1998
- }
1999
- .qsm-tooltips-icon .qsm-tooltips:before{
2000
- left: auto;
2001
- right: -3px;
2002
- }
2003
- }
2004
- @media screen and (max-width: 767px){
2005
- .qsm-quiz-row td:nth-of-type(2n){
2006
- display: none;
2007
- }
2008
- .qsm-quiz-page-wrapper,
2009
- .qsm-quiz-page-wrapper-with-ads {
2010
- overflow-x: auto;
2011
- }
2012
- .qsm-quiz-page-wrapper thead th:nth-of-type(2n),
2013
- .qsm-quiz-page-wrapper tfoot th:nth-of-type(2n),
2014
- .qsm-quiz-page-wrapper-with-ads thead th:nth-of-type(2n),
2015
- .qsm-quiz-page-wrapper-with-ads tfoot th:nth-of-type(2n){
2016
- display: none;
2017
- }
2018
- .qsm-quiz-page-wrapper .row-actions{
2019
- display: inline-block !important;
2020
- }
2021
- .qsm-quiz-page-wrapper p.search-box {
2022
- bottom: -30px;
2023
- }
2024
- .qsm-popup__container{
2025
- min-width: auto;
2026
- max-width: 100%;
2027
- }
2028
- #show-advanced-option {
2029
- display: block;
2030
- width: 100%;
2031
- float: left;
2032
- }
2033
- .contact-form-label {
2034
- display: inline-block;
2035
- }
2036
- .template_variable{
2037
- width: 100%;
2038
- max-width: 100%;
2039
- margin-bottom: 10px;
2040
- word-break: break-word;
2041
- }
2042
- .qsm_tab_content .form-table input[type=radio]{
2043
- top: 6px;
2044
- margin-bottom: 8px;
2045
- }
2046
- .result-page-wrapper form{
2047
- overflow: scroll;
2048
- width: 100%;
2049
-
2050
- }
2051
- p.search-box{
2052
- bottom: -30px;
2053
- }
2054
- .quizzes-surveys_page_qsm_quiz_help .hndle{
2055
- padding-left: 15px;
2056
- padding-bottom: 15px;
2057
- }
2058
- .qsm-news-ads .qsm-info-widget{
2059
- width: calc( 100% - 30px );
2060
- max-width: 100%;
2061
- box-sizing: border-box;
2062
- margin: 15px 15px 0 15px;
2063
- }
2064
- .form-table .qsm-opt-tr{
2065
- padding-bottom: 10px;
2066
- }
2067
- .overview-main-wrapper{
2068
- display: block;
2069
- }
2070
- .overview-main-wrapper .overview-inner-wrap{
2071
- margin-right: 0;
2072
- width: 100%;
2073
- }
2074
- .result-page-title{
2075
- margin-bottom: 10px;
2076
- }
2077
-
2078
  color: green;
2079
  }
2080
 
@@ -2083,7 +1970,145 @@ td.scheduled_time_start {
2083
  }
2084
 
2085
  .comment-inner-wrap {
2086
- /* display: none;*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2087
  }
2088
 
2089
  #qsm_themes h2.wp-heading-inline {
651
  display: flex;
652
  flex-direction: column;
653
  margin-bottom: 15px;
654
+ /* justify-content: space-around; */
655
  }
656
 
657
  .results-page-condition>select,
712
  .results-page-condition>input,
713
  .email-condition>select,
714
  .email-condition>input {
715
+ max-width: 23%;
716
  }
717
 
718
  .delete-condition-button {
1624
 
1625
  #show-all-variable-content .popup-template-span-wrap {
1626
  margin-bottom: 20px;
1627
+ margin-right: 5px;
1628
+ width: auto;
1629
  display: inline-block;
1630
  }
1631
 
1962
  }
1963
 
1964
  .popup-template-span-wrap .popup-copied-des {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1965
  color: green;
1966
  }
1967
 
1970
  }
1971
 
1972
  .comment-inner-wrap {
1973
+ /* display: none;*/
1974
+ }
1975
+
1976
+ @media (min-width: 768px) and (max-width: 1199px) {
1977
+ .qsm-news-ads .qsm-info-widget {
1978
+ float: left;
1979
+ max-width: unset;
1980
+ width: 31.3%;
1981
+ }
1982
+
1983
+ .qsm-news-ads .qsm-info-widget:nth-child(3n+5) {
1984
+ clear: both;
1985
+ }
1986
+
1987
+ .remove-ads-adv-link {
1988
+ width: 100%;
1989
+ display: inline-block;
1990
+ margin-bottom: 30px;
1991
+ }
1992
+ }
1993
+
1994
+ @media screen and (max-width: 782px) {
1995
+ .form-table td fieldset label {
1996
+ margin-top: -1px !important;
1997
+ vertical-align: top;
1998
+ }
1999
+
2000
+ .qsm-tooltips-icon .qsm-tooltips {
2001
+ left: -90px;
2002
+ }
2003
+
2004
+ .qsm-opt-tr .qsm-tooltips-icon {
2005
+ right: 13px;
2006
+ }
2007
+
2008
+ .qsm-tooltips-icon .qsm-tooltips:before {
2009
+ left: auto;
2010
+ right: -3px;
2011
+ }
2012
+ }
2013
+
2014
+ @media screen and (max-width: 767px) {
2015
+ .qsm-quiz-row td:nth-of-type(2n) {
2016
+ display: none;
2017
+ }
2018
+
2019
+ .qsm-quiz-page-wrapper,
2020
+ .qsm-quiz-page-wrapper-with-ads {
2021
+ overflow-x: auto;
2022
+ }
2023
+
2024
+ .qsm-quiz-page-wrapper thead th:nth-of-type(2n),
2025
+ .qsm-quiz-page-wrapper tfoot th:nth-of-type(2n),
2026
+ .qsm-quiz-page-wrapper-with-ads thead th:nth-of-type(2n),
2027
+ .qsm-quiz-page-wrapper-with-ads tfoot th:nth-of-type(2n) {
2028
+ display: none;
2029
+ }
2030
+
2031
+ .qsm-quiz-page-wrapper .row-actions {
2032
+ display: inline-block !important;
2033
+ }
2034
+
2035
+ .qsm-quiz-page-wrapper p.search-box {
2036
+ bottom: -30px;
2037
+ }
2038
+
2039
+ .qsm-popup__container {
2040
+ min-width: auto;
2041
+ max-width: 100%;
2042
+ }
2043
+
2044
+ #show-advanced-option {
2045
+ display: block;
2046
+ width: 100%;
2047
+ float: left;
2048
+ }
2049
+
2050
+ .contact-form-label {
2051
+ display: inline-block;
2052
+ }
2053
+
2054
+ .template_variable {
2055
+ width: 100%;
2056
+ max-width: 100%;
2057
+ margin-bottom: 10px;
2058
+ word-break: break-word;
2059
+ }
2060
+
2061
+ .qsm_tab_content .form-table input[type=radio] {
2062
+ top: 6px;
2063
+ margin-bottom: 8px;
2064
+ }
2065
+
2066
+ .result-page-wrapper form {
2067
+ overflow: scroll;
2068
+ width: 100%;
2069
+
2070
+ }
2071
+
2072
+ p.search-box {
2073
+ bottom: -30px;
2074
+ }
2075
+
2076
+ .quizzes-surveys_page_qsm_quiz_help .hndle {
2077
+ padding-left: 15px;
2078
+ padding-bottom: 15px;
2079
+ }
2080
+
2081
+ .qsm-news-ads .qsm-info-widget {
2082
+ width: calc(100% - 30px);
2083
+ max-width: 100%;
2084
+ box-sizing: border-box;
2085
+ margin: 15px 15px 0 15px;
2086
+ }
2087
+
2088
+ .form-table .qsm-opt-tr {
2089
+ padding-bottom: 10px;
2090
+ }
2091
+
2092
+ .overview-main-wrapper {
2093
+ display: block;
2094
+ }
2095
+
2096
+ .overview-main-wrapper .overview-inner-wrap {
2097
+ margin-right: 0;
2098
+ width: 100%;
2099
+ }
2100
+
2101
+ .result-page-title {
2102
+ margin-bottom: 10px;
2103
+ }
2104
+ }
2105
+
2106
+ .popup-template-span-wrap .popup-copied-des span.dashicons {
2107
+ line-height: 28px;
2108
+ }
2109
+
2110
+ .comment-inner-wrap {
2111
+ /* display: none;*/
2112
  }
2113
 
2114
  #qsm_themes h2.wp-heading-inline {
js/qsm-admin-emails.js CHANGED
@@ -26,6 +26,7 @@ var QSMAdminEmails;
26
  };
27
  $( this ).find( '.email-condition' ).each( function() {
28
  email.conditions.push({
 
29
  'criteria': $( this ).children( '.email-condition-criteria' ).val(),
30
  'operator': $( this ).children( '.email-condition-operator' ).val(),
31
  'value': $( this ).children( '.email-condition-value' ).val()
@@ -66,16 +67,17 @@ var QSMAdminEmails;
66
  })
67
  .fail(QSMAdmin.displayjQueryError);
68
  },
69
- addCondition: function( $email, criteria, operator, value ) {
70
  var template = wp.template( 'email-condition' );
71
- $email.find( '.email-when-conditions' ).append( template({
72
- 'criteria': criteria,
73
- 'operator': operator,
74
- 'value': value
 
75
  }));
76
  },
77
  newCondition: function( $email ) {
78
- QSMAdminEmails.addCondition( $email, 'score', 'equal', 0 );
79
  },
80
  addEmail: function( conditions, to, subject, content, replyTo ) {
81
  QSMAdminEmails.total += 1;
@@ -84,6 +86,7 @@ var QSMAdminEmails;
84
  conditions.forEach( function( condition, i, conditions) {
85
  QSMAdminEmails.addCondition(
86
  $( '.qsm-email:last-child' ),
 
87
  condition.criteria,
88
  condition.operator,
89
  condition.value
@@ -104,6 +107,7 @@ var QSMAdminEmails;
104
  },
105
  newEmail: function() {
106
  var conditions = [{
 
107
  'criteria': 'score',
108
  'operator': 'greater',
109
  'value': '0'
26
  };
27
  $( this ).find( '.email-condition' ).each( function() {
28
  email.conditions.push({
29
+ 'category': $(this).children('.email-condition-category').val(),
30
  'criteria': $( this ).children( '.email-condition-criteria' ).val(),
31
  'operator': $( this ).children( '.email-condition-operator' ).val(),
32
  'value': $( this ).children( '.email-condition-value' ).val()
67
  })
68
  .fail(QSMAdmin.displayjQueryError);
69
  },
70
+ addCondition: function ($email, category, criteria, operator, value) {
71
  var template = wp.template( 'email-condition' );
72
+ $email.find('.email-when-conditions').append(template({
73
+ 'category': category,
74
+ 'criteria': criteria,
75
+ 'operator': operator,
76
+ 'value': value
77
  }));
78
  },
79
  newCondition: function( $email ) {
80
+ QSMAdminEmails.addCondition($email, '', 'score', 'equal', 0);
81
  },
82
  addEmail: function( conditions, to, subject, content, replyTo ) {
83
  QSMAdminEmails.total += 1;
86
  conditions.forEach( function( condition, i, conditions) {
87
  QSMAdminEmails.addCondition(
88
  $( '.qsm-email:last-child' ),
89
+ condition.category,
90
  condition.criteria,
91
  condition.operator,
92
  condition.value
107
  },
108
  newEmail: function() {
109
  var conditions = [{
110
+ 'category': '',
111
  'criteria': 'score',
112
  'operator': 'greater',
113
  'value': '0'
js/qsm-admin-notices.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ $(document).on('click', '.enable-multiple-category', function (e) {
3
+ e.preventDefault();
4
+ $('.category-action').html('Updating database<span></span>');
5
+ $('.category-action').prev().hide();
6
+ $('.category-action').prev().prev().hide();
7
+ i = 0;
8
+ category_interval = setInterval(() => {
9
+ if (i % 3 == 0) {
10
+ $('.category-action span').html(' .');
11
+ } else {
12
+ $('.category-action span').append(' .');
13
+ }
14
+ i++;
15
+ }, 500);
16
+ $.ajax({
17
+ type: "POST",
18
+ url: qsm_notices_ajax_object.ajax_url,
19
+ data: {
20
+ action: 'enable_multiple_categories',
21
+ value: 'enable'
22
+ },
23
+ success: function (r) {
24
+ response = JSON.parse(r);
25
+ clearInterval(category_interval);
26
+ if (response.status) {
27
+ $('.category-action').parents('.multiple-category-notice').removeClass('notice-info').addClass('notice-success').html('<p>Database updated successfully.</p>');
28
+ } else {
29
+ $('.category-action').parents('.multiple-category-notice').removeClass('notice-info').addClass('notice-error').html('Error! Please try again');
30
+ }
31
+
32
+ }
33
+ });
34
+ });
35
+
36
+ $(document).on('click', '.cancel-multiple-category', function (e) {
37
+ e.preventDefault();
38
+ $('.category-action').html('');
39
+ $.ajax({
40
+ type: "POST",
41
+ url: qsm_notices_ajax_object.ajax_url,
42
+ data: {
43
+ action: 'enable_multiple_categories',
44
+ value: 'cancel'
45
+ },
46
+ success: function (status) {
47
+ if (status) {
48
+ $('.multiple-category-notice').hide();
49
+ }
50
+ }
51
+ });
52
+ });
53
+ $('.multiple-category-notice').show();
54
+ }(jQuery));
js/qsm-admin-question.js CHANGED
@@ -116,8 +116,13 @@ var import_button;
116
  $cat_html = '<select name="question-bank-cat" id="question-bank-cat">';
117
  $cat_html += '<option value="">All Questions</option>';
118
  $.each(category_arr, function (index, value) {
119
- if (value.category !== '')
120
- $cat_html += '<option value="' + value.category + '">' + value.category + ' Questions</option>';
 
 
 
 
 
121
  });
122
  $cat_html += '</select>';
123
  $('#question-bank').prepend($cat_html);
@@ -135,14 +140,23 @@ var import_button;
135
  if (question.question_title !== "undefined" && question.question_title !== "") {
136
  questionText = question.question_title;
137
  }
138
- $('#question-bank').append(template({ id: question.id, question: questionText, category: question.category, quiz_name: question.quiz_name }));
 
 
 
 
 
139
  },
140
  addQuestionFromQuestionBank: function (questionID) {
141
  //MicroModal.close( 'modal-2' );
142
  //QSMAdmin.displayAlert( 'Adding question...', 'info' );
143
- var model = new QSMQuestion.question({ id: questionID });
 
 
144
  model.fetch({
145
- headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
 
 
146
  url: wpApiSettings.root + 'quiz-survey-master/v1/questions/' + questionID,
147
  success: QSMQuestion.questionBankSuccess,
148
  error: QSMAdmin.displayError
@@ -174,13 +188,19 @@ var import_button;
174
  },
175
  addCategory: function (category) {
176
  var template = wp.template('single-category');
177
- $('#categories').prepend(template({ category: category }));
 
 
178
  },
179
  loadQuestions: function () {
180
  QSMAdmin.displayAlert('Loading questions...', 'info');
181
  QSMQuestion.questions.fetch({
182
- headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
183
- data: { quizID: qsmQuestionSettings.quizID },
 
 
 
 
184
  success: QSMQuestion.loadSuccess,
185
  error: QSMAdmin.displayError
186
  });
@@ -243,7 +263,6 @@ var import_button;
243
  pageInfo.set('questions', singlePage);
244
  qpages.push(pageInfo.attributes);
245
  });
246
- console.log(pages);
247
  var data = {
248
  action: 'qsm_save_pages',
249
  pages: pages,
@@ -268,7 +287,12 @@ var import_button;
268
  if (typeof pageID == 'undefined' || pageID == '') {
269
  var newPageID = QSMQuestion.qpages.length + 1;
270
  var pageID = newPageID;
271
- var pageInfo = QSMQuestion.qpages.add({ id: newPageID, quizID: qsmQuestionSettings.quizID, pagekey: qsmRandomID(8), hide_prevbtn: 0 });
 
 
 
 
 
272
  }
273
  var pageInfo = QSMQuestion.qpages.get(pageID);
274
  $('.questions').append(template(pageInfo));
@@ -325,22 +349,25 @@ var import_button;
325
  if (questionName == '')
326
  questionName = 'Your new question!';
327
 
328
- $('.page:nth-child(' + page + ')').append(template({ id: model.id, category: model.get('category'), question: questionName }));
 
 
 
 
329
  setTimeout(QSMQuestion.removeNew, 250);
330
  },
331
  createQuestion: function (page) {
332
  QSMAdmin.displayAlert('Creating question...', 'info');
333
- QSMQuestion.questions.create(
334
- {
335
- quizID: qsmQuestionSettings.quizID,
336
- page: page
 
 
337
  },
338
- {
339
- headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
340
- success: QSMQuestion.addNewQuestion,
341
- error: QSMAdmin.displayError
342
- }
343
- );
344
  },
345
  duplicateQuestion: function (questionID) {
346
  QSMAdmin.displayAlert('Duplicating question...', 'info');
@@ -348,9 +375,10 @@ var import_button;
348
  var newModel = _.clone(model.attributes);
349
  newModel.id = null;
350
  QSMQuestion.questions.create(
351
- newModel,
352
- {
353
- headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
 
354
  success: QSMQuestion.addNewQuestion,
355
  error: QSMAdmin.displayError
356
  }
@@ -388,6 +416,10 @@ var import_button;
388
  if (!category) {
389
  category = '';
390
  }
 
 
 
 
391
  var featureImageID = $('.qsm-feature-image-id').val();
392
  var featureImageSrc = $('.qsm-feature-image-src').val();
393
  var answerType = $('#change-answer-editor').val();
@@ -437,35 +469,37 @@ var import_button;
437
  advanced_option[element_id] = $(this).find('select').val();
438
  } else if ($(this).find('input[type="checkbox"]').length > 0) {
439
  var element_id = $(this).find('input[type="checkbox"]').attr('name');
440
- var multi_value = $(this).find('input[type="checkbox"]:checked').map(function () { return this.value; }).get().join(',');
 
 
441
  element_id = element_id.replace('[]', '');
442
  advanced_option[element_id] = multi_value;
443
  }
444
  });
445
- model.save(
446
- {
447
- type: type,
448
- name: name,
449
- question_title: question_title,
450
- answerInfo: answerInfo,
451
- comments: comments,
452
- hint: hint,
453
- category: category,
454
- featureImageID: featureImageID,
455
- featureImageSrc: featureImageSrc,
456
- answers: answers,
457
- answerEditor: answerType,
458
- matchAnswer: matchAnswer,
459
- other_settings: advanced_option
 
 
 
460
  },
461
- {
462
- headers: { 'X-WP-Nonce': qsmQuestionSettings.nonce },
463
- success: QSMQuestion.saveSuccess,
464
- error: QSMAdmin.displayError,
465
- type: 'POST'
466
- }
467
- );
468
- //CurrentElement.parents('.questionElements').slideUp('slow');
469
  },
470
  saveSuccess: function (model) {
471
  QSMAdmin.displayAlert('Question was saved!', 'success');
@@ -476,7 +510,12 @@ var import_button;
476
  if (new_question_title !== '') {
477
  questionName = $.QSMSanitize(new_question_title);
478
  }
479
- $('.question[data-question-id=' + model.id + ']').replaceWith(template({ id: model.id, type: model.get('type'), category: model.get('category'), question: questionName }));
 
 
 
 
 
480
  setTimeout(function () {
481
  $('#save-edit-question-spinner').removeClass('is-active');
482
  }, 250);
@@ -488,9 +527,28 @@ var import_button;
488
  }
489
  var answerTemplate = wp.template('single-answer');
490
  if (answer.length >= 7 && answer[6] == 'image') {
491
- $('#answers').append(answerTemplate({ answer: decodeEntities(answer[0]), points: answer[1], correct: answer[2], caption: answer[3], count: answer[4], question_id: answer[5], answerType: answer[6], form_type: qsmQuestionSettings.form_type, quiz_system: qsmQuestionSettings.quiz_system }));
 
 
 
 
 
 
 
 
 
 
492
  } else {
493
- $('#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 }));
 
 
 
 
 
 
 
 
 
494
  }
495
 
496
  // show points field only for polar in survey and simple form
@@ -598,6 +656,16 @@ var import_button;
598
  if (get_limit_fu === null || typeof get_limit_fu === "undefined") {
599
  get_limit_fu = '0';
600
  }
 
 
 
 
 
 
 
 
 
 
601
  //Get featured image
602
  var get_featureImageSrc = question.get('featureImageSrc');
603
  var get_featureImageID = question.get('featureImageID');
@@ -607,8 +675,7 @@ var import_button;
607
  //Get checked question type
608
  var get_file_upload_type = question.get('file_upload_type');
609
  $("input[name='file_upload_type[]']:checkbox").attr("checked", false);
610
- if (get_file_upload_type === null || typeof get_file_upload_type === "undefined") {
611
- } else {
612
  var fut_arr = get_file_upload_type.split(",");
613
  $.each(fut_arr, function (i) {
614
  $("input[name='file_upload_type[]']:checkbox[value='" + fut_arr[i] + "']").attr("checked", "true");
@@ -662,8 +729,7 @@ var import_button;
662
  }
663
  //Append extra settings
664
  var all_setting = question.get('settings');
665
- if (all_setting === null || typeof all_setting === "undefined") {
666
- } else {
667
  $.each(all_setting, function (index, value) {
668
  if ($('#' + index + '_area').length > 0) {
669
  if ($('#' + index + '_area').find('input[type="checkbox"]').length > 1) {
@@ -686,6 +752,10 @@ var import_button;
686
  //MicroModal.show( 'modal-1' );
687
  $('.questions').sortable('disable');
688
  $('.page').sortable('disable');
 
 
 
 
689
  },
690
  openEditPagePopup: function (pageID) {
691
  var page = QSMQuestion.qpages.get(pageID);
@@ -714,11 +784,27 @@ var import_button;
714
  };
715
  wp.editor.initialize('question-text', settings);
716
  wp.editor.initialize('correct_answer_info', settings);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  }
718
  };
719
 
720
  $(function () {
721
- QSMQuestion.pageCollection = Backbone.Collection.extend({ model: QSMQuestion.page });
 
 
722
  QSMQuestion.qpages = new QSMQuestion.pageCollection();
723
  QSMQuestion.questionCollection = Backbone.Collection.extend({
724
  url: wpApiSettings.root + 'quiz-survey-master/v1/questions',
@@ -755,6 +841,7 @@ var import_button;
755
 
756
  $('.questions').on('click', '.edit-question-button', function (event) {
757
  event.preventDefault();
 
758
  QSMQuestion.openEditPopup($(this).parents('.question').data('question-id'), $(this));
759
  });
760
  $('.questions').on('click', '.edit-page-button', function (event) {
@@ -1198,6 +1285,7 @@ var import_button;
1198
  }
1199
  });
1200
  }
 
1201
  function qsmRandomID(length) {
1202
  var result = '';
1203
  var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@@ -1207,4 +1295,91 @@ var import_button;
1207
  }
1208
  return result;
1209
  }
1210
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  $cat_html = '<select name="question-bank-cat" id="question-bank-cat">';
117
  $cat_html += '<option value="">All Questions</option>';
118
  $.each(category_arr, function (index, value) {
119
+ if (value.category !== '') {
120
+ if (typeof value.cat_id !== 'undefined' && value.cat_id !== '') {
121
+ $cat_html += '<option value="' + value.cat_id + '">' + value.category + ' Questions</option>';
122
+ } else {
123
+ $cat_html += '<option value="' + value.category + '">' + value.category + ' Questions</option>';
124
+ }
125
+ }
126
  });
127
  $cat_html += '</select>';
128
  $('#question-bank').prepend($cat_html);
140
  if (question.question_title !== "undefined" && question.question_title !== "") {
141
  questionText = question.question_title;
142
  }
143
+ $('#question-bank').append(template({
144
+ id: question.id,
145
+ question: questionText,
146
+ category: question.category,
147
+ quiz_name: question.quiz_name
148
+ }));
149
  },
150
  addQuestionFromQuestionBank: function (questionID) {
151
  //MicroModal.close( 'modal-2' );
152
  //QSMAdmin.displayAlert( 'Adding question...', 'info' );
153
+ var model = new QSMQuestion.question({
154
+ id: questionID
155
+ });
156
  model.fetch({
157
+ headers: {
158
+ 'X-WP-Nonce': qsmQuestionSettings.nonce
159
+ },
160
  url: wpApiSettings.root + 'quiz-survey-master/v1/questions/' + questionID,
161
  success: QSMQuestion.questionBankSuccess,
162
  error: QSMAdmin.displayError
188
  },
189
  addCategory: function (category) {
190
  var template = wp.template('single-category');
191
+ $('#categories').prepend(template({
192
+ category: category
193
+ }));
194
  },
195
  loadQuestions: function () {
196
  QSMAdmin.displayAlert('Loading questions...', 'info');
197
  QSMQuestion.questions.fetch({
198
+ headers: {
199
+ 'X-WP-Nonce': qsmQuestionSettings.nonce
200
+ },
201
+ data: {
202
+ quizID: qsmQuestionSettings.quizID
203
+ },
204
  success: QSMQuestion.loadSuccess,
205
  error: QSMAdmin.displayError
206
  });
263
  pageInfo.set('questions', singlePage);
264
  qpages.push(pageInfo.attributes);
265
  });
 
266
  var data = {
267
  action: 'qsm_save_pages',
268
  pages: pages,
287
  if (typeof pageID == 'undefined' || pageID == '') {
288
  var newPageID = QSMQuestion.qpages.length + 1;
289
  var pageID = newPageID;
290
+ var pageInfo = QSMQuestion.qpages.add({
291
+ id: newPageID,
292
+ quizID: qsmQuestionSettings.quizID,
293
+ pagekey: qsmRandomID(8),
294
+ hide_prevbtn: 0
295
+ });
296
  }
297
  var pageInfo = QSMQuestion.qpages.get(pageID);
298
  $('.questions').append(template(pageInfo));
349
  if (questionName == '')
350
  questionName = 'Your new question!';
351
 
352
+ $('.page:nth-child(' + page + ')').append(template({
353
+ id: model.id,
354
+ category: model.get('category'),
355
+ question: questionName
356
+ }));
357
  setTimeout(QSMQuestion.removeNew, 250);
358
  },
359
  createQuestion: function (page) {
360
  QSMAdmin.displayAlert('Creating question...', 'info');
361
+ QSMQuestion.questions.create({
362
+ quizID: qsmQuestionSettings.quizID,
363
+ page: page
364
+ }, {
365
+ headers: {
366
+ 'X-WP-Nonce': qsmQuestionSettings.nonce
367
  },
368
+ success: QSMQuestion.addNewQuestion,
369
+ error: QSMAdmin.displayError
370
+ });
 
 
 
371
  },
372
  duplicateQuestion: function (questionID) {
373
  QSMAdmin.displayAlert('Duplicating question...', 'info');
375
  var newModel = _.clone(model.attributes);
376
  newModel.id = null;
377
  QSMQuestion.questions.create(
378
+ newModel, {
379
+ headers: {
380
+ 'X-WP-Nonce': qsmQuestionSettings.nonce
381
+ },
382
  success: QSMQuestion.addNewQuestion,
383
  error: QSMAdmin.displayError
384
  }
416
  if (!category) {
417
  category = '';
418
  }
419
+ var multicategories = [];
420
+ $.each($("input[name='tax_input[qsm_category][]']:checked"), function () {
421
+ multicategories.push($(this).val());
422
+ });
423
  var featureImageID = $('.qsm-feature-image-id').val();
424
  var featureImageSrc = $('.qsm-feature-image-src').val();
425
  var answerType = $('#change-answer-editor').val();
469
  advanced_option[element_id] = $(this).find('select').val();
470
  } else if ($(this).find('input[type="checkbox"]').length > 0) {
471
  var element_id = $(this).find('input[type="checkbox"]').attr('name');
472
+ var multi_value = $(this).find('input[type="checkbox"]:checked').map(function () {
473
+ return this.value;
474
+ }).get().join(',');
475
  element_id = element_id.replace('[]', '');
476
  advanced_option[element_id] = multi_value;
477
  }
478
  });
479
+ model.save({
480
+ type: type,
481
+ name: name,
482
+ question_title: question_title,
483
+ answerInfo: answerInfo,
484
+ comments: comments,
485
+ hint: hint,
486
+ category: category,
487
+ multicategories: multicategories,
488
+ featureImageID: featureImageID,
489
+ featureImageSrc: featureImageSrc,
490
+ answers: answers,
491
+ answerEditor: answerType,
492
+ matchAnswer: matchAnswer,
493
+ other_settings: advanced_option
494
+ }, {
495
+ headers: {
496
+ 'X-WP-Nonce': qsmQuestionSettings.nonce
497
  },
498
+ success: QSMQuestion.saveSuccess,
499
+ error: QSMAdmin.displayError,
500
+ type: 'POST'
501
+ });
502
+ jQuery(document).trigger('qsm_save_question', [questionID, CurrentElement]);
 
 
 
503
  },
504
  saveSuccess: function (model) {
505
  QSMAdmin.displayAlert('Question was saved!', 'success');
510
  if (new_question_title !== '') {
511
  questionName = $.QSMSanitize(new_question_title);
512
  }
513
+ $('.question[data-question-id=' + model.id + ']').replaceWith(template({
514
+ id: model.id,
515
+ type: model.get('type'),
516
+ category: model.get('category'),
517
+ question: questionName
518
+ }));
519
  setTimeout(function () {
520
  $('#save-edit-question-spinner').removeClass('is-active');
521
  }, 250);
527
  }
528
  var answerTemplate = wp.template('single-answer');
529
  if (answer.length >= 7 && answer[6] == 'image') {
530
+ $('#answers').append(answerTemplate({
531
+ answer: decodeEntities(answer[0]),
532
+ points: answer[1],
533
+ correct: answer[2],
534
+ caption: answer[3],
535
+ count: answer[4],
536
+ question_id: answer[5],
537
+ answerType: answer[6],
538
+ form_type: qsmQuestionSettings.form_type,
539
+ quiz_system: qsmQuestionSettings.quiz_system
540
+ }));
541
  } else {
542
+ $('#answers').append(answerTemplate({
543
+ answer: decodeEntities(answer[0]),
544
+ points: answer[1],
545
+ correct: answer[2],
546
+ count: answer[3],
547
+ question_id: answer[4],
548
+ answerType: answer[5],
549
+ form_type: qsmQuestionSettings.form_type,
550
+ quiz_system: qsmQuestionSettings.quiz_system
551
+ }));
552
  }
553
 
554
  // show points field only for polar in survey and simple form
656
  if (get_limit_fu === null || typeof get_limit_fu === "undefined") {
657
  get_limit_fu = '0';
658
  }
659
+ //Get checked question type
660
+ var multicategories = question.get('multicategories');
661
+ $("input[name='tax_input[qsm_category][]']:checkbox").attr("checked", false);
662
+ if (multicategories === null || typeof multicategories === "undefined") {
663
+ //No Action Require
664
+ } else {
665
+ $.each(multicategories, function (i, val) {
666
+ $("input[name='tax_input[qsm_category][]']:checkbox[value='" + val + "']").attr("checked", "true");
667
+ });
668
+ }
669
  //Get featured image
670
  var get_featureImageSrc = question.get('featureImageSrc');
671
  var get_featureImageID = question.get('featureImageID');
675
  //Get checked question type
676
  var get_file_upload_type = question.get('file_upload_type');
677
  $("input[name='file_upload_type[]']:checkbox").attr("checked", false);
678
+ if (get_file_upload_type === null || typeof get_file_upload_type === "undefined") {} else {
 
679
  var fut_arr = get_file_upload_type.split(",");
680
  $.each(fut_arr, function (i) {
681
  $("input[name='file_upload_type[]']:checkbox[value='" + fut_arr[i] + "']").attr("checked", "true");
729
  }
730
  //Append extra settings
731
  var all_setting = question.get('settings');
732
+ if (all_setting === null || typeof all_setting === "undefined") {} else {
 
733
  $.each(all_setting, function (index, value) {
734
  if ($('#' + index + '_area').length > 0) {
735
  if ($('#' + index + '_area').find('input[type="checkbox"]').length > 1) {
752
  //MicroModal.show( 'modal-1' );
753
  $('.questions').sortable('disable');
754
  $('.page').sortable('disable');
755
+
756
+ QSMQuestion.sync_child_parent_category(questionID);
757
+
758
+ jQuery(document).trigger('qsm_open_edit_popup', [questionID, CurrentElement]);
759
  },
760
  openEditPagePopup: function (pageID) {
761
  var page = QSMQuestion.qpages.get(pageID);
784
  };
785
  wp.editor.initialize('question-text', settings);
786
  wp.editor.initialize('correct_answer_info', settings);
787
+ },
788
+ sync_child_parent_category: function (questionID) {
789
+ $('.qsm_category_checklist').find('input').each(function (index, input) {
790
+ $(input).bind('change', function () {
791
+ var checkbox = $(this);
792
+ var is_checked = $(checkbox).is(':checked');
793
+ if (is_checked) {
794
+ $(checkbox).parents('li').children('label').children('input').prop("checked", true);
795
+ } else {
796
+ $(checkbox).parentsUntil('ul').find('input').prop("checked", false);
797
+ }
798
+ jQuery(document).trigger('qsm_sync_child_parent_category', [checkbox, questionID]);
799
+ });
800
+ });
801
  }
802
  };
803
 
804
  $(function () {
805
+ QSMQuestion.pageCollection = Backbone.Collection.extend({
806
+ model: QSMQuestion.page
807
+ });
808
  QSMQuestion.qpages = new QSMQuestion.pageCollection();
809
  QSMQuestion.questionCollection = Backbone.Collection.extend({
810
  url: wpApiSettings.root + 'quiz-survey-master/v1/questions',
841
 
842
  $('.questions').on('click', '.edit-question-button', function (event) {
843
  event.preventDefault();
844
+ $('.qsm-category-filter').trigger('keyup');
845
  QSMQuestion.openEditPopup($(this).parents('.question').data('question-id'), $(this));
846
  });
847
  $('.questions').on('click', '.edit-page-button', function (event) {
1285
  }
1286
  });
1287
  }
1288
+
1289
  function qsmRandomID(length) {
1290
  var result = '';
1291
  var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1295
  }
1296
  return result;
1297
  }
1298
+ $(document).on('keyup', '.qsm-category-filter', function () {
1299
+ search_term = $.trim($(this).val());
1300
+ if (search_term == '') {
1301
+ $('.qsm_category_checklist li').each(function () {
1302
+ $(this).show()
1303
+ });
1304
+ } else {
1305
+ search_term = new RegExp(search_term, 'i');
1306
+ $('.qsm_category_checklist li').each(function () {
1307
+ search_string = $(this).children('label').text();
1308
+ result = search_string.search(search_term);
1309
+ if (result > -1) {
1310
+ $(this).show();
1311
+ if ($(this).parent('ul').hasClass('children')) {
1312
+ $(this).parents('li').show();
1313
+ }
1314
+ } else {
1315
+ $(this).hide();
1316
+ }
1317
+ });
1318
+
1319
+ }
1320
+ });
1321
+
1322
+ $(document).on('click', '.add-multiple-category', function (e) {
1323
+ e.preventDefault();
1324
+ MicroModal.show('modal-9', {
1325
+ onClose: function () {
1326
+ $('#modal-9-content .info').html('');
1327
+ $('#new-category-name').val('');
1328
+ $('#qsm-parent-category').val(-1);
1329
+ }
1330
+ });
1331
+ });
1332
+
1333
+ $(document).on('click', '#save-multi-category-button', function (e) {
1334
+ e.preventDefault();
1335
+ duplicate = false;
1336
+ new_category = $('#new-category-name').val().trim();
1337
+ parent_category = $('#qsm-parent-category option:selected').val();
1338
+ if (new_category == '') {
1339
+ $('#modal-9-content .info').html('Category cannot be empty');
1340
+ return false;
1341
+ } else {
1342
+ $('#qsm-parent-category option').each(function () {
1343
+ if ($(this).text().toLowerCase() == new_category.toLowerCase()) {
1344
+ duplicate = true;
1345
+ $('#modal-9-content .info').html('Category ' + new_category + ' already exists in database');
1346
+ return false;
1347
+ }
1348
+ });
1349
+
1350
+ if (!duplicate) {
1351
+ var new_category_data = {
1352
+ action: 'save_new_category',
1353
+ name: new_category,
1354
+ parent: parent_category
1355
+ };
1356
+ $('#modal-9-content .info').html('');
1357
+ jQuery.ajax(ajaxurl, {
1358
+ data: new_category_data,
1359
+ method: 'POST',
1360
+ success: function (response) {
1361
+ result = JSON.parse(response);
1362
+ if (result.term_id > 0) {
1363
+ $('#qsm-parent-category').append('<option class="level-0" value="' + result.term_id + '">' + new_category + '</option>');
1364
+ if (parent_category == -1) {
1365
+ $('.qsm_category_checklist').prepend('<li id="qsm_category-' + result.term_id + '"><label class="selectit"><input value="' + result.term_id + '" type="checkbox" checked="checked" name="tax_input[qsm_category][]" id="in-qsm_category-' + result.term_id + '"> ' + new_category + '</label></li>');
1366
+ } else {
1367
+ if ($('.qsm_category_checklist li#qsm_category-' + parent_category).children('ul').length > 0) {
1368
+ $('.qsm_category_checklist li#qsm_category-' + parent_category).children('ul').append('<li id="qsm_category-' + result.term_id + '"><label class="selectit"><input value="' + result.term_id + '" type="checkbox" name="tax_input[qsm_category][]" id="in-qsm_category-' + result.term_id + '"> ' + new_category + '</label></li>');
1369
+ } else {
1370
+ $('.qsm_category_checklist li#qsm_category-' + parent_category).append('<ul class="children"><li id="qsm_category-' + result.term_id + '"><label class="selectit"><input value="' + result.term_id + '" type="checkbox" name="tax_input[qsm_category][]" id="in-qsm_category-' + result.term_id + '"> ' + new_category + '</label></li></ul>')
1371
+ }
1372
+ $('.qsm_category_checklist li#qsm_category-' + result.term_id).children('label').children('input').prop('checked', true);
1373
+ $('.qsm_category_checklist li#qsm_category-' + result.term_id).parents('li').each(function () {
1374
+ console.log($(this).children('label').children('input'));
1375
+ $(this).children('label').children('input').prop('checked', true);
1376
+ });
1377
+ }
1378
+ MicroModal.close('modal-9')
1379
+ }
1380
+ }
1381
+ });
1382
+ }
1383
+ }
1384
+ });
1385
+ }(jQuery));
js/qsm-admin-results.js CHANGED
@@ -23,12 +23,13 @@ var QSMAdminResults;
23
  }
24
  $( this ).find( '.results-page-condition' ).each( function() {
25
  page.conditions.push({
 
26
  'criteria': $( this ).children( '.results-page-condition-criteria' ).val(),
27
  'operator': $( this ).children( '.results-page-condition-operator' ).val(),
28
  'value': $( this ).children( '.results-page-condition-value' ).val()
29
  });
30
  });
31
- pages.push( page );
32
  });
33
  var data = {
34
  'pages': pages
@@ -63,27 +64,29 @@ var QSMAdminResults;
63
  })
64
  .fail(QSMAdmin.displayjQueryError);
65
  },
66
- addCondition: function( $page, criteria, operator, value ) {
67
  var template = wp.template( 'results-page-condition' );
68
- $page.find( '.results-page-when-conditions' ).append( template({
69
- 'criteria': criteria,
70
- 'operator': operator,
71
- 'value': value
 
72
  }));
73
  },
74
  newCondition: function( $page ) {
75
- QSMAdminResults.addCondition( $page, 'score', 'equal', 0 );
76
  },
77
- addResultsPage: function( conditions, page, redirect ) {
78
  QSMAdminResults.total += 1;
79
  var template = wp.template( 'results-page' );
80
  $( '#results-pages' ).append( template( { id: QSMAdminResults.total, page: page, redirect: redirect } ) );
81
  conditions.forEach( function( condition, i, conditions) {
82
  QSMAdminResults.addCondition(
83
- $( '.results-page:last-child' ),
84
- condition.criteria,
85
- condition.operator,
86
- condition.value
 
87
  );
88
  });
89
  var settings = {
@@ -99,6 +102,7 @@ var QSMAdminResults;
99
  },
100
  newResultsPage: function() {
101
  var conditions = [{
 
102
  'criteria': 'score',
103
  'operator': 'greater',
104
  'value': '0'
23
  }
24
  $( this ).find( '.results-page-condition' ).each( function() {
25
  page.conditions.push({
26
+ 'category': $(this).children('.results-page-condition-category').val(),
27
  'criteria': $( this ).children( '.results-page-condition-criteria' ).val(),
28
  'operator': $( this ).children( '.results-page-condition-operator' ).val(),
29
  'value': $( this ).children( '.results-page-condition-value' ).val()
30
  });
31
  });
32
+ pages.push(page);
33
  });
34
  var data = {
35
  'pages': pages
64
  })
65
  .fail(QSMAdmin.displayjQueryError);
66
  },
67
+ addCondition: function ($page, category, criteria, operator, value) {
68
  var template = wp.template( 'results-page-condition' );
69
+ $page.find('.results-page-when-conditions').append(template({
70
+ 'category': category,
71
+ 'criteria': criteria,
72
+ 'operator': operator,
73
+ 'value': value
74
  }));
75
  },
76
  newCondition: function( $page ) {
77
+ QSMAdminResults.addCondition($page, '', 'score', 'equal', 0);
78
  },
79
+ addResultsPage: function (conditions, page, redirect) {
80
  QSMAdminResults.total += 1;
81
  var template = wp.template( 'results-page' );
82
  $( '#results-pages' ).append( template( { id: QSMAdminResults.total, page: page, redirect: redirect } ) );
83
  conditions.forEach( function( condition, i, conditions) {
84
  QSMAdminResults.addCondition(
85
+ $('.results-page:last-child'),
86
+ condition.category,
87
+ condition.criteria,
88
+ condition.operator,
89
+ condition.value
90
  );
91
  });
92
  var settings = {
102
  },
103
  newResultsPage: function() {
104
  var conditions = [{
105
+ 'category': '',
106
  'criteria': 'score',
107
  'operator': 'greater',
108
  'value': '0'
js/qsm-admin.js CHANGED
@@ -5,197 +5,201 @@
5
  var QSMQuizzesSurveys;
6
  (function ($) {
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 ) {
24
- var template = wp.template( 'quiz-row' );
25
- var values = {
26
- 'id': quizData.id,
27
- 'name': quizData.name,
28
- 'link': quizData.link,
29
- 'postID': quizData.postID,
30
- 'views': quizData.views,
31
- 'taken': quizData.taken,
32
- 'lastActivity': quizData.lastActivity,
33
- 'lastActivityDateTime': quizData.lastActivityDateTime,
34
- 'post_status' : quizData.post_status != 'publish' ? '— ' + quizData.post_status : ''
35
- };
36
- var row = $( template( values ) );
37
- $( '#the-list' ).append( row );
38
- },
39
- searchQuizzes: function( query ) {
40
- $( ".qsm-quiz-row" ).each(function() {
41
- if ( -1 === $( this ).find( '.row-title' ).text().toLowerCase().indexOf( query.toLowerCase() ) ) {
42
- $( this ).hide();
43
- } else {
44
- $( this ).show();
45
- }
46
- });
47
- },
48
- deleteQuiz: function( quiz_id ) {
49
- $( '#delete_quiz_id' ).val( quiz_id );
50
- $.each( qsmQuizObject, function( i, val ) {
51
- if ( val.id == quiz_id ) {
52
- $( '#delete_quiz_name' ).val( val.name );
53
- }
54
- });
55
- MicroModal.show( 'modal-5' );
56
- },
57
- editQuizName: function( quiz_id ) {
58
- $( '#edit_quiz_id' ).val( quiz_id );
59
- $.each( qsmQuizObject, function( i, val ) {
60
- if ( val.id == quiz_id ) {
61
- $( '#edit_quiz_name' ).val( val.name );
62
- }
63
- });
64
- MicroModal.show( 'modal-3' );
65
- },
66
- duplicateQuiz: function( quiz_id ) {
67
- $( '#duplicate_quiz_id' ).val( quiz_id );
68
- MicroModal.show( 'modal-4' );
69
- },
70
- /**
71
- * Opens the popup to reset quiz stats
72
- *
73
- * @param int The ID of the quiz
74
- */
75
- openResetPopup: function( quiz_id ) {
76
- quiz_id = parseInt( quiz_id );
77
- $( '#reset_quiz_id' ).val( quiz_id );
78
- MicroModal.show( 'modal-1' );
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('#accordion h3.ui-accordion-header').next().slideDown();
106
- jQuery('.template-list .template-list-inner:first-child').trigger('click');
107
- }
108
- });
109
- //Get quiz options
110
- $('.template-list-inner').click(function(){
111
- var action = 'qsm_wizard_template_quiz_options';
112
- var settings = $(this).data('settings');
113
- var addons = $(this).data('addons');
114
- $('.template-list .template-list-inner').removeClass('selected-quiz-template');
115
- $(this).addClass('selected-quiz-template');
116
- $('#quiz_settings_wrapper').html('').html('<div class="qsm-spinner-loader"></div>');
117
- $('#recomm_addons_wrapper').html('').html('<div class="qsm-spinner-loader"></div>');
118
- $.post(ajaxurl, {settings: settings, addons: addons, action: action },
119
- function (data) {
120
- var diff_html = data.split('=====');
121
- $('#quiz_settings_wrapper').html('');
122
- $('#quiz_settings_wrapper').html(diff_html[0]);
123
- $('#recomm_addons_wrapper').html('');
124
- $('#recomm_addons_wrapper').html(diff_html[1]);
125
- $( "#accordion" ).accordion();
126
- $('#accordion h3.ui-accordion-header').next().slideDown();
127
- $( '#quiz_settings_wrapper select' ).each(function(){
128
- var name = $(this).attr('name');
129
- var value = $(this).val();
130
- if( $( '.' + name + '_' + value ).length > 0 ){
131
- $( '.' + name + '_' + value ).show();
132
- }
133
- });
134
- }
135
- );
136
- });
137
- $( '#show_import_export_popup' ).on( 'click', function( event ) {
138
- event.preventDefault();
139
- MicroModal.show( 'modal-export-import' );
140
- });
141
- $(document).on('change', '.qsm_tab_content select, #quiz_settings_wrapper select', function(){
142
- var name = $(this).attr('name');
143
- var value = $(this).val();
144
- $( '.qsm_hidden_tr' ).hide();
145
- if( $( '.' + name + '_' + value ).length > 0 ){
146
- $( '.' + name + '_' + value ).show();
147
- }
148
- });
149
-
150
- /*$( '#quiz_search' ).keyup( function() {
151
- QSMQuizzesSurveys.searchQuizzes( $( this ).val() );
152
- });*/
153
- $( document ).on( 'click', '#the-list .qsm-action-link-delete', function( event ) {
154
- event.preventDefault();
155
- QSMQuizzesSurveys.deleteQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
156
- });
157
- $( document ).on( 'click', '#the-list .qsm-action-link-duplicate', function( event ) {
158
- event.preventDefault();
159
- QSMQuizzesSurveys.duplicateQuiz( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
160
- });
161
- $( document ).on( 'click', '#the-list .qsm-edit-name', function( event ) {
162
- event.preventDefault();
163
- QSMQuizzesSurveys.editQuizName( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
164
- });
165
- $( document ).on( 'click', '#the-list .qsm-action-link-reset', function( event ) {
166
- event.preventDefault();
167
- QSMQuizzesSurveys.openResetPopup( $( this ).parents( '.qsm-quiz-row' ).data( 'id' ) );
168
- });
169
- $( '#reset-stats-button' ).on( 'click', function( event ) {
170
- event.preventDefault();
171
- $( '#reset_quiz_form' ).submit();
172
- });
173
- $( '#duplicate-quiz-button' ).on( 'click', function( event ) {
174
- event.preventDefault();
175
- $( '#duplicate-quiz-form' ).submit();
176
- });
177
- $( '#delete-quiz-button' ).on( 'click', function( event ) {
178
- event.preventDefault();
179
- $( '#delete-quiz-form' ).submit();
180
- });
181
- QSMQuizzesSurveys.load();
182
- $(document).on('click','.qsm-list-shortcode-view',function(e){
183
- e.preventDefault();
184
- var embed_text = $(this).siblings('.sc-embed').text();
185
- var link_text = $(this).siblings('.sc-link').text();
186
- $('#sc-shortcode-model-text').val( embed_text );
187
- $('#sc-shortcode-model-text-link').val( link_text );
188
- MicroModal.show( 'modal-6' );
189
- });
190
- $(document).on('click','#sc-copy-shortcode', function(){
191
- var copyText = document.getElementById("sc-shortcode-model-text");
192
- copyText.select();
193
- document.execCommand("copy");
194
- });
195
- $(document).on('click','#sc-copy-shortcode-link', function(){
196
- var copyText = document.getElementById("sc-shortcode-model-text-link");
197
- copyText.select();
198
- document.execCommand("copy");
199
- });
200
- });
201
- }(jQuery));
 
 
 
 
5
  var QSMQuizzesSurveys;
6
  (function ($) {
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) {
24
+ var template = wp.template('quiz-row');
25
+ var values = {
26
+ 'id': quizData.id,
27
+ 'name': quizData.name,
28
+ 'link': quizData.link,
29
+ 'postID': quizData.postID,
30
+ 'views': quizData.views,
31
+ 'taken': quizData.taken,
32
+ 'lastActivity': quizData.lastActivity,
33
+ 'lastActivityDateTime': quizData.lastActivityDateTime,
34
+ 'post_status': quizData.post_status != 'publish' ? '— ' + quizData.post_status : ''
35
+ };
36
+ var row = $(template(values));
37
+ $('#the-list').append(row);
38
+ },
39
+ searchQuizzes: function (query) {
40
+ $(".qsm-quiz-row").each(function () {
41
+ if (-1 === $(this).find('.row-title').text().toLowerCase().indexOf(query.toLowerCase())) {
42
+ $(this).hide();
43
+ } else {
44
+ $(this).show();
45
+ }
46
+ });
47
+ },
48
+ deleteQuiz: function (quiz_id) {
49
+ $('#delete_quiz_id').val(quiz_id);
50
+ $.each(qsmQuizObject, function (i, val) {
51
+ if (val.id == quiz_id) {
52
+ $('#delete_quiz_name').val(val.name);
53
+ }
54
+ });
55
+ MicroModal.show('modal-5');
56
+ },
57
+ editQuizName: function (quiz_id) {
58
+ $('#edit_quiz_id').val(quiz_id);
59
+ $.each(qsmQuizObject, function (i, val) {
60
+ if (val.id == quiz_id) {
61
+ $('#edit_quiz_name').val(val.name);
62
+ }
63
+ });
64
+ MicroModal.show('modal-3');
65
+ },
66
+ duplicateQuiz: function (quiz_id) {
67
+ $('#duplicate_quiz_id').val(quiz_id);
68
+ MicroModal.show('modal-4');
69
+ },
70
+ /**
71
+ * Opens the popup to reset quiz stats
72
+ *
73
+ * @param int The ID of the quiz
74
+ */
75
+ openResetPopup: function (quiz_id) {
76
+ quiz_id = parseInt(quiz_id);
77
+ $('#reset_quiz_id').val(quiz_id);
78
+ MicroModal.show('modal-1');
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('#accordion h3.ui-accordion-header').next().slideDown();
106
+ jQuery('.template-list .template-list-inner:first-child').trigger('click');
107
+ }
108
+ });
109
+ //Get quiz options
110
+ $('.template-list-inner').click(function () {
111
+ var action = 'qsm_wizard_template_quiz_options';
112
+ var settings = $(this).data('settings');
113
+ var addons = $(this).data('addons');
114
+ $('.template-list .template-list-inner').removeClass('selected-quiz-template');
115
+ $(this).addClass('selected-quiz-template');
116
+ $('#quiz_settings_wrapper').html('').html('<div class="qsm-spinner-loader"></div>');
117
+ $('#recomm_addons_wrapper').html('').html('<div class="qsm-spinner-loader"></div>');
118
+ $.post(ajaxurl, {
119
+ settings: settings,
120
+ addons: addons,
121
+ action: action
122
+ },
123
+ function (data) {
124
+ var diff_html = data.split('=====');
125
+ $('#quiz_settings_wrapper').html('');
126
+ $('#quiz_settings_wrapper').html(diff_html[0]);
127
+ $('#recomm_addons_wrapper').html('');
128
+ $('#recomm_addons_wrapper').html(diff_html[1]);
129
+ $("#accordion").accordion();
130
+ $('#accordion h3.ui-accordion-header').next().slideDown();
131
+ $('#quiz_settings_wrapper select').each(function () {
132
+ var name = $(this).attr('name');
133
+ var value = $(this).val();
134
+ if ($('.' + name + '_' + value).length > 0) {
135
+ $('.' + name + '_' + value).show();
136
+ }
137
+ });
138
+ }
139
+ );
140
+ });
141
+ $('#show_import_export_popup').on('click', function (event) {
142
+ event.preventDefault();
143
+ MicroModal.show('modal-export-import');
144
+ });
145
+ $(document).on('change', '.qsm_tab_content select, #quiz_settings_wrapper select', function () {
146
+ var name = $(this).attr('name');
147
+ var value = $(this).val();
148
+ $('.qsm_hidden_tr').hide();
149
+ if ($('.' + name + '_' + value).length > 0) {
150
+ $('.' + name + '_' + value).show();
151
+ }
152
+ });
153
+
154
+ /*$( '#quiz_search' ).keyup( function() {
155
+ QSMQuizzesSurveys.searchQuizzes( $( this ).val() );
156
+ });*/
157
+ $(document).on('click', '#the-list .qsm-action-link-delete', function (event) {
158
+ event.preventDefault();
159
+ QSMQuizzesSurveys.deleteQuiz($(this).parents('.qsm-quiz-row').data('id'));
160
+ });
161
+ $(document).on('click', '#the-list .qsm-action-link-duplicate', function (event) {
162
+ event.preventDefault();
163
+ QSMQuizzesSurveys.duplicateQuiz($(this).parents('.qsm-quiz-row').data('id'));
164
+ });
165
+ $(document).on('click', '#the-list .qsm-edit-name', function (event) {
166
+ event.preventDefault();
167
+ QSMQuizzesSurveys.editQuizName($(this).parents('.qsm-quiz-row').data('id'));
168
+ });
169
+ $(document).on('click', '#the-list .qsm-action-link-reset', function (event) {
170
+ event.preventDefault();
171
+ QSMQuizzesSurveys.openResetPopup($(this).parents('.qsm-quiz-row').data('id'));
172
+ });
173
+ $('#reset-stats-button').on('click', function (event) {
174
+ event.preventDefault();
175
+ $('#reset_quiz_form').submit();
176
+ });
177
+ $('#duplicate-quiz-button').on('click', function (event) {
178
+ event.preventDefault();
179
+ $('#duplicate-quiz-form').submit();
180
+ });
181
+ $('#delete-quiz-button').on('click', function (event) {
182
+ event.preventDefault();
183
+ $('#delete-quiz-form').submit();
184
+ });
185
+ QSMQuizzesSurveys.load();
186
+ $(document).on('click', '.qsm-list-shortcode-view', function (e) {
187
+ e.preventDefault();
188
+ var embed_text = $(this).siblings('.sc-embed').text();
189
+ var link_text = $(this).siblings('.sc-link').text();
190
+ $('#sc-shortcode-model-text').val(embed_text);
191
+ $('#sc-shortcode-model-text-link').val(link_text);
192
+ MicroModal.show('modal-6');
193
+ });
194
+ $(document).on('click', '#sc-copy-shortcode', function () {
195
+ var copyText = document.getElementById("sc-shortcode-model-text");
196
+ copyText.select();
197
+ document.execCommand("copy");
198
+ });
199
+ $(document).on('click', '#sc-copy-shortcode-link', function () {
200
+ var copyText = document.getElementById("sc-shortcode-model-text-link");
201
+ copyText.select();
202
+ document.execCommand("copy");
203
+ });
204
+ });
205
+ }(jQuery));
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: 7.2.3
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.2.3
13
  * @package QSM
14
  */
15
 
@@ -41,7 +41,7 @@ class MLWQuizMasterNext {
41
  * @var string
42
  * @since 4.0.0
43
  */
44
- public $version = '7.2.3';
45
 
46
  /**
47
  * QSM Alert Manager Object
@@ -95,10 +95,18 @@ class MLWQuizMasterNext {
95
  * QSM theme settings object
96
  *
97
  * @var object
98
- * @since 7.1.15
99
  */
100
  public $theme_settings;
101
 
 
 
 
 
 
 
 
 
102
  /**
103
  * Main Construct Function
104
  *
@@ -187,6 +195,9 @@ class MLWQuizMasterNext {
187
  include 'php/classes/class-qsm-theme-settings.php';
188
  $this->theme_settings = new QSM_Theme_Settings();
189
 
 
 
 
190
  include 'php/rest-api.php';
191
  }
192
 
@@ -202,9 +213,24 @@ class MLWQuizMasterNext {
202
  add_action( 'admin_menu', array( $this, 'setup_admin_menu' ) );
203
  add_action( 'admin_head', array( $this, 'admin_head' ), 900 );
204
  add_action( 'init', array( $this, 'register_quiz_post_types' ) );
 
205
  add_action( 'plugins_loaded', array( &$this, 'qsm_load_textdomain' ) );
206
  add_action( 'admin_enqueue_scripts', array( $this, 'qsm_admin_scripts_style' ) );
207
  add_action( 'admin_init', array( $this, 'qsm_overide_old_setting_options' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
 
210
  /**
@@ -230,6 +256,12 @@ class MLWQuizMasterNext {
230
  wp_enqueue_script( 'qsm_admin_js', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), $this->version );
231
  wp_enqueue_media();
232
  }
 
 
 
 
 
 
233
  }
234
 
235
  /**
@@ -302,6 +334,41 @@ class MLWQuizMasterNext {
302
 
303
  // Registers post type.
304
  register_post_type( 'qsm_quiz', $quiz_args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  }
306
 
307
  /**
@@ -315,10 +382,14 @@ class MLWQuizMasterNext {
315
  public function setup_admin_menu() {
316
  if ( function_exists( 'add_menu_page' ) ) {
317
  global $qsm_quiz_list_page;
 
318
  $qsm_dashboard_page = add_menu_page( 'Quiz And Survey Master', __( 'QSM', 'quiz-master-next' ), 'edit_posts', 'qsm_dashboard', 'qsm_generate_dashboard_page', 'dashicons-feedback' );
319
  add_submenu_page( 'qsm_dashboard', __( 'Dashboard', 'quiz-master-next' ), __( 'Dashboard', 'quiz-master-next' ), 'edit_posts', 'qsm_dashboard', 'qsm_generate_dashboard_page' );
320
  $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' );
321
  add_action( "load-$qsm_quiz_list_page", 'qsm_generate_quizzes_surveys_page_screen_options' );
 
 
 
322
  add_submenu_page( null, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'edit_posts', 'mlw_quiz_options', 'qsm_generate_quiz_options' );
323
  add_submenu_page( 'qsm_dashboard', __( 'Results', 'quiz-master-next' ), __( 'Results', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_results', 'qsm_generate_admin_results_page' );
324
  add_submenu_page( null, __( 'Result Details', 'quiz-master-next' ), __( 'Result Details', 'quiz-master-next' ), 'moderate_comments', 'qsm_quiz_result_details', 'qsm_generate_result_details' );
@@ -355,27 +426,59 @@ class MLWQuizMasterNext {
355
  * @return void
356
  */
357
  public function qsm_overide_old_setting_options() {
358
- $settings = (array) get_option( 'qmn-settings' );
359
 
360
- if (isset($settings['facebook_app_id'])) {
361
 
362
- $facebook_app_id = $settings['facebook_app_id'];
363
-
364
- if ( $facebook_app_id == '483815031724529' ) {
 
 
 
 
365
  $settings['facebook_app_id'] = '594986844960937';
366
  update_option( 'qmn-settings', $settings );
367
  }
368
- }
369
- else{
370
- $settings['facebook_app_id'] = '594986844960937';
371
- update_option( 'qmn-settings', $settings );
372
- }
373
-
374
 
375
  }
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
 
379
  global $mlwQuizMasterNext;
380
  $mlwQuizMasterNext = new MLWQuizMasterNext();
381
- register_activation_hook( __FILE__, array( 'QSM_Install', 'install' ) );
2
  /**
3
  * Plugin Name: Quiz And Survey Master
4
  * Description: Easily and quickly add quizzes and surveys to your website.
5
+ * Version: 7.3.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.3.0
13
  * @package QSM
14
  */
15
 
41
  * @var string
42
  * @since 4.0.0
43
  */
44
+ public $version = '7.3.0';
45
 
46
  /**
47
  * QSM Alert Manager Object
95
  * QSM theme settings object
96
  *
97
  * @var object
98
+ * @since 7.2.0
99
  */
100
  public $theme_settings;
101
 
102
+ /**
103
+ * QSM migration helper object
104
+ *
105
+ * @var object
106
+ * @since 7.3.0
107
+ */
108
+ public $migrationHelper;
109
+
110
  /**
111
  * Main Construct Function
112
  *
195
  include 'php/classes/class-qsm-theme-settings.php';
196
  $this->theme_settings = new QSM_Theme_Settings();
197
 
198
+ include 'php/classes/class-qsm-migrate.php';
199
+ $this->migrationHelper = new QSM_Migrate();
200
+
201
  include 'php/rest-api.php';
202
  }
203
 
213
  add_action( 'admin_menu', array( $this, 'setup_admin_menu' ) );
214
  add_action( 'admin_head', array( $this, 'admin_head' ), 900 );
215
  add_action( 'init', array( $this, 'register_quiz_post_types' ) );
216
+ add_filter( 'parent_file', array( &$this, 'parent_file' ), 9999, 1 );
217
  add_action( 'plugins_loaded', array( &$this, 'qsm_load_textdomain' ) );
218
  add_action( 'admin_enqueue_scripts', array( $this, 'qsm_admin_scripts_style' ) );
219
  add_action( 'admin_init', array( $this, 'qsm_overide_old_setting_options' ) );
220
+ add_action( 'admin_notices', array( $this, 'qsm_admin_notices' ) );
221
+ add_filter( 'manage_edit-qsm_category_columns', array( $this, 'modify_qsm_category_columns' ) );
222
+ }
223
+
224
+ /**
225
+ * Modifies QSM Category taxonomy columns
226
+ *
227
+ * @param array $columns
228
+ * @return array
229
+ * @since 7.3.0
230
+ */
231
+ public function modify_qsm_category_columns( $columns ) {
232
+ unset( $columns['posts'] );
233
+ return $columns;
234
  }
235
 
236
  /**
256
  wp_enqueue_script( 'qsm_admin_js', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), $this->version );
257
  wp_enqueue_media();
258
  }
259
+
260
+ if ( strpos( $hook, 'qsm' ) !== false || strpos( $hook, 'mlw_quiz' ) !== false ) {
261
+ wp_enqueue_script( 'qsm_admin_notices_script', plugins_url( 'js/qsm-admin-notices.js', __FILE__ ), array( 'jquery' ), $this->version, true );
262
+ wp_localize_script( 'qsm_admin_notices_script', 'qsm_notices_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
263
+ }
264
+
265
  }
266
 
267
  /**
334
 
335
  // Registers post type.
336
  register_post_type( 'qsm_quiz', $quiz_args );
337
+
338
+ /**
339
+ * Register Taxonomy
340
+ */
341
+ $taxonomy_args = array(
342
+ 'labels' => array(
343
+ 'menu_name' => __( 'Question Categories', 'quiz-master-next' ),
344
+ 'name' => __( 'Categories', 'quiz-master-next' ),
345
+ 'singular_name' => __( 'Category', 'quiz-master-next' ),
346
+ 'all_items' => __( 'All Categories', 'quiz-master-next' ),
347
+ 'parent_item' => __( 'Parent Category', 'quiz-master-next' ),
348
+ 'parent_item_colon' => __( 'Parent Category:', 'quiz-master-next' ),
349
+ 'new_item_name' => __( 'New Category Name', 'quiz-master-next' ),
350
+ 'add_new_item' => __( 'Add New Category', 'quiz-master-next' ),
351
+ 'edit_item' => __( 'Edit Category', 'quiz-master-next' ),
352
+ 'update_item' => __( 'Update Category', 'quiz-master-next' ),
353
+ 'view_item' => __( 'View Category', 'quiz-master-next' ),
354
+ ),
355
+ 'hierarchical' => true,
356
+ 'public' => true,
357
+ 'show_ui' => true,
358
+ 'show_admin_column' => true,
359
+ 'show_in_nav_menus' => true,
360
+ 'show_tagcloud' => false,
361
+ 'rewrite' => false,
362
+ );
363
+ register_taxonomy( 'qsm_category', array( 'qsm-taxonomy' ), $taxonomy_args );
364
+ }
365
+
366
+ public function parent_file( $parent_file ) {
367
+ global $menu, $submenu, $parent_file, $submenu_file;
368
+ if ( 'edit-tags.php?taxonomy=qsm_category' == $submenu_file ) {
369
+ $parent_file = 'qsm_dashboard';
370
+ }
371
+ return $parent_file;
372
  }
373
 
374
  /**
382
  public function setup_admin_menu() {
383
  if ( function_exists( 'add_menu_page' ) ) {
384
  global $qsm_quiz_list_page;
385
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
386
  $qsm_dashboard_page = add_menu_page( 'Quiz And Survey Master', __( 'QSM', 'quiz-master-next' ), 'edit_posts', 'qsm_dashboard', 'qsm_generate_dashboard_page', 'dashicons-feedback' );
387
  add_submenu_page( 'qsm_dashboard', __( 'Dashboard', 'quiz-master-next' ), __( 'Dashboard', 'quiz-master-next' ), 'edit_posts', 'qsm_dashboard', 'qsm_generate_dashboard_page' );
388
  $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' );
389
  add_action( "load-$qsm_quiz_list_page", 'qsm_generate_quizzes_surveys_page_screen_options' );
390
+ if ( $enabled && $enabled != 'cancelled' ) {
391
+ $qsm_taxonomy_menu_hook = add_submenu_page( 'qsm_dashboard', __( 'Question Categories', 'quiz-master-next' ), __( 'Question Categories', 'quiz-master-next' ), 'edit_posts', 'edit-tags.php?taxonomy=qsm_category' );
392
+ }
393
  add_submenu_page( null, __( 'Settings', 'quiz-master-next' ), __( 'Settings', 'quiz-master-next' ), 'edit_posts', 'mlw_quiz_options', 'qsm_generate_quiz_options' );
394
  add_submenu_page( 'qsm_dashboard', __( 'Results', 'quiz-master-next' ), __( 'Results', 'quiz-master-next' ), 'moderate_comments', 'mlw_quiz_results', 'qsm_generate_admin_results_page' );
395
  add_submenu_page( null, __( 'Result Details', 'quiz-master-next' ), __( 'Result Details', 'quiz-master-next' ), 'moderate_comments', 'qsm_quiz_result_details', 'qsm_generate_result_details' );
426
  * @return void
427
  */
428
  public function qsm_overide_old_setting_options() {
429
+ $settings = (array) get_option( 'qmn-settings' );
430
 
431
+ if ( isset( $settings['facebook_app_id'] ) ) {
432
 
433
+ $facebook_app_id = $settings['facebook_app_id'];
434
+
435
+ if ( $facebook_app_id == '483815031724529' ) {
436
+ $settings['facebook_app_id'] = '594986844960937';
437
+ update_option( 'qmn-settings', $settings );
438
+ }
439
+ } else {
440
  $settings['facebook_app_id'] = '594986844960937';
441
  update_option( 'qmn-settings', $settings );
442
  }
 
 
 
 
 
 
443
 
444
  }
445
 
446
+ /**
447
+ * Displays QSM Admin notices
448
+ *
449
+ * @return void
450
+ * @since 7.3.0
451
+ */
452
+ public function qsm_admin_notices() {
453
+ $multiple_categories = get_option( 'qsm_multiple_category_enabled' );
454
+ if ( ! $multiple_categories ) {
455
+ ?>
456
+ <div class="notice notice-info multiple-category-notice" style="display:none;">
457
+ <h3>
458
+ <?php _e( 'Database update required', 'quiz-master-next' ); ?>
459
+ </h3>
460
+ <p>
461
+ <?php
462
+ $message = __( ' QSM has been updated! ', 'quiz-master-next' );
463
+ $message .= sprintf( __( '%1$s We need to upgrade your database so that you can enjoy the latest features. ', 'quiz-master-next' ), '<br/>' );
464
+ $message .= sprintf( __( '%1$s Please note that this action %2$s can not be %3$s rolled back. We recommend you to take a backup of your current site before proceeding.', 'quiz-master-next' ), '<br/>', '<b>', '</b>' );
465
+ echo $message;
466
+ ?>
467
+ </p>
468
+ <p class="category-action">
469
+ <?php
470
+ $buttons = sprintf( __( '%1$s Cancel %2$s', 'quiz-master-next' ), '<a href="#" class="button cancel-multiple-category">', '</a>' );
471
+ $buttons .= sprintf( __( '%1$s Update Database %2$s', 'quiz-master-next' ), '&nbsp;&nbsp;&nbsp;<a href="#" class="button button-primary enable-multiple-category">', '</a>' );
472
+ echo $buttons;
473
+ ?>
474
+ </p>
475
+ </div>
476
+ <?php
477
+ }
478
+ }
479
+
480
  }
481
 
482
  global $mlwQuizMasterNext;
483
  $mlwQuizMasterNext = new MLWQuizMasterNext();
484
+ register_activation_hook( __FILE__, array( 'QSM_Install', 'install' ) );
php/admin/admin-results-details-page.php CHANGED
@@ -16,6 +16,9 @@ function qsm_generate_result_details() {
16
  wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
17
  wp_style_add_data( 'qsm_admin_style', 'rtl', 'replace' );
18
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
 
 
 
19
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'results';
20
  $tab_array = $mlwQuizMasterNext->pluginHelper->get_results_tabs();
21
  ?>
@@ -284,6 +287,7 @@ $results_array = array(
284
  'comments' => isset( $results[2] ) ? $results[2] : '',
285
  'question_answers_array' => isset( $results[1] ) ? $results[1] : array(),
286
  'contact' => $results["contact"],
 
287
  'results' => $results,
288
  );
289
 
@@ -293,7 +297,13 @@ $template = str_replace( "\n" , "<br>", $template );
293
  if( $new_template_result_detail == 0 ){
294
  echo '<div class="old_template_result_wrap">';
295
  }
296
- echo wp_kses_post( $template );
 
 
 
 
 
 
297
  if( $new_template_result_detail == 0 ){
298
  echo '</div>';
299
  }
16
  wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
17
  wp_style_add_data( 'qsm_admin_style', 'rtl', 'replace' );
18
  wp_enqueue_script( 'math_jax', '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML' );
19
+ wp_enqueue_script( 'jquery-ui-slider-js', plugins_url( '../../js/jquery-ui.js', __FILE__ ) );
20
+ wp_enqueue_script( 'jquery-ui-slider-rtl-js', plugins_url( '../../js/jquery.ui.slider-rtl.js', __FILE__ ) );
21
+ wp_enqueue_style( 'jquery-ui-slider-rtl-css', plugins_url( '../../css/jquery.ui.slider-rtl.css', __FILE__ ) );
22
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'results';
23
  $tab_array = $mlwQuizMasterNext->pluginHelper->get_results_tabs();
24
  ?>
287
  'comments' => isset( $results[2] ) ? $results[2] : '',
288
  'question_answers_array' => isset( $results[1] ) ? $results[1] : array(),
289
  'contact' => $results["contact"],
290
+ 'result_id' => $result_id,
291
  'results' => $results,
292
  );
293
 
297
  if( $new_template_result_detail == 0 ){
298
  echo '<div class="old_template_result_wrap">';
299
  }
300
+
301
+ $is_allow_html = apply_filters('qsm_admin_results_details_page_allow_html', false);
302
+ if ($is_allow_html) {
303
+ echo $template;
304
+ } else {
305
+ echo wp_kses_post($template);
306
+ }
307
  if( $new_template_result_detail == 0 ){
308
  echo '</div>';
309
  }
php/admin/functions.php CHANGED
@@ -317,6 +317,37 @@ function qsm_display_question_option( $key, $single_option ) {
317
  </p>
318
  </div>
319
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  <?php
321
  break;
322
 
@@ -478,7 +509,7 @@ function qsm_create_new_quiz_wizard() {
478
  'value' => 0,
479
  ),
480
  'system' => array(
481
- 'option_name' => __( 'Graded System', 'quiz-master-next' ),
482
  'value' => 0,
483
  ),
484
  'pagination' => array(
@@ -701,15 +732,27 @@ function qsm_update_question_type_col_val() {
701
  */
702
  function qsm_check_create_tables() {
703
  global $wpdb;
 
 
704
  $quiz_table_name = $wpdb->prefix . 'mlw_quizzes';
705
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
706
- QSM_Install::install();
707
  }
708
 
709
  $quiz_theme_table_name = $wpdb->prefix . 'mlw_themes';
710
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_theme_table_name'" ) != $quiz_theme_table_name ) {
 
 
 
 
 
 
 
 
 
711
  QSM_Install::install();
712
  }
 
713
  }
714
  add_action( 'admin_init', 'qsm_check_create_tables' );
715
 
317
  </p>
318
  </div>
319
  </div>
320
+ <?php
321
+ break;
322
+
323
+ case 'multi_category':
324
+ ?>
325
+ <div id="multi_category_area" class="qsm-row <?php echo $show_class; ?>">
326
+ <label>
327
+ <?php echo isset( $single_option['label'] ) ? $single_option['label'] : ''; ?>
328
+ <?php echo $tooltip; ?>
329
+ <?php echo $document_text; ?>
330
+ </label>
331
+ <div id="multi_categories_wrapper" class="categorydiv">
332
+ <input type='text' class='qsm-category-filter' placeholder=' <?php _e( ' Search', 'quiz-master-next' ); ?> '>
333
+ <ul id=" multicategories_checklist" class="qsm_category_checklist categorychecklist form-no-clear">
334
+ <?php
335
+ wp_terms_checklist(
336
+ 0,
337
+ array(
338
+ 'taxonomy' => 'qsm_category',
339
+ 'descendants_and_self' => 0,
340
+ 'selected_cats' => false,
341
+ 'echo' => true,
342
+ )
343
+ );
344
+ ?>
345
+ </ul>
346
+ <a href='#' class='button button-primary add-multiple-category'>
347
+ <?php _e( '+ Add New Category ', 'quiz-master-next' ); ?>
348
+ </a>
349
+ </div>
350
+ </div>
351
  <?php
352
  break;
353
 
509
  'value' => 0,
510
  ),
511
  'system' => array(
512
+ 'option_name' => __( 'Grading System', 'quiz-master-next' ),
513
  'value' => 0,
514
  ),
515
  'pagination' => array(
732
  */
733
  function qsm_check_create_tables() {
734
  global $wpdb;
735
+ $install = false;
736
+
737
  $quiz_table_name = $wpdb->prefix . 'mlw_quizzes';
738
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
739
+ $install = true;
740
  }
741
 
742
  $quiz_theme_table_name = $wpdb->prefix . 'mlw_themes';
743
  if ( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_theme_table_name'" ) != $quiz_theme_table_name ) {
744
+ $install = true;
745
+ }
746
+
747
+ $question_terms_table_name = $wpdb->prefix . 'mlw_question_terms';
748
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$question_terms_table_name'" ) != $question_terms_table_name ) {
749
+ $install = true;
750
+ }
751
+
752
+ if ( $install ) {
753
  QSM_Install::install();
754
  }
755
+
756
  }
757
  add_action( 'admin_init', 'qsm_check_create_tables' );
758
 
php/admin/options-page-email-tab.php CHANGED
@@ -30,46 +30,61 @@ add_action( 'plugins_loaded', 'qsm_settings_email_tab', 5 );
30
  function qsm_options_emails_tab_content() {
31
  global $wpdb;
32
  global $mlwQuizMasterNext;
33
- $quiz_id = intval( $_GET['quiz_id'] );
34
- $user_id = get_current_user_id();
35
- $js_data = array(
36
- 'quizID' => $quiz_id,
37
- 'nonce' => wp_create_nonce( 'wp_rest' ),
38
- 'qsm_user_ve' => get_user_meta($user_id, 'rich_editing', true),
39
  );
 
 
 
 
 
 
 
 
 
 
40
  wp_enqueue_script( 'qsm_emails_admin_script', plugins_url( '../../js/qsm-admin-emails.js', __FILE__ ), array( 'jquery-ui-sortable', 'qmn_admin_js' ), $mlwQuizMasterNext->version );
41
  wp_localize_script( 'qsm_emails_admin_script', 'qsmEmailsObject', $js_data );
42
  wp_enqueue_editor();
43
  wp_enqueue_media();
44
- ?>
45
-
46
- <!-- Emails Section -->
47
- <section class="qsm-quiz-email-tab" style="margin-top: 15px;">
48
- <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
49
- <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
50
- <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>
51
- <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>
52
- <div id="qsm_emails"><div style="margin-bottom: 30px;margin-top: 35px;" class="qsm-spinner-loader"></div></div>
53
- <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
54
- <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
55
- <div class="qsm-alerts" style="margin-top: 20px;">
56
- <?php
57
- $mlwQuizMasterNext->alertManager->showAlerts();
58
- ?>
59
- </div>
60
- </section>
61
 
62
- <!-- Templates -->
63
- <script type="text/template" id="tmpl-email">
64
- <div class="qsm-email">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  <header class="qsm-email-header">
66
  <div><button class="delete-email-button"><span class="dashicons dashicons-trash"></span></button></div>
67
  </header>
68
  <main class="qsm-email-content">
69
  <div class="email-when">
70
  <div class="email-content-header">
71
- <h4><?php esc_html_e('When...', 'quiz-master-next') ?></h4>
72
- <p><?php esc_html_e('Set conditions for when this email should be sent. Leave empty to set this as an email that is always sent.', 'quiz-master-next'); ?></p>
73
  </div>
74
  <div class="email-when-conditions">
75
  <!-- Conditions go here. Review template below. -->
@@ -78,15 +93,15 @@ function qsm_options_emails_tab_content() {
78
  </div>
79
  <div class="email-show">
80
  <div class="email-content-header">
81
- <h4><?php esc_html_e('...Send', 'quiz-master-next'); ?></h4>
82
- <p><?php esc_html_e('Create the email that should be sent when the conditions are met.', 'quiz-master-next'); ?></p>
83
  </div>
84
- <label><?php esc_html_e('Who to send the email to? Put %USER_EMAIL% to send to user', 'quiz-master-next'); ?></label>
85
- <?php do_action('qsm_after_send_email_label'); ?>
86
  <input type="email" class="to-email" value="{{ data.to }}">
87
- <label><?php esc_html_e('Email Subject', 'quiz-master-next'); ?></label>
88
  <input type="text" class="subject" value="{{ data.subject }}">
89
- <label><?php esc_html_e('Email Content', 'quiz-master-next'); ?></label>
90
  <textarea id="email-template-{{ data.id }}" class="email-template">{{{ data.content }}}</textarea>
91
  <label><input type="checkbox" class="reply-to" <# if ( "true" == data.replyTo || true == data.replyTo ) { #>checked<# } #>>Add user email as Reply-To</label>
92
  </div>
@@ -94,82 +109,94 @@ function qsm_options_emails_tab_content() {
94
  </div>
95
  </script>
96
 
97
- <script type="text/template" id="tmpl-email-condition">
98
- <div class="email-condition">
99
  <button class="delete-condition-button"><span class="dashicons dashicons-trash"></span></button>
 
 
 
 
 
 
 
 
 
 
100
  <select class="email-condition-criteria">
101
- <option value="points" <# if (data.criteria == 'points') { #>selected<# } #>><?php _e('Total points earned', 'quiz-master-next'); ?></option>
102
- <option value="score" <# if (data.criteria == 'score') { #>selected<# } #>><?php _e('Correct score percentage', 'quiz-master-next'); ?></option>
103
  <?php do_action( 'qsm_email_condition_criteria' ); ?>
104
  </select>
105
- <?php do_action('qsm_email_extra_condition_fields'); ?>
106
  <select class="email-condition-operator">
107
- <option class="default_operator" value="equal" <# if (data.operator == 'equal') { #>selected<# } #>><?php _e('is equal to', 'quiz-master-next'); ?></option>
108
- <option class="default_operator" value="not-equal" <# if (data.operator == 'not-equal') { #>selected<# } #>><?php _e('is not equal to', 'quiz-master-next'); ?></option>
109
- <option class="default_operator" value="greater-equal" <# if (data.operator == 'greater-equal') { #>selected<# } #>><?php _e('is greater than or equal to', 'quiz-master-next'); ?></option>
110
- <option class="default_operator" value="greater" <# if (data.operator == 'greater') { #>selected<# } #>><?php _e('is greater than', 'quiz-master-next'); ?></option>
111
- <option class="default_operator" value="less-equal" <# if (data.operator == 'less-equal') { #>selected<# } #>><?php _e('is less than or equal to', 'quiz-master-next'); ?></option>
112
- <option class="default_operator" value="less" <# if (data.operator == 'less') { #>selected<# } #>><?php _e('is less than', 'quiz-master-next'); ?></option>
113
  <?php do_action( 'qsm_email_condition_operator' ); ?>
114
  </select>
115
  <input type="text" class="email-condition-value condition-default-value" value="{{ data.value }}">
116
- <?php do_action('qsm_email_condition_value'); ?>
117
  </div>
118
  </script>
119
- <!--Template popup-->
120
- <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
121
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
122
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
123
- <header class="qsm-popup__header" style="display: block;">
124
- <h2 class="qsm-popup__title"><?php _e('Template Variables', 'quiz-master-next'); ?></h2>
125
- <span class="description">
126
- <?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'); ?>
127
- <br/><b><?php _e('Note: ', 'quiz-master-next'); ?></b>
128
- <?php _e('Always use uppercase while using these variables.', 'quiz-master-next'); ?>
129
- </span>
130
- </header>
131
- <main class="qsm-popup__content" id="show-all-variable-content">
132
- <?php
133
- $variable_list = qsm_text_template_variable_list();
134
- $email_exta_variable = array(
135
- '%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' ),
136
- '%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' ),
137
- '%QUESTION_ANSWER_X%' => __('X = Question ID. It will show result of particular question.', 'quiz-master-next'),
138
- '%QUESTIONS_ANSWERS_EMAIL%' => __('Shows the question, the answer provided by user, and the correct answer', 'quiz-master-next')
139
- );
140
- $variable_list = array_merge($email_exta_variable, $variable_list);
141
- $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next');
142
- unset($variable_list['%QUESTION%']);
143
- unset($variable_list['%USER_ANSWER%']);
144
- unset($variable_list['%USER_ANSWERS_DEFAULT%']);
145
- unset($variable_list['%QUESTION_POINT_SCORE%']);
146
- unset($variable_list['%CORRECT_ANSWER%']);
147
- unset($variable_list['%USER_COMMENTS%']);
148
- unset($variable_list['%CORRECT_ANSWER_INFO%']);
149
- unset($variable_list['%QUESTIONS_ANSWERS%']);
150
- unset($variable_list['%FACEBOOK_SHARE%']);
151
- unset($variable_list['%TWITTER_SHARE%']);
152
- if( $variable_list ){
153
- foreach ( $variable_list as $key => $s_variable ) { ?>
154
- <div class="popup-template-span-wrap">
155
- <span class="qsm-text-template-span">
156
- <button class="button button-default"><?php echo $key; ?></button>
157
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
158
- <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
159
- </span>
160
- </span>
161
- </div>
162
- <?php
163
- }
164
- }
165
- ?>
166
- </main>
167
- <footer class="qsm-popup__footer" style="text-align: right;">
168
- <button class="button button-default" data-micromodal-close="" aria-label="Close this dialog window"><?php _e('Close [Esc]', 'quiz-master-next'); ?></button>
169
- </footer>
170
- </div>
171
- </div>
172
- </div>
173
- <?php
 
 
174
  }
175
- ?>
30
  function qsm_options_emails_tab_content() {
31
  global $wpdb;
32
  global $mlwQuizMasterNext;
33
+ $quiz_id = intval( $_GET['quiz_id'] );
34
+ $user_id = get_current_user_id();
35
+ $js_data = array(
36
+ 'quizID' => $quiz_id,
37
+ 'nonce' => wp_create_nonce( 'wp_rest' ),
38
+ 'qsm_user_ve' => get_user_meta( $user_id, 'rich_editing', true ),
39
  );
40
+
41
+ $categories = array();
42
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
43
+ if ( $enabled && $enabled != 'cancelled' ) {
44
+ $query = $wpdb->prepare( "SELECT name FROM {$wpdb->prefix}terms WHERE term_id IN ( SELECT DISTINCT term_id FROM {$wpdb->prefix}mlw_question_terms WHERE quiz_id = %d ) ORDER BY name ASC", $quiz_id );
45
+ } else {
46
+ $query = $wpdb->prepare( "SELECT DISTINCT category FROM {$wpdb->prefix}mlw_questions WHERE category <> '' AND quiz_id = %d", $quiz_id );
47
+ }
48
+ $categories = $wpdb->get_results( $query, ARRAY_N );
49
+
50
  wp_enqueue_script( 'qsm_emails_admin_script', plugins_url( '../../js/qsm-admin-emails.js', __FILE__ ), array( 'jquery-ui-sortable', 'qmn_admin_js' ), $mlwQuizMasterNext->version );
51
  wp_localize_script( 'qsm_emails_admin_script', 'qsmEmailsObject', $js_data );
52
  wp_enqueue_editor();
53
  wp_enqueue_media();
54
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ <!-- Emails Section -->
57
+ <section class="qsm-quiz-email-tab" style="margin-top: 15px;">
58
+ <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
59
+ <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
60
+ <a style="float: right;" class="qsm-show-all-variable-text"
61
+ href="#"><?php _e( 'Insert Template Variables', 'quiz-master-next' ); ?> <span
62
+ class="dashicons dashicons-upload"></span></a>
63
+ <a style="margin: 0 10px; float: right;" href="https://quizandsurveymaster.com/docs/v7/emails-tab/" target="_blank"
64
+ rel="noopener"><?php _e( 'View Documentation', 'quiz-master-next' ); ?></a>
65
+ <div id="qsm_emails">
66
+ <div style="margin-bottom: 30px;margin-top: 35px;" class="qsm-spinner-loader"></div>
67
+ </div>
68
+ <button class="save-emails button-primary"><?php esc_html_e( 'Save Emails', 'quiz-master-next' ); ?></button>
69
+ <button class="add-new-email button"><?php esc_html_e( 'Add New Email', 'quiz-master-next' ); ?></button>
70
+ <div class="qsm-alerts" style="margin-top: 20px;">
71
+ <?php
72
+ $mlwQuizMasterNext->alertManager->showAlerts();
73
+ ?>
74
+ </div>
75
+ </section>
76
+
77
+ <!-- Templates -->
78
+ <script type="text/template" id="tmpl-email">
79
+ <div class="qsm-email">
80
  <header class="qsm-email-header">
81
  <div><button class="delete-email-button"><span class="dashicons dashicons-trash"></span></button></div>
82
  </header>
83
  <main class="qsm-email-content">
84
  <div class="email-when">
85
  <div class="email-content-header">
86
+ <h4><?php esc_html_e( 'When...', 'quiz-master-next' ); ?></h4>
87
+ <p><?php esc_html_e( 'Set conditions for when this email should be sent. Leave empty to set this as an email that is always sent.', 'quiz-master-next' ); ?></p>
88
  </div>
89
  <div class="email-when-conditions">
90
  <!-- Conditions go here. Review template below. -->
93
  </div>
94
  <div class="email-show">
95
  <div class="email-content-header">
96
+ <h4><?php esc_html_e( '...Send', 'quiz-master-next' ); ?></h4>
97
+ <p><?php esc_html_e( 'Create the email that should be sent when the conditions are met.', 'quiz-master-next' ); ?></p>
98
  </div>
99
+ <label><?php esc_html_e( 'Who to send the email to? Put %USER_EMAIL% to send to user', 'quiz-master-next' ); ?></label>
100
+ <?php do_action( 'qsm_after_send_email_label' ); ?>
101
  <input type="email" class="to-email" value="{{ data.to }}">
102
+ <label><?php esc_html_e( 'Email Subject', 'quiz-master-next' ); ?></label>
103
  <input type="text" class="subject" value="{{ data.subject }}">
104
+ <label><?php esc_html_e( 'Email Content', 'quiz-master-next' ); ?></label>
105
  <textarea id="email-template-{{ data.id }}" class="email-template">{{{ data.content }}}</textarea>
106
  <label><input type="checkbox" class="reply-to" <# if ( "true" == data.replyTo || true == data.replyTo ) { #>checked<# } #>>Add user email as Reply-To</label>
107
  </div>
109
  </div>
110
  </script>
111
 
112
+ <script type="text/template" id="tmpl-email-condition">
113
+ <div class="email-condition">
114
  <button class="delete-condition-button"><span class="dashicons dashicons-trash"></span></button>
115
+ <?php if ( ! empty( $categories ) ) { ?>
116
+ <select class="email-condition-category">
117
+ <option value="" <# if (data.category == '') { #>selected<# } #>><?php _e( 'Quiz', 'quiz-master-next' ); ?></option>
118
+ <option value="" disabled><?php _e( '---Select Category---', 'quiz-master-next' ); ?></option>
119
+ <?php foreach ( $categories as $cat ) { ?>
120
+ <option value="<?php echo $cat[0]; ?>" <# if (data.category == '<?php echo $cat[0]; ?>') { #>selected<# } #>><?php echo $cat[0]; ?></option>
121
+ <?php } ?>
122
+ <?php do_action( 'qsm_results_page_condition_criteria' ); ?>
123
+ </select>
124
+ <?php } ?>
125
  <select class="email-condition-criteria">
126
+ <option value="points" <# if (data.criteria == 'points') { #>selected<# } #>><?php _e( 'Total points earned', 'quiz-master-next' ); ?></option>
127
+ <option value="score" <# if (data.criteria == 'score') { #>selected<# } #>><?php _e( 'Correct score percentage', 'quiz-master-next' ); ?></option>
128
  <?php do_action( 'qsm_email_condition_criteria' ); ?>
129
  </select>
130
+ <?php do_action( 'qsm_email_extra_condition_fields' ); ?>
131
  <select class="email-condition-operator">
132
+ <option class="default_operator" value="equal" <# if (data.operator == 'equal') { #>selected<# } #>><?php _e( 'is equal to', 'quiz-master-next' ); ?></option>
133
+ <option class="default_operator" value="not-equal" <# if (data.operator == 'not-equal') { #>selected<# } #>><?php _e( 'is not equal to', 'quiz-master-next' ); ?></option>
134
+ <option class="default_operator" value="greater-equal" <# if (data.operator == 'greater-equal') { #>selected<# } #>><?php _e( 'is greater than or equal to', 'quiz-master-next' ); ?></option>
135
+ <option class="default_operator" value="greater" <# if (data.operator == 'greater') { #>selected<# } #>><?php _e( 'is greater than', 'quiz-master-next' ); ?></option>
136
+ <option class="default_operator" value="less-equal" <# if (data.operator == 'less-equal') { #>selected<# } #>><?php _e( 'is less than or equal to', 'quiz-master-next' ); ?></option>
137
+ <option class="default_operator" value="less" <# if (data.operator == 'less') { #>selected<# } #>><?php _e( 'is less than', 'quiz-master-next' ); ?></option>
138
  <?php do_action( 'qsm_email_condition_operator' ); ?>
139
  </select>
140
  <input type="text" class="email-condition-value condition-default-value" value="{{ data.value }}">
141
+ <?php do_action( 'qsm_email_condition_value' ); ?>
142
  </div>
143
  </script>
144
+ <!--Template popup-->
145
+ <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
146
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
147
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
148
+ <header class="qsm-popup__header" style="display: block;">
149
+ <h2 class="qsm-popup__title"><?php _e( 'Template Variables', 'quiz-master-next' ); ?></h2>
150
+ <span class="description">
151
+ <?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' ); ?>
152
+ <br /><b><?php _e( 'Note: ', 'quiz-master-next' ); ?></b>
153
+ <?php _e( 'Always use uppercase while using these variables.', 'quiz-master-next' ); ?>
154
+ </span>
155
+ </header>
156
+ <main class="qsm-popup__content" id="show-all-variable-content">
157
+ <?php
158
+ $variable_list = qsm_text_template_variable_list();
159
+ $email_exta_variable = array(
160
+ '%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' ),
161
+ '%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' ),
162
+ '%QUESTION_ANSWER_X%' => __( 'X = Question ID. It will show result of particular question.', 'quiz-master-next' ),
163
+ '%QUESTIONS_ANSWERS_EMAIL%' => __( 'Shows the question, the answer provided by user, and the correct answer', 'quiz-master-next' ),
164
+ );
165
+ $variable_list = array_merge( $email_exta_variable, $variable_list );
166
+ $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __( 'X: Category name - The average amount of points a specific category earned.', 'quiz-master-next' );
167
+ unset( $variable_list['%QUESTION%'] );
168
+ unset( $variable_list['%USER_ANSWER%'] );
169
+ unset( $variable_list['%USER_ANSWERS_DEFAULT%'] );
170
+ unset( $variable_list['%QUESTION_POINT_SCORE%'] );
171
+ unset( $variable_list['%CORRECT_ANSWER%'] );
172
+ unset( $variable_list['%USER_COMMENTS%'] );
173
+ unset( $variable_list['%CORRECT_ANSWER_INFO%'] );
174
+ unset( $variable_list['%QUESTIONS_ANSWERS%'] );
175
+ unset( $variable_list['%FACEBOOK_SHARE%'] );
176
+ unset( $variable_list['%TWITTER_SHARE%'] );
177
+ if ( $variable_list ) {
178
+ foreach ( $variable_list as $key => $s_variable ) {
179
+ ?>
180
+ <div class="popup-template-span-wrap">
181
+ <span class="qsm-text-template-span">
182
+ <button class="button button-default"><?php echo $key; ?></button>
183
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
184
+ <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
185
+ </span>
186
+ </span>
187
+ </div>
188
+ <?php
189
+ }
190
+ }
191
+ ?>
192
+ </main>
193
+ <footer class="qsm-popup__footer" style="text-align: right;">
194
+ <button class="button button-default" data-micromodal-close=""
195
+ aria-label="Close this dialog window"><?php _e( 'Close [Esc]', 'quiz-master-next' ); ?></button>
196
+ </footer>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ <?php
201
  }
202
+ ?>
php/admin/options-page-questions-tab.php CHANGED
@@ -29,14 +29,33 @@ add_action( 'plugins_loaded', 'qsm_settings_questions_tab', 5 );
29
  function qsm_options_questions_tab_content() {
30
  global $wpdb;
31
  global $mlwQuizMasterNext;
 
32
  $question_categories = $wpdb->get_results( "SELECT DISTINCT category FROM {$wpdb->prefix}mlw_questions", 'ARRAY_A' );
33
- $quiz_id = intval( $_GET['quiz_id'] );
34
- $user_id = get_current_user_id();
35
- $form_type = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'form_type' );
36
- $quiz_system = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'system' );
37
- $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() );
38
- $db_qpages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'qpages', array() );
39
- $qpages = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  if ( ! empty( $pages ) ) {
41
  $defaultQPage = array(
42
  'id' => 1,
@@ -75,6 +94,7 @@ function qsm_options_questions_tab_content() {
75
  'categories' => $question_categories,
76
  'form_type' => $form_type,
77
  'quiz_system' => $quiz_system,
 
78
  'hide_desc_text' => __( 'Less Description', 'quiz-master-next' ),
79
  'show_desc_text' => __( 'Add Description', 'quiz-master-next' ),
80
  'show_correct_info_text' => __( 'Add Correct Answer Info', 'quiz-master-next' ),
@@ -244,17 +264,17 @@ function qsm_options_questions_tab_content() {
244
  'description' => __( 'For this question type, users will see a Captcha field on front end.', 'quiz-master-next' ),
245
  ),
246
  // array(
247
- // 'question_type_id' => '13',
248
- // 'description' => __( 'Use points based grading system for Polar questions.', 'quiz-master-next' ),
249
  // ),
250
  );
251
-
252
  // disabling polar for form type quiz and system correct/incorrect
253
  if ( $form_type == 0 && $quiz_system == 0 ) {
254
- $polar_class = $polar_question_use = '';
255
  $description_arr[] = array(
256
- 'question_type_id' => '13',
257
- 'description' => __( 'Use points based grading system for Polar questions.', 'quiz-master-next' ),
258
  );
259
  } else {
260
  $polar_class = 'qsm_show_question_type_13';
@@ -418,15 +438,27 @@ function qsm_options_questions_tab_content() {
418
  </h2>
419
  <div class="inside">
420
  <?php
421
- $category_question_option = array(
422
- 'categories' => array(
423
- 'label' => __( '', 'quiz-master-next' ),
424
- 'type' => 'category',
425
- 'priority' => '5',
426
- 'default' => '',
427
- 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Category',
428
- ),
429
- );
 
 
 
 
 
 
 
 
 
 
 
 
430
  $category_question_option = apply_filters( 'qsm_question_category_option', $category_question_option );
431
  $keys = array_column( $category_question_option, 'priority' );
432
  array_multisort( $keys, SORT_ASC, $category_question_option );
@@ -725,6 +757,58 @@ function qsm_options_questions_tab_content() {
725
  </div>
726
  </div>
727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
  <?php
729
  }
730
 
@@ -948,4 +1032,22 @@ function qsm_delete_question_from_database() {
948
  exit;
949
  }
950
  add_action( 'wp_ajax_qsm_delete_question_from_database', 'qsm_delete_question_from_database' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
951
  ?>
29
  function qsm_options_questions_tab_content() {
30
  global $wpdb;
31
  global $mlwQuizMasterNext;
32
+
33
  $question_categories = $wpdb->get_results( "SELECT DISTINCT category FROM {$wpdb->prefix}mlw_questions", 'ARRAY_A' );
34
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
35
+
36
+ if ( $enabled && 'cancelled' !== $enabled ) {
37
+ $question_categories = array();
38
+ $terms = get_terms(
39
+ array(
40
+ 'taxonomy' => 'qsm_category',
41
+ 'hide_empty' => false,
42
+ )
43
+ );
44
+ foreach ( $terms as $term ) {
45
+ $question_categories[] = array(
46
+ 'category' => $term->name,
47
+ 'cat_id' => $term->term_id,
48
+ );
49
+ }
50
+ }
51
+
52
+ $quiz_id = intval( $_GET['quiz_id'] );
53
+ $user_id = get_current_user_id();
54
+ $form_type = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'form_type' );
55
+ $quiz_system = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_options', 'system' );
56
+ $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() );
57
+ $db_qpages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'qpages', array() );
58
+ $qpages = array();
59
  if ( ! empty( $pages ) ) {
60
  $defaultQPage = array(
61
  'id' => 1,
94
  'categories' => $question_categories,
95
  'form_type' => $form_type,
96
  'quiz_system' => $quiz_system,
97
+ // 'multiple_categories' => $multiple_categories,
98
  'hide_desc_text' => __( 'Less Description', 'quiz-master-next' ),
99
  'show_desc_text' => __( 'Add Description', 'quiz-master-next' ),
100
  'show_correct_info_text' => __( 'Add Correct Answer Info', 'quiz-master-next' ),
264
  'description' => __( 'For this question type, users will see a Captcha field on front end.', 'quiz-master-next' ),
265
  ),
266
  // array(
267
+ // 'question_type_id' => '13',
268
+ // 'description' => __( 'Use points based grading system for Polar questions.', 'quiz-master-next' ),
269
  // ),
270
  );
271
+
272
  // disabling polar for form type quiz and system correct/incorrect
273
  if ( $form_type == 0 && $quiz_system == 0 ) {
274
+ $polar_class = $polar_question_use = '';
275
  $description_arr[] = array(
276
+ 'question_type_id' => '13',
277
+ 'description' => __( 'Use points based grading system for Polar questions.', 'quiz-master-next' ),
278
  );
279
  } else {
280
  $polar_class = 'qsm_show_question_type_13';
438
  </h2>
439
  <div class="inside">
440
  <?php
441
+ $enabled_multiple_category = get_option( 'qsm_multiple_category_enabled' );
442
+ if ( $enabled_multiple_category && 'cancelled' !== $enabled_multiple_category ) {
443
+ $category_question_option = array(
444
+ 'categories' => array(
445
+ 'label' => __( '', 'quiz-master-next' ),
446
+ 'type' => 'multi_category',
447
+ 'priority' => '5',
448
+ 'default' => '',
449
+ ),
450
+ );
451
+ } else {
452
+ $category_question_option = array(
453
+ 'categories' => array(
454
+ 'label' => __( '', 'quiz-master-next' ),
455
+ 'type' => 'category',
456
+ 'priority' => '5',
457
+ 'default' => '',
458
+ 'documentation_link' => 'https://quizandsurveymaster.com/docs/v7/questions-tab/#Category',
459
+ ),
460
+ );
461
+ }
462
  $category_question_option = apply_filters( 'qsm_question_category_option', $category_question_option );
463
  $keys = array_column( $category_question_option, 'priority' );
464
  array_multisort( $keys, SORT_ASC, $category_question_option );
757
  </div>
758
  </div>
759
 
760
+ <div class="qsm-popup qsm-popup-slide" id="modal-9" aria-hidden="false">
761
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
762
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-9-title">
763
+ <header class="qsm-popup__header">
764
+ <h3 class="qsm-popup__title" id="modal-9-title"><?php _e( 'Add New Category', 'quiz-master-next' ); ?>
765
+ </h3>
766
+ <a class="qsm-popup__close" aria-label="Close modal" data-micromodal-close=""></a>
767
+ </header>
768
+ <hr />
769
+ <main class="qsm-popup__content" id="modal-9-content">
770
+ <table class="modal-9-table">
771
+ <tr>
772
+ <td><?php _e( 'Category Name', 'quiz-master-next' ); ?>
773
+ </td>
774
+ <td><input type="text" id="new-category-name" /></td>
775
+ <tr>
776
+ <tr>
777
+ <td><?php _e( 'Parent Category', 'quiz-master-next' ); ?>
778
+ </td>
779
+ <td>
780
+ <?php
781
+ wp_dropdown_categories(
782
+ array(
783
+ 'taxonomy' => 'qsm_category',
784
+ 'descendants_and_self' => 0,
785
+ 'selected_cats' => true,
786
+ 'echo' => true,
787
+ 'id' => 'qsm-parent-category',
788
+ 'hide_empty' => false,
789
+ 'hirerichal' => 1,
790
+ 'show_option_none' => 'None',
791
+ 'option_none_value' => -1,
792
+ 'orderby' => 'name',
793
+ )
794
+ );
795
+ ?>
796
+ </td>
797
+ <tr>
798
+ </table>
799
+ <div class="info"></div>
800
+ </main>
801
+ <hr />
802
+ <footer class="qsm-popup__footer">
803
+ <button id="save-multi-category-button"
804
+ class="qsm-popup__btn qsm-popup__btn-primary"></span><?php _e( 'Save', 'quiz-master-next' ); ?></button>
805
+ <button id="cancel-button" class="qsm-popup__btn" data-micromodal-close=""
806
+ aria-label="Close this dialog window"><?php _e( 'Cancel', 'quiz-master-next' ); ?></button>
807
+ </footer>
808
+ </div>
809
+ </div>
810
+ </div>
811
+
812
  <?php
813
  }
814
 
1032
  exit;
1033
  }
1034
  add_action( 'wp_ajax_qsm_delete_question_from_database', 'qsm_delete_question_from_database' );
1035
+
1036
+ add_action( 'wp_ajax_save_new_category', 'qsm_save_new_category' );
1037
+
1038
+ function qsm_save_new_category() {
1039
+
1040
+ $category = sanitize_text_field( $_POST['name'] );
1041
+ $parent = (int) $_POST['parent'];
1042
+ $parent = ( $parent == -1 ) ? 0 : $parent;
1043
+ $term_array = wp_insert_term(
1044
+ $category,
1045
+ 'qsm_category',
1046
+ array(
1047
+ 'parent' => $parent,
1048
+ )
1049
+ );
1050
+ echo json_encode( $term_array );
1051
+ exit;
1052
+ }
1053
  ?>
php/admin/options-page-results-page-tab.php CHANGED
@@ -33,39 +33,54 @@ function qsm_options_results_tab_content() {
33
  'quizID' => $quiz_id,
34
  'nonce' => wp_create_nonce( 'wp_rest' ),
35
  );
 
 
 
 
 
 
 
 
 
 
36
  wp_enqueue_script( 'qsm_results_admin_script', plugins_url( '../../js/qsm-admin-results.js', __FILE__ ), array( 'jquery-ui-sortable', 'qmn_admin_js' ), $mlwQuizMasterNext->version );
37
  wp_localize_script( 'qsm_results_admin_script', 'qsmResultsObject', $js_data );
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 -->
59
- <script type="text/template" id="tmpl-results-page">
60
- <div class="results-page">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  <header class="results-page-header">
62
  <div><button class="delete-page-button"><span class="dashicons dashicons-trash"></span></button></div>
63
  </header>
64
  <main class="results-page-content">
65
  <div class="results-page-when">
66
  <div class="results-page-content-header">
67
- <h4><?php esc_html_e('When...', 'quiz-master-next'); ?></h4>
68
- <p><?php esc_html_e('Set conditions for when this page should be shown. Leave empty to set this as the default page.', 'quiz-master-next'); ?></p>
69
  </div>
70
  <div class="results-page-when-conditions">
71
  <!-- Conditions go here. Review template below. -->
@@ -74,92 +89,104 @@ function qsm_options_results_tab_content() {
74
  </div>
75
  <div class="results-page-show">
76
  <div class="results-page-content-header">
77
- <h4><?php esc_html_e('...Show', 'quiz-master-next'); ?></h4>
78
- <p><?php esc_html_e('Create the results page that should be shown when the conditions are met.', 'quiz-master-next'); ?></p>
79
  </div>
80
  <textarea id="results-page-{{ data.id }}" class="results-page-template">{{{ data.page }}}</textarea>
81
- <p><?php esc_html_e('Or, redirect the user by entering the URL below:', 'quiz-master-next'); ?></p>
82
  <input type="text" class="results-page-redirect" value="<# if ( data.redirect ) { #>{{ data.redirect }}<# } #>">
83
  </div>
84
  </main>
85
  </div>
86
  </script>
87
 
88
- <script type="text/template" id="tmpl-results-page-condition">
89
- <div class="results-page-condition">
90
  <button class="delete-condition-button"><span class="dashicons dashicons-trash"></span></button>
 
 
 
 
 
 
 
 
 
 
91
  <select class="results-page-condition-criteria">
92
- <option value="points" <# if (data.criteria == 'points') { #>selected<# } #>><?php _e('Total points earned', 'quiz-master-next'); ?></option>
93
- <option value="score" <# if (data.criteria == 'score') { #>selected<# } #>><?php _e('Correct score percentage', 'quiz-master-next'); ?></option>
94
  <?php do_action( 'qsm_results_page_condition_criteria' ); ?>
95
  </select>
96
- <?php do_action('qsm_results_page_extra_condition_fields'); ?>
97
  <select class="results-page-condition-operator">
98
- <option class="default_operator" value="equal" <# if (data.operator == 'equal') { #>selected<# } #>><?php _e('is equal to', 'quiz-master-next'); ?></option>
99
- <option class="default_operator" value="not-equal" <# if (data.operator == 'not-equal') { #>selected<# } #>><?php _e('is not equal to', 'quiz-master-next'); ?></option>
100
- <option class="default_operator" value="greater-equal" <# if (data.operator == 'greater-equal') { #>selected<# } #>><?php _e('is greater than or equal to', 'quiz-master-next'); ?></option>
101
- <option class="default_operator" value="greater" <# if (data.operator == 'greater') { #>selected<# } #>><?php _e('is greater than', 'quiz-master-next'); ?></option>
102
- <option class="default_operator" value="less-equal" <# if (data.operator == 'less-equal') { #>selected<# } #>><?php _e('is less than or equal to', 'quiz-master-next'); ?></option>
103
- <option class="default_operator" value="less" <# if (data.operator == 'less') { #>selected<# } #>><?php _e('is less than', 'quiz-master-next'); ?></option>
104
  <?php do_action( 'qsm_results_page_condition_operator' ); ?>
105
  </select>
106
  <input type="text" class="results-page-condition-value condition-default-value" value="{{ data.value }}">
107
- <?php do_action('qsm_results_page_condition_value'); ?>
108
  </div>
109
  </script>
110
- <!--Template popup-->
111
- <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
112
- <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
113
- <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
114
- <header class="qsm-popup__header" style="display: block;">
115
- <h2 class="qsm-popup__title"><?php _e('Template Variables', 'quiz-master-next'); ?></h2>
116
- <span class="description">
117
- <?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'); ?>
118
- <br/><b><?php _e('Note: ', 'quiz-master-next'); ?></b>
119
- <?php _e('Always use uppercase while using these variables.', 'quiz-master-next'); ?>
120
- </span>
121
- </header>
122
- <main class="qsm-popup__content" id="show-all-variable-content">
123
- <?php
124
- $variable_list = qsm_text_template_variable_list();
125
- $email_exta_variable = array(
126
- '%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' ),
127
- '%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' ),
128
- );
129
- $variable_list = array_merge($email_exta_variable, $variable_list);
130
- $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __('X: Category name - The average amount of points a specific category earned.', 'quiz-master-next');
131
- $variable_list['%POLL_RESULTS_X%'] = __('X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next');
132
- $variable_list['%RESULT_ID%'] = __('Show result id', 'quiz-master-next');
133
- $variable_list['%QUESTION_ANSWER_X%'] = __('X = Question ID. It will show result of particular question.', 'quiz-master-next');
134
- unset($variable_list['%QUESTION%']);
135
- unset($variable_list['%USER_ANSWER%']);
136
- unset($variable_list['%USER_ANSWERS_DEFAULT%']);
137
- unset($variable_list['%QUESTION_POINT_SCORE%']);
138
- unset($variable_list['%CORRECT_ANSWER%']);
139
- unset($variable_list['%USER_COMMENTS%']);
140
- unset($variable_list['%CORRECT_ANSWER_INFO%']);
141
- unset($variable_list['%CURRENT_DATE%']);
142
- if( $variable_list ){
143
- foreach ( $variable_list as $key => $s_variable ) { ?>
144
- <div class="popup-template-span-wrap">
145
- <span class="qsm-text-template-span">
146
- <button class="button button-default"><?php echo $key; ?></button>
147
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
148
- <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
149
- </span>
150
- </span>
151
- </div>
152
- <?php
153
- }
154
- }
155
- ?>
156
- </main>
157
- <footer class="qsm-popup__footer" style="text-align: right;">
158
- <button class="button button-default" data-micromodal-close="" aria-label="Close this dialog window"><?php _e('Close [Esc]', 'quiz-master-next'); ?></button>
159
- </footer>
160
- </div>
161
- </div>
162
- </div>
163
- <?php
 
 
164
  }
165
- ?>
33
  'quizID' => $quiz_id,
34
  'nonce' => wp_create_nonce( 'wp_rest' ),
35
  );
36
+
37
+ $categories = array();
38
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
39
+ if ( $enabled && $enabled != 'cancelled' ) {
40
+ $query = $wpdb->prepare( "SELECT name FROM {$wpdb->prefix}terms WHERE term_id IN ( SELECT DISTINCT term_id FROM {$wpdb->prefix}mlw_question_terms WHERE quiz_id = %d ) ORDER BY name ASC", $quiz_id );
41
+ } else {
42
+ $query = $wpdb->prepare( "SELECT DISTINCT category FROM {$wpdb->prefix}mlw_questions WHERE category <> '' AND quiz_id = %d", $quiz_id );
43
+ }
44
+ $categories = $wpdb->get_results( $query, ARRAY_N );
45
+
46
  wp_enqueue_script( 'qsm_results_admin_script', plugins_url( '../../js/qsm-admin-results.js', __FILE__ ), array( 'jquery-ui-sortable', 'qmn_admin_js' ), $mlwQuizMasterNext->version );
47
  wp_localize_script( 'qsm_results_admin_script', 'qsmResultsObject', $js_data );
48
  wp_enqueue_editor();
49
  wp_enqueue_media();
50
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ <!-- Results Page Section -->
53
+ <section class="qsm-quiz-result-tab" style="margin-top: 15px;">
54
+ <button class="save-pages button-primary"><?php esc_html_e( 'Save Results Pages', 'quiz-master-next' ); ?></button>
55
+ <button class="add-new-page button"><?php esc_html_e( 'Add New Results Page', 'quiz-master-next' ); ?></button>
56
+ <a style="float: right;" class="qsm-show-all-variable-text"
57
+ href="#"><?php _e( 'Insert Template Variables', 'quiz-master-next' ); ?> <span
58
+ class="dashicons dashicons-upload"></span></a>
59
+ <a style="margin: 0 10px; float: right;" href="https://quizandsurveymaster.com/docs/v7/results-pages-tab/"
60
+ target="_blank" rel="noopener">View Documentation</a>
61
+ <div id="results-pages">
62
+ <div style="margin-bottom: 30px;margin-top: 35px;" class="qsm-spinner-loader"></div>
63
+ </div>
64
+ <button class="save-pages button-primary"><?php esc_html_e( 'Save Results Pages', 'quiz-master-next' ); ?></button>
65
+ <button class="add-new-page button"><?php esc_html_e( 'Add New Results Page', 'quiz-master-next' ); ?></button>
66
+ <div class="qsm-alerts" style="margin-top: 20px;">
67
+ <?php
68
+ $mlwQuizMasterNext->alertManager->showAlerts();
69
+ ?>
70
+ </div>
71
+ </section>
72
+
73
+ <!-- Templates -->
74
+ <script type="text/template" id="tmpl-results-page">
75
+ <div class="results-page">
76
  <header class="results-page-header">
77
  <div><button class="delete-page-button"><span class="dashicons dashicons-trash"></span></button></div>
78
  </header>
79
  <main class="results-page-content">
80
  <div class="results-page-when">
81
  <div class="results-page-content-header">
82
+ <h4><?php esc_html_e( 'When...', 'quiz-master-next' ); ?></h4>
83
+ <p><?php esc_html_e( 'Set conditions for when this page should be shown. Leave empty to set this as the default page.', 'quiz-master-next' ); ?></p>
84
  </div>
85
  <div class="results-page-when-conditions">
86
  <!-- Conditions go here. Review template below. -->
89
  </div>
90
  <div class="results-page-show">
91
  <div class="results-page-content-header">
92
+ <h4><?php esc_html_e( '...Show', 'quiz-master-next' ); ?></h4>
93
+ <p><?php esc_html_e( 'Create the results page that should be shown when the conditions are met.', 'quiz-master-next' ); ?></p>
94
  </div>
95
  <textarea id="results-page-{{ data.id }}" class="results-page-template">{{{ data.page }}}</textarea>
96
+ <p><?php esc_html_e( 'Or, redirect the user by entering the URL below:', 'quiz-master-next' ); ?></p>
97
  <input type="text" class="results-page-redirect" value="<# if ( data.redirect ) { #>{{ data.redirect }}<# } #>">
98
  </div>
99
  </main>
100
  </div>
101
  </script>
102
 
103
+ <script type="text/template" id="tmpl-results-page-condition">
104
+ <div class="results-page-condition">
105
  <button class="delete-condition-button"><span class="dashicons dashicons-trash"></span></button>
106
+ <?php if ( ! empty( $categories ) ) { ?>
107
+ <select class="results-page-condition-category">
108
+ <option value="" <# if (data.category == '') { #>selected<# } #>><?php _e( 'Quiz', 'quiz-master-next' ); ?></option>
109
+ <option value="" disabled><?php _e( '---Select Category---', 'quiz-master-next' ); ?></option>
110
+ <?php foreach ( $categories as $cat ) { ?>
111
+ <option value="<?php echo $cat[0]; ?>" <# if (data.category == '<?php echo $cat[0]; ?>') { #>selected<# } #>><?php echo $cat[0]; ?></option>
112
+ <?php } ?>
113
+ <?php do_action( 'qsm_results_page_condition_criteria' ); ?>
114
+ </select>
115
+ <?php } ?>
116
  <select class="results-page-condition-criteria">
117
+ <option value="points" <# if (data.criteria == 'points') { #>selected<# } #>><?php _e( 'Total points earned', 'quiz-master-next' ); ?></option>
118
+ <option value="score" <# if (data.criteria == 'score') { #>selected<# } #>><?php _e( 'Correct score percentage', 'quiz-master-next' ); ?></option>
119
  <?php do_action( 'qsm_results_page_condition_criteria' ); ?>
120
  </select>
121
+ <?php do_action( 'qsm_results_page_extra_condition_fields' ); ?>
122
  <select class="results-page-condition-operator">
123
+ <option class="default_operator" value="equal" <# if (data.operator == 'equal') { #>selected<# } #>><?php _e( 'is equal to', 'quiz-master-next' ); ?></option>
124
+ <option class="default_operator" value="not-equal" <# if (data.operator == 'not-equal') { #>selected<# } #>><?php _e( 'is not equal to', 'quiz-master-next' ); ?></option>
125
+ <option class="default_operator" value="greater-equal" <# if (data.operator == 'greater-equal') { #>selected<# } #>><?php _e( 'is greater than or equal to', 'quiz-master-next' ); ?></option>
126
+ <option class="default_operator" value="greater" <# if (data.operator == 'greater') { #>selected<# } #>><?php _e( 'is greater than', 'quiz-master-next' ); ?></option>
127
+ <option class="default_operator" value="less-equal" <# if (data.operator == 'less-equal') { #>selected<# } #>><?php _e( 'is less than or equal to', 'quiz-master-next' ); ?></option>
128
+ <option class="default_operator" value="less" <# if (data.operator == 'less') { #>selected<# } #>><?php _e( 'is less than', 'quiz-master-next' ); ?></option>
129
  <?php do_action( 'qsm_results_page_condition_operator' ); ?>
130
  </select>
131
  <input type="text" class="results-page-condition-value condition-default-value" value="{{ data.value }}">
132
+ <?php do_action( 'qsm_results_page_condition_value' ); ?>
133
  </div>
134
  </script>
135
+ <!--Template popup-->
136
+ <div class="qsm-popup qsm-popup-slide" id="show-all-variable" aria-hidden="false">
137
+ <div class="qsm-popup__overlay" tabindex="-1" data-micromodal-close="">
138
+ <div class="qsm-popup__container" role="dialog" aria-modal="true" aria-labelledby="modal-3-title">
139
+ <header class="qsm-popup__header" style="display: block;">
140
+ <h2 class="qsm-popup__title"><?php _e( 'Template Variables', 'quiz-master-next' ); ?></h2>
141
+ <span class="description">
142
+ <?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' ); ?>
143
+ <br /><b><?php _e( 'Note: ', 'quiz-master-next' ); ?></b>
144
+ <?php _e( 'Always use uppercase while using these variables.', 'quiz-master-next' ); ?>
145
+ </span>
146
+ </header>
147
+ <main class="qsm-popup__content" id="show-all-variable-content">
148
+ <?php
149
+ $variable_list = qsm_text_template_variable_list();
150
+ $email_exta_variable = array(
151
+ '%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' ),
152
+ '%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' ),
153
+ );
154
+ $variable_list = array_merge( $email_exta_variable, $variable_list );
155
+ $variable_list['%AVERAGE_CATEGORY_POINTS_X%'] = __( 'X: Category name - The average amount of points a specific category earned.', 'quiz-master-next' );
156
+ $variable_list['%POLL_RESULTS_X%'] = __( 'X = Question ID Note: only supported for multiple choice answers', 'quiz-master-next' );
157
+ $variable_list['%RESULT_ID%'] = __( 'Show result id', 'quiz-master-next' );
158
+ $variable_list['%QUESTION_ANSWER_X%'] = __( 'X = Question ID. It will show result of particular question.', 'quiz-master-next' );
159
+ unset( $variable_list['%QUESTION%'] );
160
+ unset( $variable_list['%USER_ANSWER%'] );
161
+ unset( $variable_list['%USER_ANSWERS_DEFAULT%'] );
162
+ unset( $variable_list['%QUESTION_POINT_SCORE%'] );
163
+ unset( $variable_list['%CORRECT_ANSWER%'] );
164
+ unset( $variable_list['%USER_COMMENTS%'] );
165
+ unset( $variable_list['%CORRECT_ANSWER_INFO%'] );
166
+ unset( $variable_list['%CURRENT_DATE%'] );
167
+ if ( $variable_list ) {
168
+ foreach ( $variable_list as $key => $s_variable ) {
169
+ ?>
170
+ <div class="popup-template-span-wrap">
171
+ <span class="qsm-text-template-span">
172
+ <button class="button button-default"><?php echo $key; ?></button>
173
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
174
+ <span class="qsm-tooltips"><?php echo $s_variable; ?></span>
175
+ </span>
176
+ </span>
177
+ </div>
178
+ <?php
179
+ }
180
+ }
181
+ ?>
182
+ </main>
183
+ <footer class="qsm-popup__footer" style="text-align: right;">
184
+ <button class="button button-default" data-micromodal-close=""
185
+ aria-label="Close this dialog window"><?php _e( 'Close [Esc]', 'quiz-master-next' ); ?></button>
186
+ </footer>
187
+ </div>
188
+ </div>
189
+ </div>
190
+ <?php
191
  }
192
+ ?>
php/admin/settings-page.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
3
 
4
  /**
5
  * Generates The Settings Page For The Plugin
@@ -9,29 +11,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
9
  class QMNGlobalSettingsPage {
10
 
11
  /**
12
- * Main Construct Function
13
- *
14
- * Call functions within class
15
- *
16
- * @since 4.1.0
17
- * @uses QMNGlobalSettingsPage::load_dependencies() Loads required filed
18
- * @uses QMNGlobalSettingsPage::add_hooks() Adds actions to hooks and filters
19
- * @return void
20
- */
21
  function __construct() {
22
  $this->add_hooks();
23
  }
24
 
25
  /**
26
- * Add Hooks
27
- *
28
- * Adds functions to relavent hooks and filters
29
- *
30
- * @since 4.1.0
31
- * @return void
32
- */
33
  private function add_hooks() {
34
- add_action( "admin_init", array( $this, 'init' ) );
35
  }
36
 
37
  /**
@@ -47,15 +49,15 @@ class QMNGlobalSettingsPage {
47
  add_settings_field( 'ip-collection', __( 'Disable collecting and storing IP addresses?', 'quiz-master-next' ), array( $this, 'ip_collection_field' ), 'qmn_global_settings', 'qmn-global-section' );
48
  add_settings_field( 'cpt-search', __( 'Disable Quiz Posts From Being Searched?', 'quiz-master-next' ), array( $this, 'cpt_search_field' ), 'qmn_global_settings', 'qmn-global-section' );
49
  add_settings_field( 'cpt-archive', __( 'Disable Quiz Archive?', 'quiz-master-next' ), array( $this, 'cpt_archive_field' ), 'qmn_global_settings', 'qmn-global-section' );
50
- add_settings_field( 'detele-qsm-data', __( 'Delete all the data related to QSM on deletion?', 'quiz-master-next' ), array( $this, 'qsm_delete_data' ), 'qmn_global_settings', 'qmn-global-section' );
51
- add_settings_field( 'background-quiz-email-process', __( 'Process emails in background?', 'quiz-master-next' ), array( $this, 'qsm_background_quiz_email_process' ), 'qmn_global_settings', 'qmn-global-section' );
52
  add_settings_field( 'cpt-slug', __( 'Quiz Url Slug', 'quiz-master-next' ), array( $this, 'cpt_slug_field' ), 'qmn_global_settings', 'qmn-global-section' );
53
  add_settings_field( 'plural-name', __( 'Post Type Plural Name (Shown in various places such as on archive pages)', 'quiz-master-next' ), array( $this, 'plural_name_field' ), 'qmn_global_settings', 'qmn-global-section' );
54
  add_settings_field( 'facebook-app-id', __( 'Facebook App Id', 'quiz-master-next' ), array( $this, 'facebook_app_id' ), 'qmn_global_settings', 'qmn-global-section' );
55
  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' );
56
  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' );
57
- add_settings_field( 'items-per-page-question-bank', __( 'Items per page in question bank pagination', 'quiz-master-next' ), array( $this, 'items_per_page_question_bank' ), 'qmn_global_settings', 'qmn-global-section' );
58
- 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' );
59
  add_settings_field( 'results-details', __( 'Template For Admin Results Details', 'quiz-master-next' ), array( $this, 'results_details_template' ), 'qmn_global_settings', 'qmn-global-section' );
60
  }
61
 
@@ -67,14 +69,38 @@ class QMNGlobalSettingsPage {
67
  * @since 4.1.0
68
  * @return void
69
  */
70
- public function global_section() {
71
  _e( 'These settings are applied to the entire plugin and all quizzes.', 'quiz-master-next' );
72
- if ( isset( $_GET["settings-updated"] ) && $_GET["settings-updated"] ) {
73
  flush_rewrite_rules( true );
74
- echo '<div class="updated" style="padding: 10px;">';
75
- echo "<span>" . __( ' Settings have been updated!', 'quiz-master-next' ) . "</span>";
76
- echo '</div>';
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
 
80
  /**
@@ -94,7 +120,7 @@ class QMNGlobalSettingsPage {
94
  value='<?php echo esc_attr( $from_email ); ?>' />
95
  <?php
96
  }
97
-
98
  /**
99
  * Generates Setting Field For items per page in question bank pagination
100
  *
@@ -102,10 +128,10 @@ class QMNGlobalSettingsPage {
102
  * @return void
103
  */
104
  public function items_per_page_question_bank() {
105
- $settings = (array) get_option( 'qmn-settings' );
106
  $items_per_page_question_bank = 20;
107
  if ( isset( $settings['items_per_page_question_bank'] ) ) {
108
- $items_per_page_question_bank = $settings['items_per_page_question_bank'];
109
  }
110
  ?>
111
  <input type='number' name='qmn-settings[items_per_page_question_bank]' id='qmn-settings[items_per_page_question_bank]'
@@ -138,13 +164,12 @@ class QMNGlobalSettingsPage {
138
  * @return void
139
  */
140
  public function facebook_app_id() {
141
- $settings = (array) get_option( 'qmn-settings' );
142
  $facebook_app_id = '594986844960937';
143
- if (isset($settings['facebook_app_id']))
144
- {
145
  $facebook_app_id = esc_attr( $settings['facebook_app_id'] );
146
- }
147
- echo "<input type='text' name='qmn-settings[facebook_app_id]' id='qmn-settings[facebook_app_id]' value='$facebook_app_id' />";
148
  }
149
 
150
  /**
@@ -158,8 +183,8 @@ class QMNGlobalSettingsPage {
158
  $cpt_slug = 'quiz';
159
  if ( isset( $settings['cpt_slug'] ) ) {
160
  $cpt_slug = esc_attr( $settings['cpt_slug'] );
161
- }
162
- echo "<input type='text' name='qmn-settings[cpt_slug]' id='qmn-settings[cpt_slug]' value='$cpt_slug' />";
163
  }
164
 
165
  /**
@@ -169,12 +194,12 @@ class QMNGlobalSettingsPage {
169
  * @return void
170
  */
171
  public function plural_name_field() {
172
- $settings = (array) get_option( 'qmn-settings' );
173
  $plural_name = __( 'Quizzes & Surveys', 'quiz-master-next' );
174
  if ( isset( $settings['plural_name'] ) ) {
175
  $plural_name = esc_attr( $settings['plural_name'] );
176
- }
177
- echo "<input type='text' name='qmn-settings[plural_name]' id='qmn-settings[plural_name]' value='$plural_name' />";
178
  }
179
 
180
  /**
@@ -183,22 +208,19 @@ class QMNGlobalSettingsPage {
183
  * @since 4.1.0
184
  * @return void
185
  */
186
- public function cpt_search_field()
187
- {
188
- $settings = (array) get_option( 'qmn-settings' );
189
  $cpt_search = '0';
190
- if (isset($settings['cpt_search']))
191
- {
192
  $cpt_search = esc_attr( $settings['cpt_search'] );
193
  }
194
  $checked = '';
195
- if ($cpt_search == '1')
196
- {
197
  $checked = " checked='checked'";
198
  }
199
- echo '<label class="switch">';
200
  echo "<input type='checkbox' name='qmn-settings[cpt_search]' id='qmn-settings[cpt_search]' value='1'$checked />";
201
- echo '<span class="slider round"></span></label>';
202
  }
203
 
204
  /**
@@ -207,70 +229,63 @@ class QMNGlobalSettingsPage {
207
  * @since 4.1.0
208
  * @return void
209
  */
210
- public function cpt_archive_field()
211
- {
212
- $settings = (array) get_option( 'qmn-settings' );
213
  $cpt_archive = '0';
214
- if (isset($settings['cpt_archive']))
215
- {
216
  $cpt_archive = esc_attr( $settings['cpt_archive'] );
217
  }
218
  $checked = '';
219
- if ($cpt_archive == '1')
220
- {
221
  $checked = " checked='checked'";
222
  }
223
- echo '<label class="switch">';
224
  echo "<input type='checkbox' name='qmn-settings[cpt_archive]' id='qmn-settings[cpt_archive]' value='1'$checked />";
225
- echo '<span class="slider round"></span></label>';
226
  }
227
-
228
- /**
229
  * Generates Setting Field For delete QSM data
230
  *
231
  * @since 7.0.3
232
  * @return void
233
  */
234
- public function qsm_delete_data()
235
- {
236
- $settings = (array) get_option( 'qmn-settings' );
237
  $cpt_archive = '0';
238
- if (isset($settings['delete_qsm_data']))
239
- {
240
  $cpt_archive = esc_attr( $settings['delete_qsm_data'] );
241
  }
242
  $checked = '';
243
- if ($cpt_archive == '1')
244
- {
245
  $checked = " checked='checked'";
246
  }
247
- echo '<label class="switch">';
248
  echo "<input type='checkbox' name='qmn-settings[delete_qsm_data]' id='qmn-settings[delete_qsm_data]' value='1'$checked />";
249
- echo '<span class="slider round"></span></label>';
250
  }
251
-
252
- /**
253
  * Generates Setting Field For background email process
254
  *
255
  * @since 7.0.3
256
  * @return void
257
  */
258
- public function qsm_background_quiz_email_process()
259
- {
260
- $settings = (array) get_option( 'qmn-settings' );
261
- $background_quiz_email_process = '1';
262
- if ( isset($settings['background_quiz_email_process']) ){
263
- $background_quiz_email_process = esc_attr( $settings['background_quiz_email_process'] );
264
- }
265
- echo '<label style="margin-bottom: 10px;display: inline-block;">';
266
- echo "<input type='radio' name='qmn-settings[background_quiz_email_process]' class='background_quiz_email_process' value='1' ". checked($background_quiz_email_process, '1', false) ."/>";
267
- echo __('Yes', 'quiz-master-next');
268
- echo '</label>';
269
- echo '<br/>';
270
- echo '<label>';
271
- echo "<input type='radio' name='qmn-settings[background_quiz_email_process]' class='background_quiz_email_process' value='0' ". checked($background_quiz_email_process, '0', false) ."/>";
272
- echo __('No', 'quiz-master-next');
273
- echo '</label>';
274
  }
275
 
276
  /**
@@ -279,16 +294,12 @@ class QMNGlobalSettingsPage {
279
  * @since 4.1.0
280
  * @return void
281
  */
282
- public function results_details_template()
283
- {
284
  $settings = (array) get_option( 'qmn-settings' );
285
- if (isset($settings['results_details_template']))
286
- {
287
- $template = htmlspecialchars_decode($settings['results_details_template'], ENT_QUOTES);
288
- }
289
- else
290
- {
291
- $template = "<h2>Quiz Results for %QUIZ_NAME%</h2>
292
  <p>%CONTACT_ALL%</p>
293
  <p>Name Provided: %USER_NAME%</p>
294
  <p>Business Provided: %USER_BUSINESS%</p>
@@ -299,9 +310,9 @@ class QMNGlobalSettingsPage {
299
  <p>The user took %TIMER% to complete quiz.</p>
300
  <p>Comments entered were: %COMMENT_SECTION%</p>
301
  <p>The answers were as follows:</p>
302
- %QUESTIONS_ANSWERS%";
303
  }
304
- wp_editor( $template, 'results_template', array('textarea_name' => 'qmn-settings[results_details_template]') );
305
  }
306
 
307
  /**
@@ -310,23 +321,20 @@ class QMNGlobalSettingsPage {
310
  * @since 4.1.0
311
  * @return void
312
  */
313
- public function usage_tracker_field()
314
- {
315
- $settings = (array) get_option( 'qmn-settings' );
316
  $tracking_allowed = '0';
317
- if (isset($settings['tracking_allowed']))
318
- {
319
  $tracking_allowed = esc_attr( $settings['tracking_allowed'] );
320
  }
321
  $checked = '';
322
- if ($tracking_allowed == '2')
323
- {
324
  $checked = " checked='checked'";
325
- }
326
- echo '<label class="switch">';
327
- echo "<input type='checkbox' name='qmn-settings[tracking_allowed]' id='qmn-settings[tracking_allowed]' value='2'$checked /><span class='slider round'></span>";
328
- echo '</label>';
329
- echo "<span class='global-sub-text' for='qmn-settings[tracking_allowed]'>" . __( "Allow Quiz And Survey Master to anonymously track this plugin's usage and help us make this plugin better.", 'quiz-master-next' ) . "</span>";
330
  }
331
 
332
  /**
@@ -336,7 +344,7 @@ class QMNGlobalSettingsPage {
336
  * @return void
337
  */
338
  public function ip_collection_field() {
339
- $settings = (array) get_option( 'qmn-settings' );
340
  $ip_collection = '0';
341
  if ( isset( $settings['ip_collection'] ) ) {
342
  $ip_collection = esc_attr( $settings['ip_collection'] );
@@ -345,11 +353,11 @@ class QMNGlobalSettingsPage {
345
  if ( '1' == $ip_collection ) {
346
  $checked = " checked='checked'";
347
  }
348
- echo '<label class="switch">';
349
  echo "<input type='checkbox' name='qmn-settings[ip_collection]' id='qmn-settings[ip_collection]' value='1'$checked />";
350
- echo '<span class="slider round"></span></label>';
351
  echo "<span class='global-sub-text' for='qmn-settings[ip_collection]'>"
352
- . __( "You must not restrict number of quiz attempts when this option is enabled.", 'quiz-master-next' ) . "</span>";
353
  }
354
 
355
  /**
@@ -359,9 +367,9 @@ class QMNGlobalSettingsPage {
359
  * @return void
360
  */
361
  public static function display_page() {
362
- global $mlwQuizMasterNext;
363
- wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
364
- wp_style_add_data( 'qsm_admin_style', 'rtl', 'replace' );
365
  wp_enqueue_script( 'qsm_admin_js', plugins_url( '../../js/admin.js', __FILE__ ), array( 'jquery' ), $mlwQuizMasterNext->version );
366
  ?>
367
  <div class="wrap">
@@ -374,29 +382,28 @@ class QMNGlobalSettingsPage {
374
  </div>
375
  <?php
376
  }
377
-
378
- /**
379
  * Generates Setting Field For new template for result detail
380
  *
381
  * @since 7.0.0
382
  * @return void
383
  */
384
- public function new_template_results_details()
385
- {
386
- $settings = (array) get_option( 'qmn-settings' );
387
  $new_template_result_detail = '1';
388
- if (isset($settings['new_template_result_detail'])){
389
- $new_template_result_detail = esc_attr( $settings['new_template_result_detail'] );
390
- }
391
- echo '<label style="margin-bottom: 10px;display: inline-block;">';
392
- 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) ."/>";
393
- echo __('New Template', 'quiz-master-next');
394
- echo '</label>';
395
- echo '<br/>';
396
- echo '<label>';
397
- 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) ."/>";
398
- echo __('Old Template', 'quiz-master-next');
399
- echo '</label>';
400
  }
401
  }
402
 
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
 
6
  /**
7
  * Generates The Settings Page For The Plugin
11
  class QMNGlobalSettingsPage {
12
 
13
  /**
14
+ * Main Construct Function
15
+ *
16
+ * Call functions within class
17
+ *
18
+ * @since 4.1.0
19
+ * @uses QMNGlobalSettingsPage::load_dependencies() Loads required filed
20
+ * @uses QMNGlobalSettingsPage::add_hooks() Adds actions to hooks and filters
21
+ * @return void
22
+ */
23
  function __construct() {
24
  $this->add_hooks();
25
  }
26
 
27
  /**
28
+ * Add Hooks
29
+ *
30
+ * Adds functions to relavent hooks and filters
31
+ *
32
+ * @since 4.1.0
33
+ * @return void
34
+ */
35
  private function add_hooks() {
36
+ add_action( 'admin_init', array( $this, 'init' ) );
37
  }
38
 
39
  /**
49
  add_settings_field( 'ip-collection', __( 'Disable collecting and storing IP addresses?', 'quiz-master-next' ), array( $this, 'ip_collection_field' ), 'qmn_global_settings', 'qmn-global-section' );
50
  add_settings_field( 'cpt-search', __( 'Disable Quiz Posts From Being Searched?', 'quiz-master-next' ), array( $this, 'cpt_search_field' ), 'qmn_global_settings', 'qmn-global-section' );
51
  add_settings_field( 'cpt-archive', __( 'Disable Quiz Archive?', 'quiz-master-next' ), array( $this, 'cpt_archive_field' ), 'qmn_global_settings', 'qmn-global-section' );
52
+ add_settings_field( 'detele-qsm-data', __( 'Delete all the data related to QSM on deletion?', 'quiz-master-next' ), array( $this, 'qsm_delete_data' ), 'qmn_global_settings', 'qmn-global-section' );
53
+ add_settings_field( 'background-quiz-email-process', __( 'Process emails in background?', 'quiz-master-next' ), array( $this, 'qsm_background_quiz_email_process' ), 'qmn_global_settings', 'qmn-global-section' );
54
  add_settings_field( 'cpt-slug', __( 'Quiz Url Slug', 'quiz-master-next' ), array( $this, 'cpt_slug_field' ), 'qmn_global_settings', 'qmn-global-section' );
55
  add_settings_field( 'plural-name', __( 'Post Type Plural Name (Shown in various places such as on archive pages)', 'quiz-master-next' ), array( $this, 'plural_name_field' ), 'qmn_global_settings', 'qmn-global-section' );
56
  add_settings_field( 'facebook-app-id', __( 'Facebook App Id', 'quiz-master-next' ), array( $this, 'facebook_app_id' ), 'qmn_global_settings', 'qmn-global-section' );
57
  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' );
58
  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' );
59
+ add_settings_field( 'items-per-page-question-bank', __( 'Items per page in question bank pagination', 'quiz-master-next' ), array( $this, 'items_per_page_question_bank' ), 'qmn_global_settings', 'qmn-global-section' );
60
+ 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' );
61
  add_settings_field( 'results-details', __( 'Template For Admin Results Details', 'quiz-master-next' ), array( $this, 'results_details_template' ), 'qmn_global_settings', 'qmn-global-section' );
62
  }
63
 
69
  * @since 4.1.0
70
  * @return void
71
  */
72
+ public function global_section() {
73
  _e( 'These settings are applied to the entire plugin and all quizzes.', 'quiz-master-next' );
74
+ if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] ) {
75
  flush_rewrite_rules( true );
76
+ echo '<div class="updated" style="padding: 10px;">';
77
+ echo '<span>' . __( ' Settings have been updated!', 'quiz-master-next' ) . '</span>';
78
+ echo '</div>';
79
+ }
80
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
81
+ if ( $enabled == 'cancelled' ) {
82
+ ?>
83
+ <div class="notice notice-info multiple-category-notice">
84
+ <h3>
85
+ <?php _e( 'Database update required', 'quiz-master-next' ); ?>
86
+ </h3>
87
+ <p>
88
+ <?php
89
+ $message = __( ' QSM has been updated! ', 'quiz-master-next' );
90
+ $message .= sprintf( __( '%1$s We need to upgrade your database so that you can enjoy the latest features. ', 'quiz-master-next' ), '<br/>' );
91
+ $message .= sprintf( __( '%1$s Please note that this action %2$s can not be %3$s rolled back. We recommend you to take a backup of your current site before proceeding.', 'quiz-master-next' ), '<br/>', '<b>', '</b>' );
92
+ echo $message;
93
+ ?>
94
+ </p>
95
+ <p class="category-action">
96
+ <?php
97
+ $buttons = sprintf( __( '%1$s Update Database %2$s', 'quiz-master-next' ), '<a href="#" class="button button-primary enable-multiple-category">', '</a>' );
98
+ echo $buttons;
99
+ ?>
100
+ </p>
101
+ </div>
102
+ <?php
103
+ }
104
  }
105
 
106
  /**
120
  value='<?php echo esc_attr( $from_email ); ?>' />
121
  <?php
122
  }
123
+
124
  /**
125
  * Generates Setting Field For items per page in question bank pagination
126
  *
128
  * @return void
129
  */
130
  public function items_per_page_question_bank() {
131
+ $settings = (array) get_option( 'qmn-settings' );
132
  $items_per_page_question_bank = 20;
133
  if ( isset( $settings['items_per_page_question_bank'] ) ) {
134
+ $items_per_page_question_bank = $settings['items_per_page_question_bank'];
135
  }
136
  ?>
137
  <input type='number' name='qmn-settings[items_per_page_question_bank]' id='qmn-settings[items_per_page_question_bank]'
164
  * @return void
165
  */
166
  public function facebook_app_id() {
167
+ $settings = (array) get_option( 'qmn-settings' );
168
  $facebook_app_id = '594986844960937';
169
+ if ( isset( $settings['facebook_app_id'] ) ) {
 
170
  $facebook_app_id = esc_attr( $settings['facebook_app_id'] );
171
+ }
172
+ echo "<input type='text' name='qmn-settings[facebook_app_id]' id='qmn-settings[facebook_app_id]' value='$facebook_app_id' />";
173
  }
174
 
175
  /**
183
  $cpt_slug = 'quiz';
184
  if ( isset( $settings['cpt_slug'] ) ) {
185
  $cpt_slug = esc_attr( $settings['cpt_slug'] );
186
+ }
187
+ echo "<input type='text' name='qmn-settings[cpt_slug]' id='qmn-settings[cpt_slug]' value='$cpt_slug' />";
188
  }
189
 
190
  /**
194
  * @return void
195
  */
196
  public function plural_name_field() {
197
+ $settings = (array) get_option( 'qmn-settings' );
198
  $plural_name = __( 'Quizzes & Surveys', 'quiz-master-next' );
199
  if ( isset( $settings['plural_name'] ) ) {
200
  $plural_name = esc_attr( $settings['plural_name'] );
201
+ }
202
+ echo "<input type='text' name='qmn-settings[plural_name]' id='qmn-settings[plural_name]' value='$plural_name' />";
203
  }
204
 
205
  /**
208
  * @since 4.1.0
209
  * @return void
210
  */
211
+ public function cpt_search_field() {
212
+ $settings = (array) get_option( 'qmn-settings' );
 
213
  $cpt_search = '0';
214
+ if ( isset( $settings['cpt_search'] ) ) {
 
215
  $cpt_search = esc_attr( $settings['cpt_search'] );
216
  }
217
  $checked = '';
218
+ if ( $cpt_search == '1' ) {
 
219
  $checked = " checked='checked'";
220
  }
221
+ echo '<label class="switch">';
222
  echo "<input type='checkbox' name='qmn-settings[cpt_search]' id='qmn-settings[cpt_search]' value='1'$checked />";
223
+ echo '<span class="slider round"></span></label>';
224
  }
225
 
226
  /**
229
  * @since 4.1.0
230
  * @return void
231
  */
232
+ public function cpt_archive_field() {
233
+ $settings = (array) get_option( 'qmn-settings' );
 
234
  $cpt_archive = '0';
235
+ if ( isset( $settings['cpt_archive'] ) ) {
 
236
  $cpt_archive = esc_attr( $settings['cpt_archive'] );
237
  }
238
  $checked = '';
239
+ if ( $cpt_archive == '1' ) {
 
240
  $checked = " checked='checked'";
241
  }
242
+ echo '<label class="switch">';
243
  echo "<input type='checkbox' name='qmn-settings[cpt_archive]' id='qmn-settings[cpt_archive]' value='1'$checked />";
244
+ echo '<span class="slider round"></span></label>';
245
  }
246
+
247
+ /**
248
  * Generates Setting Field For delete QSM data
249
  *
250
  * @since 7.0.3
251
  * @return void
252
  */
253
+ public function qsm_delete_data() {
254
+ $settings = (array) get_option( 'qmn-settings' );
 
255
  $cpt_archive = '0';
256
+ if ( isset( $settings['delete_qsm_data'] ) ) {
 
257
  $cpt_archive = esc_attr( $settings['delete_qsm_data'] );
258
  }
259
  $checked = '';
260
+ if ( $cpt_archive == '1' ) {
 
261
  $checked = " checked='checked'";
262
  }
263
+ echo '<label class="switch">';
264
  echo "<input type='checkbox' name='qmn-settings[delete_qsm_data]' id='qmn-settings[delete_qsm_data]' value='1'$checked />";
265
+ echo '<span class="slider round"></span></label>';
266
  }
267
+
268
+ /**
269
  * Generates Setting Field For background email process
270
  *
271
  * @since 7.0.3
272
  * @return void
273
  */
274
+ public function qsm_background_quiz_email_process() {
275
+ $settings = (array) get_option( 'qmn-settings' );
276
+ $background_quiz_email_process = '1';
277
+ if ( isset( $settings['background_quiz_email_process'] ) ) {
278
+ $background_quiz_email_process = esc_attr( $settings['background_quiz_email_process'] );
279
+ }
280
+ echo '<label style="margin-bottom: 10px;display: inline-block;">';
281
+ echo "<input type='radio' name='qmn-settings[background_quiz_email_process]' class='background_quiz_email_process' value='1' " . checked( $background_quiz_email_process, '1', false ) . '/>';
282
+ echo __( 'Yes', 'quiz-master-next' );
283
+ echo '</label>';
284
+ echo '<br/>';
285
+ echo '<label>';
286
+ echo "<input type='radio' name='qmn-settings[background_quiz_email_process]' class='background_quiz_email_process' value='0' " . checked( $background_quiz_email_process, '0', false ) . '/>';
287
+ echo __( 'No', 'quiz-master-next' );
288
+ echo '</label>';
 
289
  }
290
 
291
  /**
294
  * @since 4.1.0
295
  * @return void
296
  */
297
+ public function results_details_template() {
 
298
  $settings = (array) get_option( 'qmn-settings' );
299
+ if ( isset( $settings['results_details_template'] ) ) {
300
+ $template = htmlspecialchars_decode( $settings['results_details_template'], ENT_QUOTES );
301
+ } else {
302
+ $template = '<h2>Quiz Results for %QUIZ_NAME%</h2>
 
 
 
303
  <p>%CONTACT_ALL%</p>
304
  <p>Name Provided: %USER_NAME%</p>
305
  <p>Business Provided: %USER_BUSINESS%</p>
310
  <p>The user took %TIMER% to complete quiz.</p>
311
  <p>Comments entered were: %COMMENT_SECTION%</p>
312
  <p>The answers were as follows:</p>
313
+ %QUESTIONS_ANSWERS%';
314
  }
315
+ wp_editor( $template, 'results_template', array( 'textarea_name' => 'qmn-settings[results_details_template]' ) );
316
  }
317
 
318
  /**
321
  * @since 4.1.0
322
  * @return void
323
  */
324
+ public function usage_tracker_field() {
325
+ $settings = (array) get_option( 'qmn-settings' );
 
326
  $tracking_allowed = '0';
327
+ if ( isset( $settings['tracking_allowed'] ) ) {
 
328
  $tracking_allowed = esc_attr( $settings['tracking_allowed'] );
329
  }
330
  $checked = '';
331
+ if ( $tracking_allowed == '2' ) {
 
332
  $checked = " checked='checked'";
333
+ }
334
+ echo '<label class="switch">';
335
+ echo "<input type='checkbox' name='qmn-settings[tracking_allowed]' id='qmn-settings[tracking_allowed]' value='2'$checked /><span class='slider round'></span>";
336
+ echo '</label>';
337
+ echo "<span class='global-sub-text' for='qmn-settings[tracking_allowed]'>" . __( "Allow Quiz And Survey Master to anonymously track this plugin's usage and help us make this plugin better.", 'quiz-master-next' ) . '</span>';
338
  }
339
 
340
  /**
344
  * @return void
345
  */
346
  public function ip_collection_field() {
347
+ $settings = (array) get_option( 'qmn-settings' );
348
  $ip_collection = '0';
349
  if ( isset( $settings['ip_collection'] ) ) {
350
  $ip_collection = esc_attr( $settings['ip_collection'] );
353
  if ( '1' == $ip_collection ) {
354
  $checked = " checked='checked'";
355
  }
356
+ echo '<label class="switch">';
357
  echo "<input type='checkbox' name='qmn-settings[ip_collection]' id='qmn-settings[ip_collection]' value='1'$checked />";
358
+ echo '<span class="slider round"></span></label>';
359
  echo "<span class='global-sub-text' for='qmn-settings[ip_collection]'>"
360
+ . __( 'You must not restrict number of quiz attempts when this option is enabled.', 'quiz-master-next' ) . '</span>';
361
  }
362
 
363
  /**
367
  * @return void
368
  */
369
  public static function display_page() {
370
+ global $mlwQuizMasterNext;
371
+ wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );
372
+ wp_style_add_data( 'qsm_admin_style', 'rtl', 'replace' );
373
  wp_enqueue_script( 'qsm_admin_js', plugins_url( '../../js/admin.js', __FILE__ ), array( 'jquery' ), $mlwQuizMasterNext->version );
374
  ?>
375
  <div class="wrap">
382
  </div>
383
  <?php
384
  }
385
+
386
+ /**
387
  * Generates Setting Field For new template for result detail
388
  *
389
  * @since 7.0.0
390
  * @return void
391
  */
392
+ public function new_template_results_details() {
393
+ $settings = (array) get_option( 'qmn-settings' );
 
394
  $new_template_result_detail = '1';
395
+ if ( isset( $settings['new_template_result_detail'] ) ) {
396
+ $new_template_result_detail = esc_attr( $settings['new_template_result_detail'] );
397
+ }
398
+ echo '<label style="margin-bottom: 10px;display: inline-block;">';
399
+ 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 ) . '/>';
400
+ echo __( 'New Template', 'quiz-master-next' );
401
+ echo '</label>';
402
+ echo '<br/>';
403
+ echo '<label>';
404
+ 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 ) . '/>';
405
+ echo __( 'Old Template', 'quiz-master-next' );
406
+ echo '</label>';
407
  }
408
  }
409
 
php/classes/class-qmn-quiz-creator.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- if (!defined('ABSPATH')) {
3
- exit;
4
  }
5
 
6
  /**
@@ -12,711 +12,738 @@ if (!defined('ABSPATH')) {
12
  *
13
  * @since 3.7.1
14
  */
15
- class QMNQuizCreator
16
- {
17
 
18
- /**
19
- * QMN ID of quiz
20
- *
21
- * @var object
22
- * @since 3.7.1
23
- */
24
- private $quiz_id;
25
 
26
- /**
27
- * If the quiz ID is set, store it as the class quiz ID
28
- *
29
- * @since 3.7.1
30
- */
31
- public function __construct()
32
- {
33
- if (isset($_REQUEST['quiz_id'])) {
34
- $this->quiz_id = intval($_REQUEST['quiz_id']);
35
- }
36
- }
37
 
38
- /**
39
- * Sets quiz ID
40
- *
41
- * @since 3.8.1
42
- * @param int $quiz_id The ID of the quiz.
43
- * @access public
44
- * @return void
45
- */
46
- public function set_id($quiz_id)
47
- {
48
- $this->quiz_id = intval($quiz_id);
49
- }
50
 
51
- /**
52
- * Gets the quiz ID stored (for backwards compatibility)
53
- *
54
- * @since 5.0.0
55
- * @return int|false The ID of the quiz stored or false
56
- */
57
- public function get_id()
58
- {
59
- if ($this->quiz_id) {
60
- return intval($this->quiz_id);
61
- } else {
62
- return false;
63
- }
64
- }
65
 
66
- /**
67
- * Creates a new quiz with the default settings
68
- *
69
- * @access public
70
- * @since 3.7.1
71
- * @param string $quiz_name The name of the new quiz.
72
- * @return void
73
- */
74
- public function create_quiz($quiz_name, $theme_id, $quiz_settings = '')
75
- {
76
- global $mlwQuizMasterNext;
77
- global $wpdb;
78
- $current_user = wp_get_current_user();
79
- $results = $wpdb->insert(
80
- $wpdb->prefix . 'mlw_quizzes',
81
- array(
82
- 'quiz_name' => $quiz_name,
83
- 'message_before' => __('Welcome to your %QUIZ_NAME%', 'quiz-master-next'),
84
- 'message_after' => __('Thanks for submitting your response! You can edit this message on the "Results Pages" tab. <br>%CONTACT_ALL% <br>%QUESTIONS_ANSWERS%', 'quiz-master-next'),
85
- 'message_comment' => __('Please fill in the comment box below.', 'quiz-master-next'),
86
- 'message_end_template' => '',
87
- 'user_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
88
- 'admin_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
89
- 'submit_button_text' => __('Submit', 'quiz-master-next'),
90
- 'name_field_text' => __('Name', 'quiz-master-next'),
91
- 'business_field_text' => __('Business', 'quiz-master-next'),
92
- 'email_field_text' => __('Email', 'quiz-master-next'),
93
- 'phone_field_text' => __('Phone Number', 'quiz-master-next'),
94
- 'comment_field_text' => __('Comments', 'quiz-master-next'),
95
- 'email_from_text' => 'Wordpress',
96
- 'question_answer_template' => '%QUESTION%<br />%USER_ANSWERS_DEFAULT%',
97
- 'leaderboard_template' => '',
98
- 'quiz_system' => 0,
99
- 'randomness_order' => 0,
100
- 'loggedin_user_contact' => 0,
101
- 'show_score' => 0,
102
- 'send_user_email' => 0,
103
- 'send_admin_email' => 0,
104
- 'contact_info_location' => 0,
105
- 'user_name' => 2,
106
- 'user_comp' => 2,
107
- 'user_email' => 2,
108
- 'user_phone' => 2,
109
- 'admin_email' => get_option('admin_email', 'Enter email'),
110
- 'comment_section' => 1,
111
- 'question_from_total' => 0,
112
- 'total_user_tries' => 0,
113
- 'total_user_tries_text' => __('You have utilized all of your attempts to pass this quiz.', 'quiz-master-next'),
114
- 'certificate_template' => '',
115
- 'social_media' => 0,
116
- 'social_media_text' => __('I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!', 'quiz-master-next'),
117
- 'pagination' => 0,
118
- 'pagination_text' => __('Next', 'quiz-master-next'),
119
- 'timer_limit' => 0,
120
- 'quiz_stye' => '',
121
- 'question_numbering' => 0,
122
- 'quiz_settings' => $quiz_settings,
123
- 'theme_selected' => 'primary',
124
- 'last_activity' => current_time('mysql'),
125
- 'require_log_in' => 0,
126
- 'require_log_in_text' => __('This quiz is for logged in users only.', 'quiz-master-next'),
127
- 'limit_total_entries' => 0,
128
- 'limit_total_entries_text' => __('Unfortunately, this quiz has a limited amount of entries it can recieve and has already reached that limit.', 'quiz-master-next'),
129
- 'scheduled_timeframe' => '',
130
- 'scheduled_timeframe_text' => '',
131
- 'quiz_views' => 0,
132
- 'quiz_taken' => 0,
133
- 'deleted' => 0,
134
- 'quiz_author_id' => $current_user->ID,
135
- ),
136
- array(
137
- '%s',
138
- '%s',
139
- '%s',
140
- '%s',
141
- '%s',
142
- '%s',
143
- '%s',
144
- '%s',
145
- '%s',
146
- '%s',
147
- '%s',
148
- '%s',
149
- '%s',
150
- '%s',
151
- '%s',
152
- '%s',
153
- '%d',
154
- '%d',
155
- '%d',
156
- '%d',
157
- '%d',
158
- '%d',
159
- '%d',
160
- '%d',
161
- '%d',
162
- '%d',
163
- '%d',
164
- '%s',
165
- '%d',
166
- '%d',
167
- '%d',
168
- '%s',
169
- '%s',
170
- '%d',
171
- '%s',
172
- '%d',
173
- '%s',
174
- '%d',
175
- '%s',
176
- '%d',
177
- '%s',
178
- '%s',
179
- '%s',
180
- '%d',
181
- '%s',
182
- '%d',
183
- '%s',
184
- '%s',
185
- '%s',
186
- '%d',
187
- '%d',
188
- '%d',
189
- '%d',
190
- )
191
- );
192
- if (false !== $results) {
193
- $new_quiz = $wpdb->insert_id;
194
- $quiz_post = array(
195
- 'post_title' => $quiz_name,
196
- 'post_content' => "[mlw_quizmaster quiz=$new_quiz]",
197
- 'post_status' => 'draft',
198
- 'post_author' => $current_user->ID,
199
- 'post_type' => 'qsm_quiz',
200
- );
201
- $quiz_post_id = wp_insert_post($quiz_post);
202
- add_post_meta($quiz_post_id, 'quiz_id', $new_quiz);
203
 
204
- // activating selected theme
205
- $mlwQuizMasterNext->theme_settings->activate_selected_theme($new_quiz, $theme_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
 
207
- $mlwQuizMasterNext->alertManager->newAlert(__('Your new quiz or survey has been created successfully. To begin editing, click the Edit link.', 'quiz-master-next'), 'success');
208
- $mlwQuizMasterNext->audit_manager->new_audit("New Quiz/Survey Has Been Created: $quiz_name");
209
 
210
- // Hook called after new quiz or survey has been created. Passes quiz_id to hook
211
- do_action('qmn_quiz_created', $new_quiz);
212
- } else {
213
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0001'), 'error');
214
- $mlwQuizMasterNext->log_manager->add("Error 0001", $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error');
215
- }
216
- }
217
 
218
- /**
219
- * Deletes a quiz with the given quiz_id
220
- *
221
- * @access public
222
- * @since 3.7.1
223
- * @return void
224
- */
225
- public function delete_quiz($quiz_id, $quiz_name)
226
- {
227
- global $mlwQuizMasterNext;
228
- global $wpdb;
229
- $results = $wpdb->update(
230
- $wpdb->prefix . "mlw_quizzes",
231
- array(
232
- 'deleted' => 1,
233
- ),
234
- array('quiz_id' => $quiz_id),
235
- array(
236
- '%d',
237
- ),
238
- array('%d')
239
- );
240
- $deleted = 0;
241
- if (isset($_POST['qsm_delete_question_from_qb']) && $_POST['qsm_delete_question_from_qb'] == 1) {
242
- $deleted = 1;
243
- }
244
- $delete_question_results = $wpdb->update(
245
- $wpdb->prefix . "mlw_questions",
246
- array(
247
- 'deleted' => $deleted,
248
- ),
249
- array('quiz_id' => $quiz_id),
250
- array(
251
- '%d',
252
- ),
253
- array('%d')
254
- );
255
- if ($results != false) {
256
- $my_query = new WP_Query(array('post_type' => 'qsm_quiz', 'meta_key' => 'quiz_id', 'meta_value' => $quiz_id));
257
- if ($my_query->have_posts()) {
258
- while ($my_query->have_posts()) {
259
- $my_query->the_post();
260
- $my_post = array(
261
- 'ID' => get_the_ID(),
262
- 'post_status' => 'trash',
263
- );
264
- wp_update_post($my_post);
265
- }
266
- }
267
- wp_reset_postdata();
268
- $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz or survey has been deleted successfully.', 'quiz-master-next'), 'success');
269
- $mlwQuizMasterNext->audit_manager->new_audit("Quiz/Survey Has Been Deleted: $quiz_name");
270
- } else {
271
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0002'), 'error');
272
- $mlwQuizMasterNext->log_manager->add("Error 0002", $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error');
273
- }
274
 
275
- // Hook called after quiz or survey is deleted. Hook passes quiz_id to function
276
- do_action('qmn_quiz_deleted', $quiz_id);
277
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
- /**
280
- * Edits the name of the quiz with the given ID
281
- *
282
- * @access public
283
- * @since 3.7.1
284
- * @param int $quiz_id The ID of the quiz.
285
- * @param string $quiz_name The new name of the quiz.
286
- * @return void
287
- */
288
- public function edit_quiz_name($quiz_id, $quiz_name)
289
- {
290
- global $mlwQuizMasterNext;
291
- global $wpdb;
292
- $results = $wpdb->update(
293
- $wpdb->prefix . 'mlw_quizzes',
294
- array(
295
- 'quiz_name' => $quiz_name,
296
- ),
297
- array('quiz_id' => $quiz_id),
298
- array(
299
- '%s',
300
- ),
301
- array('%d')
302
- );
303
- if (false !== $results) {
304
- $mlwQuizMasterNext->alertManager->newAlert(__('The name of your quiz or survey has been updated successfully.', 'quiz-master-next'), 'success');
305
- $mlwQuizMasterNext->audit_manager->new_audit("Quiz/Survey Name Has Been Edited: $quiz_name");
306
- } else {
307
- $error = $wpdb->last_error;
308
- if (empty($error)) {
309
- $error = __('Unknown error', 'quiz-master-next');
310
- }
311
- $mlwQuizMasterNext->alertManager->newAlert(__('An error occurred while trying to update the name of your quiz or survey. Please try again.', 'quiz-master-next'), 'error');
312
- $mlwQuizMasterNext->log_manager->add('Error when updating quiz name', "Tried {$wpdb->last_query} but got $error", 0, 'error');
313
- }
314
 
315
- // Fires when the name of a quiz/survey is edited.
316
- do_action('qsm_quiz_name_edited', $quiz_id, $quiz_name);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
- // Legacy code.
319
- do_action('qmn_quiz_name_edited', $quiz_id);
320
- }
321
 
322
- /**
323
- * Duplicates the quiz with the given ID and gives new quiz the given quiz name
324
- *
325
- * @access public
326
- * @since 3.7.1
327
- * @return void
328
- */
329
- public function duplicate_quiz($quiz_id, $quiz_name, $is_duplicating_questions)
330
- {
331
- global $mlwQuizMasterNext;
332
- global $wpdb;
333
- $current_user = wp_get_current_user();
334
- $table_name = $wpdb->prefix . "mlw_quizzes";
335
- $logic_table = $wpdb->prefix . "mlw_logic";
336
- $logic_table_exists = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $logic_table));
337
- $mlw_qmn_duplicate_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d", $quiz_id));
338
- $quiz_settings = unserialize($mlw_qmn_duplicate_data->quiz_settings);
339
- if ($is_duplicating_questions == 0) {
340
- $quiz_settings['pages'] = '';
341
- }
342
- $qsm_create_quiz_system = 0;
343
- if (isset($mlw_qmn_duplicate_data->system)) {
344
- $qsm_create_quiz_system = $mlw_qmn_duplicate_data->system;
345
- } else if (isset($mlw_qmn_duplicate_data->quiz_system)) {
346
- $qsm_create_quiz_system = $mlw_qmn_duplicate_data->quiz_system;
347
- }
348
- $results = $wpdb->insert(
349
- $table_name,
350
- array(
351
- 'quiz_name' => $quiz_name,
352
- 'message_before' => $mlw_qmn_duplicate_data->message_before,
353
- 'message_after' => $mlw_qmn_duplicate_data->message_after,
354
- 'message_comment' => $mlw_qmn_duplicate_data->message_comment,
355
- 'message_end_template' => $mlw_qmn_duplicate_data->message_end_template,
356
- 'user_email_template' => $mlw_qmn_duplicate_data->user_email_template,
357
- 'admin_email_template' => $mlw_qmn_duplicate_data->admin_email_template,
358
- 'submit_button_text' => $mlw_qmn_duplicate_data->submit_button_text,
359
- 'name_field_text' => $mlw_qmn_duplicate_data->name_field_text,
360
- 'business_field_text' => $mlw_qmn_duplicate_data->business_field_text,
361
- 'email_field_text' => $mlw_qmn_duplicate_data->email_field_text,
362
- 'phone_field_text' => $mlw_qmn_duplicate_data->phone_field_text,
363
- 'comment_field_text' => $mlw_qmn_duplicate_data->comment_field_text,
364
- 'email_from_text' => $mlw_qmn_duplicate_data->email_from_text,
365
- 'question_answer_template' => $mlw_qmn_duplicate_data->question_answer_template,
366
- 'leaderboard_template' => $mlw_qmn_duplicate_data->leaderboard_template,
367
- 'quiz_system' => $qsm_create_quiz_system,
368
- 'randomness_order' => $mlw_qmn_duplicate_data->randomness_order,
369
- 'loggedin_user_contact' => $mlw_qmn_duplicate_data->loggedin_user_contact,
370
- 'show_score' => $mlw_qmn_duplicate_data->show_score,
371
- 'send_user_email' => $mlw_qmn_duplicate_data->send_user_email,
372
- 'send_admin_email' => $mlw_qmn_duplicate_data->send_admin_email,
373
- 'contact_info_location' => $mlw_qmn_duplicate_data->contact_info_location,
374
- 'user_name' => $mlw_qmn_duplicate_data->user_name,
375
- 'user_comp' => $mlw_qmn_duplicate_data->user_comp,
376
- 'user_email' => $mlw_qmn_duplicate_data->user_email,
377
- 'user_phone' => $mlw_qmn_duplicate_data->user_phone,
378
- 'admin_email' => get_option('admin_email', 'Enter email'),
379
- 'comment_section' => $mlw_qmn_duplicate_data->comment_section,
380
- 'question_from_total' => $mlw_qmn_duplicate_data->question_from_total,
381
- 'total_user_tries' => $mlw_qmn_duplicate_data->total_user_tries,
382
- 'total_user_tries_text' => $mlw_qmn_duplicate_data->total_user_tries_text,
383
- 'certificate_template' => $mlw_qmn_duplicate_data->certificate_template,
384
- 'social_media' => $mlw_qmn_duplicate_data->social_media,
385
- 'social_media_text' => $mlw_qmn_duplicate_data->social_media_text,
386
- 'pagination' => $mlw_qmn_duplicate_data->pagination,
387
- 'pagination_text' => $mlw_qmn_duplicate_data->pagination_text,
388
- 'timer_limit' => $mlw_qmn_duplicate_data->timer_limit,
389
- 'quiz_stye' => $mlw_qmn_duplicate_data->quiz_stye,
390
- 'question_numbering' => $mlw_qmn_duplicate_data->question_numbering,
391
- 'quiz_settings' => serialize($quiz_settings),
392
- 'theme_selected' => $mlw_qmn_duplicate_data->theme_selected,
393
- 'last_activity' => date("Y-m-d H:i:s"),
394
- 'require_log_in' => $mlw_qmn_duplicate_data->require_log_in,
395
- 'require_log_in_text' => $mlw_qmn_duplicate_data->require_log_in_text,
396
- 'limit_total_entries' => $mlw_qmn_duplicate_data->limit_total_entries,
397
- 'limit_total_entries_text' => $mlw_qmn_duplicate_data->limit_total_entries_text,
398
- 'scheduled_timeframe' => $mlw_qmn_duplicate_data->scheduled_timeframe,
399
- 'scheduled_timeframe_text' => $mlw_qmn_duplicate_data->scheduled_timeframe_text,
400
- 'quiz_views' => 0,
401
- 'quiz_taken' => 0,
402
- 'deleted' => 0,
403
- 'quiz_author_id' => $current_user->ID,
404
- ),
405
- array(
406
- '%s',
407
- '%s',
408
- '%s',
409
- '%s',
410
- '%s',
411
- '%s',
412
- '%s',
413
- '%s',
414
- '%s',
415
- '%s',
416
- '%s',
417
- '%s',
418
- '%s',
419
- '%s',
420
- '%s',
421
- '%s',
422
- '%d',
423
- '%d',
424
- '%d',
425
- '%d',
426
- '%d',
427
- '%d',
428
- '%d',
429
- '%d',
430
- '%d',
431
- '%d',
432
- '%d',
433
- '%s',
434
- '%d',
435
- '%d',
436
- '%d',
437
- '%s',
438
- '%s',
439
- '%d',
440
- '%s',
441
- '%d',
442
- '%s',
443
- '%d',
444
- '%s',
445
- '%d',
446
- '%s',
447
- '%s',
448
- '%s',
449
- '%d',
450
- '%s',
451
- '%d',
452
- '%s',
453
- '%s',
454
- '%s',
455
- '%d',
456
- '%d',
457
- '%d',
458
- '%d',
459
- )
460
- );
461
- $mlw_new_id = $wpdb->insert_id;
462
 
463
- //Update quiz settings
464
- $update_quiz_settings = unserialize($mlw_qmn_duplicate_data->quiz_settings);
465
- $update_pages = unserialize($update_quiz_settings['pages']);
466
- //get logic data from logic table first or else from quiz_settings
467
- if (!is_null($logic_table_exists)) {
468
- $query = $wpdb->prepare("SELECT * FROM $logic_table WHERE quiz_id = %d", $quiz_id);
469
- $logic_data = $wpdb->get_results($query);
470
- $logic_rules = [];
471
- if (!empty($logic_data)) {
472
- foreach ($logic_data as $data) {
473
- $logic_rules[] = unserialize($data->logic);
474
- }
475
- }
476
- } else {
477
- $logic_rules = isset($update_quiz_settings['logic_rules']) ? unserialize(unserialize($update_quiz_settings['logic_rules'])) : array();
478
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
 
480
- if (false != $results) {
481
- $current_user = wp_get_current_user();
482
- $quiz_post = array(
483
- 'post_title' => $quiz_name,
484
- 'post_content' => "[mlw_quizmaster quiz=$mlw_new_id]",
485
- 'post_status' => 'publish',
486
- 'post_author' => $current_user->ID,
487
- 'post_type' => 'qsm_quiz',
488
- );
489
- $quiz_post_id = wp_insert_post($quiz_post);
490
- add_post_meta($quiz_post_id, 'quiz_id', $mlw_new_id);
491
- $mlwQuizMasterNext->alertManager->newAlert(__('Your quiz or survey has been duplicated successfully.', 'quiz-master-next'), 'success');
492
- $mlwQuizMasterNext->audit_manager->new_audit("New Quiz/Survey Has Been Created: $quiz_name");
493
- do_action('qmn_quiz_duplicated', $quiz_id, $mlw_new_id);
494
- } else {
495
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0011'), 'error');
496
- $mlwQuizMasterNext->log_manager->add("Error 0011", $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error');
497
- }
498
- if ($is_duplicating_questions) {
499
- $table_name = $wpdb->prefix . "mlw_questions";
500
- $questions = [];
501
- if (is_array($update_pages)) {
502
- foreach ($update_pages[0] as $ids) {
503
- $questions[] = $ids;
504
- }
505
- }
506
- $question_ids = implode(',', $questions);
507
- $mlw_current_questions = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name WHERE question_id IN (%1s)", $question_ids));
508
- foreach ($mlw_current_questions as $mlw_question) {
509
- $question_results = $wpdb->insert(
510
- $table_name,
511
- array(
512
- 'quiz_id' => $mlw_new_id,
513
- 'question_name' => $mlw_question->question_name,
514
- 'answer_array' => $mlw_question->answer_array,
515
- 'answer_one' => $mlw_question->answer_one,
516
- 'answer_one_points' => $mlw_question->answer_one_points,
517
- 'answer_two' => $mlw_question->answer_two,
518
- 'answer_two_points' => $mlw_question->answer_two_points,
519
- 'answer_three' => $mlw_question->answer_three,
520
- 'answer_three_points' => $mlw_question->answer_three_points,
521
- 'answer_four' => $mlw_question->answer_four,
522
- 'answer_four_points' => $mlw_question->answer_four_points,
523
- 'answer_five' => $mlw_question->answer_five,
524
- 'answer_five_points' => $mlw_question->answer_five_points,
525
- 'answer_six' => $mlw_question->answer_six,
526
- 'answer_six_points' => $mlw_question->answer_six_points,
527
- 'correct_answer' => $mlw_question->correct_answer,
528
- 'question_answer_info' => $mlw_question->question_answer_info,
529
- 'comments' => $mlw_question->comments,
530
- 'hints' => $mlw_question->hints,
531
- 'question_order' => $mlw_question->question_order,
532
- 'question_type_new' => $mlw_question->question_type_new,
533
- 'question_settings' => $mlw_question->question_settings,
534
- 'category' => $mlw_question->category,
535
- 'deleted' => 0,
536
- ),
537
- array(
538
- '%d',
539
- '%s',
540
- '%s',
541
- '%s',
542
- '%d',
543
- '%s',
544
- '%d',
545
- '%s',
546
- '%d',
547
- '%s',
548
- '%d',
549
- '%s',
550
- '%d',
551
- '%s',
552
- '%d',
553
- '%d',
554
- '%s',
555
- '%d',
556
- '%s',
557
- '%d',
558
- '%s',
559
- '%s',
560
- '%s',
561
- '%d',
562
- )
563
- );
564
- foreach ($update_pages as $pages_key => $pages_value) {
565
- foreach ($pages_value as $pages_k_q => $page_q_id) {
566
- if ($page_q_id == $mlw_question->question_id) {
567
- $update_pages[$pages_key][$pages_k_q] = $wpdb->insert_id;
568
- }
569
- }
570
- }
571
- // Fixed Rules Questions with new question ids
572
- if ($logic_rules) {
573
- foreach ($logic_rules as $logic_key => $logic_value) {
574
- foreach ($logic_value as $logic_cond_k => $logic_cond) {
575
- foreach ($logic_cond as $l_cond_k => $logic_val) {
576
- if ($logic_val['question'] == $mlw_question->question_id) {
577
- $logic_rules[$logic_key][$logic_cond_k][$l_cond_k]['question'] = $wpdb->insert_id;
578
- }
579
- }
580
- }
581
- }
582
- }
583
- if ($question_results == false) {
584
- $mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0020'), 'error');
585
- $mlwQuizMasterNext->log_manager->add("Error 0020", $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error');
586
- }
587
- }
588
- $update_quiz_settings['pages'] = serialize($update_pages);
589
- //saves data in logic table first or else in quiz_settings
590
- $value_array = [];
591
- if (is_array($logic_rules) && !empty($logic_rules)) {
592
- if (is_null($logic_table_exists)) {
593
- $update_quiz_settings['logic_rules'] = serialize(serialize($logic_rules));
594
- } else {
595
- foreach ($logic_rules as $logic_data) {
596
- $data = array(
597
- $mlw_new_id,
598
- serialize($logic_data),
599
- );
600
- $value_array[] = stripslashes($wpdb->prepare("(%d, %s)", $data));
601
- }
602
- $values = implode(',', $value_array);
603
- $query = "INSERT INTO $logic_table (quiz_id, logic) VALUES ";
604
- $query .= $values;
605
- $saved = $wpdb->query($query);
606
- if ($saved != false) {
607
- update_option("logic_rules_quiz_$mlw_new_id", date(time()));
608
- $update_quiz_settings['logic_rules'] = '';
609
- } else {
610
- $update_quiz_settings['logic_rules'] = serialize(serialize($logic_rules));
611
- }
612
- }
613
- }
614
 
615
- $wpdb->update(
616
- $wpdb->prefix . "mlw_quizzes",
617
- array(
618
- 'quiz_settings' => serialize($update_quiz_settings),
619
- ),
620
- array(
621
- 'quiz_id' => $mlw_new_id,
622
- )
623
- );
624
- }
625
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626
 
627
- /**
628
- * Retrieves setting store in quiz_settings
629
- *
630
- * @deprecated 6.0.3 Use the get_quiz_setting function in the pluginHelper object.
631
- * @since 3.8.1
632
- * @access public
633
- * @param string $setting_name The slug of the setting.
634
- * @return string The value of the setting
635
- */
636
- public function get_setting($setting_name)
637
- {
638
- global $wpdb;
639
- $qmn_settings_array = '';
640
- $qmn_quiz_settings = $wpdb->get_var($wpdb->prepare("SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id));
641
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings))) {
642
- $qmn_settings_array = @unserialize($qmn_quiz_settings);
643
- }
644
- if (is_array($qmn_settings_array) && isset($qmn_settings_array[$setting_name])) {
645
- return $qmn_settings_array[$setting_name];
646
- } else {
647
- return '';
648
- }
649
 
650
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
 
652
- /**
653
- * Updates setting stored in quiz_settings
654
- *
655
- * @deprecated 6.0.3 Use the update_quiz_setting function in the pluginHelper object.
656
- * @since 3.8.1
657
- * @access public
658
- * @param string $setting_name The slug of the setting.
659
- * @param mixed $setting_value The value for the setting.
660
- * @return bool True if update was successful
661
- */
662
- public function update_setting($setting_name, $setting_value)
663
- {
664
- global $wpdb;
665
- $qmn_settings_array = array();
666
- $qmn_quiz_settings = $wpdb->get_var($wpdb->prepare("SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id));
667
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings))) {
668
- $qmn_settings_array = @unserialize($qmn_quiz_settings);
669
- }
670
- $qmn_settings_array[$setting_name] = $setting_value;
671
- $qmn_serialized_array = serialize($qmn_settings_array);
672
- $results = $wpdb->update(
673
- $wpdb->prefix . "mlw_quizzes",
674
- array(
675
- 'quiz_settings' => $qmn_serialized_array,
676
- ),
677
- array('quiz_id' => $this->quiz_id),
678
- array(
679
- '%s',
680
- ),
681
- array('%d')
682
- );
683
- if ($results != false) {
684
- return true;
685
- } else {
686
- return false;
687
- }
688
- }
689
 
690
- /**
691
- * Deletes setting stored in quiz_settings
692
- *
693
- * @deprecated 6.0.3
694
- * @since 3.8.1
695
- * @access public
696
- * @return void
697
- */
698
- public function delete_setting($setting_name)
699
- {
700
- global $wpdb;
701
- $qmn_settings_array = array();
702
- $qmn_quiz_settings = $wpdb->get_var($wpdb->prepare("SELECT quiz_settings FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=%d", $this->quiz_id));
703
- if (is_serialized($qmn_quiz_settings) && is_array(@unserialize($qmn_quiz_settings))) {
704
- $qmn_settings_array = @unserialize($qmn_quiz_settings);
705
- }
706
- if (is_array($qmn_settings_array) && isset($qmn_settings_array[$setting_name])) {
707
- unset($qmn_settings_array[$setting_name]);
708
- }
709
- $qmn_serialized_array = serialize($qmn_settings_array);
710
- $results = $wpdb->update(
711
- $wpdb->prefix . "mlw_quizzes",
712
- array(
713
- 'quiz_settings' => $qmn_serialized_array,
714
- ),
715
- array('quiz_id' => $this->quiz_id),
716
- array(
717
- '%s',
718
- ),
719
- array('%d')
720
- );
721
- }
722
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
  }
5
 
6
  /**
12
  *
13
  * @since 3.7.1
14
  */
15
+ class QMNQuizCreator {
 
16
 
 
 
 
 
 
 
 
17
 
18
+ /**
19
+ * QMN ID of quiz
20
+ *
21
+ * @var object
22
+ * @since 3.7.1
23
+ */
24
+ private $quiz_id;
 
 
 
 
25
 
26
+ /**
27
+ * If the quiz ID is set, store it as the class quiz ID
28
+ *
29
+ * @since 3.7.1
30
+ */
31
+ public function __construct() {
32
+ if ( isset( $_REQUEST['quiz_id'] ) ) {
33
+ $this->quiz_id = intval( $_REQUEST['quiz_id'] );
34
+ }
35
+ }
 
 
36
 
37
+ /**
38
+ * Sets quiz ID
39
+ *
40
+ * @since 3.8.1
41
+ * @param int $quiz_id The ID of the quiz.
42
+ * @access public
43
+ * @return void
44
+ */
45
+ public function set_id( $quiz_id ) {
46
+ $this->quiz_id = intval( $quiz_id );
47
+ }
 
 
 
48
 
49
+ /**
50
+ * Gets the quiz ID stored (for backwards compatibility)
51
+ *
52
+ * @since 5.0.0
53
+ * @return int|false The ID of the quiz stored or false
54
+ */
55
+ public function get_id() {
56
+ if ( $this->quiz_id ) {
57
+ return intval( $this->quiz_id );
58
+ } else {
59
+ return false;
60
+ }
61
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
+ /**
64
+ * Creates a new quiz with the default settings
65
+ *
66
+ * @access public
67
+ * @since 3.7.1
68
+ * @param string $quiz_name The name of the new quiz.
69
+ * @return void
70
+ */
71
+ public function create_quiz( $quiz_name, $theme_id, $quiz_settings = '' ) {
72
+ global $mlwQuizMasterNext;
73
+ global $wpdb;
74
+ $current_user = wp_get_current_user();
75
+ $results = $wpdb->insert(
76
+ $wpdb->prefix . 'mlw_quizzes',
77
+ array(
78
+ 'quiz_name' => $quiz_name,
79
+ 'message_before' => __( 'Welcome to your %QUIZ_NAME%', 'quiz-master-next' ),
80
+ 'message_after' => __( 'Thanks for submitting your response! You can edit this message on the "Results Pages" tab. <br>%CONTACT_ALL% <br>%QUESTIONS_ANSWERS%', 'quiz-master-next' ),
81
+ 'message_comment' => __( 'Please fill in the comment box below.', 'quiz-master-next' ),
82
+ 'message_end_template' => '',
83
+ 'user_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
84
+ 'admin_email_template' => '%QUESTIONS_ANSWERS_EMAIL%',
85
+ 'submit_button_text' => __( 'Submit', 'quiz-master-next' ),
86
+ 'name_field_text' => __( 'Name', 'quiz-master-next' ),
87
+ 'business_field_text' => __( 'Business', 'quiz-master-next' ),
88
+ 'email_field_text' => __( 'Email', 'quiz-master-next' ),
89
+ 'phone_field_text' => __( 'Phone Number', 'quiz-master-next' ),
90
+ 'comment_field_text' => __( 'Comments', 'quiz-master-next' ),
91
+ 'email_from_text' => 'Wordpress',
92
+ 'question_answer_template' => '%QUESTION%<br />%USER_ANSWERS_DEFAULT%',
93
+ 'leaderboard_template' => '',
94
+ 'quiz_system' => 0,
95
+ 'randomness_order' => 0,
96
+ 'loggedin_user_contact' => 0,
97
+ 'show_score' => 0,
98
+ 'send_user_email' => 0,
99
+ 'send_admin_email' => 0,
100
+ 'contact_info_location' => 0,
101
+ 'user_name' => 2,
102
+ 'user_comp' => 2,
103
+ 'user_email' => 2,
104
+ 'user_phone' => 2,
105
+ 'admin_email' => get_option( 'admin_email', 'Enter email' ),
106
+ 'comment_section' => 1,
107
+ 'question_from_total' => 0,
108
+ 'total_user_tries' => 0,
109
+ 'total_user_tries_text' => __( 'You have utilized all of your attempts to pass this quiz.', 'quiz-master-next' ),
110
+ 'certificate_template' => '',
111
+ 'social_media' => 0,
112
+ 'social_media_text' => __( 'I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!', 'quiz-master-next' ),
113
+ 'pagination' => 0,
114
+ 'pagination_text' => __( 'Next', 'quiz-master-next' ),
115
+ 'timer_limit' => 0,
116
+ 'quiz_stye' => '',
117
+ 'question_numbering' => 0,
118
+ 'quiz_settings' => $quiz_settings,
119
+ 'theme_selected' => 'primary',
120
+ 'last_activity' => current_time( 'mysql' ),
121
+ 'require_log_in' => 0,
122
+ 'require_log_in_text' => __( 'This quiz is for logged in users only.', 'quiz-master-next' ),
123
+ 'limit_total_entries' => 0,
124
+ 'limit_total_entries_text' => __( 'Unfortunately, this quiz has a limited amount of entries it can recieve and has already reached that limit.', 'quiz-master-next' ),
125
+ 'scheduled_timeframe' => '',
126
+ 'scheduled_timeframe_text' => '',
127
+ 'quiz_views' => 0,
128
+ 'quiz_taken' => 0,
129
+ 'deleted' => 0,
130
+ 'quiz_author_id' => $current_user->ID,
131
+ ),
132
+ array(
133
+ '%s',
134
+ '%s',
135
+ '%s',
136
+ '%s',
137
+ '%s',
138
+ '%s',
139
+ '%s',
140
+ '%s',
141
+ '%s',
142
+ '%s',
143
+ '%s',
144
+ '%s',
145
+ '%s',
146
+ '%s',
147
+ '%s',
148
+ '%s',
149
+ '%d',
150
+ '%d',
151
+ '%d',
152
+ '%d',
153
+ '%d',
154
+ '%d',
155
+ '%d',
156
+ '%d',
157
+ '%d',
158
+ '%d',
159
+ '%d',
160
+ '%s',
161
+ '%d',
162
+ '%d',
163
+ '%d',
164
+ '%s',
165
+ '%s',
166
+ '%d',
167
+ '%s',
168
+ '%d',
169
+ '%s',
170
+ '%d',
171
+ '%s',
172
+ '%d',
173
+ '%s',
174
+ '%s',
175
+ '%s',
176
+ '%d',
177
+ '%s',
178
+ '%d',
179
+ '%s',
180
+ '%s',
181
+ '%s',
182
+ '%d',
183
+ '%d',
184
+ '%d',
185
+ '%d',
186
+ )
187
+ );
188
+ if ( false !== $results ) {
189
+ $new_quiz = $wpdb->insert_id;
190
+ $quiz_post = array(
191
+ 'post_title' => $quiz_name,
192
+ 'post_content' => "[mlw_quizmaster quiz=$new_quiz]",
193
+ 'post_status' => 'draft',
194
+ 'post_author' => $current_user->ID,
195
+ 'post_type' => 'qsm_quiz',
196
+ );
197
+ $quiz_post_id = wp_insert_post( $quiz_post );
198
+ add_post_meta( $quiz_post_id, 'quiz_id', $new_quiz );
199
 
200
+ // activating selected theme
201
+ $mlwQuizMasterNext->theme_settings->activate_selected_theme( $new_quiz, $theme_id );
202
 
203
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'Your new quiz or survey has been created successfully. To begin editing, click the Edit link.', 'quiz-master-next' ), 'success' );
204
+ $mlwQuizMasterNext->audit_manager->new_audit( "New Quiz/Survey Has Been Created: $quiz_name" );
 
 
 
 
 
205
 
206
+ // Hook called after new quiz or survey has been created. Passes quiz_id to hook
207
+ do_action( 'qmn_quiz_created', $new_quiz );
208
+ } else {
209
+ $mlwQuizMasterNext->alertManager->newAlert( sprintf( __( 'There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next' ), '0001' ), 'error' );
210
+ $mlwQuizMasterNext->log_manager->add( 'Error 0001', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
211
+ }
212
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
+ /**
215
+ * Deletes a quiz with the given quiz_id
216
+ *
217
+ * @access public
218
+ * @since 3.7.1
219
+ * @return void
220
+ */
221
+ public function delete_quiz( $quiz_id, $quiz_name ) {
222
+ global $mlwQuizMasterNext;
223
+ global $wpdb;
224
+ $results = $wpdb->update(
225
+ $wpdb->prefix . 'mlw_quizzes',
226
+ array(
227
+ 'deleted' => 1,
228
+ ),
229
+ array( 'quiz_id' => $quiz_id ),
230
+ array(
231
+ '%d',
232
+ ),
233
+ array( '%d' )
234
+ );
235
+ $deleted = 0;
236
+ if ( isset( $_POST['qsm_delete_question_from_qb'] ) && $_POST['qsm_delete_question_from_qb'] == 1 ) {
237
+ $deleted = 1;
238
+ }
239
+ $delete_question_results = $wpdb->update(
240
+ $wpdb->prefix . 'mlw_questions',
241
+ array(
242
+ 'deleted' => $deleted,
243
+ ),
244
+ array( 'quiz_id' => $quiz_id ),
245
+ array(
246
+ '%d',
247
+ ),
248
+ array( '%d' )
249
+ );
250
+ if ( $results != false ) {
251
+ $my_query = new WP_Query(
252
+ array(
253
+ 'post_type' => 'qsm_quiz',
254
+ 'meta_key' => 'quiz_id',
255
+ 'meta_value' => $quiz_id,
256
+ )
257
+ );
258
+ if ( $my_query->have_posts() ) {
259
+ while ( $my_query->have_posts() ) {
260
+ $my_query->the_post();
261
+ $my_post = array(
262
+ 'ID' => get_the_ID(),
263
+ 'post_status' => 'trash',
264
+ );
265
+ wp_update_post( $my_post );
266
+ }
267
+ }
268
+ wp_reset_postdata();
269
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'Your quiz or survey has been deleted successfully.', 'quiz-master-next' ), 'success' );
270
+ $mlwQuizMasterNext->audit_manager->new_audit( "Quiz/Survey Has Been Deleted: $quiz_name" );
271
+ } else {
272
+ $mlwQuizMasterNext->alertManager->newAlert( sprintf( __( 'There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next' ), '0002' ), 'error' );
273
+ $mlwQuizMasterNext->log_manager->add( 'Error 0002', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
274
+ }
275
 
276
+ // Hook called after quiz or survey is deleted. Hook passes quiz_id to function
277
+ do_action( 'qmn_quiz_deleted', $quiz_id );
278
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
+ /**
281
+ * Edits the name of the quiz with the given ID
282
+ *
283
+ * @access public
284
+ * @since 3.7.1
285
+ * @param int $quiz_id The ID of the quiz.
286
+ * @param string $quiz_name The new name of the quiz.
287
+ * @return void
288
+ */
289
+ public function edit_quiz_name( $quiz_id, $quiz_name ) {
290
+ global $mlwQuizMasterNext;
291
+ global $wpdb;
292
+ $results = $wpdb->update(
293
+ $wpdb->prefix . 'mlw_quizzes',
294
+ array(
295
+ 'quiz_name' => $quiz_name,
296
+ ),
297
+ array( 'quiz_id' => $quiz_id ),
298
+ array(
299
+ '%s',
300
+ ),
301
+ array( '%d' )
302
+ );
303
+ if ( false !== $results ) {
304
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'The name of your quiz or survey has been updated successfully.', 'quiz-master-next' ), 'success' );
305
+ $mlwQuizMasterNext->audit_manager->new_audit( "Quiz/Survey Name Has Been Edited: $quiz_name" );
306
+ } else {
307
+ $error = $wpdb->last_error;
308
+ if ( empty( $error ) ) {
309
+ $error = __( 'Unknown error', 'quiz-master-next' );
310
+ }
311
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'An error occurred while trying to update the name of your quiz or survey. Please try again.', 'quiz-master-next' ), 'error' );
312
+ $mlwQuizMasterNext->log_manager->add( 'Error when updating quiz name', "Tried {$wpdb->last_query} but got $error", 0, 'error' );
313
+ }
314
 
315
+ // Fires when the name of a quiz/survey is edited.
316
+ do_action( 'qsm_quiz_name_edited', $quiz_id, $quiz_name );
 
317
 
318
+ // Legacy code.
319
+ do_action( 'qmn_quiz_name_edited', $quiz_id );
320
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
+ /**
323
+ * Duplicates the quiz with the given ID and gives new quiz the given quiz name
324
+ *
325
+ * @access public
326
+ * @since 3.7.1
327
+ * @return void
328
+ */
329
+ public function duplicate_quiz( $quiz_id, $quiz_name, $is_duplicating_questions ) {
330
+ global $mlwQuizMasterNext;
331
+ global $wpdb;
332
+ $current_user = wp_get_current_user();
333
+ $table_name = $wpdb->prefix . 'mlw_quizzes';
334
+ $logic_table = $wpdb->prefix . 'mlw_logic';
335
+ $question_term = $wpdb->prefix . 'mlw_question_terms';
336
+ $logic_table_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $logic_table ) );
337
+ $question_term_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $question_term ) );
338
+ $mlw_qmn_duplicate_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE quiz_id=%d", $quiz_id ) );
339
+ $quiz_settings = unserialize( $mlw_qmn_duplicate_data->quiz_settings );
340
+ if ( $is_duplicating_questions == 0 ) {
341
+ $quiz_settings['pages'] = '';
342
+ }
343
+ $qsm_create_quiz_system = 0;
344
+ if ( isset( $mlw_qmn_duplicate_data->system ) ) {
345
+ $qsm_create_quiz_system = $mlw_qmn_duplicate_data->system;
346
+ } elseif ( isset( $mlw_qmn_duplicate_data->quiz_system ) ) {
347
+ $qsm_create_quiz_system = $mlw_qmn_duplicate_data->quiz_system;
348
+ }
349
+ $results = $wpdb->insert(
350
+ $table_name,
351
+ array(
352
+ 'quiz_name' => $quiz_name,
353
+ 'message_before' => $mlw_qmn_duplicate_data->message_before,
354
+ 'message_after' => $mlw_qmn_duplicate_data->message_after,
355
+ 'message_comment' => $mlw_qmn_duplicate_data->message_comment,
356
+ 'message_end_template' => $mlw_qmn_duplicate_data->message_end_template,
357
+ 'user_email_template' => $mlw_qmn_duplicate_data->user_email_template,
358
+ 'admin_email_template' => $mlw_qmn_duplicate_data->admin_email_template,
359
+ 'submit_button_text' => $mlw_qmn_duplicate_data->submit_button_text,
360
+ 'name_field_text' => $mlw_qmn_duplicate_data->name_field_text,
361
+ 'business_field_text' => $mlw_qmn_duplicate_data->business_field_text,
362
+ 'email_field_text' => $mlw_qmn_duplicate_data->email_field_text,
363
+ 'phone_field_text' => $mlw_qmn_duplicate_data->phone_field_text,
364
+ 'comment_field_text' => $mlw_qmn_duplicate_data->comment_field_text,
365
+ 'email_from_text' => $mlw_qmn_duplicate_data->email_from_text,
366
+ 'question_answer_template' => $mlw_qmn_duplicate_data->question_answer_template,
367
+ 'leaderboard_template' => $mlw_qmn_duplicate_data->leaderboard_template,
368
+ 'quiz_system' => $qsm_create_quiz_system,
369
+ 'randomness_order' => $mlw_qmn_duplicate_data->randomness_order,
370
+ 'loggedin_user_contact' => $mlw_qmn_duplicate_data->loggedin_user_contact,
371
+ 'show_score' => $mlw_qmn_duplicate_data->show_score,
372
+ 'send_user_email' => $mlw_qmn_duplicate_data->send_user_email,
373
+ 'send_admin_email' => $mlw_qmn_duplicate_data->send_admin_email,
374
+ 'contact_info_location' => $mlw_qmn_duplicate_data->contact_info_location,
375
+ 'user_name' => $mlw_qmn_duplicate_data->user_name,
376
+ 'user_comp' => $mlw_qmn_duplicate_data->user_comp,
377
+ 'user_email' => $mlw_qmn_duplicate_data->user_email,
378
+ 'user_phone' => $mlw_qmn_duplicate_data->user_phone,
379
+ 'admin_email' => get_option( 'admin_email', 'Enter email' ),
380
+ 'comment_section' => $mlw_qmn_duplicate_data->comment_section,
381
+ 'question_from_total' => $mlw_qmn_duplicate_data->question_from_total,
382
+ 'total_user_tries' => $mlw_qmn_duplicate_data->total_user_tries,
383
+ 'total_user_tries_text' => $mlw_qmn_duplicate_data->total_user_tries_text,
384
+ 'certificate_template' => $mlw_qmn_duplicate_data->certificate_template,
385
+ 'social_media' => $mlw_qmn_duplicate_data->social_media,
386
+ 'social_media_text' => $mlw_qmn_duplicate_data->social_media_text,
387
+ 'pagination' => $mlw_qmn_duplicate_data->pagination,
388
+ 'pagination_text' => $mlw_qmn_duplicate_data->pagination_text,
389
+ 'timer_limit' => $mlw_qmn_duplicate_data->timer_limit,
390
+ 'quiz_stye' => $mlw_qmn_duplicate_data->quiz_stye,
391
+ 'question_numbering' => $mlw_qmn_duplicate_data->question_numbering,
392
+ 'quiz_settings' => serialize( $quiz_settings ),
393
+ 'theme_selected' => $mlw_qmn_duplicate_data->theme_selected,
394
+ 'last_activity' => date( 'Y-m-d H:i:s' ),
395
+ 'require_log_in' => $mlw_qmn_duplicate_data->require_log_in,
396
+ 'require_log_in_text' => $mlw_qmn_duplicate_data->require_log_in_text,
397
+ 'limit_total_entries' => $mlw_qmn_duplicate_data->limit_total_entries,
398
+ 'limit_total_entries_text' => $mlw_qmn_duplicate_data->limit_total_entries_text,
399
+ 'scheduled_timeframe' => $mlw_qmn_duplicate_data->scheduled_timeframe,
400
+ 'scheduled_timeframe_text' => $mlw_qmn_duplicate_data->scheduled_timeframe_text,
401
+ 'quiz_views' => 0,
402
+ 'quiz_taken' => 0,
403
+ 'deleted' => 0,
404
+ 'quiz_author_id' => $current_user->ID,
405
+ ),
406
+ array(
407
+ '%s',
408
+ '%s',
409
+ '%s',
410
+ '%s',
411
+ '%s',
412
+ '%s',
413
+ '%s',
414
+ '%s',
415
+ '%s',
416
+ '%s',
417
+ '%s',
418
+ '%s',
419
+ '%s',
420
+ '%s',
421
+ '%s',
422
+ '%s',
423
+ '%d',
424
+ '%d',
425
+ '%d',
426
+ '%d',
427
+ '%d',
428
+ '%d',
429
+ '%d',
430
+ '%d',
431
+ '%d',
432
+ '%d',
433
+ '%d',
434
+ '%s',
435
+ '%d',
436
+ '%d',
437
+ '%d',
438
+ '%s',
439
+ '%s',
440
+ '%d',
441
+ '%s',
442
+ '%d',
443
+ '%s',
444
+ '%d',
445
+ '%s',
446
+ '%d',
447
+ '%s',
448
+ '%s',
449
+ '%s',
450
+ '%d',
451
+ '%s',
452
+ '%d',
453
+ '%s',
454
+ '%s',
455
+ '%s',
456
+ '%d',
457
+ '%d',
458
+ '%d',
459
+ '%d',
460
+ )
461
+ );
462
+ $mlw_new_id = $wpdb->insert_id;
463
 
464
+ // Update quiz settings
465
+ $update_quiz_settings = unserialize( $mlw_qmn_duplicate_data->quiz_settings );
466
+ $update_pages = unserialize( $update_quiz_settings['pages'] );
467
+ // get logic data from logic table first or else from quiz_settings
468
+ if ( ! is_null( $logic_table_exists ) ) {
469
+ $query = $wpdb->prepare( "SELECT * FROM $logic_table WHERE quiz_id = %d", $quiz_id );
470
+ $logic_data = $wpdb->get_results( $query );
471
+ $logic_rules = array();
472
+ if ( ! empty( $logic_data ) ) {
473
+ foreach ( $logic_data as $data ) {
474
+ $logic_rules[] = unserialize( $data->logic );
475
+ }
476
+ }
477
+ } else {
478
+ $logic_rules = isset( $update_quiz_settings['logic_rules'] ) ? unserialize( unserialize( $update_quiz_settings['logic_rules'] ) ) : array();
479
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
 
481
+ if ( false != $results ) {
482
+ $current_user = wp_get_current_user();
483
+ $quiz_post = array(
484
+ 'post_title' => $quiz_name,
485
+ 'post_content' => "[mlw_quizmaster quiz=$mlw_new_id]",
486
+ 'post_status' => 'publish',
487
+ 'post_author' => $current_user->ID,
488
+ 'post_type' => 'qsm_quiz',
489
+ );
490
+ $quiz_post_id = wp_insert_post( $quiz_post );
491
+ add_post_meta( $quiz_post_id, 'quiz_id', $mlw_new_id );
492
+ $mlwQuizMasterNext->alertManager->newAlert( __( 'Your quiz or survey has been duplicated successfully.', 'quiz-master-next' ), 'success' );
493
+ $mlwQuizMasterNext->audit_manager->new_audit( "New Quiz/Survey Has Been Created: $quiz_name" );
494
+ do_action( 'qmn_quiz_duplicated', $quiz_id, $mlw_new_id );
495
+ } else {
496
+ $mlwQuizMasterNext->alertManager->newAlert( sprintf( __( 'There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next' ), '0011' ), 'error' );
497
+ $mlwQuizMasterNext->log_manager->add( 'Error 0011', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
498
+ }
499
+ if ( $is_duplicating_questions ) {
500
+ $table_name = $wpdb->prefix . 'mlw_questions';
501
+ $questions = array();
502
+ if ( is_array( $update_pages ) ) {
503
+ foreach ( $update_pages as $ids ) {
504
+ foreach ( $ids as $id ) {
505
+ $questions[] = $id;
506
+ }
507
+ }
508
+ }
509
+ $question_ids = implode( ',', $questions );
510
+ $mlw_current_questions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table_name WHERE question_id IN (%1s)", $question_ids ) );
511
+ foreach ( $mlw_current_questions as $mlw_question ) {
512
+ $question_results = $wpdb->insert(
513
+ $table_name,
514
+ array(
515
+ 'quiz_id' => $mlw_new_id,
516
+ 'question_name' => $mlw_question->question_name,
517
+ 'answer_array' => $mlw_question->answer_array,
518
+ 'answer_one' => $mlw_question->answer_one,
519
+ 'answer_one_points' => $mlw_question->answer_one_points,
520
+ 'answer_two' => $mlw_question->answer_two,
521
+ 'answer_two_points' => $mlw_question->answer_two_points,
522
+ 'answer_three' => $mlw_question->answer_three,
523
+ 'answer_three_points' => $mlw_question->answer_three_points,
524
+ 'answer_four' => $mlw_question->answer_four,
525
+ 'answer_four_points' => $mlw_question->answer_four_points,
526
+ 'answer_five' => $mlw_question->answer_five,
527
+ 'answer_five_points' => $mlw_question->answer_five_points,
528
+ 'answer_six' => $mlw_question->answer_six,
529
+ 'answer_six_points' => $mlw_question->answer_six_points,
530
+ 'correct_answer' => $mlw_question->correct_answer,
531
+ 'question_answer_info' => $mlw_question->question_answer_info,
532
+ 'comments' => $mlw_question->comments,
533
+ 'hints' => $mlw_question->hints,
534
+ 'question_order' => $mlw_question->question_order,
535
+ 'question_type_new' => $mlw_question->question_type_new,
536
+ 'question_settings' => $mlw_question->question_settings,
537
+ 'category' => $mlw_question->category,
538
+ 'deleted' => 0,
539
+ ),
540
+ array(
541
+ '%d',
542
+ '%s',
543
+ '%s',
544
+ '%s',
545
+ '%d',
546
+ '%s',
547
+ '%d',
548
+ '%s',
549
+ '%d',
550
+ '%s',
551
+ '%d',
552
+ '%s',
553
+ '%d',
554
+ '%s',
555
+ '%d',
556
+ '%d',
557
+ '%s',
558
+ '%d',
559
+ '%s',
560
+ '%d',
561
+ '%s',
562
+ '%s',
563
+ '%s',
564
+ '%d',
565
+ )
566
+ );
567
+ foreach ( $update_pages as $pages_key => $pages_value ) {
568
+ foreach ( $pages_value as $pages_k_q => $page_q_id ) {
569
+ if ( $page_q_id == $mlw_question->question_id ) {
570
+ $update_pages[ $pages_key ][ $pages_k_q ] = $wpdb->insert_id;
571
+ }
572
+ }
573
+ }
574
+ // Fixed Rules Questions with new question ids
575
+ if ( $logic_rules ) {
576
+ foreach ( $logic_rules as $logic_key => $logic_value ) {
577
+ foreach ( $logic_value as $logic_cond_k => $logic_cond ) {
578
+ foreach ( $logic_cond as $l_cond_k => $logic_val ) {
579
+ if ( $logic_val['question'] == $mlw_question->question_id ) {
580
+ $logic_rules[ $logic_key ][ $logic_cond_k ][ $l_cond_k ]['question'] = $wpdb->insert_id;
581
+ }
582
+ }
583
+ }
584
+ }
585
+ }
586
+ // Copying categories for multiple categories table
587
+ $new_question_id = $wpdb->insert_id;
588
+ if ( ! is_null( $question_term_exists ) ) {
589
+ $query = $wpdb->prepare( "SELECT DISTINCT term_id FROM $question_term WHERE question_id = %d AND quiz_id = %d", $mlw_question->question_id, $quiz_id );
590
+ $term_ids = $wpdb->get_results( $query, ARRAY_N );
591
 
592
+ if ( ! is_null( $term_ids ) ) {
593
+ foreach ( $term_ids as $term_id ) {
594
+ $wpdb->insert(
595
+ $question_term,
596
+ array(
597
+ 'question_id' => $new_question_id,
598
+ 'quiz_id' => $mlw_new_id,
599
+ 'term_id' => $term_id[0],
600
+ 'taxonomy' => 'qsm_category',
601
+ ),
602
+ array(
603
+ '%d',
604
+ '%d',
605
+ '%d',
606
+ '%s',
607
+ )
608
+ );
609
+ }
610
+ }
611
+ }
 
 
612
 
613
+ if ( $question_results == false ) {
614
+ $mlwQuizMasterNext->alertManager->newAlert( sprintf( __( 'There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next' ), '0020' ), 'error' );
615
+ $mlwQuizMasterNext->log_manager->add( 'Error 0020', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error' );
616
+ }
617
+ }
618
+ $update_quiz_settings['pages'] = serialize( $update_pages );
619
+ // saves data in logic table first or else in quiz_settings
620
+ $value_array = array();
621
+ if ( is_array( $logic_rules ) && ! empty( $logic_rules ) ) {
622
+ if ( is_null( $logic_table_exists ) ) {
623
+ $update_quiz_settings['logic_rules'] = serialize( serialize( $logic_rules ) );
624
+ } else {
625
+ foreach ( $logic_rules as $logic_data ) {
626
+ $data = array(
627
+ $mlw_new_id,
628
+ serialize( $logic_data ),
629
+ );
630
+ $value_array[] = stripslashes( $wpdb->prepare( '(%d, %s)', $data ) );
631
+ }
632
+ $values = implode( ',', $value_array );
633
+ $query = "INSERT INTO $logic_table (quiz_id, logic) VALUES ";
634
+ $query .= $values;
635
+ $saved = $wpdb->query( $query );
636
+ if ( $saved != false ) {
637
+ update_option( "logic_rules_quiz_$mlw_new_id", date( time() ) );
638
+ $update_quiz_settings['logic_rules'] = '';
639
+ } else {
640
+ $update_quiz_settings['logic_rules'] = serialize( serialize( $logic_rules ) );
641
+ }
642
+ }
643
+ }
644
 
645
+ $wpdb->update(
646
+ $wpdb->prefix . 'mlw_quizzes',
647
+ array(
648
+ 'quiz_settings' => serialize( $update_quiz_settings ),
649
+ ),
650
+ array(
651
+ 'quiz_id' => $mlw_new_id,
652
+ )
653
+ );
654
+ }
655
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
 
657
+ /**
658
+ * Retrieves setting store in quiz_settings
659
+ *
660
+ * @deprecated 6.0.3 Use the get_quiz_setting function in the pluginHelper object.
661
+ * @since 3.8.1
662
+ * @access public
663
+ * @param string $setting_name The slug of the setting.
664
+ * @return string The value of the setting
665
+ */
666
+ public function get_setting( $setting_name ) {
667
+ global $wpdb;
668
+ $qmn_settings_array = '';
669
+ $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( 'SELECT quiz_settings FROM ' . $wpdb->prefix . 'mlw_quizzes' . ' WHERE quiz_id=%d', $this->quiz_id ) );
670
+ if ( is_serialized( $qmn_quiz_settings ) && is_array( @unserialize( $qmn_quiz_settings ) ) ) {
671
+ $qmn_settings_array = @unserialize( $qmn_quiz_settings );
672
+ }
673
+ if ( is_array( $qmn_settings_array ) && isset( $qmn_settings_array[ $setting_name ] ) ) {
674
+ return $qmn_settings_array[ $setting_name ];
675
+ } else {
676
+ return '';
677
+ }
678
+
679
+ }
680
+
681
+ /**
682
+ * Updates setting stored in quiz_settings
683
+ *
684
+ * @deprecated 6.0.3 Use the update_quiz_setting function in the pluginHelper object.
685
+ * @since 3.8.1
686
+ * @access public
687
+ * @param string $setting_name The slug of the setting.
688
+ * @param mixed $setting_value The value for the setting.
689
+ * @return bool True if update was successful
690
+ */
691
+ public function update_setting( $setting_name, $setting_value ) {
692
+ global $wpdb;
693
+ $qmn_settings_array = array();
694
+ $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( 'SELECT quiz_settings FROM ' . $wpdb->prefix . 'mlw_quizzes' . ' WHERE quiz_id=%d', $this->quiz_id ) );
695
+ if ( is_serialized( $qmn_quiz_settings ) && is_array( @unserialize( $qmn_quiz_settings ) ) ) {
696
+ $qmn_settings_array = @unserialize( $qmn_quiz_settings );
697
+ }
698
+ $qmn_settings_array[ $setting_name ] = $setting_value;
699
+ $qmn_serialized_array = serialize( $qmn_settings_array );
700
+ $results = $wpdb->update(
701
+ $wpdb->prefix . 'mlw_quizzes',
702
+ array(
703
+ 'quiz_settings' => $qmn_serialized_array,
704
+ ),
705
+ array( 'quiz_id' => $this->quiz_id ),
706
+ array(
707
+ '%s',
708
+ ),
709
+ array( '%d' )
710
+ );
711
+ if ( $results != false ) {
712
+ return true;
713
+ } else {
714
+ return false;
715
+ }
716
+ }
717
+
718
+ /**
719
+ * Deletes setting stored in quiz_settings
720
+ *
721
+ * @deprecated 6.0.3
722
+ * @since 3.8.1
723
+ * @access public
724
+ * @return void
725
+ */
726
+ public function delete_setting( $setting_name ) {
727
+ global $wpdb;
728
+ $qmn_settings_array = array();
729
+ $qmn_quiz_settings = $wpdb->get_var( $wpdb->prepare( 'SELECT quiz_settings FROM ' . $wpdb->prefix . 'mlw_quizzes' . ' WHERE quiz_id=%d', $this->quiz_id ) );
730
+ if ( is_serialized( $qmn_quiz_settings ) && is_array( @unserialize( $qmn_quiz_settings ) ) ) {
731
+ $qmn_settings_array = @unserialize( $qmn_quiz_settings );
732
+ }
733
+ if ( is_array( $qmn_settings_array ) && isset( $qmn_settings_array[ $setting_name ] ) ) {
734
+ unset( $qmn_settings_array[ $setting_name ] );
735
+ }
736
+ $qmn_serialized_array = serialize( $qmn_settings_array );
737
+ $results = $wpdb->update(
738
+ $wpdb->prefix . 'mlw_quizzes',
739
+ array(
740
+ 'quiz_settings' => $qmn_serialized_array,
741
+ ),
742
+ array( 'quiz_id' => $this->quiz_id ),
743
+ array(
744
+ '%s',
745
+ ),
746
+ array( '%d' )
747
+ );
748
+ }
749
+ }
php/classes/class-qmn-quiz-manager.php CHANGED
@@ -457,6 +457,13 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
457
  $order_by_sql = 'ORDER BY question_order ASC';
458
  $limit_sql = '';
459
  $big_array = array();
 
 
 
 
 
 
 
460
 
461
  // Checks if the questions should be randomized.
462
  $cat_query = '';
@@ -465,8 +472,12 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
465
  $categories = isset( $quiz_options->randon_category ) ? $quiz_options->randon_category : '';
466
  if ( $categories ) {
467
  $exploded_arr = explode( ',', $quiz_options->randon_category );
468
- $cat_str = "'" . implode( "', '", $exploded_arr ) . "'";
469
- $cat_query = " AND category IN ( $cat_str ) ";
 
 
 
 
470
  }
471
  }
472
 
@@ -483,10 +494,28 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
483
  $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() );
484
  // Get all question IDs needed.
485
  $total_pages = count( $pages );
 
 
 
 
 
 
 
 
 
 
486
  if ( $total_pages > 0 ) {
487
  for ( $i = 0; $i < $total_pages; $i++ ) {
488
  foreach ( $pages[ $i ] as $question ) {
489
- $question_ids[] = intval( $question );
 
 
 
 
 
 
 
 
490
  }
491
  }
492
  $question_ids = apply_filters( 'qsm_load_questions_ids', $question_ids, $quiz_id, $quiz_options );
@@ -805,6 +834,7 @@ $range = range(0, $quiz_options->question_from_total);
805
  if ( 0 == $options->contact_info_location ) {
806
  echo QSM_Contact_Manager::display_fields( $options );
807
  }
 
808
  ?>
809
  </div>
810
  </section>
@@ -842,7 +872,8 @@ $range = range(0, $quiz_options->question_from_total);
842
  $question_list .= $question_id . 'Q';
843
  $question = $questions[ $question_id ];
844
  ?>
845
- <div class='quiz_section question-section-id-<?php echo esc_attr( $question_id ); ?>'>
 
846
  <?php
847
  echo $mlwQuizMasterNext->pluginHelper->display_question( $question['question_type_new'], $question_id, $options );
848
  if ( 0 == $question['comments'] ) {
@@ -906,7 +937,8 @@ $range = range(0, $quiz_options->question_from_total);
906
  $question_list .= $question_id . 'Q';
907
  $question = $questions[ $question_id ];
908
  ?>
909
- <div class='quiz_section question-section-id-<?php echo esc_attr( $question_id ); ?>'>
 
910
  <?php
911
  echo $mlwQuizMasterNext->pluginHelper->display_question( $question['question_type_new'], $question_id, $options );
912
  if ( 0 == $question['comments'] ) {
@@ -1611,7 +1643,7 @@ $range = range(0, $quiz_options->question_from_total);
1611
  }
1612
 
1613
  // Send question to our grading function
1614
- $results_array = apply_filters( 'qmn_results_array', $mlwQuizMasterNext->pluginHelper->display_review( $question['question_type_new'], $question['question_id'] ) );
1615
  if ( isset( $results_array['question_type'] ) && $results_array['question_type'] == 'file_upload' ) {
1616
  $results_array['user_text'] = '<a target="_blank" href="' . $results_array['user_text'] . '">' . __( 'Click here to view', 'quiz-master-next' ) . '</a>';
1617
  }
@@ -1668,6 +1700,7 @@ $range = range(0, $quiz_options->question_from_total);
1668
  'id' => $question['question_id'],
1669
  'points' => $answer_points,
1670
  'category' => $question['category'],
 
1671
  'question_type' => $question['question_type_new'],
1672
  'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : '',
1673
  'user_compare_text' => $user_compare_text,
@@ -1715,7 +1748,7 @@ $range = range(0, $quiz_options->question_from_total);
1715
  }
1716
 
1717
  // Send question to our grading function
1718
- $results_array = apply_filters( 'qmn_results_array', $mlwQuizMasterNext->pluginHelper->display_review( $question['question_type_new'], $question['question_id'] ) );
1719
 
1720
  // If question was graded correctly.
1721
  if ( ! isset( $results_array['null_review'] ) ) {
@@ -1760,6 +1793,7 @@ $range = range(0, $quiz_options->question_from_total);
1760
  'id' => $question['question_id'],
1761
  'points' => $answer_points,
1762
  'category' => $question['category'],
 
1763
  'question_type' => $question['question_type_new'],
1764
  'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : '',
1765
  'user_compare_text' => $user_compare_text,
457
  $order_by_sql = 'ORDER BY question_order ASC';
458
  $limit_sql = '';
459
  $big_array = array();
460
+ $exploded_arr = array();
461
+ $multiple_category_system = false;
462
+ // check if multiple category is enabled.
463
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
464
+ if( $enabled && $enabled != 'cancelled' ){
465
+ $multiple_category_system = true;
466
+ }
467
 
468
  // Checks if the questions should be randomized.
469
  $cat_query = '';
472
  $categories = isset( $quiz_options->randon_category ) ? $quiz_options->randon_category : '';
473
  if ( $categories ) {
474
  $exploded_arr = explode( ',', $quiz_options->randon_category );
475
+ if ( ! $multiple_category_system ) {
476
+ $cat_str = "'" . implode( "', '", $exploded_arr ) . "'";
477
+ $cat_query = " AND category IN ( $cat_str ) ";
478
+ } else {
479
+ $exploded_arr = array_map( 'intval' , $exploded_arr );
480
+ }
481
  }
482
  }
483
 
494
  $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() );
495
  // Get all question IDs needed.
496
  $total_pages = count( $pages );
497
+ $category_question_ids = array();
498
+ if ( $multiple_category_system && ! empty( $exploded_arr )) {
499
+ $term_ids = implode( ', ', $exploded_arr );
500
+ $query = $wpdb->prepare( "SELECT DISTINCT question_id FROM {$wpdb->prefix}mlw_question_terms WHERE quiz_id = %d AND term_id IN (%1s)", $quiz_id, $term_ids);
501
+ $question_data = $wpdb->get_results( $query, ARRAY_N );
502
+ foreach( $question_data as $q_data ) {
503
+ $category_question_ids[] = $q_data[0];
504
+ }
505
+ }
506
+
507
  if ( $total_pages > 0 ) {
508
  for ( $i = 0; $i < $total_pages; $i++ ) {
509
  foreach ( $pages[ $i ] as $question ) {
510
+ if( ! empty( $category_question_ids ) ){
511
+ if( in_array( $question, $category_question_ids) ){
512
+ $question_ids[] = intval( $question );
513
+ }
514
+ } else {
515
+ $question_ids[] = intval( $question );
516
+ }
517
+
518
+
519
  }
520
  }
521
  $question_ids = apply_filters( 'qsm_load_questions_ids', $question_ids, $quiz_id, $quiz_options );
834
  if ( 0 == $options->contact_info_location ) {
835
  echo QSM_Contact_Manager::display_fields( $options );
836
  }
837
+ do_action('qsm_after_begin_message', $options, $quiz_data);
838
  ?>
839
  </div>
840
  </section>
872
  $question_list .= $question_id . 'Q';
873
  $question = $questions[ $question_id ];
874
  ?>
875
+ <div class='quiz_section qsm-question-wrapper question-section-id-<?php echo esc_attr( $question_id ); ?>'
876
+ data-qid="<?php echo esc_attr($question_id); ?>">
877
  <?php
878
  echo $mlwQuizMasterNext->pluginHelper->display_question( $question['question_type_new'], $question_id, $options );
879
  if ( 0 == $question['comments'] ) {
937
  $question_list .= $question_id . 'Q';
938
  $question = $questions[ $question_id ];
939
  ?>
940
+ <div class='quiz_section qsm-question-wrapper question-section-id-<?php echo esc_attr( $question_id ); ?>'
941
+ data-qid='<?php echo esc_attr($question_id); ?>'>
942
  <?php
943
  echo $mlwQuizMasterNext->pluginHelper->display_question( $question['question_type_new'], $question_id, $options );
944
  if ( 0 == $question['comments'] ) {
1643
  }
1644
 
1645
  // Send question to our grading function
1646
+ $results_array = apply_filters( 'qmn_results_array', $mlwQuizMasterNext->pluginHelper->display_review( $question['question_type_new'], $question['question_id'] ), $question );
1647
  if ( isset( $results_array['question_type'] ) && $results_array['question_type'] == 'file_upload' ) {
1648
  $results_array['user_text'] = '<a target="_blank" href="' . $results_array['user_text'] . '">' . __( 'Click here to view', 'quiz-master-next' ) . '</a>';
1649
  }
1700
  'id' => $question['question_id'],
1701
  'points' => $answer_points,
1702
  'category' => $question['category'],
1703
+ 'multicategories' => $question['multicategories'],
1704
  'question_type' => $question['question_type_new'],
1705
  'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : '',
1706
  'user_compare_text' => $user_compare_text,
1748
  }
1749
 
1750
  // Send question to our grading function
1751
+ $results_array = apply_filters( 'qmn_results_array', $mlwQuizMasterNext->pluginHelper->display_review( $question['question_type_new'], $question['question_id'] ), $question );
1752
 
1753
  // If question was graded correctly.
1754
  if ( ! isset( $results_array['null_review'] ) ) {
1793
  'id' => $question['question_id'],
1794
  'points' => $answer_points,
1795
  'category' => $question['category'],
1796
+ 'multicategories' => $question['multicategories'],
1797
  'question_type' => $question['question_type_new'],
1798
  'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : '',
1799
  'user_compare_text' => $user_compare_text,
php/classes/class-qsm-emails.php CHANGED
@@ -48,15 +48,26 @@ class QSM_Emails {
48
  // Cycle through each condition to see if we should sent this email.
49
  foreach ( $email['conditions'] as $condition ) {
50
  $value = $condition['value'];
51
-
 
 
 
52
  // First, determine which value we need to test.
53
  switch ( $condition['criteria'] ) {
54
  case 'score':
55
- $test = $response_data['total_score'];
 
 
 
 
56
  break;
57
 
58
  case 'points':
59
- $test = $response_data['total_points'];
 
 
 
 
60
  break;
61
 
62
  default:
@@ -471,4 +482,4 @@ class QSM_Emails {
471
  }
472
  }
473
  }
474
- ?>
48
  // Cycle through each condition to see if we should sent this email.
49
  foreach ( $email['conditions'] as $condition ) {
50
  $value = $condition['value'];
51
+ $category = '';
52
+ if( isset($condition['category'])){
53
+ $category = $condition['category'];
54
+ }
55
  // First, determine which value we need to test.
56
  switch ( $condition['criteria'] ) {
57
  case 'score':
58
+ if( $category != '' ){
59
+ $test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_SCORE_$category%", $response_data );
60
+ } else {
61
+ $test = $response_data['total_score'];
62
+ }
63
  break;
64
 
65
  case 'points':
66
+ if( $category != '' ){
67
+ $test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_POINTS_$category%", $response_data );
68
+ } else {
69
+ $test = $response_data['total_points'];
70
+ }
71
  break;
72
 
73
  default:
482
  }
483
  }
484
  }
485
+ ?>
php/classes/class-qsm-fields.php CHANGED
@@ -76,11 +76,11 @@ class QSM_Fields {
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' ); ?>
81
- <button class="button-primary"><?php _e('Save Changes', 'quiz-master-next'); ?></button>
82
- <table class="form-table" style="width: 100%;">
83
- <?php
84
  $array_before_legacy = array();
85
  foreach ( $fields as $key => $field ) {
86
  if( isset( $field['legacy_option'] ) && $field['legacy_option'] == 0 ){
@@ -105,10 +105,10 @@ class QSM_Fields {
105
  QSM_Fields::generate_field( $field, $settings[ $field["id"] ] );
106
  }
107
  ?>
108
- </table>
109
- <button class="button-primary"><?php _e('Save Changes', 'quiz-master-next'); ?></button>
110
- </form>
111
- <?php
112
  }
113
 
114
  /**
@@ -157,53 +157,55 @@ class QSM_Fields {
157
  */
158
  public static function generate_text_field( $field, $value ) {
159
  ?>
160
- <tr valign="top">
161
- <th scope="row" class="qsm-opt-tr">
162
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
163
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
164
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
165
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
166
- </span>
167
- <?php } ?>
168
- </th>
169
- <td>
170
- <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
171
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
172
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
173
- <?php } ?>
174
- </td>
175
- </tr>
176
- <?php
 
177
  }
178
 
179
  public static function generate_select_page_field( $field, $value ) {
180
  ?>
181
- <tr valign="top">
182
- <th scope="row" class="qsm-opt-tr">
183
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
184
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
185
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
186
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
187
- </span>
188
- <?php } ?>
189
- </th>
190
- <td>
191
- <select id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>">
192
- <option value="">Select Page</option>
193
- <?php
194
  $pages = get_pages();
195
  foreach ( $pages as $page ) { ?>
196
- <option value="<?php echo get_page_link( $page->ID ) ?>" <?php selected($value, get_page_link( $page->ID )); ?> ><?php echo $page->post_title ?></option>;
197
- <?php } ?>
198
- </select>
199
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
200
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
201
- <?php } ?>
202
- <br/>
203
- <b style="color: red;">Note: </b><?php echo isset($field['note']) ? $field['note'] : ''; ?>
204
- </td>
205
- </tr>
206
- <?php
 
207
  }
208
 
209
  /**
@@ -215,29 +217,29 @@ class QSM_Fields {
215
  */
216
  public static function generate_editor_field( $field, $value ) {
217
  ?>
218
- <tr>
219
- <th scope="row">
220
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?>
221
- <?php
222
  if ( is_array( $field["variables"] ) ) {
223
  ?>
224
- <br>
225
- <p><?php _e( "Allowed Variables:", 'quiz-master-next' ); ?></p>
226
- <?php
227
  foreach ( $field["variables"] as $variable ) {
228
  ?>
229
- <p style="margin: 2px 0">- <?php echo $variable; ?></p>
230
- <?php
231
  }
232
  }
233
  ?>
234
- </label>
235
- </th>
236
- <td>
237
- <?php wp_editor( htmlspecialchars_decode( $value, ENT_QUOTES ), $field["id"] ); ?>
238
- </td>
239
- </tr>
240
- <?php
241
  }
242
 
243
  /**
@@ -249,34 +251,35 @@ class QSM_Fields {
249
  */
250
  public static function generate_date_field( $field, $value ) {
251
  ?>
252
- <script>
253
- jQuery(function() {
254
- jQuery( "#<?php echo $field["id"]; ?>" ).datetimepicker({
255
- format:'m/d/Y H:i',
256
- step: 1
257
- });
258
- });
259
- </script>
260
- <tr valign="top">
261
- <th scope="row" class="qsm-opt-tr">
262
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
263
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
264
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
265
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
266
- </span>
267
- <?php } ?>
268
- </th>
269
- <td class="<?php echo $field["id"]; ?>">
270
- <?php if( isset($field['ph_text']) && $field['ph_text'] != ''){ ?>
271
- <span class="qsm-ph_text"><?php echo $field['ph_text']; ?></span>
272
- <?php } ?>
273
- <input autocomplete="off" type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
274
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
275
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
276
- <?php } ?>
277
- </td>
278
- </tr>
279
- <?php
 
280
  }
281
 
282
  /**
@@ -288,23 +291,24 @@ class QSM_Fields {
288
  */
289
  public static function generate_number_field( $field, $value ) {
290
  ?>
291
- <tr valign="top">
292
- <th scope="row" class="qsm-opt-tr">
293
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
294
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
295
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
296
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
297
- </span>
298
- <?php } ?>
299
- </th>
300
- <td>
301
- <input type="number" step="1" min="0" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>" value="<?php echo $value; ?>" />
302
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
303
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
304
- <?php } ?>
305
- </td>
306
- </tr>
307
- <?php
 
308
  }
309
 
310
  /**
@@ -317,32 +321,35 @@ class QSM_Fields {
317
  public static function generate_radio_field( $field, $value ) {
318
  $show_option = isset( $field['show_option'] ) ? $field['show_option'] : '';
319
  ?>
320
- <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ." hidden qsm_hidden_tr'"; } ?>>
321
- <th scope="row" class="qsm-opt-tr">
322
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
323
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
324
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
325
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
326
- </span>
327
- <?php } ?>
328
- </th>
329
- <td>
330
- <fieldset class="buttonset buttonset-hide" data-hide='1'>
331
- <?php
332
  foreach ( $field["options"] as $option ) {
333
- ?>
334
- <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"]; ?>" />
335
- <label for="<?php echo $field["id"] . '-' . $option["value"]; ?>"><?php echo $option["label"]; ?></label><br/>
336
- <?php
 
 
 
337
  }
338
  ?>
339
- </fieldset>
340
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
341
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
342
- <?php } ?>
343
- </td>
344
- </tr>
345
- <?php
346
  }
347
 
348
  /**
@@ -355,31 +362,32 @@ class QSM_Fields {
355
  public static function generate_select_field( $field, $value ) {
356
  $show_option = isset( $field['show_option'] ) ? $field['show_option'] : '';
357
  ?>
358
- <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ."'"; } ?>>
359
- <th scope="row" class="qsm-opt-tr">
360
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
361
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
362
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
363
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
364
- </span>
365
- <?php } ?>
366
- </th>
367
- <td>
368
- <select name="<?php echo $field["id"]; ?>">
369
- <?php
370
  foreach ( $field["options"] as $option ) {
371
- ?>
372
- <option <?php selected( $option["value"], $value ); ?> value="<?php echo $option["value"]; ?>"><?php echo $option["label"]; ?></option>
373
- <?php
 
374
  }
375
  ?>
376
- </select>
377
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
378
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
379
- <?php } ?>
380
- </td>
381
- </tr>
382
- <?php
383
  }
384
 
385
  /**
@@ -394,49 +402,73 @@ class QSM_Fields {
394
  $quiz_id = isset($_GET['quiz_id']) ? $_GET['quiz_id'] : 0;
395
  $explode_cat = explode(',', $value);
396
  ?>
397
- <tr valign="top">
398
- <th scope="row" class="qsm-opt-tr">
399
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
400
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
401
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
402
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
403
- </span>
404
- <?php } ?>
405
- </th>
406
- <td>
407
- <?php
408
  $questions = QSM_Questions::load_questions_by_pages( $quiz_id );
409
  $cat_array = array();
410
  if($questions){
411
- foreach( $questions as $single_question ){
412
- $cat_array[] = $single_question['category'];
413
- }
414
- $cat_array = array_unique($cat_array);
415
- if($cat_array){
416
- ?>
417
- <select class="category_selection_random" multiple="">
418
- <option value="">Select Categories</option>
419
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  foreach( $cat_array as $single_cat ){ ?>
421
- <option <?php if( in_array($single_cat, $explode_cat) ){ echo "selected"; } ?> value="<?php echo $single_cat; ?>"><?php echo $single_cat; ?></option>
 
 
 
 
 
 
 
 
 
 
422
  <?php
423
  } ?>
424
- </select>
425
- <?php
426
  }else{
427
- echo 'No catergory found.';
428
  }
429
  }else{
430
  echo 'No catergory found.';
431
  }
432
  ?>
433
- <input type="hidden" class="catergory_comma_values" name="<?php echo $field["id"]; ?>" value='<?php echo $value; ?>'>
434
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
435
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
436
- <?php } ?>
437
- </td>
438
- </tr>
439
- <?php
 
440
  }
441
 
442
  /**
@@ -447,22 +479,22 @@ class QSM_Fields {
447
  * Generate the hide show div
448
  */
449
  public static function generate_hide_show_field( $field, $value ) { ?>
450
- <tr valign="top">
451
- <th scope="row" class="qsm-opt-tr">
452
- <a href="#" id="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></a>
453
- <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
454
- <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
455
- <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
456
- </span>
457
- <?php } ?>
458
- </th>
459
- <td>
460
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
461
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
462
- <?php } ?>
463
- </td>
464
- </tr>
465
- <?php
466
  }
467
 
468
  /**
@@ -474,12 +506,14 @@ class QSM_Fields {
474
  */
475
  public static function generate_section_heading_field( $field, $value ) {
476
  ?>
477
- <tr valign="top">
478
- <th scope="row"><h2 class="section_heading"><?php echo $field["label"]; ?></h2></th>
479
- <td>
480
- </td>
481
- </tr>
482
- <?php
 
 
483
  }
484
  /**
485
  * Generates checkbox inputs
@@ -493,29 +527,32 @@ class QSM_Fields {
493
  global $mlwQuizMasterNext;
494
  $score_roundoff = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'score_roundoff');
495
  ?>
496
- <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ." hidden qsm_hidden_tr qsm_hidden_tr_gradingsystem'"; } ?>>
497
- <th scope="row" class="qsm-opt-tr">
498
- <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
499
- </th>
500
- <td>
501
- <fieldset class="buttonset buttonset-hide" data-hide='1'>
502
- <?php
 
503
  foreach ( $field["options"] as $option ) {
504
- ?>
505
- <input type="checkbox" id="<?php echo $field["id"] . '-' . $option["value"]; ?>" name="<?php echo $field["id"]; ?>" <?php checked( $option["value"], $score_roundoff ); ?> value="<?php echo $option["value"]; ?>" />
506
- <br/>
507
- <?php
 
 
508
  }
509
  ?>
510
- </fieldset>
511
- <?php if( isset($field['help']) && $field['help'] != ''){ ?>
512
- <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
513
- <?php } ?>
514
- </td>
515
- </tr>
516
- <?php
517
  }
518
 
519
  }
520
 
521
- ?>
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' ); ?>
81
+ <button class="button-primary"><?php _e('Save Changes', 'quiz-master-next'); ?></button>
82
+ <table class="form-table" style="width: 100%;">
83
+ <?php
84
  $array_before_legacy = array();
85
  foreach ( $fields as $key => $field ) {
86
  if( isset( $field['legacy_option'] ) && $field['legacy_option'] == 0 ){
105
  QSM_Fields::generate_field( $field, $settings[ $field["id"] ] );
106
  }
107
  ?>
108
+ </table>
109
+ <button class="button-primary"><?php _e('Save Changes', 'quiz-master-next'); ?></button>
110
+ </form>
111
+ <?php
112
  }
113
 
114
  /**
157
  */
158
  public static function generate_text_field( $field, $value ) {
159
  ?>
160
+ <tr valign="top">
161
+ <th scope="row" class="qsm-opt-tr">
162
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
163
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
164
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
165
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
166
+ </span>
167
+ <?php } ?>
168
+ </th>
169
+ <td>
170
+ <input type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>"
171
+ value="<?php echo $value; ?>" />
172
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
173
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
174
+ <?php } ?>
175
+ </td>
176
+ </tr>
177
+ <?php
178
  }
179
 
180
  public static function generate_select_page_field( $field, $value ) {
181
  ?>
182
+ <tr valign="top">
183
+ <th scope="row" class="qsm-opt-tr">
184
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
185
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
186
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
187
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
188
+ </span>
189
+ <?php } ?>
190
+ </th>
191
+ <td>
192
+ <select id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>">
193
+ <option value="">Select Page</option>
194
+ <?php
195
  $pages = get_pages();
196
  foreach ( $pages as $page ) { ?>
197
+ <option value="<?php echo get_page_link( $page->ID ) ?>"
198
+ <?php selected($value, get_page_link( $page->ID )); ?>><?php echo $page->post_title ?></option>;
199
+ <?php } ?>
200
+ </select>
201
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
202
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
203
+ <?php } ?>
204
+ <br />
205
+ <b style="color: red;">Note: </b><?php echo isset($field['note']) ? $field['note'] : ''; ?>
206
+ </td>
207
+ </tr>
208
+ <?php
209
  }
210
 
211
  /**
217
  */
218
  public static function generate_editor_field( $field, $value ) {
219
  ?>
220
+ <tr>
221
+ <th scope="row">
222
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?>
223
+ <?php
224
  if ( is_array( $field["variables"] ) ) {
225
  ?>
226
+ <br>
227
+ <p><?php _e( "Allowed Variables:", 'quiz-master-next' ); ?></p>
228
+ <?php
229
  foreach ( $field["variables"] as $variable ) {
230
  ?>
231
+ <p style="margin: 2px 0">- <?php echo $variable; ?></p>
232
+ <?php
233
  }
234
  }
235
  ?>
236
+ </label>
237
+ </th>
238
+ <td>
239
+ <?php wp_editor( htmlspecialchars_decode( $value, ENT_QUOTES ), $field["id"] ); ?>
240
+ </td>
241
+ </tr>
242
+ <?php
243
  }
244
 
245
  /**
251
  */
252
  public static function generate_date_field( $field, $value ) {
253
  ?>
254
+ <script>
255
+ jQuery(function() {
256
+ jQuery("#<?php echo $field["id"]; ?>").datetimepicker({
257
+ format: 'm/d/Y H:i',
258
+ step: 1
259
+ });
260
+ });
261
+ </script>
262
+ <tr valign="top">
263
+ <th scope="row" class="qsm-opt-tr">
264
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
265
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
266
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
267
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
268
+ </span>
269
+ <?php } ?>
270
+ </th>
271
+ <td class="<?php echo $field["id"]; ?>">
272
+ <?php if( isset($field['ph_text']) && $field['ph_text'] != ''){ ?>
273
+ <span class="qsm-ph_text"><?php echo $field['ph_text']; ?></span>
274
+ <?php } ?>
275
+ <input autocomplete="off" type="text" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>"
276
+ value="<?php echo $value; ?>" />
277
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
278
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
279
+ <?php } ?>
280
+ </td>
281
+ </tr>
282
+ <?php
283
  }
284
 
285
  /**
291
  */
292
  public static function generate_number_field( $field, $value ) {
293
  ?>
294
+ <tr valign="top">
295
+ <th scope="row" class="qsm-opt-tr">
296
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
297
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
298
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
299
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
300
+ </span>
301
+ <?php } ?>
302
+ </th>
303
+ <td>
304
+ <input type="number" step="1" min="0" id="<?php echo $field["id"]; ?>" name="<?php echo $field["id"]; ?>"
305
+ value="<?php echo $value; ?>" />
306
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
307
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
308
+ <?php } ?>
309
+ </td>
310
+ </tr>
311
+ <?php
312
  }
313
 
314
  /**
321
  public static function generate_radio_field( $field, $value ) {
322
  $show_option = isset( $field['show_option'] ) ? $field['show_option'] : '';
323
  ?>
324
+ <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ." hidden qsm_hidden_tr'"; } ?>>
325
+ <th scope="row" class="qsm-opt-tr">
326
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
327
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
328
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
329
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
330
+ </span>
331
+ <?php } ?>
332
+ </th>
333
+ <td>
334
+ <fieldset class="buttonset buttonset-hide" data-hide='1'>
335
+ <?php
336
  foreach ( $field["options"] as $option ) {
337
+ ?>
338
+ <input type="radio" id="<?php echo $field["id"] . '-' . $option["value"]; ?>"
339
+ name="<?php echo $field["id"]; ?>" <?php checked( $option["value"], $value ); ?>
340
+ value="<?php echo $option["value"]; ?>" />
341
+ <label
342
+ for="<?php echo $field["id"] . '-' . $option["value"]; ?>"><?php echo $option["label"]; ?></label><br />
343
+ <?php
344
  }
345
  ?>
346
+ </fieldset>
347
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
348
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
349
+ <?php } ?>
350
+ </td>
351
+ </tr>
352
+ <?php
353
  }
354
 
355
  /**
362
  public static function generate_select_field( $field, $value ) {
363
  $show_option = isset( $field['show_option'] ) ? $field['show_option'] : '';
364
  ?>
365
+ <tr valign="top" <?php if( $show_option ){ echo "class='". $show_option ."'"; } ?>>
366
+ <th scope="row" class="qsm-opt-tr">
367
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
368
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
369
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
370
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
371
+ </span>
372
+ <?php } ?>
373
+ </th>
374
+ <td>
375
+ <select name="<?php echo $field["id"]; ?>">
376
+ <?php
377
  foreach ( $field["options"] as $option ) {
378
+ ?>
379
+ <option <?php selected( $option["value"], $value ); ?> value="<?php echo $option["value"]; ?>">
380
+ <?php echo $option["label"]; ?></option>
381
+ <?php
382
  }
383
  ?>
384
+ </select>
385
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
386
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
387
+ <?php } ?>
388
+ </td>
389
+ </tr>
390
+ <?php
391
  }
392
 
393
  /**
402
  $quiz_id = isset($_GET['quiz_id']) ? $_GET['quiz_id'] : 0;
403
  $explode_cat = explode(',', $value);
404
  ?>
405
+ <tr valign="top">
406
+ <th scope="row" class="qsm-opt-tr">
407
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
408
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
409
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
410
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
411
+ </span>
412
+ <?php } ?>
413
+ </th>
414
+ <td>
415
+ <?php
416
  $questions = QSM_Questions::load_questions_by_pages( $quiz_id );
417
  $cat_array = array();
418
  if($questions){
419
+ $multiple_category_system = false;
420
+ // check if multiple category is enabled.
421
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
422
+ if( $enabled && $enabled != 'cancelled' ){
423
+ $multiple_category_system = true;
424
+ }
425
+ foreach( $questions as $single_question ){
426
+ if( $multiple_category_system ){
427
+ foreach($single_question['multicategories'] as $category_id ){
428
+ $cat_array[] = $category_id;
429
+ }
430
+ } else {
431
+ $cat_array[] = $single_question['category'];
432
+ }
433
+ }
434
+ $cat_array = array_unique($cat_array);
435
+ if($cat_array){
436
+
437
+ ?>
438
+ <select class="category_selection_random" multiple="">
439
+ <option value="">Select Categories</option>
440
+ <?php
441
  foreach( $cat_array as $single_cat ){ ?>
442
+ <option <?php if( in_array($single_cat, $explode_cat) ){ echo "selected"; } ?>
443
+ value="<?php echo $single_cat; ?>">
444
+ <?php
445
+ if($multiple_category_system){
446
+ $cat_data = get_term_by('term_id', $single_cat, 'qsm_category' );
447
+ echo $cat_data->name;
448
+ } else {
449
+ echo $single_cat;
450
+ }
451
+ ?>
452
+ </option>
453
  <?php
454
  } ?>
455
+ </select>
456
+ <?php
457
  }else{
458
+ echo 'No category found.';
459
  }
460
  }else{
461
  echo 'No catergory found.';
462
  }
463
  ?>
464
+ <input type="hidden" class="catergory_comma_values" name="<?php echo $field["id"]; ?>"
465
+ value='<?php echo $value; ?>'>
466
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
467
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
468
+ <?php } ?>
469
+ </td>
470
+ </tr>
471
+ <?php
472
  }
473
 
474
  /**
479
  * Generate the hide show div
480
  */
481
  public static function generate_hide_show_field( $field, $value ) { ?>
482
+ <tr valign="top">
483
+ <th scope="row" class="qsm-opt-tr">
484
+ <a href="#" id="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></a>
485
+ <?php if( isset($field['tooltip']) && $field['tooltip'] != '' ){ ?>
486
+ <span class="dashicons dashicons-editor-help qsm-tooltips-icon">
487
+ <span class="qsm-tooltips"><?php echo $field['tooltip']; ?></span>
488
+ </span>
489
+ <?php } ?>
490
+ </th>
491
+ <td>
492
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
493
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
494
+ <?php } ?>
495
+ </td>
496
+ </tr>
497
+ <?php
498
  }
499
 
500
  /**
506
  */
507
  public static function generate_section_heading_field( $field, $value ) {
508
  ?>
509
+ <tr valign="top">
510
+ <th scope="row">
511
+ <h2 class="section_heading"><?php echo $field["label"]; ?></h2>
512
+ </th>
513
+ <td>
514
+ </td>
515
+ </tr>
516
+ <?php
517
  }
518
  /**
519
  * Generates checkbox inputs
527
  global $mlwQuizMasterNext;
528
  $score_roundoff = $mlwQuizMasterNext->pluginHelper->get_section_setting('quiz_options', 'score_roundoff');
529
  ?>
530
+ <tr valign="top"
531
+ <?php if( $show_option ){ echo "class='". $show_option ." hidden qsm_hidden_tr qsm_hidden_tr_gradingsystem'"; } ?>>
532
+ <th scope="row" class="qsm-opt-tr">
533
+ <label for="<?php echo $field["id"]; ?>"><?php echo $field["label"]; ?></label>
534
+ </th>
535
+ <td>
536
+ <fieldset class="buttonset buttonset-hide" data-hide='1'>
537
+ <?php
538
  foreach ( $field["options"] as $option ) {
539
+ ?>
540
+ <input type="checkbox" id="<?php echo $field["id"] . '-' . $option["value"]; ?>"
541
+ name="<?php echo $field["id"]; ?>" <?php checked( $option["value"], $score_roundoff ); ?>
542
+ value="<?php echo $option["value"]; ?>" />
543
+ <br />
544
+ <?php
545
  }
546
  ?>
547
+ </fieldset>
548
+ <?php if( isset($field['help']) && $field['help'] != ''){ ?>
549
+ <span class="qsm-opt-desc"><?php echo $field['help']; ?></span>
550
+ <?php } ?>
551
+ </td>
552
+ </tr>
553
+ <?php
554
  }
555
 
556
  }
557
 
558
+ ?>
php/classes/class-qsm-install.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
4
 
5
  /**
6
  * Class that handles installation, updates, and plugin row meta
@@ -9,1251 +11,1234 @@ if ( ! defined( 'ABSPATH' ) ) exit;
9
  */
10
  class QSM_Install {
11
 
12
- /**
13
- * Main Constructor
14
- *
15
- * @uses QSM_Install::add_hooks
16
- * @since 4.7.1
17
- */
18
- function __construct() {
19
- $this->add_hooks();
20
- }
21
-
22
- /**
23
- * Adds the various class functions to hooks and filters
24
- *
25
- * @since 4.7.1
26
- */
27
- public function add_hooks() {
28
- add_action( 'admin_init', array( $this, 'update' ) );
29
- add_action( 'admin_init', array( $this, 'update' ) );
30
- add_filter( 'plugin_action_links_' . QSM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
31
- add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
32
- add_action( 'plugins_loaded', array( $this, 'register_default_settings' ) );
33
- }
34
-
35
- /**
36
- * Adds the default quiz settings
37
- *
38
- * @since 5.0.0
39
- */
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(
74
- 'label' => __('Correct/Incorrect', 'quiz-master-next'),
75
- 'value' => 0
76
- ),
77
- array(
78
- 'label' => __('Points', 'quiz-master-next'),
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 Rounding setting
94
- $field_array = array(
95
- 'id' => 'score_roundoff',
96
- 'label' => __('Allow Score Round-off', 'quiz-master-next'),
97
- 'type' => 'checkbox',
98
- 'options' => array(
99
- array(
100
- 'value' => 1
101
- )
102
- ),
103
- 'default' => 0,
104
- 'show_option' => 'form_type_0'
105
- );
106
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
107
-
108
- // Registers progress_bar setting
109
- $field_array = array(
110
- 'id' => 'progress_bar',
111
- 'label' => __( 'Show progress bar', 'quiz-master-next' ),
112
- 'type' => 'radio',
113
- 'options' => array(
114
- array(
115
- 'label' => __( 'Yes', 'quiz-master-next' ),
116
- 'value' => 1
117
- ),
118
- array(
119
- 'label' => __( 'No', 'quiz-master-next' ),
120
- 'value' => 0
121
- )
122
- ),
123
- 'default' => 0
124
- );
125
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
126
-
127
- // Registers require_log_in setting
128
- $field_array = array(
129
- 'id' => 'require_log_in',
130
- 'label' => __('Require User Login', 'quiz-master-next'),
131
- 'type' => 'radio',
132
- 'options' => array(
133
- array(
134
- 'label' => __('Yes', 'quiz-master-next'),
135
- 'value' => 1
136
- ),
137
- array(
138
- 'label' => __('No', 'quiz-master-next'),
139
- 'value' => 0
140
- )
141
- ),
142
- 'default' => 0,
143
- 'help' => __('Enabling this allows only logged in users to take the quiz','quiz-master-next')
144
- );
145
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
146
-
147
- // Registers pagination setting
148
- $field_array = array(
149
- 'id' => 'pagination',
150
- 'label' => __('Questions Per Page', 'quiz-master-next'),
151
- 'type' => 'number',
152
- 'options' => array(
153
-
154
- ),
155
- 'default' => 0,
156
- 'help' => __('Override the default pagination created on questions tab','quiz-master-next')
157
- );
158
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
159
-
160
- // Registers timer_limit setting
161
- $field_array = array(
162
- 'id' => 'timer_limit',
163
- 'label' => __('Time Limit (in minutes)', 'quiz-master-next'),
164
- 'type' => 'number',
165
- 'options' => array(
166
-
167
- ),
168
- 'default' => 0,
169
- 'help' => __('Leave 0 for no time limit','quiz-master-next')
170
- );
171
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
172
-
173
- // Settings for quick result
174
- $field_array = array(
175
- 'id' => 'enable_result_after_timer_end',
176
- 'label' => __('Force submit after timer expiry', 'quiz-master-next'),
177
- 'type' => 'radio',
178
- 'options' => array(
179
- array(
180
- 'label' => __('Yes', 'quiz-master-next'),
181
- 'value' => 1
182
- ),
183
- array(
184
- 'label' => __('No', 'quiz-master-next'),
185
- 'value' => 0
186
- )
187
- ),
188
- 'default' => 0
189
- );
190
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
191
-
192
- $field_array = array(
193
- 'id' => 'skip_validation_time_expire',
194
- 'label' => __('Skip validations when time expire', 'quiz-master-next'),
195
- 'type' => 'radio',
196
- 'options' => array(
197
- array(
198
- 'label' => __('Yes', 'quiz-master-next'),
199
- 'value' => 1
200
- ),
201
- array(
202
- 'label' => __('No', 'quiz-master-next'),
203
- 'value' => 0
204
- )
205
- ),
206
- 'default' => 1
207
- );
208
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
209
-
210
- // Registers total_user_tries setting
211
- $field_array = array(
212
- 'id' => 'total_user_tries',
213
- 'label' => __('Limit Attempts', 'quiz-master-next'),
214
- 'type' => 'number',
215
- 'options' => array(
216
-
217
- ),
218
- 'default' => 0,
219
- 'help' => __('Leave 0 for unlimited attempts','quiz-master-next'),
220
- 'tooltip' => __('Limits how many times a user can take the quiz','quiz-master-next')
221
- );
222
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
223
-
224
- // Registers limit_total_entries setting
225
- $field_array = array(
226
- 'id' => 'limit_total_entries',
227
- 'label' => __('Limit Entries', 'quiz-master-next'),
228
- 'type' => 'number',
229
- 'options' => array(
230
-
231
- ),
232
- 'default' => 0,
233
- 'help' => __('Leave 0 for unlimited entries','quiz-master-next'),
234
- 'tooltip' => __('Limits how many users can take the quiz.','quiz-master-next')
235
- );
236
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
237
-
238
- // Registers question_from_total setting
239
- $field_array = array(
240
- 'id' => 'question_from_total',
241
- 'label' => __('Limit number of Questions', 'quiz-master-next'),
242
- 'type' => 'number',
243
- 'options' => array(
244
-
245
- ),
246
- 'default' => 0,
247
- 'help' => __('Leave 0 to load all questions','quiz-master-next'),
248
- 'tooltip' => __('Show only limited number of questions from your quiz.','quiz-master-next')
249
- );
250
-
251
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
252
-
253
-
254
- // Registers question_per_category setting
255
- $field_array = array(
256
- 'id' => 'question_per_category',
257
- 'label' => __('Limit number of Questions Per Category ', 'quiz-master-next'),
258
- 'type' => 'number',
259
- 'options' => array(
260
-
261
- ),
262
- 'default' => 0,
263
- 'help' => __('Leave 0 to load all questions. You also need to set Limit Number of questions, as well as select Question Categories','quiz-master-next'),
264
- 'tooltip' => __('Show only limited number of category questions from your quiz.You also need to set Limit Number of questions.','quiz-master-next')
265
- );
266
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
267
-
268
- // Registers scheduled_time_start setting
269
- $field_array = array(
270
- 'id' => 'scheduled_time_start',
271
- 'label' => __('Quiz Dates', 'quiz-master-next'),
272
- 'type' => 'date',
273
- 'options' => array(
274
-
275
- ),
276
- 'default' => '',
277
- 'help' => '',
278
- 'ph_text' => __('Start Date','quiz-master-next'),
279
- 'help' => __('If set, Quiz will be accessible only after this date', 'quiz-master-next'),
280
- 'tooltip' => __( 'Leave blank for no date limit', 'quiz-master-next' )
281
- );
282
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
283
-
284
- // Registers scheduled_time_end setting
285
- $field_array = array(
286
- 'id' => 'scheduled_time_end',
287
- 'label' => '',
288
- 'type' => 'date',
289
- 'options' => array(
290
-
291
- ),
292
- 'default' => '',
293
- 'help' => __(' If set, Quiz will not be accessible after this date','quiz-master-next'),
294
- 'ph_text' => __('End Date','quiz-master-next')
295
- );
296
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
297
-
298
- // Registers randomness_order setting
299
- $field_array = array(
300
- 'id' => 'randomness_order',
301
- 'label' => __('Random Questions', 'quiz-master-next'),
302
- 'type' => 'select',
303
- 'options' => array(
304
- array(
305
- 'label' => __('Random Questions', 'quiz-master-next'),
306
- 'value' => 1
307
- ),
308
- array(
309
- 'label' => __('Random Questions And Answers', 'quiz-master-next'),
310
- 'value' => 2
311
- ),
312
- array(
313
- 'label' => __('Random Answers', 'quiz-master-next'),
314
- 'value' => 3
315
- ),
316
- array(
317
- 'label' => __('Disabled', 'quiz-master-next'),
318
- 'value' => 0
319
- )
320
- ),
321
- 'default' => 0,
322
- 'tooltip' => __('Randomize the order of questions or answers every time a quiz loads', 'quiz')
323
- );
324
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
325
-
326
- // Registers category setting
327
- $field_array = array(
328
- 'id' => 'randon_category',
329
- 'label' => __('Questions Categories', 'quiz-master-next'),
330
- 'type' => 'category',
331
- 'default' => '',
332
- 'help' => __('Questions will load only from selected categories', 'quiz-master-next')
333
- );
334
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
335
-
336
- // Registers contact_info_location setting
337
- $field_array = array(
338
- 'id' => 'contact_info_location',
339
- 'label' => __('Contact form position', 'quiz-master-next'),
340
- 'type' => 'radio',
341
- 'options' => array(
342
- array(
343
- 'label' => __('Show before quiz begins', 'quiz-master-next'),
344
- 'value' => 0
345
- ),
346
- array(
347
- 'label' => __('Show after the quiz ends', 'quiz-master-next'),
348
- 'value' => 1
349
- )
350
- ),
351
- 'default' => 0,
352
- 'help' => __('Select when to display the contact form','quiz-master-next'),
353
- 'tooltip' => __('The form can be configured in Contact tab','quiz-master-next')
354
- );
355
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
356
-
357
- // Registers loggedin_user_contact setting
358
- $field_array = array(
359
- 'id' => 'loggedin_user_contact',
360
- 'label' => __('Show contact form to logged in users', 'quiz-master-next'),
361
- 'type' => 'radio',
362
- 'options' => array(
363
- array(
364
- 'label' => __('Yes', 'quiz-master-next'),
365
- 'value' => 0
366
- ),
367
- array(
368
- 'label' => __('No', 'quiz-master-next'),
369
- 'value' => 1
370
- )
371
- ),
372
- 'default' => 0,
373
- 'help' => __('Logged in users can edit their contact information','quiz-master-next'),
374
- 'tooltip' => __('The information will still get saved if this option is disabled','quiz-master-next')
375
- );
376
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
377
-
378
- // Registers comment_section setting
379
- $field_array = array(
380
- 'id' => 'comment_section',
381
- 'label' => __('Enable comments', 'quiz-master-next'),
382
- 'type' => 'radio',
383
- 'options' => array(
384
- array(
385
- 'label' => __('Yes', 'quiz-master-next'),
386
- 'value' => 0
387
- ),
388
- array(
389
- 'label' => __('No', 'quiz-master-next'),
390
- 'value' => 1
391
- )
392
- ),
393
- 'default' => 1,
394
- 'help' => __('Allow users to enter their comments after the quiz','quiz-master-next'),
395
- );
396
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
397
-
398
- // Registers question_numbering setting
399
- $field_array = array(
400
- 'id' => 'question_numbering',
401
- 'label' => __('Show question numbers', 'quiz-master-next'),
402
- 'type' => 'radio',
403
- 'options' => array(
404
- array(
405
- 'label' => __('Yes', 'quiz-master-next'),
406
- 'value' => 1
407
- ),
408
- array(
409
- 'label' => __('No', 'quiz-master-next'),
410
- 'value' => 0
411
- )
412
- ),
413
- 'default' => 0
414
- );
415
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
416
-
417
- // Registers store_responses setting
418
- $field_array = array(
419
- 'id' => 'store_responses',
420
- 'label' => __( 'Save Responses', 'quiz-master-next' ),
421
- 'type' => 'radio',
422
- 'options' => array(
423
- array(
424
- 'label' => __( 'Yes', 'quiz-master-next' ),
425
- 'value' => 1
426
- ),
427
- array(
428
- 'label' => __( 'No', 'quiz-master-next' ),
429
- 'value' => 0
430
- )
431
- ),
432
- 'default' => 1,
433
- 'help' => __('The results will be permanently stored in a database', 'quiz-master-next')
434
- );
435
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
436
-
437
- // Registers disable_answer_onselect setting
438
- $field_array = array(
439
- 'id' => 'disable_answer_onselect',
440
- 'label' => __('Disable change of answers', 'quiz-master-next'),
441
- 'type' => 'radio',
442
- 'options' => array(
443
- array(
444
- 'label' => __('Yes', 'quiz-master-next'),
445
- 'value' => 1
446
- ),
447
- array(
448
- 'label' => __('No', 'quiz-master-next'),
449
- 'value' => 0
450
- )
451
- ),
452
- 'default' => 0,
453
- 'help' => __('Works with multiple choice questions only','quiz-master-next'),
454
- 'tooltip' => __('The question will be disabled once an answer is selected','quiz-master-next'),
455
- );
456
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
457
-
458
- // Registers ajax_show_correct setting
459
- $field_array = array(
460
- 'id' => 'ajax_show_correct',
461
- 'label' => __('Add class for correct/incorrect answers', 'quiz-master-next'),
462
- 'type' => 'radio',
463
- 'options' => array(
464
- array(
465
- 'label' => __('Yes', 'quiz-master-next'),
466
- 'value' => 1
467
- ),
468
- array(
469
- 'label' => __('No', 'quiz-master-next'),
470
- 'value' => 0
471
- )
472
- ),
473
- 'default' => 0,
474
- 'help' => __('Works with multiple choice questions only','quiz-master-next'),
475
- 'tooltip' => __('Dynamically add class for incorrect/correct answer after user selects answer.','quiz-master-next'),
476
- );
477
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
478
-
479
- // Registers hide_auto fill setting
480
- $field_array = array(
481
- 'id' => 'contact_disable_autofill',
482
- 'label' => __('Disable auto fill for contact input', 'quiz-master-next'),
483
- 'type' => 'radio',
484
- 'options' => array(
485
- array(
486
- 'label' => __('Yes', 'quiz-master-next'),
487
- 'value' => 1
488
- ),
489
- array(
490
- 'label' => __('No', 'quiz-master-next'),
491
- 'value' => 0
492
- ),
493
- ),
494
- 'default' => 0
495
- );
496
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
497
-
498
- $field_array = array(
499
- 'id' => 'form_disable_autofill',
500
- 'label' => __('Disable auto fill for Quiz input', 'quiz-master-next'),
501
- 'type' => 'radio',
502
- 'options' => array(
503
- array(
504
- 'label' => __('Yes', 'quiz-master-next'),
505
- 'value' => 1
506
- ),
507
- array(
508
- 'label' => __('No', 'quiz-master-next'),
509
- 'value' => 0
510
- ),
511
- ),
512
- 'default' => 0
513
- );
514
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
515
-
516
- // Registers show category on front setting
517
- $field_array = array(
518
- 'id' => 'show_category_on_front',
519
- 'label' => __('Display category name on front end', 'quiz-master-next'),
520
- 'type' => 'radio',
521
- 'options' => array(
522
- array(
523
- 'label' => __('Yes', 'quiz-master-next'),
524
- 'value' => 1
525
- ),
526
- array(
527
- 'label' => __('No', 'quiz-master-next'),
528
- 'value' => 0
529
- ),
530
- ),
531
- 'default' => 0
532
- );
533
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
534
-
535
- // Settings for quick result
536
- $field_array = array(
537
- 'id' => 'enable_quick_result_mc',
538
- 'label' => __('Show results inline', 'quiz-master-next'),
539
- 'type' => 'radio',
540
- 'options' => array(
541
- array(
542
- 'label' => __('Yes', 'quiz-master-next'),
543
- 'value' => 1
544
- ),
545
- array(
546
- 'label' => __('No', 'quiz-master-next'),
547
- 'value' => 0
548
- )
549
- ),
550
- 'default' => 0,
551
- 'help' => __('Instantly displays the result for each question','quiz-master-next')
552
- );
553
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
554
-
555
- $field_array = array(
556
- 'id' => 'end_quiz_if_wrong',
557
- 'label' => __( 'End quiz if there is wrong answer', 'quiz-master-next' ),
558
- 'type' => 'radio',
559
- 'options' => array(
560
- array(
561
- 'label' => __( 'Yes', 'quiz-master-next' ),
562
- 'value' => 1
563
- ),
564
- array(
565
- 'label' => __( 'No', 'quiz-master-next' ),
566
- 'value' => 0
567
- )
568
- ),
569
- 'default' => 0,
570
- 'help' => __('This option works with vertical Multiple Choice , horizontal Multiple Choice , drop down , multiple response and horizontal multiple response question types','quiz-master-next')
571
- );
572
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
573
-
574
- // Settings for quick result
575
- $field_array = array(
576
- 'id' => 'enable_quick_correct_answer_info',
577
- 'label' => __('Show correct answer inline', 'quiz-master-next'),
578
- 'type' => 'radio',
579
- 'options' => array(
580
- array(
581
- 'label' => __('Yes When answer is correct', 'quiz-master-next'),
582
- 'value' => 1
583
- ),
584
- array(
585
- 'label' => __('Yes Independent of correct/incorrect', 'quiz-master-next'),
586
- 'value' => 2
587
- ),
588
- array(
589
- 'label' => __('No', 'quiz-master-next'),
590
- 'value' => 0
591
- )
592
- ),
593
- 'default' => 0,
594
- 'help' => __('Show correct user info when inline result is enabled.','quiz-master-next')
595
- );
596
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
597
-
598
- //Setting for retake quiz
599
- $field_array = array(
600
- 'id' => 'enable_retake_quiz_button',
601
- 'label' => __('Retake Quiz', 'quiz-master-next'),
602
- 'type' => 'radio',
603
- 'options' => array(
604
- array(
605
- 'label' => __('Yes', 'quiz-master-next'),
606
- 'value' => 1
607
- ),
608
- array(
609
- 'label' => __('No', 'quiz-master-next'),
610
- 'value' => 0
611
- ),
612
- ),
613
- 'default' => 0,
614
- 'help' => __('Show a button on result page to retake the quiz', 'quiz-master-next')
615
- );
616
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
617
-
618
- //Setting for pagination of quiz
619
- $field_array = array(
620
- 'id' => 'enable_pagination_quiz',
621
- 'label' => __('Show current page number', 'quiz-master-next'),
622
- 'type' => 'radio',
623
- 'options' => array(
624
- array(
625
- 'label' => __('Yes', 'quiz-master-next'),
626
- 'value' => 1
627
- ),
628
- array(
629
- 'label' => __('No', 'quiz-master-next'),
630
- 'value' => 0
631
- ),
632
- ),
633
- 'default' => 0,
634
- );
635
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
636
-
637
- //Setting for pagination of quiz
638
- $field_array = array(
639
- 'id' => 'enable_deselect_option',
640
- 'label' => __('Deselect Answer', 'quiz-master-next'),
641
- 'type' => 'radio',
642
- 'options' => array(
643
- array(
644
- 'label' => __('Yes', 'quiz-master-next'),
645
- 'value' => 1
646
- ),
647
- array(
648
- 'label' => __('No', 'quiz-master-next'),
649
- 'value' => 0
650
- ),
651
- ),
652
- 'default' => 0,
653
- 'help' => __('Users are able deselect an answer and leave it blank. Works with Multiple Choice and Horizintal Multiple Choice questions only','quiz-master-next')
654
- );
655
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
656
-
657
- //Setting for pagination of quiz
658
- $field_array = array(
659
- 'id' => 'disable_description_on_result',
660
- 'label' => __('Disable description on quiz result page?', 'quiz-master-next'),
661
- 'type' => 'radio',
662
- 'options' => array(
663
- array(
664
- 'label' => __('Yes', 'quiz-master-next'),
665
- 'value' => 1
666
- ),
667
- array(
668
- 'label' => __('No', 'quiz-master-next'),
669
- 'value' => 0
670
- ),
671
- ),
672
- 'default' => 0,
673
- );
674
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
675
-
676
- //Setting for pagination of quiz
677
- $field_array = array(
678
- 'id' => 'disable_scroll_next_previous_click',
679
- 'label' => __('Disable scroll on next and previous button click?', 'quiz-master-next'),
680
- 'type' => 'radio',
681
- 'options' => array(
682
- array(
683
- 'label' => __('Yes', 'quiz-master-next'),
684
- 'value' => 1
685
- ),
686
- array(
687
- 'label' => __('No', 'quiz-master-next'),
688
- 'value' => 0
689
- ),
690
- ),
691
- 'default' => 0,
692
- );
693
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
694
-
695
- //Setting for animation
696
- $field_array = array(
697
- 'id' => 'quiz_animation',
698
- 'label' => __('Quiz Animation', 'quiz-master-next'),
699
- 'type' => 'select',
700
- 'options' => array(
701
- array(
702
- 'label' => __('bounce', 'quiz-master-next'),
703
- 'value' => 'bounce'
704
- ),
705
- array(
706
- 'label' => __('flash', 'quiz-master-next'),
707
- 'value' => 'flash'
708
- ),
709
- array(
710
- 'label' => __('pulse', 'quiz-master-next'),
711
- 'value' => 'pulse'
712
- ),
713
- array(
714
- 'label' => __('rubberBand', 'quiz-master-next'),
715
- 'value' => 'rubberBand'
716
- ),
717
- array(
718
- 'label' => __('shake', 'quiz-master-next'),
719
- 'value' => 'shake'
720
- ),
721
- array(
722
- 'label' => __('swing', 'quiz-master-next'),
723
- 'value' => 'swing'
724
- ),
725
- array(
726
- 'label' => __('tada', 'quiz-master-next'),
727
- 'value' => 'tada'
728
- ),
729
- array(
730
- 'label' => __('wobble', 'quiz-master-next'),
731
- 'value' => 'wobble'
732
- ),
733
- array(
734
- 'label' => __('jello', 'quiz-master-next'),
735
- 'value' => 'jello'
736
- ),
737
- array(
738
- 'label' => __('heartBeat', 'quiz-master-next'),
739
- 'value' => 'heartBeat'
740
- ),
741
- array(
742
- 'label' => __('No animation', 'quiz-master-next'),
743
- 'value' => ''
744
- )
745
- ),
746
- 'default' => ''
747
- );
748
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
749
-
750
- // result page for sharing
751
- $field_array = array(
752
- 'id' => 'result_page_fb_image',
753
- 'label' => __('Logo URL', 'quiz-master-next'),
754
- 'type' => 'text',
755
- 'default' => QSM_PLUGIN_URL . 'assets/icon-200x200.png',
756
- 'tooltip' => __('Enter the url of an image which will be used as logo while sharing on facebook.', 'quiz-master-next'),
757
- 'help' => __('If left blank, this will default to QSM logo', 'quiz-master-next')
758
- );
759
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
760
- do_action('qsm_extra_setting_fields');
761
- //Setting for animation
762
- $field_array = array(
763
- 'id' => 'legacy_options',
764
- 'label' => __('Show Legacy Options', 'quiz-master-next'),
765
- 'type' => 'hide_show',
766
- 'default' => '',
767
- 'help' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next' ),
768
- //'tooltip' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next')
769
- );
770
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
771
-
772
- // Registers social_media setting
773
- $field_array = array(
774
- 'id' => 'social_media',
775
- 'label' => __('Social Sharing Buttons', 'quiz-master-next'),
776
- 'type' => 'radio',
777
- 'options' => array(
778
- array(
779
- 'label' => __('Yes', 'quiz-master-next'),
780
- 'value' => 1
781
- ),
782
- array(
783
- 'label' => __('No', 'quiz-master-next'),
784
- 'value' => 0
785
- )
786
- ),
787
- 'default' => 0,
788
- 'tooltip' => __('Please use the new template variables instead.%FACEBOOK_SHARE% %TWITTER_SHARE%', 'quiz-master-next')
789
- );
790
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
791
-
792
- // Registers user_name setting
793
- $field_array = array(
794
- 'id' => 'user_name',
795
- 'label' => __("Ask user's name", 'quiz-master-next'),
796
- 'type' => 'radio',
797
- 'options' => array(
798
- array(
799
- 'label' => __('No', 'quiz-master-next'),
800
- 'value' => 2
801
- ),
802
- array(
803
- 'label' => __('Yes', 'quiz-master-next'),
804
- 'value' => 0
805
- ),
806
- array(
807
- 'label' => __('Require', 'quiz-master-next'),
808
- 'value' => 1
809
- ),
810
-
811
- ),
812
- 'default' => 2
813
- );
814
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
815
-
816
- // Registers user_comp setting
817
- $field_array = array(
818
- 'id' => 'user_comp',
819
- 'label' => __("Ask user's business", 'quiz-master-next'),
820
- 'type' => 'radio',
821
- 'options' => array(
822
- array(
823
- 'label' => __('No', 'quiz-master-next'),
824
- 'value' => 2
825
- ),
826
- array(
827
- 'label' => __('Yes', 'quiz-master-next'),
828
- 'value' => 0
829
- ),
830
- array(
831
- 'label' => __('Require', 'quiz-master-next'),
832
- 'value' => 1
833
- )
834
- ),
835
- 'default' => 2
836
- );
837
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
838
-
839
- // Registers user_email setting
840
- $field_array = array(
841
- 'id' => 'user_email',
842
- 'label' => __("Ask user's email", 'quiz-master-next'),
843
- 'type' => 'radio',
844
- 'options' => array(
845
- array(
846
- 'label' => __('No', 'quiz-master-next'),
847
- 'value' => 2
848
- ),
849
- array(
850
- 'label' => __('Yes', 'quiz-master-next'),
851
- 'value' => 0
852
- ),
853
- array(
854
- 'label' => __('Require', 'quiz-master-next'),
855
- 'value' => 1
856
- )
857
- ),
858
- 'default' => 2
859
- );
860
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
861
-
862
- // Registers user_phone setting
863
- $field_array = array(
864
- 'id' => 'user_phone',
865
- 'label' => __("Ask user's phone", 'quiz-master-next'),
866
- 'type' => 'radio',
867
- 'options' => array(
868
- array(
869
- 'label' => __('No', 'quiz-master-next'),
870
- 'value' => 2
871
- ),
872
- array(
873
- 'label' => __('Yes', 'quiz-master-next'),
874
- 'value' => 0
875
- ),
876
- array(
877
- 'label' => __('Require', 'quiz-master-next'),
878
- 'value' => 1
879
- )
880
- ),
881
- 'default' => 2
882
- );
883
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
884
-
885
- // Registers message_before setting
886
- $field_array = array(
887
- 'id' => 'message_before',
888
- 'label' => __("Message Displayed Before Quiz", 'quiz-master-next'),
889
- 'type' => 'editor',
890
- 'default' => 0,
891
- 'variables' => array(
892
- '%QUIZ_NAME%',
893
- '%QUIZ_LINK%',
894
- '%CURRENT_DATE%',
895
- )
896
- );
897
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
898
-
899
- // Registers message_comment setting
900
- $field_array = array(
901
- 'id' => 'message_comment',
902
- 'label' => __("Message Displayed Before Comments Box If Enabled", 'quiz-master-next'),
903
- 'type' => 'editor',
904
- 'default' => 0,
905
- 'variables' => array(
906
- '%QUIZ_NAME%',
907
- '%QUIZ_LINK%',
908
- '%CURRENT_DATE%',
909
- )
910
- );
911
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
912
-
913
- // Registers message_end_template setting
914
- $field_array = array(
915
- 'id' => 'message_end_template',
916
- 'label' => __("Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)", 'quiz-master-next'),
917
- 'type' => 'editor',
918
- 'default' => 0,
919
- 'variables' => array(
920
- '%QUIZ_NAME%',
921
- '%QUIZ_LINK%',
922
- '%CURRENT_DATE%',
923
- )
924
- );
925
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
926
-
927
- // Registers total_user_tries_text setting
928
- $field_array = array(
929
- 'id' => 'total_user_tries_text',
930
- 'label' => __("Message Displayed If User Has Tried Quiz Too Many Times", 'quiz-master-next'),
931
- 'type' => 'editor',
932
- 'default' => 0,
933
- 'variables' => array(
934
- '%QUIZ_NAME%',
935
- '%QUIZ_LINK%',
936
- '%CURRENT_DATE%'
937
- )
938
- );
939
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
940
-
941
- // Registers require_log_in_text setting
942
- $field_array = array(
943
- 'id' => 'require_log_in_text',
944
- 'label' => __("Message Displayed If User Is Not Logged In And Quiz Requires Users To Be Logged In", 'quiz-master-next'),
945
- 'type' => 'editor',
946
- 'default' => 0,
947
- 'variables' => array(
948
- '%QUIZ_NAME%',
949
- '%QUIZ_LINK%',
950
- '%CURRENT_DATE%',
951
- )
952
- );
953
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
954
-
955
- // Registers scheduled_timeframe_text setting
956
- $field_array = array(
957
- 'id' => 'scheduled_timeframe_text',
958
- 'label' => __("Message Displayed If Date Is Outside Scheduled Timeframe", 'quiz-master-next'),
959
- 'type' => 'editor',
960
- 'default' => 0,
961
- 'variables' => array(
962
- '%QUIZ_NAME%',
963
- '%QUIZ_LINK%',
964
- '%CURRENT_DATE%',
965
- )
966
- );
967
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
968
-
969
- // Registers limit_total_entries_text setting
970
- $field_array = array(
971
- 'id' => 'limit_total_entries_text',
972
- 'label' => __("Message Displayed If The Limit Of Total Entries Has Been Reached", 'quiz-master-next'),
973
- 'type' => 'editor',
974
- 'default' => 0,
975
- 'variables' => array(
976
- '%QUIZ_NAME%',
977
- '%QUIZ_LINK%',
978
- '%CURRENT_DATE%'
979
- )
980
- );
981
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
982
-
983
- // Registers question_answer_template setting
984
- $field_array = array(
985
- 'id' => 'question_answer_template',
986
- 'label' => __("Results Page %QUESTIONS_ANSWERS% Text", 'quiz-master-next'),
987
- 'type' => 'editor',
988
- 'default' => 0,
989
- 'variables' => array(
990
- '%QUESTION%',
991
- '%USER_ANSWERS_DEFAULT%',
992
- '%USER_ANSWER%',
993
- '%CORRECT_ANSWER%',
994
- '%USER_COMMENTS%',
995
- '%CORRECT_ANSWER_INFO%',
996
- '%QUESTION_POINT_SCORE%',
997
- '%QUESTION_MAX_POINTS%'
998
- )
999
- );
1000
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1001
-
1002
- // Registers question_answer_template setting
1003
- $field_array = array(
1004
- 'id' => 'question_answer_email_template',
1005
- 'label' => __("%QUESTIONS_ANSWERS_EMAIL% Text", 'quiz-master-next'),
1006
- 'type' => 'editor',
1007
- 'default' => '%QUESTION%<br />Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%',
1008
- 'variables' => array(
1009
- '%QUESTION%',
1010
- '%USER_ANSWER%',
1011
- '%CORRECT_ANSWER%',
1012
- '%USER_COMMENTS%',
1013
- '%CORRECT_ANSWER_INFO%',
1014
- '%QUESTION_POINT_SCORE%',
1015
- '%QUESTION_MAX_POINTS%'
1016
- )
1017
- );
1018
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1019
-
1020
- // Registers twitter_sharing_text setting
1021
- $field_array = array(
1022
- 'id' => 'twitter_sharing_text',
1023
- 'label' => __("Twitter Sharing Text", 'quiz-master-next'),
1024
- 'type' => 'editor',
1025
- 'default' => 0,
1026
- 'variables' => array(
1027
- '%POINT_SCORE%',
1028
- '%AVERAGE_POINT%',
1029
- '%AMOUNT_CORRECT%',
1030
- '%TOTAL_QUESTIONS%',
1031
- '%CORRECT_SCORE%',
1032
- '%QUIZ_NAME%',
1033
- '%QUIZ_LINK%',
1034
- '%RESULT_LINK%',
1035
- '%TIMER%',
1036
- '%CURRENT_DATE%'
1037
- )
1038
- );
1039
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1040
-
1041
- // Registers facebook_sharing_text setting
1042
- $field_array = array(
1043
- 'id' => 'facebook_sharing_text',
1044
- 'label' => __("Facebook Sharing Text", 'quiz-master-next'),
1045
- 'type' => 'editor',
1046
- 'default' => 0,
1047
- 'variables' => array(
1048
- '%POINT_SCORE%',
1049
- '%AVERAGE_POINT%',
1050
- '%AMOUNT_CORRECT%',
1051
- '%TOTAL_QUESTIONS%',
1052
- '%CORRECT_SCORE%',
1053
- '%QUIZ_NAME%',
1054
- '%QUIZ_LINK%',
1055
- '%RESULT_LINK%',
1056
- '%TIMER%',
1057
- '%CURRENT_DATE%'
1058
- )
1059
- );
1060
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1061
-
1062
- // Registers submit_button_text setting
1063
- $field_array = array(
1064
- 'id' => 'button_section',
1065
- 'label' => __('Buttons', 'quiz-master-next'),
1066
- 'type' => 'section_heading',
1067
- 'default' => 0
1068
- );
1069
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1070
-
1071
- $field_array = array(
1072
- 'id' => 'submit_button_text',
1073
- 'label' => __('Submit Button', 'quiz-master-next'),
1074
- 'type' => 'text',
1075
- 'default' => 0
1076
- );
1077
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1078
-
1079
- // Registers previous_button_text setting
1080
- $field_array = array(
1081
- 'id' => 'previous_button_text',
1082
- 'label' => __('Previous button', 'quiz-master-next'),
1083
- 'type' => 'text',
1084
- 'default' => 0
1085
- );
1086
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1087
-
1088
- // Registers next_button_text setting
1089
- $field_array = array(
1090
- 'id' => 'next_button_text',
1091
- 'label' => __('Next button', 'quiz-master-next'),
1092
- 'type' => 'text',
1093
- 'default' => 0
1094
- );
1095
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1096
-
1097
- // Registers submit_button_text setting
1098
- $field_array = array(
1099
- 'id' => 'validation_text_section',
1100
- 'label' => __('Validation Messages', 'quiz-master-next'),
1101
- 'type' => 'section_heading',
1102
- 'default' => 0
1103
- );
1104
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1105
-
1106
- // Registers empty_error_text setting
1107
- $field_array = array(
1108
- 'id' => 'empty_error_text',
1109
- 'label' => __('All required fields', 'quiz-master-next'),
1110
- 'type' => 'text',
1111
- 'default' => __('Please complete all required fields!', 'quiz-master-next')
1112
- );
1113
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1114
-
1115
- // Registers email_error_text setting
1116
- $field_array = array(
1117
- 'id' => 'email_error_text',
1118
- 'label' => __('Invalid email', 'quiz-master-next'),
1119
- 'type' => 'text',
1120
- 'default' => __('Not a valid e-mail address!', 'quiz-master-next')
1121
- );
1122
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1123
-
1124
- // Registers number_error_text setting
1125
- $field_array = array(
1126
- 'id' => 'number_error_text',
1127
- 'label' => __('Invalid number', 'quiz-master-next'),
1128
- 'type' => 'text',
1129
- 'default' => __('This field must be a number!', 'quiz-master-next')
1130
- );
1131
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1132
-
1133
- // Registers incorrect_error_text setting
1134
- $field_array = array(
1135
- 'id' => 'incorrect_error_text',
1136
- 'label' => __('Invalid Captcha', 'quiz-master-next'),
1137
- 'type' => 'text',
1138
- 'default' => __('The entered text is not correct!', 'quiz-master-next')
1139
- );
1140
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1141
-
1142
- // Registers submit_button_text setting
1143
- $field_array = array(
1144
- 'id' => 'other_text_section',
1145
- 'label' => __('Other', 'quiz-master-next'),
1146
- 'type' => 'section_heading',
1147
- 'default' => 0
1148
- );
1149
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1150
-
1151
- // Registers comment_field_text setting
1152
- $field_array = array(
1153
- 'id' => 'comment_field_text',
1154
- 'label' => __('Comments field', 'quiz-master-next'),
1155
- 'type' => 'text',
1156
- 'default' => 0
1157
- );
1158
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1159
-
1160
- // Registers hint_text setting
1161
- $field_array = array(
1162
- 'id' => 'hint_text',
1163
- 'label' => __('Hint Text', 'quiz-master-next'),
1164
- 'type' => 'text',
1165
- 'default' => __('Hint', 'quiz-master-next')
1166
- );
1167
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1168
-
1169
- // Registers quick result correct answer setting
1170
- $field_array = array(
1171
- 'id' => 'quick_result_correct_answer_text',
1172
- 'label' => __('Correct answer message', 'quiz-master-next'),
1173
- 'type' => 'text',
1174
- 'default' => __('Correct! You have selected correct answer.', 'quiz-master-next'),
1175
- 'tooltip' => __('Text to show when the selected option is correct answer.', 'quiz-master-next')
1176
- );
1177
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1178
-
1179
- // Registers quick result wrong answer setting
1180
- $field_array = array(
1181
- 'id' => 'quick_result_wrong_answer_text',
1182
- 'label' => __('Incorrect answer message', 'quiz-master-next'),
1183
- 'type' => 'text',
1184
- 'default' => __('Wrong! You have selected wrong answer.', 'quiz-master-next'),
1185
- 'tooltip' => __('Text to show when the selected option is wrong answer.', 'quiz-master-next')
1186
- );
1187
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1188
-
1189
- //Setting for animation
1190
- $field_array = array(
1191
- 'id' => 'legacy_options',
1192
- 'label' => __('Show Legacy Options', 'quiz-master-next'),
1193
- 'type' => 'hide_show',
1194
- 'default' => '',
1195
- 'help' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next' ),
1196
- //'tooltip' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next')
1197
- );
1198
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1199
-
1200
- // Registers name_field_text setting
1201
- $field_array = array(
1202
- 'id' => 'name_field_text',
1203
- 'label' => __('Name field', 'quiz-master-next'),
1204
- 'type' => 'text',
1205
- 'default' => 0
1206
- );
1207
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1208
-
1209
- // Registers business_field_text setting
1210
- $field_array = array(
1211
- 'id' => 'business_field_text',
1212
- 'label' => __('Business field', 'quiz-master-next'),
1213
- 'type' => 'text',
1214
- 'default' => 0
1215
- );
1216
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1217
-
1218
- // Registers email_field_text setting
1219
- $field_array = array(
1220
- 'id' => 'email_field_text',
1221
- 'label' => __('Email field', 'quiz-master-next'),
1222
- 'type' => 'text',
1223
- 'default' => 0
1224
- );
1225
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1226
-
1227
- // Registers phone_field_text setting
1228
- $field_array = array(
1229
- 'id' => 'phone_field_text',
1230
- 'label' => __('Phone number field', 'quiz-master-next'),
1231
- 'type' => 'text',
1232
- 'default' => 0
1233
- );
1234
- $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1235
-
1236
- }
1237
-
1238
- /**
1239
- * Installs the plugin and its database tables
1240
- *
1241
- * @since 4.7.1
1242
- */
1243
- public static function install() {
1244
-
1245
- global $wpdb;
1246
- $charset_collate = $wpdb->get_charset_collate();
1247
-
1248
- $quiz_table_name = $wpdb->prefix . "mlw_quizzes";
1249
- $question_table_name = $wpdb->prefix . "mlw_questions";
1250
- $results_table_name = $wpdb->prefix . "mlw_results";
1251
- $audit_table_name = $wpdb->prefix . "mlw_qm_audit_trail";
1252
- $themes_table_name = $wpdb->prefix . "mlw_themes";
1253
- $quiz_themes_settings_table_name = $wpdb->prefix . "mlw_quiz_theme_settings";
1254
-
1255
- if( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
1256
- $sql = "CREATE TABLE $quiz_table_name (
1257
  quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
1258
  quiz_name TEXT NOT NULL,
1259
  message_before TEXT NOT NULL,
@@ -1313,12 +1298,18 @@ class QSM_Install {
1313
  PRIMARY KEY (quiz_id)
1314
  ) $charset_collate;";
1315
 
1316
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1317
- dbDelta( $sql );
1318
- }
 
 
 
 
 
 
1319
 
1320
- if( $wpdb->get_var( "SHOW TABLES LIKE '$question_table_name'" ) != $question_table_name ) {
1321
- $sql = "CREATE TABLE $question_table_name (
1322
  question_id mediumint(9) NOT NULL AUTO_INCREMENT,
1323
  quiz_id INT NOT NULL,
1324
  question_name TEXT NOT NULL,
@@ -1349,12 +1340,12 @@ class QSM_Install {
1349
  PRIMARY KEY (question_id)
1350
  ) $charset_collate;";
1351
 
1352
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1353
- dbDelta( $sql );
1354
- }
1355
 
1356
- if( $wpdb->get_var( "SHOW TABLES LIKE '$results_table_name'" ) != $results_table_name ) {
1357
- $sql = "CREATE TABLE $results_table_name (
1358
  result_id mediumint(9) NOT NULL AUTO_INCREMENT,
1359
  quiz_id INT NOT NULL,
1360
  quiz_name TEXT NOT NULL,
@@ -1378,12 +1369,12 @@ class QSM_Install {
1378
  PRIMARY KEY (result_id)
1379
  ) $charset_collate;";
1380
 
1381
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1382
- dbDelta( $sql );
1383
- }
1384
 
1385
- if( $wpdb->get_var( "SHOW TABLES LIKE '$audit_table_name'" ) != $audit_table_name ) {
1386
- $sql = "CREATE TABLE $audit_table_name (
1387
  trail_id mediumint(9) NOT NULL AUTO_INCREMENT,
1388
  action_user TEXT NOT NULL,
1389
  action TEXT NOT NULL,
@@ -1391,26 +1382,44 @@ class QSM_Install {
1391
  PRIMARY KEY (trail_id)
1392
  ) $charset_collate;";
1393
 
1394
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1395
- dbDelta( $sql );
1396
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1397
 
1398
- if( $wpdb->get_var( "SHOW TABLES LIKE '$themes_table_name'" ) != $themes_table_name ) {
1399
- $sql = "CREATE TABLE $themes_table_name (
1400
  id mediumint(9) NOT NULL AUTO_INCREMENT,
1401
  theme TEXT NOT NULL,
1402
- theme_name TEXT NOT NULL,
1403
- default_settings TEXT NOT NULL,
1404
- theme_active BOOLEAN NOT NULL,
1405
  PRIMARY KEY (id)
1406
  ) $charset_collate;";
1407
 
1408
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1409
- dbDelta( $sql );
1410
- }
1411
-
1412
- if( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_themes_settings_table_name'" ) != $quiz_themes_settings_table_name ) {
1413
- $sql = "CREATE TABLE $quiz_themes_settings_table_name (
1414
  id mediumint(9) NOT NULL AUTO_INCREMENT,
1415
  theme_id mediumint(9) NOT NULL,
1416
  quiz_id mediumint(9) NOT NULL,
@@ -1419,180 +1428,181 @@ class QSM_Install {
1419
  PRIMARY KEY (id)
1420
  ) $charset_collate;";
1421
 
1422
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1423
- dbDelta( $sql );
1424
- }
1425
-
1426
- global $mlwQuizMasterNext;
1427
- $mlwQuizMasterNext->register_quiz_post_types();
1428
- // Will be removed
1429
- //Create a folder in upload folder
1430
- $upload = wp_upload_dir();
1431
- $upload_dir = $upload['basedir'];
1432
- $upload_dir = $upload_dir . '/qsm_themes';
1433
- if (! is_dir($upload_dir)) {
1434
- mkdir( $upload_dir, 0700 );
1435
- }
1436
- flush_rewrite_rules();
1437
- }
1438
-
1439
- /**
1440
- * Updates the plugin
1441
- *
1442
- * @since 4.7.1
1443
- */
1444
- public function update() {
1445
- global $mlwQuizMasterNext;
1446
- $data = $mlwQuizMasterNext->version ;
1447
- if ( ! get_option( 'qmn_original_version' ) ) {
1448
- add_option( 'qmn_original_version', $data );
1449
- }
1450
- if ( get_option( 'mlw_quiz_master_version' ) != $data ) {
1451
- global $wpdb;
1452
- $table_name = $wpdb->prefix . "mlw_quizzes";
1453
- //Update 0.5
1454
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'comment_section'") != "comment_section")
1455
- {
1456
- $sql = "ALTER TABLE ".$table_name." ADD comment_field_text TEXT NOT NULL AFTER phone_field_text";
1457
- $results = $wpdb->query( $sql );
1458
- $sql = "ALTER TABLE ".$table_name." ADD comment_section INT NOT NULL AFTER admin_email";
1459
- $results = $wpdb->query( $sql );
1460
- $sql = "ALTER TABLE ".$table_name." ADD message_comment TEXT NOT NULL AFTER message_after";
1461
- $results = $wpdb->query( $sql );
1462
- $update_sql = "UPDATE ".$table_name." SET comment_field_text='Comments', comment_section=1, message_comment='Enter You Text Here'";
1463
- $results = $wpdb->query( $update_sql );
1464
- }
1465
-
1466
- //Update 0.9.4
1467
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'randomness_order'") != "randomness_order")
1468
- {
1469
- $sql = "ALTER TABLE ".$table_name." ADD randomness_order INT NOT NULL AFTER system";
1470
- $results = $wpdb->query( $sql );
1471
- $update_sql = "UPDATE ".$table_name." SET randomness_order=0";
1472
- $results = $wpdb->query( $update_sql );
1473
- }
1474
-
1475
- //Update 0.9.5
1476
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_template'") != "question_answer_template")
1477
- {
1478
- $sql = "ALTER TABLE ".$table_name." ADD question_answer_template TEXT NOT NULL AFTER comment_field_text";
1479
- $results = $wpdb->query( $sql );
1480
- $mlw_question_answer_default = "%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />";
1481
- $update_sql = "UPDATE ".$table_name." SET question_answer_template='".$mlw_question_answer_default."'";
1482
- $results = $wpdb->query( $update_sql );
1483
- }
1484
-
1485
- //Update 0.9.6
1486
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'contact_info_location'") != "contact_info_location")
1487
- {
1488
- $sql = "ALTER TABLE ".$table_name." ADD contact_info_location INT NOT NULL AFTER send_admin_email";
1489
- $results = $wpdb->query( $sql );
1490
- $update_sql = "UPDATE ".$table_name." SET contact_info_location=0";
1491
- $results = $wpdb->query( $update_sql );
1492
- }
1493
-
1494
- //Update 1.0
1495
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'email_from_text'") != "email_from_text")
1496
- {
1497
- $sql = "ALTER TABLE ".$table_name." ADD email_from_text TEXT NOT NULL AFTER comment_field_text";
1498
- $results = $wpdb->query( $sql );
1499
- $update_sql = "UPDATE ".$table_name." SET email_from_text='Wordpress'";
1500
- $results = $wpdb->query( $update_sql );
1501
- }
1502
-
1503
- //Update 1.3.1
1504
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'loggedin_user_contact'") != "loggedin_user_contact")
1505
- {
1506
- $sql = "ALTER TABLE ".$table_name." ADD loggedin_user_contact INT NOT NULL AFTER randomness_order";
1507
- $results = $wpdb->query( $sql );
1508
- $update_sql = "UPDATE ".$table_name." SET loggedin_user_contact=0";
1509
- $results = $wpdb->query( $update_sql );
1510
- }
1511
-
1512
- //Update 1.5.1
1513
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_from_total'") != "question_from_total")
1514
- {
1515
- $sql = "ALTER TABLE ".$table_name." ADD question_from_total INT NOT NULL AFTER comment_section";
1516
- $results = $wpdb->query( $sql );
1517
- $update_sql = "UPDATE ".$table_name." SET question_from_total=0";
1518
- $results = $wpdb->query( $update_sql );
1519
- }
1520
-
1521
- //Update 1.6.1
1522
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'total_user_tries'") != "total_user_tries")
1523
- {
1524
- $sql = "ALTER TABLE ".$table_name." ADD total_user_tries INT NOT NULL AFTER question_from_total";
1525
- $results = $wpdb->query( $sql );
1526
- $update_sql = "UPDATE ".$table_name." SET total_user_tries=0";
1527
- $results = $wpdb->query( $update_sql );
1528
- }
1529
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'total_user_tries_text'") != "total_user_tries_text")
1530
- {
1531
- $sql = "ALTER TABLE ".$table_name." ADD total_user_tries_text TEXT NOT NULL AFTER total_user_tries";
1532
- $results = $wpdb->query( $sql );
1533
- $update_sql = "UPDATE ".$table_name." SET total_user_tries_text='Enter Your Text Here'";
1534
- $results = $wpdb->query( $update_sql );
1535
- }
1536
-
1537
- //Update 1.8.1
1538
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'message_end_template'") != "message_end_template")
1539
- {
1540
- $sql = "ALTER TABLE ".$table_name." ADD message_end_template TEXT NOT NULL AFTER message_comment";
1541
- $results = $wpdb->query( $sql );
1542
- $update_sql = "UPDATE ".$table_name." SET message_end_template=''";
1543
- $results = $wpdb->query( $update_sql );
1544
- }
1545
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'certificate_template'") != "certificate_template")
1546
- {
1547
- $sql = "ALTER TABLE ".$table_name." ADD certificate_template TEXT NOT NULL AFTER total_user_tries_text";
1548
- $results = $wpdb->query( $sql );
1549
- $update_sql = "UPDATE ".$table_name." SET certificate_template='Enter your text here!'";
1550
- $results = $wpdb->query( $update_sql );
1551
- }
1552
-
1553
- //Update 1.9.1
1554
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'social_media'") != "social_media")
1555
- {
1556
- $sql = "ALTER TABLE ".$table_name." ADD social_media INT NOT NULL AFTER certificate_template";
1557
- $results = $wpdb->query( $sql );
1558
- $update_sql = "UPDATE ".$table_name." SET social_media='0'";
1559
- $results = $wpdb->query( $update_sql );
1560
- }
1561
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'social_media_text'") != "social_media_text")
1562
- {
1563
- $sql = "ALTER TABLE ".$table_name." ADD social_media_text TEXT NOT NULL AFTER social_media";
1564
- $results = $wpdb->query( $sql );
1565
- $update_sql = "UPDATE ".$table_name." SET social_media_text='I just score a %CORRECT_SCORE%% on %QUIZ_NAME%!'";
1566
- $results = $wpdb->query( $update_sql );
1567
- }
1568
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'pagination'") != "pagination")
1569
- {
1570
- $sql = "ALTER TABLE ".$table_name." ADD pagination INT NOT NULL AFTER social_media_text";
1571
- $results = $wpdb->query( $sql );
1572
- $update_sql = "UPDATE ".$table_name." SET pagination=0";
1573
- $results = $wpdb->query( $update_sql );
1574
- }
1575
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'pagination_text'") != "pagination_text")
1576
- {
1577
- $sql = "ALTER TABLE ".$table_name." ADD pagination_text TEXT NOT NULL AFTER pagination";
1578
- $results = $wpdb->query( $sql );
1579
- $update_sql = "UPDATE ".$table_name." SET pagination_text='Next'";
1580
- $results = $wpdb->query( $update_sql );
1581
- }
1582
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'timer_limit'") != "timer_limit")
1583
- {
1584
- $sql = "ALTER TABLE ".$table_name." ADD timer_limit INT NOT NULL AFTER pagination_text";
1585
- $results = $wpdb->query( $sql );
1586
- $update_sql = "UPDATE ".$table_name." SET timer_limit=0";
1587
- $results = $wpdb->query( $update_sql );
1588
- }
1589
-
1590
- //Update 2.1.1
1591
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_stye'") != "quiz_stye")
1592
- {
1593
- $sql = "ALTER TABLE ".$table_name." ADD quiz_stye TEXT NOT NULL AFTER timer_limit";
1594
- $results = $wpdb->query( $sql );
1595
- $mlw_style_default = "
 
1596
  div.mlw_qmn_quiz input[type=radio],
1597
  div.mlw_qmn_quiz input[type=submit],
1598
  div.mlw_qmn_quiz label {
@@ -1633,226 +1643,201 @@ class QSM_Install {
1633
  display: inline-block;
1634
  padding: 5px 5px 5px 5px;
1635
  margin: auto;
1636
- }";
1637
- $update_sql = "UPDATE ".$table_name." SET quiz_stye='".$mlw_style_default."'";
1638
- $results = $wpdb->query( $update_sql );
1639
- }
1640
-
1641
- //Update 2.2.1
1642
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_numbering'") != "question_numbering")
1643
- {
1644
- $sql = "ALTER TABLE ".$table_name." ADD question_numbering INT NOT NULL AFTER quiz_stye";
1645
- $results = $wpdb->query( $sql );
1646
- $update_sql = "UPDATE ".$table_name." SET question_numbering='0'";
1647
- $results = $wpdb->query( $update_sql );
1648
- }
1649
-
1650
- //Update 2.8.1
1651
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'quiz_settings'") != "quiz_settings")
1652
- {
1653
- $sql = "ALTER TABLE ".$table_name." ADD quiz_settings TEXT NOT NULL AFTER question_numbering";
1654
- $results = $wpdb->query( $sql );
1655
- $update_sql = "UPDATE ".$table_name." SET quiz_settings=''";
1656
- $results = $wpdb->query( $update_sql );
1657
- }
1658
-
1659
- //Update 3.0.1
1660
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'theme_selected'") != "theme_selected")
1661
- {
1662
- $sql = "ALTER TABLE ".$table_name." ADD theme_selected TEXT NOT NULL AFTER quiz_settings";
1663
- $results = $wpdb->query( $sql );
1664
- $update_sql = "UPDATE ".$table_name." SET theme_selected='default'";
1665
- $results = $wpdb->query( $update_sql );
1666
- }
1667
-
1668
- //Update 3.3.1
1669
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'last_activity'") != "last_activity")
1670
- {
1671
- $sql = "ALTER TABLE ".$table_name." ADD last_activity DATETIME NOT NULL AFTER theme_selected";
1672
- $results = $wpdb->query( $sql );
1673
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET last_activity='%s'", date("Y-m-d H:i:s") );
1674
- $results = $wpdb->query( $update_sql );
1675
- }
1676
-
1677
- //Update 3.5.1
1678
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'require_log_in'") != "require_log_in")
1679
- {
1680
- $sql = "ALTER TABLE ".$table_name." ADD require_log_in INT NOT NULL AFTER last_activity";
1681
- $results = $wpdb->query( $sql );
1682
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET require_log_in='%d'", '0' );
1683
- $results = $wpdb->query( $update_sql );
1684
- }
1685
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'require_log_in_text'") != "require_log_in_text")
1686
- {
1687
- $sql = "ALTER TABLE ".$table_name." ADD require_log_in_text TEXT NOT NULL AFTER require_log_in";
1688
- $results = $wpdb->query( $sql );
1689
- $update_sql = $wpdb->prepare( "UPDATE ".$table_name." SET require_log_in_text='%s'", 'Enter Text Here' );
1690
- $results = $wpdb->query( $update_sql );
1691
- }
1692
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'limit_total_entries'") != "limit_total_entries")
1693
- {
1694
- $sql = "ALTER TABLE ".$table_name." ADD limit_total_entries INT NOT NULL AFTER require_log_in_text";
1695
- $results = $wpdb->query( $sql );
1696
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET limit_total_entries='%d'", '0' );
1697
- $results = $wpdb->query( $update_sql );
1698
- }
1699
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'limit_total_entries_text'") != "limit_total_entries_text")
1700
- {
1701
- $sql = "ALTER TABLE ".$table_name." ADD limit_total_entries_text TEXT NOT NULL AFTER limit_total_entries";
1702
- $results = $wpdb->query( $sql );
1703
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET limit_total_entries_text='%s'", 'Enter Text Here' );
1704
- $results = $wpdb->query( $update_sql );
1705
- }
1706
-
1707
- //Update 3.7.1
1708
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'scheduled_timeframe'") != "scheduled_timeframe")
1709
- {
1710
- $sql = "ALTER TABLE ".$table_name." ADD scheduled_timeframe TEXT NOT NULL AFTER limit_total_entries_text";
1711
- $results = $wpdb->query( $sql );
1712
- $update_sql = "UPDATE ".$table_name." SET scheduled_timeframe=''";
1713
- $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1714
- }
1715
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'scheduled_timeframe_text'") != "scheduled_timeframe_text")
1716
- {
1717
- $sql = "ALTER TABLE ".$table_name." ADD scheduled_timeframe_text TEXT NOT NULL AFTER scheduled_timeframe";
1718
- $results = $wpdb->query( $sql );
1719
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET scheduled_timeframe_text='%s'", 'Enter Text Here' );
1720
- $results = $wpdb->query( $update_sql );
1721
- }
1722
-
1723
- //Update 4.3.0
1724
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'disable_answer_onselect'") != "disable_answer_onselect")
1725
- {
1726
- $sql = "ALTER TABLE ".$table_name." ADD disable_answer_onselect INT NOT NULL AFTER scheduled_timeframe_text";
1727
- $results = $wpdb->query( $sql );
1728
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET disable_answer_onselect=%d", '0' );
1729
- $results = $wpdb->query( $update_sql );
1730
- }
1731
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'ajax_show_correct'") != "ajax_show_correct")
1732
- {
1733
- $sql = "ALTER TABLE ".$table_name." ADD ajax_show_correct INT NOT NULL AFTER disable_answer_onselect";
1734
- $results = $wpdb->query( $sql );
1735
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET ajax_show_correct=%d", '0' );
1736
- $results = $wpdb->query( $update_sql );
1737
- }
1738
-
1739
- global $wpdb;
1740
- $table_name = $wpdb->prefix . "mlw_questions";
1741
- //Update 0.5
1742
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'comments'") != "comments")
1743
- {
1744
- $sql = "ALTER TABLE ".$table_name." ADD comments INT NOT NULL AFTER correct_answer";
1745
- $results = $wpdb->query( $sql );
1746
- $sql = "ALTER TABLE ".$table_name." ADD hints TEXT NOT NULL AFTER comments";
1747
- $results = $wpdb->query( $sql );
1748
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET comments=%d, hints=''", '1' );
1749
- $results = $wpdb->query( $update_sql );
1750
- }
1751
- //Update 0.8
1752
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_order'") != "question_order")
1753
- {
1754
- $sql = "ALTER TABLE ".$table_name." ADD question_order INT NOT NULL AFTER hints";
1755
- $results = $wpdb->query( $sql );
1756
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET question_order=%d", '0' );
1757
- $results = $wpdb->query( $update_sql );
1758
- }
1759
-
1760
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type'") != "question_type")
1761
- {
1762
- $sql = "ALTER TABLE ".$table_name." ADD question_type INT NOT NULL AFTER question_order";
1763
- $results = $wpdb->query( $sql );
1764
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET question_type=%d", '0' );
1765
- $results = $wpdb->query( $update_sql );
1766
- }
1767
-
1768
- //Update 1.1.1
1769
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_answer_info'") != "question_answer_info")
1770
- {
1771
- $sql = "ALTER TABLE ".$table_name." ADD question_answer_info TEXT NOT NULL AFTER correct_answer";
1772
- $results = $wpdb->query( $sql );
1773
- $update_sql = "UPDATE ".$table_name." SET question_answer_info=''";
1774
- $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1775
- }
1776
-
1777
- //Update 2.5.1
1778
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'answer_array'") != "answer_array")
1779
- {
1780
- $sql = "ALTER TABLE ".$table_name." ADD answer_array TEXT NOT NULL AFTER question_name";
1781
- $results = $wpdb->query( $sql );
1782
- $update_sql = "UPDATE ".$table_name." SET answer_array=''";
1783
- $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1784
- }
1785
-
1786
- //Update 3.1.1
1787
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_settings'") != "question_settings")
1788
- {
1789
- $sql = "ALTER TABLE ".$table_name." ADD question_settings TEXT NOT NULL AFTER question_type";
1790
- $results = $wpdb->query( $sql );
1791
- $update_sql = "UPDATE ".$table_name." SET question_settings=''";
1792
- $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1793
- }
1794
-
1795
- //Update 4.0.0
1796
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'category'") != "category")
1797
- {
1798
- $sql = "ALTER TABLE ".$table_name." ADD category TEXT NOT NULL AFTER question_settings";
1799
- $results = $wpdb->query( $sql );
1800
- $update_sql = "UPDATE ".$table_name." SET category=''";
1801
- $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1802
- }
1803
-
1804
- //Update 4.0.0
1805
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'question_type_new'") != "question_type_new")
1806
- {
1807
- $sql = "ALTER TABLE ".$table_name." ADD question_type_new TEXT NOT NULL AFTER question_type";
1808
- $results = $wpdb->query( $sql );
1809
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET question_type_new=%s", 'question_type' );
1810
- $results = $wpdb->query( $update_sql );
1811
- }
1812
-
1813
- //Update 7.1.11
1814
- $user_email_template_data= $wpdb->get_row("SHOW COLUMNS FROM ".$wpdb->prefix."mlw_quizzes LIKE 'user_email_template'");
1815
- if($user_email_template_data->Type == "text")
1816
- {
1817
- $sql = "ALTER TABLE ".$wpdb->prefix."mlw_quizzes CHANGE user_email_template user_email_template LONGTEXT NOT NULL";
1818
- $results = $wpdb->query( $sql );
1819
- }
1820
-
1821
- //Update 2.6.1
1822
- $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_qm_audit_trail CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;" );
1823
- $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_questions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
1824
- $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_quizzes CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
1825
- $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_results CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" );
1826
-
1827
-
1828
-
1829
- global $wpdb;
1830
- $table_name = $wpdb->prefix . "mlw_results";
1831
- //Update 2.6.4
1832
- if($wpdb->get_var("SHOW COLUMNS FROM ".$table_name." LIKE 'user'") != "user")
1833
- {
1834
- $sql = "ALTER TABLE ".$table_name." ADD user INT NOT NULL AFTER phone";
1835
- $results = $wpdb->query( $sql );
1836
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET user=%d", '0' );
1837
- $results = $wpdb->query( $update_sql );
1838
- }
1839
-
1840
- // Update 4.7.0
1841
- if( $wpdb->get_var( "SHOW COLUMNS FROM $table_name LIKE 'user_ip'" ) != "user_ip" ) {
1842
- $sql = "ALTER TABLE $table_name ADD user_ip TEXT NOT NULL AFTER user";
1843
- $results = $wpdb->query( $sql );
1844
- $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET user_ip='%s'", 'Unknown' );
1845
- $results = $wpdb->query( $update_sql );
1846
- }
1847
- //Update 7.1.11
1848
- if($wpdb->get_var("select data_type from information_schema.columns where table_name = '".$wpdb->prefix . "mlw_results' and column_name = 'point_score'") != 'FLOAT' )
1849
- {
1850
- $results = $wpdb->query( "ALTER TABLE ".$wpdb->prefix . "mlw_results MODIFY point_score FLOAT NOT NULL;" );
1851
- }
1852
- // Update 5.0.0
1853
- $settings = (array) get_option( 'qmn-settings', array() );
1854
- if ( ! isset( $settings['results_details_template'] ) ) {
1855
- $settings['results_details_template'] = "<h2>Quiz Results for %QUIZ_NAME%</h2>
1856
  <p>%CONTACT_ALL%</p>
1857
  <p>Name Provided: %USER_NAME%</p>
1858
  <p>Business Provided: %USER_BUSINESS%</p>
@@ -1863,53 +1848,49 @@ class QSM_Install {
1863
  <p>The user took %TIMER% to complete quiz.</p>
1864
  <p>Comments entered were: %COMMENT_SECTION%</p>
1865
  <p>The answers were as follows:</p>
1866
- %QUESTIONS_ANSWERS%";
1867
- update_option( 'qmn-settings' , $settings );
1868
- }
1869
-
1870
- update_option('mlw_quiz_master_version' , $data);
1871
- }
1872
- if ( ! get_option('mlw_advert_shows') ) {
1873
- add_option( 'mlw_advert_shows' , 'true' );
1874
- }
1875
-
1876
-
1877
-
1878
- }
1879
-
1880
- /**
1881
- * Adds new links to the plugin action links
1882
- *
1883
- * @since 4.7.1
1884
- */
1885
- public function plugin_action_links( $links ) {
1886
- $action_links = array(
1887
- '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>',
1888
- );
1889
- return array_merge( $action_links, $links );
1890
- }
1891
-
1892
- /**
1893
- * Adds new links to the plugin row meta
1894
- *
1895
- * @since 4.7.1
1896
- */
1897
- public function plugin_row_meta( $links, $file ) {
1898
- if ( $file == QSM_PLUGIN_BASENAME ) {
1899
- $row_meta = array(
1900
- 'docs' => '<a href="' . esc_url( 'https://quizandsurveymaster.com/docs/' ) . '" title="' . esc_attr( __( 'View Documentation', 'quiz-master-next' ) ) . '">' . __( 'Documentation', 'quiz-master-next' ) . '</a>',
1901
- 'support' => '<a href="' . admin_url( 'admin.php?page=qsm_quiz_help' ) . '" title="' . esc_attr( __( 'Create Support Ticket', 'quiz-master-next' ) ) . '">' . __( 'Support', 'quiz-master-next' ) . '</a>',
1902
- );
1903
- return array_merge( $links, $row_meta );
1904
- }
1905
-
1906
- return (array) $links;
1907
-
1908
- }
1909
-
1910
-
1911
- }
1912
 
1913
- $qsm_install = new QSM_Install();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1914
 
1915
- ?>
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
 
7
  /**
8
  * Class that handles installation, updates, and plugin row meta
11
  */
12
  class QSM_Install {
13
 
14
+ /**
15
+ * Main Constructor
16
+ *
17
+ * @uses QSM_Install::add_hooks
18
+ * @since 4.7.1
19
+ */
20
+ function __construct() {
21
+ $this->add_hooks();
22
+ }
23
+
24
+ /**
25
+ * Adds the various class functions to hooks and filters
26
+ *
27
+ * @since 4.7.1
28
+ */
29
+ public function add_hooks() {
30
+ add_action( 'admin_init', array( $this, 'update' ) );
31
+ add_action( 'admin_init', array( $this, 'update' ) );
32
+ add_filter( 'plugin_action_links_' . QSM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
33
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
34
+ add_action( 'plugins_loaded', array( $this, 'register_default_settings' ) );
35
+ }
36
+
37
+ /**
38
+ * Adds the default quiz settings
39
+ *
40
+ * @since 5.0.0
41
+ */
42
+ public function register_default_settings() {
43
+
44
+ global $mlwQuizMasterNext;
45
+
46
+ // Registers system setting
47
+ $field_array = array(
48
+ 'id' => 'form_type',
49
+ 'label' => __( 'Quiz Type', 'quiz-master-next' ),
50
+ 'type' => 'select',
51
+ 'options' => array(
52
+ array(
53
+ 'label' => __( 'Quiz', 'quiz-master-next' ),
54
+ 'value' => 0,
55
+ ),
56
+ array(
57
+ 'label' => __( 'Survey', 'quiz-master-next' ),
58
+ 'value' => 1,
59
+ ),
60
+ array(
61
+ 'label' => __( 'Simple Form', 'quiz-master-next' ),
62
+ 'value' => 2,
63
+ ),
64
+ ),
65
+ 'default' => 0,
66
+ );
67
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
68
+
69
+ // Registers system setting
70
+ $field_array = array(
71
+ 'id' => 'system',
72
+ 'label' => __( 'Grading System', 'quiz-master-next' ),
73
+ 'type' => 'radio',
74
+ 'options' => array(
75
+ array(
76
+ 'label' => __( 'Correct/Incorrect', 'quiz-master-next' ),
77
+ 'value' => 0,
78
+ ),
79
+ array(
80
+ 'label' => __( 'Points', 'quiz-master-next' ),
81
+ 'value' => 1,
82
+ ),
83
+ array(
84
+ 'label' => __( 'Both', 'quiz-master-next' ),
85
+ 'value' => 3,
86
+ ),
87
+ ),
88
+ 'default' => 0,
89
+ 'help' => __( 'Select the system for grading the quiz.', 'quiz-master-next' ),
90
+ '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>',
91
+ 'show_option' => 'form_type_0',
92
+ );
93
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
94
+
95
+ // Registers Rounding setting
96
+ $field_array = array(
97
+ 'id' => 'score_roundoff',
98
+ 'label' => __( 'Allow Score Round-off', 'quiz-master-next' ),
99
+ 'type' => 'checkbox',
100
+ 'options' => array(
101
+ array(
102
+ 'value' => 1,
103
+ ),
104
+ ),
105
+ 'default' => 0,
106
+ 'show_option' => 'form_type_0',
107
+ );
108
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
109
+
110
+ // Registers progress_bar setting
111
+ $field_array = array(
112
+ 'id' => 'progress_bar',
113
+ 'label' => __( 'Show progress bar', 'quiz-master-next' ),
114
+ 'type' => 'radio',
115
+ 'options' => array(
116
+ array(
117
+ 'label' => __( 'Yes', 'quiz-master-next' ),
118
+ 'value' => 1,
119
+ ),
120
+ array(
121
+ 'label' => __( 'No', 'quiz-master-next' ),
122
+ 'value' => 0,
123
+ ),
124
+ ),
125
+ 'default' => 0,
126
+ );
127
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
128
+
129
+ // Registers require_log_in setting
130
+ $field_array = array(
131
+ 'id' => 'require_log_in',
132
+ 'label' => __( 'Require User Login', 'quiz-master-next' ),
133
+ 'type' => 'radio',
134
+ 'options' => array(
135
+ array(
136
+ 'label' => __( 'Yes', 'quiz-master-next' ),
137
+ 'value' => 1,
138
+ ),
139
+ array(
140
+ 'label' => __( 'No', 'quiz-master-next' ),
141
+ 'value' => 0,
142
+ ),
143
+ ),
144
+ 'default' => 0,
145
+ 'help' => __( 'Enabling this allows only logged in users to take the quiz', 'quiz-master-next' ),
146
+ );
147
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
148
+
149
+ // Registers pagination setting
150
+ $field_array = array(
151
+ 'id' => 'pagination',
152
+ 'label' => __( 'Questions Per Page', 'quiz-master-next' ),
153
+ 'type' => 'number',
154
+ 'options' => array(),
155
+ 'default' => 0,
156
+ 'help' => __( 'Override the default pagination created on questions tab', 'quiz-master-next' ),
157
+ );
158
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
159
+
160
+ // Registers timer_limit setting
161
+ $field_array = array(
162
+ 'id' => 'timer_limit',
163
+ 'label' => __( 'Time Limit (in minutes)', 'quiz-master-next' ),
164
+ 'type' => 'number',
165
+ 'options' => array(),
166
+ 'default' => 0,
167
+ 'help' => __( 'Leave 0 for no time limit', 'quiz-master-next' ),
168
+ );
169
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
170
+
171
+ // Settings for quick result
172
+ $field_array = array(
173
+ 'id' => 'enable_result_after_timer_end',
174
+ 'label' => __( 'Force submit after timer expiry', 'quiz-master-next' ),
175
+ 'type' => 'radio',
176
+ 'options' => array(
177
+ array(
178
+ 'label' => __( 'Yes', 'quiz-master-next' ),
179
+ 'value' => 1,
180
+ ),
181
+ array(
182
+ 'label' => __( 'No', 'quiz-master-next' ),
183
+ 'value' => 0,
184
+ ),
185
+ ),
186
+ 'default' => 0,
187
+ );
188
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
189
+
190
+ $field_array = array(
191
+ 'id' => 'skip_validation_time_expire',
192
+ 'label' => __( 'Skip validations when time expire', 'quiz-master-next' ),
193
+ 'type' => 'radio',
194
+ 'options' => array(
195
+ array(
196
+ 'label' => __( 'Yes', 'quiz-master-next' ),
197
+ 'value' => 1,
198
+ ),
199
+ array(
200
+ 'label' => __( 'No', 'quiz-master-next' ),
201
+ 'value' => 0,
202
+ ),
203
+ ),
204
+ 'default' => 1,
205
+ );
206
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
207
+
208
+ // Registers total_user_tries setting
209
+ $field_array = array(
210
+ 'id' => 'total_user_tries',
211
+ 'label' => __( 'Limit Attempts', 'quiz-master-next' ),
212
+ 'type' => 'number',
213
+ 'options' => array(),
214
+ 'default' => 0,
215
+ 'help' => __( 'Leave 0 for unlimited attempts', 'quiz-master-next' ),
216
+ 'tooltip' => __( 'Limits how many times a user can take the quiz', 'quiz-master-next' ),
217
+ );
218
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
219
+
220
+ // Registers limit_total_entries setting
221
+ $field_array = array(
222
+ 'id' => 'limit_total_entries',
223
+ 'label' => __( 'Limit Entries', 'quiz-master-next' ),
224
+ 'type' => 'number',
225
+ 'options' => array(),
226
+ 'default' => 0,
227
+ 'help' => __( 'Leave 0 for unlimited entries', 'quiz-master-next' ),
228
+ 'tooltip' => __( 'Limits how many users can take the quiz.', 'quiz-master-next' ),
229
+ );
230
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
231
+
232
+ // Registers question_from_total setting
233
+ $field_array = array(
234
+ 'id' => 'question_from_total',
235
+ 'label' => __( 'Limit number of Questions', 'quiz-master-next' ),
236
+ 'type' => 'number',
237
+ 'options' => array(),
238
+ 'default' => 0,
239
+ 'help' => __( 'Leave 0 to load all questions', 'quiz-master-next' ),
240
+ 'tooltip' => __( 'Show only limited number of questions from your quiz.', 'quiz-master-next' ),
241
+ );
242
+
243
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
244
+
245
+ // Registers question_per_category setting
246
+ $field_array = array(
247
+ 'id' => 'question_per_category',
248
+ 'label' => __( 'Limit number of Questions Per Category ', 'quiz-master-next' ),
249
+ 'type' => 'number',
250
+ 'options' => array(),
251
+ 'default' => 0,
252
+ 'help' => __( 'Leave 0 to load all questions. You also need to set Limit Number of questions, as well as select Question Categories', 'quiz-master-next' ),
253
+ 'tooltip' => __( 'Show only limited number of category questions from your quiz.You also need to set Limit Number of questions.', 'quiz-master-next' ),
254
+ );
255
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
256
+
257
+ // Registers scheduled_time_start setting
258
+ $field_array = array(
259
+ 'id' => 'scheduled_time_start',
260
+ 'label' => __( 'Quiz Dates', 'quiz-master-next' ),
261
+ 'type' => 'date',
262
+ 'options' => array(),
263
+ 'default' => '',
264
+ 'help' => '',
265
+ 'ph_text' => __( 'Start Date', 'quiz-master-next' ),
266
+ 'help' => __( 'If set, Quiz will be accessible only after this date', 'quiz-master-next' ),
267
+ 'tooltip' => __( 'Leave blank for no date limit', 'quiz-master-next' ),
268
+ );
269
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
270
+
271
+ // Registers scheduled_time_end setting
272
+ $field_array = array(
273
+ 'id' => 'scheduled_time_end',
274
+ 'label' => '',
275
+ 'type' => 'date',
276
+ 'options' => array(),
277
+ 'default' => '',
278
+ 'help' => __( ' If set, Quiz will not be accessible after this date', 'quiz-master-next' ),
279
+ 'ph_text' => __( 'End Date', 'quiz-master-next' ),
280
+ );
281
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
282
+
283
+ // Registers randomness_order setting
284
+ $field_array = array(
285
+ 'id' => 'randomness_order',
286
+ 'label' => __( 'Random Questions', 'quiz-master-next' ),
287
+ 'type' => 'select',
288
+ 'options' => array(
289
+ array(
290
+ 'label' => __( 'Random Questions', 'quiz-master-next' ),
291
+ 'value' => 1,
292
+ ),
293
+ array(
294
+ 'label' => __( 'Random Questions And Answers', 'quiz-master-next' ),
295
+ 'value' => 2,
296
+ ),
297
+ array(
298
+ 'label' => __( 'Random Answers', 'quiz-master-next' ),
299
+ 'value' => 3,
300
+ ),
301
+ array(
302
+ 'label' => __( 'Disabled', 'quiz-master-next' ),
303
+ 'value' => 0,
304
+ ),
305
+ ),
306
+ 'default' => 0,
307
+ 'tooltip' => __( 'Randomize the order of questions or answers every time a quiz loads', 'quiz' ),
308
+ );
309
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
310
+
311
+ // Registers category setting
312
+ $field_array = array(
313
+ 'id' => 'randon_category',
314
+ 'label' => __( 'Questions Categories', 'quiz-master-next' ),
315
+ 'type' => 'category',
316
+ 'default' => '',
317
+ 'help' => __( 'Questions will load only from selected categories. This option works only with Random Questions ', 'quiz-master-next' ),
318
+ );
319
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
320
+
321
+ // Registers contact_info_location setting
322
+ $field_array = array(
323
+ 'id' => 'contact_info_location',
324
+ 'label' => __( 'Contact form position', 'quiz-master-next' ),
325
+ 'type' => 'radio',
326
+ 'options' => array(
327
+ array(
328
+ 'label' => __( 'Show before quiz begins', 'quiz-master-next' ),
329
+ 'value' => 0,
330
+ ),
331
+ array(
332
+ 'label' => __( 'Show after the quiz ends', 'quiz-master-next' ),
333
+ 'value' => 1,
334
+ ),
335
+ ),
336
+ 'default' => 0,
337
+ 'help' => __( 'Select when to display the contact form', 'quiz-master-next' ),
338
+ 'tooltip' => __( 'The form can be configured in Contact tab', 'quiz-master-next' ),
339
+ );
340
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
341
+
342
+ // Registers loggedin_user_contact setting
343
+ $field_array = array(
344
+ 'id' => 'loggedin_user_contact',
345
+ 'label' => __( 'Show contact form to logged in users', 'quiz-master-next' ),
346
+ 'type' => 'radio',
347
+ 'options' => array(
348
+ array(
349
+ 'label' => __( 'Yes', 'quiz-master-next' ),
350
+ 'value' => 0,
351
+ ),
352
+ array(
353
+ 'label' => __( 'No', 'quiz-master-next' ),
354
+ 'value' => 1,
355
+ ),
356
+ ),
357
+ 'default' => 0,
358
+ 'help' => __( 'Logged in users can edit their contact information', 'quiz-master-next' ),
359
+ 'tooltip' => __( 'The information will still get saved if this option is disabled', 'quiz-master-next' ),
360
+ );
361
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
362
+
363
+ // Registers comment_section setting
364
+ $field_array = array(
365
+ 'id' => 'comment_section',
366
+ 'label' => __( 'Enable comments', 'quiz-master-next' ),
367
+ 'type' => 'radio',
368
+ 'options' => array(
369
+ array(
370
+ 'label' => __( 'Yes', 'quiz-master-next' ),
371
+ 'value' => 0,
372
+ ),
373
+ array(
374
+ 'label' => __( 'No', 'quiz-master-next' ),
375
+ 'value' => 1,
376
+ ),
377
+ ),
378
+ 'default' => 1,
379
+ 'help' => __( 'Allow users to enter their comments after the quiz', 'quiz-master-next' ),
380
+ );
381
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
382
+
383
+ // Registers question_numbering setting
384
+ $field_array = array(
385
+ 'id' => 'question_numbering',
386
+ 'label' => __( 'Show question numbers', 'quiz-master-next' ),
387
+ 'type' => 'radio',
388
+ 'options' => array(
389
+ array(
390
+ 'label' => __( 'Yes', 'quiz-master-next' ),
391
+ 'value' => 1,
392
+ ),
393
+ array(
394
+ 'label' => __( 'No', 'quiz-master-next' ),
395
+ 'value' => 0,
396
+ ),
397
+ ),
398
+ 'default' => 0,
399
+ );
400
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
401
+
402
+ // Registers store_responses setting
403
+ $field_array = array(
404
+ 'id' => 'store_responses',
405
+ 'label' => __( 'Save Responses', 'quiz-master-next' ),
406
+ 'type' => 'radio',
407
+ 'options' => array(
408
+ array(
409
+ 'label' => __( 'Yes', 'quiz-master-next' ),
410
+ 'value' => 1,
411
+ ),
412
+ array(
413
+ 'label' => __( 'No', 'quiz-master-next' ),
414
+ 'value' => 0,
415
+ ),
416
+ ),
417
+ 'default' => 1,
418
+ 'help' => __( 'The results will be permanently stored in a database', 'quiz-master-next' ),
419
+ );
420
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
421
+
422
+ // Registers disable_answer_onselect setting
423
+ $field_array = array(
424
+ 'id' => 'disable_answer_onselect',
425
+ 'label' => __( 'Disable change of answers', 'quiz-master-next' ),
426
+ 'type' => 'radio',
427
+ 'options' => array(
428
+ array(
429
+ 'label' => __( 'Yes', 'quiz-master-next' ),
430
+ 'value' => 1,
431
+ ),
432
+ array(
433
+ 'label' => __( 'No', 'quiz-master-next' ),
434
+ 'value' => 0,
435
+ ),
436
+ ),
437
+ 'default' => 0,
438
+ 'help' => __( 'Works with multiple choice questions only', 'quiz-master-next' ),
439
+ 'tooltip' => __( 'The question will be disabled once an answer is selected', 'quiz-master-next' ),
440
+ );
441
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
442
+
443
+ // Registers ajax_show_correct setting
444
+ $field_array = array(
445
+ 'id' => 'ajax_show_correct',
446
+ 'label' => __( 'Add class for correct/incorrect answers', 'quiz-master-next' ),
447
+ 'type' => 'radio',
448
+ 'options' => array(
449
+ array(
450
+ 'label' => __( 'Yes', 'quiz-master-next' ),
451
+ 'value' => 1,
452
+ ),
453
+ array(
454
+ 'label' => __( 'No', 'quiz-master-next' ),
455
+ 'value' => 0,
456
+ ),
457
+ ),
458
+ 'default' => 0,
459
+ 'help' => __( 'Works with multiple choice questions only', 'quiz-master-next' ),
460
+ 'tooltip' => __( 'Dynamically add class for incorrect/correct answer after user selects answer.', 'quiz-master-next' ),
461
+ );
462
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
463
+
464
+ // Registers hide_auto fill setting
465
+ $field_array = array(
466
+ 'id' => 'contact_disable_autofill',
467
+ 'label' => __( 'Disable auto fill for contact input', 'quiz-master-next' ),
468
+ 'type' => 'radio',
469
+ 'options' => array(
470
+ array(
471
+ 'label' => __( 'Yes', 'quiz-master-next' ),
472
+ 'value' => 1,
473
+ ),
474
+ array(
475
+ 'label' => __( 'No', 'quiz-master-next' ),
476
+ 'value' => 0,
477
+ ),
478
+ ),
479
+ 'default' => 0,
480
+ );
481
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
482
+
483
+ $field_array = array(
484
+ 'id' => 'form_disable_autofill',
485
+ 'label' => __( 'Disable auto fill for Quiz input', 'quiz-master-next' ),
486
+ 'type' => 'radio',
487
+ 'options' => array(
488
+ array(
489
+ 'label' => __( 'Yes', 'quiz-master-next' ),
490
+ 'value' => 1,
491
+ ),
492
+ array(
493
+ 'label' => __( 'No', 'quiz-master-next' ),
494
+ 'value' => 0,
495
+ ),
496
+ ),
497
+ 'default' => 0,
498
+ );
499
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
500
+
501
+ // Registers show category on front setting
502
+ $field_array = array(
503
+ 'id' => 'show_category_on_front',
504
+ 'label' => __( 'Display category name on front end', 'quiz-master-next' ),
505
+ 'type' => 'radio',
506
+ 'options' => array(
507
+ array(
508
+ 'label' => __( 'Yes', 'quiz-master-next' ),
509
+ 'value' => 1,
510
+ ),
511
+ array(
512
+ 'label' => __( 'No', 'quiz-master-next' ),
513
+ 'value' => 0,
514
+ ),
515
+ ),
516
+ 'default' => 0,
517
+ );
518
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
519
+
520
+ // Settings for quick result
521
+ $field_array = array(
522
+ 'id' => 'enable_quick_result_mc',
523
+ 'label' => __( 'Show results inline', 'quiz-master-next' ),
524
+ 'type' => 'radio',
525
+ 'options' => array(
526
+ array(
527
+ 'label' => __( 'Yes', 'quiz-master-next' ),
528
+ 'value' => 1,
529
+ ),
530
+ array(
531
+ 'label' => __( 'No', 'quiz-master-next' ),
532
+ 'value' => 0,
533
+ ),
534
+ ),
535
+ 'default' => 0,
536
+ 'help' => __( 'Instantly displays the result for each question', 'quiz-master-next' ),
537
+ );
538
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
539
+
540
+ $field_array = array(
541
+ 'id' => 'end_quiz_if_wrong',
542
+ 'label' => __( 'End quiz if there is wrong answer', 'quiz-master-next' ),
543
+ 'type' => 'radio',
544
+ 'options' => array(
545
+ array(
546
+ 'label' => __( 'Yes', 'quiz-master-next' ),
547
+ 'value' => 1,
548
+ ),
549
+ array(
550
+ 'label' => __( 'No', 'quiz-master-next' ),
551
+ 'value' => 0,
552
+ ),
553
+ ),
554
+ 'default' => 0,
555
+ 'help' => __( 'This option works with vertical Multiple Choice , horizontal Multiple Choice , drop down , multiple response and horizontal multiple response question types', 'quiz-master-next' ),
556
+ );
557
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
558
+
559
+ // Settings for quick result
560
+ $field_array = array(
561
+ 'id' => 'enable_quick_correct_answer_info',
562
+ 'label' => __( 'Show correct answer inline', 'quiz-master-next' ),
563
+ 'type' => 'radio',
564
+ 'options' => array(
565
+ array(
566
+ 'label' => __( 'Yes When answer is correct', 'quiz-master-next' ),
567
+ 'value' => 1,
568
+ ),
569
+ array(
570
+ 'label' => __( 'Yes Independent of correct/incorrect', 'quiz-master-next' ),
571
+ 'value' => 2,
572
+ ),
573
+ array(
574
+ 'label' => __( 'No', 'quiz-master-next' ),
575
+ 'value' => 0,
576
+ ),
577
+ ),
578
+ 'default' => 0,
579
+ 'help' => __( 'Show correct user info when inline result is enabled.', 'quiz-master-next' ),
580
+ );
581
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
582
+
583
+ // Setting for retake quiz
584
+ $field_array = array(
585
+ 'id' => 'enable_retake_quiz_button',
586
+ 'label' => __( 'Retake Quiz', 'quiz-master-next' ),
587
+ 'type' => 'radio',
588
+ 'options' => array(
589
+ array(
590
+ 'label' => __( 'Yes', 'quiz-master-next' ),
591
+ 'value' => 1,
592
+ ),
593
+ array(
594
+ 'label' => __( 'No', 'quiz-master-next' ),
595
+ 'value' => 0,
596
+ ),
597
+ ),
598
+ 'default' => 0,
599
+ 'help' => __( 'Show a button on result page to retake the quiz', 'quiz-master-next' ),
600
+ );
601
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
602
+
603
+ // Setting for pagination of quiz
604
+ $field_array = array(
605
+ 'id' => 'enable_pagination_quiz',
606
+ 'label' => __( 'Show current page number', 'quiz-master-next' ),
607
+ 'type' => 'radio',
608
+ 'options' => array(
609
+ array(
610
+ 'label' => __( 'Yes', 'quiz-master-next' ),
611
+ 'value' => 1,
612
+ ),
613
+ array(
614
+ 'label' => __( 'No', 'quiz-master-next' ),
615
+ 'value' => 0,
616
+ ),
617
+ ),
618
+ 'default' => 0,
619
+ );
620
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
621
+
622
+ // Setting for pagination of quiz
623
+ $field_array = array(
624
+ 'id' => 'enable_deselect_option',
625
+ 'label' => __( 'Deselect Answer', 'quiz-master-next' ),
626
+ 'type' => 'radio',
627
+ 'options' => array(
628
+ array(
629
+ 'label' => __( 'Yes', 'quiz-master-next' ),
630
+ 'value' => 1,
631
+ ),
632
+ array(
633
+ 'label' => __( 'No', 'quiz-master-next' ),
634
+ 'value' => 0,
635
+ ),
636
+ ),
637
+ 'default' => 0,
638
+ 'help' => __( 'Users are able deselect an answer and leave it blank. Works with Multiple Choice and Horizintal Multiple Choice questions only', 'quiz-master-next' ),
639
+ );
640
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
641
+
642
+ // Setting for pagination of quiz
643
+ $field_array = array(
644
+ 'id' => 'disable_description_on_result',
645
+ 'label' => __( 'Disable description on quiz result page?', 'quiz-master-next' ),
646
+ 'type' => 'radio',
647
+ 'options' => array(
648
+ array(
649
+ 'label' => __( 'Yes', 'quiz-master-next' ),
650
+ 'value' => 1,
651
+ ),
652
+ array(
653
+ 'label' => __( 'No', 'quiz-master-next' ),
654
+ 'value' => 0,
655
+ ),
656
+ ),
657
+ 'default' => 0,
658
+ );
659
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
660
+
661
+ // Setting for pagination of quiz
662
+ $field_array = array(
663
+ 'id' => 'disable_scroll_next_previous_click',
664
+ 'label' => __( 'Disable scroll on next and previous button click?', 'quiz-master-next' ),
665
+ 'type' => 'radio',
666
+ 'options' => array(
667
+ array(
668
+ 'label' => __( 'Yes', 'quiz-master-next' ),
669
+ 'value' => 1,
670
+ ),
671
+ array(
672
+ 'label' => __( 'No', 'quiz-master-next' ),
673
+ 'value' => 0,
674
+ ),
675
+ ),
676
+ 'default' => 0,
677
+ );
678
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
679
+
680
+ // Setting for animation
681
+ $field_array = array(
682
+ 'id' => 'quiz_animation',
683
+ 'label' => __( 'Quiz Animation', 'quiz-master-next' ),
684
+ 'type' => 'select',
685
+ 'options' => array(
686
+ array(
687
+ 'label' => __( 'bounce', 'quiz-master-next' ),
688
+ 'value' => 'bounce',
689
+ ),
690
+ array(
691
+ 'label' => __( 'flash', 'quiz-master-next' ),
692
+ 'value' => 'flash',
693
+ ),
694
+ array(
695
+ 'label' => __( 'pulse', 'quiz-master-next' ),
696
+ 'value' => 'pulse',
697
+ ),
698
+ array(
699
+ 'label' => __( 'rubberBand', 'quiz-master-next' ),
700
+ 'value' => 'rubberBand',
701
+ ),
702
+ array(
703
+ 'label' => __( 'shake', 'quiz-master-next' ),
704
+ 'value' => 'shake',
705
+ ),
706
+ array(
707
+ 'label' => __( 'swing', 'quiz-master-next' ),
708
+ 'value' => 'swing',
709
+ ),
710
+ array(
711
+ 'label' => __( 'tada', 'quiz-master-next' ),
712
+ 'value' => 'tada',
713
+ ),
714
+ array(
715
+ 'label' => __( 'wobble', 'quiz-master-next' ),
716
+ 'value' => 'wobble',
717
+ ),
718
+ array(
719
+ 'label' => __( 'jello', 'quiz-master-next' ),
720
+ 'value' => 'jello',
721
+ ),
722
+ array(
723
+ 'label' => __( 'heartBeat', 'quiz-master-next' ),
724
+ 'value' => 'heartBeat',
725
+ ),
726
+ array(
727
+ 'label' => __( 'No animation', 'quiz-master-next' ),
728
+ 'value' => '',
729
+ ),
730
+ ),
731
+ 'default' => '',
732
+ );
733
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
734
+
735
+ // result page for sharing
736
+ $field_array = array(
737
+ 'id' => 'result_page_fb_image',
738
+ 'label' => __( 'Logo URL', 'quiz-master-next' ),
739
+ 'type' => 'text',
740
+ 'default' => QSM_PLUGIN_URL . 'assets/icon-200x200.png',
741
+ 'tooltip' => __( 'Enter the url of an image which will be used as logo while sharing on facebook.', 'quiz-master-next' ),
742
+ 'help' => __( 'If left blank, this will default to QSM logo', 'quiz-master-next' ),
743
+ );
744
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
745
+ do_action( 'qsm_extra_setting_fields' );
746
+ // Setting for animation
747
+ $field_array = array(
748
+ 'id' => 'legacy_options',
749
+ 'label' => __( 'Show Legacy Options', 'quiz-master-next' ),
750
+ 'type' => 'hide_show',
751
+ 'default' => '',
752
+ 'help' => __( 'All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next' ),
753
+ // 'tooltip' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next')
754
+ );
755
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
756
+
757
+ // Registers social_media setting
758
+ $field_array = array(
759
+ 'id' => 'social_media',
760
+ 'label' => __( 'Social Sharing Buttons', 'quiz-master-next' ),
761
+ 'type' => 'radio',
762
+ 'options' => array(
763
+ array(
764
+ 'label' => __( 'Yes', 'quiz-master-next' ),
765
+ 'value' => 1,
766
+ ),
767
+ array(
768
+ 'label' => __( 'No', 'quiz-master-next' ),
769
+ 'value' => 0,
770
+ ),
771
+ ),
772
+ 'default' => 0,
773
+ 'tooltip' => __( 'Please use the new template variables instead.%FACEBOOK_SHARE% %TWITTER_SHARE%', 'quiz-master-next' ),
774
+ );
775
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
776
+
777
+ // Registers user_name setting
778
+ $field_array = array(
779
+ 'id' => 'user_name',
780
+ 'label' => __( "Ask user's name", 'quiz-master-next' ),
781
+ 'type' => 'radio',
782
+ 'options' => array(
783
+ array(
784
+ 'label' => __( 'No', 'quiz-master-next' ),
785
+ 'value' => 2,
786
+ ),
787
+ array(
788
+ 'label' => __( 'Yes', 'quiz-master-next' ),
789
+ 'value' => 0,
790
+ ),
791
+ array(
792
+ 'label' => __( 'Require', 'quiz-master-next' ),
793
+ 'value' => 1,
794
+ ),
795
+
796
+ ),
797
+ 'default' => 2,
798
+ );
799
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
800
+
801
+ // Registers user_comp setting
802
+ $field_array = array(
803
+ 'id' => 'user_comp',
804
+ 'label' => __( "Ask user's business", 'quiz-master-next' ),
805
+ 'type' => 'radio',
806
+ 'options' => array(
807
+ array(
808
+ 'label' => __( 'No', 'quiz-master-next' ),
809
+ 'value' => 2,
810
+ ),
811
+ array(
812
+ 'label' => __( 'Yes', 'quiz-master-next' ),
813
+ 'value' => 0,
814
+ ),
815
+ array(
816
+ 'label' => __( 'Require', 'quiz-master-next' ),
817
+ 'value' => 1,
818
+ ),
819
+ ),
820
+ 'default' => 2,
821
+ );
822
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
823
+
824
+ // Registers user_email setting
825
+ $field_array = array(
826
+ 'id' => 'user_email',
827
+ 'label' => __( "Ask user's email", 'quiz-master-next' ),
828
+ 'type' => 'radio',
829
+ 'options' => array(
830
+ array(
831
+ 'label' => __( 'No', 'quiz-master-next' ),
832
+ 'value' => 2,
833
+ ),
834
+ array(
835
+ 'label' => __( 'Yes', 'quiz-master-next' ),
836
+ 'value' => 0,
837
+ ),
838
+ array(
839
+ 'label' => __( 'Require', 'quiz-master-next' ),
840
+ 'value' => 1,
841
+ ),
842
+ ),
843
+ 'default' => 2,
844
+ );
845
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
846
+
847
+ // Registers user_phone setting
848
+ $field_array = array(
849
+ 'id' => 'user_phone',
850
+ 'label' => __( "Ask user's phone", 'quiz-master-next' ),
851
+ 'type' => 'radio',
852
+ 'options' => array(
853
+ array(
854
+ 'label' => __( 'No', 'quiz-master-next' ),
855
+ 'value' => 2,
856
+ ),
857
+ array(
858
+ 'label' => __( 'Yes', 'quiz-master-next' ),
859
+ 'value' => 0,
860
+ ),
861
+ array(
862
+ 'label' => __( 'Require', 'quiz-master-next' ),
863
+ 'value' => 1,
864
+ ),
865
+ ),
866
+ 'default' => 2,
867
+ );
868
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
869
+
870
+ // Registers message_before setting
871
+ $field_array = array(
872
+ 'id' => 'message_before',
873
+ 'label' => __( 'Message Displayed Before Quiz', 'quiz-master-next' ),
874
+ 'type' => 'editor',
875
+ 'default' => 0,
876
+ 'variables' => array(
877
+ '%QUIZ_NAME%',
878
+ '%QUIZ_LINK%',
879
+ '%CURRENT_DATE%',
880
+ ),
881
+ );
882
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
883
+
884
+ // Registers message_comment setting
885
+ $field_array = array(
886
+ 'id' => 'message_comment',
887
+ 'label' => __( 'Message Displayed Before Comments Box If Enabled', 'quiz-master-next' ),
888
+ 'type' => 'editor',
889
+ 'default' => 0,
890
+ 'variables' => array(
891
+ '%QUIZ_NAME%',
892
+ '%QUIZ_LINK%',
893
+ '%CURRENT_DATE%',
894
+ ),
895
+ );
896
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
897
+
898
+ // Registers message_end_template setting
899
+ $field_array = array(
900
+ 'id' => 'message_end_template',
901
+ 'label' => __( 'Message Displayed At End Of Quiz (Leave Blank To Omit Text Section)', 'quiz-master-next' ),
902
+ 'type' => 'editor',
903
+ 'default' => 0,
904
+ 'variables' => array(
905
+ '%QUIZ_NAME%',
906
+ '%QUIZ_LINK%',
907
+ '%CURRENT_DATE%',
908
+ ),
909
+ );
910
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
911
+
912
+ // Registers total_user_tries_text setting
913
+ $field_array = array(
914
+ 'id' => 'total_user_tries_text',
915
+ 'label' => __( 'Message Displayed If User Has Tried Quiz Too Many Times', 'quiz-master-next' ),
916
+ 'type' => 'editor',
917
+ 'default' => 0,
918
+ 'variables' => array(
919
+ '%QUIZ_NAME%',
920
+ '%QUIZ_LINK%',
921
+ '%CURRENT_DATE%',
922
+ ),
923
+ );
924
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
925
+
926
+ // Registers require_log_in_text setting
927
+ $field_array = array(
928
+ 'id' => 'require_log_in_text',
929
+ 'label' => __( 'Message Displayed If User Is Not Logged In And Quiz Requires Users To Be Logged In', 'quiz-master-next' ),
930
+ 'type' => 'editor',
931
+ 'default' => 0,
932
+ 'variables' => array(
933
+ '%QUIZ_NAME%',
934
+ '%QUIZ_LINK%',
935
+ '%CURRENT_DATE%',
936
+ ),
937
+ );
938
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
939
+
940
+ // Registers scheduled_timeframe_text setting
941
+ $field_array = array(
942
+ 'id' => 'scheduled_timeframe_text',
943
+ 'label' => __( 'Message Displayed If Date Is Outside Scheduled Timeframe', 'quiz-master-next' ),
944
+ 'type' => 'editor',
945
+ 'default' => 0,
946
+ 'variables' => array(
947
+ '%QUIZ_NAME%',
948
+ '%QUIZ_LINK%',
949
+ '%CURRENT_DATE%',
950
+ ),
951
+ );
952
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
953
+
954
+ // Registers limit_total_entries_text setting
955
+ $field_array = array(
956
+ 'id' => 'limit_total_entries_text',
957
+ 'label' => __( 'Message Displayed If The Limit Of Total Entries Has Been Reached', 'quiz-master-next' ),
958
+ 'type' => 'editor',
959
+ 'default' => 0,
960
+ 'variables' => array(
961
+ '%QUIZ_NAME%',
962
+ '%QUIZ_LINK%',
963
+ '%CURRENT_DATE%',
964
+ ),
965
+ );
966
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
967
+
968
+ // Registers question_answer_template setting
969
+ $field_array = array(
970
+ 'id' => 'question_answer_template',
971
+ 'label' => __( 'Results Page %QUESTIONS_ANSWERS% Text', 'quiz-master-next' ),
972
+ 'type' => 'editor',
973
+ 'default' => 0,
974
+ 'variables' => array(
975
+ '%QUESTION%',
976
+ '%USER_ANSWERS_DEFAULT%',
977
+ '%USER_ANSWER%',
978
+ '%CORRECT_ANSWER%',
979
+ '%USER_COMMENTS%',
980
+ '%CORRECT_ANSWER_INFO%',
981
+ '%QUESTION_POINT_SCORE%',
982
+ '%QUESTION_MAX_POINTS%',
983
+ ),
984
+ );
985
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
986
+
987
+ // Registers question_answer_template setting
988
+ $field_array = array(
989
+ 'id' => 'question_answer_email_template',
990
+ 'label' => __( '%QUESTIONS_ANSWERS_EMAIL% Text', 'quiz-master-next' ),
991
+ 'type' => 'editor',
992
+ 'default' => '%QUESTION%<br />Answer Provided: %USER_ANSWER%<br/>Correct Answer: %CORRECT_ANSWER%<br/>Comments Entered: %USER_COMMENTS%',
993
+ 'variables' => array(
994
+ '%QUESTION%',
995
+ '%USER_ANSWER%',
996
+ '%CORRECT_ANSWER%',
997
+ '%USER_COMMENTS%',
998
+ '%CORRECT_ANSWER_INFO%',
999
+ '%QUESTION_POINT_SCORE%',
1000
+ '%QUESTION_MAX_POINTS%',
1001
+ ),
1002
+ );
1003
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1004
+
1005
+ // Registers twitter_sharing_text setting
1006
+ $field_array = array(
1007
+ 'id' => 'twitter_sharing_text',
1008
+ 'label' => __( 'Twitter Sharing Text', 'quiz-master-next' ),
1009
+ 'type' => 'editor',
1010
+ 'default' => 0,
1011
+ 'variables' => array(
1012
+ '%POINT_SCORE%',
1013
+ '%AVERAGE_POINT%',
1014
+ '%AMOUNT_CORRECT%',
1015
+ '%TOTAL_QUESTIONS%',
1016
+ '%CORRECT_SCORE%',
1017
+ '%QUIZ_NAME%',
1018
+ '%QUIZ_LINK%',
1019
+ '%RESULT_LINK%',
1020
+ '%TIMER%',
1021
+ '%CURRENT_DATE%',
1022
+ ),
1023
+ );
1024
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1025
+
1026
+ // Registers facebook_sharing_text setting
1027
+ $field_array = array(
1028
+ 'id' => 'facebook_sharing_text',
1029
+ 'label' => __( 'Facebook Sharing Text', 'quiz-master-next' ),
1030
+ 'type' => 'editor',
1031
+ 'default' => 0,
1032
+ 'variables' => array(
1033
+ '%POINT_SCORE%',
1034
+ '%AVERAGE_POINT%',
1035
+ '%AMOUNT_CORRECT%',
1036
+ '%TOTAL_QUESTIONS%',
1037
+ '%CORRECT_SCORE%',
1038
+ '%QUIZ_NAME%',
1039
+ '%QUIZ_LINK%',
1040
+ '%RESULT_LINK%',
1041
+ '%TIMER%',
1042
+ '%CURRENT_DATE%',
1043
+ ),
1044
+ );
1045
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1046
+
1047
+ // Registers submit_button_text setting
1048
+ $field_array = array(
1049
+ 'id' => 'button_section',
1050
+ 'label' => __( 'Buttons', 'quiz-master-next' ),
1051
+ 'type' => 'section_heading',
1052
+ 'default' => 0,
1053
+ );
1054
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1055
+
1056
+ $field_array = array(
1057
+ 'id' => 'submit_button_text',
1058
+ 'label' => __( 'Submit Button', 'quiz-master-next' ),
1059
+ 'type' => 'text',
1060
+ 'default' => 0,
1061
+ );
1062
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1063
+
1064
+ // Registers previous_button_text setting
1065
+ $field_array = array(
1066
+ 'id' => 'previous_button_text',
1067
+ 'label' => __( 'Previous button', 'quiz-master-next' ),
1068
+ 'type' => 'text',
1069
+ 'default' => 0,
1070
+ );
1071
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1072
+
1073
+ // Registers next_button_text setting
1074
+ $field_array = array(
1075
+ 'id' => 'next_button_text',
1076
+ 'label' => __( 'Next button', 'quiz-master-next' ),
1077
+ 'type' => 'text',
1078
+ 'default' => 0,
1079
+ );
1080
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1081
+
1082
+ // Registers submit_button_text setting
1083
+ $field_array = array(
1084
+ 'id' => 'validation_text_section',
1085
+ 'label' => __( 'Validation Messages', 'quiz-master-next' ),
1086
+ 'type' => 'section_heading',
1087
+ 'default' => 0,
1088
+ );
1089
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1090
+
1091
+ // Registers empty_error_text setting
1092
+ $field_array = array(
1093
+ 'id' => 'empty_error_text',
1094
+ 'label' => __( 'All required fields', 'quiz-master-next' ),
1095
+ 'type' => 'text',
1096
+ 'default' => __( 'Please complete all required fields!', 'quiz-master-next' ),
1097
+ );
1098
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1099
+
1100
+ // Registers email_error_text setting
1101
+ $field_array = array(
1102
+ 'id' => 'email_error_text',
1103
+ 'label' => __( 'Invalid email', 'quiz-master-next' ),
1104
+ 'type' => 'text',
1105
+ 'default' => __( 'Not a valid e-mail address!', 'quiz-master-next' ),
1106
+ );
1107
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1108
+
1109
+ // Registers number_error_text setting
1110
+ $field_array = array(
1111
+ 'id' => 'number_error_text',
1112
+ 'label' => __( 'Invalid number', 'quiz-master-next' ),
1113
+ 'type' => 'text',
1114
+ 'default' => __( 'This field must be a number!', 'quiz-master-next' ),
1115
+ );
1116
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1117
+
1118
+ // Registers incorrect_error_text setting
1119
+ $field_array = array(
1120
+ 'id' => 'incorrect_error_text',
1121
+ 'label' => __( 'Invalid Captcha', 'quiz-master-next' ),
1122
+ 'type' => 'text',
1123
+ 'default' => __( 'The entered text is not correct!', 'quiz-master-next' ),
1124
+ );
1125
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1126
+
1127
+ // Registers submit_button_text setting
1128
+ $field_array = array(
1129
+ 'id' => 'other_text_section',
1130
+ 'label' => __( 'Other', 'quiz-master-next' ),
1131
+ 'type' => 'section_heading',
1132
+ 'default' => 0,
1133
+ );
1134
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1135
+
1136
+ // Registers comment_field_text setting
1137
+ $field_array = array(
1138
+ 'id' => 'comment_field_text',
1139
+ 'label' => __( 'Comments field', 'quiz-master-next' ),
1140
+ 'type' => 'text',
1141
+ 'default' => 0,
1142
+ );
1143
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1144
+
1145
+ // Registers hint_text setting
1146
+ $field_array = array(
1147
+ 'id' => 'hint_text',
1148
+ 'label' => __( 'Hint Text', 'quiz-master-next' ),
1149
+ 'type' => 'text',
1150
+ 'default' => __( 'Hint', 'quiz-master-next' ),
1151
+ );
1152
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1153
+
1154
+ // Registers quick result correct answer setting
1155
+ $field_array = array(
1156
+ 'id' => 'quick_result_correct_answer_text',
1157
+ 'label' => __( 'Correct answer message', 'quiz-master-next' ),
1158
+ 'type' => 'text',
1159
+ 'default' => __( 'Correct! You have selected correct answer.', 'quiz-master-next' ),
1160
+ 'tooltip' => __( 'Text to show when the selected option is correct answer.', 'quiz-master-next' ),
1161
+ );
1162
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1163
+
1164
+ // Registers quick result wrong answer setting
1165
+ $field_array = array(
1166
+ 'id' => 'quick_result_wrong_answer_text',
1167
+ 'label' => __( 'Incorrect answer message', 'quiz-master-next' ),
1168
+ 'type' => 'text',
1169
+ 'default' => __( 'Wrong! You have selected wrong answer.', 'quiz-master-next' ),
1170
+ 'tooltip' => __( 'Text to show when the selected option is wrong answer.', 'quiz-master-next' ),
1171
+ );
1172
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1173
+
1174
+ // Setting for animation
1175
+ $field_array = array(
1176
+ 'id' => 'legacy_options',
1177
+ 'label' => __( 'Show Legacy Options', 'quiz-master-next' ),
1178
+ 'type' => 'hide_show',
1179
+ 'default' => '',
1180
+ 'help' => __( 'All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next' ),
1181
+ // 'tooltip' => __('All the legacy options are deprecated and will be removed in upcoming version', 'quiz-master-next')
1182
+ );
1183
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1184
+
1185
+ // Registers name_field_text setting
1186
+ $field_array = array(
1187
+ 'id' => 'name_field_text',
1188
+ 'label' => __( 'Name field', 'quiz-master-next' ),
1189
+ 'type' => 'text',
1190
+ 'default' => 0,
1191
+ );
1192
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1193
+
1194
+ // Registers business_field_text setting
1195
+ $field_array = array(
1196
+ 'id' => 'business_field_text',
1197
+ 'label' => __( 'Business field', 'quiz-master-next' ),
1198
+ 'type' => 'text',
1199
+ 'default' => 0,
1200
+ );
1201
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1202
+
1203
+ // Registers email_field_text setting
1204
+ $field_array = array(
1205
+ 'id' => 'email_field_text',
1206
+ 'label' => __( 'Email field', 'quiz-master-next' ),
1207
+ 'type' => 'text',
1208
+ 'default' => 0,
1209
+ );
1210
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1211
+
1212
+ // Registers phone_field_text setting
1213
+ $field_array = array(
1214
+ 'id' => 'phone_field_text',
1215
+ 'label' => __( 'Phone number field', 'quiz-master-next' ),
1216
+ 'type' => 'text',
1217
+ 'default' => 0,
1218
+ );
1219
+ $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );
1220
+
1221
+ }
1222
+
1223
+ /**
1224
+ * Installs the plugin and its database tables
1225
+ *
1226
+ * @since 4.7.1
1227
+ */
1228
+ public static function install() {
1229
+
1230
+ global $wpdb;
1231
+ $charset_collate = $wpdb->get_charset_collate();
1232
+
1233
+ $quiz_table_name = $wpdb->prefix . 'mlw_quizzes';
1234
+ $question_table_name = $wpdb->prefix . 'mlw_questions';
1235
+ $results_table_name = $wpdb->prefix . 'mlw_results';
1236
+ $audit_table_name = $wpdb->prefix . 'mlw_qm_audit_trail';
1237
+ $themes_table_name = $wpdb->prefix . 'mlw_themes';
1238
+ $quiz_themes_settings_table_name = $wpdb->prefix . 'mlw_quiz_theme_settings';
1239
+
1240
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_table_name'" ) != $quiz_table_name ) {
1241
+ $sql = "CREATE TABLE $quiz_table_name (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1242
  quiz_id mediumint(9) NOT NULL AUTO_INCREMENT,
1243
  quiz_name TEXT NOT NULL,
1244
  message_before TEXT NOT NULL,
1298
  PRIMARY KEY (quiz_id)
1299
  ) $charset_collate;";
1300
 
1301
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1302
+ dbDelta( $sql );
1303
+
1304
+ // enabling multiple category for fresh installation
1305
+ $multiple_category = get_option( 'qsm_multiple_category_enabled' );
1306
+ if ( ! $multiple_category ) {
1307
+ add_option( 'qsm_multiple_category_enabled', date( time() ) );
1308
+ }
1309
+ }
1310
 
1311
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$question_table_name'" ) != $question_table_name ) {
1312
+ $sql = "CREATE TABLE $question_table_name (
1313
  question_id mediumint(9) NOT NULL AUTO_INCREMENT,
1314
  quiz_id INT NOT NULL,
1315
  question_name TEXT NOT NULL,
1340
  PRIMARY KEY (question_id)
1341
  ) $charset_collate;";
1342
 
1343
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1344
+ dbDelta( $sql );
1345
+ }
1346
 
1347
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$results_table_name'" ) != $results_table_name ) {
1348
+ $sql = "CREATE TABLE $results_table_name (
1349
  result_id mediumint(9) NOT NULL AUTO_INCREMENT,
1350
  quiz_id INT NOT NULL,
1351
  quiz_name TEXT NOT NULL,
1369
  PRIMARY KEY (result_id)
1370
  ) $charset_collate;";
1371
 
1372
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1373
+ dbDelta( $sql );
1374
+ }
1375
 
1376
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$audit_table_name'" ) != $audit_table_name ) {
1377
+ $sql = "CREATE TABLE $audit_table_name (
1378
  trail_id mediumint(9) NOT NULL AUTO_INCREMENT,
1379
  action_user TEXT NOT NULL,
1380
  action TEXT NOT NULL,
1382
  PRIMARY KEY (trail_id)
1383
  ) $charset_collate;";
1384
 
1385
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1386
+ dbDelta( $sql );
1387
+ }
1388
+
1389
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}mlw_question_terms'" ) != "{$wpdb->prefix}mlw_question_terms" ) {
1390
+ $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}mlw_question_terms` (
1391
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
1392
+ `question_id` int(11) DEFAULT '0',
1393
+ `quiz_id` int(11) DEFAULT '0',
1394
+ `term_id` int(11) DEFAULT '0',
1395
+ `taxonomy` varchar(50) DEFAULT NULL,
1396
+ PRIMARY KEY (`id`),
1397
+ KEY `question_id` (`question_id`),
1398
+ KEY `quiz_id` (`quiz_id`),
1399
+ KEY `term_id` (`term_id`),
1400
+ KEY `taxonomy` (`taxonomy`)
1401
+ ) $charset_collate;";
1402
+
1403
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1404
+ dbDelta( $sql );
1405
+ }
1406
 
1407
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$themes_table_name'" ) != $themes_table_name ) {
1408
+ $sql = "CREATE TABLE $themes_table_name (
1409
  id mediumint(9) NOT NULL AUTO_INCREMENT,
1410
  theme TEXT NOT NULL,
1411
+ theme_name TEXT NOT NULL,
1412
+ default_settings TEXT NOT NULL,
1413
+ theme_active BOOLEAN NOT NULL,
1414
  PRIMARY KEY (id)
1415
  ) $charset_collate;";
1416
 
1417
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1418
+ dbDelta( $sql );
1419
+ }
1420
+
1421
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$quiz_themes_settings_table_name'" ) != $quiz_themes_settings_table_name ) {
1422
+ $sql = "CREATE TABLE $quiz_themes_settings_table_name (
1423
  id mediumint(9) NOT NULL AUTO_INCREMENT,
1424
  theme_id mediumint(9) NOT NULL,
1425
  quiz_id mediumint(9) NOT NULL,
1428
  PRIMARY KEY (id)
1429
  ) $charset_collate;";
1430
 
1431
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1432
+ dbDelta( $sql );
1433
+ }
1434
+
1435
+ global $mlwQuizMasterNext;
1436
+ $mlwQuizMasterNext->register_quiz_post_types();
1437
+ // Will be removed
1438
+ // Create a folder in upload folder
1439
+ $upload = wp_upload_dir();
1440
+ $upload_dir = $upload['basedir'];
1441
+ $upload_dir = $upload_dir . '/qsm_themes';
1442
+ if ( ! is_dir( $upload_dir ) ) {
1443
+ mkdir( $upload_dir, 0700 );
1444
+ }
1445
+ flush_rewrite_rules();
1446
+ }
1447
+
1448
+ /**
1449
+ * Updates the plugin
1450
+ *
1451
+ * @since 4.7.1
1452
+ */
1453
+ public function update() {
1454
+ global $wpdb, $mlwQuizMasterNext;
1455
+ $data = $mlwQuizMasterNext->version;
1456
+ if ( ! get_option( 'qmn_original_version' ) ) {
1457
+ add_option( 'qmn_original_version', $data );
1458
+ }
1459
+ if ( get_option( 'mlw_quiz_master_version' ) != $data ) {
1460
+ $charset_collate = $wpdb->get_charset_collate();
1461
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}mlw_question_terms'" ) != "{$wpdb->prefix}mlw_question_terms" ) {
1462
+ $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}mlw_question_terms` (
1463
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
1464
+ `question_id` int(11) DEFAULT '0',
1465
+ `quiz_id` int(11) DEFAULT '0',
1466
+ `term_id` int(11) DEFAULT '0',
1467
+ `taxonomy` varchar(50) DEFAULT NULL,
1468
+ PRIMARY KEY (`id`),
1469
+ KEY `question_id` (`question_id`),
1470
+ KEY `quiz_id` (`quiz_id`),
1471
+ KEY `term_id` (`term_id`),
1472
+ KEY `taxonomy` (`taxonomy`)
1473
+ ) $charset_collate;";
1474
+
1475
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1476
+ dbDelta( $sql );
1477
+ }
1478
+
1479
+ $table_name = $wpdb->prefix . 'mlw_quizzes';
1480
+ // Update 0.5
1481
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'comment_section'" ) != 'comment_section' ) {
1482
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD comment_field_text TEXT NOT NULL AFTER phone_field_text';
1483
+ $results = $wpdb->query( $sql );
1484
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD comment_section INT NOT NULL AFTER admin_email';
1485
+ $results = $wpdb->query( $sql );
1486
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD message_comment TEXT NOT NULL AFTER message_after';
1487
+ $results = $wpdb->query( $sql );
1488
+ $update_sql = 'UPDATE ' . $table_name . " SET comment_field_text='Comments', comment_section=1, message_comment='Enter You Text Here'";
1489
+ $results = $wpdb->query( $update_sql );
1490
+ }
1491
+
1492
+ // Update 0.9.4
1493
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'randomness_order'" ) != 'randomness_order' ) {
1494
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD randomness_order INT NOT NULL AFTER system';
1495
+ $results = $wpdb->query( $sql );
1496
+ $update_sql = 'UPDATE ' . $table_name . ' SET randomness_order=0';
1497
+ $results = $wpdb->query( $update_sql );
1498
+ }
1499
+
1500
+ // Update 0.9.5
1501
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_answer_template'" ) != 'question_answer_template' ) {
1502
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_answer_template TEXT NOT NULL AFTER comment_field_text';
1503
+ $results = $wpdb->query( $sql );
1504
+ $mlw_question_answer_default = '%QUESTION%<br /> Answer Provided: %USER_ANSWER%<br /> Correct Answer: %CORRECT_ANSWER%<br /> Comments Entered: %USER_COMMENTS%<br />';
1505
+ $update_sql = 'UPDATE ' . $table_name . " SET question_answer_template='" . $mlw_question_answer_default . "'";
1506
+ $results = $wpdb->query( $update_sql );
1507
+ }
1508
+
1509
+ // Update 0.9.6
1510
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'contact_info_location'" ) != 'contact_info_location' ) {
1511
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD contact_info_location INT NOT NULL AFTER send_admin_email';
1512
+ $results = $wpdb->query( $sql );
1513
+ $update_sql = 'UPDATE ' . $table_name . ' SET contact_info_location=0';
1514
+ $results = $wpdb->query( $update_sql );
1515
+ }
1516
+
1517
+ // Update 1.0
1518
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'email_from_text'" ) != 'email_from_text' ) {
1519
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD email_from_text TEXT NOT NULL AFTER comment_field_text';
1520
+ $results = $wpdb->query( $sql );
1521
+ $update_sql = 'UPDATE ' . $table_name . " SET email_from_text='Wordpress'";
1522
+ $results = $wpdb->query( $update_sql );
1523
+ }
1524
+
1525
+ // Update 1.3.1
1526
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'loggedin_user_contact'" ) != 'loggedin_user_contact' ) {
1527
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD loggedin_user_contact INT NOT NULL AFTER randomness_order';
1528
+ $results = $wpdb->query( $sql );
1529
+ $update_sql = 'UPDATE ' . $table_name . ' SET loggedin_user_contact=0';
1530
+ $results = $wpdb->query( $update_sql );
1531
+ }
1532
+
1533
+ // Update 1.5.1
1534
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_from_total'" ) != 'question_from_total' ) {
1535
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_from_total INT NOT NULL AFTER comment_section';
1536
+ $results = $wpdb->query( $sql );
1537
+ $update_sql = 'UPDATE ' . $table_name . ' SET question_from_total=0';
1538
+ $results = $wpdb->query( $update_sql );
1539
+ }
1540
+
1541
+ // Update 1.6.1
1542
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'total_user_tries'" ) != 'total_user_tries' ) {
1543
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD total_user_tries INT NOT NULL AFTER question_from_total';
1544
+ $results = $wpdb->query( $sql );
1545
+ $update_sql = 'UPDATE ' . $table_name . ' SET total_user_tries=0';
1546
+ $results = $wpdb->query( $update_sql );
1547
+ }
1548
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'total_user_tries_text'" ) != 'total_user_tries_text' ) {
1549
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD total_user_tries_text TEXT NOT NULL AFTER total_user_tries';
1550
+ $results = $wpdb->query( $sql );
1551
+ $update_sql = 'UPDATE ' . $table_name . " SET total_user_tries_text='Enter Your Text Here'";
1552
+ $results = $wpdb->query( $update_sql );
1553
+ }
1554
+
1555
+ // Update 1.8.1
1556
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'message_end_template'" ) != 'message_end_template' ) {
1557
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD message_end_template TEXT NOT NULL AFTER message_comment';
1558
+ $results = $wpdb->query( $sql );
1559
+ $update_sql = 'UPDATE ' . $table_name . " SET message_end_template=''";
1560
+ $results = $wpdb->query( $update_sql );
1561
+ }
1562
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'certificate_template'" ) != 'certificate_template' ) {
1563
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD certificate_template TEXT NOT NULL AFTER total_user_tries_text';
1564
+ $results = $wpdb->query( $sql );
1565
+ $update_sql = 'UPDATE ' . $table_name . " SET certificate_template='Enter your text here!'";
1566
+ $results = $wpdb->query( $update_sql );
1567
+ }
1568
+
1569
+ // Update 1.9.1
1570
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'social_media'" ) != 'social_media' ) {
1571
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD social_media INT NOT NULL AFTER certificate_template';
1572
+ $results = $wpdb->query( $sql );
1573
+ $update_sql = 'UPDATE ' . $table_name . " SET social_media='0'";
1574
+ $results = $wpdb->query( $update_sql );
1575
+ }
1576
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'social_media_text'" ) != 'social_media_text' ) {
1577
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD social_media_text TEXT NOT NULL AFTER social_media';
1578
+ $results = $wpdb->query( $sql );
1579
+ $update_sql = 'UPDATE ' . $table_name . " SET social_media_text='I just score a %CORRECT_SCORE%% on %QUIZ_NAME%!'";
1580
+ $results = $wpdb->query( $update_sql );
1581
+ }
1582
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'pagination'" ) != 'pagination' ) {
1583
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD pagination INT NOT NULL AFTER social_media_text';
1584
+ $results = $wpdb->query( $sql );
1585
+ $update_sql = 'UPDATE ' . $table_name . ' SET pagination=0';
1586
+ $results = $wpdb->query( $update_sql );
1587
+ }
1588
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'pagination_text'" ) != 'pagination_text' ) {
1589
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD pagination_text TEXT NOT NULL AFTER pagination';
1590
+ $results = $wpdb->query( $sql );
1591
+ $update_sql = 'UPDATE ' . $table_name . " SET pagination_text='Next'";
1592
+ $results = $wpdb->query( $update_sql );
1593
+ }
1594
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'timer_limit'" ) != 'timer_limit' ) {
1595
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD timer_limit INT NOT NULL AFTER pagination_text';
1596
+ $results = $wpdb->query( $sql );
1597
+ $update_sql = 'UPDATE ' . $table_name . ' SET timer_limit=0';
1598
+ $results = $wpdb->query( $update_sql );
1599
+ }
1600
+
1601
+ // Update 2.1.1
1602
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'quiz_stye'" ) != 'quiz_stye' ) {
1603
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD quiz_stye TEXT NOT NULL AFTER timer_limit';
1604
+ $results = $wpdb->query( $sql );
1605
+ $mlw_style_default = '
1606
  div.mlw_qmn_quiz input[type=radio],
1607
  div.mlw_qmn_quiz input[type=submit],
1608
  div.mlw_qmn_quiz label {
1643
  display: inline-block;
1644
  padding: 5px 5px 5px 5px;
1645
  margin: auto;
1646
+ }';
1647
+ $update_sql = 'UPDATE ' . $table_name . " SET quiz_stye='" . $mlw_style_default . "'";
1648
+ $results = $wpdb->query( $update_sql );
1649
+ }
1650
+
1651
+ // Update 2.2.1
1652
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_numbering'" ) != 'question_numbering' ) {
1653
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_numbering INT NOT NULL AFTER quiz_stye';
1654
+ $results = $wpdb->query( $sql );
1655
+ $update_sql = 'UPDATE ' . $table_name . " SET question_numbering='0'";
1656
+ $results = $wpdb->query( $update_sql );
1657
+ }
1658
+
1659
+ // Update 2.8.1
1660
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'quiz_settings'" ) != 'quiz_settings' ) {
1661
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD quiz_settings TEXT NOT NULL AFTER question_numbering';
1662
+ $results = $wpdb->query( $sql );
1663
+ $update_sql = 'UPDATE ' . $table_name . " SET quiz_settings=''";
1664
+ $results = $wpdb->query( $update_sql );
1665
+ }
1666
+
1667
+ // Update 3.0.1
1668
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'theme_selected'" ) != 'theme_selected' ) {
1669
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD theme_selected TEXT NOT NULL AFTER quiz_settings';
1670
+ $results = $wpdb->query( $sql );
1671
+ $update_sql = 'UPDATE ' . $table_name . " SET theme_selected='default'";
1672
+ $results = $wpdb->query( $update_sql );
1673
+ }
1674
+
1675
+ // Update 3.3.1
1676
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'last_activity'" ) != 'last_activity' ) {
1677
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD last_activity DATETIME NOT NULL AFTER theme_selected';
1678
+ $results = $wpdb->query( $sql );
1679
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET last_activity='%s'", date( 'Y-m-d H:i:s' ) );
1680
+ $results = $wpdb->query( $update_sql );
1681
+ }
1682
+
1683
+ // Update 3.5.1
1684
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'require_log_in'" ) != 'require_log_in' ) {
1685
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD require_log_in INT NOT NULL AFTER last_activity';
1686
+ $results = $wpdb->query( $sql );
1687
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET require_log_in='%d'", '0' );
1688
+ $results = $wpdb->query( $update_sql );
1689
+ }
1690
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'require_log_in_text'" ) != 'require_log_in_text' ) {
1691
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD require_log_in_text TEXT NOT NULL AFTER require_log_in';
1692
+ $results = $wpdb->query( $sql );
1693
+ $update_sql = $wpdb->prepare( 'UPDATE ' . $table_name . " SET require_log_in_text='%s'", 'Enter Text Here' );
1694
+ $results = $wpdb->query( $update_sql );
1695
+ }
1696
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'limit_total_entries'" ) != 'limit_total_entries' ) {
1697
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD limit_total_entries INT NOT NULL AFTER require_log_in_text';
1698
+ $results = $wpdb->query( $sql );
1699
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET limit_total_entries='%d'", '0' );
1700
+ $results = $wpdb->query( $update_sql );
1701
+ }
1702
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'limit_total_entries_text'" ) != 'limit_total_entries_text' ) {
1703
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD limit_total_entries_text TEXT NOT NULL AFTER limit_total_entries';
1704
+ $results = $wpdb->query( $sql );
1705
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET limit_total_entries_text='%s'", 'Enter Text Here' );
1706
+ $results = $wpdb->query( $update_sql );
1707
+ }
1708
+
1709
+ // Update 3.7.1
1710
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'scheduled_timeframe'" ) != 'scheduled_timeframe' ) {
1711
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD scheduled_timeframe TEXT NOT NULL AFTER limit_total_entries_text';
1712
+ $results = $wpdb->query( $sql );
1713
+ $update_sql = 'UPDATE ' . $table_name . " SET scheduled_timeframe=''";
1714
+ $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1715
+ }
1716
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'scheduled_timeframe_text'" ) != 'scheduled_timeframe_text' ) {
1717
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD scheduled_timeframe_text TEXT NOT NULL AFTER scheduled_timeframe';
1718
+ $results = $wpdb->query( $sql );
1719
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET scheduled_timeframe_text='%s'", 'Enter Text Here' );
1720
+ $results = $wpdb->query( $update_sql );
1721
+ }
1722
+
1723
+ // Update 4.3.0
1724
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'disable_answer_onselect'" ) != 'disable_answer_onselect' ) {
1725
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD disable_answer_onselect INT NOT NULL AFTER scheduled_timeframe_text';
1726
+ $results = $wpdb->query( $sql );
1727
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET disable_answer_onselect=%d", '0' );
1728
+ $results = $wpdb->query( $update_sql );
1729
+ }
1730
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'ajax_show_correct'" ) != 'ajax_show_correct' ) {
1731
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD ajax_show_correct INT NOT NULL AFTER disable_answer_onselect';
1732
+ $results = $wpdb->query( $sql );
1733
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET ajax_show_correct=%d", '0' );
1734
+ $results = $wpdb->query( $update_sql );
1735
+ }
1736
+
1737
+ global $wpdb;
1738
+ $table_name = $wpdb->prefix . 'mlw_questions';
1739
+ // Update 0.5
1740
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'comments'" ) != 'comments' ) {
1741
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD comments INT NOT NULL AFTER correct_answer';
1742
+ $results = $wpdb->query( $sql );
1743
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD hints TEXT NOT NULL AFTER comments';
1744
+ $results = $wpdb->query( $sql );
1745
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET comments=%d, hints=''", '1' );
1746
+ $results = $wpdb->query( $update_sql );
1747
+ }
1748
+ // Update 0.8
1749
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_order'" ) != 'question_order' ) {
1750
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_order INT NOT NULL AFTER hints';
1751
+ $results = $wpdb->query( $sql );
1752
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET question_order=%d", '0' );
1753
+ $results = $wpdb->query( $update_sql );
1754
+ }
1755
+
1756
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_type'" ) != 'question_type' ) {
1757
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_type INT NOT NULL AFTER question_order';
1758
+ $results = $wpdb->query( $sql );
1759
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET question_type=%d", '0' );
1760
+ $results = $wpdb->query( $update_sql );
1761
+ }
1762
+
1763
+ // Update 1.1.1
1764
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_answer_info'" ) != 'question_answer_info' ) {
1765
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_answer_info TEXT NOT NULL AFTER correct_answer';
1766
+ $results = $wpdb->query( $sql );
1767
+ $update_sql = 'UPDATE ' . $table_name . " SET question_answer_info=''";
1768
+ $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1769
+ }
1770
+
1771
+ // Update 2.5.1
1772
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'answer_array'" ) != 'answer_array' ) {
1773
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD answer_array TEXT NOT NULL AFTER question_name';
1774
+ $results = $wpdb->query( $sql );
1775
+ $update_sql = 'UPDATE ' . $table_name . " SET answer_array=''";
1776
+ $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1777
+ }
1778
+
1779
+ // Update 3.1.1
1780
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_settings'" ) != 'question_settings' ) {
1781
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_settings TEXT NOT NULL AFTER question_type';
1782
+ $results = $wpdb->query( $sql );
1783
+ $update_sql = 'UPDATE ' . $table_name . " SET question_settings=''";
1784
+ $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1785
+ }
1786
+
1787
+ // Update 4.0.0
1788
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'category'" ) != 'category' ) {
1789
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD category TEXT NOT NULL AFTER question_settings';
1790
+ $results = $wpdb->query( $sql );
1791
+ $update_sql = 'UPDATE ' . $table_name . " SET category=''";
1792
+ $results = $wpdb->query( stripslashes( esc_sql( $update_sql ) ) );
1793
+ }
1794
+
1795
+ // Update 4.0.0
1796
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'question_type_new'" ) != 'question_type_new' ) {
1797
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD question_type_new TEXT NOT NULL AFTER question_type';
1798
+ $results = $wpdb->query( $sql );
1799
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET question_type_new=%s", 'question_type' );
1800
+ $results = $wpdb->query( $update_sql );
1801
+ }
1802
+
1803
+ // Update 7.1.11
1804
+ $user_email_template_data = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $wpdb->prefix . "mlw_quizzes LIKE 'user_email_template'" );
1805
+ if ( $user_email_template_data->Type == 'text' ) {
1806
+ $sql = 'ALTER TABLE ' . $wpdb->prefix . 'mlw_quizzes CHANGE user_email_template user_email_template LONGTEXT NOT NULL';
1807
+ $results = $wpdb->query( $sql );
1808
+ }
1809
+
1810
+ // Update 2.6.1
1811
+ $results = $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . 'mlw_qm_audit_trail CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' );
1812
+ $results = $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . 'mlw_questions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci' );
1813
+ $results = $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . 'mlw_quizzes CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci' );
1814
+ $results = $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . 'mlw_results CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci' );
1815
+
1816
+ global $wpdb;
1817
+ $table_name = $wpdb->prefix . 'mlw_results';
1818
+ // Update 2.6.4
1819
+ if ( $wpdb->get_var( 'SHOW COLUMNS FROM ' . $table_name . " LIKE 'user'" ) != 'user' ) {
1820
+ $sql = 'ALTER TABLE ' . $table_name . ' ADD user INT NOT NULL AFTER phone';
1821
+ $results = $wpdb->query( $sql );
1822
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET user=%d", '0' );
1823
+ $results = $wpdb->query( $update_sql );
1824
+ }
1825
+
1826
+ // Update 4.7.0
1827
+ if ( $wpdb->get_var( "SHOW COLUMNS FROM $table_name LIKE 'user_ip'" ) != 'user_ip' ) {
1828
+ $sql = "ALTER TABLE $table_name ADD user_ip TEXT NOT NULL AFTER user";
1829
+ $results = $wpdb->query( $sql );
1830
+ $update_sql = $wpdb->prepare( "UPDATE {$table_name} SET user_ip='%s'", 'Unknown' );
1831
+ $results = $wpdb->query( $update_sql );
1832
+ }
1833
+ // Update 7.1.11
1834
+ if ( $wpdb->get_var( "select data_type from information_schema.columns where table_name = '" . $wpdb->prefix . "mlw_results' and column_name = 'point_score'" ) != 'FLOAT' ) {
1835
+ $results = $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . 'mlw_results MODIFY point_score FLOAT NOT NULL;' );
1836
+ }
1837
+ // Update 5.0.0
1838
+ $settings = (array) get_option( 'qmn-settings', array() );
1839
+ if ( ! isset( $settings['results_details_template'] ) ) {
1840
+ $settings['results_details_template'] = '<h2>Quiz Results for %QUIZ_NAME%</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1841
  <p>%CONTACT_ALL%</p>
1842
  <p>Name Provided: %USER_NAME%</p>
1843
  <p>Business Provided: %USER_BUSINESS%</p>
1848
  <p>The user took %TIMER% to complete quiz.</p>
1849
  <p>Comments entered were: %COMMENT_SECTION%</p>
1850
  <p>The answers were as follows:</p>
1851
+ %QUESTIONS_ANSWERS%';
1852
+ update_option( 'qmn-settings', $settings );
1853
+ }
1854
+
1855
+ update_option( 'mlw_quiz_master_version', $data );
1856
+ }
1857
+ if ( ! get_option( 'mlw_advert_shows' ) ) {
1858
+ add_option( 'mlw_advert_shows', 'true' );
1859
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1860
 
1861
+ }
1862
+
1863
+ /**
1864
+ * Adds new links to the plugin action links
1865
+ *
1866
+ * @since 4.7.1
1867
+ */
1868
+ public function plugin_action_links( $links ) {
1869
+ $action_links = array(
1870
+ '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>',
1871
+ );
1872
+ return array_merge( $action_links, $links );
1873
+ }
1874
+
1875
+ /**
1876
+ * Adds new links to the plugin row meta
1877
+ *
1878
+ * @since 4.7.1
1879
+ */
1880
+ public function plugin_row_meta( $links, $file ) {
1881
+ if ( $file == QSM_PLUGIN_BASENAME ) {
1882
+ $row_meta = array(
1883
+ 'docs' => '<a href="' . esc_url( 'https://quizandsurveymaster.com/docs/' ) . '" title="' . esc_attr( __( 'View Documentation', 'quiz-master-next' ) ) . '">' . __( 'Documentation', 'quiz-master-next' ) . '</a>',
1884
+ 'support' => '<a href="' . admin_url( 'admin.php?page=qsm_quiz_help' ) . '" title="' . esc_attr( __( 'Create Support Ticket', 'quiz-master-next' ) ) . '">' . __( 'Support', 'quiz-master-next' ) . '</a>',
1885
+ );
1886
+ return array_merge( $links, $row_meta );
1887
+ }
1888
+
1889
+ return (array) $links;
1890
+
1891
+ }
1892
+
1893
+
1894
+ }
1895
 
1896
+ $qsm_install = new QSM_Install();
php/classes/class-qsm-migrate.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Class that handles migration logic
9
+ *
10
+ * @since 7.3.0
11
+ */
12
+ class QSM_Migrate {
13
+
14
+
15
+ public function __construct() {
16
+ add_action( 'wp_ajax_enable_multiple_categories', array( $this, 'enable_multiple_categories' ) );
17
+ }
18
+
19
+ /**
20
+ * This function enables multiple categories feature in QSM
21
+ *
22
+ * @since 7.3.0
23
+ * @return void
24
+ */
25
+ public function enable_multiple_categories() {
26
+ global $wpdb;
27
+ global $mlwQuizMasterNext;
28
+ switch ( $_POST['value'] ) {
29
+ case 'enable':
30
+ $new_category = '';
31
+ $term_id = 0;
32
+ $values_array = array();
33
+ $result = false;
34
+ $category_data = $wpdb->get_results( "SELECT question_id, quiz_id, category FROM {$wpdb->prefix}mlw_questions WHERE category <> '' ORDER BY category" );
35
+ foreach ( $category_data as $data ) {
36
+ if ( $new_category != $data->category ) {
37
+ $term_data = get_term_by( 'name', $data->category, 'qsm_category' );
38
+ if ( $term_data ) {
39
+ $term_id = $term_data->term_id;
40
+ } else {
41
+ $term_array = wp_insert_term( $data->category, 'qsm_category' );
42
+ $term_id = $term_array['term_id'];
43
+ }
44
+ }
45
+ $values_array[] = "($data->question_id, $data->quiz_id, $term_id, 'qsm_category')";
46
+ }
47
+ $values = join( ',', $values_array );
48
+ $insert_query = stripslashes( $wpdb->prepare( "INSERT INTO {$wpdb->prefix}mlw_question_terms (question_id, quiz_id, term_id, taxonomy) VALUES %1s", $values ) );
49
+ $result = $wpdb->query( $insert_query );
50
+ if ( $result > 0 ) {
51
+ update_option( 'qsm_multiple_category_enabled', date( time() ) );
52
+ $response = array(
53
+ 'status' => true,
54
+ 'count' => $result,
55
+ );
56
+ $update = "UPDATE {$wpdb->prefix}mlw_questions SET category = '' ";
57
+ $updated = $wpdb->query( $update );
58
+ } else {
59
+ $response = array(
60
+ 'status' => false,
61
+ );
62
+ }
63
+ echo json_encode( $response );
64
+ break;
65
+
66
+ case 'cancel':
67
+ update_option( 'qsm_multiple_category_enabled', 'cancelled' );
68
+ return true;
69
+ break;
70
+ }
71
+ exit;
72
+ }
73
+
74
+ /**
75
+ * This function check which regime of category is available and returns category data accordingly
76
+ *
77
+ * @param string $name
78
+ * @return array
79
+ */
80
+ public function get_category_data( $name ) {
81
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
82
+ $migrated = false;
83
+ if ( $enabled && 'cancelled' !== $enabled ) {
84
+ $migrated = true;
85
+ }
86
+
87
+ $response = array(
88
+ 'migrated' => $migrated,
89
+ );
90
+
91
+ if ( $migrated ) {
92
+ $cats = explode( '_', $name );
93
+ $ids = array();
94
+ foreach ( $cats as $category ) {
95
+ $category = trim( $category );
96
+ if ( $category != '' ) {
97
+ $cat_data = get_term_by( 'name', $category, 'qsm_category' );
98
+ if ( $cat_data ) {
99
+ $ids[] = $cat_data->term_id;
100
+ }
101
+ }
102
+ }
103
+
104
+ if ( ! empty( $ids ) ) {
105
+ $response['ids'] = $ids;
106
+ } else {
107
+ $response['migrated'] = false;
108
+ $response['name'] = $name;
109
+ }
110
+ } else {
111
+ $response['name'] = $name;
112
+ }
113
+
114
+ return $response;
115
+ }
116
+ }
php/classes/class-qsm-questions.php CHANGED
@@ -24,6 +24,14 @@ class QSM_Questions {
24
  $question_id = intval( $question_id );
25
  $question = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE question_id = %d LIMIT 1", $question_id ), 'ARRAY_A' );
26
  if ( ! is_null( $question ) ) {
 
 
 
 
 
 
 
 
27
  // Prepare answers.
28
  $answers = maybe_unserialize( $question['answer_array'] );
29
  if ( ! is_array( $answers ) ) {
@@ -83,7 +91,14 @@ class QSM_Questions {
83
 
84
  // Loop through questions and prepare serialized data.
85
  foreach ( $question_array as $question ) {
86
-
 
 
 
 
 
 
 
87
  // Prepare answers.
88
  $answers = maybe_unserialize( $question['answer_array'] );
89
  if ( ! is_array( $answers ) ) {
@@ -136,7 +151,14 @@ class QSM_Questions {
136
 
137
  // Loop through questions and prepare serialized data.
138
  foreach ( $questions as $question ) {
139
-
 
 
 
 
 
 
 
140
  // Prepare answers.
141
  $answers = maybe_unserialize( $question['answer_array'] );
142
  if ( ! is_array( $answers ) ) {
@@ -243,6 +265,7 @@ class QSM_Questions {
243
  'hint' => '',
244
  'order' => 1,
245
  'category' => '',
 
246
  );
247
  $data = wp_parse_args( $data, $defaults );
248
 
@@ -276,6 +299,7 @@ class QSM_Questions {
276
  'category' => sanitize_text_field( $data['category'] ),
277
  'deleted' => 0,
278
  );
 
279
 
280
  $types = array(
281
  '%d',
@@ -291,17 +315,19 @@ class QSM_Questions {
291
  '%d',
292
  );
293
 
 
294
  if ( $is_creating ) {
295
  $results = $wpdb->insert(
296
  $wpdb->prefix . 'mlw_questions',
297
  $values,
298
  $types
299
  );
 
300
  } else {
301
  $results = $wpdb->update(
302
  $wpdb->prefix . 'mlw_questions',
303
  $values,
304
- array( 'question_id' => intval( $data['ID'] ) ),
305
  $types,
306
  array( '%d' )
307
  );
@@ -312,11 +338,24 @@ class QSM_Questions {
312
  $mlwQuizMasterNext->log_manager->add( 'Error when creating/saving question', $msg, 0, 'error' );
313
  throw new Exception( $msg );
314
  }
315
-
316
- if ( $is_creating ) {
317
- return $wpdb->insert_id;
318
- } else {
319
- return $data['ID'];
 
 
 
 
 
 
 
 
 
 
 
320
  }
 
 
321
  }
322
  }
24
  $question_id = intval( $question_id );
25
  $question = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE question_id = %d LIMIT 1", $question_id ), 'ARRAY_A' );
26
  if ( ! is_null( $question ) ) {
27
+ $multicategories = array();
28
+ $multicategories_res = $wpdb->get_results("SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `question_id`='{$question['question_id']}' AND `taxonomy`='qsm_category'", ARRAY_A);
29
+ if (!empty($multicategories_res)){
30
+ foreach ($multicategories_res as $cat) {
31
+ $multicategories[] = $cat['term_id'];
32
+ }
33
+ }
34
+ $question['multicategories'] = $multicategories;
35
  // Prepare answers.
36
  $answers = maybe_unserialize( $question['answer_array'] );
37
  if ( ! is_array( $answers ) ) {
91
 
92
  // Loop through questions and prepare serialized data.
93
  foreach ( $question_array as $question ) {
94
+ $multicategories = array();
95
+ $multicategories_res = $wpdb->get_results("SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `question_id`='{$question['question_id']}' AND `taxonomy`='qsm_category'", ARRAY_A);
96
+ if (!empty($multicategories_res)){
97
+ foreach ($multicategories_res as $cat) {
98
+ $multicategories[] = $cat['term_id'];
99
+ }
100
+ }
101
+ $question['multicategories'] = $multicategories;
102
  // Prepare answers.
103
  $answers = maybe_unserialize( $question['answer_array'] );
104
  if ( ! is_array( $answers ) ) {
151
 
152
  // Loop through questions and prepare serialized data.
153
  foreach ( $questions as $question ) {
154
+ $multicategories = array();
155
+ $multicategories_res = $wpdb->get_results("SELECT `term_id` FROM `{$wpdb->prefix}mlw_question_terms` WHERE `question_id`='{$question['question_id']}' AND `taxonomy`='qsm_category'", ARRAY_A);
156
+ if (!empty($multicategories_res)){
157
+ foreach ($multicategories_res as $cat) {
158
+ $multicategories[] = $cat['term_id'];
159
+ }
160
+ }
161
+ $question['multicategories'] = $multicategories;
162
  // Prepare answers.
163
  $answers = maybe_unserialize( $question['answer_array'] );
164
  if ( ! is_array( $answers ) ) {
265
  'hint' => '',
266
  'order' => 1,
267
  'category' => '',
268
+ 'multicategories' => '',
269
  );
270
  $data = wp_parse_args( $data, $defaults );
271
 
299
  'category' => sanitize_text_field( $data['category'] ),
300
  'deleted' => 0,
301
  );
302
+ $values = apply_filters('qsm_save_question_data', $values);
303
 
304
  $types = array(
305
  '%d',
315
  '%d',
316
  );
317
 
318
+ $question_id = intval($data['ID']);
319
  if ( $is_creating ) {
320
  $results = $wpdb->insert(
321
  $wpdb->prefix . 'mlw_questions',
322
  $values,
323
  $types
324
  );
325
+ $question_id = $wpdb->insert_id;
326
  } else {
327
  $results = $wpdb->update(
328
  $wpdb->prefix . 'mlw_questions',
329
  $values,
330
+ array( 'question_id' => $question_id ),
331
  $types,
332
  array( '%d' )
333
  );
338
  $mlwQuizMasterNext->log_manager->add( 'Error when creating/saving question', $msg, 0, 'error' );
339
  throw new Exception( $msg );
340
  }
341
+
342
+ /**
343
+ * Process Question Categories
344
+ */
345
+ $question_terms_table = $wpdb->prefix . "mlw_question_terms";
346
+ $wpdb->delete($question_terms_table, array('question_id' => $question_id, 'taxonomy' => 'qsm_category'));
347
+ if (!empty($data['multicategories'])) {
348
+ foreach ($data['multicategories'] as $term_id) {
349
+ $term_rel_data = array(
350
+ 'question_id' => $question_id,
351
+ 'quiz_id' => intval($data['quiz_id']),
352
+ 'term_id' => $term_id,
353
+ 'taxonomy' => 'qsm_category',
354
+ );
355
+ $wpdb->insert($question_terms_table, $term_rel_data);
356
+ }
357
  }
358
+
359
+ return $question_id;
360
  }
361
  }
php/classes/class-qsm-results-pages.php CHANGED
@@ -30,8 +30,8 @@ class QSM_Results_Pages {
30
  $default_redirect = false;
31
  ob_start();
32
  ?>
33
- <div class="qsm-results-page">
34
- <?php
35
  do_action( 'qsm_before_results_page' );
36
 
37
  // Cycles through each possible page.
@@ -51,15 +51,27 @@ class QSM_Results_Pages {
51
  // Cycle through each condition to see if we should show this page.
52
  foreach ( $page['conditions'] as $condition ) {
53
  $value = $condition['value'];
54
-
 
 
 
55
  // First, determine which value we need to test.
56
  switch ( $condition['criteria'] ) {
57
  case 'score':
58
- $test = $response_data['total_score'];
 
 
 
 
 
59
  break;
60
 
61
  case 'points':
62
- $test = $response_data['total_points'];
 
 
 
 
63
  break;
64
 
65
  default:
@@ -151,8 +163,8 @@ class QSM_Results_Pages {
151
  echo apply_filters( 'mlw_qmn_template_variable_results_page', $page, $response_data );
152
  do_action( 'qsm_after_results_page' );
153
  ?>
154
- </div>
155
- <?php
156
  return array(
157
  'display' => do_shortcode( ob_get_clean() ),
158
  'redirect' => $redirect,
@@ -347,4 +359,4 @@ class QSM_Results_Pages {
347
  }
348
  }
349
  }
350
- ?>
30
  $default_redirect = false;
31
  ob_start();
32
  ?>
33
+ <div class="qsm-results-page">
34
+ <?php
35
  do_action( 'qsm_before_results_page' );
36
 
37
  // Cycles through each possible page.
51
  // Cycle through each condition to see if we should show this page.
52
  foreach ( $page['conditions'] as $condition ) {
53
  $value = $condition['value'];
54
+ $category = '';
55
+ if( isset($condition['category'])){
56
+ $category = $condition['category'];
57
+ }
58
  // First, determine which value we need to test.
59
  switch ( $condition['criteria'] ) {
60
  case 'score':
61
+ if( $category != '' ){
62
+ $test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_SCORE_$category%", $response_data );
63
+ } else {
64
+ $test = $response_data['total_score'];
65
+ }
66
+
67
  break;
68
 
69
  case 'points':
70
+ if( $category != '' ){
71
+ $test = apply_filters( 'mlw_qmn_template_variable_results_page', "%CATEGORY_POINTS_$category%", $response_data );
72
+ } else {
73
+ $test = $response_data['total_points'];
74
+ }
75
  break;
76
 
77
  default:
163
  echo apply_filters( 'mlw_qmn_template_variable_results_page', $page, $response_data );
164
  do_action( 'qsm_after_results_page' );
165
  ?>
166
+ </div>
167
+ <?php
168
  return array(
169
  'display' => do_shortcode( ob_get_clean() ),
170
  'redirect' => $redirect,
359
  }
360
  }
361
  }
362
+ ?>
php/classes/class-qsm-theme-settings.php CHANGED
@@ -41,7 +41,7 @@ class QSM_Theme_Settings {
41
  *
42
  * @return bool true for successful update, false in failure
43
  */
44
- public function update_theme_status( $status = true, $path, $name = '', $default_settings = '' ) {
45
  global $wpdb;
46
  $theme_path = isset( $path ) ? $path : '';
47
  $theme_name = isset( $name ) ? $name : '';
41
  *
42
  * @return bool true for successful update, false in failure
43
  */
44
+ public function update_theme_status( $status, $path, $name = '', $default_settings = '' ) {
45
  global $wpdb;
46
  $theme_path = isset( $path ) ? $path : '';
47
  $theme_name = isset( $name ) ? $name : '';
php/question-types.php CHANGED
@@ -177,7 +177,7 @@ function qmn_multiple_choice_review( $id, $question, $answers ) {
177
  $correct_text = array();
178
  foreach ( $answers as $answer ) {
179
  if ( $answerEditor === 'rich' ) {
180
- $answer_option = htmlspecialchars_decode( $answer[0], ENT_QUOTES );
181
  $sinel_answer_cmp = preg_replace( "/\s+|\n+|\r/", ' ', htmlentities( $answer_option ) );
182
  if ( $rich_text_comapre == $sinel_answer_cmp ) {
183
  $return_array['points'] = $answer[1];
@@ -344,6 +344,7 @@ function qmn_horizontal_multiple_choice_display( $id, $question, $answers ) {
344
  $question_display .= '</span>';
345
  }
346
  }
 
347
  $question_display .= "<input type='radio' style='display: none;' name='question" . $id . "' id='question" . $id . "_none' checked='checked' value='' />";
348
  }
349
  $question_display .= '</div>';
177
  $correct_text = array();
178
  foreach ( $answers as $answer ) {
179
  if ( $answerEditor === 'rich' ) {
180
+ $answer_option = stripslashes( htmlspecialchars_decode( $answer[0], ENT_QUOTES ) );
181
  $sinel_answer_cmp = preg_replace( "/\s+|\n+|\r/", ' ', htmlentities( $answer_option ) );
182
  if ( $rich_text_comapre == $sinel_answer_cmp ) {
183
  $return_array['points'] = $answer[1];
344
  $question_display .= '</span>';
345
  }
346
  }
347
+ $question_display =apply_filters( 'qmn_horizontal_multiple_choice_question_display', $question_display, $id, $question, $answers );
348
  $question_display .= "<input type='radio' style='display: none;' name='question" . $id . "' id='question" . $id . "_none' checked='checked' value='' />";
349
  }
350
  $question_display .= '</div>';
php/rest-api.php CHANGED
@@ -134,11 +134,21 @@ function qsm_rest_get_bank_questions( WP_REST_Request $request ) {
134
  if ( is_user_logged_in() ) {
135
  global $wpdb;
136
  $category = isset( $_REQUEST['category'] ) ? sanitize_text_field( $_REQUEST['category'] ) : '';
 
 
 
 
 
 
137
 
138
  if ( ! empty( $category ) ) {
139
- $query = $wpdb->prepare( "SELECT COUNT(question_id) as total_question FROM {$wpdb->prefix}mlw_questions WHERE deleted=0 AND deleted_question_bank=0 AND category=%s", $category );
 
 
 
 
140
  } else {
141
- $query = "SELECT COUNT(question_id) as total_question FROM {$wpdb->prefix}mlw_questions WHERE deleted=0 AND deleted_question_bank=0";
142
  }
143
 
144
  $total_count_query = $wpdb->get_row( $query, 'ARRAY_A' );
@@ -155,12 +165,33 @@ function qsm_rest_get_bank_questions( WP_REST_Request $request ) {
155
  $offset = ( $pageno - 1 ) * $limit;
156
 
157
  if ( ! empty( $category ) ) {
158
- $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank = 0 AND category = %s ORDER BY question_order ASC LIMIT %d, %d", $category, $offset, $limit );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  } else {
160
  $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank = 0 ORDER BY question_order ASC LIMIT %d, %d", $offset, $limit );
 
161
  }
162
 
163
- $questions = $wpdb->get_results( $query, 'ARRAY_A' );
164
  $question_array = array();
165
  $question_array['pagination'] = array(
166
  'total_pages' => $total_pages,
@@ -169,46 +200,49 @@ function qsm_rest_get_bank_questions( WP_REST_Request $request ) {
169
  );
170
 
171
  $question_array['questions'] = array();
172
- foreach ( $questions as $question ) {
173
- $quiz_name = $wpdb->get_row( $wpdb->prepare( "SELECT quiz_name FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id = %d", $question['quiz_id'] ), ARRAY_A );
174
- $question['page'] = isset( $question['page'] ) ? (int) $question['page'] : 0;
175
 
176
- $answers = maybe_unserialize( $question['answer_array'] );
177
  if ( ! is_array( $answers ) ) {
178
- $answers = array();
179
  }
180
- $question['answers'] = $answers;
181
 
182
- $settings = maybe_unserialize( $question['question_settings'] );
183
  if ( ! is_array( $settings ) ) {
184
- $settings = array( 'required' => 1 );
185
  }
186
- $question['settings'] = $settings;
187
-
188
- $question_data = array(
189
- 'id' => $question['question_id'],
190
- 'quizID' => $question['quiz_id'],
191
- 'type' => $question['question_type_new'],
192
- 'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : 0,
193
- 'name' => $question['question_name'],
194
- 'answerInfo' => $question['question_answer_info'],
195
- 'comments' => $question['comments'],
196
- 'hint' => $question['hints'],
197
- 'category' => $question['category'],
198
- 'required' => $question['settings']['required'],
199
- 'answers' => $question['answers'],
200
- 'page' => $question['page'],
201
- 'answerEditor' => isset( $question['settings']['answerEditor'] ) ? $question['settings']['answerEditor'] : 'text',
202
- 'autofill' => isset( $question['settings']['autofill'] ) ? $question['settings']['autofill'] : 0,
203
- 'limit_text' => isset( $question['settings']['limit_text'] ) ? $question['settings']['limit_text'] : 0,
204
- 'limit_multiple_response' => isset( $question['settings']['limit_multiple_response'] ) ? $question['settings']['limit_multiple_response'] : 0,
205
- 'file_upload_limit' => isset( $question['settings']['file_upload_limit'] ) ? $question['settings']['file_upload_limit'] : 0,
206
- 'file_upload_type' => isset( $question['settings']['file_upload_type'] ) ? $question['settings']['file_upload_type'] : '',
207
- 'quiz_name' => isset( $quiz_name['quiz_name'] ) ? $quiz_name['quiz_name'] : '',
208
- 'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : '',
209
- );
210
- $question_data = apply_filters( 'qsm_rest_api_filter_question_data', $question_data, $question, $request );
211
- $question_array['questions'][] = $question_data;
 
 
 
212
  }
213
  return $question_array;
214
  } else {
@@ -435,6 +469,7 @@ function qsm_rest_get_question( WP_REST_Request $request ) {
435
  'comments' => $question['comments'],
436
  'hint' => $question['hints'],
437
  'category' => $question['category'],
 
438
  'required' => $question['settings']['required'],
439
  'answers' => $question['answers'],
440
  'page' => $question['page'],
@@ -482,6 +517,7 @@ function qsm_rest_get_questions( WP_REST_Request $request ) {
482
  'comments' => $question['comments'],
483
  'hint' => $question['hints'],
484
  'category' => $question['category'],
 
485
  'required' => $question['settings']['required'],
486
  'answers' => $question['answers'],
487
  'page' => $question['page'],
@@ -532,6 +568,7 @@ function qsm_rest_create_question( WP_REST_Request $request ) {
532
  'hint' => $request['hint'],
533
  'order' => 1,
534
  'category' => $request['category'],
 
535
  );
536
  $settings = array(
537
  'required' => $request['required'],
@@ -590,6 +627,7 @@ function qsm_rest_save_question( WP_REST_Request $request ) {
590
  'hint' => $request['hint'],
591
  'order' => 1,
592
  'category' => $request['category'],
 
593
  );
594
  $settings = array();
595
  $settings['answerEditor'] = $request['answerEditor'];
134
  if ( is_user_logged_in() ) {
135
  global $wpdb;
136
  $category = isset( $_REQUEST['category'] ) ? sanitize_text_field( $_REQUEST['category'] ) : '';
137
+ $enabled = get_option( 'qsm_multiple_category_enabled' );
138
+
139
+ $migrated = false;
140
+ if ( $enabled && 'cancelled' !== $enabled ) {
141
+ $migrated = true;
142
+ }
143
 
144
  if ( ! empty( $category ) ) {
145
+ if ( $migrated && is_numeric( $category ) ) {
146
+ $query = $wpdb->prepare( "SELECT COUNT(question_id) as total_question FROM {$wpdb->prefix}mlw_question_terms WHERE term_id = %d", $category );
147
+ } else {
148
+ $query = $wpdb->prepare( "SELECT COUNT(question_id) as total_question FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank = 0 AND category = %s", $category );
149
+ }
150
  } else {
151
+ $query = "SELECT COUNT(question_id) as total_question FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank=0";
152
  }
153
 
154
  $total_count_query = $wpdb->get_row( $query, 'ARRAY_A' );
165
  $offset = ( $pageno - 1 ) * $limit;
166
 
167
  if ( ! empty( $category ) ) {
168
+ if ( $migrated && is_numeric( $category ) ) {
169
+ $query = $wpdb->prepare( "SELECT DISTINCT question_id FROM {$wpdb->prefix}mlw_question_terms WHERE term_id = %d", $category );
170
+ $term_ids = $wpdb->get_results( $query, 'ARRAY_A' );
171
+ $question_ids = [];
172
+ foreach( $term_ids as $term_id ) {
173
+ $question_ids[] = esc_sql( intval( $term_id['question_id'] ) );
174
+ }
175
+ $question_ids = array_unique( $question_ids );
176
+ $query_result = [];
177
+ foreach( $question_ids as $question_id ) {
178
+ $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank = 0 AND question_id = %d ORDER BY question_order ASC LIMIT %d, %d", $question_id, $offset, $limit );
179
+ $question_data = $wpdb->get_row( $query, 'ARRAY_A' );
180
+ if( ! is_null($question_data)){
181
+ $query_result[] = $question_data;
182
+ }
183
+
184
+ }
185
+ $questions = $query_result;
186
+ } else {
187
+ $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank = 0 AND category = %s ORDER BY question_order ASC LIMIT %d, %d", $category, $offset, $limit );
188
+ $questions = $wpdb->get_results( $query, 'ARRAY_A' );
189
+ }
190
  } else {
191
  $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}mlw_questions WHERE deleted = 0 AND deleted_question_bank = 0 ORDER BY question_order ASC LIMIT %d, %d", $offset, $limit );
192
+ $questions = $wpdb->get_results( $query, 'ARRAY_A' );
193
  }
194
 
 
195
  $question_array = array();
196
  $question_array['pagination'] = array(
197
  'total_pages' => $total_pages,
200
  );
201
 
202
  $question_array['questions'] = array();
203
+ foreach( $questions as $question ) {
204
+ $quiz_name = $wpdb->get_row( $wpdb->prepare( "SELECT quiz_name FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id = %d", $question['quiz_id'] ), ARRAY_A );
205
+ $question['page'] = isset( $question['page'] ) ? (int) $question['page'] : 0;
206
 
207
+ $answers = maybe_unserialize( $question['answer_array'] );
208
  if ( ! is_array( $answers ) ) {
209
+ $answers = array();
210
  }
211
+ $question['answers'] = $answers;
212
 
213
+ $settings = maybe_unserialize( $question['question_settings'] );
214
  if ( ! is_array( $settings ) ) {
215
+ $settings = array( 'required' => 1 );
216
  }
217
+ if ( empty( $settings['question_title'] ) && empty( $question['question_name'] )) {
218
+ continue;
219
+ }
220
+
221
+ $question['settings'] = $settings;
222
+ $question_data = array(
223
+ 'id' => $question['question_id'],
224
+ 'quizID' => $question['quiz_id'],
225
+ 'type' => $question['question_type_new'],
226
+ 'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : 0,
227
+ 'name' => $question['question_name'],
228
+ 'answerInfo' => $question['question_answer_info'],
229
+ 'comments' => $question['comments'],
230
+ 'hint' => $question['hints'],
231
+ 'category' => $question['category'],
232
+ 'required' => $question['settings']['required'],
233
+ 'answers' => $question['answers'],
234
+ 'page' => $question['page'],
235
+ 'answerEditor' => isset( $question['settings']['answerEditor'] ) ? $question['settings']['answerEditor'] : 'text',
236
+ 'autofill' => isset( $question['settings']['autofill'] ) ? $question['settings']['autofill'] : 0,
237
+ 'limit_text' => isset( $question['settings']['limit_text'] ) ? $question['settings']['limit_text'] : 0,
238
+ 'limit_multiple_response' => isset( $question['settings']['limit_multiple_response'] ) ? $question['settings']['limit_multiple_response'] : 0,
239
+ 'file_upload_limit' => isset( $question['settings']['file_upload_limit'] ) ? $question['settings']['file_upload_limit'] : 0,
240
+ 'file_upload_type' => isset( $question['settings']['file_upload_type'] ) ? $question['settings']['file_upload_type'] : '',
241
+ 'quiz_name' => isset( $quiz_name['quiz_name'] ) ? $quiz_name['quiz_name'] : '',
242
+ 'question_title' => isset( $question['settings']['question_title'] ) ? $question['settings']['question_title'] : '',
243
+ );
244
+ $question_data = apply_filters( 'qsm_rest_api_filter_question_data', $question_data, $question, $request );
245
+ $question_array['questions'][] = $question_data;
246
  }
247
  return $question_array;
248
  } else {
469
  'comments' => $question['comments'],
470
  'hint' => $question['hints'],
471
  'category' => $question['category'],
472
+ 'multicategories'=> $question['multicategories'],
473
  'required' => $question['settings']['required'],
474
  'answers' => $question['answers'],
475
  'page' => $question['page'],
517
  'comments' => $question['comments'],
518
  'hint' => $question['hints'],
519
  'category' => $question['category'],
520
+ 'multicategories' => $question['multicategories'],
521
  'required' => $question['settings']['required'],
522
  'answers' => $question['answers'],
523
  'page' => $question['page'],
568
  'hint' => $request['hint'],
569
  'order' => 1,
570
  'category' => $request['category'],
571
+ 'multicategories' => $request['multicategories'],
572
  );
573
  $settings = array(
574
  'required' => $request['required'],
627
  'hint' => $request['hint'],
628
  'order' => 1,
629
  'category' => $request['category'],
630
+ 'multicategories' => $request['multicategories'],
631
  );
632
  $settings = array();
633
  $settings['answerEditor'] = $request['answerEditor'];
php/template-variables.php CHANGED
@@ -552,6 +552,7 @@ function mlw_qmn_variable_date_taken( $content, $mlw_quiz_array ) {
552
  * @return string Returns the contents for the results page
553
  */
554
  function qmn_variable_category_points( $content, $mlw_quiz_array ) {
 
555
  $return_points = 0;
556
  while ( strpos( $content, '%CATEGORY_POINTS%' ) !== false || false !== strpos( $content, '%CATEGORY_POINTS_' ) ) {
557
  $return_points = 0;
@@ -562,9 +563,23 @@ function qmn_variable_category_points( $content, $mlw_quiz_array ) {
562
  $category_name = $answer_text[1];
563
  }
564
 
 
 
565
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
566
- if ( $answer['category'] == $category_name ) {
567
- $return_points += $answer['points'];
 
 
 
 
 
 
 
 
 
 
 
 
568
  }
569
  }
570
  if ( empty( $answer_text ) ) {
@@ -634,6 +649,7 @@ function qmn_variable_average_category_points( $content, $mlw_quiz_array ) {
634
  * @return string Returns the contents for the results page
635
  */
636
  function qmn_variable_category_score( $content, $mlw_quiz_array ) {
 
637
  $return_score = 0;
638
  $total_questions = 0;
639
  $amount_correct = 0;
@@ -647,11 +663,29 @@ function qmn_variable_category_score( $content, $mlw_quiz_array ) {
647
  } else {
648
  $category_name = $answer_text[1];
649
  }
 
 
 
650
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
651
- if ( $answer['category'] == $category_name ) {
652
- $total_questions += 1;
653
- if ( $answer['correct'] == 'correct' ) {
654
- $amount_correct += 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
655
  }
656
  }
657
  }
@@ -947,20 +981,20 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
947
  $question_with_answer_text .= "<span class='$user_answer_class'>" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span>';
948
  }
949
  } elseif ( isset( $answer['question_type'] ) && $answer['question_type'] == 14 ) {
950
- $match_answer = $mlwQuizMasterNext->pluginHelper->get_question_setting( $answer['id'], 'matchAnswer' );
951
  $new_array_user_answer = isset( $answer['user_compare_text'] ) ? explode( '=====', $answer['user_compare_text'] ) : array();
952
- if($match_answer == 'sequence'){
953
  foreach ( $total_answers as $key => $single_answer ) {
954
  $show_user_answer = $new_array_user_answer[ $key ];
955
  $is_answer_correct = false;
956
  if ( mb_strtoupper( $show_user_answer ) == mb_strtoupper( $single_answer[0] ) ) {
957
  $is_answer_correct = true;
958
  }
959
- $index = $key +1;
960
  if ( $is_answer_correct ) {
961
- $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">(' . $index. ') ' . $show_user_answer . '</span>';
962
  } else {
963
- if($show_user_answer == '') {
964
  $show_user_answer = 'No answer provided';
965
  }
966
  $question_with_answer_text .= '<span class="qsm-text-wrong-option">(' . $index . ') ' . $show_user_answer . '</span>';
@@ -969,41 +1003,39 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
969
  }
970
  } else {
971
  $options = array();
972
- foreach($total_answers as $key => $single_answer){
973
- $options[] = mb_strtoupper($single_answer[0]);
974
  }
975
- if(sizeof($new_array_user_answer) < sizeof($total_answers)){
976
- foreach($new_array_user_answer as $show_user_answer){
977
- $key = array_search( mb_strtoupper($show_user_answer), $options );
978
- if($key !== false){
979
  $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . $show_user_answer . '</span>';
980
  } else {
981
- if($show_user_answer == '') {
982
  $show_user_answer = 'No answer provided';
983
  }
984
  $question_with_answer_text .= '<span class="qsm-text-wrong-option">' . $show_user_answer . '</span>';
985
  }
986
  }
987
  } else {
988
- foreach($new_array_user_answer as $show_user_answer){
989
- $key = array_search( mb_strtoupper($show_user_answer), $options );
990
- if($key !== false){
991
  $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . $show_user_answer . '</span>';
992
  } else {
993
- if($show_user_answer == '') {
994
  $show_user_answer = 'No answer provided';
995
  }
996
- if($answer['correct'] == 'correct'){
997
  $question_with_answer_text .= '<span class="qsm-text-simple-option">' . $show_user_answer . '</span>';
998
  } else {
999
  $question_with_answer_text .= '<span class="qsm-text-wrong-option">' . $show_user_answer . '</span>';
1000
  }
1001
-
1002
  }
1003
  }
1004
  }
1005
  }
1006
-
1007
  } else {
1008
  if ( $form_type == 0 && ( $quiz_system == 0 || $quiz_system == 3 ) ) {
1009
  if ( isset( $answer['question_type'] ) && ( $answer['question_type'] == 4 || $answer['question_type'] == 10 ) ) {
552
  * @return string Returns the contents for the results page
553
  */
554
  function qmn_variable_category_points( $content, $mlw_quiz_array ) {
555
+ global $mlwQuizMasterNext;
556
  $return_points = 0;
557
  while ( strpos( $content, '%CATEGORY_POINTS%' ) !== false || false !== strpos( $content, '%CATEGORY_POINTS_' ) ) {
558
  $return_points = 0;
563
  $category_name = $answer_text[1];
564
  }
565
 
566
+ $category_data = $mlwQuizMasterNext->migrationHelper->get_category_data( $category_name );
567
+
568
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
569
+ if ( $category_data['migrated'] ) {
570
+ $length = 0;
571
+ foreach ( $category_data['ids'] as $id ) {
572
+ if ( in_array( $id, $answer['multicategories'] ) ) {
573
+ $length++;
574
+ }
575
+ }
576
+ if ( $length == sizeof( $category_data['ids'] ) ) {
577
+ $return_points += $answer['points'];
578
+ }
579
+ } else {
580
+ if ( $answer['category'] == $category_name ) {
581
+ $return_points += $answer['points'];
582
+ }
583
  }
584
  }
585
  if ( empty( $answer_text ) ) {
649
  * @return string Returns the contents for the results page
650
  */
651
  function qmn_variable_category_score( $content, $mlw_quiz_array ) {
652
+ global $mlwQuizMasterNext;
653
  $return_score = 0;
654
  $total_questions = 0;
655
  $amount_correct = 0;
663
  } else {
664
  $category_name = $answer_text[1];
665
  }
666
+
667
+ $category_data = $mlwQuizMasterNext->migrationHelper->get_category_data( $category_name );
668
+
669
  foreach ( $mlw_quiz_array['question_answers_array'] as $answer ) {
670
+ if ( $category_data['migrated'] ) {
671
+ $length = 0;
672
+ foreach ( $category_data['ids'] as $id ) {
673
+ if ( in_array( $id, $answer['multicategories'] ) ) {
674
+ $length++;
675
+ }
676
+ }
677
+ if ( $length == sizeof( $category_data['ids'] ) ) {
678
+ $total_questions += 1;
679
+ if ( $answer['correct'] == 'correct' ) {
680
+ $amount_correct += 1;
681
+ }
682
+ }
683
+ } else {
684
+ if ( $answer['category'] == $category_name ) {
685
+ $total_questions += 1;
686
+ if ( $answer['correct'] == 'correct' ) {
687
+ $amount_correct += 1;
688
+ }
689
  }
690
  }
691
  }
981
  $question_with_answer_text .= "<span class='$user_answer_class'>" . trim( htmlspecialchars_decode( $answer[1], ENT_QUOTES ) ) . '</span>';
982
  }
983
  } elseif ( isset( $answer['question_type'] ) && $answer['question_type'] == 14 ) {
984
+ $match_answer = $mlwQuizMasterNext->pluginHelper->get_question_setting( $answer['id'], 'matchAnswer' );
985
  $new_array_user_answer = isset( $answer['user_compare_text'] ) ? explode( '=====', $answer['user_compare_text'] ) : array();
986
+ if ( $match_answer == 'sequence' ) {
987
  foreach ( $total_answers as $key => $single_answer ) {
988
  $show_user_answer = $new_array_user_answer[ $key ];
989
  $is_answer_correct = false;
990
  if ( mb_strtoupper( $show_user_answer ) == mb_strtoupper( $single_answer[0] ) ) {
991
  $is_answer_correct = true;
992
  }
993
+ $index = $key + 1;
994
  if ( $is_answer_correct ) {
995
+ $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">(' . $index . ') ' . $show_user_answer . '</span>';
996
  } else {
997
+ if ( $show_user_answer == '' ) {
998
  $show_user_answer = 'No answer provided';
999
  }
1000
  $question_with_answer_text .= '<span class="qsm-text-wrong-option">(' . $index . ') ' . $show_user_answer . '</span>';
1003
  }
1004
  } else {
1005
  $options = array();
1006
+ foreach ( $total_answers as $key => $single_answer ) {
1007
+ $options[] = mb_strtoupper( $single_answer[0] );
1008
  }
1009
+ if ( sizeof( $new_array_user_answer ) < sizeof( $total_answers ) ) {
1010
+ foreach ( $new_array_user_answer as $show_user_answer ) {
1011
+ $key = array_search( mb_strtoupper( $show_user_answer ), $options );
1012
+ if ( $key !== false ) {
1013
  $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . $show_user_answer . '</span>';
1014
  } else {
1015
+ if ( $show_user_answer == '' ) {
1016
  $show_user_answer = 'No answer provided';
1017
  }
1018
  $question_with_answer_text .= '<span class="qsm-text-wrong-option">' . $show_user_answer . '</span>';
1019
  }
1020
  }
1021
  } else {
1022
+ foreach ( $new_array_user_answer as $show_user_answer ) {
1023
+ $key = array_search( mb_strtoupper( $show_user_answer ), $options );
1024
+ if ( $key !== false ) {
1025
  $question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . $show_user_answer . '</span>';
1026
  } else {
1027
+ if ( $show_user_answer == '' ) {
1028
  $show_user_answer = 'No answer provided';
1029
  }
1030
+ if ( $answer['correct'] == 'correct' ) {
1031
  $question_with_answer_text .= '<span class="qsm-text-simple-option">' . $show_user_answer . '</span>';
1032
  } else {
1033
  $question_with_answer_text .= '<span class="qsm-text-wrong-option">' . $show_user_answer . '</span>';
1034
  }
 
1035
  }
1036
  }
1037
  }
1038
  }
 
1039
  } else {
1040
  if ( $form_type == 0 && ( $quiz_system == 0 || $quiz_system == 3 ) ) {
1041
  if ( isset( $answer['question_type'] ) && ( $answer['question_type'] == 4 || $answer['question_type'] == 10 ) ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: quiz, survey, lead, test, score, exam, questionnaire, question,wordpress q
4
  Requires at least: 4.9
5
  Tested up to: 5.7
6
  Requires PHP: 5.4
7
- Stable tag: 7.2.3
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -152,6 +152,12 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
152
 
153
  == Changelog ==
154
 
 
 
 
 
 
 
155
  = 7.2.3 (July 15, 2021) =
156
  * Bug: Fixed issue fatal error on php version below 7.3.
157
 
4
  Requires at least: 4.9
5
  Tested up to: 5.7
6
  Requires PHP: 5.4
7
+ Stable tag: 7.3.0
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
152
 
153
  == Changelog ==
154
 
155
+ = 7.3.0 (July 29, 2021) =
156
+ * Feature: Added option to add multiple categories to single question.
157
+ * Feature: Added option to display quiz results based on category points.
158
+ * Enhancement: Extended category based template variables to support multiple categories.
159
+ * Bug: Fixed issue with quiz duplication.
160
+
161
  = 7.2.3 (July 15, 2021) =
162
  * Bug: Fixed issue fatal error on php version below 7.3.
163