-
-
Save anonymous/c41ec15b8b20ccdd8c55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (g) { | |
g.wpProQuizFront = function (M, e) { | |
var b = g(M), | |
d = this, | |
h = {}, B = {}, V = 0, | |
k = null, | |
q = [], | |
W = "", | |
E = !1, | |
N = 1, | |
X = 0, | |
Y = 0, | |
F = 0, | |
Z = 0, | |
G = 0, | |
O = 0, | |
P = 0, | |
x = 0, | |
$ = 0, | |
r = 0, | |
aa = 0, | |
y = 0, | |
ba = 0, | |
H = 0, | |
Q = 0, | |
ca = 0, | |
R = 0, | |
da = 0, | |
S = 0, | |
ea = 0, | |
fa = 0, | |
ga = b.find('input[name="back"]'), | |
z = b.find('input[name="next"]'), | |
m = b.find(".wpProQuiz_quiz"), | |
v = b.find(".wpProQuiz_list"), | |
A = b.find(".wpProQuiz_results"), | |
w = b.find(".wpProQuiz_text"), | |
C = b.find(".wpProQuiz_time_limit"), | |
I = b.find(".wpProQuiz_toplistShowInButton"), | |
T = g(), | |
ha = "", | |
U = 0, | |
ia = function () { | |
var a = e.timelimit, | |
c = 0, | |
b = { | |
stop: function () { | |
a && (window.clearInterval(c), C.hide()) | |
}, | |
pause:function(){ | |
if(a) { | |
window.clearInterval(c); | |
C.find("span").val()=C.find("span").textContent(); | |
} | |
}, | |
resume:function(){ | |
if(a) | |
{ | |
var text_content = C.find('span').text(); | |
var txt_split = text_content.split(':'); | |
var txt_time = txt_split[0] * 3600/1 + txt_split[1] * 60/1 + txt_split[2]/1; | |
a=txt_time; | |
var f = 1E3 * a, | |
//var x = a * 1000; | |
g= C.find('span').text(d.methode.parseTime(a)); | |
e= C.find('.wpProQuiz_progress'); | |
var n= +new Date(); | |
c = window.setInterval(function() { | |
var a = (+new Date() - n); | |
c = f - a; | |
500 <= a && g.text(d.methode.parseTime(Math.ceil(c / 1E3))); | |
e.css("width", 100 * (c / f) + "%"); | |
0 >= c && (b.stop(), d.methode.finishQuiz(!0)) | |
}, 16) | |
} | |
}, | |
start: function () { | |
if (a) { | |
var f = 1E3 * a, | |
g = C.find("span").text(d.methode.parseTime(a)), | |
e = C.find(".wpProQuiz_progress"); | |
C.show(); | |
var n = +new Date; | |
c = window.setInterval(function () { | |
var a = +new Date - n, | |
c = f - a; | |
500 <= a && g.text(d.methode.parseTime(Math.ceil(c / 1E3))); | |
e.css("width", 100 * (c / f) + "%"); | |
0 >= c && (b.stop(), d.methode.finishQuiz(!0)) | |
}, 16) | |
} | |
} | |
}; | |
return b | |
}(), | |
u = new function () { | |
function a(a) { | |
var c = "", | |
b = k[a]; | |
b.review ? c = "#FFB800" : b.solved && (c = "#6CA54C"); | |
n.eq(a).css("background-color", | |
c) | |
} | |
function c(a) { | |
a.preventDefault(); | |
a = a.pageY - J; | |
0 > a && (a = 0); | |
a > h && (a = h); | |
e.attr("style", "margin-top: " + -(D * a) + "px !important"); | |
p.css({ | |
top: a | |
}) | |
} | |
function l(a) { | |
a.preventDefault(); | |
g(document).unbind(".scrollEvent") | |
} | |
var f = [], | |
p = [], | |
e = [], | |
n = [], | |
h = 0, | |
J = 0, | |
D = 0, | |
K = 0, | |
t = 0, | |
k = []; | |
this.init = function () { | |
f = b.find(".wpProQuiz_reviewQuestion"); | |
p = f.find("div"); | |
e = f.find("ol"); | |
n = e.children(); | |
p.mousedown(function (a) { | |
a.preventDefault(); | |
a.stopPropagation(); | |
J = a.pageY - p.offset().top + K; | |
g(document).bind("mouseup.scrollEvent", l); | |
g(document).bind("mousemove.scrollEvent", | |
c) | |
}); | |
n.click(function (a) { | |
d.methode.showQuestion(g(this).index()) | |
}); | |
b.bind("questionSolved", function (c) { | |
k[c.values.index].solved = c.values.solved; | |
a(c.values.index) | |
}); | |
b.bind("changeQuestion", function (a) { | |
n.removeClass("wpProQuiz_reviewQuestionTarget"); | |
n.eq(a.values.index).addClass("wpProQuiz_reviewQuestionTarget"); | |
a = n.eq(a.values.index); | |
var c = a.offset().top, | |
b = f.offset().top, | |
c = c - b; | |
if (0 > c - 4 || 100 < c + 32) a = b - n.eq(0).offset().top - (b - e.offset().top) + a.position().top, a > t && (a = t), b = a / D, e.attr("style", "margin-top: " + -a + "px !important"), p.css({ | |
top: b | |
}) | |
}); | |
b.bind("reviewQuestion", function (c) { | |
k[c.values.index].review = !k[c.values.index].review; | |
a(c.values.index) | |
}); | |
f.bind("mousewheel DOMMouseScroll", function (a) { | |
a.preventDefault(); | |
a = a.originalEvent; | |
a = 20 * (a.wheelDelta ? -a.wheelDelta / 120 : a.detail / 3); | |
a = K - e.offset().top + a; | |
a > t && (a = t); | |
0 > a && (a = 0); | |
var c = a / D; | |
e.attr("style", "margin-top: " + -a + "px !important"); | |
p.css({ | |
top: c | |
}); | |
return !1 | |
}) | |
}; | |
this.show = function (a) { | |
r && f.parent().show(); | |
b.find(".wpProQuiz_reviewDiv .wpProQuiz_button2").show(); | |
if (!a) { | |
e.attr("style", "margin-top: 0px !important"); | |
p.css({ | |
top: 0 | |
}); | |
a = e.outerHeight(); | |
var c = f.height(); | |
h = c - p.height(); | |
J = 0; | |
t = a - c; | |
D = t / h; | |
this.reset(); | |
100 < a && p.show(); | |
K = p.offset().top | |
} | |
}; | |
this.hide = function () { | |
f.parent().hide() | |
}; | |
this.toggle = function () { | |
if (r) { | |
f.parent().toggle(); | |
n.removeClass("wpProQuiz_reviewQuestionTarget"); | |
b.find(".wpProQuiz_reviewDiv .wpProQuiz_button2").hide(); | |
e.attr("style", "margin-top: 0px !important"); | |
p.css({ | |
top: 0 | |
}); | |
var a = e.outerHeight(), | |
c = f.height(); | |
h = c - p.height(); | |
J = 0; | |
t = a - c; | |
D = t / h; | |
100 < a && p.show(); | |
K = p.offset().top | |
} | |
}; | |
this.reset = function () { | |
for (var a = 0, c = n.length; a < c; a++) k[a] = {}; | |
n.removeClass("wpProQuiz_reviewQuestionTarget").css("background-color", "") | |
} | |
}, s = new function () { | |
var a = 0, | |
c = -1, | |
b = 0, | |
f = !1; | |
this.questionStart = function (b) { | |
-1 != c && this.questionStop(); | |
c = b; | |
a = +new Date | |
}; | |
this.questionStop = function () { | |
-1 != c && (h[c].time += Math.round((new Date - a) / 1E3), c = -1) | |
}; | |
this.startQuiz = function () { | |
f && this.stopQuiz(); | |
b = +new Date; | |
f = !0 | |
}; | |
this.stopQuiz = function () { | |
f && (h.comp.quizTime += Math.round((new Date - b) / 1E3), f = !1) | |
}; | |
this.init = function () {} | |
}, ja = function (a, c, b, f) { | |
var e = !0, | |
h = 0, | |
n = g.isArray(c.points), | |
k = {}; | |
({ | |
singleMulti: function () { | |
var a = f.find(".wpProQuiz_questionInput").attr("disabled", "disabled"), | |
b = c.diffMode; | |
f.children().each(function (l) { | |
var f = g(this), | |
k = f.data("pos"); | |
l = a.eq(l).is(":checked"); | |
c.correct[k] ? (l ? n && (h = b ? c.points[k] : h + c.points[k]) : e = !1, c.disCorrect ? e = !0 : d.methode.marker(f, !0)) : l ? (c.disCorrect ? e = !0 : (d.methode.marker(f, !1), e = !1), b && (h = c.points[k])) : n && !b && (h += c.points[k]) | |
}) | |
}, | |
sort_answer: function () { | |
var a = f.children(); | |
a.each(function (a, b) { | |
var l = g(this); | |
k[a] = l.data("pos"); | |
a == l.data("pos") ? (d.methode.marker(l, !0), n && (h += c.points[a])) : (d.methode.marker(l, !1), e = !1) | |
}); | |
a.children().css({ | |
"box-shadow": "0 0", | |
cursor: "auto" | |
}); | |
f.sortable("destroy"); | |
a.sort(function (a, c) { | |
return g(a).data("pos") > g(c).data("pos") ? 1 : -1 | |
}); | |
f.append(a) | |
}, | |
matrix_sort_answer: function () { | |
var a = f.children(), | |
m = []; | |
k = { | |
0: -1 | |
}; | |
a.each(function () { | |
var a = g(this), | |
b = a.data("pos"), | |
a = a.find(".wpProQuiz_maxtrixSortCriterion"), | |
l = a.children(); | |
l.length && (k[b] = l.data("pos")); | |
l.length && 0 <= g.inArray(String(b), String(l.data("correct")).split(",")) ? (d.methode.marker(a, !0), n && (h += c.points[b])) : (e = !1, d.methode.marker(a, !1)); | |
m[b] = a | |
}); | |
d.methode.resetMatrix(b); | |
b.find(".wpProQuiz_sortStringItem").each(function () { | |
var a = m[g(this).data("pos")]; | |
void 0 != a && a.append(this) | |
}).css({ | |
"box-shadow": "0 0", | |
cursor: "auto" | |
}); | |
b.find(".wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion").sortable("destroy") | |
}, | |
free_answer: function () { | |
var a = f.children(), | |
b = a.find(".wpProQuiz_questionInput").attr("disabled", | |
"disabled").val(); | |
0 <= g.inArray(g.trim(b).toLowerCase(), c.correct) ? d.methode.marker(a, !0) : (d.methode.marker(a, !1), e = !1) | |
}, | |
cloze_answer: function () { | |
f.find(".wpProQuiz_cloze").each(function (a, b) { | |
var l = g(this).children(), | |
f = l.eq(0), | |
l = l.eq(1), | |
k = d.methode.cleanupCurlyQuotes(f.val()); | |
0 <= g.inArray(k, c.correct[a]) ? (n && (h += c.points[a]), F || f.css("background-color", "#B0DAB0")) : (F || f.css("background-color", "#FFBABA"), e = !1, l.show()); | |
f.attr("disabled", "disabled") | |
}) | |
}, | |
assessment_answer: function () { | |
e = !0; | |
var a = 0; | |
f.find(".wpProQuiz_questionInput").attr("disabled", | |
"disabled").filter(":checked").each(function () { | |
a += parseInt(g(this).val()) | |
}); | |
h = a | |
} | |
})[a](); | |
!n && e && (h = c.points); | |
return { | |
c: e, | |
p: h, | |
s: k | |
} | |
}, L = new function () { | |
var a = { | |
isEmpty: function (a) { | |
a = g.trim(a); | |
return !a || 0 === a.length | |
} | |
}; | |
this.checkForm = function () { | |
var c = !0; | |
b.find(".wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select").each(function () { | |
var b = g(this), | |
f = 1 == b.data("required"), | |
e = b.data("type"), | |
d = !0, | |
h = g.trim(b.val()); | |
switch (e) { | |
case 0: | |
case 1: | |
case 7: | |
f && (d = !a.isEmpty(h)); | |
break; | |
case 2: | |
if (f || !a.isEmpty(h)) d = !a.isEmpty(h) && !isNaN(h); | |
break; | |
case 4: | |
if (f || !a.isEmpty(h)) d = !a.isEmpty(h) && RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/).test(h); | |
break; | |
case 3: | |
f && (d = b.is(":checked")); | |
break; | |
case 5: | |
case 8: | |
f && (d = void 0 !== b.find('input[type="radio"]:checked').val()); | |
break; | |
case 6: | |
var k = 0, | |
m = 0; | |
b.find("select").each(function () { | |
k++; | |
m += a.isEmpty(g(this).val()) ? 0 : 1 | |
}); | |
if (f || 0 < m) d = k == m | |
} | |
d ? b.siblings(".wpProQuiz_invalidate").hide() : (c = !1, b.siblings(".wpProQuiz_invalidate").show()) | |
}); | |
return c | |
}; | |
this.getFormData = function () { | |
var a = {}; | |
b.find(".wpProQuiz_forms input, .wpProQuiz_forms textarea, .wpProQuiz_forms .wpProQuiz_formFields, .wpProQuiz_forms select").each(function () { | |
var b = g(this), | |
f = b.data("form_id"); | |
switch (b.data("type")) { | |
case 0: | |
case 1: | |
case 7: | |
case 2: | |
case 4: | |
a[f] = b.val(); | |
break; | |
case 3: | |
a[f] = b.is(":checked") ? 1 : 0; | |
break; | |
case 5: | |
case 8: | |
a[f] = b.find('input[type="radio"]:checked').val(); | |
break; | |
case 6: | |
a[f] = { | |
day: b.find('select[name="wpProQuiz_field_' + f + '_day"]').val(), | |
month: b.find('select[name="wpProQuiz_field_' + f + '_month"]').val(), | |
year: b.find('select[name="wpProQuiz_field_' + f + '_year"]').val() | |
} | |
} | |
}); | |
return a | |
} | |
}, ka = function (a) { | |
b.find(".wpProQuiz_questionList").each(function () { | |
var c = g(this), | |
b = c.data("question_id"), | |
f = c.data("type"), | |
d = {}; | |
if ("single" == f || "multiple" == f) c.find(".wpProQuiz_questionListItem").each(function () { | |
d[g(this).data("pos")] = +g(this).find(".wpProQuiz_questionInput").is(":checked") | |
}); | |
else if ("free_answer" == f) d[0] = c.find(".wpProQuiz_questionInput").val(); | |
else { | |
if ("sort_answer" == f || "matrix_sort_answer" == f) return !0; | |
if ("cloze_answer" == f) { | |
var e = 0; | |
c.find(".wpProQuiz_cloze input").each(function () { | |
d[e++] = g(this).val() | |
}) | |
} else "assessment_answer" == f && (d[0] = "", c.find(".wpProQuiz_questionInput:checked").each(function () { | |
d[g(this).data("index")] = g(this).val() | |
})) | |
} | |
a[b].data = d | |
}) | |
}; | |
d.methode = { | |
parseBitOptions: function () { | |
if (e.bo) { | |
X = e.bo & 1; | |
Y = e.bo & 2; | |
F = e.bo & 4; | |
Z = e.bo & 8; | |
G = e.bo & 16; | |
P = e.bo & 64; | |
r = e.bo & 128; | |
x = e.bo & 256; | |
$ = e.bo & 512; | |
aa = e.bo & 1024; | |
y = e.bo & 2048; | |
ba = e.bo & 4096; | |
H = e.bo & 8192; | |
Q = e.bo & 16384; | |
ca = e.bo & 32768; | |
var a = e.bo & 32; | |
a && void 0 != jQuery.support && void 0 != jQuery.support.cors && !1 == jQuery.support.cors && (O = a) | |
} | |
}, | |
setClozeStyle: function () { | |
b.find(".wpProQuiz_cloze input").each(function () { | |
for (var a = g(this), c = "", b = a.data("wordlen"), f = 0; f < b; f++) c += "w"; | |
c = g(document.createElement("span")).css("visibility", "hidden").text(c).appendTo(g("body")); | |
b = c.width(); | |
c.remove(); | |
a.width(b + 5) | |
}) | |
}, | |
parseTime: function (a) { | |
var c = parseInt(a % 60), | |
b = parseInt(a / 60 % 60); | |
a = parseInt(a / 3600 % 24); | |
return (9 < a ? "" : "0") + a + ":" + ((9 < b ? "" : "0") + b) + ":" + ((9 < c ? "" : "0") + c) | |
}, | |
cleanupCurlyQuotes: function (a) { | |
a = a.replace(/\u2018/, "'"); | |
a = a.replace(/\u2019/, "'"); | |
a = a.replace(/\u201C/, '"'); | |
a = a.replace(/\u201D/, '"'); | |
return g.trim(a).toLowerCase() | |
}, | |
resetMatrix: function (a) { | |
a.each(function () { | |
var a = g(this), | |
b = a.find(".wpProQuiz_sortStringList"); | |
a.find(".wpProQuiz_sortStringItem").each(function () { | |
b.append(g(this)) | |
}) | |
}) | |
}, | |
marker: function (a, b) { | |
F || (b ? a.addClass("wpProQuiz_answerCorrect") : a.addClass("wpProQuiz_answerIncorrect")) | |
}, | |
startQuiz: function (a) { | |
if (S) R = 1; | |
else if (R = 0, da) w.hide(), b.find(".wpProQuiz_lock").show(); | |
else if (ea) w.hide(), b.find(".wpProQuiz_prerequisite").show(); | |
else if (fa) w.hide(), b.find(".wpProQuiz_startOnlyRegisteredUser").show(); | |
else if (Q && !a) w.hide(), b.find(".wpProQuiz_loadQuiz").show(), d.methode.loadQuizDataAjax(!0); | |
else if (!H || 0 != e.formPos || L.checkForm()) { | |
d.methode.loadQuizData(); | |
Y && d.methode.random(v); | |
X && d.methode.random(b.find(".wpProQuiz_questionList")); | |
ca && d.methode.sortCategories(); | |
d.methode.random(b.find(".wpProQuiz_sortStringList")); | |
d.methode.random(b.find('[data-type="sort_answer"]')); | |
b.find(".wpProQuiz_listItem").each(function (a, b) { | |
var f = g(this); | |
f.find(".wpProQuiz_question_page span:eq(0)").text(a + 1); | |
f.find("> h5 span").text(a + 1); | |
f.find(".wpProQuiz_questionListItem").each(function (a, b) { | |
g(this).find("> span:not(.wpProQuiz_cloze)").text(a + 1 + ". ") | |
}) | |
}); | |
z = b.find('input[name="next"]'); | |
switch (e.mode) { | |
case 3: | |
b.find('input[name="checkSingle"]').show(); | |
break; | |
case 2: | |
b.find('input[name="check"]').show(); | |
!$ && r && b.find('input[name="skip"]').show(); | |
break; | |
case 1: | |
b.find('input[name="back"]').slice(1).show(); | |
case 0: | |
z.show() | |
}(ba || 3 == e.mode) && b.find(".wpProQuiz_question_page").hide(); | |
a = z.last(); | |
W = a.val(); | |
a.val(e.lbn); | |
a = v.children(); | |
T = b.find(".wpProQuiz_list > li"); | |
3 == e.mode ? d.methode.showSinglePage(0) : (k = a.eq(0).show(), a = k.find(".wpProQuiz_questionList").data("question_id"), s.questionStart(a)); | |
s.startQuiz(); | |
b.find(".wpProQuiz_sortable").parents("ul").sortable({ | |
update: function (a, | |
d) { | |
var f = g(this).parents(".wpProQuiz_listItem"); | |
b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: f, | |
index: f.index(), | |
solved: !0 | |
} | |
}) | |
} | |
}).disableSelection(); | |
b.find(".wpProQuiz_sortStringList, .wpProQuiz_maxtrixSortCriterion").sortable({ | |
connectWith: ".wpProQuiz_maxtrixSortCriterion:not(:has(li)), .wpProQuiz_sortStringList", | |
placeholder: "wpProQuiz_placehold", | |
update: function (a, d) { | |
var f = g(this).parents(".wpProQuiz_listItem"); | |
b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: f, | |
index: f.index(), | |
solved: !0 | |
} | |
}) | |
} | |
}).disableSelection(); | |
q = []; | |
ia.start(); | |
V = +new Date; | |
h = { | |
comp: { | |
points: 0, | |
correctQuestions: 0, | |
quizTime: 0 | |
} | |
}; | |
b.find(".wpProQuiz_questionList").each(function () { | |
var a = g(this).data("question_id"); | |
h[a] = { | |
time: 0 | |
} | |
}); | |
B = {}; | |
g.each(e.catPoints, function (a, b) { | |
B[a] = 0 | |
}); | |
w.hide(); | |
b.find(".wpProQuiz_loadQuiz").hide(); | |
m.show(); | |
u.show(); | |
3 != e.mode && b.trigger({ | |
type: "changeQuestion", | |
values: { | |
item: k, | |
index: k.index() | |
} | |
}) | |
} | |
}, | |
showSingleQuestion: function (a) { | |
a = a ? Math.ceil(a / e.qpp) : 1; | |
this.showSinglePage(a) | |
}, | |
showSinglePage: function (a) { | |
$listItem = v.children().hide(); | |
if (e.qpp) { | |
a = a ? +a : 1; | |
var c = Math.ceil(b.find(".wpProQuiz_list > li").length / e.qpp); | |
if (!(a > c)) { | |
var l = b.find('input[name="wpProQuiz_pageLeft"]').hide(), | |
f = b.find('input[name="wpProQuiz_pageRight"]').hide(), | |
g = b.find('input[name="checkSingle"]').hide(); | |
1 < a && l.val(l.data("text").replace(/%d/, a - 1)).show(); | |
a == c ? g.show() : f.val(f.data("text").replace(/%d/, a + 1)).show(); | |
N = a; | |
a = e.qpp * (a - 1); | |
$listItem.slice(a, a + e.qpp).show(); | |
d.methode.scrollTo(m) | |
} | |
} else $listItem.show() | |
}, | |
nextQuestion: function () { | |
this.showQuestionObject(k.next()) | |
}, | |
prevQuestion: function () { | |
this.showQuestionObject(k.prev()) | |
}, | |
showQuestion: function (a) { | |
var b = T.eq(a); | |
3 == e.mode || E ? (e.qpp && d.methode.showSingleQuestion(a + 1), d.methode.scrollTo(b, 1), s.startQuiz()) : this.showQuestionObject(b) | |
}, | |
showQuestionObject: function (a) { | |
if (!a.length && y && x && r) for (var c = 0, e = b.find(".wpProQuiz_listItem").length; c < e; c++) if (!q[c]) return alert(WpProQuizGlobal.questionsNotSolved), !1; | |
k.hide(); | |
k = a.show(); | |
d.methode.scrollTo(m); | |
b.trigger({ | |
type: "changeQuestion", | |
values: { | |
item: k, | |
index: k.index() | |
} | |
}); | |
k.length ? (a = k.find(".wpProQuiz_questionList").data("question_id"), s.questionStart(a)) : d.methode.showQuizSummary() | |
}, | |
skipQuestion: function () { | |
b.trigger({ | |
type: "skipQuestion", | |
values: { | |
item: k, | |
index: k.index() | |
} | |
}); | |
d.methode.nextQuestion() | |
}, | |
reviewQuestion: function () { | |
b.trigger({ | |
type: "reviewQuestion", | |
values: { | |
item: k, | |
index: k.index() | |
} | |
}) | |
}, | |
showQuizSummary: function () { | |
s.questionStop(); | |
s.stopQuiz(); | |
if (x || !r) H && 1 == e.formPos ? (u.hide(), m.hide(), d.methode.scrollTo(b.find(".wpProQuiz_infopage").show())) : d.methode.finishQuiz(); | |
else { | |
var a = b.find(".wpProQuiz_checkPage"); | |
a.find("ol:eq(0)").empty().append(b.find(".wpProQuiz_reviewQuestion ol li").clone().removeClass("wpProQuiz_reviewQuestionTarget")).children().click(function (b) { | |
a.hide(); | |
m.show(); | |
u.show(!0); | |
d.methode.showQuestion(g(this).index()) | |
}); | |
for (var c = 0, l = 0, f = q.length; l < f; l++) q[l] && c++; | |
a.find("span:eq(0)").text(c); | |
u.hide(); | |
m.hide(); | |
a.show(); | |
d.methode.scrollTo(a) | |
} | |
}, | |
//pause quiz | |
pauseQuiz:function (a) { | |
s.questionStop(); | |
ia.pause(); | |
}, | |
resumeQuiz:function(a){ | |
s.questionStart(); | |
ia.resume(); | |
}, | |
finishQuiz: function (a) { | |
s.questionStop(); | |
s.stopQuiz(); | |
ia.stop(); | |
var c = (+new Date - V) / 1E3, | |
c = e.timelimit && c > e.timelimit ? e.timelimit : c; | |
b.find(".wpProQuiz_quiz_time span").text(d.methode.parseTime(c)); | |
a && A.find(".wpProQuiz_time_limit_expired").show(); | |
d.methode.checkQuestion(v.children(), !0); | |
b.find(".wpProQuiz_correct_answer").text(h.comp.correctQuestions); | |
h.comp.result = Math.round(1E4 * (h.comp.points / e.globalPoints)) / 100; | |
$pointFields = b.find(".wpProQuiz_points span"); | |
$pointFields.eq(0).text(h.comp.points); | |
$pointFields.eq(1).text(e.globalPoints); | |
$pointFields.eq(2).text(h.comp.result + "%"); | |
b.find(".wpProQuiz_resultsList > li").eq(d.methode.findResultIndex(h.comp.result)).show(); | |
d.methode.setAverageResult(h.comp.result, !1); | |
this.setCategoryOverview(); | |
d.methode.sendCompletedQuiz(); | |
P && U && d.methode.addToplist(); | |
u.hide(); | |
b.find(".wpProQuiz_checkPage, .wpProQuiz_infopage").hide(); | |
m.hide(); | |
A.show(); | |
d.methode.scrollTo(A) | |
}, | |
setCategoryOverview: function () { | |
h.comp.cats = {}; | |
b.find(".wpProQuiz_catOverview li").each(function () { | |
var a = g(this), | |
b = a.data("category_id"); | |
if (void 0 === e.catPoints[b]) return a.hide(), !0; | |
var d = Math.round(1E4 * (B[b] / e.catPoints[b])) / 100; | |
h.comp.cats[b] = d; | |
a.find(".wpProQuiz_catPercent").text(d + | |
"%"); | |
a.show() | |
}) | |
}, | |
questionSolved: function (a) { | |
q[a.values.index] = a.values.solved | |
}, | |
sendCompletedQuiz: function () { | |
if (!G) { | |
ka(h); | |
var a = L.getFormData(); | |
d.methode.ajax({ | |
action: "wp_pro_quiz_completed_quiz", | |
quizId: e.quizId, | |
results: h, | |
forms: a | |
}) | |
} | |
}, | |
findResultIndex: function (a) { | |
for (var b = e.resultsGrade, d = -1, f = 999999, g = 0; g < b.length; g++) { | |
var h = b[g]; | |
a >= h && a - h < f && (f = a - h, d = g) | |
} | |
return d | |
}, | |
showQustionList: function () { | |
E = !E; | |
I.hide(); | |
m.toggle(); | |
b.find(".wpProQuiz_QuestionButton").hide(); | |
v.children().show(); | |
u.toggle(); | |
b.find(".wpProQuiz_question_page").hide() | |
}, | |
random: function (a) { | |
a.each(function () { | |
var a = g(this).children().get().sort(function () { | |
return Math.round(Math.random()) - 0.5 | |
}); | |
g(a).appendTo(a[0].parentNode) | |
}) | |
}, | |
sortCategories: function () { | |
var a = g(".wpProQuiz_list").children().get().sort(function (a, b) { | |
var d = g(a).find(".wpProQuiz_questionList").data("question_id"), | |
h = g(b).find(".wpProQuiz_questionList").data("question_id"); | |
return e.json[d].catId - e.json[h].catId | |
}); | |
g(a).appendTo(a[0].parentNode) | |
}, | |
restartQuiz: function () { | |
A.hide(); | |
w.show(); | |
v.children().hide(); | |
I.hide(); | |
u.hide(); | |
b.find(".wpProQuiz_questionInput, .wpProQuiz_cloze input").removeAttr("disabled").removeAttr("checked").css("background-color", ""); | |
b.find('.wpProQuiz_questionListItem input[type="text"]').val(""); | |
b.find(".wpProQuiz_answerCorrect, .wpProQuiz_answerIncorrect").removeClass("wpProQuiz_answerCorrect wpProQuiz_answerIncorrect"); | |
b.find(".wpProQuiz_listItem").data("check", !1); | |
b.find(".wpProQuiz_response").hide().children().hide(); | |
d.methode.resetMatrix(b.find(".wpProQuiz_listItem")); | |
b.find(".wpProQuiz_sortStringItem, .wpProQuiz_sortable").removeAttr("style"); | |
b.find(".wpProQuiz_clozeCorrect, .wpProQuiz_QuestionButton, .wpProQuiz_resultsList > li").hide(); | |
b.find('.wpProQuiz_question_page, input[name="tip"]').show(); | |
A.find(".wpProQuiz_time_limit_expired").hide(); | |
z.last().val(W); | |
E = !1 | |
}, | |
checkQuestion: function (a, c) { | |
a = void 0 == a ? k : a; | |
a.each(function () { | |
var a = g(this), | |
d = a.find(".wpProQuiz_questionList"), | |
k = e.json[d.data("question_id")], | |
m = k.type; | |
s.questionStop(); | |
if (a.data("check")) return !0; | |
if ("single" == k.type || "multiple" == k.type) m = "singleMulti"; | |
d = ja(m, k, a, d); | |
a.find(".wpProQuiz_response").show(); | |
a.find('input[name="check"]').hide(); | |
a.find('input[name="skip"]').hide(); | |
a.find('input[name="next"]').show(); | |
h[k.id].points = d.p; | |
h[k.id].correct = Number(d.c); | |
h[k.id].data = d.s; | |
h.comp.points += d.p; | |
B[k.catId] += d.p; | |
d.c ? (a.find(".wpProQuiz_correct").show(), h.comp.correctQuestions += 1) : a.find(".wpProQuiz_incorrect").show(); | |
a.find(".wpProQuiz_responsePoints").text(d.p); | |
a.data("check", !0); | |
c || b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: a, | |
index: a.index(), | |
solved: !0 | |
} | |
}) | |
}) | |
}, | |
showTip: function () { | |
var a = g(this), | |
c = a.siblings(".wpProQuiz_question").find(".wpProQuiz_questionList").data("question_id"); | |
a.siblings(".wpProQuiz_tipp").toggle("fast"); | |
h[c].tip = 1; | |
g(document).bind("mouseup.tipEvent", function (a) { | |
var c = b.find(".wpProQuiz_tipp"), | |
d = b.find('input[name="tip"]'); | |
c.is(a.target) || 0 != c.has(a.target).length || d.is(a.target) || (c.hide("fast"), g(document).unbind(".tipEvent")) | |
}) | |
}, | |
ajax: function (a, b, d) { | |
O && (jQuery.support.cors = !0); | |
g.post(WpProQuizGlobal.ajaxurl, a, b, d || "json"); | |
O && (jQuery.support.cors = !1) | |
}, | |
checkQuizLock: function () { | |
S = 1; | |
d.methode.ajax({ | |
action: "wp_pro_quiz_check_lock", | |
quizId: e.quizId | |
}, function (a) { | |
void 0 != a.lock && (da = a.lock.is, a.lock.pre && b.find('input[name="restartQuiz"]').hide()); | |
void 0 != a.prerequisite && (ea = 1, b.find(".wpProQuiz_prerequisite span").text(a.prerequisite)); | |
void 0 != a.startUserLock && (fa = a.startUserLock); | |
S = 0; | |
R && d.methode.startQuiz() | |
}) | |
}, | |
loadQuizData: function () { | |
d.methode.ajax({ | |
action: "wp_pro_quiz_load_quiz_data", | |
quizId: e.quizId | |
}, function (a) { | |
a.toplist && d.methode.handleToplistData(a.toplist); | |
void 0 != a.averageResult && d.methode.setAverageResult(a.averageResult, !0) | |
}) | |
}, | |
setAverageResult: function (a, | |
c) { | |
var d = b.find(".wpProQuiz_resultValue:eq(" + (c ? 0 : 1) + ") > * "); | |
d.eq(1).text(a + "%"); | |
d.eq(0).css("width", 240 * a / 100 + "px") | |
}, | |
handleToplistData: function (a) { | |
var c = b.find(".wpProQuiz_addToplist"), | |
d = c.find(".wpProQuiz_addBox").show().children("div"); | |
a.canAdd ? (c.show(), c.find(".wpProQuiz_addToplistMessage").hide(), c.find(".wpProQuiz_toplistButton").show(), ha = a.token, U = 0, a.userId ? (d.hide(), U = 1, P && c.hide()) : (d.show(), c = d.children().eq(1), a.captcha ? (c.find('input[name="wpProQuiz_captchaPrefix"]').val(a.captcha.code), | |
c.find(".wpProQuiz_captchaImg").attr("src", a.captcha.img), c.find('input[name="wpProQuiz_captcha"]').val(""), c.show()) : c.hide())) : c.hide() | |
}, | |
scrollTo: function (a, b) { | |
var d = a.offset().top - 100; | |
(b || (window.pageYOffset || document.body.scrollTop) > d) && g("html,body").animate({ | |
scrollTop: d | |
}, 300) | |
}, | |
addToplist: function () { | |
if (!G) { | |
var a = b.find(".wpProQuiz_addToplistMessage").text(WpProQuizGlobal.loadData).show(), | |
c = b.find(".wpProQuiz_addBox").hide(); | |
d.methode.ajax({ | |
action: "wp_pro_quiz_add_toplist", | |
quizId: e.quizId, | |
token: ha, | |
name: c.find('input[name="wpProQuiz_toplistName"]').val(), | |
email: c.find('input[name="wpProQuiz_toplistEmail"]').val(), | |
captcha: c.find('input[name="wpProQuiz_captcha"]').val(), | |
prefix: c.find('input[name="wpProQuiz_captchaPrefix"]').val(), | |
points: h.comp.points, | |
totalPoints: e.globalPoints | |
}, function (b) { | |
a.text(b.text); | |
b.clear ? (c.hide(), d.methode.updateToplist()) : c.show(); | |
b.captcha && (c.find(".wpProQuiz_captchaImg").attr("src", b.captcha.img), c.find('input[name="wpProQuiz_captchaPrefix"]').val(b.captcha.code), | |
c.find('input[name="wpProQuiz_captcha"]').val("")) | |
}) | |
} | |
}, | |
updateToplist: function () { | |
"function" == typeof wpProQuiz_fetchToplist && wpProQuiz_fetchToplist() | |
}, | |
registerSolved: function () { | |
b.find('.wpProQuiz_questionInput[type="text"]').change(function (a) { | |
a = g(this); | |
var c = a.parents(".wpProQuiz_listItem"), | |
d = !1; | |
"" != a.val() && (d = !0); | |
b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: c, | |
index: c.index(), | |
solved: d | |
} | |
}) | |
}); | |
b.find('.wpProQuiz_questionList[data-type="single"] .wpProQuiz_questionInput, .wpProQuiz_questionList[data-type="assessment_answer"] .wpProQuiz_questionInput').change(function (a) { | |
a = g(this).parents(".wpProQuiz_listItem"); | |
var c = this.checked; | |
b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: a, | |
index: a.index(), | |
solved: c | |
} | |
}) | |
}); | |
b.find(".wpProQuiz_cloze input").change(function () { | |
var a = g(this).parents(".wpProQuiz_listItem"), | |
c = !0; | |
a.find(".wpProQuiz_cloze input").each(function () { | |
if ("" == g(this).val()) return c = !1 | |
}); | |
b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: a, | |
index: a.index(), | |
solved: c | |
} | |
}) | |
}); | |
b.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').change(function (a) { | |
a = g(this).parents(".wpProQuiz_listItem"); | |
var c = 0; | |
a.find('.wpProQuiz_questionList[data-type="multiple"] .wpProQuiz_questionInput').each(function (a) { | |
this.checked && c++ | |
}); | |
b.trigger({ | |
type: "questionSolved", | |
values: { | |
item: a, | |
index: a.index(), | |
solved: c ? !0 : !1 | |
} | |
}) | |
}) | |
}, | |
loadQuizDataAjax: function (a) { | |
d.methode.ajax({ | |
action: "wp_pro_quiz_admin_ajax", | |
func: "quizLoadData", | |
data: { | |
quizId: e.quizId | |
} | |
}, function (c) { | |
e.globalPoints = c.globalPoints; | |
e.catPoints = c.catPoints; | |
e.json = c.json; | |
m.remove(); | |
b.find(".wpProQuiz_quizAnker").after(c.content); | |
ga = b.find('input[name="back"]'); | |
z = b.find('input[name="next"]'); | |
m = b.find(".wpProQuiz_quiz"); | |
v = b.find(".wpProQuiz_list"); | |
A = b.find(".wpProQuiz_results"); | |
w = b.find(".wpProQuiz_text"); | |
C = b.find(".wpProQuiz_time_limit"); | |
I = b.find(".wpProQuiz_toplistShowInButton"); | |
T = g(); | |
d.methode.initQuiz(); | |
a && d.methode.startQuiz(!0) | |
}) | |
}, | |
initQuiz: function () { | |
d.methode.setClozeStyle(); | |
d.methode.registerSolved(); | |
z.click(function () { | |
if (y && !q[k.index()] && (x || !r)) return alert(WpProQuizGlobal.questionNotSolved), !1; | |
d.methode.nextQuestion() | |
}); | |
ga.click(function () { | |
d.methode.prevQuestion() | |
}); | |
b.find('input[name="check"]').click(function () { | |
if (y && !q[k.index()] && (x || !r)) return alert(WpProQuizGlobal.questionNotSolved), !1; | |
d.methode.checkQuestion() | |
}); | |
b.find('input[name="checkSingle"]').click(function () { | |
if (y && (x || !r)) for (var a = 0, c = b.find(".wpProQuiz_listItem").length; a < c; a++) if (!q[a]) return alert(WpProQuizGlobal.questionsNotSolved), !1; | |
d.methode.showQuizSummary() | |
}); | |
b.find('input[name="tip"]').click(d.methode.showTip); | |
b.find('input[name="skip"]').click(d.methode.skipQuestion); | |
b.find('input[name="wpProQuiz_pageLeft"]').click(function () { | |
d.methode.showSinglePage(N - 1) | |
}); | |
b.find('input[name="wpProQuiz_pageRight"]').click(function () { | |
d.methode.showSinglePage(N + 1) | |
}) | |
} | |
}; | |
d.preInit = function () { | |
d.methode.parseBitOptions(); | |
u.init(); | |
b.find('input[name="startQuiz"]').click(function () { | |
d.methode.startQuiz(); | |
return !1 | |
}); | |
b.find('input[name="pause"]').click(function(){ | |
d.methode.pauseQuiz(); | |
}); | |
b.find('input[name="resume"]').click(function(){ | |
d.methode.resumeQuiz(); | |
}); | |
Z && !G && d.methode.checkQuizLock(); | |
b.find('input[name="reShowQuestion"]').click(function () { | |
d.methode.showQustionList() | |
}); | |
b.find('input[name="restartQuiz"]').click(function () { | |
d.methode.restartQuiz() | |
}); | |
b.find('input[name="review"]').click(d.methode.reviewQuestion); | |
b.find('input[name="wpProQuiz_toplistAdd"]').click(d.methode.addToplist); | |
b.find('input[name="quizSummary"]').click(d.methode.showQuizSummary); | |
b.find('input[name="endQuizSummary"]').click(function () { | |
if (y) for (var a = 0, c = b.find(".wpProQuiz_listItem").length; a < c; a++) if (!q[a]) return alert(WpProQuizGlobal.questionsNotSolved), !1; | |
H && 1 == e.formPos && !L.checkForm() || d.methode.finishQuiz() | |
}); | |
b.find('input[name="endInfopage"]').click(function () { | |
L.checkForm() && d.methode.finishQuiz() | |
}); | |
b.find('input[name="showToplist"]').click(function () { | |
m.hide(); | |
I.toggle() | |
}); | |
b.bind("questionSolved", d.methode.questionSolved); | |
Q || d.methode.initQuiz(); | |
aa && d.methode.startQuiz() | |
}; | |
d.preInit() | |
}; | |
g.fn.wpProQuizFront = function (M) { | |
return this.each(function () { | |
void 0 == g(this).data("wpProQuizFront") && g(this).data("wpProQuizFront", new g.wpProQuizFront(this, M)) | |
}) | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment