Skip to content

Commit

Permalink
implement shuffle cards
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeker committed Feb 28, 2024
1 parent 61a077f commit 07399ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 2 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ def allDecks(username):
@app.route("/<username>/<deckTitle>")
def displayDeck(username, deckTitle):
if username == "guest":

# get the list of cards for the deck
currentDeck = db.decks.find_one({"title": deckTitle})
cardList = currentDeck['cards']

# TODO: shuffle cards

# shuffle deck
random.shuffle(cardList)
return render_template('card.html', deckTitle=deckTitle, username=username, cardList=cardList)
return "temp"

Expand Down
2 changes: 0 additions & 2 deletions templates/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ <h3 id="next-question"> START </h3>
const nextQuestion = document.querySelector("#next-question");
const card = document.querySelector("#card");
var cardIndex = 0;

var questions = '{{ cardList }}'
questions = questions.replaceAll("&#39;","\"")
var cardList = Array.from(JSON.parse(questions))
cardList.push("END OF DECK")

card.addEventListener("click", function() {
nextQuestion.textContent = cardList[cardIndex];
if (cardIndex < cardList.length-1) {
Expand Down

0 comments on commit 07399ab

Please sign in to comment.