Skip to content

Commit c728afd

Browse files
Merge pull request #309 from cmu15122/skyism_timeformat
sheng time_format fixes + queue update question fix
2 parents 0adcd8a + 0f9b85e commit c728afd

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

client/src/components/home/student/UpdateQuestionOverlay.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export default function UpdateQuestionOverlay(props) {
4646
handleClose();
4747
setIsSubmitting(false);
4848
});
49+
}).catch((error) => {
50+
handleClose();
51+
setIsSubmitting(false);
4952
});
5053
};
5154

client/src/components/home/ta/StudentEntries.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ export default function StudentEntries(props) {
190190
setTempDisabled(false);
191191
});
192192
};
193-
194193
const handleCancel = (index) => {
195194
setTempDisabled(true);
196195
HomeService.unhelpStudent(

client/src/components/metrics/CumulativeStats.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ export default function CumulativeStats(props) {
4949
<Divider orientation="vertical" variant="middle" flexItem />
5050
<Grid sx={{px: 4, py: 4, alignItems: 'center', textAlign: 'center'}}>
5151
<Typography variant='h6' fontWeight='bold'>Average Time Spent per Question (min)</Typography>
52-
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{Number(avgTimePerQuestion).toFixed(2)}</Typography>
52+
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{avgTimePerQuestion}</Typography>
5353
</Grid>
5454

5555
<Divider orientation="vertical" variant="middle" flexItem />
5656
<Grid sx={{px: 4, py: 4, alignItems: 'center', textAlign: 'center'}}>
5757
<Typography variant='h6' fontWeight='bold'>Average Wait Time (min)</Typography>
58-
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{Number(avgWaitTime).toFixed(2)}</Typography>
58+
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{avgWaitTime}</Typography>
5959
</Grid>
6060
</Card>
6161
</div>

client/src/components/metrics/OverallStats.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function OverallStats() {
5959
<Divider orientation="vertical" variant="middle" flexItem />
6060
<Grid sx={{px: 4, py: 4, alignItems: 'center', textAlign: 'center'}}>
6161
<Typography variant='h6' fontWeight='bold'>Average Waiting Time (min)</Typography>
62-
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{Number(avgWaitTime).toFixed(2)}</Typography>
62+
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{avgWaitTime}</Typography>
6363
</Grid>
6464
<Divider orientation="vertical" variant="middle" flexItem />
6565
<Grid sx={{px: 4, py: 4, alignItems: 'center', textAlign: 'center'}}>

client/src/components/metrics/PersonalStats.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default function PersonalStats() {
8787
</Grid>
8888
<Grid sx={{textAlign: 'center'}}>
8989
<Typography variant='h6' fontWeight='bold'>Avg. Time Spent Per Question (min)</Typography>
90-
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{Number(averageHelpTime).toFixed(2)}</Typography>
90+
<Typography variant='h3' sx={{mt: 2}} fontWeight='bold'>{averageHelpTime}</Typography>
9191
</Grid>
9292
<Stack sx={{width: '100%'}}>
9393
<TableContainer sx={{height: 300}}>

server/controllers/metrics.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ exports.get_avg_time_per_question = (req, res) => {
109109

110110
if (count != 0) averageTime /= count;
111111

112+
const minutes = Math.floor(averageTime);
113+
const seconds = Math.round((averageTime - minutes) * 60);
114+
averageTime = minutes + ":" + seconds.toString().padStart(2, '0');
115+
112116
respond(req, res, "Got average time per question", { averageTime: averageTime }, 200);
113117
});
114118
}
@@ -199,6 +203,10 @@ exports.get_avg_wait_time_today = (req, res) => {
199203

200204
if (count != 0) avgWaitTime /= count;
201205

206+
const minutes = Math.floor(avgWaitTime);
207+
const seconds = Math.round((avgWaitTime - minutes) * 60);
208+
avgWaitTime = minutes + ":" + seconds.toString().padStart(2, '0');
209+
202210
respond(req, res, "Got average wait time today", { avgWaitTime: avgWaitTime }, 200);
203211
});
204212
}
@@ -292,6 +300,10 @@ exports.get_total_avg_time_per_question = (req, res) => {
292300

293301
if (count != 0) averageTime /= count;
294302

303+
const minutes = Math.floor(averageTime);
304+
const seconds = Math.round((averageTime - minutes) * 60);
305+
averageTime = minutes + ":" + seconds.toString().padStart(2, '0');
306+
295307
respond(req, res, "Got average time per question", { averageTime: averageTime }, 200);
296308
});
297309
}
@@ -320,6 +332,10 @@ exports.get_total_avg_wait_time = (req, res) => {
320332

321333
if (count != 0) avgWaitTime /= count;
322334

335+
const minutes = Math.floor(avgWaitTime);
336+
const seconds = Math.round((avgWaitTime - minutes) * 60);
337+
avgWaitTime = minutes + ":" + seconds.toString().padStart(2, '0');
338+
323339
respond(req, res, "Got average wait time", { totalAvgWaitTime: avgWaitTime }, 200);
324340
});
325341
}

0 commit comments

Comments
 (0)