Update
This commit is contained in:
1 parent
4f15788983
commit
eaabb7cc65
36 files changed
+2116
-80
No files matched your search
+158
-14
@@ -7,8 +7,10 @@
|
||||
.head {
|
||||
margin-bottom: 100px;
|
||||
}
|
||||
#teacher-container {
|
||||
position: relative;
|
||||
.teacher-container {
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
left: 205px;
|
||||
}
|
||||
#pro-pic {
|
||||
position: absolute;
|
||||
@@ -31,15 +33,26 @@
|
||||
border: 1px solid black;
|
||||
margin:5px;
|
||||
}
|
||||
#logout-btn {
|
||||
.buttons-container {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
width: 151px;
|
||||
height: 500px;
|
||||
top: 25px;
|
||||
right: 25px;
|
||||
border: solid #5b94f0 2px;
|
||||
border-style: solid;
|
||||
border-radius: 10px;
|
||||
background-color: rgba(112, 196, 255, .3);
|
||||
}
|
||||
#edit-btn {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 85px;
|
||||
width: 95px;
|
||||
margin-left: 28px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
#logout-btn {
|
||||
width: 95px;
|
||||
margin-left: 28px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
#welcome {
|
||||
position: absolute;
|
||||
@@ -83,17 +96,19 @@
|
||||
<!-- Welcome Message & Profile Picture -->
|
||||
<h1 class="mt-4">Teacher Dashboard</h1>
|
||||
<div class='head'>
|
||||
<div id='teacher-container'>
|
||||
<div>
|
||||
<div>
|
||||
<div class="teacher-container">
|
||||
<p id='welcome' class="lead mb-3">Welcome <%= user.name %></p>
|
||||
<img id='pro-pic' src='data:image/<%=user.image.contentType%>;base64,
|
||||
<%=user.image.data.toString('base64')%>'>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<a id='logout-btn' href="/users/logout" class="btn btn-secondary">Logout</a>
|
||||
<button id='edit-btn' onClick='passData()' class='btn btn-secondary'>Edit</button>
|
||||
<div class="buttons-container">
|
||||
<!-- Action Buttons -->
|
||||
<a id='logout-btn' href="/users/logout" class="btn btn-info">Logout</a>
|
||||
<button id='edit-btn' onClick='passData()' class='btn btn-info'>Edit</button>
|
||||
</div>
|
||||
|
||||
<!-- Passing user _id to edit page script -->
|
||||
<script>
|
||||
@@ -133,8 +148,131 @@
|
||||
console.log("Students Shouldnt be here");
|
||||
</script>
|
||||
|
||||
<!-- Alert container -->
|
||||
<div id='div-container'></div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel"</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="/users/addXP" method="POST">
|
||||
<div>
|
||||
<input id='_id_add' type='text' name='_id_add' value='' style='display: none'></input>
|
||||
<input id="current_xp" type="text" name="current_xp" value="" style="display: none"></input>
|
||||
</div>
|
||||
<div>
|
||||
<p>Minimum: 1</p>
|
||||
<p>Maximum: 50</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="amount">Amount</label>
|
||||
<input
|
||||
id="amount"
|
||||
name="amount"
|
||||
type="number"
|
||||
min="1"
|
||||
max="50"
|
||||
value=""
|
||||
class="form-control"
|
||||
>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Add XP
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Creates unique ID
|
||||
function makeid(length) {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Create Div
|
||||
function createDiv(type, message) {
|
||||
let id = makeid(8);
|
||||
|
||||
if (type == 'error') {
|
||||
document.getElementById('div-container').innerHTML += '<div id="new-div-'+id+'" style="display: none;" class="alert alert-warning alert-dismissible fade show" role="alert">';
|
||||
}
|
||||
if (type == 'message') {
|
||||
document.getElementById('div-container').innerHTML += '<div id="new-div-'+id+'" style="display: none;" class="alert alert-info alert-dismissible fade show" role="alert">';
|
||||
}
|
||||
document.getElementById('new-div-'+id).innerHTML += '<div id="message'+id+'">'+message+'</div>';
|
||||
document.getElementById('new-div-'+id).innerHTML += '<button id="close-btn-'+id+'" class="close" data-dismiss="alert" aria-label="Close"></button>';
|
||||
document.getElementById('close-btn-'+id).innerHTML += '<span aria-hidden="true">×</span>';
|
||||
document.getElementById('new-div-'+id).style.display = "block";
|
||||
}
|
||||
|
||||
// // Check amount
|
||||
// function amountCheck(_id) {
|
||||
// const amount = document.getElementById("amount").value;
|
||||
// if (amount > 50) {
|
||||
// createDiv('error', "Can't add more than 50 XP");
|
||||
// }
|
||||
// if (amount == 0 || amount < 0) {
|
||||
// createDiv('error', "XP Must be more than 0");
|
||||
// }
|
||||
//
|
||||
// if (amount > 0 && amount < 50) {
|
||||
//
|
||||
// createDiv('message', "Succesfully added XP");
|
||||
// }
|
||||
// }
|
||||
|
||||
// Pass name to Modal
|
||||
function passName(name, xp, member_id) {
|
||||
if (xp < 800) {
|
||||
document.getElementById("exampleModalLabel").innerHTML = "Give " + name + " XP";
|
||||
document.getElementById("_id_add").value = member_id;
|
||||
document.getElementById("current_xp").value = xp;
|
||||
$("#exampleModal").modal()
|
||||
}
|
||||
if (xp >= 800) {
|
||||
// Construct and show Max XP Alert
|
||||
message = name + ' has reached max XP!';
|
||||
createDiv('message', message);
|
||||
}
|
||||
}
|
||||
|
||||
// Catching url Parameters
|
||||
window.onload = function () {
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const successRate = urlParams.get('successRate')
|
||||
if(successRate == 'addXP > 50') {
|
||||
createDiv('error', "Can't add more than 50 XP")
|
||||
}
|
||||
if(successRate == 'addXP <= 0') {
|
||||
createDiv('error', "XP Must be Greater than 0");
|
||||
}
|
||||
if(parseInt(successRate) > 0 && parseInt(successRate) < 50 || parseInt(successRate) == 50) {
|
||||
createDiv('message', "Gave " + successRate + "XP to a Student");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- List of all site students (not teachers) -->
|
||||
<h2>Site Members</h2>
|
||||
<h2>Studen Members</h2>
|
||||
<div class='members'>
|
||||
<ul>
|
||||
<!-- Loops through all members -->
|
||||
@@ -153,6 +291,12 @@
|
||||
<div>
|
||||
<p id='userRank-<%= member.id %>'></p>
|
||||
<p>XP: <%= member.xp %></p>
|
||||
|
||||
<!-- Button trigger modal -->
|
||||
<button onClick='passName("<%= member.name %>", <%= member.xp %>, "<%= member._id %>")' type="button" class="btn btn-outline-info btn-sm">
|
||||
Add XP
|
||||
</button>
|
||||
|
||||
<p><%= member.role %></p>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
Reference in new issue
Block a user