Version Description
- release
Download this release
Release Info
Developer | xeno010 |
Plugin | Wp-Pro-Quiz |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- css/wpProQuiz_front.css +113 -0
- css/wpProQuiz_front.min.css +1 -0
- js/wpProQuiz_admin.js +231 -0
- js/wpProQuiz_admin.min.js +7 -0
- js/wpProQuiz_front.js +340 -0
- js/wpProQuiz_front.min.js +12 -0
- languages/wp-pro-quiz-de_DE.mo +0 -0
- languages/wp-pro-quiz-de_DE.po +374 -0
- lib/controller/WpProQuiz_Controller_Admin.php +106 -0
- lib/controller/WpProQuiz_Controller_Front.php +84 -0
- lib/controller/WpProQuiz_Controller_Preview.php +30 -0
- lib/controller/WpProQuiz_Controller_Question.php +135 -0
- lib/controller/WpProQuiz_Controller_Quiz.php +92 -0
- lib/helper/WpProQuiz_Helper_DbUpgrade.php +102 -0
- lib/model/WpProQuiz_Model_Mapper.php +20 -0
- lib/model/WpProQuiz_Model_Model.php +55 -0
- lib/model/WpProQuiz_Model_Question.php +106 -0
- lib/model/WpProQuiz_Model_QuestionMapper.php +117 -0
- lib/model/WpProQuiz_Model_Quiz.php +109 -0
- lib/model/WpProQuiz_Model_QuizMapper.php +74 -0
- lib/view/WpProQuiz_View_FrontQuiz.php +172 -0
- lib/view/WpProQuiz_View_QuestionEdit.php +184 -0
- lib/view/WpProQuiz_View_QuestionOverall.php +39 -0
- lib/view/WpProQuiz_View_QuizEdit.php +156 -0
- lib/view/WpProQuiz_View_QuizOverall.php +43 -0
- lib/view/WpProQuiz_View_View.php +25 -0
- readme.txt +60 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-7.png +0 -0
- screenshot-8.png +0 -0
- screenshot-9.png +0 -0
- template/wp-pro-quiz_overall_view.php +20 -0
- template/wpProQuizEditQuiz.php +52 -0
- uninstall.php +11 -0
- wp-pro-quiz.php +24 -0
css/wpProQuiz_front.css
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wpProQuiz_content {
|
2 |
+
margin-top: 10px;
|
3 |
+
margin-bottom: 10px;
|
4 |
+
}
|
5 |
+
|
6 |
+
.wpProQuiz_content h2 {
|
7 |
+
margin-bottom: 10px;
|
8 |
+
}
|
9 |
+
|
10 |
+
.wpProQuiz_content input[type="button"] {
|
11 |
+
margin: 0;
|
12 |
+
padding: 5px 10px;
|
13 |
+
background: #13455B;
|
14 |
+
border-radius: 11px;
|
15 |
+
color: white;
|
16 |
+
font-weight: bold;
|
17 |
+
border: 1px solid #13455B;
|
18 |
+
box-shadow: 1px 1px 1px #333;
|
19 |
+
}
|
20 |
+
|
21 |
+
.wpProQuiz_question_page {
|
22 |
+
margin-bottom: 10px;
|
23 |
+
}
|
24 |
+
|
25 |
+
.wpProQuiz_question_page span {
|
26 |
+
font-weight: bold;
|
27 |
+
}
|
28 |
+
|
29 |
+
.wpProQuiz_questionListItem {
|
30 |
+
padding: 3px;
|
31 |
+
margin-bottom: 5px;
|
32 |
+
}
|
33 |
+
|
34 |
+
.wpProQuiz_questionListItem:last-child {
|
35 |
+
padding: 3px;
|
36 |
+
margin-bottom: 0;
|
37 |
+
}
|
38 |
+
|
39 |
+
.wpProQuiz_questionList {
|
40 |
+
margin-bottom: 10px;
|
41 |
+
background: #F8FAF5;
|
42 |
+
border: 1px solid #C3D1A3;
|
43 |
+
padding: 5px;
|
44 |
+
list-style: none;
|
45 |
+
}
|
46 |
+
.wpProQuiz_list, wpProQuiz_listItem {
|
47 |
+
list-style: none;
|
48 |
+
padding: 0;
|
49 |
+
margin: 0;
|
50 |
+
}
|
51 |
+
.wpProQuiz_response {
|
52 |
+
display: none;
|
53 |
+
background: #F8FAF5;
|
54 |
+
border: 1px solid #C4C4C4;
|
55 |
+
padding: 5px;
|
56 |
+
margin-bottom: 15px;
|
57 |
+
box-shadow: 1px 1px 2px #AAA;
|
58 |
+
}
|
59 |
+
|
60 |
+
.wpProQuiz_response span {
|
61 |
+
font-weight: bold;
|
62 |
+
}
|
63 |
+
.wpProQuiz_quiz, .wpProQuiz_correct, .wpProQuiz_incorrect, .wpProQuiz_results, .wpProQuiz_time_limit, .wpProQuiz_QuestionButton {
|
64 |
+
display: none;
|
65 |
+
}
|
66 |
+
.wpProQuiz_answerCorrect {
|
67 |
+
background: #6DB46D;
|
68 |
+
font-weight: bold;
|
69 |
+
}
|
70 |
+
|
71 |
+
.wpProQuiz_answerIncorrect {
|
72 |
+
background: #FF9191;
|
73 |
+
font-weight: bold;
|
74 |
+
}
|
75 |
+
.wpProQuiz_sort {
|
76 |
+
width: 25px;
|
77 |
+
}
|
78 |
+
|
79 |
+
.wpProQuiz_results h3 {
|
80 |
+
margin-bottom: 10px;
|
81 |
+
}
|
82 |
+
.wpProQuiz_sort_correct_answer {
|
83 |
+
font-weight: bold;
|
84 |
+
margin-right: 5px;
|
85 |
+
display: none;
|
86 |
+
}
|
87 |
+
.wpProQuiz_sortable {
|
88 |
+
padding: 5px;
|
89 |
+
border: 1px solid lightGrey;
|
90 |
+
box-shadow: 2px 2px 1px #EEE;
|
91 |
+
background-color: #F8FAF5;
|
92 |
+
cursor: move;
|
93 |
+
}
|
94 |
+
.wpProQuiz_time_limit .time {
|
95 |
+
font-weight: bold;
|
96 |
+
margin-top: 5px;
|
97 |
+
margin-bottom: 5px;
|
98 |
+
}
|
99 |
+
.wpProQuiz_time_limit .progress {
|
100 |
+
height: 10px;
|
101 |
+
width: 46%;
|
102 |
+
background-color: blue;
|
103 |
+
margin-bottom: 5px;
|
104 |
+
}
|
105 |
+
.wpProQuiz_time_limit_expired {
|
106 |
+
display: none;
|
107 |
+
font-weight: bold;
|
108 |
+
font-size: 15px;
|
109 |
+
text-align: center;
|
110 |
+
}
|
111 |
+
.wpProQuiz_question_text {
|
112 |
+
margin-bottom: 10px;
|
113 |
+
}
|
css/wpProQuiz_front.min.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.wpProQuiz_content{margin-top:10px;margin-bottom:10px;}.wpProQuiz_content h2{margin-bottom:10px;}.wpProQuiz_content input[type=button]{margin:0;padding:5px 10px;background:#13455B;border-radius:11px;color:#FFF;font-weight:700;border:1px solid #13455B;box-shadow:1px 1px 1px #333;}.wpProQuiz_question_page{margin-bottom:10px;}.wpProQuiz_question_page span{font-weight:700;}.wpProQuiz_questionListItem{padding:3px;margin-bottom:5px;}.wpProQuiz_questionListItem:last-child{padding:3px;margin-bottom:0;}.wpProQuiz_questionList{margin-bottom:10px;background:#F8FAF5;border:1px solid #C3D1A3;padding:5px;list-style:none;}.wpProQuiz_list,wpProQuiz_listItem{list-style:none;padding:0;margin:0;}.wpProQuiz_response{display:none;background:#F8FAF5;border:1px solid #C4C4C4;padding:5px;margin-bottom:15px;box-shadow:1px 1px 2px #AAA;}.wpProQuiz_response span{font-weight:700;}.wpProQuiz_quiz,.wpProQuiz_correct,.wpProQuiz_incorrect,.wpProQuiz_results,.wpProQuiz_time_limit,.wpProQuiz_QuestionButton{display:none;}.wpProQuiz_answerCorrect{background:#6DB46D;font-weight:700;}.wpProQuiz_answerIncorrect{background:#FF9191;font-weight:700;}.wpProQuiz_sort{width:25px;}.wpProQuiz_results h3{margin-bottom:10px;}.wpProQuiz_sort_correct_answer{font-weight:700;margin-right:5px;display:none;}.wpProQuiz_sortable{padding:5px;border:1px solid #D3D3D3;box-shadow:2px 2px 1px #EEE;background-color:#F8FAF5;cursor:move;}.wpProQuiz_time_limit .time{font-weight:700;margin-top:5px;margin-bottom:5px;}.wpProQuiz_time_limit .progress{height:10px;width:46%;background-color:blue;margin-bottom:5px;}.wpProQuiz_time_limit_expired{display:none;font-weight:700;font-size:15px;text-align:center;}.wpProQuiz_question_text{margin-bottom:10px;}
|
js/wpProQuiz_admin.js
ADDED
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
$.fn.wpProQuiz_preview = function() {
|
3 |
+
var methods = {
|
4 |
+
openPreview: function(obj) {
|
5 |
+
window.open($(obj).attr('href'), 'wpProQuizPreview', 'width=900,height=900');
|
6 |
+
}
|
7 |
+
};
|
8 |
+
|
9 |
+
var init = function() {
|
10 |
+
$('.wpProQuiz_prview').click(function(e) {
|
11 |
+
methods.openPreview(this);
|
12 |
+
e.preventDefault();
|
13 |
+
});
|
14 |
+
};
|
15 |
+
|
16 |
+
init();
|
17 |
+
};
|
18 |
+
|
19 |
+
$.fn.wpProQuiz_questionEdit = function() {
|
20 |
+
|
21 |
+
var setup = function() {
|
22 |
+
if($('input[name="answerType"][checked="checked"]').size() < 1) {
|
23 |
+
$('input[name="answerType"][value="single"]').attr({'checked': 'checked'});
|
24 |
+
}
|
25 |
+
|
26 |
+
$('input[name="answerType"]:checked').click();
|
27 |
+
};
|
28 |
+
|
29 |
+
var formListener = {
|
30 |
+
setup: function() {
|
31 |
+
$('input[name="answerType"]').click(function(e) {
|
32 |
+
$('.answer_felder').children().css('display', 'none');
|
33 |
+
|
34 |
+
switch (this.value) {
|
35 |
+
case 'single':
|
36 |
+
formListener.displaySingle('radio');
|
37 |
+
break;
|
38 |
+
case 'multiple':
|
39 |
+
formListener.displaySingle('checkbox');
|
40 |
+
break;
|
41 |
+
case 'free_answer':
|
42 |
+
formListener.displayFreeAnswer();
|
43 |
+
break;
|
44 |
+
case 'sort_answer':
|
45 |
+
formListener.displaySortAnswer();
|
46 |
+
break;
|
47 |
+
}
|
48 |
+
});
|
49 |
+
|
50 |
+
$('.addAnswer').click(function(e) {
|
51 |
+
formListener.addAnswer(this);
|
52 |
+
});
|
53 |
+
|
54 |
+
$('.deleteAnswer').click(function(e) {
|
55 |
+
formListener.deleteAnswer(this);
|
56 |
+
});
|
57 |
+
|
58 |
+
$('#saveQuestion').click(function(e) {
|
59 |
+
return validate();
|
60 |
+
});
|
61 |
+
|
62 |
+
$('.sort_answer ul, .classic_answer ul').sortable({
|
63 |
+
handle: '.wpProQuiz_move',
|
64 |
+
update: function(event, ui) {
|
65 |
+
formListener.setValueClassicAnswer();
|
66 |
+
}
|
67 |
+
});
|
68 |
+
|
69 |
+
},
|
70 |
+
|
71 |
+
displaySingle: function(type) {
|
72 |
+
$('.classic_answer').find('input[name="answerJson[classic_answer][correct][]"]').each(function() {
|
73 |
+
$("<input type=" + type + " />").attr({ name: this.name, value: this.value, checked: this.checked}).insertBefore(this);
|
74 |
+
}).remove();
|
75 |
+
|
76 |
+
$('.classic_answer').css('display', 'block');
|
77 |
+
},
|
78 |
+
|
79 |
+
displayFreeAnswer: function() {
|
80 |
+
$('.free_answer').css('display', 'block');
|
81 |
+
},
|
82 |
+
|
83 |
+
displaySortAnswer: function() {
|
84 |
+
$('.sort_answer').css('display', 'block');
|
85 |
+
},
|
86 |
+
|
87 |
+
addAnswer: function(obj) {
|
88 |
+
$(obj).siblings('ul').children().first()
|
89 |
+
.clone().css('display', 'block')
|
90 |
+
.appendTo($(obj).siblings('ul'));
|
91 |
+
|
92 |
+
formListener.setValueClassicAnswer();
|
93 |
+
|
94 |
+
$('.deleteAnswer').click(function(e) {
|
95 |
+
formListener.deleteAnswer(this);
|
96 |
+
});
|
97 |
+
},
|
98 |
+
|
99 |
+
deleteAnswer: function(obj) {
|
100 |
+
$(obj).parent('li').remove();
|
101 |
+
|
102 |
+
formListener.setValueClassicAnswer();
|
103 |
+
},
|
104 |
+
|
105 |
+
setValueClassicAnswer: function() {
|
106 |
+
i = 0;
|
107 |
+
$('input[name="answerJson[classic_answer][correct][]"]').each(function() {
|
108 |
+
this.value = i++;
|
109 |
+
});
|
110 |
+
}
|
111 |
+
};
|
112 |
+
|
113 |
+
var validate = function () {
|
114 |
+
var title = $('input[name="title"]');
|
115 |
+
var question = tinymce.editors.question.getContent();
|
116 |
+
var type = $('input[name="answerType"]:checked');
|
117 |
+
|
118 |
+
if(isEmpty(title.val())) {
|
119 |
+
alert(wpProQuizLocalize.no_title_msg);
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
|
123 |
+
if(isEmpty(question)) {
|
124 |
+
alert(wpProQuizLocalize.no_question_msg);
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
|
128 |
+
if(type.val() == 'single' || type.val() == 'multiple') {
|
129 |
+
var findChecked = true;
|
130 |
+
if($('input[name="answerJson[classic_answer][correct][]"]:checked').each(function() {
|
131 |
+
if($.trim($(this).parent().siblings('textarea').val()) != '')
|
132 |
+
findChecked &= true;
|
133 |
+
else
|
134 |
+
findChecked = false;
|
135 |
+
})
|
136 |
+
.size() < 1) {
|
137 |
+
alert(wpProQuizLocalize.no_correct_msg);
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
|
141 |
+
if(!findChecked) {
|
142 |
+
alert(wpProQuizLocalize.no_answer_msg);
|
143 |
+
return false;
|
144 |
+
}
|
145 |
+
} else if(type.val() == 'sort_answer') {
|
146 |
+
var findChecked = false;
|
147 |
+
$('textarea[name="answerJson[answer_sort][answer][]"]').each(function() {
|
148 |
+
if(isEmpty($(this).val())) {
|
149 |
+
findChecked |= false;
|
150 |
+
} else {
|
151 |
+
findChecked = true;
|
152 |
+
}
|
153 |
+
});
|
154 |
+
|
155 |
+
if(!findChecked) {
|
156 |
+
alert(wpProQuizLocalize.no_answer_msg);
|
157 |
+
return false;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
return true;
|
162 |
+
|
163 |
+
};
|
164 |
+
|
165 |
+
var isEmpty = function(str) {
|
166 |
+
return (!str || 0 === str.length);
|
167 |
+
};
|
168 |
+
|
169 |
+
formListener.setup();
|
170 |
+
setup();
|
171 |
+
};
|
172 |
+
|
173 |
+
$.fn.wpProQuiz_questionOverall = function() {
|
174 |
+
|
175 |
+
var methode = {
|
176 |
+
saveSort: function() {
|
177 |
+
|
178 |
+
var data = {
|
179 |
+
action: 'update_sort',
|
180 |
+
sort: methode.parseSortArray()
|
181 |
+
};
|
182 |
+
|
183 |
+
var location = window.location.pathname + window.location.search;
|
184 |
+
var url = location.replace('admin.php', 'admin-ajax.php') + '&action=save_sort';
|
185 |
+
|
186 |
+
$.post(url, data, function(response) {
|
187 |
+
console.debug(response);
|
188 |
+
$('#sortMsg').show(400).delay(1000).hide(400);
|
189 |
+
});
|
190 |
+
},
|
191 |
+
|
192 |
+
parseSortArray: function() {
|
193 |
+
var array = new Array();
|
194 |
+
|
195 |
+
$('tbody tr').each(function() {
|
196 |
+
array.push(this.id.replace('wpProQuiz_questionId_', ''));
|
197 |
+
});
|
198 |
+
|
199 |
+
return array;
|
200 |
+
}
|
201 |
+
};
|
202 |
+
|
203 |
+
var init = function() {
|
204 |
+
$('.wp-list-table tbody').sortable({ handle: '.wpProQuiz_move' });
|
205 |
+
|
206 |
+
$('.wpProQuiz_delete').click(function(e) {
|
207 |
+
var b = confirm(wpProQuizLocalize.delete_msg);
|
208 |
+
|
209 |
+
if(!b) {
|
210 |
+
e.preventDefault();
|
211 |
+
return false;
|
212 |
+
}
|
213 |
+
|
214 |
+
return true;
|
215 |
+
});
|
216 |
+
|
217 |
+
$('#wpProQuiz_saveSort').click(function(e) {
|
218 |
+
e.preventDefault();
|
219 |
+
methode.saveSort();
|
220 |
+
});
|
221 |
+
|
222 |
+
console.debug($);
|
223 |
+
};
|
224 |
+
|
225 |
+
init();
|
226 |
+
};
|
227 |
+
|
228 |
+
$('.wpProQuiz_quizOverall').wpProQuiz_preview();
|
229 |
+
$('.wpProQuiz_questionEdit').wpProQuiz_questionEdit();
|
230 |
+
$('.wpProQuiz_questionOverall').wpProQuiz_questionOverall();
|
231 |
+
});
|
js/wpProQuiz_admin.min.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function(a){a.fn.wpProQuiz_preview=function(){var b={openPreview:function(b){window.open(a(b).attr("href"),"wpProQuizPreview","width=900,height=900")}};a(".wpProQuiz_prview").click(function(a){b.openPreview(this);a.preventDefault()})};a.fn.wpProQuiz_questionEdit=function(){var b={setup:function(){a('input[name="answerType"]').click(function(){a(".answer_felder").children().css("display","none");switch(this.value){case "single":b.displaySingle("radio");break;case "multiple":b.displaySingle("checkbox");
|
2 |
+
break;case "free_answer":b.displayFreeAnswer();break;case "sort_answer":b.displaySortAnswer()}});a(".addAnswer").click(function(){b.addAnswer(this)});a(".deleteAnswer").click(function(){b.deleteAnswer(this)});a("#saveQuestion").click(function(){return d()});a(".sort_answer ul, .classic_answer ul").sortable({handle:".wpProQuiz_move",update:function(){b.setValueClassicAnswer()}})},displaySingle:function(b){a(".classic_answer").find('input[name="answerJson[classic_answer][correct][]"]').each(function(){a("<input type="+
|
3 |
+
b+" />").attr({name:this.name,value:this.value,checked:this.checked}).insertBefore(this)}).remove();a(".classic_answer").css("display","block")},displayFreeAnswer:function(){a(".free_answer").css("display","block")},displaySortAnswer:function(){a(".sort_answer").css("display","block")},addAnswer:function(f){a(f).siblings("ul").children().first().clone().css("display","block").appendTo(a(f).siblings("ul"));b.setValueClassicAnswer();a(".deleteAnswer").click(function(){b.deleteAnswer(this)})},deleteAnswer:function(f){a(f).parent("li").remove();
|
4 |
+
b.setValueClassicAnswer()},setValueClassicAnswer:function(){i=0;a('input[name="answerJson[classic_answer][correct][]"]').each(function(){this.value=i++})}},d=function(){var b=a('input[name="title"]'),d=tinymce.editors.question.getContent(),g=a('input[name="answerType"]:checked');if(e(b.val()))return alert(wpProQuizLocalize.no_title_msg),!1;if(e(d))return alert(wpProQuizLocalize.no_question_msg),!1;if("single"==g.val()||"multiple"==g.val()){var c=!0;if(1>a('input[name="answerJson[classic_answer][correct][]"]:checked').each(function(){c=
|
5 |
+
""!=a.trim(a(this).parent().siblings("textarea").val())?c&1:!1}).size())return alert(wpProQuizLocalize.no_correct_msg),!1;if(!c)return alert(wpProQuizLocalize.no_answer_msg),!1}else if("sort_answer"==g.val()&&(c=!1,a('textarea[name="answerJson[answer_sort][answer][]"]').each(function(){c=e(a(this).val())?c|0:!0}),!c))return alert(wpProQuizLocalize.no_answer_msg),!1;return!0},e=function(a){return!a||0===a.length};b.setup();1>a('input[name="answerType"][checked="checked"]').size()&&a('input[name="answerType"][value="single"]').attr({checked:"checked"});
|
6 |
+
a('input[name="answerType"]:checked').click()};a.fn.wpProQuiz_questionOverall=function(){var b={saveSort:function(){var d={action:"update_sort",sort:b.parseSortArray()},e=(window.location.pathname+window.location.search).replace("admin.php","admin-ajax.php")+"&action=save_sort";a.post(e,d,function(b){console.debug(b);a("#sortMsg").show(400).delay(1E3).hide(400)})},parseSortArray:function(){var b=[];a("tbody tr").each(function(){b.push(this.id.replace("wpProQuiz_questionId_",""))});return b}};a(".wp-list-table tbody").sortable({handle:".wpProQuiz_move"});
|
7 |
+
a(".wpProQuiz_delete").click(function(a){return!confirm(wpProQuizLocalize.delete_msg)?(a.preventDefault(),!1):!0});a("#wpProQuiz_saveSort").click(function(a){a.preventDefault();b.saveSort()});console.debug(a)};a(".wpProQuiz_quizOverall").wpProQuiz_preview();a(".wpProQuiz_questionEdit").wpProQuiz_questionEdit();a(".wpProQuiz_questionOverall").wpProQuiz_questionOverall()});
|
js/wpProQuiz_front.js
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($) {
|
2 |
+
$.wpProQuizFront = function(element, options) {
|
3 |
+
var $element = $(element);
|
4 |
+
var config = options;
|
5 |
+
var plugin = this;
|
6 |
+
var points = 0;
|
7 |
+
var count = 0;
|
8 |
+
var intervalId = 0;
|
9 |
+
var startTime = 0;
|
10 |
+
|
11 |
+
plugin.methode = {
|
12 |
+
startQuiz: function() {
|
13 |
+
|
14 |
+
if(config.questionRandom) {
|
15 |
+
plugin.methode.questionRandom();
|
16 |
+
}
|
17 |
+
|
18 |
+
if(config.answerRandom) {
|
19 |
+
plugin.methode.answerRandom('.wpProQuiz_questionList');
|
20 |
+
} else {
|
21 |
+
plugin.methode.answerRandom($element.find('.wpProQuiz_sortable').parent().parent());
|
22 |
+
}
|
23 |
+
|
24 |
+
if(config.timeLimit) {
|
25 |
+
plugin.methode.setTimeLimit();
|
26 |
+
}
|
27 |
+
|
28 |
+
points = 0;
|
29 |
+
|
30 |
+
startTime = new Date();
|
31 |
+
|
32 |
+
if(config.checkAnswer) {
|
33 |
+
$element.find('input[name="check"]').show();
|
34 |
+
} else {
|
35 |
+
$element.find('input[name="next"]').show();
|
36 |
+
}
|
37 |
+
|
38 |
+
$element.find('.wpProQuiz_text').hide();
|
39 |
+
$element.find('.wpProQuiz_quiz').show();
|
40 |
+
$element.find('.wpProQuiz_listItem').first().fadeIn(200);
|
41 |
+
|
42 |
+
$element.find('.wpProQuiz_sortable').parent().parent().sortable().disableSelection();
|
43 |
+
},
|
44 |
+
|
45 |
+
reStartQuiz: function() {
|
46 |
+
$element.find('.wpProQuiz_answerCorrect').removeClass('wpProQuiz_answerCorrect');
|
47 |
+
$element.find('.wpProQuiz_answerIncorrect').removeClass('wpProQuiz_answerIncorrect');
|
48 |
+
|
49 |
+
$element.find('.wpProQuiz_text').show();
|
50 |
+
$element.find('.wpProQuiz_quiz, .wpProQuiz_results, .wpProQuiz_response, .wpProQuiz_correct, .wpProQuiz_incorrect')
|
51 |
+
.hide();
|
52 |
+
$element.find('.wpProQuiz_time_limit, .wpProQuiz_time_limit_expired, .wpProQuiz_sort_correct_answer')
|
53 |
+
.hide();
|
54 |
+
$element.find('.wpProQuiz_quiz').children().first().children().hide();
|
55 |
+
$element.find('.wpProQuiz_sortable').removeAttr('style');
|
56 |
+
$element.find('input[name="check"]').hide();
|
57 |
+
$element.find('input[name="next"]').hide();
|
58 |
+
$element.find('input[name="question"]').removeAttr('disabled').removeAttr('checked');
|
59 |
+
$element.find('input[name="question"][type="text"]').removeAttr('value');
|
60 |
+
},
|
61 |
+
|
62 |
+
setTimeLimit: function() {
|
63 |
+
var $timeLimit = $element.find('.wpProQuiz_time_limit');
|
64 |
+
var $span = $timeLimit.find('span');
|
65 |
+
var limit = config.timeLimit;
|
66 |
+
|
67 |
+
$timeLimit.css({width: '100%', display: 'block'});
|
68 |
+
$span.html(plugin.methode.parseTime(limit));
|
69 |
+
$timeLimit.find('.progress').css('width', '100%').animate({width: '0%'}, config.timeLimit * 1000);
|
70 |
+
|
71 |
+
intervalId = setInterval(function() {
|
72 |
+
$span.html(plugin.methode.parseTime(limit--));
|
73 |
+
|
74 |
+
if(limit < 0) {
|
75 |
+
clearInterval(intervalId);
|
76 |
+
intervalId = 0;
|
77 |
+
$timeLimit.find('.progress').clearQueue().stop();
|
78 |
+
$element.find('input[name="check"]').click().parent().hide();
|
79 |
+
$element.find('.wpProQuiz_time_limit_expired').show();
|
80 |
+
plugin.methode.showResult();
|
81 |
+
}
|
82 |
+
}, 1000);
|
83 |
+
},
|
84 |
+
|
85 |
+
parseTime: function(sec) {
|
86 |
+
var seconds = parseInt(sec % 60);
|
87 |
+
var minutes = parseInt((sec / 60) % 60);
|
88 |
+
var hours = parseInt((sec / 3600) % 24);
|
89 |
+
|
90 |
+
seconds = (seconds > 9 ? '' : '0') + seconds;
|
91 |
+
minutes = (minutes > 9 ? '' : '0') + minutes;
|
92 |
+
hours = (hours > 9 ? '' : '0') + hours;
|
93 |
+
|
94 |
+
return hours + ':' + minutes + ':' + seconds;
|
95 |
+
},
|
96 |
+
|
97 |
+
setQuizTime: function() {
|
98 |
+
var sec = (new Date().getTime() - startTime.getTime()) / 1000;
|
99 |
+
$element.find('.wpProQuiz_quiz_time span').first().html(plugin.methode.parseTime(sec));
|
100 |
+
},
|
101 |
+
|
102 |
+
setData: function() {
|
103 |
+
var i = 0;
|
104 |
+
$element.find('.wpProQuiz_questionList').each(function() {
|
105 |
+
var j = config.json[i];
|
106 |
+
var ii = 0;
|
107 |
+
$(this).parent().parent().data('type', j.answer_type);
|
108 |
+
$(this).find('input[name="question"]').each(function() {
|
109 |
+
switch(j.answer_type) {
|
110 |
+
case 'single':
|
111 |
+
case 'multiple':
|
112 |
+
if($.inArray(this.value, j.correct) >= 0) {
|
113 |
+
$(this).data('correct', '1');
|
114 |
+
} else {
|
115 |
+
$(this).data('correct', '0');
|
116 |
+
}
|
117 |
+
break;
|
118 |
+
case 'free_answer':
|
119 |
+
$(this).data('correct', j.correct);
|
120 |
+
break;
|
121 |
+
}
|
122 |
+
});
|
123 |
+
|
124 |
+
$(this).find('.wpProQuiz_sortable').each(function() {
|
125 |
+
$(this).data('correct', j.correct[ii++]);
|
126 |
+
});
|
127 |
+
|
128 |
+
i++;
|
129 |
+
});
|
130 |
+
},
|
131 |
+
|
132 |
+
checkAnswer: function(btn) {
|
133 |
+
var $question = $(btn).parent();
|
134 |
+
var correct = false;
|
135 |
+
var checked = $question.find('input[name="question"]');
|
136 |
+
var type = $question.data('type');
|
137 |
+
|
138 |
+
if(type == 'multiple' || type == 'single') {
|
139 |
+
var check = true;
|
140 |
+
|
141 |
+
checked.each(function() {
|
142 |
+
if($(this).data('correct') == '1') {
|
143 |
+
$(this).parent().parent().addClass('wpProQuiz_answerCorrect');
|
144 |
+
|
145 |
+
if(this.checked)
|
146 |
+
check &= true;
|
147 |
+
else
|
148 |
+
check &= false;
|
149 |
+
} else {
|
150 |
+
if(this.checked) {
|
151 |
+
$(this).parent().parent().addClass('wpProQuiz_answerIncorrect');
|
152 |
+
check &= false;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
});
|
156 |
+
|
157 |
+
correct = check;
|
158 |
+
|
159 |
+
} else if(type == 'sort_answer') {
|
160 |
+
var check = true;
|
161 |
+
|
162 |
+
$question.find('.wpProQuiz_sortable').each(function() {
|
163 |
+
var $div = $(this);
|
164 |
+
var index = $div.parent().index();
|
165 |
+
var correct = $div.data('correct');
|
166 |
+
|
167 |
+
if(correct == index) {
|
168 |
+
$div.parent().addClass('wpProQuiz_answerCorrect');
|
169 |
+
check &= true;
|
170 |
+
} else {
|
171 |
+
$div.parent().addClass('wpProQuiz_answerIncorrect');
|
172 |
+
check = false;
|
173 |
+
}
|
174 |
+
|
175 |
+
$div.parent().parent().sortable("destroy");
|
176 |
+
$div.css({'box-shadow': '0 0', 'cursor': 'auto'});
|
177 |
+
});
|
178 |
+
|
179 |
+
var list = $question.find('.wpProQuiz_sortable').parent().parent();
|
180 |
+
var items = list.children('li');
|
181 |
+
|
182 |
+
items.sort(function(a, b) {
|
183 |
+
return $(a).children('div').data('correct') > $(b).children('div').data('correct');
|
184 |
+
});
|
185 |
+
|
186 |
+
$.each(items, function(idx, itm) { list.append(itm); });
|
187 |
+
|
188 |
+
correct = check;
|
189 |
+
|
190 |
+
} else if(type == 'free_answer') {
|
191 |
+
var value = $.trim(checked.val()).toLowerCase();
|
192 |
+
|
193 |
+
if($.inArray(value, checked.data('correct')) >= 0) {
|
194 |
+
correct = true;
|
195 |
+
checked.parent().parent().addClass('wpProQuiz_answerCorrect');
|
196 |
+
} else {
|
197 |
+
checked.parent().parent().addClass('wpProQuiz_answerIncorrect');
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
$(btn).hide();
|
202 |
+
checked.attr('disabled', 'disabled');
|
203 |
+
|
204 |
+
$question.find('.wpProQuiz_response').show();
|
205 |
+
|
206 |
+
if(correct) {
|
207 |
+
$question.find('.wpProQuiz_correct').show();
|
208 |
+
points++;
|
209 |
+
} else {
|
210 |
+
$question.find('.wpProQuiz_incorrect').show();
|
211 |
+
}
|
212 |
+
|
213 |
+
$question.find('input[name="next"]').show();
|
214 |
+
},
|
215 |
+
|
216 |
+
nextQuestion: function(btn) {
|
217 |
+
var $q = $(btn).parent();
|
218 |
+
var $next = $q.next();
|
219 |
+
$q.hide();
|
220 |
+
|
221 |
+
if($next.length) {
|
222 |
+
$next.show();
|
223 |
+
|
224 |
+
if(config.backButton && !config.checkAnswer)
|
225 |
+
$next.find('input[name="back"]').show();
|
226 |
+
} else {
|
227 |
+
if(!config.checkAnswer)
|
228 |
+
$element.find('input[name="check"]').click();
|
229 |
+
|
230 |
+
plugin.methode.showResult();
|
231 |
+
}
|
232 |
+
},
|
233 |
+
|
234 |
+
backQuestion: function(btn) {
|
235 |
+
var $q = $(btn).parent();
|
236 |
+
var $prev = $q.prev();
|
237 |
+
|
238 |
+
$q.hide();
|
239 |
+
$prev.show();
|
240 |
+
},
|
241 |
+
|
242 |
+
showResult: function() {
|
243 |
+
clearInterval(intervalId);
|
244 |
+
|
245 |
+
$element.find('.wpProQuiz_time_limit .progress').clearQueue().stop();
|
246 |
+
$element.find('.wpProQuiz_points').html(points);
|
247 |
+
$element.find('.wpProQuiz_points_prozent').html('(' + Math.round(points / count * 100) + '%)');
|
248 |
+
$element.find('.wpProQuiz_results').show();
|
249 |
+
$element.find('.wpProQuiz_time_limit').hide();
|
250 |
+
plugin.methode.setQuizTime();
|
251 |
+
},
|
252 |
+
|
253 |
+
reShowQuestion: function() {
|
254 |
+
$element.find('input[name="next"], input[name="check"], input[name="back"]').hide();
|
255 |
+
$element.find('.wpProQuiz_quiz').children().first().children().show();
|
256 |
+
},
|
257 |
+
|
258 |
+
answerRandom: function(selector) {
|
259 |
+
$element.find(selector).each(function() {
|
260 |
+
var answer = $(this).children();
|
261 |
+
|
262 |
+
var el = answer.sort(function() {
|
263 |
+
return Math.round(Math.random())-0.5;
|
264 |
+
}).slice(0, answer.length);
|
265 |
+
|
266 |
+
$(el).appendTo(el[0].parentNode).show();
|
267 |
+
});
|
268 |
+
},
|
269 |
+
|
270 |
+
questionRandom: function() {
|
271 |
+
var answer = $element.find('.wpProQuiz_quiz ol').children();
|
272 |
+
|
273 |
+
var el = answer.sort(function() {
|
274 |
+
return Math.round(Math.random())-0.5;
|
275 |
+
}).slice(0, answer.length);
|
276 |
+
|
277 |
+
$(el).appendTo(el[0].parentNode);
|
278 |
+
|
279 |
+
var i = 1;
|
280 |
+
$(el).each(function() {
|
281 |
+
$(this).find('.wpProQuiz_question_page span').eq(0).html(i);
|
282 |
+
$(this).find('h3 span').html(i++);
|
283 |
+
});
|
284 |
+
}
|
285 |
+
};
|
286 |
+
|
287 |
+
plugin.init = function() {
|
288 |
+
points = 0;
|
289 |
+
|
290 |
+
$element.find('.wpProQuiz_quiz, .wpProQuiz_results').hide();
|
291 |
+
|
292 |
+
var li = $element.find('.wpProQuiz_quiz').children().first().children();
|
293 |
+
|
294 |
+
li.hide();
|
295 |
+
|
296 |
+
count = li.length;
|
297 |
+
|
298 |
+
plugin.methode.setData();
|
299 |
+
|
300 |
+
$element.find('input[name="startQuiz"]').click(function(e) {
|
301 |
+
e.preventDefault();
|
302 |
+
plugin.methode.startQuiz();
|
303 |
+
});
|
304 |
+
|
305 |
+
$element.find('input[name="check"]').click(function(e) {
|
306 |
+
e.preventDefault();
|
307 |
+
plugin.methode.checkAnswer(this);
|
308 |
+
});
|
309 |
+
|
310 |
+
$element.find('input[name="next"]').click(function(e) {
|
311 |
+
e.preventDefault();
|
312 |
+
plugin.methode.nextQuestion(this);
|
313 |
+
});
|
314 |
+
|
315 |
+
$element.find('input[name="restartQuiz"]').click(function(e) {
|
316 |
+
e.preventDefault();
|
317 |
+
plugin.methode.reStartQuiz();
|
318 |
+
});
|
319 |
+
|
320 |
+
$element.find('input[name="reShowQuestion"]').click(function(e) {
|
321 |
+
e.preventDefault();
|
322 |
+
plugin.methode.reShowQuestion(this);
|
323 |
+
});
|
324 |
+
|
325 |
+
$element.find('input[name="back"]').click(function(e) {
|
326 |
+
plugin.methode.backQuestion(this);
|
327 |
+
});
|
328 |
+
};
|
329 |
+
|
330 |
+
plugin.init();
|
331 |
+
};
|
332 |
+
|
333 |
+
$.fn.wpProQuizFront = function(options) {
|
334 |
+
return this.each(function() {
|
335 |
+
if(undefined == $(this).data('wpProQuizFront')) {
|
336 |
+
$(this).data('wpProQuizFront', new $.wpProQuizFront(this, options));
|
337 |
+
}
|
338 |
+
});
|
339 |
+
};
|
340 |
+
})(jQuery);
|
js/wpProQuiz_front.min.js
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function(b){b.wpProQuizFront=function(k,e){var a=b(k),c=this,j=0,l=0,h=0,m=0;c.methode={startQuiz:function(){e.questionRandom&&c.methode.questionRandom();e.answerRandom?c.methode.answerRandom(".wpProQuiz_questionList"):c.methode.answerRandom(a.find(".wpProQuiz_sortable").parent().parent());e.timeLimit&&c.methode.setTimeLimit();j=0;m=new Date;e.checkAnswer?a.find('input[name="check"]').show():a.find('input[name="next"]').show();a.find(".wpProQuiz_text").hide();a.find(".wpProQuiz_quiz").show();a.find(".wpProQuiz_listItem").first().fadeIn(200);
|
2 |
+
a.find(".wpProQuiz_sortable").parent().parent().sortable().disableSelection()},reStartQuiz:function(){a.find(".wpProQuiz_answerCorrect").removeClass("wpProQuiz_answerCorrect");a.find(".wpProQuiz_answerIncorrect").removeClass("wpProQuiz_answerIncorrect");a.find(".wpProQuiz_text").show();a.find(".wpProQuiz_quiz, .wpProQuiz_results, .wpProQuiz_response, .wpProQuiz_correct, .wpProQuiz_incorrect").hide();a.find(".wpProQuiz_time_limit, .wpProQuiz_time_limit_expired, .wpProQuiz_sort_correct_answer").hide();
|
3 |
+
a.find(".wpProQuiz_quiz").children().first().children().hide();a.find(".wpProQuiz_sortable").removeAttr("style");a.find('input[name="check"]').hide();a.find('input[name="next"]').hide();a.find('input[name="question"]').removeAttr("disabled").removeAttr("checked");a.find('input[name="question"][type="text"]').removeAttr("value")},setTimeLimit:function(){var f=a.find(".wpProQuiz_time_limit"),d=f.find("span"),b=e.timeLimit;f.css({width:"100%",display:"block"});d.html(c.methode.parseTime(b));f.find(".progress").css("width",
|
4 |
+
"100%").animate({width:"0%"},1E3*e.timeLimit);h=setInterval(function(){d.html(c.methode.parseTime(b--));0>b&&(clearInterval(h),h=0,f.find(".progress").clearQueue().stop(),a.find('input[name="check"]').click().parent().hide(),a.find(".wpProQuiz_time_limit_expired").show(),c.methode.showResult())},1E3)},parseTime:function(a){var d=parseInt(a%60),b=parseInt(a/60%60),a=parseInt(a/3600%24);return(9<a?"":"0")+a+":"+((9<b?"":"0")+b)+":"+((9<d?"":"0")+d)},setQuizTime:function(){var b=((new Date).getTime()-
|
5 |
+
m.getTime())/1E3;a.find(".wpProQuiz_quiz_time span").first().html(c.methode.parseTime(b))},setData:function(){var f=0;a.find(".wpProQuiz_questionList").each(function(){var a=e.json[f],c=0;b(this).parent().parent().data("type",a.answer_type);b(this).find('input[name="question"]').each(function(){switch(a.answer_type){case "single":case "multiple":0<=b.inArray(this.value,a.correct)?b(this).data("correct","1"):b(this).data("correct","0");break;case "free_answer":b(this).data("correct",a.correct)}});
|
6 |
+
b(this).find(".wpProQuiz_sortable").each(function(){b(this).data("correct",a.correct[c++])});f++})},checkAnswer:function(a){var d=b(a).parent(),c=!1,e=d.find('input[name="question"]'),i=d.data("type");if("multiple"==i||"single"==i){var g=!0;e.each(function(){"1"==b(this).data("correct")?(b(this).parent().parent().addClass("wpProQuiz_answerCorrect"),g=this.checked?g&1:g&0):this.checked&&(b(this).parent().parent().addClass("wpProQuiz_answerIncorrect"),g&=0)});c=g}else if("sort_answer"==i){g=!0;d.find(".wpProQuiz_sortable").each(function(){var a=
|
7 |
+
b(this),d=a.parent().index();a.data("correct")==d?(a.parent().addClass("wpProQuiz_answerCorrect"),g&=1):(a.parent().addClass("wpProQuiz_answerIncorrect"),g=!1);a.parent().parent().sortable("destroy");a.css({"box-shadow":"0 0",cursor:"auto"})});var h=d.find(".wpProQuiz_sortable").parent().parent(),c=h.children("li");c.sort(function(a,d){return b(a).children("div").data("correct")>b(d).children("div").data("correct")});b.each(c,function(a,d){h.append(d)});c=g}else"free_answer"==i&&(i=b.trim(e.val()).toLowerCase(),
|
8 |
+
0<=b.inArray(i,e.data("correct"))?(c=!0,e.parent().parent().addClass("wpProQuiz_answerCorrect")):e.parent().parent().addClass("wpProQuiz_answerIncorrect"));b(a).hide();e.attr("disabled","disabled");d.find(".wpProQuiz_response").show();c?(d.find(".wpProQuiz_correct").show(),j++):d.find(".wpProQuiz_incorrect").show();d.find('input[name="next"]').show()},nextQuestion:function(f){var f=b(f).parent(),d=f.next();f.hide();d.length?(d.show(),e.backButton&&!e.checkAnswer&&d.find('input[name="back"]').show()):
|
9 |
+
(e.checkAnswer||a.find('input[name="check"]').click(),c.methode.showResult())},backQuestion:function(a){var a=b(a).parent(),d=a.prev();a.hide();d.show()},showResult:function(){clearInterval(h);a.find(".wpProQuiz_time_limit .progress").clearQueue().stop();a.find(".wpProQuiz_points").html(j);a.find(".wpProQuiz_points_prozent").html("("+Math.round(100*(j/l))+"%)");a.find(".wpProQuiz_results").show();a.find(".wpProQuiz_time_limit").hide();c.methode.setQuizTime()},reShowQuestion:function(){a.find('input[name="next"], input[name="check"], input[name="back"]').hide();
|
10 |
+
a.find(".wpProQuiz_quiz").children().first().children().show()},answerRandom:function(c){a.find(c).each(function(){var a=b(this).children(),a=a.sort(function(){return Math.round(Math.random())-0.5}).slice(0,a.length);b(a).appendTo(a[0].parentNode).show()})},questionRandom:function(){var c=a.find(".wpProQuiz_quiz ol").children(),c=c.sort(function(){return Math.round(Math.random())-0.5}).slice(0,c.length);b(c).appendTo(c[0].parentNode);var d=1;b(c).each(function(){b(this).find(".wpProQuiz_question_page span").eq(0).html(d);
|
11 |
+
b(this).find("h3 span").html(d++)})}};c.init=function(){j=0;a.find(".wpProQuiz_quiz, .wpProQuiz_results").hide();var b=a.find(".wpProQuiz_quiz").children().first().children();b.hide();l=b.length;c.methode.setData();a.find('input[name="startQuiz"]').click(function(a){a.preventDefault();c.methode.startQuiz()});a.find('input[name="check"]').click(function(a){a.preventDefault();c.methode.checkAnswer(this)});a.find('input[name="next"]').click(function(a){a.preventDefault();c.methode.nextQuestion(this)});
|
12 |
+
a.find('input[name="restartQuiz"]').click(function(a){a.preventDefault();c.methode.reStartQuiz()});a.find('input[name="reShowQuestion"]').click(function(a){a.preventDefault();c.methode.reShowQuestion(this)});a.find('input[name="back"]').click(function(){c.methode.backQuestion(this)})};c.init()};b.fn.wpProQuizFront=function(k){return this.each(function(){void 0==b(this).data("wpProQuizFront")&&b(this).data("wpProQuizFront",new b.wpProQuizFront(this,k))})}})(jQuery);
|
languages/wp-pro-quiz-de_DE.mo
ADDED
Binary file
|
languages/wp-pro-quiz-de_DE.po
ADDED
@@ -0,0 +1,374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Wp-Pro-Quiz\n"
|
4 |
+
"POT-Creation-Date: 2012-11-10 13:55+0100\n"
|
5 |
+
"PO-Revision-Date: 2012-11-10 16:40+0100\n"
|
6 |
+
"Last-Translator: Julius Fischer <julius.f@gmx.net>\n"
|
7 |
+
"Language-Team: Julius Fischer\n"
|
8 |
+
"Language: German\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.5.4\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
14 |
+
"X-Poedit-Basepath: ..\n"
|
15 |
+
"X-Poedit-SearchPath-0: .\n"
|
16 |
+
|
17 |
+
#: lib/controller/WpProQuiz_Controller_Admin.php:21
|
18 |
+
msgid "Do you really want to delete the quiz/question?"
|
19 |
+
msgstr "Wollen Sie das Quiz/Frage wirklich löschen?"
|
20 |
+
|
21 |
+
#: lib/controller/WpProQuiz_Controller_Admin.php:22
|
22 |
+
msgid "Title is not filled!"
|
23 |
+
msgstr "Titel wurde nicht ausgefüllt!"
|
24 |
+
|
25 |
+
#: lib/controller/WpProQuiz_Controller_Admin.php:23
|
26 |
+
msgid "No question deposited!"
|
27 |
+
msgstr "Keine Frage hinterlegt!"
|
28 |
+
|
29 |
+
#: lib/controller/WpProQuiz_Controller_Admin.php:24
|
30 |
+
msgid "Correct answer was not selected!"
|
31 |
+
msgstr "Keine korrekte Antwort markiert!"
|
32 |
+
|
33 |
+
#: lib/controller/WpProQuiz_Controller_Admin.php:25
|
34 |
+
msgid "No answer deposited!"
|
35 |
+
msgstr "Keine Antwort hinterlegt!"
|
36 |
+
|
37 |
+
#: lib/controller/WpProQuiz_Controller_Question.php:52
|
38 |
+
msgid "Edit question"
|
39 |
+
msgstr "Frage bearbeiten"
|
40 |
+
|
41 |
+
#: lib/controller/WpProQuiz_Controller_Question.php:59
|
42 |
+
msgid "Question edited"
|
43 |
+
msgstr "Frage geändert"
|
44 |
+
|
45 |
+
#: lib/controller/WpProQuiz_Controller_Question.php:68
|
46 |
+
msgid "New question"
|
47 |
+
msgstr "Neue Frage"
|
48 |
+
|
49 |
+
#: lib/controller/WpProQuiz_Controller_Question.php:77
|
50 |
+
msgid "Question added"
|
51 |
+
msgstr "Frage hinzugefügt"
|
52 |
+
|
53 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:37
|
54 |
+
msgid "Edit quiz"
|
55 |
+
msgstr "Quiz bearbeiten"
|
56 |
+
|
57 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:44
|
58 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:73
|
59 |
+
msgid "Quiz title or quiz description are not filled"
|
60 |
+
msgstr "Quiz Titel oder Quiz Beschreibung nicht ausgefüllt"
|
61 |
+
|
62 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:49
|
63 |
+
msgid "Not all fields are filled"
|
64 |
+
msgstr "Nicht alle Felder ausgefüllt"
|
65 |
+
|
66 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:61
|
67 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:67
|
68 |
+
msgid "Create quiz"
|
69 |
+
msgstr "Quiz erstellen"
|
70 |
+
|
71 |
+
#: lib/controller/WpProQuiz_Controller_Quiz.php:85
|
72 |
+
msgid "Quiz deleted"
|
73 |
+
msgstr "Quiz gelöscht"
|
74 |
+
|
75 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:51
|
76 |
+
msgid "Start quiz"
|
77 |
+
msgstr "Quiz starten"
|
78 |
+
|
79 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:55
|
80 |
+
msgid "Results"
|
81 |
+
msgstr "Ergebnis"
|
82 |
+
|
83 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:57
|
84 |
+
#, php-format
|
85 |
+
msgid "%s from %s questions answered correctly"
|
86 |
+
msgstr "%s von %s Frage korrekt beantwortet"
|
87 |
+
|
88 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:60
|
89 |
+
msgid "Time has elapsed"
|
90 |
+
msgstr "Zeit ist abgelaufen"
|
91 |
+
|
92 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:63
|
93 |
+
msgid "Your time: <span></span>"
|
94 |
+
msgstr "Ihre Zeit: <span></span>"
|
95 |
+
|
96 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:69
|
97 |
+
msgid "Restart quiz"
|
98 |
+
msgstr "Quiz erneut starten"
|
99 |
+
|
100 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:70
|
101 |
+
msgid "View question"
|
102 |
+
msgstr "Frage ansehen"
|
103 |
+
|
104 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:74
|
105 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:72
|
106 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:77
|
107 |
+
msgid "Time limit"
|
108 |
+
msgstr "Zeitlimit"
|
109 |
+
|
110 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:86
|
111 |
+
#, php-format
|
112 |
+
msgid "Question %s from %s"
|
113 |
+
msgstr "Frage %s von %s"
|
114 |
+
|
115 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:88
|
116 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:23
|
117 |
+
msgid "Question"
|
118 |
+
msgstr "Frage"
|
119 |
+
|
120 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:132
|
121 |
+
msgid "Right"
|
122 |
+
msgstr "Richtig"
|
123 |
+
|
124 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:140
|
125 |
+
msgid "Wrong"
|
126 |
+
msgstr "Falsch"
|
127 |
+
|
128 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:147
|
129 |
+
msgid "Check"
|
130 |
+
msgstr "Prüfen"
|
131 |
+
|
132 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:148
|
133 |
+
msgid "Back"
|
134 |
+
msgstr "Zurück"
|
135 |
+
|
136 |
+
#: lib/view/WpProQuiz_View_FrontQuiz.php:149
|
137 |
+
msgid "Next exercise"
|
138 |
+
msgstr "Nächste Frage"
|
139 |
+
|
140 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:13
|
141 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:9
|
142 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:8
|
143 |
+
msgid "back to overview"
|
144 |
+
msgstr "zurück zur Übersicht"
|
145 |
+
|
146 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:17
|
147 |
+
msgid "Title"
|
148 |
+
msgstr "Titel"
|
149 |
+
|
150 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:31
|
151 |
+
msgid "Message with the correct answer"
|
152 |
+
msgstr "Nachricht bei korrekter Antwort"
|
153 |
+
|
154 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:39
|
155 |
+
msgid "Message with the incorrect answer"
|
156 |
+
msgstr "Nachricht bei inkorrekter Antwort"
|
157 |
+
|
158 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:47
|
159 |
+
msgid "Answer type"
|
160 |
+
msgstr "Antwort Typ?"
|
161 |
+
|
162 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:55
|
163 |
+
msgid "Single choice"
|
164 |
+
msgstr "Single choice"
|
165 |
+
|
166 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:59
|
167 |
+
msgid "Multiple choice"
|
168 |
+
msgstr "Multiple choice"
|
169 |
+
|
170 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:63
|
171 |
+
msgid "\"Free\" choice"
|
172 |
+
msgstr "\"Free\" choice"
|
173 |
+
|
174 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:67
|
175 |
+
msgid "\"Sorting\" choice"
|
176 |
+
msgstr "\"Sorting\" choice"
|
177 |
+
|
178 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:72
|
179 |
+
msgid "Answers"
|
180 |
+
msgstr "Antworten"
|
181 |
+
|
182 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:81
|
183 |
+
msgid ""
|
184 |
+
"korrect answers (one per line) (answers will be converted to lower case)"
|
185 |
+
msgstr ""
|
186 |
+
"Korrekte Antworten (eine pro Zeile ) (Antworten werden in Kleinbuchstaben "
|
187 |
+
"umgewandelt)"
|
188 |
+
|
189 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:87
|
190 |
+
msgid ""
|
191 |
+
"Please sort the answers in right order with the \"Move\" - Button. The "
|
192 |
+
"answers will be displayed in right order later."
|
193 |
+
msgstr ""
|
194 |
+
"Bitte Fragen mit dem \"Verschiebe\"-Button in die richtige Reihenfolge "
|
195 |
+
"bringen. Die Fragen werden später immer sortiert ausgegeben."
|
196 |
+
|
197 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:93
|
198 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:105
|
199 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:115
|
200 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:134
|
201 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:150
|
202 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:164
|
203 |
+
msgid "Delete question"
|
204 |
+
msgstr "Frage löschen"
|
205 |
+
|
206 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:94
|
207 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:106
|
208 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:116
|
209 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:135
|
210 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:151
|
211 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:165
|
212 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:26
|
213 |
+
msgid "Move"
|
214 |
+
msgstr "Verschieben"
|
215 |
+
|
216 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:96
|
217 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:108
|
218 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:118
|
219 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:137
|
220 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:153
|
221 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:167
|
222 |
+
msgid "Allow HTML"
|
223 |
+
msgstr "HTML erlauben"
|
224 |
+
|
225 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:124
|
226 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:173
|
227 |
+
msgid "add new question"
|
228 |
+
msgstr "neue Frage hinzufügen"
|
229 |
+
|
230 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:132
|
231 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:148
|
232 |
+
#: lib/view/WpProQuiz_View_QuestionEdit.php:162
|
233 |
+
msgid "correct?"
|
234 |
+
msgstr "Korrekt?"
|
235 |
+
|
236 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:8
|
237 |
+
msgid "Questions sorted"
|
238 |
+
msgstr "Fragen sortiert"
|
239 |
+
|
240 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:13
|
241 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:14
|
242 |
+
msgid "Name"
|
243 |
+
msgstr "Name"
|
244 |
+
|
245 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:14
|
246 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:15
|
247 |
+
msgid "Action"
|
248 |
+
msgstr "Aktion"
|
249 |
+
|
250 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:24
|
251 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:28
|
252 |
+
msgid "Edit"
|
253 |
+
msgstr "Bearbeiten"
|
254 |
+
|
255 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:25
|
256 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:29
|
257 |
+
msgid "Delete"
|
258 |
+
msgstr "Löschen"
|
259 |
+
|
260 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:33
|
261 |
+
msgid "Add question"
|
262 |
+
msgstr "Frage hinzufügen"
|
263 |
+
|
264 |
+
#: lib/view/WpProQuiz_View_QuestionOverall.php:34
|
265 |
+
msgid "Save order"
|
266 |
+
msgstr "Sortierung speichern"
|
267 |
+
|
268 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:12
|
269 |
+
msgid "Quiz title"
|
270 |
+
msgstr "Quiz Titel"
|
271 |
+
|
272 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:18
|
273 |
+
msgid "Options"
|
274 |
+
msgstr "Optionen"
|
275 |
+
|
276 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:24
|
277 |
+
msgid "Hide quiz title"
|
278 |
+
msgstr "Quiz Titel verstecken"
|
279 |
+
|
280 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:29
|
281 |
+
msgid "Hide title"
|
282 |
+
msgstr "Titel verstecken"
|
283 |
+
|
284 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:35
|
285 |
+
msgid "The title serves as quiz heading."
|
286 |
+
msgstr "Der Titel dient als Quiz Überschrift."
|
287 |
+
|
288 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:42
|
289 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:47
|
290 |
+
msgid "Display question randomly"
|
291 |
+
msgstr "Fragen zufällig ausgeben"
|
292 |
+
|
293 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:57
|
294 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:62
|
295 |
+
msgid "Display answers randomly"
|
296 |
+
msgstr "Antworten zufällig ausgeben"
|
297 |
+
|
298 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:80
|
299 |
+
msgid "Seconds"
|
300 |
+
msgstr "Sekunden"
|
301 |
+
|
302 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:83
|
303 |
+
msgid "0 = no limit"
|
304 |
+
msgstr "0 = Kein Limit"
|
305 |
+
|
306 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:90
|
307 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:95
|
308 |
+
msgid "Check -> continue"
|
309 |
+
msgstr "Prüfen -> Weiter"
|
310 |
+
|
311 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:101
|
312 |
+
msgid ""
|
313 |
+
"Show \"right or wrong\" after the question. Otherwise the solutions will be "
|
314 |
+
"displayed at the end."
|
315 |
+
msgstr ""
|
316 |
+
"Zeigt \"richtig oder falsch\" nach jeder Frage an. Ansonsten werden die "
|
317 |
+
"Lösungen erst am Ende angezeigt."
|
318 |
+
|
319 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:108
|
320 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:113
|
321 |
+
msgid "Back button"
|
322 |
+
msgstr "Zurück Button"
|
323 |
+
|
324 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:119
|
325 |
+
msgid ""
|
326 |
+
"Allow to use back button in a question. (Option will be ignored if \"Check -"
|
327 |
+
"> Continue\" was used)"
|
328 |
+
msgstr ""
|
329 |
+
"Ermöglicht das Zurückgehen einer Frage. (Option wird ignoriert bei \"Prüfen -"
|
330 |
+
"> Weiter\")"
|
331 |
+
|
332 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:129
|
333 |
+
msgid "Quiz description"
|
334 |
+
msgstr "Quiz Beschreibung"
|
335 |
+
|
336 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:132
|
337 |
+
msgid "This text will be displayed before start of the quiz."
|
338 |
+
msgstr "Dieser Text wird vor dem Starten des Quizes angezeigt."
|
339 |
+
|
340 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:140
|
341 |
+
msgid "Results text"
|
342 |
+
msgstr "Ergebnis Text"
|
343 |
+
|
344 |
+
#: lib/view/WpProQuiz_View_QuizEdit.php:143
|
345 |
+
msgid ""
|
346 |
+
"This text will be displayed at the end of the quiz (in results). (this text "
|
347 |
+
"is optional)"
|
348 |
+
msgstr ""
|
349 |
+
"Dieser Text wird beim Beenden (im Ergebnis) des Quizes angezeigt (Dieser "
|
350 |
+
"Text ist optional)"
|
351 |
+
|
352 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:8
|
353 |
+
msgid "Quiz overview"
|
354 |
+
msgstr "Quiz Übersicht"
|
355 |
+
|
356 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:12
|
357 |
+
msgid "ID"
|
358 |
+
msgstr "ID"
|
359 |
+
|
360 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:13
|
361 |
+
msgid "Shortcode"
|
362 |
+
msgstr "Shortcode"
|
363 |
+
|
364 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:27
|
365 |
+
msgid "Questions"
|
366 |
+
msgstr "Fragen"
|
367 |
+
|
368 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:30
|
369 |
+
msgid "Preview"
|
370 |
+
msgstr "Vorschau"
|
371 |
+
|
372 |
+
#: lib/view/WpProQuiz_View_QuizOverall.php:37
|
373 |
+
msgid "Add quiz"
|
374 |
+
msgstr "Quiz hinzufügen"
|
lib/controller/WpProQuiz_Controller_Admin.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Controller_Admin {
|
3 |
+
|
4 |
+
private $_plugin_dir;
|
5 |
+
private $_plugin_file;
|
6 |
+
|
7 |
+
public function __construct($plugin_dir) {
|
8 |
+
spl_autoload_register(array($this, 'autoload'));
|
9 |
+
|
10 |
+
$this->_plugin_dir = $plugin_dir;
|
11 |
+
$this->_plugin_file = $this->_plugin_dir.'/wp-pro-quiz.php';
|
12 |
+
|
13 |
+
add_action('admin_init', array($this, 'upgradePlugin'));
|
14 |
+
add_action('wp_ajax_update_sort', array($this, 'route') );
|
15 |
+
add_action('admin_menu', array($this, 'register_page'));
|
16 |
+
add_action('admin_enqueue_scripts', array($this, 'enqueueScript') );
|
17 |
+
}
|
18 |
+
|
19 |
+
private function localizeScript() {
|
20 |
+
$translation_array = array(
|
21 |
+
'delete_msg' => __('Do you really want to delete the quiz/question?', 'wp-pro-quiz'),
|
22 |
+
'no_title_msg' => __('Title is not filled!', 'wp-pro-quiz'),
|
23 |
+
'no_question_msg' => __('No question deposited!', 'wp-pro-quiz'),
|
24 |
+
'no_correct_msg' => __('Correct answer was not selected!', 'wp-pro-quiz'),
|
25 |
+
'no_answer_msg' => __('No answer deposited!', 'wp-pro-quiz')
|
26 |
+
);
|
27 |
+
|
28 |
+
wp_localize_script('wpProQuiz_admin_javascript', 'wpProQuizLocalize', $translation_array);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function enqueueScript() {
|
32 |
+
|
33 |
+
wp_enqueue_script('jquery');
|
34 |
+
wp_enqueue_script('jquery-ui-sortable');
|
35 |
+
wp_enqueue_script('wpProQuiz_admin_javascript', plugins_url('js/wpProQuiz_admin.min.js', $this->_plugin_file));
|
36 |
+
$this->localizeScript();
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
public function upgradePlugin() {
|
41 |
+
$db = new WpProQuiz_Helper_DbUpgrade();
|
42 |
+
$v = $db->upgrade(get_option('wpProQuiz_dbVersion', false));
|
43 |
+
|
44 |
+
add_option('wpProQuiz_dbVersion', $v);
|
45 |
+
}
|
46 |
+
|
47 |
+
public static function install() {
|
48 |
+
$db = new WpProQuiz_Helper_DbUpgrade();
|
49 |
+
$v = $db->upgrade(get_option('wpProQuiz_dbVersion', false));
|
50 |
+
|
51 |
+
add_option('wpProQuiz_dbVersion', $v);
|
52 |
+
}
|
53 |
+
|
54 |
+
public function register_page() {
|
55 |
+
add_menu_page(
|
56 |
+
'WP-Pro-Quiz',
|
57 |
+
'WP-Pro-Quiz',
|
58 |
+
'administrator',
|
59 |
+
'wpProQuiz',
|
60 |
+
array($this, 'route'));
|
61 |
+
}
|
62 |
+
|
63 |
+
public function route() {
|
64 |
+
$_POST = stripslashes_deep($_POST);
|
65 |
+
|
66 |
+
$module = isset($_GET['module']) ? $_GET['module'] : 'overallView';
|
67 |
+
switch ($module) {
|
68 |
+
case 'overallView':
|
69 |
+
new WpProQuiz_Controller_Quiz();
|
70 |
+
break;
|
71 |
+
case 'question':
|
72 |
+
new WpProQuiz_Controller_Question();
|
73 |
+
break;
|
74 |
+
case 'preview':
|
75 |
+
new WpProQuiz_Controller_Preview($this->_plugin_file);
|
76 |
+
break;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
public function autoload($class) {
|
81 |
+
$c = explode("_", $class);
|
82 |
+
|
83 |
+
if($c === false || count($c) != 3 || $c[0] !== 'WpProQuiz')
|
84 |
+
return;
|
85 |
+
|
86 |
+
$dir = '';
|
87 |
+
|
88 |
+
switch ($c[1]) {
|
89 |
+
case 'View':
|
90 |
+
$dir = 'view';
|
91 |
+
break;
|
92 |
+
case 'Model':
|
93 |
+
$dir = 'model';
|
94 |
+
break;
|
95 |
+
case 'Helper':
|
96 |
+
$dir = 'helper';
|
97 |
+
break;
|
98 |
+
case 'Controller':
|
99 |
+
$dir = 'controller';
|
100 |
+
break;
|
101 |
+
}
|
102 |
+
|
103 |
+
if(file_exists($this->_plugin_dir.'/lib/'.$dir.'/'.$class.'.php'))
|
104 |
+
include_once $this->_plugin_dir.'/lib/'.$dir.'/'.$class.'.php';
|
105 |
+
}
|
106 |
+
}
|
lib/controller/WpProQuiz_Controller_Front.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Controller_Front {
|
3 |
+
|
4 |
+
private $_plugin_dir;
|
5 |
+
private $_plugin_file;
|
6 |
+
|
7 |
+
public function __construct($plugin_dir) {
|
8 |
+
$this->_plugin_dir = $plugin_dir;
|
9 |
+
$this->_plugin_file = $this->_plugin_dir.'/wp-pro-quiz.php';
|
10 |
+
|
11 |
+
spl_autoload_register(array($this, 'autoload'));
|
12 |
+
|
13 |
+
add_action('wp_enqueue_scripts', array($this, 'loadDefaultScripts'));
|
14 |
+
add_shortcode('WpProQuiz', array($this, 'shortcode'));
|
15 |
+
}
|
16 |
+
|
17 |
+
public function loadDefaultScripts() {
|
18 |
+
wp_enqueue_script('jquery');
|
19 |
+
wp_enqueue_style('wpProQuiz_front_style', plugins_url('css/wpProQuiz_front.min.css', $this->_plugin_file));
|
20 |
+
}
|
21 |
+
|
22 |
+
public function shortcode($attr) {
|
23 |
+
$id = $attr[0];
|
24 |
+
$content = '';
|
25 |
+
|
26 |
+
wp_enqueue_script('jquery-ui-sortable');
|
27 |
+
wp_enqueue_script('wpProQuiz_front_javascript', plugins_url('js/wpProQuiz_front.min.js', $this->_plugin_file));
|
28 |
+
|
29 |
+
|
30 |
+
if(is_numeric($id)) {
|
31 |
+
ob_start();
|
32 |
+
|
33 |
+
$this->handleShortCode($id);
|
34 |
+
|
35 |
+
$content = ob_get_contents();
|
36 |
+
|
37 |
+
ob_end_clean();
|
38 |
+
}
|
39 |
+
|
40 |
+
return $content;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function handleShortCode($id) {
|
44 |
+
$view = new WpProQuiz_View_FrontQuiz();
|
45 |
+
|
46 |
+
$quizMapper = new WpProQuiz_Model_QuizMapper();
|
47 |
+
$questionMapper = new WpProQuiz_Model_QuestionMapper();
|
48 |
+
|
49 |
+
$quiz = $quizMapper->fetch($id);
|
50 |
+
$question = $questionMapper->fetchAll($id);
|
51 |
+
|
52 |
+
if(empty($quiz) || empty($question))
|
53 |
+
return '';
|
54 |
+
|
55 |
+
$view->quiz = $quiz;
|
56 |
+
$view->question = $question;
|
57 |
+
|
58 |
+
$view->show();
|
59 |
+
}
|
60 |
+
|
61 |
+
public function autoload($class) {
|
62 |
+
$c = explode("_", $class);
|
63 |
+
|
64 |
+
if($c === false || count($c) != 3 || $c[0] !== 'WpProQuiz')
|
65 |
+
return;
|
66 |
+
|
67 |
+
$dir = '';
|
68 |
+
|
69 |
+
switch ($c[1]) {
|
70 |
+
case 'View':
|
71 |
+
$dir = 'view';
|
72 |
+
break;
|
73 |
+
case 'Model':
|
74 |
+
$dir = 'model';
|
75 |
+
break;
|
76 |
+
case 'Controller':
|
77 |
+
$dir = 'controller';
|
78 |
+
break;
|
79 |
+
}
|
80 |
+
|
81 |
+
if(file_exists($this->_plugin_dir.'/lib/'.$dir.'/'.$class.'.php'))
|
82 |
+
include_once $this->_plugin_dir.'/lib/'.$dir.'/'.$class.'.php';
|
83 |
+
}
|
84 |
+
}
|
lib/controller/WpProQuiz_Controller_Preview.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Controller_Preview {
|
3 |
+
|
4 |
+
private $_plugin_file;
|
5 |
+
|
6 |
+
public function __construct($plugin_file) {
|
7 |
+
|
8 |
+
$this->_plugin_file = $plugin_file;
|
9 |
+
|
10 |
+
wp_enqueue_script('jquery');
|
11 |
+
wp_enqueue_script('jquery-ui-sortable');
|
12 |
+
wp_enqueue_script('wpProQuiz_fron_javascript', plugins_url('js/wpProQuiz_front.min.js', $this->_plugin_file));
|
13 |
+
|
14 |
+
wp_enqueue_style('wpProQuiz_front_style', plugins_url('css/wpProQuiz_front.min.css', $this->_plugin_file));
|
15 |
+
|
16 |
+
$this->showAction($_GET['id']);
|
17 |
+
}
|
18 |
+
|
19 |
+
public function showAction($id) {
|
20 |
+
$view = new WpProQuiz_View_FrontQuiz();
|
21 |
+
|
22 |
+
$quizMapper = new WpProQuiz_Model_QuizMapper();
|
23 |
+
$questionMapper = new WpProQuiz_Model_QuestionMapper();
|
24 |
+
|
25 |
+
$view->quiz = $quizMapper->fetch($id);
|
26 |
+
$view->question = $questionMapper->fetchAll($id);
|
27 |
+
|
28 |
+
$view->show();
|
29 |
+
}
|
30 |
+
}
|
lib/controller/WpProQuiz_Controller_Question.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Controller_Question {
|
3 |
+
|
4 |
+
private $_quizId;
|
5 |
+
|
6 |
+
public function __construct() {
|
7 |
+
|
8 |
+
if(!isset($_GET['quiz_id']))
|
9 |
+
wp_die('Keine ID');
|
10 |
+
|
11 |
+
$this->_quizId = (int)$_GET['quiz_id'];
|
12 |
+
$action = isset($_GET['action']) ? $_GET['action'] : 'show';
|
13 |
+
|
14 |
+
switch ($action) {
|
15 |
+
case 'add':
|
16 |
+
$this->createAction();
|
17 |
+
break;
|
18 |
+
case 'show':
|
19 |
+
$this->showAction();
|
20 |
+
break;
|
21 |
+
case 'edit':
|
22 |
+
$this->editAction($_GET['id']);
|
23 |
+
break;
|
24 |
+
case 'delete':
|
25 |
+
$this->deleteAction($_GET['id']);
|
26 |
+
break;
|
27 |
+
case 'save_sort':
|
28 |
+
$this->saveSort($_GET['id']);
|
29 |
+
break;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
public function saveSort($quizId) {
|
34 |
+
$mapper = new WpProQuiz_Model_QuestionMapper();
|
35 |
+
$map = $_POST['sort'];
|
36 |
+
|
37 |
+
foreach($map as $k => $v)
|
38 |
+
$mapper->updateSort($v, $k);
|
39 |
+
|
40 |
+
die();
|
41 |
+
}
|
42 |
+
|
43 |
+
public function deleteAction($id) {
|
44 |
+
$mapper = new WpProQuiz_Model_QuestionMapper();
|
45 |
+
$mapper->delete($id);
|
46 |
+
|
47 |
+
$this->showAction();
|
48 |
+
}
|
49 |
+
|
50 |
+
public function editAction($id) {
|
51 |
+
$this->view = new WpProQuiz_View_QuestionEdit();
|
52 |
+
$this->view->header = __('Edit question', 'wp-pro-quiz');
|
53 |
+
$mapper = new WpProQuiz_Model_QuestionMapper();
|
54 |
+
|
55 |
+
if(isset($_POST['submit'])) {
|
56 |
+
$post = $this->clearPost($_POST);
|
57 |
+
$post['id'] = $id;
|
58 |
+
$mapper->save(new WpProQuiz_Model_Question($post));
|
59 |
+
WpProQuiz_View_View::admin_notices(__('Question edited', 'wp-pro-quiz'), 'info');
|
60 |
+
}
|
61 |
+
|
62 |
+
$this->view->question = $mapper->fetch($id);
|
63 |
+
$this->view->show();
|
64 |
+
}
|
65 |
+
|
66 |
+
public function createAction() {
|
67 |
+
$this->view = new WpProQuiz_View_QuestionEdit();
|
68 |
+
$this->view->header = __('New question', 'wp-pro-quiz');
|
69 |
+
$post = null;
|
70 |
+
|
71 |
+
if(isset($_POST['submit'])) {
|
72 |
+
$post = $this->clearPost($_POST);
|
73 |
+
|
74 |
+
$questionMapper = new WpProQuiz_Model_QuestionMapper();
|
75 |
+
$questionMapper->save(new WpProQuiz_Model_Question($post));
|
76 |
+
|
77 |
+
WpProQuiz_View_View::admin_notices(__('Question added', 'wp-pro-quiz'), 'info');
|
78 |
+
|
79 |
+
$this->showAction();
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
$this->view->question = new WpProQuiz_Model_Question($post);
|
84 |
+
$this->view->show();
|
85 |
+
}
|
86 |
+
|
87 |
+
public function clearPost($post) {
|
88 |
+
switch($post['answerType']) {
|
89 |
+
case 'single':
|
90 |
+
case 'multiple':
|
91 |
+
unset($post['answerJson']['answer_sort']);
|
92 |
+
unset($post['answerJson']['free_answer']);
|
93 |
+
break;
|
94 |
+
case 'free_answer':
|
95 |
+
unset($post['answerJson']['answer_sort']);
|
96 |
+
unset($post['answerJson']['classic_answer']);
|
97 |
+
break;
|
98 |
+
case 'sort_answer':
|
99 |
+
unset($post['answerJson']['free_answer']);
|
100 |
+
unset($post['answerJson']['classic_answer']);
|
101 |
+
break;
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
$post['answerJson'] = $this->clear($post['answerJson']);
|
106 |
+
$post = $post;
|
107 |
+
$post['quizId'] = $this->_quizId;
|
108 |
+
|
109 |
+
return $post;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function clear($a) {
|
113 |
+
foreach($a as $k => $v) {
|
114 |
+
if(is_array($v)) {
|
115 |
+
$a[$k] = $this->clear($a[$k]);
|
116 |
+
}
|
117 |
+
|
118 |
+
if(empty($a[$k])) {
|
119 |
+
unset($a[$k]);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return $a;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function showAction() {
|
127 |
+
$m = new WpProQuiz_Model_QuizMapper();
|
128 |
+
$mm = new WpProQuiz_Model_QuestionMapper();
|
129 |
+
|
130 |
+
$this->view = new WpProQuiz_View_QuestionOverall();
|
131 |
+
$this->view->quiz = $m->fetch($this->_quizId);
|
132 |
+
$this->view->question = $mm->fetchAll($this->_quizId);
|
133 |
+
$this->view->show();
|
134 |
+
}
|
135 |
+
}
|
lib/controller/WpProQuiz_Controller_Quiz.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Controller_Quiz {
|
3 |
+
private $view;
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
$action = isset($_GET['action']) ? $_GET['action'] : 'show';
|
7 |
+
|
8 |
+
switch ($action) {
|
9 |
+
case 'show':
|
10 |
+
$this->showAction();
|
11 |
+
break;
|
12 |
+
case 'add':
|
13 |
+
$this->createAction();
|
14 |
+
break;
|
15 |
+
case 'edit':
|
16 |
+
if(isset($_GET['id']))
|
17 |
+
$this->editAction($_GET['id']);
|
18 |
+
break;
|
19 |
+
case 'delete':
|
20 |
+
if(isset($_GET['id']))
|
21 |
+
$this->deleteAction($_GET['id']);
|
22 |
+
break;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
private function showAction() {
|
27 |
+
$this->view = new WpProQuiz_View_QuizOverall();
|
28 |
+
|
29 |
+
$m = new WpProQuiz_Model_QuizMapper();
|
30 |
+
$this->view->quiz = $m->fetchAll();
|
31 |
+
|
32 |
+
$this->view->show();
|
33 |
+
}
|
34 |
+
|
35 |
+
private function editAction($id) {
|
36 |
+
$this->view = new WpProQuiz_View_QuizEdit();
|
37 |
+
$this->view->header = __('Edit quiz', 'wp-pro-quiz');
|
38 |
+
|
39 |
+
if(isset($_POST['submit'])) {
|
40 |
+
$this->view->quiz = new WpProQuiz_Model_Quiz($_POST);
|
41 |
+
$this->view->quiz->setId($id);
|
42 |
+
|
43 |
+
if($this->checkValidit($_POST)) {
|
44 |
+
WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled', 'wp-pro-quiz'), 'info');
|
45 |
+
$this->view->quiz->getMapper()->save($this->view->quiz);
|
46 |
+
$this->showAction();
|
47 |
+
return;
|
48 |
+
} else {
|
49 |
+
WpProQuiz_View_View::admin_notices(__('Not all fields are filled', 'wp-pro-quiz'));
|
50 |
+
}
|
51 |
+
} else {
|
52 |
+
$m = new WpProQuiz_Model_QuizMapper();
|
53 |
+
$this->view->quiz = $m->fetch($id);
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->view->show();
|
57 |
+
}
|
58 |
+
|
59 |
+
private function createAction() {
|
60 |
+
$this->view = new WpProQuiz_View_QuizEdit();
|
61 |
+
$this->view->header = __('Create quiz', 'wp-pro-quiz');
|
62 |
+
|
63 |
+
if(isset($_POST['submit'])) {
|
64 |
+
$this->view->quiz = new WpProQuiz_Model_Quiz($_POST);
|
65 |
+
|
66 |
+
if($this->checkValidit($_POST)) {
|
67 |
+
WpProQuiz_View_View::admin_notices(__('Create quiz', 'wp-pro-quiz'), 'info');
|
68 |
+
$this->view->quiz->getMapper()->save($this->view->quiz);
|
69 |
+
$this->showAction();
|
70 |
+
return;
|
71 |
+
} else {
|
72 |
+
//add_action('admin_notices', array('WpProQuiz_View_View', 'admin_notices'));
|
73 |
+
WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled', 'wp-pro-quiz'));
|
74 |
+
}
|
75 |
+
} else {
|
76 |
+
$this->view->quiz = new WpProQuiz_Model_Quiz();
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->view->show();
|
80 |
+
}
|
81 |
+
|
82 |
+
private function deleteAction($id) {
|
83 |
+
$m = new WpProQuiz_Model_QuizMapper();
|
84 |
+
$m->delete($id);
|
85 |
+
WpProQuiz_View_View::admin_notices(__('Quiz deleted', 'wp-pro-quiz'), 'info');
|
86 |
+
$this->showAction();
|
87 |
+
}
|
88 |
+
|
89 |
+
private function checkValidit($post) {
|
90 |
+
return (isset($post['name']) && !empty($post['name']) && isset($post['text']) && !empty($post['text']));
|
91 |
+
}
|
92 |
+
}
|
lib/helper/WpProQuiz_Helper_DbUpgrade.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Helper_DbUpgrade {
|
3 |
+
|
4 |
+
const WPPROQUIZ_DB_VERSION = 3;
|
5 |
+
|
6 |
+
private $_wpdb;
|
7 |
+
private $_prefix;
|
8 |
+
|
9 |
+
public function __construct() {
|
10 |
+
global $wpdb;
|
11 |
+
|
12 |
+
$this->_wpdb = $wpdb;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function upgrade($version) {
|
16 |
+
|
17 |
+
if($version === false || ((int)$version) > WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION) {
|
18 |
+
$this->install();
|
19 |
+
return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
|
20 |
+
}
|
21 |
+
|
22 |
+
$version = (int) $version;
|
23 |
+
|
24 |
+
if($version === WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION)
|
25 |
+
return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
|
26 |
+
|
27 |
+
if($version === false || $version > WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION) {
|
28 |
+
$this->install();
|
29 |
+
return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
|
30 |
+
}
|
31 |
+
|
32 |
+
do {
|
33 |
+
$f = 'upgradeDbV'.$version;
|
34 |
+
|
35 |
+
if(method_exists($this, $f)) {
|
36 |
+
$version = $this->$f();
|
37 |
+
} else {
|
38 |
+
die("WpProQuiz upgrade error");
|
39 |
+
}
|
40 |
+
} while ($version < WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION);
|
41 |
+
|
42 |
+
return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function delete() {
|
46 |
+
$this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master`');
|
47 |
+
$this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question`');
|
48 |
+
}
|
49 |
+
|
50 |
+
private function install() {
|
51 |
+
|
52 |
+
$this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master`');
|
53 |
+
$this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question`');
|
54 |
+
|
55 |
+
$this->_wpdb->query('
|
56 |
+
CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master` (
|
57 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
58 |
+
`name` varchar(200) NOT NULL,
|
59 |
+
`text` text NOT NULL,
|
60 |
+
`result_text` text NOT NULL,
|
61 |
+
`title_hidden` tinyint(1) NOT NULL,
|
62 |
+
`question_random` tinyint(1) NOT NULL,
|
63 |
+
`answer_random` tinyint(1) NOT NULL,
|
64 |
+
`check_answer` tinyint(1) NOT NULL,
|
65 |
+
`back_button` tinyint(1) NOT NULL,
|
66 |
+
`time_limit` int(11) NOT NULL,
|
67 |
+
PRIMARY KEY (`id`)
|
68 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
69 |
+
');
|
70 |
+
|
71 |
+
$this->_wpdb->query('
|
72 |
+
CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question` (
|
73 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
74 |
+
`quiz_id` int(11) NOT NULL,
|
75 |
+
`sort` tinyint(3) unsigned NOT NULL,
|
76 |
+
`title` varchar(200) NOT NULL,
|
77 |
+
`question` text NOT NULL,
|
78 |
+
`correct_msg` text NOT NULL,
|
79 |
+
`incorrect_msg` text NOT NULL,
|
80 |
+
`answer_type` varchar(50) NOT NULL,
|
81 |
+
`answer_json` text NOT NULL,
|
82 |
+
PRIMARY KEY (`id`)
|
83 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
84 |
+
');
|
85 |
+
}
|
86 |
+
|
87 |
+
private function upgradeDbV1() {
|
88 |
+
|
89 |
+
$this->_wpdb->query('
|
90 |
+
ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
|
91 |
+
ADD `back_button` TINYINT( 1 ) NOT NULL AFTER `answer_random`,
|
92 |
+
ADD `check_answer` TINYINT( 1 ) NOT NULL AFTER `answer_random`,
|
93 |
+
ADD `result_text` TEXT NOT NULL AFTER `text`
|
94 |
+
');
|
95 |
+
|
96 |
+
return 2;
|
97 |
+
}
|
98 |
+
|
99 |
+
private function upgradeDbV2() {
|
100 |
+
return 3;
|
101 |
+
}
|
102 |
+
}
|
lib/model/WpProQuiz_Model_Mapper.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Model_Mapper {
|
3 |
+
/**
|
4 |
+
* Wordpress Datenbank Object
|
5 |
+
* @var wpdb
|
6 |
+
*/
|
7 |
+
protected $_wpdb;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
protected $_prefix;
|
13 |
+
|
14 |
+
function __construct() {
|
15 |
+
global $wpdb;
|
16 |
+
|
17 |
+
$this->_wpdb = $wpdb;
|
18 |
+
$this->_prefix = $wpdb->prefix.'wp_pro_quiz_';
|
19 |
+
}
|
20 |
+
}
|
lib/model/WpProQuiz_Model_Model.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Model_Model {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* @var WpProQuiz_Model_QuizMapper
|
6 |
+
*/
|
7 |
+
protected $_mapper = null;
|
8 |
+
|
9 |
+
public function __construct($array = null) {
|
10 |
+
if($array != null) {
|
11 |
+
// $a = get_object_vars($this);
|
12 |
+
// foreach($array as $k => $v) {
|
13 |
+
// if(array_key_exists('_'.$k, $a)) {
|
14 |
+
// $this->{'_'.$k} = $v;
|
15 |
+
// }
|
16 |
+
// }
|
17 |
+
|
18 |
+
foreach($array as $k => $v) {
|
19 |
+
// if(array_key_exists('_'.$k, $a)) {
|
20 |
+
// $this->{'_'.$k} = $v;
|
21 |
+
// }
|
22 |
+
|
23 |
+
if(strpos($k, '_') !== false) {
|
24 |
+
$k = str_replace(' ', '', ucwords(str_replace('_', ' ', $k)));
|
25 |
+
}
|
26 |
+
|
27 |
+
$this->{'set'.ucfirst($k)}($v);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
public function __call($name, $args) {
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
*
|
37 |
+
* @return WpProQuiz_Model_QuizMapper
|
38 |
+
*/
|
39 |
+
public function getMapper() {
|
40 |
+
if($this->_mapper === null) {
|
41 |
+
$this->_mapper = new WpProQuiz_Model_QuizMapper();
|
42 |
+
}
|
43 |
+
|
44 |
+
return $this->_mapper;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @param WpProQuiz_Model_QuizMapper $mapper
|
49 |
+
* @return WpProQuiz_Model_Model
|
50 |
+
*/
|
51 |
+
public function setMapper($mapper) {
|
52 |
+
$this->_mapper = $mapper;
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
}
|
lib/model/WpProQuiz_Model_Question.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Model_Question extends WpProQuiz_Model_Model {
|
3 |
+
protected $_id;
|
4 |
+
protected $_quizId;
|
5 |
+
protected $_sort;
|
6 |
+
protected $_title;
|
7 |
+
protected $_question;
|
8 |
+
protected $_correctMsg;
|
9 |
+
protected $_incorrectMsg;
|
10 |
+
protected $_answerType;
|
11 |
+
protected $_answerJson;
|
12 |
+
|
13 |
+
public function setId($_id)
|
14 |
+
{
|
15 |
+
$this->_id = $_id;
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getId() {
|
20 |
+
return $this->_id;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function setQuizId($_quizId)
|
24 |
+
{
|
25 |
+
$this->_quizId = $_quizId;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getQuizId() {
|
30 |
+
return $this->_quizId;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function setSort($_sort)
|
34 |
+
{
|
35 |
+
$this->_sort = $_sort;
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getSort() {
|
40 |
+
return $this->_sort;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function setTitle($title)
|
44 |
+
{
|
45 |
+
$this->_title = $title;
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getTitle() {
|
50 |
+
return $this->_title;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function setQuestion($question)
|
54 |
+
{
|
55 |
+
$this->_question = $question;
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getQuestion() {
|
60 |
+
return $this->_question;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function setCorrectMsg($correctMsg)
|
64 |
+
{
|
65 |
+
$this->_correctMsg = $correctMsg;
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getCorrectMsg() {
|
70 |
+
return $this->_correctMsg;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function setIncorrectMsg($incorrectMsg)
|
74 |
+
{
|
75 |
+
$this->_incorrectMsg = $incorrectMsg;
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getIncorrectMsg() {
|
80 |
+
return $this->_incorrectMsg;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function setAnswerType($_answerType)
|
84 |
+
{
|
85 |
+
$this->_answerType = $_answerType;
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
public function getAnswerType() {
|
90 |
+
return $this->_answerType;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function setAnswerJson($answerJson)
|
94 |
+
{
|
95 |
+
$this->_answerJson = $answerJson;
|
96 |
+
|
97 |
+
if(isset($this->_answerJson['answer_type']))
|
98 |
+
$this->setAnswerType($this->_answerJson['answer_type']);
|
99 |
+
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
public function getAnswerJson() {
|
104 |
+
return $this->_answerJson;
|
105 |
+
}
|
106 |
+
}
|
lib/model/WpProQuiz_Model_QuestionMapper.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Model_QuestionMapper extends WpProQuiz_Model_Mapper {
|
3 |
+
private $_table;
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
|
8 |
+
$this->_table = $this->_prefix."question";
|
9 |
+
}
|
10 |
+
|
11 |
+
public function delete($id) {
|
12 |
+
$this->_wpdb->delete($this->_table, array('id' => $id), '%d');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function updateSort($id, $sort) {
|
16 |
+
$this->_wpdb->update(
|
17 |
+
$this->_table,
|
18 |
+
array(
|
19 |
+
'sort' => $sort),
|
20 |
+
array('id' => $id),
|
21 |
+
array('%d'),
|
22 |
+
array('%d'));
|
23 |
+
}
|
24 |
+
|
25 |
+
public function save(WpProQuiz_Model_Question $question) {
|
26 |
+
if($question->getId() != 0) {
|
27 |
+
$this->_wpdb->update(
|
28 |
+
$this->_table,
|
29 |
+
array(
|
30 |
+
'title' => $question->getTitle(),
|
31 |
+
'question' => $question->getQuestion(),
|
32 |
+
'correct_msg' => $question->getCorrectMsg(),
|
33 |
+
'incorrect_msg' => $question->getIncorrectMsg(),
|
34 |
+
'answer_type' => $question->getAnswerType(),
|
35 |
+
'answer_json' => json_encode($question->getAnswerJson())),
|
36 |
+
array('id' => $question->getId()),
|
37 |
+
array('%s', '%s', '%s', '%s', '%s', '%s'),
|
38 |
+
array('%d'));
|
39 |
+
} else {
|
40 |
+
$id = $this->_wpdb->insert($this->_table, array(
|
41 |
+
'quiz_id' => $question->getQuizId(),
|
42 |
+
'sort' => $this->count($question->getQuizId()),
|
43 |
+
'title' => $question->getTitle(),
|
44 |
+
'question' => $question->getQuestion(),
|
45 |
+
'correct_msg' => $question->getCorrectMsg(),
|
46 |
+
'incorrect_msg' => $question->getIncorrectMsg(),
|
47 |
+
'answer_type' => $question->getAnswerType(),
|
48 |
+
'answer_json' => json_encode($question->getAnswerJson())
|
49 |
+
),
|
50 |
+
array('%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s')
|
51 |
+
);
|
52 |
+
|
53 |
+
$question->setId($id);
|
54 |
+
}
|
55 |
+
|
56 |
+
return $question;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function fetch($id) {
|
60 |
+
$row = $this->_wpdb->get_row(
|
61 |
+
$this->_wpdb->prepare(
|
62 |
+
"SELECT
|
63 |
+
*
|
64 |
+
FROM
|
65 |
+
". $this->_table. "
|
66 |
+
WHERE
|
67 |
+
id = %d",
|
68 |
+
$id)
|
69 |
+
);
|
70 |
+
|
71 |
+
$model = new WpProQuiz_Model_Question();
|
72 |
+
$model ->setId($row->id)
|
73 |
+
->setQuizId($row->quiz_id)
|
74 |
+
->setTitle($row->title)
|
75 |
+
->setQuestion($row->question)
|
76 |
+
->setCorrectMsg($row->correct_msg)
|
77 |
+
->setIncorrectMsg($row->incorrect_msg)
|
78 |
+
->setAnswerType($row->answer_type)
|
79 |
+
->setAnswerJson(json_decode($row->answer_json, true));
|
80 |
+
|
81 |
+
return $model;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function fetchAll($quizId) {
|
85 |
+
$a = array();
|
86 |
+
$results = $this->_wpdb->get_results(
|
87 |
+
$this->_wpdb->prepare(
|
88 |
+
'SELECT
|
89 |
+
*
|
90 |
+
FROM
|
91 |
+
'. $this->_table.'
|
92 |
+
WHERE
|
93 |
+
quiz_id = %d
|
94 |
+
ORDER BY sort ASC', $quizId));
|
95 |
+
|
96 |
+
foreach($results as $row) {
|
97 |
+
$model = new WpProQuiz_Model_Question();
|
98 |
+
|
99 |
+
$model ->setId($row->id)
|
100 |
+
->setQuizId($row->quiz_id)
|
101 |
+
->setTitle($row->title)
|
102 |
+
->setQuestion($row->question)
|
103 |
+
->setCorrectMsg($row->correct_msg)
|
104 |
+
->setIncorrectMsg($row->incorrect_msg)
|
105 |
+
->setAnswerType($row->answer_type)
|
106 |
+
->setAnswerJson(json_decode($row->answer_json, true));
|
107 |
+
|
108 |
+
$a[] = $model;
|
109 |
+
}
|
110 |
+
|
111 |
+
return $a;
|
112 |
+
}
|
113 |
+
|
114 |
+
public function count($quizId) {
|
115 |
+
return $this->_wpdb->get_var($this->_wpdb->prepare("SELECT COUNT(*) FROM {$this->_table} WHERE quiz_id = %d", $quizId));
|
116 |
+
}
|
117 |
+
}
|
lib/model/WpProQuiz_Model_Quiz.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Model_Quiz extends WpProQuiz_Model_Model {
|
3 |
+
|
4 |
+
protected $_id;
|
5 |
+
protected $_name;
|
6 |
+
protected $_text;
|
7 |
+
protected $_resultText;
|
8 |
+
protected $_titleHidden;
|
9 |
+
protected $_questionRandom;
|
10 |
+
protected $_answerRandom;
|
11 |
+
protected $_timeLimit = 0;
|
12 |
+
protected $_backButton;
|
13 |
+
protected $_checkAnswer;
|
14 |
+
|
15 |
+
public function getId() {
|
16 |
+
return $this->_id;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setId($id) {
|
20 |
+
$this->_id = $id;
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getName() {
|
25 |
+
return $this->_name;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function setName($name) {
|
29 |
+
$this->_name = $name;
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Test
|
35 |
+
* @param string $text
|
36 |
+
* @return WpProQuiz_Model_Quiz
|
37 |
+
*/
|
38 |
+
public function setText($text) {
|
39 |
+
$this->_text = $text;
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getText() {
|
44 |
+
return $this->_text;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function setResultText($_resultText) {
|
48 |
+
$this->_resultText = $_resultText;
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getResultText() {
|
53 |
+
return $this->_resultText;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function setTitleHidden($_titleHidden) {
|
57 |
+
$this->_titleHidden = (bool)$_titleHidden;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function isTitleHidden() {
|
62 |
+
return $this->_titleHidden;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function setQuestionRandom($_questionRandom) {
|
66 |
+
$this->_questionRandom = (bool)$_questionRandom;
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function isQuestionRandom() {
|
71 |
+
return $this->_questionRandom;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function setAnswerRandom($_answerRandom) {
|
75 |
+
$this->_answerRandom = (bool)$_answerRandom;
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
public function isAnswerRandom() {
|
80 |
+
return $this->_answerRandom;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function setTimeLimit($_timeLimit) {
|
84 |
+
$this->_timeLimit = $_timeLimit;
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
+
public function getTimeLimit() {
|
89 |
+
return $this->_timeLimit;
|
90 |
+
}
|
91 |
+
|
92 |
+
public function setBackButton($_backButton) {
|
93 |
+
$this->_backButton = (bool)$_backButton;
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
|
97 |
+
public function isBackButton() {
|
98 |
+
return $this->_backButton;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function setCheckAnswer($_checkAnswer) {
|
102 |
+
$this->_checkAnswer = (bool)$_checkAnswer;
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
public function isCheckAnswer() {
|
107 |
+
return $this->_checkAnswer;
|
108 |
+
}
|
109 |
+
}
|
lib/model/WpProQuiz_Model_QuizMapper.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_Model_QuizMapper extends WpProQuiz_Model_Mapper
|
3 |
+
{
|
4 |
+
protected $_table;
|
5 |
+
|
6 |
+
function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_table = $this->_prefix."master";
|
10 |
+
}
|
11 |
+
|
12 |
+
public function delete($id) {
|
13 |
+
$this->_wpdb->delete($this->_table, array(
|
14 |
+
'id' => $id),
|
15 |
+
array('%d'));
|
16 |
+
}
|
17 |
+
|
18 |
+
public function fetch($id) {
|
19 |
+
$results = $this->_wpdb->get_row(
|
20 |
+
$this->_wpdb->prepare(
|
21 |
+
"SELECT
|
22 |
+
*
|
23 |
+
FROM
|
24 |
+
{$this->_table}
|
25 |
+
WHERE
|
26 |
+
id = %d",
|
27 |
+
$id),
|
28 |
+
ARRAY_A
|
29 |
+
);
|
30 |
+
|
31 |
+
return new WpProQuiz_Model_Quiz($results);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function fetchAll() {
|
35 |
+
$r = array();
|
36 |
+
|
37 |
+
$results = $this->_wpdb->get_results("SELECT * FROM {$this->_table}", ARRAY_A);
|
38 |
+
|
39 |
+
foreach ($results as $row) {
|
40 |
+
$r[] = new WpProQuiz_Model_Quiz($row);
|
41 |
+
}
|
42 |
+
|
43 |
+
return $r;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function save(WpProQuiz_Model_Quiz $data) {
|
47 |
+
|
48 |
+
$set = array(
|
49 |
+
'name' => $data->getName(),
|
50 |
+
'text' => $data->getText(),
|
51 |
+
'result_text' => $data->getResultText(),
|
52 |
+
'title_hidden' => (int)$data->isTitleHidden(),
|
53 |
+
'question_random' => (int)$data->isQuestionRandom(),
|
54 |
+
'answer_random' => (int)$data->isAnswerRandom(),
|
55 |
+
'back_button' => (int)$data->isBackButton(),
|
56 |
+
'check_answer' => (int) $data->isCheckAnswer(),
|
57 |
+
'time_limit' => (int)$data->getTimeLimit()
|
58 |
+
);
|
59 |
+
|
60 |
+
if($data->getId() != 0) {
|
61 |
+
return $this->_wpdb->update($this->_table,
|
62 |
+
$set,
|
63 |
+
array(
|
64 |
+
'id' => $data->getId()
|
65 |
+
),
|
66 |
+
array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d'),
|
67 |
+
array('%d'));
|
68 |
+
} else {
|
69 |
+
return $this->_wpdb->insert($this->_table,
|
70 |
+
$set,
|
71 |
+
array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d'));
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
lib/view/WpProQuiz_View_FrontQuiz.php
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_View_FrontQuiz extends WpProQuiz_View_View {
|
3 |
+
|
4 |
+
private function parseJson($data) {
|
5 |
+
$r = array();
|
6 |
+
|
7 |
+
foreach($data as $q) {
|
8 |
+
$a = array();
|
9 |
+
$a['answer_type'] = $q->getAnswerType();
|
10 |
+
$j = $q->getAnswerJson();
|
11 |
+
|
12 |
+
switch ($q->getAnswerType()) {
|
13 |
+
case 'single':
|
14 |
+
case 'multiple':
|
15 |
+
$a['correct'] = $j['classic_answer']['correct'];
|
16 |
+
break;
|
17 |
+
case 'sort_answer':
|
18 |
+
$a['correct'] = array_keys(array_values($j['answer_sort']['answer']));
|
19 |
+
break;
|
20 |
+
case 'free_answer':
|
21 |
+
$t = str_replace("\r\n", "\n", strtolower($j['free_answer']['correct']));
|
22 |
+
$t = str_replace("\r", "\n", $t);
|
23 |
+
$t = explode("\n", $t);
|
24 |
+
$a['correct'] = array_values(array_filter(array_map('trim', $t)));
|
25 |
+
break;
|
26 |
+
}
|
27 |
+
|
28 |
+
$r[] = $a;
|
29 |
+
}
|
30 |
+
|
31 |
+
return $r;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function show() {
|
35 |
+
|
36 |
+
$question_count = count($this->question);
|
37 |
+
|
38 |
+
$json = json_encode($this->parseJson($this->question));
|
39 |
+
|
40 |
+
?>
|
41 |
+
|
42 |
+
<div class="wpProQuiz_content" id="wpProQuiz_<?php echo $this->quiz->getId(); ?>">
|
43 |
+
<?php if(!$this->quiz->isTitleHidden()) { ?>
|
44 |
+
<h2><?php echo $this->quiz->getName(); ?></h2>
|
45 |
+
<?php } ?>
|
46 |
+
<div class="wpProQuiz_text">
|
47 |
+
<p>
|
48 |
+
<?php echo do_shortcode(apply_filters('comment_text', $this->quiz->getText())); ?>
|
49 |
+
</p>
|
50 |
+
<div>
|
51 |
+
<input type="button" value="<?php _e('Start quiz', 'wp-pro-quiz'); ?>" name="startQuiz">
|
52 |
+
</div>
|
53 |
+
</div>
|
54 |
+
<div class="wpProQuiz_results">
|
55 |
+
<h3><?php _e('Results', 'wp-pro-quiz'); ?></h3>
|
56 |
+
<p>
|
57 |
+
<?php printf(__('%s from %s questions answered correctly', 'wp-pro-quiz'), '<span class="wpProQuiz_points"></span>', '<span>'.$question_count.'</span>'); ?> <span class="wpProQuiz_points_prozent">(0%)</span>
|
58 |
+
</p>
|
59 |
+
<p class="wpProQuiz_time_limit_expired">
|
60 |
+
<?php _e('Time has elapsed', 'wp-pro-quiz'); ?>
|
61 |
+
</p>
|
62 |
+
<p class="wpProQuiz_quiz_time">
|
63 |
+
<?php _e('Your time: <span></span>', 'wp-pro-quiz') ?>
|
64 |
+
</p>
|
65 |
+
<div>
|
66 |
+
<?php echo do_shortcode(apply_filters('comment_text', $this->quiz->getResultText())); ?>
|
67 |
+
</div>
|
68 |
+
<p>
|
69 |
+
<input type="button" name="restartQuiz" value="<?php _e('Restart quiz', 'wp-pro-quiz'); ?>" >
|
70 |
+
<input type="button" name="reShowQuestion" value="<?php _e('View question', 'wp-pro-quiz'); ?>">
|
71 |
+
</p>
|
72 |
+
</div>
|
73 |
+
<div class="wpProQuiz_time_limit">
|
74 |
+
<div class="time"><?php _e('Time limit', 'wp-pro-quiz'); ?>: <span>00:03:15</span></div>
|
75 |
+
<div class="progress"></div>
|
76 |
+
</div>
|
77 |
+
<div class="wpProQuiz_quiz">
|
78 |
+
<ol class="wpProQuiz_list">
|
79 |
+
<?php
|
80 |
+
$index = 0;
|
81 |
+
foreach($this->question as $question) {
|
82 |
+
$index++;
|
83 |
+
?>
|
84 |
+
<li class="wpProQuiz_listItem">
|
85 |
+
<div class="wpProQuiz_question_page">
|
86 |
+
<?php printf(__('Question %s from %s', 'wp-pro-quiz'), '<span>'.$index.'</span>', '<span>'.$question_count.'</span>'); ?>
|
87 |
+
</div>
|
88 |
+
<h3><span><?php echo $index; ?></span>. <?php _e('Question', 'wp-pro-quiz'); ?></h3>
|
89 |
+
<div class="wpProQuiz_question">
|
90 |
+
<div class="wpProQuiz_question_text">
|
91 |
+
<?php echo do_shortcode(apply_filters('comment_text', $question->getQuestion())); ?>
|
92 |
+
</div>
|
93 |
+
<ul class="wpProQuiz_questionList">
|
94 |
+
<?php
|
95 |
+
$answerArray = $question->getAnswerJson();
|
96 |
+
|
97 |
+
if($question->getAnswerType() === 'single' || $question->getAnswerType() === 'multiple') {
|
98 |
+
$answer_index = 1;
|
99 |
+
foreach($answerArray['classic_answer']['answer'] as $k => $v) {
|
100 |
+
$answer_text = (isset($answerArray['classic_answer']['html']) && in_array($k, $answerArray['classic_answer']['html'])) ? $v : esc_html($v);
|
101 |
+
?>
|
102 |
+
|
103 |
+
<li class="wpProQuiz_questionListItem">
|
104 |
+
<label>
|
105 |
+
<input type="<?php echo $question->getAnswerType() === 'single' ? 'radio' : 'checkbox' ?>" name="question" value="<?php echo $answer_index; ?>"> <?php echo $answer_text; ?>
|
106 |
+
</label>
|
107 |
+
</li>
|
108 |
+
|
109 |
+
<?php $answer_index++; }
|
110 |
+
} else if($question->getAnswerType() === 'sort_answer') {
|
111 |
+
foreach($answerArray['answer_sort']['answer'] as $k => $v) {
|
112 |
+
?>
|
113 |
+
<li class="wpProQuiz_questionListItem">
|
114 |
+
<div class="wpProQuiz_sortable">
|
115 |
+
<?php echo (isset($answerArray['answer_sort']['html']) && in_array($k, $answerArray['answer_sort']['html'])) ? $v : esc_html($v); ?>
|
116 |
+
</div>
|
117 |
+
</li>
|
118 |
+
<?php } } else if($question->getAnswerType() === 'free_answer') {
|
119 |
+
|
120 |
+
?>
|
121 |
+
<li class="wpProQuiz_questionListItem">
|
122 |
+
<label>
|
123 |
+
<input type="text" name="question" style="width: 300px;">
|
124 |
+
</label>
|
125 |
+
</li>
|
126 |
+
<?php } ?>
|
127 |
+
</ul>
|
128 |
+
</div>
|
129 |
+
<div class="wpProQuiz_response">
|
130 |
+
<div class="wpProQuiz_correct">
|
131 |
+
<span>
|
132 |
+
<?php _e('Right', 'wp-pro-quiz'); ?>
|
133 |
+
</span>
|
134 |
+
<p>
|
135 |
+
<?php echo do_shortcode(apply_filters('comment_text', $question->getCorrectMsg())); ?>
|
136 |
+
</p>
|
137 |
+
</div>
|
138 |
+
<div class="wpProQuiz_incorrect">
|
139 |
+
<span>
|
140 |
+
<?php _e('Wrong', 'wp-pro-quiz'); ?>
|
141 |
+
</span>
|
142 |
+
<p>
|
143 |
+
<?php echo do_shortcode(apply_filters('comment_text', $question->getIncorrectMsg())); ?>
|
144 |
+
</p>
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
<input type="button" name="check" value="<?php _e('Check', 'wp-pro-quiz'); ?>" class="wpProQuiz_QuestionButton" style="float: left;">
|
148 |
+
<input type="button" name="back" value="<?php _e('Back', 'wp-pro-quiz'); ?>" class="wpProQuiz_QuestionButton" style="float: left;">
|
149 |
+
<input type="button" name="next" value="<?php _e('Next exercise', 'wp-pro-quiz'); ?>" class="wpProQuiz_QuestionButton" style="float: right;" >
|
150 |
+
<div style="clear: both;"></div>
|
151 |
+
</li>
|
152 |
+
|
153 |
+
<?php } ?>
|
154 |
+
</ol>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
<script>
|
158 |
+
jQuery(document).ready(function($) {
|
159 |
+
$('#wpProQuiz_<?php echo $this->quiz->getId(); ?>').wpProQuizFront({
|
160 |
+
questionRandom: <?php echo (int)$this->quiz->isQuestionRandom(); ?>,
|
161 |
+
answerRandom: <?php echo (int)$this->quiz->isAnswerRandom(); ?>,
|
162 |
+
timeLimit: <?php echo (int)$this->quiz->getTimeLimit(); ?>,
|
163 |
+
checkAnswer: <?php echo (int)$this->quiz->isCheckAnswer(); ?>,
|
164 |
+
backButton: <?php echo (int)$this->quiz->isBackButton();?>,
|
165 |
+
json: <?php echo $json; ?>
|
166 |
+
});
|
167 |
+
});
|
168 |
+
|
169 |
+
</script>
|
170 |
+
<?php
|
171 |
+
}
|
172 |
+
}
|
lib/view/WpProQuiz_View_QuestionEdit.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_View_QuestionEdit extends WpProQuiz_View_View {
|
3 |
+
|
4 |
+
public function show() {
|
5 |
+
?>
|
6 |
+
<script>
|
7 |
+
jQuery(document).ready(function($) {
|
8 |
+
|
9 |
+
});
|
10 |
+
</script>
|
11 |
+
<div class="wrap wpProQuiz_questionEdit">
|
12 |
+
<h2 style="margin-bottom: 10px;"><?php echo $this->header; ?></h2>
|
13 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz&module=question&action=show&quiz_id=<?php echo $this->question->getQuizId(); ?>"><?php _e('back to overview', 'wp-pro-quiz'); ?></a>
|
14 |
+
<form action="" method="POST">
|
15 |
+
<div id="poststuff">
|
16 |
+
<div class="postbox">
|
17 |
+
<h3 class="hndle"><?php _e('Title', 'wp-pro-quiz'); ?></h3>
|
18 |
+
<div class="inside">
|
19 |
+
<input name="title" class="regular-text" value="<?php echo $this->question->getTitle(); ?>">
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
<div class="postbox">
|
23 |
+
<h3 class="hndle"><?php _e('Question', 'wp-pro-quiz'); ?></h3>
|
24 |
+
<div class="inside">
|
25 |
+
<?php
|
26 |
+
wp_editor($this->question->getQuestion(), "question", array('textarea_rows' => 5));
|
27 |
+
?>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<div class="postbox">
|
31 |
+
<h3 class="hndle"><?php _e('Message with the correct answer', 'wp-pro-quiz'); ?></h3>
|
32 |
+
<div class="inside">
|
33 |
+
<?php
|
34 |
+
wp_editor($this->question->getCorrectMsg(), "correctMsg", array('textarea_rows' => 3));
|
35 |
+
?>
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
<div class="postbox">
|
39 |
+
<h3 class="hndle"><?php _e('Message with the incorrect answer', 'wp-pro-quiz'); ?></h3>
|
40 |
+
<div class="inside">
|
41 |
+
<?php
|
42 |
+
wp_editor($this->question->getIncorrectMsg(), "incorrectMsg", array('textarea_rows' => 3));
|
43 |
+
?>
|
44 |
+
</div>
|
45 |
+
</div>
|
46 |
+
<div class="postbox">
|
47 |
+
<h3 class="hndle"><?php _e('Answer type', 'wp-pro-quiz'); ?></h3>
|
48 |
+
<div class="inside">
|
49 |
+
<?php
|
50 |
+
$qa = (array) $this->question->getAnswerJson();
|
51 |
+
$type = $this->question->getAnswerType();
|
52 |
+
?>
|
53 |
+
<label style="padding-right: 10px;">
|
54 |
+
<input type="radio" name="answerType" value="single" <?php echo ($type === 'single') ? 'checked="checked"' : ''; ?>>
|
55 |
+
<?php _e('Single choice', 'wp-pro-quiz'); ?>
|
56 |
+
</label>
|
57 |
+
<label style="padding-right: 10px;">
|
58 |
+
<input type="radio" name="answerType" value="multiple" <?php echo ($type === 'multiple') ? 'checked="checked"' : ''; ?>>
|
59 |
+
<?php _e('Multiple choice', 'wp-pro-quiz'); ?>
|
60 |
+
</label>
|
61 |
+
<label style="padding-right: 10px;">
|
62 |
+
<input type="radio" name="answerType" value="free_answer" <?php echo ($type === 'free_answer') ? 'checked="checked"' : ''; ?>>
|
63 |
+
<?php _e('"Free" choice', 'wp-pro-quiz'); ?>
|
64 |
+
</label>
|
65 |
+
<label style="padding-right: 10px;">
|
66 |
+
<input type="radio" name="answerType" value="sort_answer" <?php echo ($type === 'sort_answer') ? 'checked="checked"' : ''; ?>>
|
67 |
+
<?php _e('"Sorting" choice', 'wp-pro-quiz'); ?>
|
68 |
+
</label>
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
<div class="postbox">
|
72 |
+
<h3 class="hndle"><?php _e('Answers', 'wp-pro-quiz'); ?></h3>
|
73 |
+
<div class="inside answer_felder">
|
74 |
+
<div class="free_answer">
|
75 |
+
<?php if($type === 'free_answer') { ?>
|
76 |
+
<p style="border-bottom:1px dotted #ccc;">
|
77 |
+
<textarea placeholder="Korrekte antworten (per komme getrennt)" rows="6" cols="100" class="large-text" name="answerJson[free_answer][correct]"><?php echo $qa['free_answer']['correct']; ?></textarea>
|
78 |
+
</p>
|
79 |
+
<?php } else { ?>
|
80 |
+
<p style="border-bottom:1px dotted #ccc;">
|
81 |
+
<textarea placeholder="<?php _e('korrect answers (one per line) (answers will be converted to lower case)', 'wp-pro-quiz'); ?>" rows="6" cols="100" class="large-text" name="answerJson[free_answer][correct]"></textarea>
|
82 |
+
</p>
|
83 |
+
<?php } ?>
|
84 |
+
</div>
|
85 |
+
<div class="sort_answer">
|
86 |
+
<p class="description">
|
87 |
+
<?php _e('Please sort the answers in right order with the "Move" - Button. The answers will be displayed in right order later.', 'wp-pro-quiz'); ?>
|
88 |
+
</p>
|
89 |
+
<ul>
|
90 |
+
<li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; display:none; background-color: whiteSmoke;">
|
91 |
+
<!-- <input class="small-text" name="answerJson[answer_sort][nr][]" value="" placeholder="Nr."> -->
|
92 |
+
<textarea rows="2" cols="100" class="large-text" name="answerJson[answer_sort][answer][]"></textarea>
|
93 |
+
<input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete question', 'wp-pro-quiz'); ?>">
|
94 |
+
<a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
95 |
+
<label>
|
96 |
+
<?php _e('Allow HTML', 'wp-pro-quiz'); ?>
|
97 |
+
<input type="checkbox" name="answerJson[answer_sort][html][]" value="0">
|
98 |
+
</label>
|
99 |
+
</li>
|
100 |
+
<?php if($type === 'sort_answer') {
|
101 |
+
foreach($qa['answer_sort']['answer'] as $k => $v) { ?>
|
102 |
+
<li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; background-color: whiteSmoke;">
|
103 |
+
<!-- <input class="small-text" name="answerJson[answer_sort][nr][]" value="<?php echo $qa['answer_sort']['nr'][$k]; ?>" placeholder="Nr.">-->
|
104 |
+
<textarea rows="2" cols="100" class="large-text" name="answerJson[answer_sort][answer][]"><?php echo $v; ?></textarea>
|
105 |
+
<input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete question', 'wp-pro-quiz'); ?>">
|
106 |
+
<a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
107 |
+
<label>
|
108 |
+
<?php _e('Allow HTML', 'wp-pro-quiz'); ?>
|
109 |
+
<input type="checkbox" name="answerJson[answer_sort][html][]" value="<?php echo $k; ?>" <?php echo (isset($qa['answer_sort']['html']) && in_array($k, $qa['answer_sort']['html'])) ? 'checked=checked' : ''; ?>>
|
110 |
+
</label>
|
111 |
+
</li>
|
112 |
+
<?php } } else { ?>
|
113 |
+
<li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; background-color: whiteSmoke;">
|
114 |
+
<textarea rows="2" cols="100" class="large-text" name="answerJson[answer_sort][answer][]"></textarea>
|
115 |
+
<input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete question', 'wp-pro-quiz'); ?>">
|
116 |
+
<a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
117 |
+
<label>
|
118 |
+
<?php _e('Allow HTML', 'wp-pro-quiz'); ?>
|
119 |
+
<input type="checkbox" name="answerJson[answer_sort][html][]" value="1">
|
120 |
+
</label>
|
121 |
+
</li>
|
122 |
+
<?php } ?>
|
123 |
+
</ul>
|
124 |
+
<input type="button" class="button-primary addAnswer" value="<?php _e('add new question', 'wp-pro-quiz'); ?>">
|
125 |
+
</div>
|
126 |
+
<div class="classic_answer">
|
127 |
+
<ul>
|
128 |
+
<li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; display:none;">
|
129 |
+
<textarea rows="2" cols="50" class="large-text" name="answerJson[classic_answer][answer][]"></textarea>
|
130 |
+
<label>
|
131 |
+
<input type="radio" name="answerJson[classic_answer][correct][]" value="0">
|
132 |
+
<?php _e('correct?', 'wp-pro-quiz'); ?>
|
133 |
+
</label>
|
134 |
+
<input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete question', 'wp-pro-quiz'); ?>">
|
135 |
+
<a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
136 |
+
<label>
|
137 |
+
<?php _e('Allow HTML', 'wp-pro-quiz'); ?>
|
138 |
+
<input type="checkbox" name="answerJson[classic_answer][html][]" value="0">
|
139 |
+
</label>
|
140 |
+
</li>
|
141 |
+
<?php if($type === 'single' || $type === 'multiple') {
|
142 |
+
foreach($qa['classic_answer']['answer'] as $k => $v) { ?>
|
143 |
+
<li style="border-bottom:1px dotted #ccc; padding-bottom: 5px;">
|
144 |
+
<textarea rows="2" cols="50" class="large-text" name="answerJson[classic_answer][answer][]"><?php echo $v; ?></textarea>
|
145 |
+
<label>
|
146 |
+
<input type="checkbox" name="answerJson[classic_answer][correct][]" value="<?php echo $k; ?>"
|
147 |
+
<?php echo (isset($qa['classic_answer']['correct']) && in_array($k, $qa['classic_answer']['correct'])) ? 'checked="checked"' : ''; ?>>
|
148 |
+
<?php _e('correct?', 'wp-pro-quiz'); ?>
|
149 |
+
</label>
|
150 |
+
<input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete question', 'wp-pro-quiz'); ?>">
|
151 |
+
<a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
152 |
+
<label>
|
153 |
+
<?php _e('Allow HTML', 'wp-pro-quiz'); ?>
|
154 |
+
<input type="checkbox" name="answerJson[classic_answer][html][]" value="<?php echo $k; ?>" <?php echo (isset($qa['classic_answer']['html']) && in_array($k, $qa['classic_answer']['html'])) ? 'checked="checked"' : ''; ?>>
|
155 |
+
</label>
|
156 |
+
</li>
|
157 |
+
<?php } } else { ?>
|
158 |
+
<li style="border-bottom:1px dotted #ccc; padding-bottom: 5px;">
|
159 |
+
<textarea rows="2" cols="50" class="large-text" name="answerJson[classic_answer][answer][]"></textarea>
|
160 |
+
<label>
|
161 |
+
<input type="radio" name="answerJson[classic_answer][correct][]" value="1" checked="checked">
|
162 |
+
<?php _e('correct?', 'wp-pro-quiz'); ?>
|
163 |
+
</label>
|
164 |
+
<input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete question', 'wp-pro-quiz'); ?>">
|
165 |
+
<a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
166 |
+
<label>
|
167 |
+
<?php _e('Allow HTML', 'wp-pro-quiz'); ?>
|
168 |
+
<input type="checkbox" name="answerJson[classic_answer][html][]" value="1">
|
169 |
+
</label>
|
170 |
+
</li>
|
171 |
+
<?php } ?>
|
172 |
+
</ul>
|
173 |
+
<input type="button" class="button-primary addAnswer" value="<?php _e('add new question', 'wp-pro-quiz'); ?>">
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
<input type="submit" name="submit" id="saveQuestion" class="button-primary" name="Senden">
|
178 |
+
</div>
|
179 |
+
</form>
|
180 |
+
</div>
|
181 |
+
|
182 |
+
<?php
|
183 |
+
}
|
184 |
+
}
|
lib/view/WpProQuiz_View_QuestionOverall.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_View_QuestionOverall extends WpProQuiz_View_View {
|
3 |
+
|
4 |
+
public function show() {
|
5 |
+
?>
|
6 |
+
<div class="wrap wpProQuiz_questionOverall">
|
7 |
+
<h2>Quiz: <?php echo $this->quiz->getName(); ?></h2>
|
8 |
+
<div id="sortMsg" class="updated" style="display: none;"><p><strong><?php _e('Questions sorted', 'wp-pro-quiz'); ?></strong></p></div>
|
9 |
+
<p><a class="button-secondary" href="admin.php?page=wpProQuiz"><?php _e('back to overview', 'wp-pro-quiz'); ?></a></p>
|
10 |
+
<table class="wp-list-table widefat">
|
11 |
+
<thead>
|
12 |
+
<tr>
|
13 |
+
<th scope="col"><?php _e('Name', 'wp-pro-quiz'); ?></th>
|
14 |
+
<th><?php _e('Action', 'wp-pro-quiz'); ?></th>
|
15 |
+
</tr>
|
16 |
+
</thead>
|
17 |
+
<tbody>
|
18 |
+
<?php
|
19 |
+
foreach ($this->question as $question) {
|
20 |
+
?>
|
21 |
+
<tr id="wpProQuiz_questionId_<?php echo $question->getId(); ?>">
|
22 |
+
<th><?php echo $question->getTitle(); ?></th>
|
23 |
+
<th>
|
24 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz&module=question&action=edit&quiz_id=<?php echo $this->quiz->getId(); ?>&id=<?php echo $question->getId(); ?>"><?php _e('Edit', 'wp-pro-quiz'); ?></a>
|
25 |
+
<a class="button-secondary wpProQuiz_delete" href="admin.php?page=wpProQuiz&module=question&action=delete&quiz_id=<?php echo $this->quiz->getId(); ?>&id=<?php echo $question->getId(); ?>"><?php _e('Delete', 'wp-pro-quiz'); ?></a>
|
26 |
+
<a class="button-secondary wpProQuiz_move" href="#" style="cursor:move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
|
27 |
+
</th>
|
28 |
+
</tr>
|
29 |
+
<?php } ?>
|
30 |
+
</tbody>
|
31 |
+
</table>
|
32 |
+
<p>
|
33 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz&module=question&action=add&quiz_id=<?php echo $this->quiz->getId(); ?>"><?php _e('Add question', 'wp-pro-quiz'); ?></a>
|
34 |
+
<a class="button-secondary" href="#" id="wpProQuiz_saveSort"><?php _e('Save order', 'wp-pro-quiz'); ?></a>
|
35 |
+
</p>
|
36 |
+
</div>
|
37 |
+
<?php
|
38 |
+
}
|
39 |
+
}
|
lib/view/WpProQuiz_View_QuizEdit.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_View_QuizEdit extends WpProQuiz_View_View {
|
3 |
+
|
4 |
+
public function show() {
|
5 |
+
?>
|
6 |
+
<div class="wrap">
|
7 |
+
<h2 style="margin-bottom: 10px;"><?php echo $this->header; ?></h2>
|
8 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz"><?php _e('back to overview', 'wp-pro-quiz'); ?></a>
|
9 |
+
<form method="post">
|
10 |
+
<div id="poststuff">
|
11 |
+
<div class="postbox">
|
12 |
+
<h3 class="hndle"><?php _e('Quiz title', 'wp-pro-quiz'); ?></h3>
|
13 |
+
<div class="inside">
|
14 |
+
<input name="name" type="text" class="regular-text" value="<?php echo $this->quiz->getName(); ?>">
|
15 |
+
</div>
|
16 |
+
</div>
|
17 |
+
<div class="postbox">
|
18 |
+
<h3 class="hndle"><?php _e('Options', 'wp-pro-quiz'); ?></h3>
|
19 |
+
<div class="inside">
|
20 |
+
<table class="form-table">
|
21 |
+
<tbody>
|
22 |
+
<tr>
|
23 |
+
<th scope="row">
|
24 |
+
<?php _e('Hide quiz title', 'wp-pro-quiz'); ?>
|
25 |
+
</th>
|
26 |
+
<td>
|
27 |
+
<fieldset>
|
28 |
+
<legend class="screen-reader-text">
|
29 |
+
<span><?php _e('Hide title', 'wp-pro-quiz'); ?></span>
|
30 |
+
</legend>
|
31 |
+
<label for="title_hidden">
|
32 |
+
<input type="checkbox" id="title_hidden" value="1" name="titleHidden" <?php echo $this->quiz->isTitleHidden() ? 'checked="checked"' : '' ?> >
|
33 |
+
</label>
|
34 |
+
<p class="description">
|
35 |
+
<?php _e('The title serves as quiz heading.', 'wp-pro-quiz'); ?>
|
36 |
+
</p>
|
37 |
+
</fieldset>
|
38 |
+
</td>
|
39 |
+
</tr>
|
40 |
+
<tr>
|
41 |
+
<th scope="row">
|
42 |
+
<?php _e('Display question randomly', 'wp-pro-quiz'); ?>
|
43 |
+
</th>
|
44 |
+
<td>
|
45 |
+
<fieldset>
|
46 |
+
<legend class="screen-reader-text">
|
47 |
+
<span><?php _e('Display question randomly', 'wp-pro-quiz'); ?></span>
|
48 |
+
</legend>
|
49 |
+
<label for="question_random">
|
50 |
+
<input type="checkbox" id="question_random" value="1" name="questionRandom" <?php echo $this->quiz->isQuestionRandom() ? 'checked="checked"' : '' ?> >
|
51 |
+
</label>
|
52 |
+
</fieldset>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
<tr>
|
56 |
+
<th scope="row">
|
57 |
+
<?php _e('Display answers randomly', 'wp-pro-quiz'); ?>
|
58 |
+
</th>
|
59 |
+
<td>
|
60 |
+
<fieldset>
|
61 |
+
<legend class="screen-reader-text">
|
62 |
+
<span><?php _e('Display answers randomly', 'wp-pro-quiz'); ?></span>
|
63 |
+
</legend>
|
64 |
+
<label for="answer_random">
|
65 |
+
<input type="checkbox" id="answer_random" value="1" name="answerRandom" <?php echo $this->quiz->isAnswerRandom() ? 'checked="checked"' : '' ?> >
|
66 |
+
</label>
|
67 |
+
</fieldset>
|
68 |
+
</td>
|
69 |
+
</tr>
|
70 |
+
<tr>
|
71 |
+
<th scope="row">
|
72 |
+
<?php _e('Time limit', 'wp-pro-quiz'); ?>
|
73 |
+
</th>
|
74 |
+
<td>
|
75 |
+
<fieldset>
|
76 |
+
<legend class="screen-reader-text">
|
77 |
+
<span><?php _e('Time limit', 'wp-pro-quiz'); ?></span>
|
78 |
+
</legend>
|
79 |
+
<label for="time_limit">
|
80 |
+
<input type="text" id="time_limit" value="<?php echo $this->quiz->getTimeLimit(); ?>" name="timeLimit"> <?php _e('Seconds', 'wp-pro-quiz'); ?>
|
81 |
+
</label>
|
82 |
+
<p class="description">
|
83 |
+
<?php _e('0 = no limit', 'wp-pro-quiz'); ?>
|
84 |
+
</p>
|
85 |
+
</fieldset>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
<tr>
|
89 |
+
<th scope="row">
|
90 |
+
<?php _e('Check -> continue', 'wp-pro-quiz'); ?>
|
91 |
+
</th>
|
92 |
+
<td>
|
93 |
+
<fieldset>
|
94 |
+
<legend class="screen-reader-text">
|
95 |
+
<span><?php _e('Check -> continue', 'wp-pro-quiz'); ?></span>
|
96 |
+
</legend>
|
97 |
+
<label for="check_next">
|
98 |
+
<input type="checkbox" id="check_next" value="1" name="checkAnswer" <?php echo $this->quiz->isCheckAnswer() ? 'checked="checked"' : '' ?>>
|
99 |
+
</label>
|
100 |
+
<p class="description">
|
101 |
+
<?php _e('Show "right or wrong" after the question. Otherwise the solutions will be displayed at the end.', 'wp-pro-quiz'); ?>
|
102 |
+
</p>
|
103 |
+
</fieldset>
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
<tr>
|
107 |
+
<th scope="row">
|
108 |
+
<?php _e('Back button', 'wp-pro-quiz'); ?>
|
109 |
+
</th>
|
110 |
+
<td>
|
111 |
+
<fieldset>
|
112 |
+
<legend class="screen-reader-text">
|
113 |
+
<span><?php _e('Back button', 'wp-pro-quiz'); ?></span>
|
114 |
+
</legend>
|
115 |
+
<label for="back_button">
|
116 |
+
<input type="checkbox" id="back_button" value="1" name="backButton" <?php echo $this->quiz->isBackButton() ? 'checked="checked"' : '' ?>>
|
117 |
+
</label>
|
118 |
+
<p class="description">
|
119 |
+
<?php _e('Allow to use back button in a question. (Option will be ignored if "Check -> Continue" was used)', 'wp-pro-quiz'); ?>
|
120 |
+
</p>
|
121 |
+
</fieldset>
|
122 |
+
</td>
|
123 |
+
</tr>
|
124 |
+
</tbody>
|
125 |
+
</table>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
<div class="postbox">
|
129 |
+
<h3 class="hndle"><?php _e('Quiz description', 'wp-pro-quiz'); ?></h3>
|
130 |
+
<div class="inside">
|
131 |
+
<p class="description">
|
132 |
+
<?php _e('This text will be displayed before start of the quiz.', 'wp-pro-quiz'); ?>
|
133 |
+
</p>
|
134 |
+
<?php
|
135 |
+
wp_editor($this->quiz->getText(), "text");
|
136 |
+
?>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
<div class="postbox">
|
140 |
+
<h3 class="hndle"><?php _e('Results text', 'wp-pro-quiz'); ?></h3>
|
141 |
+
<div class="inside">
|
142 |
+
<p class="description">
|
143 |
+
<?php _e('This text will be displayed at the end of the quiz (in results). (this text is optional)', 'wp-pro-quiz'); ?>
|
144 |
+
</p>
|
145 |
+
<?php
|
146 |
+
wp_editor($this->quiz->getResultText(), "resultText");
|
147 |
+
?>
|
148 |
+
</div>
|
149 |
+
</div>
|
150 |
+
<input type="submit" name="submit" class="button-primary">
|
151 |
+
</div>
|
152 |
+
</form>
|
153 |
+
</div>
|
154 |
+
<?php
|
155 |
+
}
|
156 |
+
}
|
lib/view/WpProQuiz_View_QuizOverall.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WpProQuiz_View_QuizOverall extends WpProQuiz_View_View {
|
4 |
+
|
5 |
+
public function show() {
|
6 |
+
?>
|
7 |
+
<div class="wrap wpProQuiz_quizOverall">
|
8 |
+
<h2><?php _e('Quiz overview', 'wp-pro-quiz'); ?></h2>
|
9 |
+
<table class="wp-list-table widefat">
|
10 |
+
<thead>
|
11 |
+
<tr>
|
12 |
+
<th scope="col"><?php _e('ID', 'wp-pro-quiz'); ?></th>
|
13 |
+
<th scope="col"><?php _e('Shortcode', 'wp-pro-quiz'); ?></th>
|
14 |
+
<th scope="col"><?php _e('Name', 'wp-pro-quiz'); ?></th>
|
15 |
+
<th scope="col"><?php _e('Action', 'wp-pro-quiz'); ?></th>
|
16 |
+
</tr>
|
17 |
+
</thead>
|
18 |
+
<tbody>
|
19 |
+
<?php
|
20 |
+
foreach ($this->quiz as $quiz) {
|
21 |
+
?>
|
22 |
+
<tr>
|
23 |
+
<th><?php echo $quiz->getId(); ?></th>
|
24 |
+
<th>[WpProQuiz <?php echo $quiz->getId(); ?>]</th>
|
25 |
+
<th><?php echo $quiz->getName(); ?></th>
|
26 |
+
<th>
|
27 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz&module=question&quiz_id=<?php echo $quiz->getId(); ?>"><?php _e('Questions', 'wp-pro-quiz'); ?></a>
|
28 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz&action=edit&id=<?php echo $quiz->getId(); ?>"><?php _e('Edit', 'wp-pro-quiz'); ?></a>
|
29 |
+
<a class="button-secondary wpProQuiz_delete" href="admin.php?page=wpProQuiz&action=delete&id=<?php echo $quiz->getId(); ?>"><?php _e('Delete', 'wp-pro-quiz'); ?></a>
|
30 |
+
<a class="button-secondary wpProQuiz_prview" href="admin.php?page=wpProQuiz&module=preview&id=<?php echo $quiz->getId(); ?>"><?php _e('Preview', 'wp-pro-quiz'); ?></a>
|
31 |
+
</th>
|
32 |
+
</tr>
|
33 |
+
<?php } ?>
|
34 |
+
</tbody>
|
35 |
+
</table>
|
36 |
+
<p>
|
37 |
+
<a class="button-secondary" href="admin.php?page=wpProQuiz&action=add"><?php echo __('Add quiz', 'wp-pro-quiz'); ?></a>
|
38 |
+
</p>
|
39 |
+
</div>
|
40 |
+
|
41 |
+
<?php
|
42 |
+
}
|
43 |
+
}
|
lib/view/WpProQuiz_View_View.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WpProQuiz_View_View {
|
3 |
+
|
4 |
+
private $data = array();
|
5 |
+
|
6 |
+
public function __set($name, $value) {
|
7 |
+
$this->data[$name] = $value;
|
8 |
+
}
|
9 |
+
|
10 |
+
public function __get($name) {
|
11 |
+
if(isset($this->data[$name]))
|
12 |
+
return $this->data[$name];
|
13 |
+
}
|
14 |
+
|
15 |
+
public static function admin_notices($msg, $type = 'error') {
|
16 |
+
if($type === 'info')
|
17 |
+
echo '<div class="updated"><p><strong>'.$msg.'</strong></p></div>';
|
18 |
+
else
|
19 |
+
echo '<div class="error"><p><strong>'.$msg.'</strong></p></div>';
|
20 |
+
}
|
21 |
+
|
22 |
+
public function redirect($url) {
|
23 |
+
|
24 |
+
}
|
25 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Wp-Pro-Quiz ===
|
2 |
+
Contributors: Julius Fischer
|
3 |
+
Tags: quiz
|
4 |
+
Requires at least: 3.3
|
5 |
+
Tested up to: 3.4.2
|
6 |
+
Stable tag: 0.1
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
+
A powerful and beautiful quiz plugin for WordPress.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
A powerful and beautiful quiz plugin for WordPress.
|
15 |
+
|
16 |
+
= Functions =
|
17 |
+
* Single Choice
|
18 |
+
* Multiple Choice
|
19 |
+
* "Sorting" Choice
|
20 |
+
* "Free" Choice
|
21 |
+
* Timelimit
|
22 |
+
* Random Answer (optional)
|
23 |
+
* Random Question (optional)
|
24 |
+
* HTML in questions and answers is allowed (optional)
|
25 |
+
* Multimedia in questions
|
26 |
+
* Back-Button (optional)
|
27 |
+
* Correct / incorrect response message for all questions (optional)
|
28 |
+
* Preview-function
|
29 |
+
* really nice standard design
|
30 |
+
* mighty
|
31 |
+
|
32 |
+
= Translations =
|
33 |
+
* English
|
34 |
+
* German (Deutsch)
|
35 |
+
|
36 |
+
= Live Demo =
|
37 |
+
http://www.it-gecko.de/wp-pro-quiz-quiz-plugin-fuer-wordpress.html (scroll to "Demo")
|
38 |
+
|
39 |
+
== Installation ==
|
40 |
+
|
41 |
+
1. Upload the wp-pro-quiz folder to the /wp-content/plugins/ directory
|
42 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
43 |
+
|
44 |
+
== Screenshots ==
|
45 |
+
|
46 |
+
1. Quiz demo - Start page
|
47 |
+
2. Quiz demo - Correkt message
|
48 |
+
3. Quiz demo - Multimedia
|
49 |
+
4. Quiz demo - Results
|
50 |
+
5. Quiz demo2 - Time limit and back button
|
51 |
+
6. Adminmenu - Quiz overview
|
52 |
+
7. Adminmenu - Create quiz
|
53 |
+
8. Adminmenu - Quiz question overview
|
54 |
+
9. Adminmenu - Create question
|
55 |
+
|
56 |
+
|
57 |
+
== Changelog ==
|
58 |
+
|
59 |
+
= 0.1 =
|
60 |
+
* release
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|
screenshot-5.png
ADDED
Binary file
|
screenshot-6.png
ADDED
Binary file
|
screenshot-7.png
ADDED
Binary file
|
screenshot-8.png
ADDED
Binary file
|
screenshot-9.png
ADDED
Binary file
|
template/wp-pro-quiz_overall_view.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
?>
|
3 |
+
|
4 |
+
<div>
|
5 |
+
<h2>Quiz �bersicht</h2>
|
6 |
+
<table class="wp-list-table widefat">
|
7 |
+
<thead>
|
8 |
+
<tr>
|
9 |
+
<th scope="col">ID</th>
|
10 |
+
<th scope="col">Name</th>
|
11 |
+
</tr>
|
12 |
+
</thead>
|
13 |
+
<tbody>
|
14 |
+
<tr>
|
15 |
+
<th>1</th>
|
16 |
+
<th>Test Quiz</th>
|
17 |
+
</tr>
|
18 |
+
</tbody>
|
19 |
+
</table>
|
20 |
+
</div>
|
template/wpProQuizEditQuiz.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
add_action('admin_init', 'editor_admin_init');
|
3 |
+
add_action('admin_head', 'editor_admin_head');
|
4 |
+
|
5 |
+
function editor_admin_init() {
|
6 |
+
wp_enqueue_script('word-count');
|
7 |
+
wp_enqueue_script('post');
|
8 |
+
wp_enqueue_script('editor');
|
9 |
+
wp_enqueue_script('media-upload');
|
10 |
+
}
|
11 |
+
|
12 |
+
function editor_admin_head() {
|
13 |
+
wp_tiny_mce();
|
14 |
+
}
|
15 |
+
|
16 |
+
var_dump($_POST);
|
17 |
+
|
18 |
+
?>
|
19 |
+
|
20 |
+
<div style="padding-right: 20px;">
|
21 |
+
<form method="post">
|
22 |
+
<table class="form-table">
|
23 |
+
<tbody>
|
24 |
+
<tr valign="top">
|
25 |
+
<th>
|
26 |
+
<label for="quiz_name">
|
27 |
+
Name
|
28 |
+
</label>
|
29 |
+
</th>
|
30 |
+
<td>
|
31 |
+
<input name="quiz_name" type="text" class="regular-text">
|
32 |
+
</td>
|
33 |
+
</tr>
|
34 |
+
<tr valign="top">
|
35 |
+
<th>
|
36 |
+
<label for="quiz_text">
|
37 |
+
Text
|
38 |
+
</label>
|
39 |
+
</th>
|
40 |
+
<td>ja
|
41 |
+
<?php
|
42 |
+
wp_editor("", "quiz_text");
|
43 |
+
?>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
</tbody>
|
47 |
+
</table>
|
48 |
+
<p>
|
49 |
+
<input type="submit" class="button-primary">
|
50 |
+
</p>
|
51 |
+
</form>
|
52 |
+
</div>
|
uninstall.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('WP_UNINSTALL_PLUGIN'))
|
4 |
+
exit();
|
5 |
+
|
6 |
+
include_once 'lib/helper/WpProQuiz_Helper_DbUpgrade.php';
|
7 |
+
|
8 |
+
$db = new WpProQuiz_Helper_DbUpgrade();
|
9 |
+
$db->delete();
|
10 |
+
|
11 |
+
delete_option('wpProQuiz_dbVersion');
|
wp-pro-quiz.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP-Pro-Quiz
|
4 |
+
Plugin URI: http://wordpress.org/extend/plugins/wp-pro-quiz
|
5 |
+
Description: A powerful and beautiful quiz plugin for WordPress.
|
6 |
+
Version: 0.1
|
7 |
+
Author: Julius Fischer
|
8 |
+
Author URI: http://www.it-gecko.de
|
9 |
+
*/
|
10 |
+
|
11 |
+
//Wo anders ohne funktion
|
12 |
+
register_activation_hook(__FILE__, array('WpProQuiz_Controller_Admin', 'install'));
|
13 |
+
|
14 |
+
load_plugin_textdomain('wp-pro-quiz', false, dirname(plugin_basename(__FILE__)).'/languages');
|
15 |
+
|
16 |
+
if(is_admin()) {
|
17 |
+
require_once 'lib/controller/WpProQuiz_Controller_Admin.php';
|
18 |
+
|
19 |
+
new WpProQuiz_Controller_Admin(dirname(__FILE__));
|
20 |
+
} else {
|
21 |
+
require_once 'lib/controller/WpProQuiz_Controller_Front.php';
|
22 |
+
|
23 |
+
new WpProQuiz_Controller_Front(dirname(__FILE__));
|
24 |
+
}
|