Skip to content

Commit d220843

Browse files
author
Aishwarya Nair
committed
add collab submission to user attempt db
1 parent 6f0ce5c commit d220843

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Frontend/src/Components/LandingPage/AttemptHistory.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const AttemptHistory = ({isList, setIsList}) => {
1212
// to be replaced with actual attempt fetch
1313
const fetchAttempts = async () => {
1414
setAttempts(getUserAttempts(getUserId()));
15+
console.log(attempts);
1516
};
1617

1718
useEffect(() => {
@@ -23,9 +24,9 @@ export const AttemptHistory = ({isList, setIsList}) => {
2324
{isList?
2425
<div className="attempt-list-container">
2526
{/* to be replaced by mapping over actual stored attempts */}
26-
{attempts.map((a, index) => (
27+
{/* {attempts.map((a, index) => (
2728
<Attempt key = {index} attempt = {a} i = {index}
28-
setSelectedAttempt = {setSelectedAttempt} setIsList = {setIsList}/>))}
29+
setSelectedAttempt = {setSelectedAttempt} setIsList = {setIsList}/>))} */}
2930
</div>:
3031
<AttemptView attempt = {selectedAttempt} setIsList = {setIsList}/>
3132
}

HistoryService/server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ const port = config.port;
77
const server = http.createServer(app);
88

99
server.listen(port);
10+
11+
const routes = require("./Routes/HistoryRoutes");
12+
app.use("/history", routes);

MatchingService/controllers/matchingController.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,15 @@ async function getSession(req, res, next) {
8585
async function endSession(req, res, next) {
8686
try {
8787
const sessionId = req.params.sessionId;
88-
88+
const sessionInfo = await getMatchedPairBySessionId(sessionId);
8989
const isEnded = await matchingDB.endSession(sessionId);
9090

9191
if (isEnded) {
9292
await res.status(200).json({ status: 'success', message: 'Session ended successfully' });
93+
await addUserAttemptToHistoryDatabase(sessionInfo.id1,
94+
sessionInfo.id2,
95+
sessionInfo.sessionId,
96+
sessionInfo.questionId);
9397

9498
} else {
9599
await res.status(500).json({ status: 'error', message: 'Failed to end session' });

0 commit comments

Comments
 (0)