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;