-
Notifications
You must be signed in to change notification settings - Fork 0
/
join-course-code.html
90 lines (81 loc) · 3.03 KB
/
join-course-code.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v4.1.1">
<title>Join Autograder</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href="css/join-course.css" rel="stylesheet">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
input[type="text"]::placeholder {
text-align: left;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
</head>
<body class="text-center">
<form class="form-signin" id="generate-code-form">
<a href="./index.html"><img class="pt-2 mb-2 logo" src="img/logo-black.png" alt="autograder-logo" width="72" height="72"></a>
<h1 class="h3 mb-5 font-weight-bold text-white">Join a course!</h1>
<input type="text" id="code" class="mb-2 form-control" placeholder="Code" required>
<button class="mt-4 btn btn-lg btn-dark btn-block" type="submit">Join</button>
</form>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
const myForm = document.getElementById("generate-code-form");
myForm.addEventListener("submit", (e) => {
e.preventDefault();
const endPoint = "https://login.simplebar.dk/api/join";
const formData = new FormData();
formData.append("code", document.getElementById("code").value);
$.ajax(
{
url: endPoint,
type: "POST",
headers: {
Authorization: `Bearer ${sessionStorage.getItem("token")}`,
},
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (result) {
console.log("Join course API has been called successfully", result);
Swal.fire({
icon: "success",
title: `You have enrolled in the course or assignment successfully`,
text: `Please sign in with the credentials to access the course and assignment`,
}).then(() => {
window.location.replace("./student-dashboard.html");
});
},
error: function (result) {
console.log("Result", result);
},
},
"json"
);
});
</script>
</body>
</html>