-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-course-code.html
115 lines (91 loc) · 4.05 KB
/
get-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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!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/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href="css/join-course.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.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;
}
@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="./teacher-dashboard.html"><img class="pt-1 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-dark">Get Course Code</h1>
<h2 class="h4 mb-3 font-weight-normal">Click Generate button to get the code</h2>
<p class="mb-4"> Give the Course ID , number of students along with Assignment ID (optional)</p>
<div class="form-group">
<input type="text" id="inputLimit" class="mb-3 form-control select2" placeholder="Number of Students" required autofocus>
<div class="mb-3">
<select id="inputCourseID" class="form-control" required>
<option disabled="" selected="">Choose a course</option>
</select>
</div>
<div class="mb-3 mt-3">
<select id="inputAssignmentID" class="form-control select2"></select>
</div>
</div>
<button class="mt-4 mb-5 btn btn-lg btn-success btn-block" type="submit">Generate</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://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.full.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="js/get-course-code.js"></script>
<script>
config = {
method: "get",
url: `https://course.simplebar.dk/api/me`,
headers: {
Authorization: `Bearer ${sessionStorage.getItem("token")}`,
},
};
axios(config)
.then(function (response) {
let courses = [];
let assignments = [];
$.each(response['data']['courses'], function( index, course ) {
$.each(course['assignments'], function( index, assignment ) {
assignments.push({'course_id': course['id'], 'id': assignment['id'], 'text': assignment['title']});
});
courses.push({'id': course['id'], 'text': course['title']});
});
$('#inputCourseID').select2({
data: courses
});
$('#inputCourseID').on('select2:select', function (e) {
let course_id = $('#inputCourseID').val();
filtered_assignments = [];
filtered_assignments = $.grep(assignments, function( assignment ) {
return (assignment['course_id'] == course_id);
});
filtered_assignments.push({'id': 0, 'text': 'No Assignment'});
$('#inputAssignmentID').select2();
$('#inputAssignmentID').select2('destroy').empty().select2({
data: filtered_assignments
});
});
});
</script>
</body>
</html>