Widget:WJG Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
<script src="http://wikidoc.org/includes/jquery.timer.js"></script> | <script src="http://www.wikidoc.org/includes/raty/jquery.timer.js"></script> | ||
<script type="text/javascript" src="http://wikidoc.org/includes/raty/jquery.raty.js"></script> | <script type="text/javascript" src="http://www.wikidoc.org/includes/raty/jquery.raty.js"></script> | ||
<style type="text/css"> | <style type="text/css"> | ||
.boxed{ | .boxed{ | ||
border: | border:0px solid black !important; | ||
} | } | ||
.redBoxed{ | .redBoxed{ | ||
border: | border:0px solid #F00 !important; | ||
} | } | ||
Line 47: | Line 47: | ||
#examSpace{ | #examSpace{ | ||
position:relative; | position:relative; | ||
float: | float:right; | ||
width: | width:94%; | ||
} | } | ||
#navBar{ | #navBar{ | ||
Line 65: | Line 64: | ||
} | } | ||
div.answerNoBorder{ | div.answerNoBorder{ | ||
border: | border:0px solid #FFF; | ||
} | } | ||
div.answerBorder{ | div.answerBorder{ | ||
border: | border:0px solid #000; | ||
} | } | ||
div.explanationHide{ | div.explanationHide{ | ||
Line 311: | Line 310: | ||
for (var i = 0; i < categories['sub'].length; i++) { | for (var i = 0; i < categories['sub'].length; i++) { | ||
if (categories['main'][i]) { | if (categories['main'][i]) { | ||
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " ( " + exam.arrCounts['category']['main'][categories['main'][i]] + " ) </td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " )</td></tr>"; | table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " ( " + exam.arrCounts['category']['main'][categories['main'][i]] + " ) </td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]]+ " )</td></tr>"; | ||
} else { | } else { | ||
table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " ) </td></tr>"; | table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " ) </td></tr>"; | ||
Line 475: | Line 474: | ||
}); | }); | ||
$("#" + exam.currentQuestion).addClass("boxed"); | $("#" + exam.currentQuestion).addClass("boxed"); | ||
$(".navPaneButton:odd").css("background-color", "# | $(".navPaneButton:odd").css("background-color", "#3338CC"); | ||
$(".navPaneButton:odd").css("background-color", "#B0B0B0"); | |||
questionDisplay(exam); | questionDisplay(exam); | ||
} | } | ||
Line 491: | Line 490: | ||
} | } | ||
if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") { | if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ae'> | htmlStuff += "<div class='answerExp explanationHide' id='Ae'>" + trimP(obj.AnswerAExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerB && obj.AnswerB.length > 0) { | if (obj.AnswerB && obj.AnswerB.length > 0) { | ||
Line 497: | Line 496: | ||
} | } | ||
if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && exam.examType === "Tutor") { | if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Be'> | htmlStuff += "<div class='answerExp explanationHide' id='Be'>" + trimP(obj.AnswerBExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerC && obj.AnswerC.length > 0) { | if (obj.AnswerC && obj.AnswerC.length > 0) { | ||
Line 503: | Line 502: | ||
} | } | ||
if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && exam.examType === "Tutor") { | if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ce'> | htmlStuff += "<div class='answerExp explanationHide' id='Ce'>" + trimP(obj.AnswerCExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerD && obj.AnswerD.length > 0) { | if (obj.AnswerD && obj.AnswerD.length > 0) { | ||
Line 509: | Line 508: | ||
} | } | ||
if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && exam.examType === "Tutor") { | if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='De'> | htmlStuff += "<div class='answerExp explanationHide' id='De'>" + trimP(obj.AnswerDExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerEExp && obj.AnswerE.length > 0) { | if (obj.AnswerEExp && obj.AnswerE.length > 0) { | ||
Line 515: | Line 514: | ||
} | } | ||
if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && exam.examType === "Tutor") { | if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ee'> | htmlStuff += "<div class='answerExp explanationHide' id='Ee'>" + trimP(obj.AnswerEExp) + "</div>"; | ||
} | } | ||
$("#examSpace").html(htmlStuff); | $("#examSpace").html(htmlStuff); | ||
Line 523: | Line 522: | ||
$("div.answer").mouseover(function () { | $("div.answer").mouseover(function () { | ||
$(this).css({ | $(this).css({ | ||
'border' : ' | 'border' : '0px solid #000' | ||
}) | }) | ||
}).mouseout(function () { | }).mouseout(function () { | ||
$(this).css({ | $(this).css({ | ||
'border' : ' | 'border' : '0px solid #FFF' | ||
}) | }) | ||
}); | }); | ||
Line 551: | Line 550: | ||
} | } | ||
if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") { | if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i> | htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i> " + obj.AnswerAExp + "</i></div>"; | ||
} | } | ||
if (obj.AnswerB && obj.AnswerB.length > 0) { | if (obj.AnswerB && obj.AnswerB.length > 0) { | ||
Line 588: | Line 587: | ||
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder"); | $("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder"); | ||
} | } | ||
$("#examSpace").append("<br /><br />The correct answer is: " + exam.examQuestions[exam.currentQuestion].RightAnswer + "<br /><br />< | $("#examSpace").append("<br /><br />The correct answer is: " + exam.examQuestions[exam.currentQuestion].RightAnswer + "<br /><br /><b>" + exam.examQuestions[exam.currentQuestion].Explanation + "</b><br />"); | ||
} | } | ||
} | } | ||
Line 594: | Line 593: | ||
var ratyLayers = "<center>Rate this question!</center><br /><span style='position:relative; float:left;'>Difficulty: <div id='star1'></div></span><span style='position:relative; float:left;left:33%;'>High Yield: <div id='star2'></div></span><span style='position:relative; float:left;left:66%'>Quality: <div id='star3'></div></span><br /><br /><br />" | var ratyLayers = "<center>Rate this question!</center><br /><span style='position:relative; float:left;'>Difficulty: <div id='star1'></div></span><span style='position:relative; float:left;left:33%;'>High Yield: <div id='star2'></div></span><span style='position:relative; float:left;left:66%'>Quality: <div id='star3'></div></span><br /><br /><br />" | ||
$("#examSpace").prepend(ratyLayers); | $("#examSpace").prepend(ratyLayers); | ||
getRating(exam.examQuestions[exam.currentQuestion].PageName); | |||
} | |||
function answerClicked(event){ | |||
$(".answer").removeClass("boxed"); | |||
$('input[type=radio]').prop('checked', function () { | |||
return this.getAttribute('checked') == 'checked'; | |||
}); | |||
$(this).addClass("boxed"); | |||
$(this).find("#Ar").prop("checked",true); | |||
if($("#exam").find('#submit').length == 0){ | |||
$("#examSpace").append("<div class='noSelect WBRButton' id='submit'><br />Submit</div>"); | |||
$("#submit").click(event.data, answerSubmitted); | |||
} | |||
} | |||
function getRating(page) { | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'wbrgetrating', | |||
question : page, | |||
format : 'json' | |||
}, { | |||
ok : function (res) { | |||
$("#star1").raty({ | $("#star1").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/img/', | path : 'http://www.wikidoc.org/includes/raty/img/', | ||
click : function (score, event) { | click : function (score, event) { | ||
submitRating("difficulty", score | submitRating("difficulty", score, exam.examQuestions[exam.currentQuestion].PageName) | ||
}, | }, | ||
score: res.wbrgetrating.difficulty, | |||
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | ||
}); | }); | ||
Line 607: | Line 629: | ||
path : 'http://www.wikidoc.org/includes/raty/img/', | path : 'http://www.wikidoc.org/includes/raty/img/', | ||
click : function (score, event) { | click : function (score, event) { | ||
submitRating("yield", score | submitRating("yield", score, exam.examQuestions[exam.currentQuestion].PageName) | ||
}, | }, | ||
score: res.wbrgetrating.yield, | |||
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | ||
}); | }); | ||
Line 617: | Line 637: | ||
path : 'http://www.wikidoc.org/includes/raty/img/', | path : 'http://www.wikidoc.org/includes/raty/img/', | ||
click : function (score, event) { | click : function (score, event) { | ||
submitRating("quality", score | submitRating("quality", score, exam.examQuestions[exam.currentQuestion].PageName) | ||
}, | }, | ||
score: res.wbrgetrating.quality, | |||
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | ||
}); | }); } | ||
});} | |||
} | |||
}); | |||
} | |||
function answerSubmitted(event) { | function answerSubmitted(event) { | ||
$("#submit").remove(); | $("#submit").remove(); | ||
Line 649: | Line 653: | ||
$(".answerExp").css("height", "auto"); | $(".answerExp").css("height", "auto"); | ||
$(".answerExp").css("visibility", "visible"); | $(".answerExp").css("visibility", "visible"); | ||
$(".answerExp").each(function(){ | |||
if($(this).attr('id') === event.data.examQuestions[event.data.currentQuestion].RightAnswer+"e"){ | |||
$(this).prepend(" <b>Correct:</b> "); | |||
} else { | |||
$(this).prepend(" <b>Incorrect:</b> "); | |||
} | |||
}); | |||
} | } | ||
$("div.answer").unbind('click'); | $("div.answer").unbind('click'); | ||
Line 724: | Line 735: | ||
$(".navPaneButton").click(event.data, questionReviewNavigation); | $(".navPaneButton").click(event.data, questionReviewNavigation); | ||
} | } | ||
function submitRating( | function submitRating(ratingType, score, page) { | ||
if(ratingType === "difficulty"){ | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
Line 730: | Line 742: | ||
username : mw.user.getName(), | username : mw.user.getName(), | ||
question : page, | question : page, | ||
difficulty : score, | |||
format : 'json' | |||
}, { | |||
ok : function (res) {} | |||
}); | |||
} else if (ratingType === "yield"){ | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'wbrinsertrating', | |||
username : mw.user.getName(), | |||
question : page, | |||
yield : score, | |||
format : 'json' | format : 'json' | ||
}, { | }, { | ||
Line 736: | Line 759: | ||
}); | }); | ||
} | } | ||
else if (ratingType === "quality"){ | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
action : ' | action : 'wbrinsertrating', | ||
username : mw.user.getName(), | |||
question : page, | question : page, | ||
quality : score, | |||
format : 'json' | format : 'json' | ||
}, { | }, { | ||
ok : function (res) { | ok : function (res) {} | ||
}); | }); | ||
} | } | ||
} | |||
function parseQuestions(examObj) { | function parseQuestions(examObj) { | ||
var tobeParsed = null; | var tobeParsed = null; |