Widget:UserExamQuery: Difference between revisions

Jump to navigation Jump to search
Matt Pijoan (talk | contribs)
No edit summary
Matt Pijoan (talk | contribs)
No edit summary
 
(61 intermediate revisions by the same user not shown)
Line 2: Line 2:
<style type="text/css">
<style type="text/css">
#metrics{
#metrics{
width:80%;
width:100%;
text-align: center;
text-align: center;
}
}
.cell{
.headerCell{
display: inline-block;
width:20%;
width:20%;
text-align: center;
}
.question{
background: #C7DDEE;
color:#000;
display: inline-block;
display: inline-block;
width:20%;
height:30px;
}
}
span{
.cell
width:100%;
{ background:#C7DDEE url('http://www.jankoatwarpspeed.com/wp-content/uploads/examples/expandable-rows/row_bkg.png') repeat-x scroll center left; color:#000; display: inline-block; width:20%; height:30px; }
#header { background:#7CB8E2 url('http://www.jankoatwarpspeed.com/wp-content/uploads/examples/expandable-rows/header_bkg.png') repeat-x scroll center left; color:#fff; width:100%; height:30px; text-align:left;
display: inline-block;}
.mw-collapsible-toggle{
position:absolute;
/* @noflip */
right: 20px;
}
}
</style>
</style>
<script type="text/javascript">
<script type="text/javascript">
function ensureLoggedIn() {
function ensureLoggedIn() {
mw.loader.using('mediawiki.user', function () { ;
mw.loader.using('mediawiki.user', function() {
if ($.isEmptyObject(wgUserName)) {
        mw.loader.using('jquery.makeCollapsible', function() {
alert("Please Log In To Continue.");
if ($.isEmptyObject(wgUserName)) {
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=UserExamQuery");
alert("Please Log In To Continue.");
} else {
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=UserExamQuery");
runQuery();
} else {
}
runQuery();
}
});
});
        });
}
}
function runQuery() {
function runQuery() {
Line 33: Line 47:
})
})
.always(function (data) {
.always(function (data) {
$.each(data.userExamQuery[0], function (index, value) {
        $.each(data.userExamQuery[0], function(index, value){
var outstring = "";
              var outstring = "";
var timeBegin = "";
                var timeBegin = "";
var timeEnd = "";
                var timeEnd = "";
var scoreString = "";
                var scoreString = "";
if (value.begin != null) {
                if(value.begin != null){
timeBegin = new Date(value.begin * 1000).toDateString();
                      timeBegin = new Date(value.begin * 1000).toDateString();
}
                }
if (value.end != null) {
                if(value.end != null){
timeEnd = new Date(value.end * 1000).toDateString();
                      timeEnd = new Date (value.end * 1000).toDateString();
scoreString = value.score + "%";
                      scoreString = value.score + "%";
} else {
                } else {
timeEnd = "Unfinished";
                      timeEnd = "Unfinished";
scoreString = "N/A";
                      scoreString = "N/A";
}
                }
 
                if($(value.questions).length > 0){
if ($(value.questions).length > 0) {
                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 class='mw-collapsible mw-collapsed'><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 class='mw-collapsible-content'>";
outstring += "<div class='mw-collapsible-content'><ul>";
                $.each(value.questions, function(ind, val){
$.each(value.questions, function (ind, val) {
                outstring += "<span class='question'>"+val.title+"</span>";
outstring += "<span class='cell'>" + val.title + "</span>";
                if(val.timestam != null){
});
                      var timestam = new Date (val.timestam * 1000).toDateString();
outstring += "</div></div>";
                      outstring += "<span class='question'>"+timestam+"</span>";
} else {
                }
outstring += "<div style='width:80%'<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></div>";
                outstring += "<span class='question'>"+val.submitted+"</span><br />";
 
                });
}
                outstring += "</div>"
outstring += "</ul>";
                outstring += "</div>";
$("#metrics").append(outstring);
                $("#metrics").append(outstring);
});
                $("#"+value.id).makeCollapsible();
                }
        });
});
});
}
}
Line 68: Line 84:


</script>
</script>
<div id="metrics"></div>
<div id="metrics">
<div id="header">
<span class="headerCell">Exam ID</span><span class="headerCell">Date started</span><span class="headerCell">Performance</span><span class="headerCell">Date Finished</span><span class="headerCell">Exam Type</span>
</div>
</div>
</includeonly>
</includeonly>

Latest revision as of 19:40, 24 July 2014