-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add route to launch session on student computers with bit.ly link
<!--- Please write your PR name in the present imperative tense. Examples of that tense are: "Fix issue in the dispatcher where…", "Improve our handling of…", etc." --> <!-- For more information on Pull Requests, you can reference here: https://success.vanillaforums.com/kb/articles/228-using-pull-requests-to-contribute --> ## Describe Your Changes - Add route '/games/sessions' that matches available bit.ly link (bit.ly/blueredgame) - Adjust template to accept session id from instructor - Use js to manage redirects including older one; previously we used the standard form with query strings. ## Non-Obvious Technical Information ## Checklist Before Requesting a Review - [x] The code runs successfully. ```commandline 2023-12-26 12:58:24 INFO: Application startup complete. 2023-12-26 12:58:31 INFO: 172.25.0.1:40658 - "GET /games/sessions HTTP/1.1" 200 OK 2023-12-26 12:59:36 INFO: 172.25.0.1:53164 - "GET /games/session/4/ HTTP/1.1" 307 Temporary Redirect 2023-12-26 12:59:36 INFO: 172.25.0.1:53164 - "GET /games/session/4 HTTP/1.1" 200 OK 2023-12-26 12:59:38 INFO: 172.25.0.1:53164 - "GET /games/10/player/59/ready HTTP/1.1" 200 OK ```
- Loading branch information
Showing
2 changed files
with
68 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,65 @@ | ||
{% extends "base.html" %} | ||
{% block helper_script %} | ||
<script> | ||
function redirectToChoosePlayers() { | ||
// Get the session ID from the input field | ||
const sessionId = document.getElementById("session_id").value; | ||
|
||
// Construct the URL with the session ID | ||
const url = "/games/session/" + sessionId + "/"; | ||
|
||
// Redirect to the generated URL | ||
window.location.href = url; | ||
} | ||
|
||
function redirectToSession() { | ||
// Get the session ID from the input field | ||
const playerId = document.getElementById("player_id").value; | ||
const gameId = document.getElementById("game_id").value; | ||
|
||
// Construct the URL with the session ID | ||
const url = "/games/" + gameId + "/player/" + playerId + "/ready"; | ||
|
||
// Redirect to the generated URL | ||
window.location.href = url; | ||
} | ||
|
||
</script> | ||
{% endblock helper_script %} | ||
{% block title %} | ||
PrijateliTree - Access Session | ||
{% endblock title %} | ||
{% block content %} | ||
<div class="container-sm flex-container"> | ||
<h1>Welcome.</h1> | ||
<h2>Select the name of the student who will sit at this desk.</h2> | ||
<div class="col-sm-4"> | ||
<form method="get" action='{{ url_for("start_session", game_id=game_id) }}'> | ||
<!--<label for="num-games" class="col-sm-4 col-form-label"></label>--> | ||
<select id="player_id" class="form-select form-select-sm" name="player_id"> | ||
{% for p in players %}<option value="{{ p.id }}">{{ p.user.name_str }}</option>{% endfor %} | ||
</select> | ||
<button type="submit" class="btn btn-primary float-end">Start</button> | ||
</form> | ||
</div> | ||
{% if session_id == -1 %} | ||
<p>Enter the session id.</p> | ||
<div class="col-sm-4"> | ||
<form> | ||
<input type="text" id="session_id" name="session_id"> | ||
<br> | ||
<br> | ||
<button type="button" | ||
onclick="redirectToChoosePlayers()" | ||
class="btn btn-primary float-start">Next</button> | ||
</form> | ||
</div> | ||
{% else %} | ||
<p>Select the name of the student who will sit at this desk.</p> | ||
<div class="col-sm-4"> | ||
<form> | ||
<input type="text" id="game_id" value={{ game_id }} hidden> | ||
<select id="player_id" class="form-select form-select-sm" name="player_id"> | ||
{% for p in players %}<option value="{{ p.id }}">{{ p.user.name_str }}</option>{% endfor %} | ||
</select> | ||
<br> | ||
<br> | ||
<!--<button type="submit" class="btn btn-primary float-start">Start</button>--> | ||
<button type="button" | ||
onclick="redirectToSession()" | ||
class="btn btn-primary float-start">Start</button> | ||
</form> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock content %} |