JSFiddle - React, Tailwind, and code Playground
by Dmitry Ieremenko
JavaScript
function Results()
{
function calculate()
{
var results = {
total : 0,
not_started : 0,
errors : 0
};
$('#topicstat-table tbody tr').each(function() {
results.total += Number($(':nth-child(8)', this).text());
results.not_started += Number($(':nth-child(7)', this).text());
results.errors += Number($(':nth-child(6)', this).text());
});
results.answered = results.total - results.not_started - results.errors;
return results;
}
this.results = calculate();
this.show = function()
{
alert(
'Всего вопросов: ' + this.results.total + '\n' +
'Не начато: ' + this.results.not_started + ' | ' + (this.results.not_started / this.results.total * 100).toFixed(1) + '%\n' +
'Ошибок: ' + this.results.errors + ' | ' + (this.results.errors / this.results.total * 100).toFixed(1) + '%\n' +
'Отвечено верно: ' + this.results.answered + ' | ' + (this.results.answered / this.results.total * 100).toFixed(1) + '%\n'
);
}
}
var results = new Results();
results.show();