-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
453 lines (398 loc) · 18.2 KB
/
index.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Daily Quiz</title>
<link rel="stylesheet" href="dailyquizz.css" />
</head>
<body>
<div class="container">
<div class="quiz-header">
<h1 class="quiz-title">Daily Trading Quiz</h1>
<p class="quiz-streak">
🔥<span class="streak-value" id="streak">0</span>
</p>
<button id="start-quiz-button">Start Quiz</button>
</div>
<div class="quiz-content">
<div class="question-container">
<span>Question:
<p class="question-text" id="question-text" style="display: none;"></p>
</span>
</div>
<form class="answer-form" id="answer-form" style="display: none;">
<label for="answer">Select your answer:</label> <select id="answer"
class="answer-select" required>
<option value="" disabled>Select an option</option>
<option value="" disabled>Select an option</option>
<option value="" disabled>Select an option</option>
<option value="" disabled>Select an option</option>
</select>
<button type="submit" class="submit-button" id="submit-button"
style="display: none;">Submit</button>
</form>
</div>
<div class="quiz-footer">
<p class="already-answered" id="already-answered"></p>
<p class="timer" id="timer"></p>
<h1 class="submit-msg" id="submit-msg"></h1>
<ol>
<h2>Trading Rules</h2>
<li class="quiz-info"><strong>Test Timing:</strong> You have a
total of 1 minute to complete the quiz.</li>
<li class="quiz-info"><strong>Entering Full Screen:</strong> To
begin the quiz, click the "Start Quiz" button. Please do not
attempt to exit full-screen mode during the quiz, as it will
automatically submit your answers.</li>
<li class="quiz-info"><strong>Questions:</strong> You will be
presented a single trading-related question. Read each question
carefully.</li>
<li class="quiz-info"><strong>Answers:</strong> For each
question, select the answer you believe is correct from the
dropdown menu and click the "Submit" button.</li>
<li class="quiz-info"><strong>Scoring:</strong> You will earn
points for each correct answer. Your streak will increase with each
correct answer and decrease with each incorrect answer.</li>
<li class="quiz-info"><strong>Streak🔥:</strong> Your
streak reflects the number of consecutive correct answers. Try to
maintain a high streak throughout the quiz.</li>
<li class="quiz-info"><strong>Navigation:</strong> You cannot
go back to previous questions once they are answered, so choose
your answers wisely.</li>
<li class="quiz-info"><strong>Auto-Submission:</strong> If you
try to exit full-screen mode or if the time limit of 1 minute is
reached, the quiz will be automatically submitted.</li>
<li class="quiz-info"><strong>Restart:</strong> After the quiz
is completed, you can restart a new quiz session.</li>
<li class="quiz-info"><strong>Enjoy:</strong> Have fun and
enjoy the quiz! It's a great way to test your trading knowledge.</li>
</ol>
<br>  <a href="home.jsp" class="back-button">Back to
Home</a>
</div>
</div>
<script>
const startQuizButton = document.getElementById("start-quiz-button");
const alreadyAnswered = document.getElementById("already-answered");
const timerElement = document.getElementById("timer");
let isInFullscreen = false;
let isQuizSubmitted = false;
const questionText = document.getElementById("question-text");
const answerForm = document.getElementById("answer-form");
const answerSelect = document.getElementById("answer");
const streakElement = document.getElementById("streak");
// Function to request fullscreen mode and start the quiz
function startQuizAndFullscreen() {
if (!isInFullscreen) {
document.getElementById("question-text").style.display = "block";
document.getElementById("answer-form").style.display = "block";
document.getElementById("streak").style.display = "block";
document.getElementById("submit-button").style.display = "block";
const element = document.documentElement;
// Request fullscreen mode
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
// Mark that we are in fullscreen mode
isInFullscreen = true;
// Add your code to start the quiz here
// For example, you can navigate to the first quiz question or load quiz content
// Simulate the completion of the quiz (all questions are answered)
// Replace this with your actual quiz completion logic
setTimeout(() => {
if (!isQuizSubmitted) {
submitQuizAndExitFullscreen();
}
}, 60000); // Simulated delay before quiz submission
startOrResumeTimer();
}
}
// Function to start or resume the timer
function startOrResumeTimer() {
const quizStartTime = localStorage.getItem("quizStartTime");
if (!quizStartTime) {
// If there is no stored start time, start a new quiz
localStorage.setItem("quizStartTime", new Date().getTime().toString());
start24HourTimer();
} else {
// If there is a stored start time, calculate the remaining time
const currentTime = new Date().getTime();
const quizDuration = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
const elapsedTime = currentTime - parseInt(quizStartTime);
if (elapsedTime >= quizDuration) {
// The quiz duration has already passed, allow the user to attend the next question
timerElement.innerText = "You can attend the next question now!";
startQuizButton.disabled = false;
alreadyAnswered.innerText = "";
localStorage.removeItem("quizStartTime");
localStorage.removeItem("answeredToday");
} else {
// Resume the timer with the remaining time
const remainingTime = quizDuration - elapsedTime;
start24HourTimer(remainingTime);
}
}
}
// Function to start a timer with the given remaining time
function start24HourTimer() {
// Update the timer every second
const quizDuration = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
let remainingTime = quizDuration;
const timerInterval = setInterval(function () {
const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((remainingTime % (1000 * 60)) / 1000);
// Display the timer
timerElement.innerText = `Next question available in: ${hours}h ${minutes}m ${seconds}s`;
if (remainingTime <= 0) {
clearInterval(timerInterval);
}
remainingTime -= 1000;
}, 1000);
}
// Function to submit the quiz and exit fullscreen mode
function submitQuizAndExitFullscreen() {
if (isInFullscreen && !isQuizSubmitted) {
// Add your code to submit the quiz here
// For example, you can check if all questions are answered, calculate scores, etc.
// Exit fullscreen mode
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
localStorage.setItem("answeredToday","true");
// Mark that we are no longer in fullscreen mode and the quiz is submitted
isInFullscreen = false;
isQuizSubmitted = true;
document.getElementById("submit-msg").innerText="Quiz Submitted Successfully";
}
}
// Check if the user has already answered today
const answeredToday1 = localStorage.getItem("answeredToday");
if (answeredToday1 === "true") {
// User has already answered today, disable the "Start Quiz" button
startQuizButton.disabled = true;
alreadyAnswered.innerText = "You have already answered today.";
}
// Add event listener to the "Start Quiz" button
startQuizButton.addEventListener("click", startQuizAndFullscreen);
answerForm.addEventListener("submit", checkAnswer);
// Listen for the user's attempt to exit fullscreen
document.addEventListener("fullscreenchange", function () {
if (!document.fullscreenElement && isInFullscreen && !isQuizSubmitted) {
// Automatically submit the quiz and exit fullscreen mode
submitQuizAndExitFullscreen();
}
});
startOrResumeTimer();
const questions = [
{
question: "What is a stop-loss order in trading?",
options: [
"An order to buy at a specified price",
"An order to sell at a specified price",
"An order to buy at the market price",
"An order to sell at the market price",
],
correctAnswer: "An order to sell at a specified price",
},
{
question: "What does 'IPO' stand for in the context of trading?",
options: [
"Initial Public Offering",
"International Portfolio Organization",
"Investor Profit Opportunity",
"Internal Performance Order",
],
correctAnswer: "Initial Public Offering",
},
{
question: "Which market is known for trading commodities such as gold and oil?",
options: ["Stock market", "Forex market", "Commodity market", "Bond market"],
correctAnswer: "Commodity market",
},
{
question: "What is the term for the difference between the bid and ask price of a security?",
options: ["Spread", "Margin", "Leverage", "Volatility"],
correctAnswer: "Spread",
},
{
question: "In technical analysis, what does RSI stand for?",
options: [
"Relative Strength Index",
"Return on Investment",
"Risk and Strategy Indicator",
"Resistance and Support Index",
],
correctAnswer: "Relative Strength Index",
},
{
question: "What is the primary function of a stock exchange?",
options: [
"To set interest rates",
"To issue government bonds",
"To facilitate the buying and selling of stocks",
"To provide insurance services",
],
correctAnswer: "To facilitate the buying and selling of stocks",
},
{
question: "What is the term for a market condition where prices are falling sharply?",
options: ["Bull market", "Bear market", "Sideways market", "Bullish market"],
correctAnswer: "Bear market",
},
{
question: "What does 'Diversification' mean in investment?",
options: [
"Investing in a single asset class",
"Spreading investments across different assets",
"Investing in high-risk assets",
"Holding onto cash",
],
correctAnswer: "Spreading investments across different assets",
},
{
question: "What is a 'Blue Chip' stock?",
options: [
"A low-priced stock",
"A speculative stock",
"A well-established, stable, and reputable company's stock",
"A stock with high volatility",
],
correctAnswer: "A well-established, stable, and reputable company's stock",
},
{
question: "What is 'Day Trading'?",
options: [
"Buying and selling within the same trading day",
"Investing for the long term",
"Trading during the night",
"Trading only on weekends",
],
correctAnswer: "Buying and selling within the same trading day",
},
{
question: "What does 'Liquidity' refer to in trading?",
options: [
"How quickly an asset can be converted into cash without affecting its price",
"How much profit can be made in a trade",
"The size of a company",
"The total assets of a company",
],
correctAnswer: "How quickly an asset can be converted into cash without affecting its price",
},
{
question: "What is a 'Pip' in Forex trading?",
options: [
"A small fruit",
"A unit of currency movement",
"A type of stock",
"A trading strategy",
],
correctAnswer: "A unit of currency movement",
},
{
question: "What is the 'Bullish' market sentiment?",
options: [
"Positive outlook, expecting prices to rise",
"Negative outlook, expecting prices to fall",
"No specific outlook",
"A market for bulls",
],
correctAnswer: "Positive outlook, expecting prices to rise",
},
{
question: "What is 'Volatility' in the context of trading?",
options: [
"A measure of market stability",
"A measure of market predictability",
"A measure of market size",
"A measure of price fluctuations",
],
correctAnswer: "A measure of price fluctuations",
},
{
question: "What is the purpose of a 'Margin Call'?",
options: [
"To request more time for trading",
"To close a trading account",
"To notify traders of their margin balance",
"To request additional funds due to trading losses",
],
correctAnswer: "To request additional funds due to trading losses",
},
];
let streak = 0;
let answeredToday = false;
// Function to get the streak from local storage
function getStreak() {
const storedStreak = localStorage.getItem("streak");
return storedStreak ? parseInt(storedStreak) : 0;
}
// Function to update the streak and store it in local storage
function updateStreak(newStreak) {
streak = newStreak;
streakElement.textContent = `${streak}`;
localStorage.setItem("streak", streak.toString());
}
function displayRandomQuestion() {
let answeredToday = localStorage.getItem("answeredToday");
if (!answeredToday) {
const randomIndex = Math.floor(Math.random() * questions.length);
const randomQuestion = questions[randomIndex];
questionText.textContent = randomQuestion.question;
// Populate answer options
answerSelect.innerHTML = "";
for (let i = 0; i < randomQuestion.options.length; i++) {
const option = randomQuestion.options[i];
const optionElement = document.createElement("option");
optionElement.value = option;
optionElement.textContent = option;
answerSelect.appendChild(optionElement);
}
} else {
// Quiz is completed for the day, exit fullscreen mode (modify as needed)
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}
// Function to check the answer
function checkAnswer(e) {
e.preventDefault();
// Check if the user has already answered today
const answeredToday = localStorage.getItem("answeredToday");
if (!answeredToday) {
const selectedAnswer = answerSelect.value.trim();
const randomQuestion = questions.find((q) => q.question === questionText.textContent);
console.log("Selected Answer:", selectedAnswer);
console.log("Correct Answer:", randomQuestion.correctAnswer.trim());
if (selectedAnswer === randomQuestion.correctAnswer.trim()) {
updateStreak(streak + 1);
} else {
updateStreak(streak - 1);
}
// Mark that the user has answered today
localStorage.setItem("answeredToday", "true");
displayRandomQuestion();
window.location.href="index.html";
}
}
// Initial question load
displayRandomQuestion();
// Initialize the streak from local storage
updateStreak(getStreak());
</script>
</body>
</html>