Widget:WJG Random Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 435: | Line 435: | ||
$('#myExamBigButton').addClass('examButtonNotSelected'); | $('#myExamBigButton').addClass('examButtonNotSelected'); | ||
$('#newExamBigButton').removeClass('examButtonNotSelected'); | $('#newExamBigButton').removeClass('examButtonNotSelected'); | ||
$('#wjgContainer').hide() | |||
}); | }); | ||
Line 445: | Line 446: | ||
$('#myExamBigButton').removeClass('examButtonNotSelected'); | $('#myExamBigButton').removeClass('examButtonNotSelected'); | ||
alert('Coming soon!') | alert('Coming soon!') | ||
$('#wjgContainer').show() | |||
if (window.exam.performanceQueriesRun==null){ | |||
window.exam.performanceQueriesRun=1 | |||
runPerformanceQuery(); | |||
} | |||
}); | }); | ||
Line 471: | Line 477: | ||
countCats() | countCats() | ||
}; | }; | ||
function runPerformanceQuery() { | |||
var r = $.Deferred(); | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'userExamQuery', | |||
username : wgUserName, | |||
format : 'json' | |||
}) | |||
.always(function (data) { | |||
$.each(data.userExamQuery[0], function(index, value){ | |||
var outstring = ""; | |||
var timeBegin = ""; | |||
var timeEnd = ""; | |||
var scoreString = ""; | |||
if(value.begin != null){ | |||
timeBegin = new Date(value.begin * 1000).toDateString(); | |||
} | |||
if(value.end != null){ | |||
timeEnd = new Date (value.end * 1000).toDateString(); | |||
scoreString = value.score + "%"; | |||
} else { | |||
timeEnd = "Unfinished"; | |||
scoreString = "N/A"; | |||
} | |||
if($(value.questions).length > 0){ | |||
var wjg_string="<tr class='odd'>"+ | |||
"<td>"+value.id +"</td>" + | |||
"<td>" + timeBegin + "</td>" + | |||
"<td>" + scoreString + "</td>" + | |||
"<td>" + timeEnd + "</td>" + | |||
"<td>" + value.type + "</td>" + | |||
'<td><div class="arrow"></div></td>' + | |||
"</tr>" + | |||
"<tr style='display:none'>" + | |||
'<td colspan="6">' + | |||
"<h4>Additional information</h4>" + | |||
"<ul>" + | |||
"<li>Categories selected: Cardiology, Oncology</li>" + | |||
"<li>Subcategories selected: Pharmacology</li>" + | |||
"<li>Resume exam!</li>" + | |||
"</ul>" + | |||
"</td>" + | |||
"</tr>"; | |||
$( "tbody" ).append( wjg_string ); | |||
outstring += "<div id='"+value.id+"'><span class='cell'>"+value.id+"</span><span class='cell'>"+timeBegin+"</span><span class='cell'>"+scoreString+"</span><span class='cell'>"+timeEnd+"</span><span class='cell'>"+value.type+"</span>"; | |||
outstring += "<div>"; | |||
// $.each(value.questions, function(ind, val){ | |||
// outstring += val.title+"<br />"; | |||
// }); | |||
// outstring += "</div>" | |||
// outstring += "</div>"; | |||
// $("#metrics").append(outstring); | |||
// $("#"+value.id).makeCollapsible(); | |||
} | |||
}); | |||
}); | |||
setTimeout(function (){ | |||
// and call `resolve` on the deferred object, once you're done | |||
r.resolve(); | |||
}, 2500); | |||
return r | |||
$("tr:odd").addClass("odd"); | |||
$("tr:not(.odd)").hide(); | |||
$("tr:first-child").show(); | |||
$("tr.odd").click(function(){ | |||
$(this).next("tr").toggle(); | |||
$(this).find(".arrow").toggleClass("up"); | |||
}); | |||
}; | |||
function categoryOrKeyword(event) { | function categoryOrKeyword(event) { | ||
window.exam.examType = $(this).attr('id'); | window.exam.examType = $(this).attr('id'); | ||
Line 1,477: | Line 1,552: | ||
</script> | </script> | ||
<div id="chooseQBank" style='height:100%;'></div> | <div id="chooseQBank" style='height:100%;'></div> | ||
<div id="testOptions" style='height:100%;'> | <div id="testOptions" style='height:100%;'> | ||
<div class="container" id="tutorOrExamContainer" style="height:105px"> | <div class="container" id="tutorOrExamContainer" style="height:105px"> | ||
Line 1,495: | Line 1,571: | ||
<div class='arrow-up' id='myExamsArrow' style="margin-left:calc(50% - 60px); display: inline-block;"></div> | <div class='arrow-up' id='myExamsArrow' style="margin-left:calc(50% - 60px); display: inline-block;"></div> | ||
<div class='arrow-up' id='newExamArrow' style="display: inline-block; margin-left: 100px;"></div> | <div class='arrow-up' id='newExamArrow' style="display: inline-block; margin-left: 100px;"></div> | ||
</div> | |||
<div id="wjgContainer" style='display:none'> | |||
<table id="report"> | |||
<thead> | |||
<tr> | |||
<th>Exam ID</th> | |||
<th>Date started</th> | |||
<th>Performance</th> | |||
<th>Date Finished</th> | |||
<th>Exam Type</th> | |||
<th></th> | |||
</tr> | |||
</thead> | |||
</table> | |||
<div id="tableContainer"> | |||
<table id="report"> | |||
<tbody> | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> | </div> | ||
<div id='examOptions' style='display:none'> | <div id='examOptions' style='display:none'> |