JS Lab 3 progress
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
import {students} from "./data.js"
|
import {students} from "./data.js"
|
||||||
let passingStudents = [];
|
let passingStudents = [];
|
||||||
|
|
||||||
function getPassingStudents(students, passMark = 70) {
|
export function getPassingStudents(students, passMark = 70) {
|
||||||
if (isNaN(passMark) || passMark < 0) {
|
if (isNaN(passMark) || passMark < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -9,13 +9,13 @@ function getPassingStudents(students, passMark = 70) {
|
|||||||
let grade = parseInt(student.grade);
|
let grade = parseInt(student.grade);
|
||||||
if (isNaN(grade)) return false;
|
if (isNaN(grade)) return false;
|
||||||
|
|
||||||
return true;
|
return grade >= passMark;
|
||||||
});
|
});
|
||||||
return passingStudents;
|
return passingStudents;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateCourseAverage(students) {
|
function calculateCourseAverages(students) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTopPerCourse(students) {
|
function getTopPerCourse(students) {
|
||||||
@@ -23,9 +23,11 @@ function getTopPerCourse(students) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function calculateOverallStatistics(students) {
|
function calculateOverallStatistics(students) {
|
||||||
|
const summary = document.getElementById("summary");
|
||||||
}
|
summary.innerHTML += `<p>Total Students: ${students.length}</p><br>
|
||||||
|
<p>Average Grade: </p><br>
|
||||||
function calculateAssignmentAvgerage(students) {
|
<p>Highest Grade: </p><br>
|
||||||
|
<p>Lowest Grade: </p><br>
|
||||||
|
<p>Average Attendance: %</p><br>
|
||||||
|
<p>Unique Courses: </p><br>`;
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,16 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Levi McLean JS Lab 3</title>
|
<title>Levi McLean JS Lab 3</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="./style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>JS Lab 3</h1>
|
<h1>Student Performance Analytics Dashboard</h1>
|
||||||
|
<input type="text" placeholder="Search By Name" id="nameSearch">
|
||||||
|
<label for="minimumGrade">Minimum Grade:</label>
|
||||||
|
<input type="range" min="0" max="100" name="minimumGrade" id="minimumGrade">
|
||||||
|
<button type="button">Toggle Theme</button>
|
||||||
|
|
||||||
<table id="studentTable">
|
<table id="studentTable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -21,6 +27,9 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody id="studentTableBody"></tbody>
|
<tbody id="studentTableBody"></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div id="summary">
|
||||||
|
<h2>Summary</h2>
|
||||||
|
</div>
|
||||||
<script type="module" src="main.js"></script>
|
<script type="module" src="main.js"></script>
|
||||||
<script type="module" src="data.js"></script>
|
<script type="module" src="data.js"></script>
|
||||||
<script type="module" src="analytics.js"></script>
|
<script type="module" src="analytics.js"></script>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
body {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border: 2px solid black;
|
||||||
|
background-color: white;
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td, table th {
|
||||||
|
border: 2px solid black;
|
||||||
|
padding: 6px 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
import {students} from "./data.js"
|
import {students} from "./data.js"
|
||||||
|
import {calculateAssignmentAverage} from "./utils.js"
|
||||||
|
import {getPassingStudents} from "./analytics.js"
|
||||||
|
|
||||||
|
const passingStudents = getPassingStudents(students);
|
||||||
|
const passingIds = passingStudents.map(student => student.id);
|
||||||
const tableBody = document.getElementById("studentTableBody");
|
const tableBody = document.getElementById("studentTableBody");
|
||||||
|
|
||||||
students.forEach(student => {
|
students.forEach(student => {
|
||||||
const row = document.createElement("tr");
|
const row = document.createElement("tr");
|
||||||
const name = document.createElement("td");
|
const name = document.createElement("td");
|
||||||
@@ -12,8 +17,9 @@ students.forEach(student => {
|
|||||||
const attendance = document.createElement("td");
|
const attendance = document.createElement("td");
|
||||||
attendance.textContent = student.attendance + "%" ?? "-";
|
attendance.textContent = student.attendance + "%" ?? "-";
|
||||||
const assignmentAvg = document.createElement("td");
|
const assignmentAvg = document.createElement("td");
|
||||||
// assignmentAvg.textContent = calculateAssignmentAvgerage(student); TODO
|
assignmentAvg.textContent = calculateAssignmentAverage(student);
|
||||||
const status = document.createElement("td");
|
const status = document.createElement("td");
|
||||||
|
status.textContent = passingIds.includes(student.id) ? "Pass" : "Fail";
|
||||||
const city = document.createElement("td");
|
const city = document.createElement("td");
|
||||||
city.textContent = student.address.city ?? "-";
|
city.textContent = student.address.city ?? "-";
|
||||||
row.append(name, course, grade, attendance, assignmentAvg, status, city);
|
row.append(name, course, grade, attendance, assignmentAvg, status, city);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export function calculateAssignmentAverage(student) {
|
||||||
|
if (!student.assignments || student.assignments.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const total = student.assignments.reduce((sum, score) => sum + score, 0);
|
||||||
|
return total / student.assignments.length;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user