Wp-Pro-Quiz - Version 0.2

Version Description

  • bugfix
  • add statistics function
  • small changes
Download this release

Release Info

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

Code changes from version 0.1 to 0.2

js/wpProQuiz_admin.js CHANGED
@@ -24,6 +24,7 @@ jQuery(document).ready(function($) {
24
  }
25
 
26
  $('input[name="answerType"]:checked').click();
 
27
  };
28
 
29
  var formListener = {
@@ -66,6 +67,13 @@ jQuery(document).ready(function($) {
66
  }
67
  });
68
 
 
 
 
 
 
 
 
69
  },
70
 
71
  displaySingle: function(type) {
@@ -111,15 +119,9 @@ jQuery(document).ready(function($) {
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;
@@ -197,11 +199,17 @@ jQuery(document).ready(function($) {
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);
@@ -224,8 +232,32 @@ jQuery(document).ready(function($) {
224
 
225
  init();
226
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
 
228
- $('.wpProQuiz_quizOverall').wpProQuiz_preview();
229
- $('.wpProQuiz_questionEdit').wpProQuiz_questionEdit();
230
- $('.wpProQuiz_questionOverall').wpProQuiz_questionOverall();
 
 
 
 
 
 
 
 
231
  });
24
  }
25
 
26
  $('input[name="answerType"]:checked').click();
27
+ $('#wpProQuiz_correctSameText').change();
28
  };
29
 
30
  var formListener = {
67
  }
68
  });
69
 
70
+ $('#wpProQuiz_correctSameText').change(function() {
71
+ if(this.checked)
72
+ $('#wpProQuiz_incorrectMassageBox').hide();
73
+ else
74
+ $('#wpProQuiz_incorrectMassageBox').show();
75
+ });
76
+
77
  },
78
 
79
  displaySingle: function(type) {
119
  };
120
 
121
  var validate = function () {
 
122
  var question = tinymce.editors.question.getContent();
123
  var type = $('input[name="answerType"]:checked');
124
 
 
 
 
 
 
125
  if(isEmpty(question)) {
126
  alert(wpProQuizLocalize.no_question_msg);
127
  return false;
199
  });
200
 
201
  return array;
202
+ },
203
+
204
+ sortUpdate: function(e, ui) {
205
+ $('.wpProQuiz_questionOverall tbody').children().each(function() {
206
+ $t = $(this).children().first().text($(this).index() + 1);
207
+ });
208
  }
209
  };
210
 
211
  var init = function() {
212
+ $('.wp-list-table tbody').sortable({ handle: '.wpProQuiz_move', update: methode.sortUpdate });
213
 
214
  $('.wpProQuiz_delete').click(function(e) {
215
  var b = confirm(wpProQuizLocalize.delete_msg);
232
 
233
  init();
234
  };
235
+
236
+ $.fn.wpProQuiz_quizEdit = function() {
237
+ var init = function() {
238
+ $('#statistics_on').change(function() {
239
+ if(this.checked) {
240
+ $('#statistics_ip_lock_tr').show();
241
+ } else {
242
+ $('#statistics_ip_lock_tr').hide();
243
+ }
244
+ });
245
+
246
+ $('#statistics_on').change();
247
+ };
248
+
249
+ init();
250
+ };
251
 
252
+ if($('.wpProQuiz_quizOverall').length)
253
+ $('.wpProQuiz_quizOverall').wpProQuiz_preview();
254
+
255
+ if($('.wpProQuiz_quizEdit').length)
256
+ $('.wpProQuiz_quizEdit').wpProQuiz_quizEdit();
257
+
258
+ if($('.wpProQuiz_questionEdit').length)
259
+ $('.wpProQuiz_questionEdit').wpProQuiz_questionEdit();
260
+
261
+ if($('.wpProQuiz_questionOverall').length)
262
+ $('.wpProQuiz_questionOverall').wpProQuiz_questionOverall();
263
  });
