Skip to content

Commit

Permalink
On quiz lock screen, dependent quiz name displays instead of ID
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanpscott committed Aug 9, 2024
1 parent f4b32d2 commit 2b71e91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/routes/quiz/[collection]/[id]/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export async function load({ params, fetch }) {
const id = params.id;
const collection = params.collection;

const book = config.bookCollections.find((x) => x.id === collection).books.find((x) => x.id === id);
const bookCollection = config.bookCollections.find((x) => x.id === collection);
const book = bookCollection.books.find((x) => x.id === id);

let locked = false;
let dependentQuizId = null;
Expand All @@ -17,6 +18,10 @@ export async function load({ params, fetch }) {
const accessGranted = await checkQuizAccess(dependentQuizId);
locked = !accessGranted;
}
if (locked) {
const dependentBook = bookCollection.books.find((x) => x.id === dependentQuizId);
dependentQuizName = dependentBook ? dependentBook.name : dependentQuizId;
}

if (!locked) {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/quiz/[collection]/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@
<div class="quiz-locked">
<div class="quiz-locked-title">{data.quizId}</div>
<div class="quiz-locked-message">
Before accessing this quiz, you need to pass the following quizzes:
Before accessing this quiz, you need to pass the following quiz:
</div>
<div class="quiz-locked-name">{dependentQuizId}</div>
<div class="quiz-locked-name">{data.dependentQuizName || data.dependentQuizId}</div>
</div>
{:else if questionNum == quizQuestions.length}
<div class="score">
Expand Down

0 comments on commit 2b71e91

Please sign in to comment.