Ensure raw mark displays properly for tests

This commit is contained in:
2021-09-11 10:45:09 +01:00
parent 62552cde42
commit c0cdf197c5
2 changed files with 17 additions and 22 deletions

View File

@@ -48,27 +48,21 @@ export default class History extends Component {
querySnapshot.docs.map((doc) => { querySnapshot.docs.map((doc) => {
const data = doc.data(); const data = doc.data();
const pushData = {
id: doc.id,
setTitle: data.set_title,
switchLanguage: data.switch_language,
percentage: (data.progress / data.questions.length * 100).toFixed(2),
mark: (data.progress > 0 ? data.correct.length / data.progress * 100 : 0).toFixed(2),
mode: data.mode,
correct: data.correct.length,
progress: data.progress,
};
if (data.duration !== null) { if (data.duration !== null) {
return complete.push({ return complete.push(pushData);
id: doc.id,
setTitle: data.set_title,
switchLanguage: data.switch_language,
progress: (data.progress / data.questions.length * 100).toFixed(2),
mark: (data.progress > 0 ? data.correct.length / data.progress * 100 : 0).toFixed(2),
mode: data.mode,
correct: data.correct.length,
});
} else { } else {
return incomplete.push({ return incomplete.push(pushData);
id: doc.id,
setTitle: data.set_title,
switchLanguage: data.switch_language,
progress: (data.progress / data.questions.length * 100).toFixed(2),
mark: (data.progress > 0 ? data.correct.length / data.progress * 100 : 0).toFixed(2),
mode: data.mode,
correct: data.correct.length,
});
} }
}); });
@@ -133,7 +127,7 @@ export default class History extends Component {
<SwapHorizRoundedIcon /> <SwapHorizRoundedIcon />
} }
</Link> </Link>
<p>{progressItem.progress}%</p> <p>{progressItem.percentage}%</p>
<p>{progressItem.correct}/{progressItem.progress}</p> <p>{progressItem.correct}/{progressItem.progress}</p>
<p>{progressItem.mark}%</p> <p>{progressItem.mark}%</p>
<p> <p>
@@ -177,7 +171,7 @@ export default class History extends Component {
<SwapHorizRoundedIcon /> <SwapHorizRoundedIcon />
} }
</Link> </Link>
<p>{progressItem.progress}%</p> <p>{progressItem.percentage}%</p>
<p>{progressItem.correct}/{progressItem.progress}</p> <p>{progressItem.correct}/{progressItem.progress}</p>
<p>{progressItem.mark}%</p> <p>{progressItem.mark}%</p>
{ {

View File

@@ -145,10 +145,11 @@ export default withRouter(class LoggedInHome extends React.Component {
id: doc.id, id: doc.id,
setTitle: data.set_title, setTitle: data.set_title,
switchLanguage: data.switch_language, switchLanguage: data.switch_language,
progress: (data.progress / data.questions.length * 100).toFixed(2), percentage: (data.progress / data.questions.length * 100).toFixed(2),
mark: (data.progress > 0 ? data.correct.length / data.progress * 100 : 0).toFixed(2), mark: (data.progress > 0 ? data.correct.length / data.progress * 100 : 0).toFixed(2),
mode: data.mode, mode: data.mode,
correct: data.correct.length, correct: data.correct.length,
progress: data.progress,
}); });
}) })
}) })
@@ -281,7 +282,7 @@ export default withRouter(class LoggedInHome extends React.Component {
<SwapHorizRoundedIcon /> <SwapHorizRoundedIcon />
} }
</Link> </Link>
<p>{progressItem.progress}%</p> <p>{progressItem.percentage}%</p>
<p>{progressItem.correct}/{progressItem.progress}</p> <p>{progressItem.correct}/{progressItem.progress}</p>
<p>{progressItem.mark}%</p> <p>{progressItem.mark}%</p>
<p> <p>