Skip to content

Commit

Permalink
Merge pull request #66 from hatchways/iss64-feedback-bug
Browse files Browse the repository at this point in the history
#64 Feedback dialogs fix, dashboard rating fix
  • Loading branch information
Nandu-D authored Jul 23, 2020
2 parents 0caeb87 + 6bfc4b4 commit d4aaafe
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 21 deletions.
74 changes: 67 additions & 7 deletions client/src/components/CustomTables.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState, useContext, useEffect } from "react";

import { makeStyles } from "@material-ui/core/styles";
import {
Grid,
Expand Down Expand Up @@ -27,7 +26,6 @@ const pastPracticeTableStyles = makeStyles({
});

function formatAMPM(date) {
console.log("date: " + date);
let hours = date.getHours();
let minutes = date.getMinutes();
const amPm = hours >= 12 ? "PM" : "AM";
Expand All @@ -39,7 +37,7 @@ function formatAMPM(date) {
}

function formatDate(unformattedDate) {
//Thursday , April 30, 2020
//Format : "Thursday , April 30, 2020"
const year = unformattedDate.getFullYear();
const date = unformattedDate.getDate();
const months = [
Expand Down Expand Up @@ -69,31 +67,93 @@ function formatDate(unformattedDate) {
];
const dayIndex = unformattedDate.getDay();
const dayName = days[dayIndex];
//Thursday , April 30, 2020
return dayName + " , " + monthName + " " + date + ", " + year;
}

export function PastPracticeTable(props) {
const classes = pastPracticeTableStyles();
const location = useLocation();
const [completedInterviewsList, setCompletedInterviewsList] = useState([]);
const [inLobby, setInLobby] = useState(true);
const { user } = useContext(UserContext);
useEffect(() => {
fetch("interviews/completed")
.then((result) => result.json())
.then((data) => {
data.forEach((element) => {
let startDate = new Date(element.startTime);
let endDate = new Date(element.endTime);
const startDate = new Date(element.startTime);
const endDate = new Date(element.endTime);
element.heldOnDate = formatDate(startDate);
element.heldOnTime =
formatAMPM(startDate) + " - " + formatAMPM(endDate);
const {
codingRating,
communicationRating,
} = extractCodingAndCommunicationRating(element, user.id);
element.codingRating = codingRating;
element.communicationRating = communicationRating;
setCompletedInterviewsList((prevArray) => [...prevArray, element]);
});
})
.catch((err) => console.error(err));
}, [location.pathname]);

const extractCodingAndCommunicationRating = (interview, userId) => {
let codingRating, communicationRating;
const participants = interview.participants;
if (participants) {
participants.forEach((participant) => {
if (participant.user && participant.user === userId) {
if (
participant.feedbackReceived &&
participant.feedbackReceived.review
) {
const review = participant.feedbackReceived.review;
const {
communicationSkills,
codeEfficiency,
codeOrganization,
debuggingSkills,
problemSolvingSkills,
speed,
} = review;
communicationRating = convertReviewPointsToScore(
communicationSkills
);
const codeRatingAverage =
(convertReviewPointsToScore(codeEfficiency) +
convertReviewPointsToScore(codeOrganization) +
convertReviewPointsToScore(debuggingSkills) +
convertReviewPointsToScore(problemSolvingSkills) +
convertReviewPointsToScore(speed)) /
5;
codingRating = codeRatingAverage;
}
}
});
}
return {
codingRating: codingRating,
communicationRating: communicationRating,
};
};

const convertReviewPointsToScore = (reviewPoint) => {
switch (reviewPoint) {
case "needs improvement":
return 1;
case "satisfactory":
return 2;
case "good":
return 3;
case "great":
return 4;
case "excellent":
return 5;
default:
return undefined;
}
};

function RatingComponent(props) {
const isRatingProvided = props.isRatingProvided;
const value = props.value;
Expand Down
3 changes: 2 additions & 1 deletion client/src/dialogs/feedback/AnythingElseDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const AnythingElseDialog = ({ onClose, onSubmitClick, match }) => {
if (result.anythingElse) {
setAnswerText(result.anythingElse);
}
});
})
.catch((err) => {});
}, [match.params.id]);

