-
Notifications
You must be signed in to change notification settings - Fork 0
/
iAttendance-student.js
44 lines (34 loc) · 1.17 KB
/
iAttendance-student.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
firebase.database().ref('Question of the day/').on("value",function(snapshot){
//Returns the obj
var snap = snapshot.val();
document.getElementById("stuQuestion").innerHTML = snap.question;
});
//Prof redirect page
$('#prof').on('click', function(e) {
var password = prompt("PLEASE ENTER PASSWORD: ");
if(password=="prof"){
window.location.href="iAttendance-tutor.html";
}else{
alert("Incorrect Password");
}
});
//Submit the students answer
$('#submitBtnstudent').on('click', function(e) {
var noteContent = document.getElementById("studentNote").value;
var d=new Date;
console.log(d.getHours());
//Check if student is inputting during class time
if((d.getHours()>8)&&(d.getHours()<10)){
//month to plus 1 cus starts from 0
var tdydate = (d.getDate()*100)+d.getMonth()+1;
var metric = document.getElementById("studentMatric").value.toLowerCase();
firebase.database().ref('Past Questions/').push({
answer:noteContent,
date:tdydate,
metricNo:metric
});
}
else{
alert("SORRY YOU HAVE MISSED YOUR CLASS TIME WINDOW! DONT BE LATE NEXT TIME!");
}
});