-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.html
208 lines (179 loc) · 9.79 KB
/
tester.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title></title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Alata&display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Alatsi&display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Allerta&display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Andika+New+Basic&display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Atkinson+Hyperlegible&display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Barlow&display=swap">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,300,600,800,900" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="assets/fonts/fontawesome-all.min.css">
<link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/styles.css">
<script src="assets/js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready( function () {
$('#loadingModal').modal('toggle');
var first_name = localStorage.getItem('first_name');
var course_id = localStorage.getItem('course_id');
var username = localStorage.getItem('username');
if (first_name == null||course_id == null||username == null) {
localStorage.clear();
sessionStorage.clear();
window.location.replace('login.html');
}
var quiz_id_selection = "";
$(document).on('click', '.qtype_menu_item', function(e) {
$("#qtype_menu").find(".qtype_menu_item").removeClass("active");
$(this).addClass("active");
quiz_id_selection = $(this).attr('id');
$("#qtype_text").html($(this).html());
});
$('#submit_button').on('click', function(e){
$("#modal_message").html('Are you sure you want to attempt the quiz with ID "'+quiz_id_selection+'" ?');
$('#confirmModal').modal('toggle');
});
$('#confirm_button').on('click', function(e){
localStorage.setItem('quiz_ID', quiz_id_selection);
window.location.href = 'quiz_test.html';
});
async function get_quizid() {
const endpoint = '/data-api/rest/QuestionList';
const response = await fetch(endpoint);
const data = await response.json();
var prev = "";
if (data.value == '') {
$("#qtype_text").html("No quizzes available.");
} else {
for (var i = 0; i < data.value.length; i++) {
if (data.value[i].quiz_id == prev) {
prev = data.value[i].quiz_id;
} else {
if (i == 0){
quiz_id_selection = data.value[i].quiz_id;
$("#qtype_text").html(data.value[i].quiz_id);
$("#qtype_menu").append('<li><a class="dropdown-item active qtype_menu_item" id="'+data.value[i].quiz_id+'">'+data.value[i].quiz_id+'</a></li>');
} else {
$("#qtype_menu").append('<li><a class="dropdown-item qtype_menu_item" id="'+data.value[i].quiz_id+'">'+data.value[i].quiz_id+'</a></li>');
}
prev = data.value[i].quiz_id;
}
}
$("#dropdownMenuButton1").prop('disabled', false);
$("#submit_button").prop('disabled', false);
}
setTimeout(()=> {
$('#loadingModal').modal('toggle');
},500);
}
get_quizid();
$('a.logout').on('click', function(e){
localStorage.clear();
window.location.replace('login.html');
});
} );
</script>
</head>
<body style="background: white; background-size: cover; ">
<div class="modal fade" id="loadingModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" data-bs-keyboard="false" data-bs-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content" style="margin: auto; width: auto; height: auto; border-radius: 0; border:0;">
<div class="modal-body">
<img src="assets/images/loading.gif" style="height: 4rem;">
</div>
</div>
</div>
</div>
<div class="modal fade" id="confirmModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content" style="border-radius: 0px; border:0;">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel" style="font-size: 1.3rem; color:rgb(0,0,0); font-weight: 700; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif; padding-top: 3px; padding-bottom: 3px; padding-left: 8px;"> Quiz Confirmation</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" style="padding-top: 3px; padding-bottom: 3px; padding-right: 20px;"></button>
</div>
<div id="modal_message" class="modal-body" style="font-size: 0.95rem; font-weight: 100; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif;padding-left: 24px; color:#5b595f;">
</div>
<div class="modal-footer">
<button type="button" class="btn ps-4 pe-4 pt-2 pb-2" data-bs-dismiss="modal" id="confirm_button" style="background-color:#b32b76; color: white; font-weight: lighter; font-family: 'Trebuchet MS', sans-serif; font-size: 0.92rem; border-radius: 0px;">Yes</button>
</div>
</div>
</div>
</div>
<div class="row" style="border-bottom: 1px solid #cfcfcf; background: white; padding-top: 2px; padding-bottom: 3px;">
<div class="col" style="margin-top: auto; margin-bottom: auto; margin-left: 15px;">
<img src="assets/images/nottingham-university-logo.jpeg" alt="University of Nottingham" style="height: 3.5rem;">
</div>
<div class="col-auto" style="margin-top: auto; margin-bottom: auto;">
<i class="far fa-bell" style="color:#a5a5a5; font-size: 1rem;"></i>
</div>
<div class="col-auto" style="margin-top: auto; margin-bottom: auto;">
<i class="far fa-comment" style="color:#a5a5a5; font-size: 1rem;"></i>
</div>
<div class="col-auto" style="text-align: right; margin-top: auto; margin-bottom: auto;">
<i class="fas fa-user-circle" style="color:#792d85; font-size: 2.2rem;"></i>
</div>
<div class="col-auto" style="margin-top: auto; margin-bottom: auto; margin-right: 25px; margin-left: -15px">
<i class="fas fa-chevron-down" role="button" data-bs-toggle="dropdown" aria-expanded="false" style="color:black; font-size: 0.6rem; cursor: pointer;" id="logout_arrow"></i>
<ul class="dropdown-menu" aria-labelledby="logout_arrow" style="font-size: 1rem; line-height: 25px; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif; border-radius: 0px;">
<li><a class="dropdown-item logout">Log out</a></li>
</ul>
</div>
</div>
<div class="row ms-4 me-4 mt-3 mb-2">
<div class="card" style="height: auto; border: 1px solid #cfcfcf; border-radius: 0px;">
<div class="row ms-2 mt-3 me-2 mb-0">
<div class="col-auto p-0">
<span class="fa-stack fa-2x">
<i class="fas fa-square-full fa-stack-1x" style="color:rgba(255, 95, 31,1); font-size: 3.3rem;"></i>
<i class="fas fa-clipboard-check fa-stack-1x" style="color:rgba(255,255,255,1); font-size: 1.4rem;"></i>
</span>
</div>
<div class="col">
<div class=""><span style="font-size: 2.3rem; color:rgb(0,0,0); font-weight: 700; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif;">Quiz Tester<span></div>
</div>
</div>
<div class="row ms-2 mt-2 me-2 mb-4">
<div class="col">
<div class=""><span style="font-size: 0.92rem; color:#1568ac; font-weight: 500; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif; cursor: pointer;" onclick="location.href = 'dashboard.html';"><u>Dashboard</u></span><span style="font-size: 0.92rem; color:#5b595f; font-weight: 500;"> > Quiz Tester</span></div>
</div>
</div>
</div>
</div>
<div class="row ms-4 me-4 mt-3 mb-2">
<div class="card pb-4" style="height: auto; border: 1px solid #cfcfcf; border-radius: 0px;">
<div class="row ms-2 mt-4 me-2 mb-2">
<div class="col">
<div class=""><span style="font-size: 0.95rem; color:rgb(0,0,0); font-weight: 500; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif;">Select a quiz to attempt.<span></div>
</div>
</div>
<div class="row ms-2 mt-1 me-2">
<div class="col">
<div class="dropdown">
<button class="btn dropdown-toggle" type="button" disabled id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false" style="width: 100%; text-align: right; font-size: 0.9rem; border: 1px solid #bbbbbb; border-radius: 0px;">
<span style="float:left; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif; font-weight: 100;" id="qtype_text"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1" style="width: 100%; font-size: 0.9rem; line-height: 30px; font-family: 'Trebuchet MS', Arial, Verdana, Helvetica, sans-serif; font-weight: 100; border-radius: 0px;" id="qtype_menu">
<li><h6 class="dropdown-header mb-1">Available Quizzes</h6></li>
</ul>
</div>
</div>
</div>
<div id="question_list">
</div>
<hr style="color: #bbbbbb;">
<div class="row ms-2 mt-1 me-2">
<div class="col-auto" style="margin: auto;">
<button type="button" disabled class="btn ps-4 pe-4 pt-2 pb-2" type="button" style="background-color:#b32b76; color: white; font-weight: lighter; font-family: 'Trebuchet MS', sans-serif; font-size: 0.92rem; border-radius: 0px;" id="submit_button">Attempt Quiz</button>
</div>
</div>
</div>
</div>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>