Skip to content

Commit

Permalink
Added GamesStarted, TimePlayed, Medals, FirstPlayed, LastPlayed to th…
Browse files Browse the repository at this point in the history
…e student overview in the instructor's pane.
  • Loading branch information
John Conomikes committed Sep 6, 2011
1 parent d0aca63 commit 005627a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 10 deletions.
40 changes: 38 additions & 2 deletions src/TestHarness/clientjs/instructor.js
Expand Up @@ -109,10 +109,31 @@ $(document).ready(function ()
{
return util.dateFormat(value * 1000, 'm/d HH:MM');
}
function formatUTC(row, cell, value, columnDef, dataContext) {
if(value === null) {
return "No Games";
}
return util.dateFormat(value, 'UTC:m/d HH:MM');
}
function formatDuration(row, cell, value, columnDef, dataContext)
{
return Math.round(value / 1000) + ' s'
}
function formatDurationLong(row, cell, value, columnDef, dataContext)
{
if(value === null) {
return "0 m";
}

var val = Math.round(value / 60000);
var str = "";
if(val > 59) {
str += val / 60 + " h ";
val = val % 60;
}

return str + val + ' m'
}
function formatMedal(row, cell, value, columnDef, dataContext)
{
var medal = constants.medal.codeToString(value);
Expand All @@ -123,6 +144,18 @@ $(document).ready(function ()
var endState = constants.endState.codeToString(value);
return '<div class="end-state ' + endState + '">' + endState + '</div>';
}
function formatMedalCount(row, cell, value, columnDef, dataContext) {
if(value === null) {
return "No Games";
}

var vArray = value.split(' ');
var ret = '';
ret += '<div class="medal gold">' + vArray[0] + '</div> ';
ret += '<div class="medal silver">' + vArray[1] + '</div> ';
ret += '<div class="medal bronze">' + vArray[2] + '</div> ';
return ret;
}

var selectedStudentLoginIDs = [];
var studentDataView = new Slick.Data.DataView();
Expand All @@ -135,10 +168,13 @@ $(document).ready(function ()
{id:'loginID', field:'loginID', name:'Login ID', sortable:true},
{id:'password', field:'password', name:'Password'},
{id:'condition', field:'condition', name:'Condition', sortable:true},
{id:'gameCount', field:'gameCount', name:'Games', sortable:true}
{id:'gameCount', field:'gameCount', name:'Games', sortable:true},
{id:'TotalTime', field:'TotalTime', name:'Total Time', sortable:true, formatter:formatDurationLong},
{id:'Medals', field:'Medals', name:'Medals', sortable:true, formatter:formatMedalCount},
{id:'FirstDate', field:'FirstDate', name:'First Date', sortable:true, formatter:formatUTC},
{id:'LastDate', field:'LastDate', name:'Last Date', sortable:true, formatter:formatUTC}
],
{
forceFitColumns: true
});
studentGrid.setSelectionModel(new Slick.RowSelectionModel());
studentGrid.onSelectedRowsChanged.subscribe(function ()
Expand Down
43 changes: 35 additions & 8 deletions src/TestHarness/instructorserver.js
Expand Up @@ -369,22 +369,49 @@ exports.addInstructorEndpoints = function (app, rootPath, gc, model, config)
Students.password, \
Students.condition, \
Instructors.loginID AS instructorLoginID, \
gameCount \
CASE WHEN SUM(QuestionSetOutcomes.elapsedMS) IS NULL THEN 0 ELSE COUNT(*) END AS gameCount, \
medalTable.Medals, \
SUM(QuestionSetOutcomes.elapsedMS) AS TotalTime, \
MIN(QuestionSetOutcomes.createdAt) AS FirstDate, \
MAX(QuestionSetOutcomes.createdAt) AS LastDate \
FROM Students \
INNER JOIN Instructors ON Instructors.id = Students.InstructorId \
LEFT JOIN QuestionSetOutcomes ON QuestionSetOutcomes.studentId = Students.id \
LEFT JOIN Instructors ON Instructors.id = Students.InstructorId \
LEFT JOIN ( \
SELECT \
StudentId, \
COUNT(*) AS gameCount \
FROM QuestionSetOutcomes \
GROUP BY StudentID \
) GameCounts ON GameCounts.StudentId = Students.id \
studentId, \
CONCAT( \
CAST(COUNT(CASE WHEN medal = 3 THEN 1 ELSE NULL END) AS CHAR(4)), "g ", \
CAST(COUNT(CASE WHEN medal = 2 THEN 1 ELSE NULL END) AS CHAR(4)), "s ", \
CAST(COUNT(CASE WHEN medal = 1 THEN 1 ELSE NULL END) AS CHAR(4)), "b" \
) AS Medals \
FROM ( \
SELECT \
DISTINCT \
studentId, \
MAX(medal) AS medal, \
stageID \
FROM \
QuestionSetOutcomes \
WHERE \
medal > 0 \
AND endState = 0 \
GROUP BY \
studentId, stageID \
) AS T \
GROUP BY \
studentId \
) AS medalTable ON medalTable.studentId = Students.id \
';

if (!instructor.isAdmin)
{
query += 'WHERE Instructors.id = ?';
query += ' WHERE Instructors.id = ? ';
params.push(instructor.id);
}

query += ' GROUP BY Students.id '

if (config.debug)
{
console.log('Custom Query:' + query.replace(/ +/g, ' '));
Expand Down
3 changes: 3 additions & 0 deletions src/TestHarness/views/instructor.ejs
Expand Up @@ -18,12 +18,15 @@
div.medal.gold {
background-color: #ffff99;
display: inline;
}
div.medal.silver {
background-color: #eee;
display: inline;
}
div.medal.bronze {
background-color: #fbf0d2;
display: inline;
}
div.end-state.completed {
Expand Down

0 comments on commit 005627a

Please sign in to comment.