Skip to content

Commit

Permalink
fix: object-exam
Browse files Browse the repository at this point in the history
  • Loading branch information
luizchaves committed Mar 25, 2024
1 parent 2fdf762 commit cdd1ef1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/pages/exercises/object-exam/_codes/js/code/exam.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export class ExamStats {
export class Exam {
// TODO
}
66 changes: 33 additions & 33 deletions src/pages/exercises/object-exam/_codes/js/code/exam.print.js
Original file line number Diff line number Diff line change
@@ -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]);

0 comments on commit cdd1ef1

Please sign in to comment.