const onTextInputChange = (value) => {
Expand Down
5 changes: 3 additions & 2 deletions client/src/dialogs/feedback/OverallDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const OverallDialog = ({ onClose, onNextQuestionClick, match }) => {
setCurrentRadioButtonSelection(result.overallScore);
}
})
.catch((err) => console.log(err));
.catch((err) => {});
}, [match.params.id]);

const handleClose = () => {
Expand All @@ -73,7 +73,8 @@ const OverallDialog = ({ onClose, onNextQuestionClick, match }) => {
};

const handleRadioButtonClick = (e) => {
setCurrentRadioButtonSelection(e.target.value.toString());
if (e.target.value)
setCurrentRadioButtonSelection(e.target.value.toString());
};

const nextButtonClick = () => {
Expand Down
3 changes: 2 additions & 1 deletion client/src/dialogs/feedback/RecommendationsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const RecommendationsDialog = ({
if (result.recommendations) {
setAnswerText(result.recommendations);
}
});
})
.catch((err) => {});
}, [match.params.id]);

const handleClose = () => {
Expand Down
16 changes: 9 additions & 7 deletions client/src/dialogs/feedback/ReviewDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ const ReviewDialog = ({
setProblemSolvingSelection(review.problemSolvingSkills);
}
}
});
})
.catch((err) => {});
}, [match.params.id]);

const handleClose = () => {
Expand Down Expand Up @@ -158,27 +159,28 @@ const ReviewDialog = ({
};

const communicationSkillsOnChange = (e) => {
setCommunicationSkillsSelection(e.target.value.toString());
if (e.target.value)
setCommunicationSkillsSelection(e.target.value.toString());
};

const codeEfficiencyOnChange = (e) => {
setCodeEfficiencySelection(e.target.value.toString());
if (e.target.value) setCodeEfficiencySelection(e.target.value.toString());
};

const codeOrganizationOnChange = (e) => {
setCodeOrganizationSelection(e.target.value.toString());
if (e.target.value) setCodeOrganizationSelection(e.target.value.toString());
};

const speedOnChange = (e) => {
setSpeedSelection(e.target.value.toString());
if (e.target.value) setSpeedSelection(e.target.value.toString());
};

const debuggingSkillsOnChange = (e) => {
setDebuggingSkillsSelection(e.target.value.toString());
if (e.target.value) setDebuggingSkillsSelection(e.target.value.toString());
};

const problemSolvingOnChange = (e) => {
setProblemSolvingSelection(e.target.value.toString());
if (e.target.value) setProblemSolvingSelection(e.target.value.toString());
};

const handleSnackbarOpen = (message, severity = "error") => {
Expand Down
3 changes: 2 additions & 1 deletion client/src/dialogs/feedback/StrengthsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const StrengthsDialog = ({
if (result.strengths) {
setAnswerText(result.strengths);
}
});
})
.catch((err) => {});
}, [match.params.id]);

const handleClose = () => {
Expand Down
3 changes: 2 additions & 1 deletion client/src/dialogs/feedback/WeaknessesDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const WeaknessesDialog = ({
if (result.weaknesses) {
setAnswerText(result.weaknesses);
}
});
})
.catch((err) => {});
}, [match.params.id]);

const handleClose = () => {
Expand Down
4 changes: 3 additions & 1 deletion server/interview/interview.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ async function createFeedback(userId, interviewId, feedbackBody) {
const user = participant.user;
//Current user giving to other interview participant
if (user.toString() !== userId.toString()) {
if (participant.feedbackReceived === undefined) {
participant.feedbackReceived = {};
}
if (feedbackBody) {
if (feedbackBody.overallScore)
participant.feedbackReceived.overallScore = feedbackBody.overallScore;
Expand Down Expand Up @@ -238,7 +241,6 @@ async function getFeedbackGiven(userId, interviewId) {
break;
}
}

return feedbackReceived;
}

Expand Down

0 comments on commit d4aaafe

Please sign in to comment.