Widget:WJG Sandbox: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
.redBoxed{ | .redBoxed{ | ||
border:0px solid #F00 !important; | border:0px solid #F00 !important; | ||
} | } | ||
.unboxed{ | .unboxed{ | ||
Line 43: | Line 43: | ||
height:40px; | height:40px; | ||
font-weight:bold; | font-weight:bold; | ||
width: | width:100px; | ||
display: table-cell; | display: table-cell; | ||
cursor: pointer; | cursor: pointer; | ||
Line 64: | Line 64: | ||
float:left; | float:left; | ||
width:5%; | width:5%; | ||
} | |||
#examSpace{ | |||
position:relative; | |||
float:right; | |||
width:94%; | |||
} | } | ||
#navBar{ | #navBar{ | ||
Line 70: | Line 74: | ||
float:right; | float:right; | ||
width:95%; | width:95%; | ||
background-color:#3366CC; | |||
} | } | ||
.navPaneButton{ | .navPaneButton{ | ||
height:20px; | height:20px; | ||
Line 282: | Line 281: | ||
} | } | ||
function removeDuplicates(obj) { | function removeDuplicates(obj) { | ||
var output = "<div id='removeNum'><b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + obj. | if(res.Count > 45){ | ||
obj.maxQ = 45; | |||
} else { | |||
obj.maxQ = res.Count; | |||
} | |||
var output = "<div id='removeNum'><b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + obj.maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div></div>"; | |||
if ($("#exam").find('#numQues').length == 0) { | if ($("#exam").find('#numQues').length == 0) { | ||
$("#exam").append(output); | $("#exam").append(output); | ||
Line 295: | Line 299: | ||
function TNG(event) { | function TNG(event) { | ||
event.data.numQuestion = $("#numQues").val(); | event.data.numQuestion = $("#numQues").val(); | ||
if(event.data.numQuestion > 0 && event.data.numQuestion <= 45){ | |||
loadNextQuestion(event.data); | loadNextQuestion(event.data); | ||
} else { | |||
alert('Invalid number of questions entered.'); | |||
} | |||
} | } | ||
function selectCats(exam) { | function selectCats(exam) { | ||
Line 404: | Line 412: | ||
}, { | }, { | ||
ok : function (res) { | ok : function (res) { | ||
if( res.Count > 45){ | |||
event.data.maxQ = 45; | |||
} else { | |||
event.data.maxQ = res.Count; | |||
} | |||
var output = "<b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + event.data.maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>"; | var output = "<b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + event.data.maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>"; | ||
if ($("#exam").find('#numQues').length == 0) { | if ($("#exam").find('#numQues').length == 0) { | ||
Line 460: | Line 472: | ||
} | } | ||
function loadNextQuestion(event) { | function loadNextQuestion(event) { | ||
if(event.searchMethod === "Category"){ | |||
var api = new mw.Api(event); | var api = new mw.Api(event); | ||
api.get({ | api.get({ | ||
Line 480: | Line 493: | ||
} | } | ||
}); | }); | ||
} else if(event.searchMethod === "Keyword"){ | |||
var api = new mw.Api(event); | |||
api.get({ | |||
action : 'load', | |||
keywords : JSON.stringify(event.questionListAll), | |||
num : event.numQuestion, | |||
format : 'json' | |||
}, { | |||
ok : function (res) { | |||
var i = 0; | |||
event.currentQuestion = 0; | |||
$.each(res.questions.list, function (key, element) { | |||
element.PageName = key; | |||
event.examQuestions[i] = element; | |||
i++; | |||
}); | |||
addToNavBar(event); | |||
} | |||
}); | |||
} | |||
} | } | ||
function addToNavBar(exam) { | function addToNavBar(exam) { | ||
$("#exam").html("<div id='navBar'><div id='back' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/c/c1/WBRLeftArrowlightblue.png' /></div><div id='next' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/e/eb/WBRRightArrowlightblue.png' /></div><div id='finish' class='noSelect WBRButton'><br />Finish</div></div><div id='navPane'></div><div id='examSpace'></div><span id='timeRem' style='height: 0px; visibility: hidden'>" + exam.timeAmt.toString() + "</span>"); | $("#exam").html("<div id='navBar'><div id='flag' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/8/89/Flag_3_16_14.png' /></div><div id='back' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/c/c1/WBRLeftArrowlightblue.png' /></div><div id='next' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/e/eb/WBRRightArrowlightblue.png' /></div><div id='finish' class='noSelect WBRButton'><br />Finish</div></div><div id='navPane'></div><div id='examSpace'></div><span id='timeRem' style='height: 0px; visibility: hidden'>" + exam.timeAmt.toString() + "</span>"); | ||
$("#back").click(exam, questionNavigation); | $("#flag").click(function(){alert("Coming Soon!")}); | ||
$("#back").click(exam, questionNavigation); | |||
$("#next").click(exam, questionNavigation); | $("#next").click(exam, questionNavigation); | ||
$("#finish").click(exam, endExam); | $("#finish").click(exam, endExam); | ||
Line 618: | Line 652: | ||
$("#examSpace").prepend(ratyLayers); | $("#examSpace").prepend(ratyLayers); | ||
getRating(exam.examQuestions[exam.currentQuestion].PageName); | getRating(exam.examQuestions[exam.currentQuestion].PageName, exam); | ||
Line 634: | Line 668: | ||
} | } | ||
} | } | ||
function getRating(page) { | function getRating(page, exam) { | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
Line 650: | Line 684: | ||
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | ||
}); | }); | ||
$("#star1").append("(Avg: " + res.wbrgetrating.difficulty + ", n=" + res.wbrgetrating.diffCount + ")" ); | |||
$("#star2").raty({ | $("#star2").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/img/', | path : 'http://www.wikidoc.org/includes/raty/img/', | ||
Line 658: | Line 693: | ||
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | ||
}); | }); | ||
$("#star2").append("(Avg: " + res.wbrgetrating.yield + ", n=" + res.wbrgetrating.qualCount + ")" ); | |||
$("#star3").raty({ | $("#star3").raty({ | ||
path : 'http://www.wikidoc.org/includes/raty/img/', | path : 'http://www.wikidoc.org/includes/raty/img/', | ||
Line 665: | Line 701: | ||
score: res.wbrgetrating.quality, | score: res.wbrgetrating.quality, | ||
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good'] | ||
}); } | }); | ||
$("#star3").append("(Avg: " + res.wbrgetrating.quality + ", n=" + res.wbrgetrating.yieldSum + ")" ); | |||
} | |||
});} | });} | ||
function answerSubmitted(event) { | function answerSubmitted(event) { | ||
Line 701: | Line 739: | ||
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed"); | $("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed"); | ||
} else if (event.data.examType === "Tutor") { | } else if (event.data.examType === "Tutor") { | ||
$("#examSpace").append("<br /><br />The correct answer is: " + event.data.examQuestions[event.data.currentQuestion].RightAnswer + "<br /><br / | $("#examSpace").append("<br /><br />The correct answer is: " + event.data.examQuestions[event.data.currentQuestion].RightAnswer + "<br /><br />" + event.data.examQuestions[event.data.currentQuestion].Explanation + "<br />"); | ||
$("#examSpace").append("<b>Author:</b> " + event.data.examQuestions[event.data.currentQuestion].PageAuthor + "<br /><br /><b>Wiki Page:</b>" + event.data.examQuestions[event.data.currentQuestion].PageName + "<br /><br />"); | $("#examSpace").append("<b>Author:</b> " + event.data.examQuestions[event.data.currentQuestion].PageAuthor + "<br /><br /><b>Wiki Page:</b>" + event.data.examQuestions[event.data.currentQuestion].PageName + "<br /><br />Discuss this question <a href='http://www.wikidoc.org/index.php/Talk:" + event.data.examQuestions[event.data.currentQuestion].PageName + "'>Here</a>"); | ||
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed"); | $("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed"); | ||
$("#" + event.data.examQuestions[event.data.currentQuestion].RightAnswer).addClass("redBoxed"); | $("#" + event.data.examQuestions[event.data.currentQuestion].RightAnswer).addClass("redBoxed"); | ||
Line 743: | Line 781: | ||
datas = ""; | datas = ""; | ||
datas += "<br />You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: "; | datas += "<br />You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: "; | ||
var percent = (event.data.answeredRight / event.data. | var percent = (event.data.answeredRight / event.data.examQuestions.length) * 100; | ||
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered."; | datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered."; | ||
var api = new mw.Api(); | var api = new mw.Api(); |