Change calculation of the average column
This commit is contained in:
parent
ae840d00eb
commit
1780caacc3
@ -85,10 +85,10 @@ const UserDatailsComponent = (props) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const usersTalkTime = allUsersArr.map((currUser) => currUser.talk.totalTime);
|
const usersTalkTime = allUsersArr.map((currUser) => currUser.talk.totalTime);
|
||||||
const usersTotalOfMessages = allUsersArr.map((currUser) => currUser.totalOfMessages);
|
const usersMessages = allUsersArr.map((currUser) => currUser.totalOfMessages);
|
||||||
const usersEmojis = allUsersArr.map((currUser) => currUser.emojis.filter((emoji) => emoji.name !== 'raiseHand').length);
|
const usersEmojis = allUsersArr.map((currUser) => currUser.emojis.filter((emoji) => emoji.name !== 'raiseHand').length);
|
||||||
const usersRaiseHands = allUsersArr.map((currUser) => currUser.emojis.filter((emoji) => emoji.name === 'raiseHand').length);
|
const usersRaiseHands = allUsersArr.map((currUser) => currUser.emojis.filter((emoji) => emoji.name === 'raiseHand').length);
|
||||||
|
const usersAnswers = allUsersArr.map((currUser) => Object.values(currUser.answers || {}).length);
|
||||||
const totalPolls = Object.values(polls || {}).length;
|
const totalPolls = Object.values(polls || {}).length;
|
||||||
|
|
||||||
function getPointsOfTalk(u) {
|
function getPointsOfTalk(u) {
|
||||||
@ -100,7 +100,7 @@ const UserDatailsComponent = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPointsOfChatting(u) {
|
function getPointsOfChatting(u) {
|
||||||
const maxMessages = Math.max(...usersTotalOfMessages);
|
const maxMessages = Math.max(...usersMessages);
|
||||||
if (maxMessages > 0) {
|
if (maxMessages > 0) {
|
||||||
return (u.totalOfMessages / maxMessages) * 2;
|
return (u.totalOfMessages / maxMessages) * 2;
|
||||||
}
|
}
|
||||||
@ -132,24 +132,19 @@ const UserDatailsComponent = (props) => {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const talkTimeAverage = allUsersArr
|
const talkTimeAverage = usersTalkTime
|
||||||
.map((currUser) => getPointsOfTalk(currUser))
|
|
||||||
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
||||||
|
|
||||||
const messagesAverage = allUsersArr
|
const messagesAverage = usersMessages
|
||||||
.map((currUser) => getPointsOfChatting(currUser))
|
|
||||||
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
||||||
|
|
||||||
const emojisAverage = allUsersArr
|
const emojisAverage = usersEmojis
|
||||||
.map((currUser) => getPointsofEmoji(currUser))
|
|
||||||
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
||||||
|
|
||||||
const raiseHandsAverage = allUsersArr
|
const raiseHandsAverage = usersRaiseHands
|
||||||
.map((currUser) => getPointsOfRaiseHand(currUser))
|
|
||||||
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
||||||
|
|
||||||
const pollsAverage = allUsersArr
|
const pollsAverage = usersAnswers
|
||||||
.map((currUser) => getPointsOfPolls(currUser))
|
|
||||||
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
.reduce((prev, curr) => prev + curr, 0) / (allUsersArr.length || 1);
|
||||||
|
|
||||||
const activityPointsFunctions = {
|
const activityPointsFunctions = {
|
||||||
@ -238,9 +233,11 @@ const UserDatailsComponent = (props) => {
|
|||||||
<div className="min-w-[20%] text-ellipsis overflow-hidden">{category}</div>
|
<div className="min-w-[20%] text-ellipsis overflow-hidden">{category}</div>
|
||||||
<div className="min-w-[60%] grow text-center text-sm">
|
<div className="min-w-[60%] grow text-center text-sm">
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
{ average >= 0
|
{ (function () {
|
||||||
? <FormattedNumber value={average} minimumFractionDigits="0" maximumFractionDigits="1" />
|
if (average >= 0 && category === 'Talk Time') return tsToHHmmss(average);
|
||||||
: <FormattedMessage id="app.learningDashboard.usersTable.notAvailable" defaultMessage="N/A" /> }
|
if (average >= 0 && category !== 'Talk Time') return <FormattedNumber value={average} minimumFractionDigits="0" maximumFractionDigits="1" />;
|
||||||
|
return <FormattedMessage id="app.learningDashboard.usersTable.notAvailable" defaultMessage="N/A" />;
|
||||||
|
}()) }
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded-2xl bg-gray-200 before:bg-gray-500 h-4 relative before:absolute before:top-[-50%] before:bottom-[-50%] before:w-[2px] before:left-[calc(50%-1px)] before:z-10">
|
<div className="rounded-2xl bg-gray-200 before:bg-gray-500 h-4 relative before:absolute before:top-[-50%] before:bottom-[-50%] before:w-[2px] before:left-[calc(50%-1px)] before:z-10">
|
||||||
<div
|
<div
|
||||||
|
Loading…
Reference in New Issue
Block a user