-
Notifications
You must be signed in to change notification settings - Fork 0
/
timetable.html
188 lines (156 loc) · 7.38 KB
/
timetable.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Study Time Allocation</title>
<link rel="stylesheet" href="timetable.css">
</head>
<body>
<h1><span class="star">★</span>Study Time Allocation<span class="star">★</span></h1>
<form id="inputForm">
<label for="freetime">Free Time for Day 0-6(comma-separated):</label>
<input type="text" id="freetime" placeholder="e.g., 5,6,5,5,7,8,9" required><br><br>
<h6>/* Day 0 is the first day of the schedule</h6>
<table>
<thead>
<tr>
<th>Course Name</th>
<th>Course Credits</th>
<th>Quiz Weightage(%)</th>
<th>Quiz Day(0-6)</th>
<th>Confidence (1-5)</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" id="courseName1" required></td>
<td><input type="number" id="courseCredits1" min="1" required></td>
<td><input type="number" id="quiztimeforcourse1" min="0" required></td>
<td><input type="number" id="quizdayforcourse1" min="0" max="6" required></td>
<td><input type="number" id="courseConfidence1" min="1" max="5" required></td>
</tr>
<tr>
<td><input type="text" id="courseName2" required></td>
<td><input type="number" id="courseCredits2" min="1" required></td>
<td><input type="number" id="quiztimeforcourse2" min="0" required></td>
<td><input type="number" id="quizdayforcourse2" min="0" max="6" required></td>
<td><input type="number" id="courseConfidence2" min="1" max="5" required></td>
</tr>
<tr>
<td><input type="text" id="courseName3" ></td>
<td><input type="number" id="courseCredits3" min="1" ></td>
<td><input type="number" id="quiztimeforcourse3" min="0" ></td>
<td><input type="number" id="quizdayforcourse3" min="0" max="6" ></td>
<td><input type="number" id="courseConfidence3" min="1" max="5" ></td>
</tr>
<tr>
<td><input type="text" id="courseName4" ></td>
<td><input type="number" id="courseCredits4" min="1"></td>
<td><input type="number" id="quiztimeforcourse4" min="0" ></td>
<td><input type="number" id="quizdayforcourse4" min="0" max="6" ></td>
<td><input type="number" id="courseConfidence4" min="1" max="5" ></td>
</tr>
<tr>
<td><input type="text" id="courseName5" ></td>
<td><input type="number" id="courseCredits5" min="1" ></td>
<td><input type="number" id="quiztimeforcourse5" min="0" ></td>
<td><input type="number" id="quizdayforcourse5" min="0" max="6" ></td>
<td><input type="number" id="courseConfidence5" min="1" max="5" ></td>
</tr>
<tr>
<td><input type="text" id="courseName6" ></td>
<td><input type="number" id="courseCredits6" min="1" ></td>
<td><input type="number" id="quiztimeforcourse6" min="0" ></td>
<td><input type="number" id="quizdayforcourse6" min="0" max="6" ></td>
<td><input type="number" id="courseConfidence6" min="1" max="5" ></td>
</tr>
</tbody>
</table>
<button type="submit">Calculate Study Time</button>
</form>
<div id="output"></div>
<script>
document.getElementById("inputForm").addEventListener("submit", function(event) {
event.preventDefault();
const freetimeInput = document.getElementById("freetime").value;
const freetime = freetimeInput.split(",").map(Number);
const courseList = [];
const quizList = [];
for (let i = 1; i <= 6; i++) {
const courseName = document.getElementById(`courseName${i}`).value;
const courseCredits = parseInt(document.getElementById(`courseCredits${i}`).value);
const courseConfidence = parseInt(document.getElementById(`courseConfidence${i}`).value);
courseList.push([courseName, courseCredits, courseConfidence]);
const quizTime = parseInt(document.getElementById(`quiztimeforcourse${i}`).value);
const quizDay = parseInt(document.getElementById(`quizdayforcourse${i}`).value);
quizList.push([courseName, quizTime, quizDay]);
}
const studyTime = studyTimePerDay(courseList, quizList, freetime);
displayStudyTime(studyTime);
});
function displayStudyTime(studyTime) {
const outputDiv = document.getElementById("output");
outputDiv.innerHTML = "<h2>Study Time Allocation</h2>";
const table = document.createElement('table');
// Create table header row with day headings
const headerRow = table.insertRow();
headerRow.insertCell().innerHTML = "<strong>Course</strong>";
for (let i = 0; i < 7; i++) {
headerRow.insertCell().innerHTML = `<strong>Day ${i}</strong>`;
}
// Populate table with study time data
for (let i = 0; i < studyTime.length; i++) {
const course = studyTime[i];
const row = table.insertRow();
const courseCell = row.insertCell(0);
courseCell.innerHTML = `Course ${i + 1}`;
for (let j = 0; j < course.length; j++) {
const dayCell = row.insertCell(j + 1);
dayCell.innerHTML = `${course[j].toFixed(2)} hours`;
}
}
outputDiv.appendChild(table);
}
function studyTimePerDay(courseList, quizList, freetime) {
const M = courseList.length;
const p = Array.from({ length: M }, () => Array(7).fill(0));
const pOrig = Array.from({ length: M }, () => Array(7).fill(0));
const qt = Array(M).fill(0);
const F = Array(M).fill(0);
const R = Array(M).fill(0);
for (let i = 0; i < M; i++) {
for (let j = 0; j < 7; j++) {
pOrig[i][j] = (courseList[i][1] / courseList[i][2]) * freetime[j] / freetime.reduce((a, b) => a + b, 0);
p[i][j] = pOrig[i][j];
}
}
for (let i = 0; i < M; i++) {
qt[i] = (4 / courseList[i][2]) * quizList[i][1] * courseList[i][1] / 100;
}
for (let i = 0; i < M; i++) {
R[i] = quizList[i][2] < 7 ? 7 - quizList[i][2] : 7;
}
for (let i = 0; i < M; i++) {
F[i] = freetime.slice(0, quizList[i][2]).reduce((a, b) => a + b, 0);
}
for (let i = 0; i < M; i++) {
if (quizList[i][2] !== 7) {
for (let j = 0; j < quizList[i][2]; j++) {
p[i][j] += freetime[j] * qt[i] / F[i];
}
for (let j = quizList[i][2]; j < 7; j++) {
p[i][j] = pOrig[i][j] - qt[i] / R[i];
}
}
}
for (let i = 0; i < M; i++) {
for (let j = 0; j < 7; j++) {
p[i][j] = Math.max(p[i][j], 0);
}
}
return p;
}
</script>
</body>
</html>