-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
310 lines (266 loc) · 7.77 KB
/
index.html
File metadata and controls
310 lines (266 loc) · 7.77 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AI GPA Helper</title>
<style>
:root {
--bg: #0f172a;
--card: #111827;
--text: #e5e7eb;
--muted: #9ca3af;
--accent: #38bdf8;
--danger: #fb7185;
--ok: #34d399;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
background: linear-gradient(135deg, #0b1022, var(--bg));
color: var(--text);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
}
.app {
width: 100%;
max-width: 920px;
background: rgba(17, 24, 39, 0.9);
border: 1px solid #1f2937;
border-radius: 16px;
padding: 22px;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
h1 { margin: 0 0 6px; }
.subtitle {
margin: 0 0 18px;
color: var(--muted);
font-size: 0.95rem;
}
.grid {
display: grid;
grid-template-columns: 2fr 1fr 1fr auto;
gap: 10px;
}
input, select, button {
border: 1px solid #263244;
background: #0b1324;
color: var(--text);
border-radius: 10px;
padding: 10px 12px;
font-size: 0.95rem;
}
input::placeholder { color: #728197; }
button {
cursor: pointer;
border-color: #1f2937;
background: linear-gradient(180deg, #0ea5e9, #0284c7);
color: white;
font-weight: 600;
transition: transform 0.08s ease;
}
button:active { transform: translateY(1px); }
.section {
margin-top: 16px;
padding-top: 16px;
border-top: 1px solid #223049;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th, td {
text-align: left;
padding: 10px;
border-bottom: 1px solid #1f2937;
font-size: 0.93rem;
}
th { color: var(--muted); font-weight: 600; }
.remove {
background: transparent;
border: 1px solid #374151;
color: var(--danger);
padding: 5px 8px;
border-radius: 8px;
}
.result-box {
margin-top: 14px;
display: grid;
grid-template-columns: 1fr;
gap: 12px;
}
.card {
background: #0b1324;
border: 1px solid #1f2937;
border-radius: 12px;
padding: 14px;
}
.gpa {
font-size: 1.9rem;
font-weight: 800;
color: var(--ok);
margin: 4px 0 0;
}
.ai-output {
line-height: 1.55;
color: #dbeafe;
margin: 8px 0 0;
white-space: pre-wrap;
}
.hint {
color: var(--muted);
font-size: 0.88rem;
margin-top: 8px;
}
@media (max-width: 700px) {
.grid { grid-template-columns: 1fr 1fr; }
.grid button { grid-column: span 2; }
}
</style>
</head>
<body>
<main class="app">
<h1>AI GPA Helper</h1>
<p class="subtitle">Enter your courses and get an instant GPA + AI-style study advice.</p>
<div class="grid">
<input id="course" type="text" placeholder="Course name (e.g., Math)" />
<input id="credits" type="number" min="1" max="6" placeholder="Credits" />
<select id="grade">
<option value="">Grade</option>
<option>A</option><option>A-</option><option>B+</option><option>B</option><option>B-</option>
<option>C+</option><option>C</option><option>C-</option><option>D</option><option>F</option>
</select>
<button id="addBtn">Add</button>
</div>
<section class="section">
<table>
<thead>
<tr>
<th>Course</th>
<th>Credits</th>
<th>Grade</th>
<th></th>
</tr>
</thead>
<tbody id="rows"></tbody>
</table>
<p class="hint">Tip: add at least 2 courses for better recommendations.</p>
</section>
<section class="result-box">
<div class="card">
<div>Current GPA</div>
<div class="gpa" id="gpaValue">0.00</div>
</div>
<div class="card">
<div>AI Study Coach</div>
<p class="ai-output" id="aiAdvice">Add courses to get personalized advice.</p>
</div>
</section>
</main>
<script>
const pointsMap = {
"A": 4.0,
"A-": 3.7,
"B+": 3.3,
"B": 3.0,
"B-": 2.7,
"C+": 2.3,
"C": 2.0,
"C-": 1.7,
"D": 1.0,
"F": 0.0
};
const courses = [];
const courseEl = document.getElementById("course");
const creditsEl = document.getElementById("credits");
const gradeEl = document.getElementById("grade");
const addBtn = document.getElementById("addBtn");
const rowsEl = document.getElementById("rows");
const gpaValueEl = document.getElementById("gpaValue");
const aiAdviceEl = document.getElementById("aiAdvice");
function render() {
rowsEl.innerHTML = "";
courses.forEach((c, idx) => {
const tr = document.createElement("tr");
tr.innerHTML = `
<td>${c.name}</td>
<td>${c.credits}</td>
<td>${c.grade}</td>
<td><button class="remove" data-index="${idx}">Remove</button></td>
`;
rowsEl.appendChild(tr);
});
document.querySelectorAll(".remove").forEach(btn => {
btn.addEventListener("click", () => {
courses.splice(Number(btn.dataset.index), 1);
updateResults();
render();
});
});
updateResults();
}
function updateResults() {
if (!courses.length) {
gpaValueEl.textContent = "0.00";
aiAdviceEl.textContent = "Add courses to get personalized advice.";
return;
}
let quality = 0;
let credits = 0;
let lowCourses = [];
for (const c of courses) {
quality += pointsMap[c.grade] * c.credits;
credits += c.credits;
if (pointsMap[c.grade] < 2.7) lowCourses.push(c.name);
}
const gpa = quality / credits;
gpaValueEl.textContent = gpa.toFixed(2);
aiAdviceEl.textContent = generateAdvice(gpa, lowCourses);
}
function generateAdvice(gpa, lowCourses) {
const base = [];
if (gpa >= 3.7) {
base.push("Great work — your performance is excellent.");
base.push("Keep your momentum with weekly review sessions and practice tests.");
} else if (gpa >= 3.0) {
base.push("You are doing well, but there is room to improve.");
base.push("Spend 20-30 extra minutes after each class rewriting key concepts.");
} else if (gpa >= 2.0) {
base.push("You are passing, but your GPA needs attention.");
base.push("Use active recall and create a small study plan: 45 minutes/day for weaker subjects.");
} else {
base.push("Your current GPA is at risk.");
base.push("Focus on fundamentals, seek tutoring, and meet each instructor this week.");
}
if (lowCourses.length) {
base.push(`Priority courses: ${lowCourses.join(", ")}.`);
}
const target = gpa < 3.0
? "If you raise one low grade by one letter, your GPA can improve noticeably this term."
: "To push toward the next GPA tier, aim for mostly A-/B+ or better going forward.";
base.push(target);
return base.join("\n");
}
addBtn.addEventListener("click", () => {
const name = courseEl.value.trim();
const credits = Number(creditsEl.value);
const grade = gradeEl.value;
if (!name || !credits || !grade) {
alert("Please enter course name, credits, and grade.");
return;
}
courses.push({ name, credits, grade });
courseEl.value = "";
creditsEl.value = "";
gradeEl.value = "";
render();
});
render();
</script>
</body>
</html>