JS lab 3
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import {students} from "./data.js"
|
||||
let passingStudents = [];
|
||||
|
||||
function getPassingStudents(students, passMark = 70) {
|
||||
if (isNaN(passMark) || passMark < 0) {
|
||||
return false;
|
||||
}
|
||||
passingStudents = students.filter(student => {
|
||||
let grade = parseInt(student.grade);
|
||||
if (isNaN(grade)) return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
return passingStudents;
|
||||
}
|
||||
|
||||
function calculateCourseAverage(students) {
|
||||
|
||||
}
|
||||
|
||||
function getTopPerCourse(students) {
|
||||
|
||||
}
|
||||
|
||||
function calculateOverallStatistics(students) {
|
||||
|
||||
}
|
||||
|
||||
function calculateAssignmentAvgerage(students) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
export const students = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Priyank",
|
||||
course: "Web Development",
|
||||
grade: 85,
|
||||
attendance: 92,
|
||||
assignments: [80, 90, 85],
|
||||
address: { city: "London", province: "ON" }
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Jay",
|
||||
course: "Web Development",
|
||||
grade: 72,
|
||||
attendance: 75,
|
||||
assignments: [70, 68, 78],
|
||||
address: { city: "Toronto", province: "ON" }
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Jim",
|
||||
course: "Mobile Development",
|
||||
grade: 90,
|
||||
attendance: 88,
|
||||
assignments: [95, 85, 90],
|
||||
address: { city: "Ottawa", province: "ON" }
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Dev",
|
||||
course: "Mobile Development",
|
||||
grade: 60,
|
||||
attendance: 65,
|
||||
assignments: [55, 60, 65],
|
||||
address: { city: "London", province: "ON" }
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "Eva",
|
||||
course: "Artificial Intelligence",
|
||||
grade: 95,
|
||||
attendance: 98,
|
||||
assignments: [100, 90, 95],
|
||||
address: { city: "Waterloo", province: "ON" }
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "Elon",
|
||||
course: "Artificial Intelligence",
|
||||
grade: 78,
|
||||
attendance: 82,
|
||||
assignments: [75, 80, 79],
|
||||
address: { city: "London", province: "ON" }
|
||||
}
|
||||
];
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Levi McLean JS Lab 3</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>JS Lab 3</h1>
|
||||
<table id="studentTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Course</th>
|
||||
<th>Grade</th>
|
||||
<th>Attendance</th>
|
||||
<th>Assignment Avg</th>
|
||||
<th>Status</th>
|
||||
<th>City</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="studentTableBody"></tbody>
|
||||
</table>
|
||||
<script type="module" src="main.js"></script>
|
||||
<script type="module" src="data.js"></script>
|
||||
<script type="module" src="analytics.js"></script>
|
||||
<script type="module" src="utils.js"></script>
|
||||
<script type="module" src="ui.js"></script>
|
||||
<script type="module" src="theme.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
import {students} from "./data.js"
|
||||
|
||||
const tableBody = document.getElementById("studentTableBody");
|
||||
students.forEach(student => {
|
||||
const row = document.createElement("tr");
|
||||
const name = document.createElement("td");
|
||||
name.textContent = student.name ?? "-";
|
||||
const course = document.createElement("td");
|
||||
course.textContent = student.course ?? "-";
|
||||
const grade = document.createElement("td");
|
||||
grade.textContent = student.grade ?? "-";
|
||||
const attendance = document.createElement("td");
|
||||
attendance.textContent = student.attendance + "%" ?? "-";
|
||||
const assignmentAvg = document.createElement("td");
|
||||
// assignmentAvg.textContent = calculateAssignmentAvgerage(student); TODO
|
||||
const status = document.createElement("td");
|
||||
const city = document.createElement("td");
|
||||
city.textContent = student.address.city ?? "-";
|
||||
row.append(name, course, grade, attendance, assignmentAvg, status, city);
|
||||
tableBody.appendChild(row);
|
||||
});
|
||||
@@ -5,7 +5,7 @@ function fetchJson() {
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
const tableBody = document.getElementById("meteorTableBody");
|
||||
data.splice(0,500).forEach(meteor => { // Just get 500 values for now
|
||||
data.forEach(meteor => { // Just get 500 values for now
|
||||
const row = document.createElement("tr");
|
||||
const id = document.createElement("td");
|
||||
id.textContent = meteor.id ?? "-";
|
||||
|
||||
Reference in New Issue
Block a user