Skip to content

Commit

Permalink
Load user quizzes
Browse files Browse the repository at this point in the history
  • Loading branch information
neves-gabriel committed Nov 23, 2021
1 parent 7ad8025 commit 45daa4e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions js/homescreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ function renderQuizzPreview (response) {

userQuizzes = JSON.parse(localStorage.getItem("id"));
console.log(userQuizzes);
if (userQuizzes != []) {
if (userQuizzes != null) {
userQuizContainer.innerHTML = "";
showScreen(`list-title-container`);
}

for(let i=0; i< allQuizzes.length; i++){
for(let i=0; i< allQuizzes.length; i++){
if (userQuizzes.includes(allQuizzes[i].id)) {
userQuizContainer.innerHTML += `<li class="quiz-preview" style="background-image: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.5) 64.58%, #000000 100%), url(${allQuizzes[i].image});"
onclick="openQuiz(${allQuizzes[i].id})">
Expand All @@ -37,8 +35,15 @@ function renderQuizzPreview (response) {
<p>${allQuizzes[i].title}</p>
</li>`;
}
}

}
} else {
for(let i=0; i< allQuizzes.length; i++){
quizContainer.innerHTML += `<li class="quiz-preview" style="background-image: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.5) 64.58%, #000000 100%), url(${allQuizzes[i].image});"
onclick="openQuiz(${allQuizzes[i].id})">
<p>${allQuizzes[i].title}</p>
</li>`;
}
}
}

function toggleHidden (element) {
Expand Down

0 comments on commit 45daa4e

Please sign in to comment.