From 27f214745817e051141f4808baa454a7284e965c Mon Sep 17 00:00:00 2001 From: nandudharmapalan Date: Wed, 22 Jul 2020 18:24:05 -0400 Subject: [PATCH 1/2] #64 Feedback dialogs fix, dashboard rating fix --- client/src/components/CustomTables.js | 61 ++++++++++++++++--- .../dialogs/feedback/AnythingElseDialog.js | 2 +- client/src/dialogs/feedback/OverallDialog.js | 5 +- .../dialogs/feedback/RecommendationsDialog.js | 2 +- client/src/dialogs/feedback/ReviewDialog.js | 14 ++--- .../src/dialogs/feedback/StrengthsDialog.js | 2 +- .../src/dialogs/feedback/WeaknessesDialog.js | 2 +- server/interview/interview.service.js | 4 +- 8 files changed, 71 insertions(+), 21 deletions(-) diff --git a/client/src/components/CustomTables.js b/client/src/components/CustomTables.js index 1de9e16..fd056cb 100644 --- a/client/src/components/CustomTables.js +++ b/client/src/components/CustomTables.js @@ -1,5 +1,4 @@ import React, { useState, useContext, useEffect } from "react"; - import { makeStyles } from "@material-ui/core/styles"; import { Grid, @@ -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"; @@ -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 = [ @@ -69,7 +67,6 @@ function formatDate(unformattedDate) { ]; const dayIndex = unformattedDate.getDay(); const dayName = days[dayIndex]; - //Thursday , April 30, 2020 return dayName + " , " + monthName + " " + date + ", " + year; } @@ -77,23 +74,73 @@ 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; diff --git a/client/src/dialogs/feedback/AnythingElseDialog.js b/client/src/dialogs/feedback/AnythingElseDialog.js index 8fc8a0e..c2cd3c8 100644 --- a/client/src/dialogs/feedback/AnythingElseDialog.js +++ b/client/src/dialogs/feedback/AnythingElseDialog.js @@ -33,7 +33,7 @@ const AnythingElseDialog = ({ onClose, onSubmitClick, match }) => { if (result.anythingElse) { setAnswerText(result.anythingElse); } - }); + }).catch(err => {}); }, [match.params.id]); const onTextInputChange = (value) => { diff --git a/client/src/dialogs/feedback/OverallDialog.js b/client/src/dialogs/feedback/OverallDialog.js index af93b68..5960a9c 100644 --- a/client/src/dialogs/feedback/OverallDialog.js +++ b/client/src/dialogs/feedback/OverallDialog.js @@ -63,7 +63,8 @@ const OverallDialog = ({ onClose, onNextQuestionClick, match }) => { if (result.overallScore) { setCurrentRadioButtonSelection(result.overallScore); } - }); + }) + .catch(err => {}); }, [match.params.id]); const handleClose = () => { @@ -72,7 +73,7 @@ const OverallDialog = ({ onClose, onNextQuestionClick, match }) => { }; const handleRadioButtonClick = (e) => { - setCurrentRadioButtonSelection(e.target.value.toString()); + if (e.target.value) setCurrentRadioButtonSelection(e.target.value.toString()); }; const nextButtonClick = () => { diff --git a/client/src/dialogs/feedback/RecommendationsDialog.js b/client/src/dialogs/feedback/RecommendationsDialog.js index ee5b1b2..dc5c8cf 100644 --- a/client/src/dialogs/feedback/RecommendationsDialog.js +++ b/client/src/dialogs/feedback/RecommendationsDialog.js @@ -40,7 +40,7 @@ const RecommendationsDialog = ({ if (result.recommendations) { setAnswerText(result.recommendations); } - }); + }).catch(err => {}); }, [match.params.id]); const handleClose = () => { diff --git a/client/src/dialogs/feedback/ReviewDialog.js b/client/src/dialogs/feedback/ReviewDialog.js index b6cf036..7933983 100644 --- a/client/src/dialogs/feedback/ReviewDialog.js +++ b/client/src/dialogs/feedback/ReviewDialog.js @@ -112,7 +112,7 @@ const ReviewDialog = ({ setProblemSolvingSelection(review.problemSolvingSkills); } } - }); + }).catch(err => {}); }, [match.params.id]); const handleClose = () => { @@ -158,27 +158,27 @@ 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") => { diff --git a/client/src/dialogs/feedback/StrengthsDialog.js b/client/src/dialogs/feedback/StrengthsDialog.js index b5bc85a..804ec32 100644 --- a/client/src/dialogs/feedback/StrengthsDialog.js +++ b/client/src/dialogs/feedback/StrengthsDialog.js @@ -40,7 +40,7 @@ const StrengthsDialog = ({ if (result.strengths) { setAnswerText(result.strengths); } - }); + }).catch(err => {}); }, [match.params.id]); const handleClose = () => { diff --git a/client/src/dialogs/feedback/WeaknessesDialog.js b/client/src/dialogs/feedback/WeaknessesDialog.js index 2b8b032..e8fe821 100644 --- a/client/src/dialogs/feedback/WeaknessesDialog.js +++ b/client/src/dialogs/feedback/WeaknessesDialog.js @@ -40,7 +40,7 @@ const WeaknessesDialog = ({ if (result.weaknesses) { setAnswerText(result.weaknesses); } - }); + }).catch(err => {}); }, [match.params.id]); const handleClose = () => { diff --git a/server/interview/interview.service.js b/server/interview/interview.service.js index 6d008d0..58f9d9b 100644 --- a/server/interview/interview.service.js +++ b/server/interview/interview.service.js @@ -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; if (feedbackBody.review) participant.feedbackReceived.review = feedbackBody.review; @@ -231,7 +234,6 @@ async function getFeedbackGiven(userId, interviewId) { break; } } - return feedbackReceived; } From de06bfe55f36587f9c1386061411d2ccb92395ba Mon Sep 17 00:00:00 2001 From: nandudharmapalan Date: Wed, 22 Jul 2020 18:30:16 -0400 Subject: [PATCH 2/2] #64 Formated files --- client/src/components/CustomTables.js | 25 ++++++++++++++----- .../dialogs/feedback/AnythingElseDialog.js | 3 ++- client/src/dialogs/feedback/OverallDialog.js | 5 ++-- .../dialogs/feedback/RecommendationsDialog.js | 3 ++- client/src/dialogs/feedback/ReviewDialog.js | 6 +++-- .../src/dialogs/feedback/StrengthsDialog.js | 3 ++- .../src/dialogs/feedback/WeaknessesDialog.js | 3 ++- server/interview/interview.service.js | 21 ++++++++++------ 8 files changed, 48 insertions(+), 21 deletions(-) diff --git a/client/src/components/CustomTables.js b/client/src/components/CustomTables.js index fd056cb..bf7ba15 100644 --- a/client/src/components/CustomTables.js +++ b/client/src/components/CustomTables.js @@ -108,12 +108,25 @@ export function PastPracticeTable(props) { 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; + 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; } } }); diff --git a/client/src/dialogs/feedback/AnythingElseDialog.js b/client/src/dialogs/feedback/AnythingElseDialog.js index c2cd3c8..0bc6824 100644 --- a/client/src/dialogs/feedback/AnythingElseDialog.js +++ b/client/src/dialogs/feedback/AnythingElseDialog.js @@ -33,7 +33,8 @@ const AnythingElseDialog = ({ onClose, onSubmitClick, match }) => { if (result.anythingElse) { setAnswerText(result.anythingElse); } - }).catch(err => {}); + }) + .catch((err) => {}); }, [match.params.id]); const onTextInputChange = (value) => { diff --git a/client/src/dialogs/feedback/OverallDialog.js b/client/src/dialogs/feedback/OverallDialog.js index 5960a9c..5ffd79d 100644 --- a/client/src/dialogs/feedback/OverallDialog.js +++ b/client/src/dialogs/feedback/OverallDialog.js @@ -64,7 +64,7 @@ const OverallDialog = ({ onClose, onNextQuestionClick, match }) => { setCurrentRadioButtonSelection(result.overallScore); } }) - .catch(err => {}); + .catch((err) => {}); }, [match.params.id]); const handleClose = () => { @@ -73,7 +73,8 @@ const OverallDialog = ({ onClose, onNextQuestionClick, match }) => { }; const handleRadioButtonClick = (e) => { - if (e.target.value) setCurrentRadioButtonSelection(e.target.value.toString()); + if (e.target.value) + setCurrentRadioButtonSelection(e.target.value.toString()); }; const nextButtonClick = () => { diff --git a/client/src/dialogs/feedback/RecommendationsDialog.js b/client/src/dialogs/feedback/RecommendationsDialog.js index dc5c8cf..b65baa5 100644 --- a/client/src/dialogs/feedback/RecommendationsDialog.js +++ b/client/src/dialogs/feedback/RecommendationsDialog.js @@ -40,7 +40,8 @@ const RecommendationsDialog = ({ if (result.recommendations) { setAnswerText(result.recommendations); } - }).catch(err => {}); + }) + .catch((err) => {}); }, [match.params.id]); const handleClose = () => { diff --git a/client/src/dialogs/feedback/ReviewDialog.js b/client/src/dialogs/feedback/ReviewDialog.js index 7933983..59e4989 100644 --- a/client/src/dialogs/feedback/ReviewDialog.js +++ b/client/src/dialogs/feedback/ReviewDialog.js @@ -112,7 +112,8 @@ const ReviewDialog = ({ setProblemSolvingSelection(review.problemSolvingSkills); } } - }).catch(err => {}); + }) + .catch((err) => {}); }, [match.params.id]); const handleClose = () => { @@ -158,7 +159,8 @@ const ReviewDialog = ({ }; const communicationSkillsOnChange = (e) => { - if (e.target.value) setCommunicationSkillsSelection(e.target.value.toString()); + if (e.target.value) + setCommunicationSkillsSelection(e.target.value.toString()); }; const codeEfficiencyOnChange = (e) => { diff --git a/client/src/dialogs/feedback/StrengthsDialog.js b/client/src/dialogs/feedback/StrengthsDialog.js index 804ec32..deeaa0a 100644 --- a/client/src/dialogs/feedback/StrengthsDialog.js +++ b/client/src/dialogs/feedback/StrengthsDialog.js @@ -40,7 +40,8 @@ const StrengthsDialog = ({ if (result.strengths) { setAnswerText(result.strengths); } - }).catch(err => {}); + }) + .catch((err) => {}); }, [match.params.id]); const handleClose = () => { diff --git a/client/src/dialogs/feedback/WeaknessesDialog.js b/client/src/dialogs/feedback/WeaknessesDialog.js index e8fe821..60c645d 100644 --- a/client/src/dialogs/feedback/WeaknessesDialog.js +++ b/client/src/dialogs/feedback/WeaknessesDialog.js @@ -40,7 +40,8 @@ const WeaknessesDialog = ({ if (result.weaknesses) { setAnswerText(result.weaknesses); } - }).catch(err => {}); + }) + .catch((err) => {}); }, [match.params.id]); const handleClose = () => { diff --git a/server/interview/interview.service.js b/server/interview/interview.service.js index 58f9d9b..9315747 100644 --- a/server/interview/interview.service.js +++ b/server/interview/interview.service.js @@ -173,15 +173,22 @@ async function createFeedback(userId, interviewId, feedbackBody) { //Current user giving to other interview participant if (user.toString() !== userId.toString()) { if (participant.feedbackReceived === undefined) { - participant.feedbackReceived = {} + participant.feedbackReceived = {}; } if (feedbackBody) { - if (feedbackBody.overallScore) participant.feedbackReceived.overallScore = feedbackBody.overallScore; - if (feedbackBody.review) participant.feedbackReceived.review = feedbackBody.review; - if (feedbackBody.strengths) participant.feedbackReceived.strengths = feedbackBody.strengths; - if (feedbackBody.weaknesses) participant.feedbackReceived.weaknesses = feedbackBody.weaknesses; - if (feedbackBody.recommendations) participant.feedbackReceived.recommendations = feedbackBody.recommendations; - if (feedbackBody.anythingElse) participant.feedbackReceived.anythingElse = feedbackBody.anythingElse; + if (feedbackBody.overallScore) + participant.feedbackReceived.overallScore = feedbackBody.overallScore; + if (feedbackBody.review) + participant.feedbackReceived.review = feedbackBody.review; + if (feedbackBody.strengths) + participant.feedbackReceived.strengths = feedbackBody.strengths; + if (feedbackBody.weaknesses) + participant.feedbackReceived.weaknesses = feedbackBody.weaknesses; + if (feedbackBody.recommendations) + participant.feedbackReceived.recommendations = + feedbackBody.recommendations; + if (feedbackBody.anythingElse) + participant.feedbackReceived.anythingElse = feedbackBody.anythingElse; } break; }