Skip to content

Commit 9f93cbf

Browse files
committed
assessment report showing results
1 parent 91bede1 commit 9f93cbf

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
<div class="testimonial" style="width: 100%; margin-bottom: 10px; ">
241241

242242

243-
<div id="landing-page" style="display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; padding: 20px; font-family: Arial, sans-serif; margin: 0 auto; max-width: 1350px; gap: 30px;">
243+
<div id="landing-page" style="display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; padding: 0 4rem 2rem 4rem; font-family: Arial, sans-serif; margin: 0 auto; max-width: 1350px; ">
244244
<!-- Left Section: Texts and Demo Class -->
245245
<div style="flex: 1; min-width: 300px; margin-right: 20px; padding: 0 10px;">
246246
<h1 style="font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 15px; font-weight: 800; line-height: 1.2;">

jobsdoor360-website/src/main/ejs/main-files/index.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<div class="testimonial" style="width: 100%; margin-bottom: 10px; ">
7070

7171

72-
<div id="landing-page" style="display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; padding: 20px; font-family: Arial, sans-serif; margin: 0 auto; max-width: 1350px; gap: 30px;">
72+
<div id="landing-page" style="display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; padding: 0 4rem 2rem 4rem; font-family: Arial, sans-serif; margin: 0 auto; max-width: 1350px; ">
7373
<!-- Left Section: Texts and Demo Class -->
7474
<div style="flex: 1; min-width: 300px; margin-right: 20px; padding: 0 10px;">
7575
<h1 style="font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 15px; font-weight: 800; line-height: 1.2;">

staticfiles/mainfiles/test/quiz/script.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,36 +214,36 @@ async function startQuiz() {
214214
if (user) {
215215
const email = user.email;
216216

217-
// Reference to the specific quiz results
218-
const userQuizRef = doc(db, "user_assessment_results", email, "assessment_results", assessmentKey);
217+
// Reference to the user's assessment results
218+
const userResultsRef = doc(db, "user_assessment_results", email);
219219

220-
// Prepare the new attempt data
220+
// New attempt data
221221
const newAttempt = {
222-
score: {
223-
score: score,
224-
timestamp: new Date(),
225-
},
222+
quizCode: assessmentKey, // Quiz identifier
223+
score: score,
224+
percentage: percentage,
225+
timestamp: new Date(),
226226
user_questions_with_answers: currentSubject.questions.map((q, index) => {
227227
const selectedAnswerIndex = selectedAnswers[index];
228228
const selectedAnswerText = selectedAnswerIndex !== undefined ? q.answers[selectedAnswerIndex] : null;
229229
return {
230230
question: q.question,
231-
answer: selectedAnswerText, // Save the full text of the selected answer
231+
answer: selectedAnswerText, // Save full text of the selected answer
232232
};
233233
}),
234234
};
235235

236-
// Check if the document for this quiz already exists
237-
const existingDoc = await getDoc(userQuizRef);
236+
// Fetch existing results
237+
const existingDoc = await getDoc(userResultsRef);
238238

239239
if (existingDoc.exists()) {
240-
// Update the attempts array
240+
// Append new attempt to the existing results array
241241
const existingData = existingDoc.data();
242-
const updatedAttempts = [...(existingData.attempts || []), newAttempt];
243-
await setDoc(userQuizRef, { attempts: updatedAttempts });
242+
const updatedResults = [...(existingData.results || []), newAttempt];
243+
await setDoc(userResultsRef, { results: updatedResults }, { merge: true });
244244
} else {
245245
// Create a new document with the first attempt
246-
await setDoc(userQuizRef, { attempts: [newAttempt] });
246+
await setDoc(userResultsRef, { results: [newAttempt] });
247247
}
248248

249249
console.log("Quiz attempt saved successfully.");
@@ -256,6 +256,7 @@ async function startQuiz() {
256256
}
257257

258258

259+
259260

260261
function startTimer() {
261262
timerInterval = setInterval(() => {

0 commit comments

Comments
 (0)