Ejemplo n.º 1
0
def set_difficulty(difficulty=None):
    if difficulty is None:
        difficulty = question.Difficulties.index(database.fetch_user_difficulty(session["userId"]))
        return render_template("change_difficulty.html", difficulty=difficulty)

    if difficulty.upper() in question.Difficulties:
        session["difficulty"] = difficulty.upper()
        return redirect("/")
    else:
        return "unknown difficulty"
Ejemplo n.º 2
0
def profile(user_id):
    return render_template(
        "profile.html",
        username=database.fetch_user_name(user_id),
        difficulty=database.fetch_user_difficulty(user_id),
        startedDate=database.fetch_user_joined_date(user_id),
        gamesPlayed=database.fetch_user_games_started(user_id),
        gamesCompleted=database.fetch_user_games_completed(user_id),
        easyScore=database.fetch_user_score(user_id, question.Difficulties.EASY),
    )
Ejemplo n.º 3
0
def index():
    session["quizId"] = -1

    # if the user has not given us a username we should probably ask for one
    return render_template(
        "index.html",
        username=session["username"],
        userId=session["userId"],
        current_difficulty=session["difficulty"].title(),
        actual_difficulty=database.fetch_user_difficulty(session["userId"]).title(),
        rank=database.fetch_user_rank(session["userId"], session["difficulty"]),
        total_users=database.fetch_number_users(),
    )