-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.js
More file actions
48 lines (42 loc) · 1.14 KB
/
Copy pathdatabase.js
File metadata and controls
48 lines (42 loc) · 1.14 KB
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
45
46
47
48
const supabase = window.supabase;
// Verify student by login code
export async function verifyStudent(loginCode) {
let { data, error } = await supabase
.from('students')
.select('*')
.eq('login_code', loginCode)
.single();
if (error) {
console.error('Login failed:', error);
return null;
}
return data;
}
export async function getTestQuestions() {
let { data, error } = await supabase.from('tests').select('*');
if (error) {
console.error('Error fetching questions:', error);
return [];
}
return data;
}
// Fetch all students
export async function getStudents() {
const { data, error } = await supabase.from('students').select('*');
if (error) {
console.error('Error fetching students:', error);
return null;
}
return data;
}
// Add a new student
export async function addStudent(name, surname, code) {
const { data, error } = await supabase.from('students').insert([
{ name, surname, code }
]);
if (error) {
console.error('Error adding student:', error);
return null;
}
return data;
}