js/wpProQuiz_admin.min.js CHANGED
@@ -1,7 +1,9 @@
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()});
 
 
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 c()});a(".sort_answer ul, .classic_answer ul").sortable({handle:".wpProQuiz_move",update:function(){b.setValueClassicAnswer()}});a("#wpProQuiz_correctSameText").change(function(){this.checked?a("#wpProQuiz_incorrectMassageBox").hide():a("#wpProQuiz_incorrectMassageBox").show()})},
3
+ displaySingle:function(b){a(".classic_answer").find('input[name="answerJson[classic_answer][correct][]"]').each(function(){a("<input type="+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(c){a(c).siblings("ul").children().first().clone().css("display",
4
+ "block").appendTo(a(c).siblings("ul"));b.setValueClassicAnswer();a(".deleteAnswer").click(function(){b.deleteAnswer(this)})},deleteAnswer:function(c){a(c).parent("li").remove();b.setValueClassicAnswer()},setValueClassicAnswer:function(){i=0;a('input[name="answerJson[classic_answer][correct][]"]').each(function(){this.value=i++})}},c=function(){var b=tinymce.editors.question.getContent(),c=a('input[name="answerType"]:checked');if(!b||0===b.length)return alert(wpProQuizLocalize.no_question_msg),!1;
5
+ if("single"==c.val()||"multiple"==c.val()){var d=!0;if(1>a('input[name="answerJson[classic_answer][correct][]"]:checked').each(function(){d=""!=a.trim(a(this).parent().siblings("textarea").val())?d&1:!1}).size())return alert(wpProQuizLocalize.no_correct_msg),!1;if(!d)return alert(wpProQuizLocalize.no_answer_msg),!1}else if("sort_answer"==c.val()&&(d=!1,a('textarea[name="answerJson[answer_sort][answer][]"]').each(function(){var b=a(this).val();d=!b||0===b.length?d|0:!0}),!d))return alert(wpProQuizLocalize.no_answer_msg),
6
+ !1;return!0};b.setup();1>a('input[name="answerType"][checked="checked"]').size()&&a('input[name="answerType"][value="single"]').attr({checked:"checked"});a('input[name="answerType"]:checked').click();a("#wpProQuiz_correctSameText").change()};a.fn.wpProQuiz_questionOverall=function(){var b={saveSort:function(){var c={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,c,function(b){console.debug(b);
7
+ 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},sortUpdate:function(){a(".wpProQuiz_questionOverall tbody").children().each(function(){$t=a(this).children().first().text(a(this).index()+1)})}};a(".wp-list-table tbody").sortable({handle:".wpProQuiz_move",update:b.sortUpdate});a(".wpProQuiz_delete").click(function(a){return!confirm(wpProQuizLocalize.delete_msg)?(a.preventDefault(),
8
+ !1):!0});a("#wpProQuiz_saveSort").click(function(a){a.preventDefault();b.saveSort()});console.debug(a)};a.fn.wpProQuiz_quizEdit=function(){a("#statistics_on").change(function(){this.checked?a("#statistics_ip_lock_tr").show():a("#statistics_ip_lock_tr").hide()});a("#statistics_on").change()};a(".wpProQuiz_quizOverall").length&&a(".wpProQuiz_quizOverall").wpProQuiz_preview();a(".wpProQuiz_quizEdit").length&&a(".wpProQuiz_quizEdit").wpProQuiz_quizEdit();a(".wpProQuiz_questionEdit").length&&a(".wpProQuiz_questionEdit").wpProQuiz_questionEdit();
9
+ a(".wpProQuiz_questionOverall").length&&a(".wpProQuiz_questionOverall").wpProQuiz_questionOverall()});
js/wpProQuiz_front.js CHANGED
@@ -7,9 +7,12 @@
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();
@@ -104,7 +107,7 @@
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':
@@ -200,6 +203,8 @@
200
 
201
  $(btn).hide();
202
  checked.attr('disabled', 'disabled');
 
 
203
 
204
  $question.find('.wpProQuiz_response').show();
205
 
@@ -248,6 +253,19 @@
248
  $element.find('.wpProQuiz_results').show();
249
  $element.find('.wpProQuiz_time_limit').hide();
250
  plugin.methode.setQuizTime();
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  },
252
 
253
  reShowQuestion: function() {
7
  var count = 0;
8
  var intervalId = 0;
9
  var startTime = 0;
10
+ var results = new Object();
11
 
12
  plugin.methode = {
13
  startQuiz: function() {
14
+
15
+ results = new Object();
16
 
17
  if(config.questionRandom) {
18
  plugin.methode.questionRandom();
107
  $element.find('.wpProQuiz_questionList').each(function() {
108
  var j = config.json[i];
109
  var ii = 0;
110
+ $(this).parent().parent().data('type', j.answer_type).data('questionId', j.id);
111
  $(this).find('input[name="question"]').each(function() {
112
  switch(j.answer_type) {
113
  case 'single':
203
 
204
  $(btn).hide();
205
  checked.attr('disabled', 'disabled');
206
+
207
+ results[$question.data('questionId')] = Number(correct);
208
 
209
  $question.find('.wpProQuiz_response').show();
210
 
253
  $element.find('.wpProQuiz_results').show();
254
  $element.find('.wpProQuiz_time_limit').hide();
255
  plugin.methode.setQuizTime();
256
+ plugin.methode.sendStatistics();
257
+ },
258
+
259
+ sendStatistics: function() {
260
+ if(!config.statisticsOn)
261
+ return;
262
+
263
+ $.ajax({
264
+ url: config.url,
265
+ type: 'POST',
266
+ cache: false,
267
+ data: {action: 'wp_pro_quiz_statistics_save', 'results': results, 'quizId': config.quizId}
268
+ });
269
  },
270
 
271
  reShowQuestion: function() {
js/wpProQuiz_front.min.js CHANGED
@@ -1,12 +1,13 @@
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);
 
1
+ (function(b){b.wpProQuizFront=function(k,e){var a=b(k),c=this,j=0,m=0,h=0,n=0,l={};c.methode={startQuiz:function(){l={};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;n=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();
2
+ a.find(".wpProQuiz_listItem").first().fadeIn(200);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
+ n.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).data("questionId",a.id);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",
6
+ a.correct)}});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"==
7
+ i){g=!0;d.find(".wpProQuiz_sortable").each(function(){var a=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,
8
+ d){h.append(d)});c=g}else"free_answer"==i&&(i=b.trim(e.val()).toLowerCase(),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");l[d.data("questionId")]=Number(c);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(),
9
+ d=f.next();f.hide();d.length?(d.show(),e.backButton&&!e.checkAnswer&&d.find('input[name="back"]').show()):(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/m))+"%)");a.find(".wpProQuiz_results").show();
10
+ a.find(".wpProQuiz_time_limit").hide();c.methode.setQuizTime();c.methode.sendStatistics()},sendStatistics:function(){e.statisticsOn&&b.ajax({url:e.url,type:"POST",cache:!1,data:{action:"wp_pro_quiz_statistics_save",results:l,quizId:e.quizId}})},reShowQuestion:function(){a.find('input[name="next"], input[name="check"], input[name="back"]').hide();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())-
11
+ 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);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();
12
+ b.hide();m=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)});a.find('input[name="restartQuiz"]').click(function(a){a.preventDefault();c.methode.reStartQuiz()});a.find('input[name="reShowQuestion"]').click(function(a){a.preventDefault();
13
+ 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 CHANGED
Binary file
languages/wp-pro-quiz-de_DE.po CHANGED
@@ -1,8 +1,8 @@
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"
@@ -14,39 +14,55 @@ msgstr ""
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
 
@@ -54,92 +70,94 @@ msgstr "Frage hinzugefügt"
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
 
@@ -147,121 +165,172 @@ msgstr "zurück zur Übersicht"
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
 
@@ -329,19 +398,56 @@ 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)"
@@ -369,6 +475,52 @@ msgstr "Fragen"
369
  msgid "Preview"
370
  msgstr "Vorschau"
371
 
372
- #: lib/view/WpProQuiz_View_QuizOverall.php:37
373
  msgid "Add quiz"
374
  msgstr "Quiz hinzufügen"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wp-Pro-Quiz\n"
4
+ "POT-Creation-Date: 2012-11-19 16:09+0100\n"
5
+ "PO-Revision-Date: 2012-11-19 16:09+0100\n"
6
  "Last-Translator: Julius Fischer <julius.f@gmx.net>\n"
7
  "Language-Team: Julius Fischer\n"
8
  "Language: German\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
+ #: lib/controller/WpProQuiz_Controller_Admin.php:36
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:37
22
  msgid "Title is not filled!"
23
  msgstr "Titel wurde nicht ausgefüllt!"
24
 
25
+ #: lib/controller/WpProQuiz_Controller_Admin.php:38
26
  msgid "No question deposited!"
27
  msgstr "Keine Frage hinterlegt!"
28
 
29
+ #: lib/controller/WpProQuiz_Controller_Admin.php:39
30
  msgid "Correct answer was not selected!"
31
  msgstr "Keine korrekte Antwort markiert!"
32
 
33
+ #: lib/controller/WpProQuiz_Controller_Admin.php:40
34
  msgid "No answer deposited!"
35
  msgstr "Keine Antwort hinterlegt!"
36
 
37
+ #: lib/controller/WpProQuiz_Controller_Question.php:9
38
+ #: lib/controller/WpProQuiz_Controller_Question.php:19
39
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:42
40
+ msgid "Quiz not found"
41
+ msgstr "Quiz nicht gefunden"
42
+
43
+ #: lib/controller/WpProQuiz_Controller_Question.php:61
44
  msgid "Edit question"
45
  msgstr "Frage bearbeiten"
46
 
47
+ #: lib/controller/WpProQuiz_Controller_Question.php:65
48
+ msgid "Question not found"
49
+ msgstr "Frage nicht gefunden"
50
+
51
+ #: lib/controller/WpProQuiz_Controller_Question.php:78
52
+ #: lib/controller/WpProQuiz_Controller_Question.php:104
53
+ #, php-format
54
+ msgid "Question: %d"
55
+ msgstr "Frage: %d"
56
+
57
+ #: lib/controller/WpProQuiz_Controller_Question.php:82
58
  msgid "Question edited"
59
  msgstr "Frage geändert"
60
 
61
+ #: lib/controller/WpProQuiz_Controller_Question.php:91
62
  msgid "New question"
63
  msgstr "Neue Frage"
64
 
65
+ #: lib/controller/WpProQuiz_Controller_Question.php:109
66
  msgid "Question added"
67
  msgstr "Frage hinzugefügt"
68
 
70
  msgid "Edit quiz"
71
  msgstr "Quiz bearbeiten"
72
 
73
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:51
74
+ msgid "Quiz edited"
75
+ msgstr "Quiz bearbeitet"
76
+
77
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:56
78
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:79
79
  msgid "Quiz title or quiz description are not filled"
80
  msgstr "Quiz Titel oder Quiz Beschreibung nicht ausgefüllt"
81
 
 
 
 
 
 
82
  #: lib/controller/WpProQuiz_Controller_Quiz.php:67
83
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:73
84
  msgid "Create quiz"
85
  msgstr "Quiz erstellen"
86
 
87
+ #: lib/controller/WpProQuiz_Controller_Quiz.php:91
88
  msgid "Quiz deleted"
89
  msgstr "Quiz gelöscht"
90
 
91
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:52
92
  msgid "Start quiz"
93
  msgstr "Quiz starten"
94
 
95
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:56
96
  msgid "Results"
97
  msgstr "Ergebnis"
98
 
99
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:58
100
  #, php-format
101
  msgid "%s from %s questions answered correctly"
102
  msgstr "%s von %s Frage korrekt beantwortet"
103
 
104
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:61
105
  msgid "Time has elapsed"
106
  msgstr "Zeit ist abgelaufen"
107
 
108
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:64
109
  msgid "Your time: <span></span>"
110
  msgstr "Ihre Zeit: <span></span>"
111
 
112
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:70
113
  msgid "Restart quiz"
114
  msgstr "Quiz erneut starten"
115
 
116
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:71
117
  msgid "View question"
118
  msgstr "Frage ansehen"
119
 
120
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:75
121
  #: lib/view/WpProQuiz_View_QuizEdit.php:72
122
  #: lib/view/WpProQuiz_View_QuizEdit.php:77
123
  msgid "Time limit"
124
  msgstr "Zeitlimit"
125
 
126
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:87
127
  #, php-format
128
  msgid "Question %s from %s"
129
  msgstr "Frage %s von %s"
130
 
131
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:89
132
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:26
133
+ #: lib/view/WpProQuiz_View_Statistics.php:19
134
  msgid "Question"
135
  msgstr "Frage"
136
 
137
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:133
138
  msgid "Right"
139
  msgstr "Richtig"
140
 
141
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:141
142
  msgid "Wrong"
143
  msgstr "Falsch"
144
 
145
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:156
146
  msgid "Check"
147
  msgstr "Prüfen"
148
 
149
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:157
150
  msgid "Back"
151
  msgstr "Zurück"
152
 
153
+ #: lib/view/WpProQuiz_View_FrontQuiz.php:158
154
  msgid "Next exercise"
155
  msgstr "Nächste Frage"
156
 
157
  #: lib/view/WpProQuiz_View_QuestionEdit.php:13
158
  #: lib/view/WpProQuiz_View_QuestionOverall.php:9
159
  #: lib/view/WpProQuiz_View_QuizEdit.php:8
160
+ #: lib/view/WpProQuiz_View_Statistics.php:8
161
  msgid "back to overview"
162
  msgstr "zurück zur Übersicht"
163
 
165
  msgid "Title"
166
  msgstr "Titel"
167
 
168
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:17
169
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:34
170
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:51
171
+ #: lib/view/WpProQuiz_View_QuizEdit.php:178
172
+ msgid "(optional)"
173
+ msgstr "(Optional)"
174
+
175
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:20
176
+ msgid ""
177
+ "The title is used for overview, it is not visible in quiz. If you leave the "
178
+ "title field empty, a title will be generated."
179
+ msgstr ""
180
+ "Der Titel dient nur zur Übersicht, es wird nicht im Quiz angezeigt. Wird der "
181
+ "Titel leer gelassen, wird ein Titel generiert."
182
+
183
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:26
184
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:87
185
+ #: lib/view/WpProQuiz_View_QuizEdit.php:12
186
+ #: lib/view/WpProQuiz_View_QuizEdit.php:167
187
+ msgid "(required)"
188
+ msgstr "(Pflichtfeld)"
189
+
190
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:34
191
  msgid "Message with the correct answer"
192
  msgstr "Nachricht bei korrekter Antwort"
193
 
194
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:37
195
+ msgid ""
196
+ "This text will be visible if answered correctly. It can be used as "
197
+ "explanation for complex questions. The message \"Right\" or \"Wrong\" is "
198
+ "always displayed automatically."
199
+ msgstr ""
200
+ "Dieser Text wird bei richtiger Antwort angezeigt. Kann z.B. als Erklärung "
201
+ "für komplexe Aufgaben dienen. Die Nachricht \"Richtig\" oder \"Falsch\" wird "
202
+ "immer automatisch angezeigt."
203
+
204
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:41
205
+ msgid "Same text for correct- and incorrect-message?"
206
+ msgstr "Gleicher Text für Korrekt- und Inkorrekt-Nachricht?"
207
+
208
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:51
209
  msgid "Message with the incorrect answer"
210
  msgstr "Nachricht bei inkorrekter Antwort"
211
 
212
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:54
213
+ msgid ""
214
+ "This text will be visible if answered incorrectly. It can be used as "
215
+ "explanation for complex questions. The message \"Right\" or \"Wrong\" is "
216
+ "always displayed automatically."
217
+ msgstr ""
218
+ "Dieser Text wird bei falscher Antwort angezeigt. Kann z.B. als Erklärung für "
219
+ "komplexe Aufgaben dienen. Die Nachricht \"Richtig\" oder \"Falsch\" wird "
220
+ "immer automatisch angezeigt."
221
+
222
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:62
223
  msgid "Answer type"
224
  msgstr "Antwort Typ?"
225
 
226
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:70
227
  msgid "Single choice"
228
  msgstr "Single choice"
229
 
230
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:74
231
  msgid "Multiple choice"
232
  msgstr "Multiple choice"
233
 
234
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:78
235
  msgid "\"Free\" choice"
236
  msgstr "\"Free\" choice"
237
 
238
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:82
239
  msgid "\"Sorting\" choice"
240
  msgstr "\"Sorting\" choice"
241
 
242
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:87
243
  msgid "Answers"
244
  msgstr "Antworten"
245
 
246
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:96
247
  msgid ""
248
  "korrect answers (one per line) (answers will be converted to lower case)"
249
  msgstr ""
250
  "Korrekte Antworten (eine pro Zeile ) (Antworten werden in Kleinbuchstaben "
251
  "umgewandelt)"
252
 
253
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:102
254
  msgid ""
255
  "Please sort the answers in right order with the \"Move\" - Button. The "
256
+ "answers will be displayed randomly."
257
  msgstr ""
258
+ "Bitte Antworten mit dem \"Verschiebe\"-Button in die richtige Reihenfolge "
259
+ "bringen. Die Antworten werden später immer zufällig ausgegeben."
260
 
261
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:108
262
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:120
263
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:130
264
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:149
 
 
 
 
 
 
 
 
 
 
265
  #: lib/view/WpProQuiz_View_QuestionEdit.php:165
266
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:179
267
+ msgid "Delete answer"
268
+ msgstr "Antwort löschen"
269
+
270
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:109
271
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:121
272
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:131
273
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:150
274
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:166
275
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:180
276
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:29
277
  msgid "Move"
278
  msgstr "Verschieben"
279
 
280
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:111
281
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:123
282
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:133
283
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:152
284
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:168
285
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:182
286
  msgid "Allow HTML"
287
  msgstr "HTML erlauben"
288
 
289
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:139
290
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:188
291
+ msgid "Add new answer"
292
+ msgstr "Neue Antwort hinzufügen"
293
 
294
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:147
295
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:163
296
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:177
297
  msgid "correct?"
298
  msgstr "Korrekt?"
299
 
300
+ #: lib/view/WpProQuiz_View_QuestionEdit.php:192
301
+ #: lib/view/WpProQuiz_View_QuizEdit.php:188
302
+ msgid "Save"
303
+ msgstr "Speichern"
304
+
305
  #: lib/view/WpProQuiz_View_QuestionOverall.php:8
306
  msgid "Questions sorted"
307
  msgstr "Fragen sortiert"
308
 
309
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:14
310
  #: lib/view/WpProQuiz_View_QuizOverall.php:14
311
  msgid "Name"
312
  msgstr "Name"
313
 
314
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:15
315
  #: lib/view/WpProQuiz_View_QuizOverall.php:15
316
  msgid "Action"
317
  msgstr "Aktion"
318
 
319
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:27
320
  #: lib/view/WpProQuiz_View_QuizOverall.php:28
321
  msgid "Edit"
322
  msgstr "Bearbeiten"
323
 
324
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:28
325
  #: lib/view/WpProQuiz_View_QuizOverall.php:29
326
  msgid "Delete"
327
  msgstr "Löschen"
328
 
329
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:36
330
  msgid "Add question"
331
  msgstr "Frage hinzufügen"
332
 
333
+ #: lib/view/WpProQuiz_View_QuestionOverall.php:37
334
  msgid "Save order"
335
  msgstr "Sortierung speichern"
336
 
398
  "Ermöglicht das Zurückgehen einer Frage. (Option wird ignoriert bei \"Prüfen -"
399
  "> Weiter\")"
400
 
401
+ #: lib/view/WpProQuiz_View_QuizEdit.php:126
402
+ #: lib/view/WpProQuiz_View_QuizEdit.php:131
403
+ #: lib/view/WpProQuiz_View_QuizOverall.php:31
404
+ msgid "Statistics"
405
+ msgstr "Statistik"
406
+
407
+ #: lib/view/WpProQuiz_View_QuizEdit.php:135
408
+ msgid "activate"
409
+ msgstr "Aktivieren"
410
+
411
+ #: lib/view/WpProQuiz_View_QuizEdit.php:138
412
+ msgid ""
413
+ "Statistics about right or wrong answers. Statistics will be saved by "
414
+ "completed quiz, not after every question. The statistics is only visible "
415
+ "over administration menu. (internal statistics)"
416
+ msgstr ""
417
+ "Statistik über richtige oder falsche Antworten. Statistik wird nur beim "
418
+ "vollständigen abschließen des Quiz gespeichert, nicht nach jeder Frage. Die "
419
+ "Statistik ist nur über das Adminmenü einsehbar (interne Statistik)"
420
+
421
+ #: lib/view/WpProQuiz_View_QuizEdit.php:145
422
+ #: lib/view/WpProQuiz_View_QuizEdit.php:150
423
+ msgid "Statistics IP-lock"
424
+ msgstr "Statistik IP-Sperre"
425
+
426
+ #: lib/view/WpProQuiz_View_QuizEdit.php:154
427
+ msgid "in minutes (recommended 1440 minutes = 1 day)"
428
+ msgstr "in Minuten (Empfohlen: 1440 Minuten = 1 Tag)"
429
+
430
+ #: lib/view/WpProQuiz_View_QuizEdit.php:157
431
+ msgid ""
432
+ "Protect the statistics from spam. Result will only be saved every X minutes "
433
+ "from same IP. (0 = deactivated)"
434
+ msgstr ""
435
+ "Schuetz die Statistik vor Spam. Ergebnis wird nur aller X Minuten von der "
436
+ "gleichen IP gespeichert. (0 = Deaktiviert)"
437
+
438
+ #: lib/view/WpProQuiz_View_QuizEdit.php:167
439
  msgid "Quiz description"
440
  msgstr "Quiz Beschreibung"
441
 
442
+ #: lib/view/WpProQuiz_View_QuizEdit.php:170
443
  msgid "This text will be displayed before start of the quiz."
444
  msgstr "Dieser Text wird vor dem Starten des Quizes angezeigt."
445
 
446
+ #: lib/view/WpProQuiz_View_QuizEdit.php:178
447
  msgid "Results text"
448
  msgstr "Ergebnis Text"
449
 
450
+ #: lib/view/WpProQuiz_View_QuizEdit.php:181
451
  msgid ""
452
  "This text will be displayed at the end of the quiz (in results). (this text "
453
  "is optional)"
475
  msgid "Preview"
476
  msgstr "Vorschau"
477
 
478
+ #: lib/view/WpProQuiz_View_QuizOverall.php:38
479
  msgid "Add quiz"
480
  msgstr "Quiz hinzufügen"
481
+
482
+ #: lib/view/WpProQuiz_View_Statistics.php:7
483
+ #, php-format
484
+ msgid "Quiz: %s - Statistics"
485
+ msgstr "Quiz: %s - Statistik"
486
+
487
+ #: lib/view/WpProQuiz_View_Statistics.php:11
488
+ msgid "Stats not enabled"
489
+ msgstr "Statistik ist nicht aktiviert"
490
+
491
+ #: lib/view/WpProQuiz_View_Statistics.php:12
492
+ msgid "Activate statistics"
493
+ msgstr "Statistik aktivieren"
494
+
495
+ #: lib/view/WpProQuiz_View_Statistics.php:20
496
+ msgid "Incorrect"
497
+ msgstr "Inkorrekt"
498
+
499
+ #: lib/view/WpProQuiz_View_Statistics.php:21
500
+ msgid "Correct"
501
+ msgstr "Korrekt"
502
+
503
+ #: lib/view/WpProQuiz_View_Statistics.php:55
504
+ msgid "Total"
505
+ msgstr "Total"
506
+
507
+ #: lib/view/WpProQuiz_View_Statistics.php:61
508
+ msgid "Reset statistics"
509
+ msgstr "Statistik zurücksetzen"
510
+
511
+ #~ msgid "Delete question"
512
+ #~ msgstr "Frage löschen"
513
+
514
+ #, fuzzy
515
+ #~ msgid "Statistics activate"
516
+ #~ msgstr "Statistik aktivieren"
517
+
518
+ #, fuzzy
519
+ #~ msgid "Statistics reset"
520
+ #~ msgstr "Statistik zurücksetzen"
521
+
522
+ #~ msgid "add new question"
523
+ #~ msgstr "neue Frage hinzufügen"
524
+
525
+ #~ msgid "Not all fields are filled"
526
+ #~ msgstr "Nicht alle Felder ausgefüllt"
lib/controller/WpProQuiz_Controller_Admin.php CHANGED
@@ -10,12 +10,27 @@ class WpProQuiz_Controller_Admin {
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'),
@@ -37,18 +52,13 @@ class WpProQuiz_Controller_Admin {
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() {
@@ -61,20 +71,28 @@ class WpProQuiz_Controller_Admin {
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) {
10
  $this->_plugin_dir = $plugin_dir;
11
  $this->_plugin_file = $this->_plugin_dir.'/wp-pro-quiz.php';
12
 
13
+ add_action('wp_ajax_update_sort', array($this, 'updateSort'));
14
+ add_action('wp_ajax_wp_pro_quiz_statistics_save', array($this, 'statisticsSave'));
15
+ add_action('wp_ajax_nopriv_wp_pro_quiz_statistics_save', array($this, 'statisticsSave'));
16
  add_action('admin_menu', array($this, 'register_page'));
17
  add_action('admin_enqueue_scripts', array($this, 'enqueueScript') );
18
  }
19
 
20
+ public function updateSort() {
21
+
22
+ if(!current_user_can('administrator'))
23
+ exit;
24
+
25
+ $c = new WpProQuiz_Controller_Question();
26
+ $c->route();
27
+ }
28
+
29
+ public function statisticsSave() {
30
+ $statistics = new WpProQuiz_Controller_Statistics();
31
+ $statistics->save();
32
+ }
33
+
34
  private function localizeScript() {
35
  $translation_array = array(
36
  'delete_msg' => __('Do you really want to delete the quiz/question?', 'wp-pro-quiz'),
52
 
53
  }
54
 
 
 
 
 
 
 
 
55
  public static function install() {
56
+
57
  $db = new WpProQuiz_Helper_DbUpgrade();
58
  $v = $db->upgrade(get_option('wpProQuiz_dbVersion', false));
59
 
60
+ if(add_option('wpProQuiz_dbVersion', $v) === false)
61
+ update_option('wpProQuiz_dbVersion', $v);
62
  }
63
 
64
  public function register_page() {
71
  }
72
 
73
  public function route() {
 
 
74
  $module = isset($_GET['module']) ? $_GET['module'] : 'overallView';
75
+
76
+ $c = null;
77
+
78
  switch ($module) {
79
  case 'overallView':
80
+ $c = new WpProQuiz_Controller_Quiz();
81
  break;
82
  case 'question':
83
+ $c = new WpProQuiz_Controller_Question();
84
  break;
85
  case 'preview':
86
+ $c = new WpProQuiz_Controller_Preview($this->_plugin_file);
87
+ break;
88
+ case 'statistics':
89
+ $c = new WpProQuiz_Controller_Statistics();
90
  break;
91
  }
92
+
93
+ if($c !== null) {
94
+ $c->route();
95
+ }
96
  }
97
 
98
  public function autoload($class) {
lib/controller/WpProQuiz_Controller_Controller.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WpProQuiz_Controller_Controller {
3
+ protected $_post = null;
4
+
5
+ public function __construct() {
6
+ if($this->_post === null) {
7
+ $this->_post = stripslashes_deep($_POST);
8
+ }
9
+ }
10
+ }
lib/controller/WpProQuiz_Controller_Front.php CHANGED
@@ -50,7 +50,7 @@ class WpProQuiz_Controller_Front {
50
  $question = $questionMapper->fetchAll($id);
51
 
52
  if(empty($quiz) || empty($question))
53
- return '';
54
 
55
  $view->quiz = $quiz;
56
  $view->question = $question;
50
  $question = $questionMapper->fetchAll($id);
51
 
52
  if(empty($quiz) || empty($question))
53
+ echo '';
54
 
55
  $view->quiz = $quiz;
56
  $view->question = $question;
lib/controller/WpProQuiz_Controller_Preview.php CHANGED
@@ -1,11 +1,16 @@
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');
@@ -25,6 +30,6 @@ class WpProQuiz_Controller_Preview {
25
  $view->quiz = $quizMapper->fetch($id);
26
  $view->question = $questionMapper->fetchAll($id);
27
 
28
- $view->show();
29
  }
30
  }
1
  <?php
2
+ class WpProQuiz_Controller_Preview extends WpProQuiz_Controller_Controller {
3
 
4
  private $_plugin_file;
5
 
6
  public function __construct($plugin_file) {
7
+ parent::__construct();
8
 
9
+
10
  $this->_plugin_file = $plugin_file;
11
+ }
12
+
13
+ public function route() {
14
 
15
  wp_enqueue_script('jquery');
16
  wp_enqueue_script('jquery-ui-sortable');
30
  $view->quiz = $quizMapper->fetch($id);
31
  $view->question = $questionMapper->fetchAll($id);
32
 
33
+ $view->show(true);
34
  }
35
  }
lib/controller/WpProQuiz_Controller_Question.php CHANGED
@@ -1,16 +1,25 @@
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();
@@ -32,7 +41,7 @@ class WpProQuiz_Controller_Question {
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);
@@ -52,9 +61,23 @@ class WpProQuiz_Controller_Question {
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
  }
@@ -67,11 +90,20 @@ class WpProQuiz_Controller_Question {
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');
@@ -81,6 +113,7 @@ class WpProQuiz_Controller_Question {
81
  }
82
 
83
  $this->view->question = new WpProQuiz_Model_Question($post);
 
84
  $this->view->show();
85
  }
86
 
@@ -103,7 +136,6 @@ class WpProQuiz_Controller_Question {
103
  }
104
 
105
  $post['answerJson'] = $this->clear($post['answerJson']);
106
- $post = $post;
107
  $post['quizId'] = $this->_quizId;
108
 
109
  return $post;
1
  <?php
2
+ class WpProQuiz_Controller_Question extends WpProQuiz_Controller_Controller {
3
 
4
  private $_quizId;
5
 
6
+ public function route() {
7
 
8
+ if(!isset($_GET['quiz_id']) || empty($_GET['quiz_id'])) {
9
+ WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
10
+ return;
11
+ }
12
 
13
  $this->_quizId = (int)$_GET['quiz_id'];
14
  $action = isset($_GET['action']) ? $_GET['action'] : 'show';
15
 
16
+ $m = new WpProQuiz_Model_QuizMapper();
17
+
18
+ if($m->exists($this->_quizId) == 0) {
19
+ WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
20
+ return;
21
+ }
22
+
23
  switch ($action) {
24
  case 'add':
25
  $this->createAction();
41
 
42
  public function saveSort($quizId) {
43
  $mapper = new WpProQuiz_Model_QuestionMapper();
44
+ $map = $this->_post['sort'];
45
 
46
  foreach($map as $k => $v)
47
  $mapper->updateSort($v, $k);
61
  $this->view->header = __('Edit question', 'wp-pro-quiz');
62
  $mapper = new WpProQuiz_Model_QuestionMapper();
63
 
64
+ if($mapper->exists($id) == 0) {
65
+ WpProQuiz_View_View::admin_notices(__('Question not found', 'wp-pro-quiz'), 'error');
66
+ return;
67
+ }
68
+
69
+ if(isset($this->_post['submit'])) {
70
+ $post = $this->clearPost($this->_post);
71
  $post['id'] = $id;
72
+
73
+ $post['title'] = isset($post['title']) ? trim($post['title']) : '';
74
+
75
+ if(empty($post['title'])) {
76
+ $question = $mapper->fetch($id);
77
+
78
+ $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $question->getSort()+1);
79
+ }
80
+
81
  $mapper->save(new WpProQuiz_Model_Question($post));
82
  WpProQuiz_View_View::admin_notices(__('Question edited', 'wp-pro-quiz'), 'info');
83
  }
90
  $this->view = new WpProQuiz_View_QuestionEdit();
91
  $this->view->header = __('New question', 'wp-pro-quiz');
92
  $post = null;
93
+
94
+ if(isset($this->_post['submit'])) {
95
+ $post = $this->clearPost($this->_post);
96
 
97
  $questionMapper = new WpProQuiz_Model_QuestionMapper();
98
+
99
+ $post['title'] = isset($post['title']) ? trim($post['title']) : '';
100
+
101
+ if(empty($post['title'])) {
102
+ $count = $questionMapper->count($this->_quizId);
103
+
104
+ $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $count+1);
105
+ }
106
+
107
  $questionMapper->save(new WpProQuiz_Model_Question($post));
108
 
109
  WpProQuiz_View_View::admin_notices(__('Question added', 'wp-pro-quiz'), 'info');
113
  }
114
 
115
  $this->view->question = new WpProQuiz_Model_Question($post);
116
+ $this->view->question->setQuizId($this->_quizId);
117
  $this->view->show();
118
  }
119
 
136
  }
137
 
138
  $post['answerJson'] = $this->clear($post['answerJson']);
 
139
  $post['quizId'] = $this->_quizId;
140
 
141
  return $post;
lib/controller/WpProQuiz_Controller_Quiz.php CHANGED
@@ -1,8 +1,8 @@
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) {
@@ -36,20 +36,26 @@ class WpProQuiz_Controller_Quiz {
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
 
@@ -60,10 +66,10 @@ class WpProQuiz_Controller_Quiz {
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();
1
  <?php
2
+ class WpProQuiz_Controller_Quiz extends WpProQuiz_Controller_Controller {
3
  private $view;
4
 
5
+ public function route() {
6
  $action = isset($_GET['action']) ? $_GET['action'] : 'show';
7
 
8
  switch ($action) {
36
  $this->view = new WpProQuiz_View_QuizEdit();
37
  $this->view->header = __('Edit quiz', 'wp-pro-quiz');
38
 
39
+ $m = new WpProQuiz_Model_QuizMapper();
40
+
41
+ if($m->exists($id) == 0) {
42
+ WpProQuiz_View_View::admin_notices(__('Quiz not found', 'wp-pro-quiz'), 'error');
43
+ return;
44
+ }
45
+
46
+ if(isset($this->_post['submit'])) {
47
+ $this->view->quiz = new WpProQuiz_Model_Quiz($this->_post);
48
  $this->view->quiz->setId($id);
49
 
50
+ if($this->checkValidit($this->_post)) {
51
+ WpProQuiz_View_View::admin_notices(__('Quiz edited', 'wp-pro-quiz'), 'info');
52
  $this->view->quiz->getMapper()->save($this->view->quiz);
53
  $this->showAction();
54
  return;
55
  } else {
56
+ WpProQuiz_View_View::admin_notices(__('Quiz title or quiz description are not filled', 'wp-pro-quiz'));
57
  }
58
  } else {
 
59
  $this->view->quiz = $m->fetch($id);
60
  }
61
 
66
  $this->view = new WpProQuiz_View_QuizEdit();
67
  $this->view->header = __('Create quiz', 'wp-pro-quiz');
68
 
69
+ if(isset($this->_post['submit'])) {
70
+ $this->view->quiz = new WpProQuiz_Model_Quiz($this->_post);
71
 
72
+ if($this->checkValidit($this->_post)) {
73
  WpProQuiz_View_View::admin_notices(__('Create quiz', 'wp-pro-quiz'), 'info');
74
  $this->view->quiz->getMapper()->save($this->view->quiz);
75
  $this->showAction();
lib/controller/WpProQuiz_Controller_Statistics.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WpProQuiz_Controller_Statistics extends WpProQuiz_Controller_Controller {
3
+
4
+ public function route() {
5
+ $action = (isset($_GET['action'])) ? $_GET['action'] : 'show';
6
+
7
+ switch ($action) {
8
+ case 'reset':
9
+ $this->reset($_GET['id']);
10
+ case 'show':
11
+ default:
12
+ $this->show($_GET['id']);
13
+ }
14
+ }
15
+
16
+ private function reset($quizId) {
17
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
18
+ $questionMapper->resetStatistics($quizId);
19
+ }
20
+
21
+ private function show($quizId) {
22
+ $view = new WpProQuiz_View_Statistics();
23
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
24
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
25
+
26
+ $view->quiz = $quizMapper->fetch($quizId);
27
+ $view->question = $questionMapper->fetchAll($quizId);
28
+
29
+ $view->show();
30
+ }
31
+
32
+ public function save() {
33
+ $quizId = $this->_post['quizId'];
34
+ $array = $this->_post['results'];
35
+ $lockIp = $this->getIp();
36
+
37
+ if($lockIp === false)
38
+ exit;
39
+
40
+ $quizMapper = new WpProQuiz_Model_QuizMapper();
41
+ $quiz = $quizMapper->fetch($quizId);
42
+
43
+ if(!$quiz->isStatisticsOn())
44
+ exit;
45
+
46
+ if($quiz->getStatisticsIpLock() > 0) {
47
+ $lockMapper = new WpProQuiz_Model_LockMapper();
48
+
49
+ $lockMapper->deleteOldLock($quiz, time());
50
+
51
+ if($lockMapper->isLock($quizId, $lockIp))
52
+ exit;
53
+
54
+ $lock = new WpProQuiz_Model_Lock();
55
+ $lock->setQuizId($quizId)
56
+ ->setLockIp($lockIp)
57
+ ->setLockDate(time());
58
+
59
+ $lockMapper->insert($lock);
60
+ }
61
+
62
+ $questionMapper = new WpProQuiz_Model_QuestionMapper();
63
+ $questionMapper->updateStatistics($quizId, $array);
64
+
65
+ exit;
66
+ }
67
+
68
+ private function getIp() {
69
+ return filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
70
+ }
71
+ }
lib/helper/WpProQuiz_Helper_DbUpgrade.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  class WpProQuiz_Helper_DbUpgrade {
3
 
4
- const WPPROQUIZ_DB_VERSION = 3;
5
 
6
  private $_wpdb;
7
  private $_prefix;
@@ -23,12 +23,7 @@ class WpProQuiz_Helper_DbUpgrade {
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
 
@@ -45,43 +40,59 @@ class WpProQuiz_Helper_DbUpgrade {
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() {
@@ -99,4 +110,36 @@ class WpProQuiz_Helper_DbUpgrade {
99
  private function upgradeDbV2() {
100
  return 3;
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
1
  <?php
2
  class WpProQuiz_Helper_DbUpgrade {
3
 
4
+ const WPPROQUIZ_DB_VERSION = 4;
5
 
6
  private $_wpdb;
7
  private $_prefix;
23
 
24
  if($version === WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION)
25
  return WpProQuiz_Helper_DbUpgrade::WPPROQUIZ_DB_VERSION;
26
+
 
 
 
 
 
27
  do {
28
  $f = 'upgradeDbV'.$version;
29
 
40
  public function delete() {
41
  $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master`');
42
  $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question`');
43
+ $this->_wpdb->query('DROP TABLE IF EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock`');
44
  }
45
 
46
  private function install() {
47
 
48
+ $this->delete();
 
49
 
50
  $this->_wpdb->query('
51
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_master` (
52
+ `id` int(11) NOT NULL AUTO_INCREMENT,
53
+ `name` varchar(200) NOT NULL,
54
+ `text` text NOT NULL,
55
+ `result_text` text NOT NULL,
56
+ `title_hidden` tinyint(1) NOT NULL,
57
+ `question_random` tinyint(1) NOT NULL,
58
+ `answer_random` tinyint(1) NOT NULL,
59
+ `check_answer` tinyint(1) NOT NULL,
60
+ `back_button` tinyint(1) NOT NULL,
61
+ `time_limit` int(11) NOT NULL,
62
+ `statistics_on` tinyint(1) NOT NULL,
63
+ `statistics_ip_lock` int(10) unsigned NOT NULL,
64
+ PRIMARY KEY (`id`)
65
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
66
+
67
  ');
68
 
69
  $this->_wpdb->query('
70
  CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_question` (
71
+ `id` int(11) NOT NULL AUTO_INCREMENT,
72
+ `quiz_id` int(11) NOT NULL,
73
+ `sort` tinyint(3) unsigned NOT NULL,
74
+ `title` varchar(200) NOT NULL,
75
+ `question` text NOT NULL,
76
+ `correct_msg` text NOT NULL,
77
+ `incorrect_msg` text NOT NULL,
78
+ `correct_same_text` tinyint(1) NOT NULL,
79
+ `correct_count` int(10) unsigned NOT NULL,
80
+ `incorrect_count` int(10) unsigned NOT NULL,
81
+ `answer_type` varchar(50) NOT NULL,
82
+ `answer_json` text NOT NULL,
83
+ PRIMARY KEY (`id`),
84
+ KEY `quiz_id` (`quiz_id`)
85
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
86
  ');
87
+
88
+ $this->_wpdb->query('
89
+ CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock` (
90
+ `quiz_id` int(11) NOT NULL,
91
+ `lock_ip` varchar(100) NOT NULL,
92
+ `lock_date` int(11) NOT NULL,
93
+ PRIMARY KEY (`quiz_id`,`lock_ip`)
94
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
95
+ ');
96
  }
97
 
98
  private function upgradeDbV1() {
110
  private function upgradeDbV2() {
111
  return 3;
112
  }
113
+
114
+ private function upgradeDbV3() {
115
+
116
+ $this->_wpdb->query('
117
+ ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
118
+ ADD `incorrect_count` INT UNSIGNED NOT NULL AFTER `incorrect_msg` ,
119
+ ADD `correct_count` INT UNSIGNED NOT NULL AFTER `incorrect_msg` ,
120
+ ADD `correct_same_text` TINYINT( 1 ) NOT NULL AFTER `incorrect_msg`
121
+ ');
122
+
123
+ $this->_wpdb->query('
124
+ ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_master`
125
+ ADD `statistics_on` TINYINT( 1 ) NOT NULL ,
126
+ ADD `statistics_ip_lock` INT UNSIGNED NOT NULL
127
+ ');
128
+
129
+ $this->_wpdb->query('
130
+ CREATE TABLE IF NOT EXISTS `'.$this->_wpdb->prefix.'wp_pro_quiz_lock` (
131
+ `quiz_id` int(11) NOT NULL,
132
+ `lock_ip` varchar(100) NOT NULL,
133
+ `lock_date` int(11) NOT NULL,
134
+ PRIMARY KEY (`quiz_id`,`lock_ip`)
135
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
136
+ ');
137
+
138
+ $this->_wpdb->query('
139
+ ALTER TABLE `'.$this->_wpdb->prefix.'wp_pro_quiz_question`
140
+ ADD INDEX ( `quiz_id` )
141
+ ');
142
+
143
+ return 4;
144
+ }
145
  }
lib/model/WpProQuiz_Model_Lock.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WpProQuiz_Model_Lock extends WpProQuiz_Model_Model {
3
+ protected $_quizId;
4
+ protected $_lockIp;
5
+ protected $_lockDate;
6
+
7
+ public function setQuizId($_quizId) {
8
+ $this->_quizId = $_quizId;
9
+ return $this;
10
+ }
11
+
12
+ public function getQuizId() {
13
+ return $this->_quizId;
14
+ }
15
+
16
+ public function setLockIp($_lockIp) {
17
+ $this->_lockIp = $_lockIp;
18
+ return $this;
19
+ }
20
+
21
+ public function getLockIp() {
22
+ return $this->_lockIp;
23
+ }
24
+
25
+ public function setLockDate($_lockDate) {
26
+ $this->_lockDate = $_lockDate;
27
+ return $this;
28
+ }
29
+
30
+ public function getLockDate() {
31
+ return $this->_lockDate;
32
+ }
33
+ }
lib/model/WpProQuiz_Model_LockMapper.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WpProQuiz_Model_LockMapper extends WpProQuiz_Model_Mapper {
3
+
4
+ protected $_table;
5
+
6
+ public function __construct() {
7
+ parent::__construct();
8
+
9
+ $this->_table = $this->_prefix.'lock';
10
+ }
11
+
12
+ public function insert(WpProQuiz_Model_Lock $lock) {
13
+ $this->_wpdb->insert($this->_table, array(
14
+ 'quiz_id' => $lock->getQuizId(),
15
+ 'lock_ip' => $lock->getLockIp(),
16
+ 'lock_date' => $lock->getLockDate()
17
+ ),
18
+ array('%d', '%s', '%d'));
19
+ }
20
+
21
+ public function fetch($quizId, $lockIp) {
22
+ $row = $this->_wpdb->get_row(
23
+ $this->_wpdb->prepare(
24
+ "SELECT
25
+ *
26
+ FROM
27
+ ". $this->_table. "
28
+ WHERE
29
+ quiz_id = %d
30
+ AND
31
+ lock_ip = %s",
32
+ $quizId, $lockIp)
33
+ );
34
+
35
+ if($row === null)
36
+ return null;
37
+
38
+ $model = new WpProQuiz_Model_Lock();
39
+ $model->setQuizId($row->quiz_id)
40
+ ->setLockIp($row->lock_id)
41
+ ->setLockDate($row->lock_date);
42
+
43
+ return $model;
44
+ }
45
+
46
+ public function isLock($quizId, $lockIp) {
47
+ $c = $this->_wpdb->get_var(
48
+ $this->_wpdb->prepare(
49
+ "SELECT COUNT(*) FROM {$this->_table}
50
+ WHERE quiz_id = %d AND lock_ip = %s", $quizId, $lockIp));
51
+
52
+ if($c === null || $c == 0)
53
+ return false;
54
+
55
+ return true;
56
+ }
57
+
58
+ public function deleteOldLock(WpProQuiz_Model_Quiz $quiz, $time) {
59
+ $lockTime = $quiz->getStatisticsIpLock() * 60;
60
+
61
+ return $this->_wpdb->query(
62
+ $this->_wpdb->prepare(
63
+ "DELETE FROM {$this->_table}
64
+ WHERE
65
+ quiz_id = %d AND (lock_date + %d) < %d",
66
+ $quiz->getId(),
67
+ $lockTime,
68
+ $time
69
+ )
70
+ );
71
+ }
72
+ }
lib/model/WpProQuiz_Model_Question.php CHANGED
@@ -9,6 +9,9 @@ class WpProQuiz_Model_Question extends WpProQuiz_Model_Model {
9
  protected $_incorrectMsg;
10
  protected $_answerType;
11
  protected $_answerJson;
 
 
 
12
 
13
  public function setId($_id)
14
  {
@@ -103,4 +106,34 @@ class WpProQuiz_Model_Question extends WpProQuiz_Model_Model {
103
  public function getAnswerJson() {
104
  return $this->_answerJson;
105
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
9
  protected $_incorrectMsg;
10
  protected $_answerType;
11
  protected $_answerJson;
12
+ protected $_correctCount;
13
+ protected $_incorrectCount;
14
+ protected $_correctSameText = false;
15
 
16
  public function setId($_id)
17
  {
106
  public function getAnswerJson() {
107
  return $this->_answerJson;
108
  }
109
+
110
+ public function setCorrectCount($_correctCount)
111
+ {
112
+ $this->_correctCount = $_correctCount;
113
+ return $this;
114
+ }
115
+
116
+ public function getCorrectCount() {
117
+ return (int)$this->_correctCount;
118
+ }
119
+
120
+ public function setIncorrectCount($_incorrectCount)
121
+ {
122
+ $this->_incorrectCount = $_incorrectCount;
123
+ return $this;
124
+ }
125
+
126
+ public function getIncorrectCount() {
127
+ return (int)$this->_incorrectCount;
128
+ }
129
+
130
+ public function setCorrectSameText($_correctSameText)
131
+ {
132
+ $this->_correctSameText = (bool)$_correctSameText;
133
+ return $this;
134
+ }
135
+
136
+ public function isCorrectSameText() {
137
+ return $this->_correctSameText;
138
+ }
139
  }
lib/model/WpProQuiz_Model_QuestionMapper.php CHANGED
@@ -31,10 +31,11 @@ class WpProQuiz_Model_QuestionMapper extends WpProQuiz_Model_Mapper {
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(
@@ -44,10 +45,11 @@ class WpProQuiz_Model_QuestionMapper extends WpProQuiz_Model_Mapper {
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);
@@ -65,18 +67,26 @@ class WpProQuiz_Model_QuestionMapper extends WpProQuiz_Model_Mapper {
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
  }
@@ -91,19 +101,28 @@ class WpProQuiz_Model_QuestionMapper extends WpProQuiz_Model_Mapper {
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
  }
@@ -114,4 +133,40 @@ class WpProQuiz_Model_QuestionMapper extends WpProQuiz_Model_Mapper {
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
  }
31
  'question' => $question->getQuestion(),
32
  'correct_msg' => $question->getCorrectMsg(),
33
  'incorrect_msg' => $question->getIncorrectMsg(),
34
+ 'correct_same_text' => (int)$question->isCorrectSameText(),
35
  'answer_type' => $question->getAnswerType(),
36
  'answer_json' => json_encode($question->getAnswerJson())),
37
  array('id' => $question->getId()),
38
+ array('%s', '%s', '%s', '%s', '%d', '%s', '%s'),
39
  array('%d'));
40
  } else {
41
  $id = $this->_wpdb->insert($this->_table, array(
45
  'question' => $question->getQuestion(),
46
  'correct_msg' => $question->getCorrectMsg(),
47
  'incorrect_msg' => $question->getIncorrectMsg(),
48
+ 'correct_same_text' => (int)$question->isCorrectSameText(),
49
  'answer_type' => $question->getAnswerType(),
50
  'answer_json' => json_encode($question->getAnswerJson())
51
  ),
52
+ array('%d', '%d', '%s', '%s', '%s', '%s', '%d', '%s', '%s')
53
  );
54
 
55
  $question->setId($id);
67
  ". $this->_table. "
68
  WHERE
69
  id = %d",
70
+ $id),
71
+ ARRAY_A
72
  );
73
 
74
+ $row['answer_json'] = json_decode($row['answer_json'], true);
75
+
76
+ $model = new WpProQuiz_Model_Question($row);
77
+
78
+ // $model = new WpProQuiz_Model_Question();
79
+ // $model ->setId($row->id)
80
+ // ->setQuizId($row->quiz_id)
81
+ // ->setTitle($row->title)
82
+ // ->setQuestion($row->question)
83
+ // ->setCorrectMsg($row->correct_msg)
84
+ // ->setIncorrectMsg($row->incorrect_msg)
85
+ // ->setAnswerType($row->answer_type)
86
+ // ->setAnswerJson(json_decode($row->answer_json, true))
87
+ // ->setCorrectCount($row->correct_count)
88
+ // ->setIncorrectCount($row->incorrect_count)
89
+ // ->setSort($row->sort);
90
 
91
  return $model;
92
  }
101
  '. $this->_table.'
102
  WHERE
103
  quiz_id = %d
104
+ ORDER BY sort ASC', $quizId),
105
+ ARRAY_A);
106
 
107
  foreach($results as $row) {
 
108
 
109
+ $row['answer_json'] = json_decode($row['answer_json'], true);
110
+
111
+ $model = new WpProQuiz_Model_Question($row);
112
+
113
+ // $model = new WpProQuiz_Model_Question();
114
+
115
+ // $model ->setId($row->id)
116
+ // ->setQuizId($row->quiz_id)
117
+ // ->setTitle($row->title)
118
+ // ->setQuestion($row->question)
119
+ // ->setCorrectMsg($row->correct_msg)
120
+ // ->setIncorrectMsg($row->incorrect_msg)
121
+ // ->setAnswerType($row->answer_type)
122
+ // ->setAnswerJson(json_decode($row->answer_json, true))
123
+ // ->setCorrectCount($row->correct_count)
124
+ // ->setIncorrectCount($row->incorrect_count)
125
+ // ->setSort($row->sort);
126
 
127
  $a[] = $model;
128
  }
133
  public function count($quizId) {
134
  return $this->_wpdb->get_var($this->_wpdb->prepare("SELECT COUNT(*) FROM {$this->_table} WHERE quiz_id = %d", $quizId));
135
  }
136
+
137
+ public function exists($id) {
138
+ return $this->_wpdb->get_var($this->_wpdb->prepare("SELECT COUNT(*) FROM {$this->_table} WHERE id = %d", $id));
139
+ }
140
+
141
+ public function updateStatistics($quizId, $array) {
142
+ $ids = $this->_wpdb->get_col($this->_wpdb->prepare("SELECT id FROM {$this->_table} WHERE quiz_id = %d", $quizId));
143
+
144
+ $v = array_keys($array);
145
+
146
+ if(array_diff($ids, $v) !== array_diff($v, $ids))
147
+ return false;
148
+
149
+ $correctIds = implode(', ', array_keys($array, 1));
150
+ $incorrectIds = implode(', ', array_keys($array, 0));
151
+
152
+ if(!empty($correctIds)) {
153
+ $this->_wpdb->query("UPDATE {$this->_table} SET correct_count = correct_count + 1 WHERE id IN({$correctIds})");
154
+ }
155
+
156
+ if(!empty($incorrectIds)) {
157
+ $this->_wpdb->query("UPDATE {$this->_table} SET incorrect_count = incorrect_count + 1 WHERE id IN({$incorrectIds})");
158
+ }
159
+
160
+ return true;
161
+ }
162
+
163
+ public function resetStatistics($quizId) {
164
+ return $this->_wpdb->update($this->_table,
165
+ array( 'incorrect_count' => 0,
166
+ 'correct_count' => 0
167
+ ),
168
+ array( 'quiz_id' => $quizId),
169
+ array( '%d', '%d'),
170
+ array( '%d'));
171
+ }
172
  }
lib/model/WpProQuiz_Model_Quiz.php CHANGED
@@ -11,6 +11,8 @@ class WpProQuiz_Model_Quiz extends WpProQuiz_Model_Model {
11
  protected $_timeLimit = 0;
12
  protected $_backButton;
13
  protected $_checkAnswer;
 
 
14
 
15
  public function getId() {
16
  return $this->_id;
@@ -29,12 +31,7 @@ class WpProQuiz_Model_Quiz extends WpProQuiz_Model_Model {
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;
@@ -106,4 +103,22 @@ class WpProQuiz_Model_Quiz extends WpProQuiz_Model_Model {
106
  public function isCheckAnswer() {
107
  return $this->_checkAnswer;
108
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
11
  protected $_timeLimit = 0;
12
  protected $_backButton;
13
  protected $_checkAnswer;
14
+ protected $_statisticsOn;
15
+ protected $_statisticsIpLock;
16
 
17
  public function getId() {
18
  return $this->_id;
31
  $this->_name = $name;
32
  return $this;
33
  }
34
+
 
 
 
 
 
35
  public function setText($text) {
36
  $this->_text = $text;
37
  return $this;
103
  public function isCheckAnswer() {
104
  return $this->_checkAnswer;
105
  }
106
+
107
+ public function setStatisticsOn($_statisticsOn) {
108
+ $this->_statisticsOn = (bool)$_statisticsOn;
109
+ return $this;
110
+ }
111
+
112
+ public function isStatisticsOn() {
113
+ return $this->_statisticsOn;
114
+ }
115
+
116
+ public function setStatisticsIpLock($_statisticsIpLock) {
117
+ $this->_statisticsIpLock = (int)$_statisticsIpLock;
118
+ return $this;
119
+ }
120
+
121
+ public function getStatisticsIpLock() {
122
+ return $this->_statisticsIpLock;
123
+ }
124
  }
lib/model/WpProQuiz_Model_QuizMapper.php CHANGED
@@ -15,6 +15,10 @@ class WpProQuiz_Model_QuizMapper extends WpProQuiz_Model_Mapper
15
  array('%d'));
16
  }
17
 
 
 
 
 
18
  public function fetch($id) {
19
  $results = $this->_wpdb->get_row(
20
  $this->_wpdb->prepare(
@@ -54,7 +58,9 @@ class WpProQuiz_Model_QuizMapper extends WpProQuiz_Model_Mapper
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) {
@@ -63,12 +69,12 @@ class WpProQuiz_Model_QuizMapper extends WpProQuiz_Model_Mapper
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
  }
15
  array('%d'));
16
  }
17
 
18
+ public function exists($id) {
19
+ return $this->_wpdb->get_var($this->_wpdb->prepare("SELECT COUNT(*) FROM {$this->_table} WHERE id = %d", $id));
20
+ }
21
+
22
  public function fetch($id) {
23
  $results = $this->_wpdb->get_row(
24
  $this->_wpdb->prepare(
58
  'answer_random' => (int)$data->isAnswerRandom(),
59
  'back_button' => (int)$data->isBackButton(),
60
  'check_answer' => (int) $data->isCheckAnswer(),
61
+ 'time_limit' => (int)$data->getTimeLimit(),
62
+ 'statistics_on' => (int)$data->isStatisticsOn(),
63
+ 'statistics_ip_lock' => (int)$data->getStatisticsIpLock()
64
  );
65
 
66
  if($data->getId() != 0) {
69
  array(
70
  'id' => $data->getId()
71
  ),
72
+ array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d'),
73
  array('%d'));
74
  } else {
75
  return $this->_wpdb->insert($this->_table,
76
  $set,
77
+ array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d'));
78
  }
79
  }
80
  }
lib/view/WpProQuiz_View_FrontQuiz.php CHANGED
@@ -7,6 +7,7 @@ class WpProQuiz_View_FrontQuiz extends WpProQuiz_View_View {
7
  foreach($data as $q) {
8
  $a = array();
9
  $a['answer_type'] = $q->getAnswerType();
 
10
  $j = $q->getAnswerJson();
11
 
12
  switch ($q->getAnswerType()) {
@@ -31,7 +32,7 @@ class WpProQuiz_View_FrontQuiz extends WpProQuiz_View_View {
31
  return $r;
32
  }
33
 
34
- public function show() {
35
 
36
  $question_count = count($this->question);
37
 
@@ -140,7 +141,15 @@ class WpProQuiz_View_FrontQuiz extends WpProQuiz_View_View {
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>
@@ -162,6 +171,9 @@ jQuery(document).ready(function($) {
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
  });
7
  foreach($data as $q) {
8
  $a = array();
9
  $a['answer_type'] = $q->getAnswerType();
10
+ $a['id'] = $q->getId();
11
  $j = $q->getAnswerJson();
12
 
13
  switch ($q->getAnswerType()) {
32
  return $r;
33
  }
34
 
35
+ public function show($preview = false) {
36
 
37
  $question_count = count($this->question);
38
 
141
  <?php _e('Wrong', 'wp-pro-quiz'); ?>
142
  </span>
143
  <p>
144
+ <?php
145
+
146
+ if($question->isCorrectSameText()) {
147
+ echo do_shortcode(apply_filters('comment_text', $question->getCorrectMsg()));
148
+ } else {
149
+ echo do_shortcode(apply_filters('comment_text', $question->getIncorrectMsg()));
150
+ }
151
+
152
+ ?>
153
  </p>
154
  </div>
155
  </div>
171
  timeLimit: <?php echo (int)$this->quiz->getTimeLimit(); ?>,
172
  checkAnswer: <?php echo (int)$this->quiz->isCheckAnswer(); ?>,
173
  backButton: <?php echo (int)$this->quiz->isBackButton();?>,
174
+ quizId: <?php echo (int)$this->quiz->getId(); ?>,
175
+ statisticsOn: <?php echo $preview ? 0 : (int)$this->quiz->isStatisticsOn(); ?>,
176
+ url: '<?php echo admin_url('admin-ajax.php'); ?>',
177
  json: <?php echo $json; ?>
178
  });
179
  });
lib/view/WpProQuiz_View_QuestionEdit.php CHANGED
@@ -14,13 +14,16 @@ jQuery(document).ready(function($) {
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));
@@ -28,16 +31,28 @@ jQuery(document).ready(function($) {
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
  ?>
@@ -69,7 +84,7 @@ jQuery(document).ready(function($) {
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') { ?>
@@ -84,13 +99,13 @@ jQuery(document).ready(function($) {
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'); ?>
@@ -102,7 +117,7 @@ jQuery(document).ready(function($) {
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'); ?>
@@ -112,7 +127,7 @@ jQuery(document).ready(function($) {
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'); ?>
@@ -121,7 +136,7 @@ jQuery(document).ready(function($) {
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>
@@ -131,7 +146,7 @@ jQuery(document).ready(function($) {
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'); ?>
@@ -147,7 +162,7 @@ jQuery(document).ready(function($) {
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'); ?>
@@ -161,7 +176,7 @@ jQuery(document).ready(function($) {
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'); ?>
@@ -170,11 +185,11 @@ jQuery(document).ready(function($) {
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>
14
  <form action="" method="POST">
15
  <div id="poststuff">
16
  <div class="postbox">
17
+ <h3 class="hndle"><?php _e('Title', 'wp-pro-quiz'); ?> <?php _e('(optional)', 'wp-pro-quiz'); ?></h3>
18
  <div class="inside">
19
+ <p class="description">
20
+ <?php _e('The title is used for overview, it is not visible in quiz. If you leave the title field empty, a title will be generated.', 'wp-pro-quiz'); ?>
21
+ </p>
22
  <input name="title" class="regular-text" value="<?php echo $this->question->getTitle(); ?>">
23
  </div>
24
  </div>
25
  <div class="postbox">
26
+ <h3 class="hndle"><?php _e('Question', 'wp-pro-quiz'); ?> <?php _e('(required)', 'wp-pro-quiz'); ?></h3>
27
  <div class="inside">
28
  <?php
29
  wp_editor($this->question->getQuestion(), "question", array('textarea_rows' => 5));
31
  </div>
32
  </div>
33
  <div class="postbox">
34
+ <h3 class="hndle"><?php _e('Message with the correct answer', 'wp-pro-quiz'); ?> <?php _e('(optional)', 'wp-pro-quiz'); ?></h3>
35
  <div class="inside">
36
+ <p class="description">
37
+ <?php _e('This text will be visible if answered correctly. It can be used as explanation for complex questions. The message "Right" or "Wrong" is always displayed automatically.', 'wp-pro-quiz'); ?>
38
+ </p>
39
+ <div style="padding-top: 10px; padding-bottom: 10px;">
40
+ <label for="wpProQuiz_correctSameText">
41
+ <?php _e('Same text for correct- and incorrect-message?', 'wp-pro-quiz'); ?>
42
+ <input type="checkbox" name="correctSameText" id="wpProQuiz_correctSameText" value="1" <?php echo $this->question->isCorrectSameText() ? 'checked="checked"' : '' ?>>
43
+ </label>
44
+ </div>
45
  <?php
46
  wp_editor($this->question->getCorrectMsg(), "correctMsg", array('textarea_rows' => 3));
47
  ?>
48
  </div>
49
  </div>
50
+ <div class="postbox" id="wpProQuiz_incorrectMassageBox">
51
+ <h3 class="hndle"><?php _e('Message with the incorrect answer', 'wp-pro-quiz'); ?> <?php _e('(optional)', 'wp-pro-quiz'); ?></h3>
52
  <div class="inside">
53
+ <p class="description">
54
+ <?php _e('This text will be visible if answered incorrectly. It can be used as explanation for complex questions. The message "Right" or "Wrong" is always displayed automatically.', 'wp-pro-quiz'); ?>
55
+ </p>
56
  <?php
57
  wp_editor($this->question->getIncorrectMsg(), "incorrectMsg", array('textarea_rows' => 3));
58
  ?>
84
  </div>
85
  </div>
86
  <div class="postbox">
87
+ <h3 class="hndle"><?php _e('Answers', 'wp-pro-quiz'); ?> <?php _e('(required)', 'wp-pro-quiz'); ?></h3>
88
  <div class="inside answer_felder">
89
  <div class="free_answer">
90
  <?php if($type === 'free_answer') { ?>
99
  </div>
100
  <div class="sort_answer">
101
  <p class="description">
102
+ <?php _e('Please sort the answers in right order with the "Move" - Button. The answers will be displayed randomly.', 'wp-pro-quiz'); ?>
103
  </p>
104
  <ul>
105
  <li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; display:none; background-color: whiteSmoke;">
106
  <!-- <input class="small-text" name="answerJson[answer_sort][nr][]" value="" placeholder="Nr."> -->
107
  <textarea rows="2" cols="100" class="large-text" name="answerJson[answer_sort][answer][]"></textarea>
108
+ <input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete answer', 'wp-pro-quiz'); ?>">
109
  <a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
110
  <label>
111
  <?php _e('Allow HTML', 'wp-pro-quiz'); ?>
117
  <li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; background-color: whiteSmoke;">
118
  <!-- <input class="small-text" name="answerJson[answer_sort][nr][]" value="<?php echo $qa['answer_sort']['nr'][$k]; ?>" placeholder="Nr.">-->
119
  <textarea rows="2" cols="100" class="large-text" name="answerJson[answer_sort][answer][]"><?php echo $v; ?></textarea>
120
+ <input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete answer', 'wp-pro-quiz'); ?>">
121
  <a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
122
  <label>
123
  <?php _e('Allow HTML', 'wp-pro-quiz'); ?>
127
  <?php } } else { ?>
128
  <li style="border-bottom:1px dotted #ccc; padding-bottom: 5px; background-color: whiteSmoke;">
129
  <textarea rows="2" cols="100" class="large-text" name="answerJson[answer_sort][answer][]"></textarea>
130
+ <input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete answer', 'wp-pro-quiz'); ?>">
131
  <a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
132
  <label>
133
  <?php _e('Allow HTML', 'wp-pro-quiz'); ?>
136
  </li>
137
  <?php } ?>
138
  </ul>
139
+ <input type="button" class="button-primary addAnswer" value="<?php _e('Add new answer', 'wp-pro-quiz'); ?>">
140
  </div>
141
  <div class="classic_answer">
142
  <ul>
146
  <input type="radio" name="answerJson[classic_answer][correct][]" value="0">
147
  <?php _e('correct?', 'wp-pro-quiz'); ?>
148
  </label>
149
+ <input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete answer', 'wp-pro-quiz'); ?>">
150
  <a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
151
  <label>
152
  <?php _e('Allow HTML', 'wp-pro-quiz'); ?>
162
  <?php echo (isset($qa['classic_answer']['correct']) && in_array($k, $qa['classic_answer']['correct'])) ? 'checked="checked"' : ''; ?>>
163
  <?php _e('correct?', 'wp-pro-quiz'); ?>
164
  </label>
165
+ <input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete answer', 'wp-pro-quiz'); ?>">
166
  <a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
167
  <label>
168
  <?php _e('Allow HTML', 'wp-pro-quiz'); ?>
176
  <input type="radio" name="answerJson[classic_answer][correct][]" value="1" checked="checked">
177
  <?php _e('correct?', 'wp-pro-quiz'); ?>
178
  </label>
179
+ <input type="button" name="submit" class="button-primary deleteAnswer" value="<?php _e('Delete answer', 'wp-pro-quiz'); ?>">
180
  <a href="#" class="button-secondary wpProQuiz_move" style="cursor: move;"><?php _e('Move', 'wp-pro-quiz'); ?></a>
181
  <label>
182
  <?php _e('Allow HTML', 'wp-pro-quiz'); ?>
185
  </li>
186
  <?php } ?>
187
  </ul>
188
+ <input type="button" class="button-primary addAnswer" value="<?php _e('Add new answer', 'wp-pro-quiz'); ?>">
189
  </div>
190
  </div>
191
  </div>
192
+ <input type="submit" name="submit" id="saveQuestion" class="button-primary" value="<?php _e('Save', 'wp-pro-quiz'); ?>">
193
  </div>
194
  </form>
195
  </div>
lib/view/WpProQuiz_View_QuestionOverall.php CHANGED
@@ -10,15 +10,18 @@ class WpProQuiz_View_QuestionOverall extends WpProQuiz_View_View {
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>
10
  <table class="wp-list-table widefat">
11
  <thead>
12
  <tr>
13
+ <th style="width: 50px;"></th>
14
  <th scope="col"><?php _e('Name', 'wp-pro-quiz'); ?></th>
15
  <th><?php _e('Action', 'wp-pro-quiz'); ?></th>
16
  </tr>
17
  </thead>
18
  <tbody>
19
  <?php
20
+ $index = 1;
21
  foreach ($this->question as $question) {
22
  ?>
23
  <tr id="wpProQuiz_questionId_<?php echo $question->getId(); ?>">
24
+ <th><?php echo $index++; ?></th>
25
  <th><?php echo $question->getTitle(); ?></th>
26
  <th>
27
  <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>
lib/view/WpProQuiz_View_QuizEdit.php CHANGED
@@ -9,14 +9,14 @@ class WpProQuiz_View_QuizEdit extends WpProQuiz_View_View {
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>
@@ -121,12 +121,50 @@ class WpProQuiz_View_QuizEdit extends WpProQuiz_View_View {
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'); ?>
@@ -137,7 +175,7 @@ class WpProQuiz_View_QuizEdit extends WpProQuiz_View_View {
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'); ?>
@@ -147,10 +185,10 @@ class WpProQuiz_View_QuizEdit extends WpProQuiz_View_View {
147
  ?>
148
  </div>
149
  </div>
150
- <input type="submit" name="submit" class="button-primary">
151
  </div>
152
  </form>
153
  </div>
154
- <?php
155
  }
156
  }
9
  <form method="post">
10
  <div id="poststuff">
11
  <div class="postbox">
12
+ <h3 class="hndle"><?php _e('Quiz title', 'wp-pro-quiz'); ?> <?php _e('(required)', '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="wrap wpProQuiz_quizEdit">
20
  <table class="form-table">
21
  <tbody>
22
  <tr>
121
  </fieldset>
122
  </td>
123
  </tr>
124
+ <tr>
125
+ <th scope="row">
126
+ <?php _e('Statistics', 'wp-pro-quiz'); ?>
127
+ </th>
128
+ <td>
129
+ <fieldset>
130
+ <legend class="screen-reader-text">
131
+ <span><?php _e('Statistics', 'wp-pro-quiz'); ?></span>
132
+ </legend>
133
+ <label for="statistics_on">
134
+ <input type="checkbox" id="statistics_on" value="1" name="statisticsOn" <?php echo $this->quiz->isStatisticsOn() ? 'checked="checked"' : '' ?>>
135
+ <?php _e('activate', 'wp-pro-quiz'); ?>
136
+ </label>
137
+ <p class="description">
138
+ <?php _e('Statistics about right or wrong answers. Statistics will be saved by completed quiz, not after every question. The statistics is only visible over administration menu. (internal statistics)', 'wp-pro-quiz'); ?>
139
+ </p>
140
+ </fieldset>
141
+ </td>
142
+ </tr>
143
+ <tr id="statistics_ip_lock_tr" style="display: none;">
144
+ <th scope="row">
145
+ <?php _e('Statistics IP-lock', 'wp-pro-quiz'); ?>
146
+ </th>
147
+ <td>
148
+ <fieldset>
149
+ <legend class="screen-reader-text">
150
+ <span><?php _e('Statistics IP-lock', 'wp-pro-quiz'); ?></span>
151
+ </legend>
152
+ <label for="statistics_ip_lock">
153
+ <input type="text" id="statistics_ip_lock" value="<?php echo ($this->quiz->getStatisticsIpLock() === null) ? 1440 : $this->quiz->getStatisticsIpLock(); ?>" name="statisticsIpLock">
154
+ <?php _e('in minutes (recommended 1440 minutes = 1 day)', 'wp-pro-quiz'); ?>
155
+ </label>
156
+ <p class="description">
157
+ <?php _e('Protect the statistics from spam. Result will only be saved every X minutes from same IP. (0 = deactivated)', 'wp-pro-quiz'); ?>
158
+ </p>
159
+ </fieldset>
160
+ </td>
161
+ </tr>
162
  </tbody>
163
  </table>
164
  </div>
165
  </div>
166
  <div class="postbox">
167
+ <h3 class="hndle"><?php _e('Quiz description', 'wp-pro-quiz'); ?> <?php _e('(required)', 'wp-pro-quiz'); ?></h3>
168
  <div class="inside">
169
  <p class="description">
170
  <?php _e('This text will be displayed before start of the quiz.', 'wp-pro-quiz'); ?>
175
  </div>
176
  </div>
177
  <div class="postbox">
178
+ <h3 class="hndle"><?php _e('Results text', 'wp-pro-quiz'); ?> <?php _e('(optional)', 'wp-pro-quiz'); ?></h3>
179
  <div class="inside">
180
  <p class="description">
181
  <?php _e('This text will be displayed at the end of the quiz (in results). (this text is optional)', 'wp-pro-quiz'); ?>
185
  ?>
186
  </div>
187
  </div>
188
+ <input type="submit" name="submit" class="button-primary" value="<?php _e('Save', 'wp-pro-quiz'); ?>">
189
  </div>
190
  </form>
191
  </div>
192
+ <?php
193
  }
194
  }
lib/view/WpProQuiz_View_QuizOverall.php CHANGED
@@ -28,6 +28,7 @@ class WpProQuiz_View_QuizOverall extends WpProQuiz_View_View {
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 } ?>
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
+ <a class="button-secondary" href="admin.php?page=wpProQuiz&module=statistics&id=<?php echo $quiz->getId(); ?>"><?php _e('Statistics', 'wp-pro-quiz'); ?></a>
32
  </th>
33
  </tr>
34
  <?php } ?>
lib/view/WpProQuiz_View_Statistics.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WpProQuiz_View_Statistics extends WpProQuiz_View_View {
3
+
4
+ public function show() {
5
+ ?>
6
+ <div class="wrap wpProQuiz_statistics">
7
+ <h2><?php printf(__('Quiz: %s - Statistics', 'wp-pro-quiz'), $this->quiz->getName()); ?></h2>
8
+ <p><a class="button-secondary" href="admin.php?page=wpProQuiz"><?php _e('back to overview', 'wp-pro-quiz'); ?></a></p>
9
+ <?php if(!$this->quiz->isStatisticsOn()) { ?>
10
+ <p style="padding: 30px; background: #F7E4E4; border: 1px dotted; width: 260px;">
11
+ <span style="font-weight: bold; padding-right: 10px;"><?php _e('Stats not enabled', 'wp-pro-quiz'); ?></span>
12
+ <a class="button-secondary" href="admin.php?page=wpProQuiz&action=edit&id=<?php echo $this->quiz->getId(); ?>"><?php _e('Activate statistics', 'wp-pro-quiz'); ?></a>
13
+ </p>
14
+ <?php return; } ?>
15
+ <table class="wp-list-table widefat">
16
+ <thead>
17
+ <tr>
18
+ <th scope="col" style="width: 50px;"></th>
19
+ <th scope="col"><?php _e('Question', 'wp-pro-quiz'); ?></th>
20
+ <th scope="col" style="width: 100px;"><?php _e('Incorrect', 'wp-pro-quiz'); ?></th>
21
+ <th scope="col" style="width: 100px;"><?php _e('Correct', 'wp-pro-quiz'); ?></th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <?php
26
+
27
+ $index = 1;
28
+ $gCount = 0;
29
+ $gIncorrectCount = 0;
30
+ $gCorrectCount = 0;
31
+
32
+ foreach($this->question as $question) {
33
+ $count = $question->getCorrectCount() + $question->getIncorrectCount();
34
+ $p = $count / 100;
35
+ $correctP = ($count > 0) ? (100 * $question->getCorrectCount() / $count) : 0;
36
+ $incorrectP = ($count > 0) ? (100 * $question->getIncorrectCount() / $count) : 0;
37
+ $gCount += $count;
38
+ $gIncorrectCount += $question->getIncorrectCount();
39
+ $gCorrectCount += $question->getCorrectCount();
40
+ ?>
41
+ <tr>
42
+ <th><?php echo $index++; ?></th>
43
+ <th><?php echo $question->getTitle(); ?></th>
44
+ <th style="color: red;"><?php echo $question->getIncorrectCount().' ('.round($incorrectP, 2).'%)'; ?></th>
45
+ <th style="color: green;"><?php echo $question->getCorrectCount().' ('.round($correctP, 2).'%)'; ?></th>
46
+ </tr>
47
+ <?php } ?>
48
+ </tbody>
49
+ <tfoot>
50
+ <?php
51
+ $gCorrectP = ($gCount > 0) ? (100 * $gCorrectCount / $gCount) : 0;
52
+ $gIncorrectP = ($gCount > 0) ? (100 * $gIncorrectCount / $gCount) : 0;
53
+ ?>
54
+ <th></th>
55
+ <th><?php _e('Total', 'wp-pro-quiz'); ?></th>
56
+ <th style="color: red;"><?php echo $gIncorrectCount.' ('.round($gIncorrectP, 2).'%)'; ?></th>
57
+ <th style="color: green;"><?php echo $gCorrectCount.' ('.round($gCorrectP, 2).'%)'; ?></th>
58
+ </tfoot>
59
+ </table>
60
+ <p>
61
+ <a class="button-secondary" href="admin.php?page=wpProQuiz&module=statistics&action=reset&id=<?php echo $this->quiz->getId(); ?>"><?php _e('Reset statistics', 'wp-pro-quiz'); ?></a>
62
+ </p>
63
+ </div>
64
+
65
+ <?php
66
+ }
67
+ }
readme.txt CHANGED
@@ -1,9 +1,9 @@
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
 
@@ -26,11 +26,12 @@ A powerful and beautiful quiz plugin for WordPress.
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 =
@@ -52,9 +53,14 @@ http://www.it-gecko.de/wp-pro-quiz-quiz-plugin-fuer-wordpress.html (scroll to "D
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
 
 
 
 
 
1
  === Wp-Pro-Quiz ===
2
+ Contributors: xeno010
3
  Tags: quiz
4
  Requires at least: 3.3
5
  Tested up to: 3.4.2
6
+ Stable tag: 0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
26
  * Back-Button (optional)
27
  * Correct / incorrect response message for all questions (optional)
28
  * Preview-function
29
+ * statistics
30
  * really nice standard design
31
  * mighty
32
 
33
  = Translations =
34
+ * English (Thanks Alexander M.)
35
  * German (Deutsch)
36
 
37
  = Live Demo =
53
  7. Adminmenu - Create quiz
54
  8. Adminmenu - Quiz question overview
55
  9. Adminmenu - Create question
56
+ 10. Adminmenu - Question statistics
57
 
58
  == Changelog ==
59
 
60
  = 0.1 =
61
+ * release
62
+
63
+ = 0.2 =
64
+ * bugfix
65
+ * add statistics function
66
+ * small changes
screenshot-10.png ADDED
Binary file
screenshot-7.png CHANGED
Binary file
screenshot-8.png CHANGED
Binary file
screenshot-9.png CHANGED
Binary file
template/wp-pro-quiz_overall_view.php DELETED
@@ -1,20 +0,0 @@
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 DELETED
@@ -1,52 +0,0 @@
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>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-pro-quiz.php CHANGED
@@ -3,22 +3,24 @@
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
- }
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.2
7
  Author: Julius Fischer
8
  Author URI: http://www.it-gecko.de
9
  */
10
 
11
+ include_once 'lib/controller/WpProQuiz_Controller_Admin.php';
12
+ include_once 'lib/helper/WpProQuiz_Helper_DbUpgrade.php';
13
+
14
  register_activation_hook(__FILE__, array('WpProQuiz_Controller_Admin', 'install'));
15
 
16
+ add_action('plugins_loaded', array('WpProQuiz_Controller_Admin', 'install'));
17
+
18
  load_plugin_textdomain('wp-pro-quiz', false, dirname(plugin_basename(__FILE__)).'/languages');
19
 
20
  if(is_admin()) {
 
 
21
  new WpProQuiz_Controller_Admin(dirname(__FILE__));
22
  } else {
23
  require_once 'lib/controller/WpProQuiz_Controller_Front.php';
24
 
25
  new WpProQuiz_Controller_Front(dirname(__FILE__));
26
+ }