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