From cdd1ef1bd2db2926fd93ebcfedf49c2c6cdb3974 Mon Sep 17 00:00:00 2001 From: Luiz Date: Mon, 25 Mar 2024 15:06:05 -0300 Subject: [PATCH] fix: object-exam --- .../object-exam/_codes/js/code/exam.js | 2 +- .../object-exam/_codes/js/code/exam.print.js | 66 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/pages/exercises/object-exam/_codes/js/code/exam.js b/src/pages/exercises/object-exam/_codes/js/code/exam.js index 45e494af..abb1dbc8 100644 --- a/src/pages/exercises/object-exam/_codes/js/code/exam.js +++ b/src/pages/exercises/object-exam/_codes/js/code/exam.js @@ -1,3 +1,3 @@ -export class ExamStats { +export class Exam { // TODO } diff --git a/src/pages/exercises/object-exam/_codes/js/code/exam.print.js b/src/pages/exercises/object-exam/_codes/js/code/exam.print.js index 9312c9f2..5e2f6123 100644 --- a/src/pages/exercises/object-exam/_codes/js/code/exam.print.js +++ b/src/pages/exercises/object-exam/_codes/js/code/exam.print.js @@ -1,47 +1,47 @@ -import { ExamCheck } from "./exam-check.js"; -import { ExamStats } from "./exam-stats.js"; +import { Exam } from './exam.js'; // Exam Tool -// calculating grade by weighted average -let weight = { q1: 2, q2: 2, q3: 2, q4: 2, q5: 2 }; -let answer = { q1: "a", q2: "b", q3: "a", q4: "c", q5: "d" }; -let examCheck = new ExamCheck(answer, weight); +const weight = { q1: 2, q2: 2, q3: 2, q4: 2, q5: 2 }; +const answer = { q1: 'a', q2: 'b', q3: 'a', q4: 'c', q5: 'd' }; +const exam = new Exam(answer, weight); -let student = { q1: "a", q2: "b", q3: "b", q4: "b", q5: "b" }; -console.log(examCheck.grade(student)); +exam.add({ + student: 'Alice', + answer: { q1: 'a', q2: 'b', q3: 'b', q4: 'b', q5: 'b' }, +}); + +console.log(exam.avg()); console.log(4); -// calculating grade by weighted average -weight = { q1: 2, q2: 2, q3: 2, q4: 2, q5: 2 }; -answer = { q1: "a", q2: "b", q3: "a", q4: "c", q5: "d" }; -examCheck = new ExamCheck(answer, weight); +console.log(exam.min()); +console.log([4]); + +console.log(exam.max()); +console.log([4]); -student = { q1: "c", q2: "b", q3: "a", q4: "c", q5: "d" }; -console.log(examCheck.grade(student)); -console.log(8); +console.log(exam.lt(7)); +console.log([4]); -// calculating exam values -let examStats = new ExamStats([ - { student: "Fulano", grade: 10 }, - { student: "Sicrano", grade: 5 }, - { student: "Beltrano", grade: 7 } -]); +console.log(exam.gt(7)); +console.log([]); -console.log(examStats.avg()); -console.log(7.333333333333333); +exam.add({ + student: 'Bob', + answer: { q1: 'c', q2: 'b', q3: 'a', q4: 'c', q5: 'd' }, +}); -console.log(examStats.min()); -console.log([5]); +console.log(exam.avg()); +console.log(6); -console.log(examStats.min(2)); -console.log([5, 7]); +console.log(exam.min()); +console.log([4]); -console.log(examStats.max()); -console.log([10]); +console.log(exam.max()); +console.log([8]); -console.log(examStats.lt(6)); -console.log([5]); +console.log(exam.lt(7)); +console.log([4]); -console.log(examStats.gt(6)); -console.log([7, 10]); +console.log(exam.gt(7)); +console.log([8]);