Wp-Pro-Quiz - Version 0.1

Version Description

  • release
Download this release

Release Info

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

Version 0.1

Files changed (40) hide show
  1. css/wpProQuiz_front.css +113 -0
  2. css/wpProQuiz_front.min.css +1 -0
  3. js/wpProQuiz_admin.js +231 -0
  4. js/wpProQuiz_admin.min.js +7 -0
  5. js/wpProQuiz_front.js +340 -0
  6. js/wpProQuiz_front.min.js +12 -0
  7. languages/wp-pro-quiz-de_DE.mo +0 -0
  8. languages/wp-pro-quiz-de_DE.po +374 -0
  9. lib/controller/WpProQuiz_Controller_Admin.php +106 -0
  10. lib/controller/WpProQuiz_Controller_Front.php +84 -0
  11. lib/controller/WpProQuiz_Controller_Preview.php +30 -0
  12. lib/controller/WpProQuiz_Controller_Question.php +135 -0
  13. lib/controller/WpProQuiz_Controller_Quiz.php +92 -0
  14. lib/helper/WpProQuiz_Helper_DbUpgrade.php +102 -0
  15. lib/model/WpProQuiz_Model_Mapper.php +20 -0
  16. lib/model/WpProQuiz_Model_Model.php +55 -0
  17. lib/model/WpProQuiz_Model_Question.php +106 -0
  18. lib/model/WpProQuiz_Model_QuestionMapper.php +117 -0
  19. lib/model/WpProQuiz_Model_Quiz.php +109 -0
  20. lib/model/WpProQuiz_Model_QuizMapper.php +74 -0
  21. lib/view/WpProQuiz_View_FrontQuiz.php +172 -0
  22. lib/view/WpProQuiz_View_QuestionEdit.php +184 -0
  23. lib/view/WpProQuiz_View_QuestionOverall.php +39 -0
  24. lib/view/WpProQuiz_View_QuizEdit.php +156 -0
  25. lib/view/WpProQuiz_View_QuizOverall.php +43 -0
  26. lib/view/WpProQuiz_View_View.php +25 -0
  27. readme.txt +60 -0
  28. screenshot-1.png +0 -0
  29. screenshot-2.png +0 -0
  30. screenshot-3.png +0 -0
  31. screenshot-4.png +0 -0
  32. screenshot-5.png +0 -0
  33. screenshot-6.png +0 -0
  34. screenshot-7.png +0 -0
  35. screenshot-8.png +0 -0
  36. screenshot-9.png +0 -0
  37. template/wp-pro-quiz_overall_view.php +20 -0
  38. template/wpProQuizEditQuiz.php +52 -0
  39. uninstall.php +11 -0
  40. 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 @@