Updated Teacher Dashboard

This commit is contained in:
SowinskiBraeden committed 2020-11-27 10:26:03 -08:00
1 parent 601e886c14
commit 867770e14e
1 file changed
+67 -53
+67 -53
View File
@@ -1,6 +1,7 @@
<style> <style>
.members { .members {
width: 230px; width: 230px;
display: inline-block;
} }
h2 { h2 {
@@ -47,65 +48,78 @@
<br> <br>
<a href="/users/logout" class="btn btn-secondary">Logout</a> <a href="/users/logout" class="btn btn-secondary">Logout</a>
<br> <br>
<h2>Site Members</h2> <div>
<div class='members'> <script>
<ul> let xp;
<% members.forEach(function (member) { %> let currRank;
<li><button class='btn btn-link mt-2' onclick='openProfile("<%= member.id %>")'><%= member.name %></button></li> let ranks = [
<div style='display: none;' data-role='page' id='<%= member._id %>'> {"Digital Noob": 0}, // index 0
<p class="lead mb-3"><%= member.name %></p> {"Digital Novice": 48}, // index 1
<p class='lead mb-3'><%= member.email %></p> {"Digital Novice II": 100}, // index 2
<br> {"Digital Amature": 148}, // index 3
<div> {"Digital Amature II": 200}, // index 4
<p id='userRank'></p> {"Digital Apprentice": 248}, // index 5
<p>XP: <%= member.xp %></p> {"Digital Apprentice II": 300}, // index 6
<p><%= member.role %></p> {"Digital Journeyman": 396}, // index 7
</div> {"Digital Journeyman II": 476}, // index 8
<br> {"Digital Journeyman III": 532}, // index 9
<script> {"Digital Crafter": 580}, // index 10
let xp = <%= member.xp %>; {"Expert Digital Crafter": 648}, // index 11
let currRank; {"Master Digital Crafter": 800} // index 12
]
let indexes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12]
console.log("Students Shouldnt be here");
</script>
<h2>Site Members</h2>
<div class='members'>
<ul>
<% members.forEach(function (member) { %>
<% if (member.role == "Student") { %>
<li><button class='btn btn-link mt-2' onclick='openProfile("<%= member.id %>")'><%= member.name %></button></li>
<div style='display: none;' data-role='page' id='<%= member._id %>'>
<p class="lead mb-3"><%= member.name %></p>
<p class='lead mb-3'><%= member.email %></p>
<br>
<div>
<p id='userRank-<%= member.id %>'></p>
<p>XP: <%= member.xp %></p>
<p><%= member.role %></p>
</div>
<br>
<script>
xp = <%= member.xp %>;
let ranks = [ // Get current rank
{"Digital Noob": 0}, // index 0 if (xp == 0) {
{"Digital Novice": 48}, // index 1 currRank = 'Digital Noob';
{"Digital Novice II": 100}, // index 2 } else {
{"Digital Amature": 148}, // index 3 if (xp < 800 && xp > 0) {
{"Digital Amature II": 200}, // index 4 for(var i = 0; i < ranks.length; i++) {
{"Digital Apprentice": 248}, // index 5 for (let rank in ranks[i]) {
{"Digital Apprentice II": 300}, // index 6 let nextIndex = indexes[i];
{"Digital Journeyman": 396}, // index 7 for (let nextRank in ranks[nextIndex]) {
{"Digital Journeyman II": 476}, // index 8 if (xp >= ranks[i][rank] && xp < ranks[nextIndex][nextRank]) {
{"Digital Journeyman III": 532}, // index 9 currRank = rank;
{"Digital Crafter": 580}, // index 10 }
{"Expert Digital Crafter": 648}, // index 11 }
{"Master Digital Crafter": 800} // index 12 }
] }
} else {
// Get current rank if (xp == 800) {
let indexes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12] currRank = "Master Digital Crafter";
if (xp < 800) {
for(var i = 0; i < ranks.length; i++) {
for (let rank in ranks[i]) {
let nextIndex = indexes[i];
for (let nextRank in ranks[nextIndex]) {
if (xp >= ranks[i][rank] && xp < ranks[nextIndex][nextRank]) {
currRank = rank;
} }
} }
} }
}
} else {
currRank = "Master Digital Crafter";
}
//Show Data //Show Data
document.getElementById('userRank').innerHTML = currRank; document.getElementById('userRank-<%= member.id %>').innerHTML = currRank;
</script> </script>
</div> </div>
<% }) %> <% } %>
</ul> <% }) %>
</ul>
</div>
</div> </div>
<script> <script>
function openProfile(id) { function openProfile(id) {