From dfd500020a9ef5d048c0d2cc5436875dd6cdb26d Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Sat, 8 Apr 2023 14:39:30 -0400 Subject: [PATCH 01/33] set up index page --- src/App.js | 2 + src/components/Layout/Header.js | 2 +- .../Questionnaires/CreateQuestionnaire.js | 183 ++++++++++++++++ .../Questionnaires/DeleteQuestionnaire.js | 62 ++++++ .../Questionnaires/Questionnaires.js | 154 ++++++++++++++ .../Questionnaires/UpdateQuestionnaire.js | 197 ++++++++++++++++++ .../Questionnaires/questionnaireColumns.js | 72 +++++++ src/components/Questionnaires/util.js | 55 +++++ src/components/UI/Icons.js | 9 + 9 files changed, 735 insertions(+), 1 deletion(-) create mode 100644 src/components/Questionnaires/CreateQuestionnaire.js create mode 100644 src/components/Questionnaires/DeleteQuestionnaire.js create mode 100644 src/components/Questionnaires/Questionnaires.js create mode 100644 src/components/Questionnaires/UpdateQuestionnaire.js create mode 100644 src/components/Questionnaires/questionnaireColumns.js create mode 100644 src/components/Questionnaires/util.js diff --git a/src/App.js b/src/App.js index 3132f60..ad22e5b 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom"; import Home from "./components/Layout/Home"; import RootLayout from "./components/Layout/Root"; import Users from "./components/Users/Users"; +import Questionnaires from "./components/Questionnaires/Questionnaires"; function App() { const router = createBrowserRouter([ @@ -12,6 +13,7 @@ function App() { children: [ { index: true, element: }, { path: "users", element: }, + { path: "questionnaires", element: }, ], }, ]); diff --git a/src/components/Layout/Header.js b/src/components/Layout/Header.js index 3ca8a32..df353b9 100644 --- a/src/components/Layout/Header.js +++ b/src/components/Layout/Header.js @@ -60,7 +60,7 @@ const Header = () => { Assignments - + Questionnaire diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js new file mode 100644 index 0000000..0193b95 --- /dev/null +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -0,0 +1,183 @@ +import {Form, Formik} from "formik"; +import {useEffect, useState} from "react"; +import {Button, Col, InputGroup, Modal, Row} from "react-bootstrap"; +import {useDispatch} from "react-redux"; +import * as Yup from "yup"; +import useAPI from "../../hooks/use-api"; +import {alertActions} from "../../store/alert"; +import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; +import FormInput from "../UI/Form/FormInput"; +import FormSelect from "../UI/Form/FormSelect"; +import {emailOptions, transformInstitutionsResponse, transformRolesResponse, transformUserRequest,} from "./util"; + +// Get the logged-in user from the session +const loggedInUser = null; + +const initialValues = { + name: "", + email: "", + firstName: "", + lastName: "", + emailPreferences: [], + institution: "", + role: "", +}; + +const validationSchema = Yup.object({ + name: Yup.string() + .required("Required") + .lowercase("Username must be lowercase") + .min(3, "Username must be at least 3 characters") + .max(20, "Username must be at most 20 characters"), + email: Yup.string().required("Required").email("Invalid email format"), + firstName: Yup.string().required("Required").nonNullable(), + lastName: Yup.string().required("Required").nonNullable(), + role: Yup.string().required("Required").nonNullable(), + institution: Yup.string().required("Required").nonNullable(), +}); + +const CreateUser = ({onClose}) => { + const dispatch = useDispatch(); + const [show, setShow] = useState(true); + const {data: roles, sendRequest: fetchRoles} = useAPI(); + const {data: institutions, sendRequest: fetchInstitutions} = useAPI(); + const { + data: createdUser, + error: userError, + sendRequest: createUser, + } = useAPI(); + + useEffect(() => { + fetchRoles({url: "/roles", transformResponse: transformRolesResponse}); + fetchInstitutions({ + url: "/institutions", + transformResponse: transformInstitutionsResponse, + }); + }, [fetchRoles, fetchInstitutions]); + + useEffect(() => { + if (userError) { + dispatch(alertActions.showAlert({ + variant: "danger", + message: userError + })); + } + }, [userError, dispatch]); + + useEffect(() => { + if (createdUser.length > 0) { + setShow(false); + onClose(createdUser[0]); + } + }, [userError, createdUser, onClose]); + + const onSubmit = (values, submitProps) => { + createUser({ + url: "/users", + method: "post", + data: {...values, parent: loggedInUser}, + transformRequest: transformUserRequest, + }); + submitProps.resetForm(); + submitProps.setSubmitting(false); + }; + + const handleClose = () => { + setShow(false); + onClose(); + }; + + return ( + + + Create User + + + + {(formik) => { + return ( +
+ Role + } + /> + @ + } + /> + + + + + + + + + Institution + + } + /> + + + + + + + ); + }} +
+
+
+ ); +}; + +export default CreateUser; diff --git a/src/components/Questionnaires/DeleteQuestionnaire.js b/src/components/Questionnaires/DeleteQuestionnaire.js new file mode 100644 index 0000000..bab10fd --- /dev/null +++ b/src/components/Questionnaires/DeleteQuestionnaire.js @@ -0,0 +1,62 @@ +import {useEffect, useState} from "react"; +import {Button, Modal} from "react-bootstrap"; +import {useDispatch} from "react-redux"; +import useAPI from "../../hooks/use-api"; +import {alertActions} from "../../store/alert"; + +const DeleteUser = ({userData, onClose}) => { + const dispatch = useDispatch(); + const { + data: deletedUser, + error: userError, + sendRequest: deleteUser, + } = useAPI(); + const [show, setShow] = useState(true); + + const deleteHandler = () => + deleteUser({url: `/users/${userData.id}`, method: "DELETE"}); + + useEffect(() => { + if (userError) { + dispatch(alertActions.showAlert({ + variant: "danger", + message: userError, + })); + } + }, [userError, dispatch]); + + useEffect(() => { + if (deletedUser.length > 0) { + setShow(false); + onClose(deletedUser[0]); + } + }, [deletedUser, onClose]); + + const closeHandler = () => { + setShow(false); + onClose(); + }; + + return ( + + + Delete User + + +

+ Are you sure you want to delete user {userData.name}? +

+
+ + + + +
+ ); +}; + +export default DeleteUser; diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js new file mode 100644 index 0000000..0df1c60 --- /dev/null +++ b/src/components/Questionnaires/Questionnaires.js @@ -0,0 +1,154 @@ +import {useCallback, useEffect, useMemo, useState} from "react"; +import {Button, Col, Container, Row} from "react-bootstrap"; +import {useDispatch} from "react-redux"; +import useAPI from "../../hooks/use-api"; +import {alertActions} from "../../store/alert"; +import {AddQuestionnaireIcon} from "../UI/Icons"; +import Table from "../UI/Table/Table"; +import CreateQuestionnaire from "./CreateQuestionnaire"; +import DeleteQuestionnaire from "./DeleteQuestionnaire"; +import UpdateQuestionnaire from "./UpdateQuestionnaire"; +import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; + +const Questionnaires = () => { + const dispatch = useDispatch(); + const { + error, + isLoading, + data: questionnaireData, + setData: setQuestionnaireData, + sendRequest: fetchQuestionnaires, + } = useAPI(); + + const [showCreate, setShowCreate] = useState(false); + const [showUpdate, setShowUpdate] = useState({ + visible: false, + data: {}, + }); + const [showDeleteConfirmation, setShowDeleteConfirmation] = useState({ + visible: false, + data: {}, + }); + + useEffect(() => fetchQuestionnaires({url: "/questionnaires", method: "get"}), [fetchQuestionnaires]); + + // Error alert + useEffect(() => { + if (error) { + dispatch(alertActions.showAlert({ + variant: "danger", + message: error + })); + } + }, [error, dispatch]); + + const onCreateQuestionnaireHandler = useCallback( + (questionnaire) => { + if (questionnaire && questionnaire.name) { + console.log(questionnaire); + setQuestionnaireData((prevData) => [...prevData, questionnaire]); + dispatch(alertActions.showAlert({ + variant: "success", + message: `Questionnaire ${questionnaire.name} created successfully!` + })); + } + setShowCreate(false); + }, + [setQuestionnaireData, dispatch] + ); + + const onUpdateQuestionnaireHandler = useCallback( + (updatedQuestionnaire) => { + if (updatedQuestionnaire && updatedQuestionnaire.name !== undefined) { + setQuestionnaireData((prevData) => [ + ...prevData.filter((questionnaire) => questionnaire.id !== updatedQuestionnaire.id), + updatedQuestionnaire, + ]); + dispatch(alertActions.showAlert({ + variant: "success", + message: `Questionnaire ${updatedQuestionnaire.name} updated successfully!` + })); + } + setShowUpdate({visible: false, data: {}}); + }, + [setQuestionnaireData, dispatch] + ); + + const onDeleteQuestionnaireHandler = useCallback( + (id, name, status) => { + if (status) { + setQuestionnaireData((prevData) => { + return prevData.filter((questionnaire) => questionnaire.id !== id); + }); + dispatch(alertActions.showAlert({ + variant: "success", + message: `Questionnaire ${name} deleted successfully!` + })); + } + setShowDeleteConfirmation({visible: false, data: {}}); + }, + [setQuestionnaireData, dispatch] + ); + + const onEditHandle = (row) => + setShowUpdate({visible: true, data: row.original}); + const onDeleteHandle = (row) => + setShowDeleteConfirmation({visible: true, data: row.original}); + + const tableColumns = useMemo( + () => QUESTIONNAIRE_COLUMNS(onDeleteHandle, onEditHandle), + [] + ); + const tableData = useMemo( + () => (isLoading ? [] : questionnaireData), + [questionnaireData, isLoading] + ); + const initialState = {hiddenColumns: ["id", "institution"]}; + + return ( + + + +

Manage Questionnaire

+ +
+
+ + + + + {showCreate && } + {showUpdate.visible && ( + + )} + {showDeleteConfirmation.visible && ( + + )} + + + + + + ); +}; + +export default Questionnaires; diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js new file mode 100644 index 0000000..df96a41 --- /dev/null +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -0,0 +1,197 @@ +import {Form, Formik} from "formik"; +import {useEffect, useState} from "react"; +import {Button, Col, InputGroup, Modal, Row} from "react-bootstrap"; +import {useDispatch} from "react-redux"; +import * as Yup from "yup"; +import useAPI from "../../hooks/use-api"; +import {alertActions} from "../../store/alert"; +import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; +import FormInput from "../UI/Form/FormInput"; +import FormSelect from "../UI/Form/FormSelect"; +import {emailOptions, transformInstitutionsResponse, transformRolesResponse, transformUserRequest,} from "./util"; + +// Get the logged-in user from the session +const loggedInUser = null; +const initialValues = (user) => { + const [lastName, firstName] = user.fullname.split(","); + const emailPreferences = [ + "email_on_review", + "email_on_review_of_review", + "email_on_submission", + ].filter((pref) => user[pref]); + + return { + name: user.name, + email: user.email, + firstName: firstName.trim(), + lastName: lastName.trim(), + emailPreferences: emailPreferences, + institution: user.institution.id ? user.institution.id : "", + role: user.role.id, + }; +}; + +const validationSchema = Yup.object({ + name: Yup.string() + .required("Required") + .lowercase("Username must be lowercase") + .min(3, "Username must be at least 3 characters") + .max(20, "Username must be at most 20 characters"), + email: Yup.string().required("Required").email("Invalid email format"), + firstName: Yup.string().required("Required").nonNullable(), + lastName: Yup.string().required("Required").nonNullable(), + role: Yup.string().required("Required").nonNullable(), + institution: Yup.string().required("Required").nonNullable(), +}); + +const UpdateUser = ({userData, onClose}) => { + const [show, setShow] = useState(true); + const {data: roles, sendRequest: fetchRoles} = useAPI(); + const {data: institutions, sendRequest: fetchInstitutions} = useAPI(); + const { + data: updatedUser, + error: userError, + sendRequest: updateUser, + } = useAPI(); + const dispatch = useDispatch(); + + useEffect(() => { + fetchRoles({url: "/roles", transformResponse: transformRolesResponse}); + fetchInstitutions({ + url: "/institutions", + transformResponse: transformInstitutionsResponse, + }); + }, [fetchRoles, fetchInstitutions]); + + // Close the modal if the user is updated successfully and pass the updated user to the parent component + useEffect(() => { + if (updatedUser.length > 0) { + console.log("user updated"); + onClose(updatedUser[0]); + setShow(false); + } + }, [userError, updatedUser, onClose]); + + useEffect(() => { + if (userError) { + dispatch(alertActions.showAlert({ + variant: "danger", + message: userError, + })); + } + }, [userError, dispatch]); + + const onSubmit = (values, submitProps) => { + const userId = userData.id; + updateUser({ + url: `/users/${userId}`, + method: "patch", + data: {...values, parent: loggedInUser}, + transformRequest: transformUserRequest, + }); + submitProps.resetForm(); + submitProps.setSubmitting(false); + }; + + const handleClose = () => { + setShow(false); + onClose(); + }; + + return ( + + + Update User + + + {userError &&

{userError}

} + + {(formik) => { + return ( +
+ Role + } + /> + @ + } + /> + + + + + + + + Institution + + } + /> + + + + + + + ); + }} +
+
+
+ ); +}; + +export default UpdateUser; diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js new file mode 100644 index 0000000..b740423 --- /dev/null +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -0,0 +1,72 @@ +import {Fragment} from "react"; +import {Button} from "react-bootstrap"; +import {Link} from "react-router-dom"; +import {EditIcon, RemoveUserIcon} from "../UI/Icons"; + +export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ + { + Header: "Id", + accessor: "id", + disableFilters: true, + }, + { + Header: "Name", + accessor: "name", + Cell: ({row}) => ( + {row.original.name} + ), + }, + { + Header: "Type", + accessor: "type", + }, + { + Header: "Updated At", + accessor: "updated_at", + }, + { + Header: "Instructor", + accessor: (d) => d.instructor.name, + disableFilters: true, + }, + { + Header: "Min Question Score", + accessor: (d) => d.min_question_score, + disableFilters: true, + }, + { + Header: "Max Question Score", + accessor: (d) => d.max_question_score, + disableFilters: true, + }, + { + Header: "Private", + accessor: (d) => d.private, + disableFilters: true, + }, + { + id: "actions", + Header: "Actions", + Cell: ({row}) => { + return ( + + + + + ); + }, + }, +]; diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js new file mode 100644 index 0000000..854e890 --- /dev/null +++ b/src/components/Questionnaires/util.js @@ -0,0 +1,55 @@ +export const emailOptions = [ + {label: "When someone else reviews my work", value: "email_on_review"}, + { + label: "When someone else submits work I am assigned to review", + value: "email_on_submission", + }, + { + label: "When someone else reviews one of my reviews (meta-reviews my work)", + value: "email_on_review_of_review", + }, +]; + +export const transformInstitutionsResponse = (institutions) => { + let institutionsData = [{key: "Select an Institution", value: ""}]; + institutions = JSON.parse(institutions); + institutionsData = institutionsData.concat( + institutions.map((institution) => ({ + key: institution.name, + value: institution.id, + })) + ); + return institutionsData; +}; + +export const transformRolesResponse = (roles) => { + let rolesData = [{key: "Select a Role", value: ""}]; + roles = JSON.parse(roles); + rolesData = rolesData.concat( + roles.map((role) => ({ + key: role.name, + value: role.id, + })) + ); + return rolesData; +}; + +export const transformUserRequest = (values, headers) => { + console.log("transformUserRequest", values, headers); + const user = { + name: values.name, + email: values.email, + fullname: values.lastName + ", " + values.firstName, + role_id: values.role, + institution_id: values.institution, + parent_id: values.parent, + email_on_review: values.emailPreferences.includes("email_on_review"), + email_on_submission: values.emailPreferences.includes( + "email_on_submission" + ), + email_on_review_of_review: values.emailPreferences.includes( + "email_on_review_of_review" + ), + }; + return JSON.stringify(user); +}; diff --git a/src/components/UI/Icons.js b/src/components/UI/Icons.js index 57342b5..03c29f8 100644 --- a/src/components/UI/Icons.js +++ b/src/components/UI/Icons.js @@ -26,6 +26,15 @@ export const AddUserIcon = () => { ); }; +export const AddQuestionnaireIcon = () => { + return ( + add + ); +}; + export const InfoIcon = () => { return ( Date: Sat, 8 Apr 2023 21:47:36 -0400 Subject: [PATCH 02/33] create questionnaire changes commited --- .../Questionnaires/CreateQuestionnaire.js | 141 +++++++++--------- .../Questionnaires/UpdateQuestionnaire.js | 13 +- src/components/Questionnaires/util.js | 60 ++------ 3 files changed, 81 insertions(+), 133 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 0193b95..2943f92 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -8,75 +8,68 @@ import {alertActions} from "../../store/alert"; import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; import FormInput from "../UI/Form/FormInput"; import FormSelect from "../UI/Form/FormSelect"; -import {emailOptions, transformInstitutionsResponse, transformRolesResponse, transformUserRequest,} from "./util"; +import { transformQuestionnaireRequest} from "./util"; +// import {FormCheckbox} from "react-bootstrap"; + // Get the logged-in user from the session const loggedInUser = null; const initialValues = { name: "", - email: "", - firstName: "", - lastName: "", - emailPreferences: [], - institution: "", - role: "", + instructor_id: "", + private: false, + min_question_score: 0, + max_question_score: null, + created_at: null, + updated_at: null, + type: "", + display_type: "", + instruction_loc: "" }; + const validationSchema = Yup.object({ name: Yup.string() .required("Required") .lowercase("Username must be lowercase") .min(3, "Username must be at least 3 characters") .max(20, "Username must be at most 20 characters"), - email: Yup.string().required("Required").email("Invalid email format"), - firstName: Yup.string().required("Required").nonNullable(), - lastName: Yup.string().required("Required").nonNullable(), - role: Yup.string().required("Required").nonNullable(), - institution: Yup.string().required("Required").nonNullable(), + }); -const CreateUser = ({onClose}) => { +const CreateQuestionnaire = ({onClose}) => { const dispatch = useDispatch(); const [show, setShow] = useState(true); - const {data: roles, sendRequest: fetchRoles} = useAPI(); - const {data: institutions, sendRequest: fetchInstitutions} = useAPI(); const { - data: createdUser, - error: userError, - sendRequest: createUser, + data: createdQuestionnaire, + error: questionnaireError, + sendRequest: createQuestionnaire, } = useAPI(); - useEffect(() => { - fetchRoles({url: "/roles", transformResponse: transformRolesResponse}); - fetchInstitutions({ - url: "/institutions", - transformResponse: transformInstitutionsResponse, - }); - }, [fetchRoles, fetchInstitutions]); useEffect(() => { - if (userError) { + if (questionnaireError) { dispatch(alertActions.showAlert({ variant: "danger", - message: userError + message: questionnaireError })); } - }, [userError, dispatch]); + }, [questionnaireError, dispatch]); useEffect(() => { - if (createdUser.length > 0) { + if (createdQuestionnaire.length > 0) { setShow(false); - onClose(createdUser[0]); + onClose(createdQuestionnaire[0]); } - }, [userError, createdUser, onClose]); + }, [questionnaireError, createdQuestionnaire, onClose]); const onSubmit = (values, submitProps) => { - createUser({ - url: "/users", + createQuestionnaire({ + url: "/questionnaires", method: "post", data: {...values, parent: loggedInUser}, - transformRequest: transformUserRequest, + transformRequest: transformQuestionnaireRequest, }); submitProps.resetForm(); submitProps.setSubmitting(false); @@ -96,7 +89,7 @@ const CreateUser = ({onClose}) => { backdrop="static" > - Create User + Create Questionnaire { {(formik) => { return (
- Role - } - /> + @ - } + /> + {/* */} + + - - - - - Institution - - } + {/* + */} + @@ -180,4 +175,4 @@ const CreateUser = ({onClose}) => { ); }; -export default CreateUser; +export default CreateQuestionnaire; diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index df96a41..9fbec1f 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -8,7 +8,7 @@ import {alertActions} from "../../store/alert"; import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; import FormInput from "../UI/Form/FormInput"; import FormSelect from "../UI/Form/FormSelect"; -import {emailOptions, transformInstitutionsResponse, transformRolesResponse, transformUserRequest,} from "./util"; +import {transformQuestionnaireRequest,} from "./util"; // Get the logged-in user from the session const loggedInUser = null; @@ -55,13 +55,6 @@ const UpdateUser = ({userData, onClose}) => { } = useAPI(); const dispatch = useDispatch(); - useEffect(() => { - fetchRoles({url: "/roles", transformResponse: transformRolesResponse}); - fetchInstitutions({ - url: "/institutions", - transformResponse: transformInstitutionsResponse, - }); - }, [fetchRoles, fetchInstitutions]); // Close the modal if the user is updated successfully and pass the updated user to the parent component useEffect(() => { @@ -87,7 +80,7 @@ const UpdateUser = ({userData, onClose}) => { url: `/users/${userId}`, method: "patch", data: {...values, parent: loggedInUser}, - transformRequest: transformUserRequest, + transformRequest: transformQuestionnaireRequest, }); submitProps.resetForm(); submitProps.setSubmitting(false); @@ -157,7 +150,7 @@ const UpdateUser = ({userData, onClose}) => { controlId="email-pref" label="Email Preferences" name="emailPreferences" - options={emailOptions} + // options={emailOptions} /> { + console.log("transformQuestionnaireRequest", values, headers); + const questionnaire = { + name: values.name, + instructor_id: values.instructor_id, + min_question_score: values.min_question_score, + max_question_score: values.min_question_score, + instruction_loc: values.instruction_loc + -export const transformInstitutionsResponse = (institutions) => { - let institutionsData = [{key: "Select an Institution", value: ""}]; - institutions = JSON.parse(institutions); - institutionsData = institutionsData.concat( - institutions.map((institution) => ({ - key: institution.name, - value: institution.id, - })) - ); - return institutionsData; -}; -export const transformRolesResponse = (roles) => { - let rolesData = [{key: "Select a Role", value: ""}]; - roles = JSON.parse(roles); - rolesData = rolesData.concat( - roles.map((role) => ({ - key: role.name, - value: role.id, - })) - ); - return rolesData; -}; -export const transformUserRequest = (values, headers) => { - console.log("transformUserRequest", values, headers); - const user = { - name: values.name, - email: values.email, - fullname: values.lastName + ", " + values.firstName, - role_id: values.role, - institution_id: values.institution, - parent_id: values.parent, - email_on_review: values.emailPreferences.includes("email_on_review"), - email_on_submission: values.emailPreferences.includes( - "email_on_submission" - ), - email_on_review_of_review: values.emailPreferences.includes( - "email_on_review_of_review" - ), }; - return JSON.stringify(user); + return JSON.stringify(questionnaire); }; From 8d5feeb5e22fe92f50e75cf343c6857b8466dcd9 Mon Sep 17 00:00:00 2001 From: varundeepakgudhe Date: Sat, 8 Apr 2023 21:58:32 -0400 Subject: [PATCH 03/33] create questionnaire changes commited2 --- src/components/Questionnaires/CreateQuestionnaire.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 2943f92..7b4d57c 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -108,12 +108,12 @@ const CreateQuestionnaire = ({onClose}) => { name="name" /> - {/* */} + /> { name="max_question_score" /> - {/* { label="Display Type" name="display_type" // options={displayTypes} - /> */} + /> Date: Sun, 9 Apr 2023 11:29:21 -0400 Subject: [PATCH 04/33] create questionnaire errors solved, checkbox and formselect are left --- .../Questionnaires/CreateQuestionnaire.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 7b4d57c..c82f151 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -108,17 +108,17 @@ const CreateQuestionnaire = ({onClose}) => { name="name" /> - - */} + {/* + /> */} { name="max_question_score" /> - + /> + /> */} Date: Sun, 9 Apr 2023 20:48:52 -0400 Subject: [PATCH 05/33] create questionnaire resolved formselect --- .../Questionnaires/CreateQuestionnaire.js | 36 ++++++++----- src/components/Questionnaires/util.js | 50 ++++++++++++++++++- 2 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index c82f151..134ae0d 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -8,7 +8,7 @@ import {alertActions} from "../../store/alert"; import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; import FormInput from "../UI/Form/FormInput"; import FormSelect from "../UI/Form/FormSelect"; -import { transformQuestionnaireRequest} from "./util"; +import { q_private,instructors,types,displayTypes,transformQuestionnaireRequest} from "./util"; // import {FormCheckbox} from "react-bootstrap"; @@ -108,16 +108,21 @@ const CreateQuestionnaire = ({onClose}) => { name="name" /> - {/* */} + options={instructors} + inputGroupPrepend={ + Instructor_id + } + /> + {/* */} @@ -134,18 +139,25 @@ const CreateQuestionnaire = ({onClose}) => { name="max_question_score" /> - {/* Questionnaire Type + } /> */} + options={displayTypes} + inputGroupPrepend={ + Display Type + } + + /> { console.log("transformQuestionnaireRequest", values, headers); const questionnaire = { @@ -6,7 +54,7 @@ export const transformQuestionnaireRequest = (values, headers) => { min_question_score: values.min_question_score, max_question_score: values.min_question_score, instruction_loc: values.instruction_loc - + From 720905d1430e52f9c43aeb2d4de2a2ccde9db421 Mon Sep 17 00:00:00 2001 From: varundeepakgudhe Date: Sun, 9 Apr 2023 21:16:22 -0400 Subject: [PATCH 06/33] updated delete questionnaire and very few changes in update questionnaire --- .../Questionnaires/DeleteQuestionnaire.js | 28 +++++++++---------- .../Questionnaires/UpdateQuestionnaire.js | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/Questionnaires/DeleteQuestionnaire.js b/src/components/Questionnaires/DeleteQuestionnaire.js index bab10fd..e942b07 100644 --- a/src/components/Questionnaires/DeleteQuestionnaire.js +++ b/src/components/Questionnaires/DeleteQuestionnaire.js @@ -4,33 +4,33 @@ import {useDispatch} from "react-redux"; import useAPI from "../../hooks/use-api"; import {alertActions} from "../../store/alert"; -const DeleteUser = ({userData, onClose}) => { +const DeleteQuestionnaire = ({questionnaireData, onClose}) => { const dispatch = useDispatch(); const { - data: deletedUser, - error: userError, - sendRequest: deleteUser, + data: deletedQuestionnaire, + error: questionnaireError, + sendRequest: deleteQuestionnaire, } = useAPI(); const [show, setShow] = useState(true); const deleteHandler = () => - deleteUser({url: `/users/${userData.id}`, method: "DELETE"}); + deleteQuestionnaire({url: `/questionnaires/${questionnaireData.id}`, method: "DELETE"}); useEffect(() => { - if (userError) { + if (questionnaireError) { dispatch(alertActions.showAlert({ variant: "danger", - message: userError, + message: questionnaireError, })); } - }, [userError, dispatch]); + }, [questionnaireError, dispatch]); useEffect(() => { - if (deletedUser.length > 0) { + if (deletedQuestionnaire.length > 0) { setShow(false); - onClose(deletedUser[0]); + onClose(deletedQuestionnaire[0]); } - }, [deletedUser, onClose]); + }, [deletedQuestionnaire, onClose]); const closeHandler = () => { setShow(false); @@ -40,11 +40,11 @@ const DeleteUser = ({userData, onClose}) => { return ( - Delete User + Delete Questionnaire

- Are you sure you want to delete user {userData.name}? + Are you sure you want to delete questionnaire {questionnaireData.name}?

@@ -59,4 +59,4 @@ const DeleteUser = ({userData, onClose}) => { ); }; -export default DeleteUser; +export default DeleteQuestionnaire; diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index 9fbec1f..300c000 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -77,7 +77,7 @@ const UpdateUser = ({userData, onClose}) => { const onSubmit = (values, submitProps) => { const userId = userData.id; updateUser({ - url: `/users/${userId}`, + url: `/questionnaires/${userId}`, method: "patch", data: {...values, parent: loggedInUser}, transformRequest: transformQuestionnaireRequest, From 05a7d3da5f0b7ddb2d2bfe5d7e152c49588360d4 Mon Sep 17 00:00:00 2001 From: Michael Fergione Date: Tue, 11 Apr 2023 17:31:24 -0400 Subject: [PATCH 07/33] Add link to dummy json, show update and delete buttons --- src/components/Questionnaires/Questionnaires.js | 3 ++- src/components/Questionnaires/questionnaireColumns.js | 2 +- src/hooks/use-api.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index 0df1c60..a9de285 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,6 +9,7 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; +import record_data from './records.json'; // for testing const Questionnaires = () => { const dispatch = useDispatch(); @@ -30,7 +31,7 @@ const Questionnaires = () => { data: {}, }); - useEffect(() => fetchQuestionnaires({url: "/questionnaires", method: "get"}), [fetchQuestionnaires]); + useEffect(() => fetchQuestionnaires({url: "", method: "get"}), [fetchQuestionnaires]); // Error alert useEffect(() => { diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index b740423..8dcb6fc 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -26,7 +26,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ }, { Header: "Instructor", - accessor: (d) => d.instructor.name, + accessor: (d) => d.instructor, disableFilters: true, }, { diff --git a/src/hooks/use-api.js b/src/hooks/use-api.js index 4877f9b..67f988d 100644 --- a/src/hooks/use-api.js +++ b/src/hooks/use-api.js @@ -1,7 +1,8 @@ import axios from "axios"; import {useCallback, useState} from "react"; -axios.defaults.baseURL = "http://localhost:3000/api/v1"; +//axios.defaults.baseURL = "http://localhost:3000/api/v1"; +axios.defaults.baseURL = "https://api.jsonbin.io/v3/b/64359edaebd26539d0a8ffd1"; axios.defaults.headers.common["Accept"] = "application/json"; axios.defaults.headers.post["Content-Type"] = "application/json"; axios.defaults.headers.put["Content-Type"] = "application/json"; From 2790ae840eba003a250649f74905a3e1f58cb4de Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Sun, 16 Apr 2023 22:37:18 -0400 Subject: [PATCH 08/33] added delete functionality to close #4 --- .../Questionnaires/DeleteQuestionnaire.js | 28 +++++++++---------- .../Questionnaires/Questionnaires.js | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/Questionnaires/DeleteQuestionnaire.js b/src/components/Questionnaires/DeleteQuestionnaire.js index bab10fd..e942b07 100644 --- a/src/components/Questionnaires/DeleteQuestionnaire.js +++ b/src/components/Questionnaires/DeleteQuestionnaire.js @@ -4,33 +4,33 @@ import {useDispatch} from "react-redux"; import useAPI from "../../hooks/use-api"; import {alertActions} from "../../store/alert"; -const DeleteUser = ({userData, onClose}) => { +const DeleteQuestionnaire = ({questionnaireData, onClose}) => { const dispatch = useDispatch(); const { - data: deletedUser, - error: userError, - sendRequest: deleteUser, + data: deletedQuestionnaire, + error: questionnaireError, + sendRequest: deleteQuestionnaire, } = useAPI(); const [show, setShow] = useState(true); const deleteHandler = () => - deleteUser({url: `/users/${userData.id}`, method: "DELETE"}); + deleteQuestionnaire({url: `/questionnaires/${questionnaireData.id}`, method: "DELETE"}); useEffect(() => { - if (userError) { + if (questionnaireError) { dispatch(alertActions.showAlert({ variant: "danger", - message: userError, + message: questionnaireError, })); } - }, [userError, dispatch]); + }, [questionnaireError, dispatch]); useEffect(() => { - if (deletedUser.length > 0) { + if (deletedQuestionnaire.length > 0) { setShow(false); - onClose(deletedUser[0]); + onClose(deletedQuestionnaire[0]); } - }, [deletedUser, onClose]); + }, [deletedQuestionnaire, onClose]); const closeHandler = () => { setShow(false); @@ -40,11 +40,11 @@ const DeleteUser = ({userData, onClose}) => { return ( - Delete User + Delete Questionnaire

- Are you sure you want to delete user {userData.name}? + Are you sure you want to delete questionnaire {questionnaireData.name}?

@@ -59,4 +59,4 @@ const DeleteUser = ({userData, onClose}) => { ); }; -export default DeleteUser; +export default DeleteQuestionnaire; diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index a9de285..0ae375a 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,7 +9,7 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; -import record_data from './records.json'; // for testing +//import record_data from './records.json'; // for testing const Questionnaires = () => { const dispatch = useDispatch(); From 54d5a116859162480e6d3b01ea7f6f35fe5413f5 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Mon, 17 Apr 2023 13:05:50 -0400 Subject: [PATCH 09/33] added questionnaire icons to close #10 --- public/assets/icons/questionnaire-add.png | Bin 0 -> 2399 bytes public/assets/icons/questionnaire-remove.png | Bin 0 -> 3081 bytes .../Questionnaires/questionnaireColumns.js | 4 ++-- src/components/UI/Icons.js | 15 ++++++++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 public/assets/icons/questionnaire-add.png create mode 100644 public/assets/icons/questionnaire-remove.png diff --git a/public/assets/icons/questionnaire-add.png b/public/assets/icons/questionnaire-add.png new file mode 100644 index 0000000000000000000000000000000000000000..5a06098b9586d6d534ee17f34510edfca0e7469c GIT binary patch literal 2399 zcmZuz3pmqlAD;12P6?rmiIwCuBD}nY*jPDqQj+K(hiXnaYZJW{IalO3IpjD~8j9ES zCCfI%D&$l$8*>cJ)@JX&>-(dcJ`v1; z`L3?6#a0nByj2#1!Po+>fadzkNJ|@?Yi~{9g%d8OAnnMvZ{LlL@XZSK*%g)pwlhEt$x(nMaxyV?h?inQ zw&Ys5`n&%ulsmij>gm-~R9p%SynEeQKxq>Q1RWh6FYwC(U1$|!c9l1S)wGH6ct)Kh z;}BSZC6{r@lsPkl{z&cZ{UdVjf!GA}F_SYyT*XO(#VQSNy*}?mDit|yeJ2yACw4}@M@ixfyX^YyKjs$l!mU)stefo4b@D z$jAu0K6et0PNha=W##A3a(@gp_~?^UKZ|m^BPt-7u7w9v)afQRHudj)P^de8)&)hs zWm0s)uP2aT*XEOQElbuiS}3>6e9VR$BCcct%D`EP^v;*1&dPXcp~D)+52&*5Dns^o`EhBU2vB%hl-6E&7>XtJ}RT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r`c3mKt!gmySqm8XbE6_gp^4Rzlfs7@M zbM3MD>`q2c4`Mj#goc!@m)C*5J5D%KHGh>u`w8!fh$LFJ4}G z^X5%JK!CcGaF|JlUk+AMbIk2*ww|*GCnSm4x*?~e1l8@+%H;=gKH{0xRMo;u#h#I; z+VWy<4lgb~aZMv2t*v{3;%Hs$Ba5oG5Ny=jW0$|uq(I=A3VV3>&u!gCg_3*s0@j54 z0EDltT^ZW2u&EsG=rA{i?M1GxL>T6AeO{#`pE||=Dxa-z?I-Bz-}?EDhAyf;cZY3M zls7OiaA$?#$9H(M;*h+8!hHgPal7HPkm!)c?CmXTS{fgxKBt62f&WkR(FuhJn zeCex=zY;1YXlZF_TI$fcRw`)0!~w1LbSF1_Wz|viViWscRgQeU*zix!ddJ5JVaSoW zSrGdG7Kub&(MM?GDJzVpf`i=uV(p)9{eyVro7f5OMqDf3Dw|(HYIkz2L?JE%p=}Hs z^%k;G1C>Y^sLunf#jbL=8^`!~^ntL5NaETzVT?dwUGWyvUR_lX1X2*&v$)hHekn66 ztL=*#p?793NphN@qL!Hq@8R9+{(q;~I)H^k9yeX1LTIpR$ok+-_+``Pldx(4e!sTD zvXUOSX+1rCaps5)l*ooEk_4jYz9@5g1Ovr7(ZCm;Xz*2aB<9kP9 YDJEAls#CE7xW@C?S~(!<;eKiV2D`87@&Et; literal 0 HcmV?d00001 diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index 8dcb6fc..47d44b9 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -1,7 +1,7 @@ import {Fragment} from "react"; import {Button} from "react-bootstrap"; import {Link} from "react-router-dom"; -import {EditIcon, RemoveUserIcon} from "../UI/Icons"; +import {EditIcon, RemoveQuestionnaireIcon} from "../UI/Icons"; export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ { @@ -63,7 +63,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ className="ms-sm-2" onClick={() => handleDelete(row)} > - + ); diff --git a/src/components/UI/Icons.js b/src/components/UI/Icons.js index 03c29f8..981fcde 100644 --- a/src/components/UI/Icons.js +++ b/src/components/UI/Icons.js @@ -29,8 +29,21 @@ export const AddUserIcon = () => { export const AddQuestionnaireIcon = () => { return ( add + ); +}; + +export const RemoveQuestionnaireIcon = () => { + return ( + remove ); }; From eea5a7075be6afda34aea11fbc48a0e1415492a4 Mon Sep 17 00:00:00 2001 From: varundeepakgudhe Date: Fri, 21 Apr 2023 22:35:37 -0400 Subject: [PATCH 10/33] comitting update questionnaire, create que changes --- src/components/Users/util.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Users/util.js b/src/components/Users/util.js index 854e890..2dfadb0 100644 --- a/src/components/Users/util.js +++ b/src/components/Users/util.js @@ -22,6 +22,7 @@ export const transformInstitutionsResponse = (institutions) => { return institutionsData; }; + export const transformRolesResponse = (roles) => { let rolesData = [{key: "Select a Role", value: ""}]; roles = JSON.parse(roles); From 5e2c2068ec54f58de10abfa06f10d21ee3604bed Mon Sep 17 00:00:00 2001 From: varundeepakgudhe Date: Fri, 21 Apr 2023 22:35:57 -0400 Subject: [PATCH 11/33] comited update Questionnaires --- .../Questionnaires/CreateQuestionnaire.js | 36 +++-- .../Questionnaires/UpdateQuestionnaire.js | 152 ++++++++---------- src/components/Questionnaires/util.js | 89 +++++----- 3 files changed, 133 insertions(+), 144 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 134ae0d..4a564c6 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -8,7 +8,7 @@ import {alertActions} from "../../store/alert"; import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; import FormInput from "../UI/Form/FormInput"; import FormSelect from "../UI/Form/FormSelect"; -import { q_private,instructors,types,displayTypes,transformQuestionnaireRequest} from "./util"; +import {QUESTIONNAIRE_TYPES, questionnaireTypesOptions ,q_private,transformQuestionnaireRequest,transformTypesResponse,} from "./util"; // import {FormCheckbox} from "react-bootstrap"; @@ -32,12 +32,18 @@ const initialValues = { const validationSchema = Yup.object({ name: Yup.string() .required("Required") - .lowercase("Username must be lowercase") - .min(3, "Username must be at least 3 characters") - .max(20, "Username must be at most 20 characters"), + .min(3, "Questionnaire name must be at least 3 characters") + .max(40, "Questionnaire name must be at most 40 characters"), + private: Yup.boolean().required(), + min_question_score: Yup.number().min(0).required(), + max_question_score: Yup.number().allow(null), + type: Yup.string().required(), + instruction_loc: Yup.string().required() }); + + const CreateQuestionnaire = ({onClose}) => { const dispatch = useDispatch(); const [show, setShow] = useState(true); @@ -108,7 +114,7 @@ const CreateQuestionnaire = ({onClose}) => { name="name" /> - { inputGroupPrepend={ Instructor_id } - /> + /> */} + {/* */} + /> + */} { controlId="questionnaire-type" // label="Type" name="type" - options={types} - inputGroupPrepend={ - Questionnaire Type - } - /> - Questionnaire Type} + /> + {/* { Display Type } - /> + /> */} { - const [lastName, firstName] = user.fullname.split(","); - const emailPreferences = [ - "email_on_review", - "email_on_review_of_review", - "email_on_submission", - ].filter((pref) => user[pref]); +const initialValues = (questionnaire) => { return { - name: user.name, - email: user.email, - firstName: firstName.trim(), - lastName: lastName.trim(), - emailPreferences: emailPreferences, - institution: user.institution.id ? user.institution.id : "", - role: user.role.id, + name: questionnaire.name, + private: questionnaire.q_private, + min_question_score: questionnaire.min_question_score, + max_question_score: questionnaire.max_question_score, + type: questionnaire.type.id, + instruction_loc: questionnaire.instruction_loc }; }; + const validationSchema = Yup.object({ name: Yup.string() .required("Required") - .lowercase("Username must be lowercase") - .min(3, "Username must be at least 3 characters") - .max(20, "Username must be at most 20 characters"), - email: Yup.string().required("Required").email("Invalid email format"), - firstName: Yup.string().required("Required").nonNullable(), - lastName: Yup.string().required("Required").nonNullable(), - role: Yup.string().required("Required").nonNullable(), - institution: Yup.string().required("Required").nonNullable(), + .min(3, "Questionnaire name must be at least 3 characters") + .max(40, "Questionnaire name must be at most 40 characters"), + private: Yup.boolean().required(), + min_question_score: Yup.number().min(0).required(), + max_question_score: Yup.number().allow(null), + type: Yup.string().required(), + instruction_loc: Yup.string().required() + }); -const UpdateUser = ({userData, onClose}) => { +const UpdateQuestionnaire = ({questionnaireData, onClose}) => { const [show, setShow] = useState(true); - const {data: roles, sendRequest: fetchRoles} = useAPI(); - const {data: institutions, sendRequest: fetchInstitutions} = useAPI(); const { - data: updatedUser, - error: userError, - sendRequest: updateUser, + data: updatedQuestionnaire, + error: questionnaireError, + sendRequest: updateQuestionnaire, } = useAPI(); const dispatch = useDispatch(); // Close the modal if the user is updated successfully and pass the updated user to the parent component useEffect(() => { - if (updatedUser.length > 0) { - console.log("user updated"); - onClose(updatedUser[0]); + if (updatedQuestionnaire.length > 0) { + console.log("questionnaire updated"); + onClose(updatedQuestionnaire[0]); setShow(false); } - }, [userError, updatedUser, onClose]); + }, [questionnaireError, updatedQuestionnaire, onClose]); useEffect(() => { - if (userError) { + if (questionnaireError) { dispatch(alertActions.showAlert({ variant: "danger", - message: userError, + message: questionnaireError, })); } - }, [userError, dispatch]); + }, [questionnaireError, dispatch]); const onSubmit = (values, submitProps) => { - const userId = userData.id; - updateUser({ - url: `/questionnaires/${userId}`, + const questionnaireId = questionnaireData.id; + updateQuestionnaire({ + url: `/questionnaires/${questionnaireId}`, method: "patch", data: {...values, parent: loggedInUser}, transformRequest: transformQuestionnaireRequest, @@ -100,12 +93,12 @@ const UpdateUser = ({userData, onClose}) => { backdrop="static" > - Update User + Update Questionnaire - {userError &&

{userError}

} + {questionnaireError &&

{questionnaireError}

} { {(formik) => { return (
- Role - } - /> + @ - } /> + - + as={Col} + controlId="questionnaire-min-question-score" + label="Minimum Question Score" + name="min_question_score" + /> + - - - - Institution - - } - /> + Questionnaire Type} + /> + + @@ -187,4 +165,4 @@ const UpdateUser = ({userData, onClose}) => { ); }; -export default UpdateUser; +export default UpdateQuestionnaire; diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js index 5dff5cf..7a7c654 100644 --- a/src/components/Questionnaires/util.js +++ b/src/components/Questionnaires/util.js @@ -1,51 +1,56 @@ -export const types = [ - {label: "When someone else reviews my work", value: "email_on_review"}, - { - label: "When someone else submits work I am assigned to review", - value: "email_on_submission", - }, - { - label: "When someone else reviews one of my reviews (meta-reviews my work)", - value: "email_on_review_of_review", - }, -]; +// export const emailOptions = [ +// {label: "When someone else reviews my work", value: "email_on_review"}, +// { +// label: "When someone else submits work I am assigned to review", +// value: "True", +// } +// ]; -export const displayTypes = [ - {label: "When someone else reviews my work", value: "email_on_review"}, - { - label: "When someone else submits work I am assigned to review", - value: "email_on_submission", - }, - { - label: "When someone else reviews one of my reviews (meta-reviews my work)", - value: "email_on_review_of_review", - }, -]; -export const instructors = [ - {label: "When someone else reviews my work", value: "email_on_review"}, - { - label: "When someone else submits work I am assigned to review", - value: "email_on_submission", - }, - { - label: "When someone else reviews one of my reviews (meta-reviews my work)", - value: "email_on_review_of_review", - }, -]; +// export const transformTypesResponse = (types) => { +// let typesData = [{key: "Select a Questionnaire type", value: ""}]; +// types = JSON.parse(types); +// typesData = typesData.concat( +// types.map((type) => ({ +// key: type.name, +// value: type.id, +// })) +// ); +// return typesData; +// }; + export const q_private = [ - {label: "When someone else reviews my work", value: "email_on_review"}, - { - label: "When someone else submits work I am assigned to review", - value: "email_on_submission", - }, - { - label: "When someone else reviews one of my reviews (meta-reviews my work)", - value: "email_on_review_of_review", - }, + {label: "True"}, + ]; +export const QUESTIONNAIRE_TYPES = [ + 'ReviewQuestionnaire', + 'MetareviewQuestionnaire', + 'Author FeedbackQuestionnaire', + 'AuthorFeedbackQuestionnaire', + 'Teammate ReviewQuestionnaire', + 'TeammateReviewQuestionnaire', + 'SurveyQuestionnaire', + 'AssignmentSurveyQuestionnaire', + 'Assignment SurveyQuestionnaire', + 'Global SurveyQuestionnaire', + 'GlobalSurveyQuestionnaire', + 'Course SurveyQuestionnaire', + 'CourseSurveyQuestionnaire', + 'Bookmark RatingQuestionnaire', + 'BookmarkRatingQuestionnaire', + 'QuizQuestionnaire', +]; + +export const questionnaireTypesOptions = QUESTIONNAIRE_TYPES.map((type) => ({ + label: type, + value: type.replace(/ /g, ''), + // This will remove spaces from the value, but even though we are getting error +})); + + export const transformQuestionnaireRequest = (values, headers) => { console.log("transformQuestionnaireRequest", values, headers); const questionnaire = { From 834573d6d6faa5e6fa9c1521af8554c403282122 Mon Sep 17 00:00:00 2001 From: Michael Fergione Date: Tue, 11 Apr 2023 17:31:24 -0400 Subject: [PATCH 12/33] Add link to dummy json, show update and delete buttons --- src/components/Questionnaires/Questionnaires.js | 3 ++- src/components/Questionnaires/questionnaireColumns.js | 2 +- src/hooks/use-api.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index 0df1c60..a9de285 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,6 +9,7 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; +import record_data from './records.json'; // for testing const Questionnaires = () => { const dispatch = useDispatch(); @@ -30,7 +31,7 @@ const Questionnaires = () => { data: {}, }); - useEffect(() => fetchQuestionnaires({url: "/questionnaires", method: "get"}), [fetchQuestionnaires]); + useEffect(() => fetchQuestionnaires({url: "", method: "get"}), [fetchQuestionnaires]); // Error alert useEffect(() => { diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index b740423..8dcb6fc 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -26,7 +26,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ }, { Header: "Instructor", - accessor: (d) => d.instructor.name, + accessor: (d) => d.instructor, disableFilters: true, }, { diff --git a/src/hooks/use-api.js b/src/hooks/use-api.js index 4877f9b..67f988d 100644 --- a/src/hooks/use-api.js +++ b/src/hooks/use-api.js @@ -1,7 +1,8 @@ import axios from "axios"; import {useCallback, useState} from "react"; -axios.defaults.baseURL = "http://localhost:3000/api/v1"; +//axios.defaults.baseURL = "http://localhost:3000/api/v1"; +axios.defaults.baseURL = "https://api.jsonbin.io/v3/b/64359edaebd26539d0a8ffd1"; axios.defaults.headers.common["Accept"] = "application/json"; axios.defaults.headers.post["Content-Type"] = "application/json"; axios.defaults.headers.put["Content-Type"] = "application/json"; From 3ac320a5b996b49ac55d3679e453b6cd797513b1 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Sun, 16 Apr 2023 22:37:18 -0400 Subject: [PATCH 13/33] added delete functionality to close #4 --- src/components/Questionnaires/Questionnaires.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index a9de285..0ae375a 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,7 +9,7 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; -import record_data from './records.json'; // for testing +//import record_data from './records.json'; // for testing const Questionnaires = () => { const dispatch = useDispatch(); From 4af2912a1308893c8ae3bd3022c6948dcb3a7a19 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Mon, 17 Apr 2023 13:05:50 -0400 Subject: [PATCH 14/33] added questionnaire icons to close #10 --- public/assets/icons/questionnaire-add.png | Bin 0 -> 2399 bytes public/assets/icons/questionnaire-remove.png | Bin 0 -> 3081 bytes .../Questionnaires/questionnaireColumns.js | 4 ++-- src/components/UI/Icons.js | 15 ++++++++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 public/assets/icons/questionnaire-add.png create mode 100644 public/assets/icons/questionnaire-remove.png diff --git a/public/assets/icons/questionnaire-add.png b/public/assets/icons/questionnaire-add.png new file mode 100644 index 0000000000000000000000000000000000000000..5a06098b9586d6d534ee17f34510edfca0e7469c GIT binary patch literal 2399 zcmZuz3pmqlAD;12P6?rmiIwCuBD}nY*jPDqQj+K(hiXnaYZJW{IalO3IpjD~8j9ES zCCfI%D&$l$8*>cJ)@JX&>-(dcJ`v1; z`L3?6#a0nByj2#1!Po+>fadzkNJ|@?Yi~{9g%d8OAnnMvZ{LlL@XZSK*%g)pwlhEt$x(nMaxyV?h?inQ zw&Ys5`n&%ulsmij>gm-~R9p%SynEeQKxq>Q1RWh6FYwC(U1$|!c9l1S)wGH6ct)Kh z;}BSZC6{r@lsPkl{z&cZ{UdVjf!GA}F_SYyT*XO(#VQSNy*}?mDit|yeJ2yACw4}@M@ixfyX^YyKjs$l!mU)stefo4b@D z$jAu0K6et0PNha=W##A3a(@gp_~?^UKZ|m^BPt-7u7w9v)afQRHudj)P^de8)&)hs zWm0s)uP2aT*XEOQElbuiS}3>6e9VR$BCcct%D`EP^v;*1&dPXcp~D)+52&*5Dns^o`EhBU2vB%hl-6E&7>XtJ}RTnza$1$wT&ZlL0D>4eu|E9)9{mfJA zkqDxpu`oYhR8*vF(R7C3R&^X6`_2zer_;?WEbch$HsvV=1qB)9(J(Da%YUk3(FFp5 zea6?tNiy`XqOJU$ix)09G!_>W?2?tz?VfsbPyA-$#(>kw?B^*uIFCKS>)xc`hh0Y0!dDG+&F&8c;ol1udPn^RBF;-@}3Q6T_*I- zTsOgb9BrGhq1Cjwv9STD5zcf6&M@$K zsT@lyNIp$&#aEZu#6An?FA23wJ6K{h$Y6|q`b4Et;UwaYxLHJ9UENAb09>t`LQ(P~ z?S+!~dOk@2nsnndN9{0!%2QM}dml!1`e+@V#>@%1YPJjD&P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R(FuhJn zeCex=zY;1YXlZF_TI$fcRw`)0!~w1LbSF1_Wz|viViWscRgQeU*zix!ddJ5JVaSoW zSrGdG7Kub&(MM?GDJzVpf`i=uV(p)9{eyVro7f5OMqDf3Dw|(HYIkz2L?JE%p=}Hs z^%k;G1C>Y^sLunf#jbL=8^`!~^ntL5NaETzVT?dwUGWyvUR_lX1X2*&v$)hHekn66 ztL=*#p?793NphN@qL!Hq@8R9+{(q;~I)H^k9yeX1LTIpR$ok+-_+``Pldx(4e!sTD zvXUOSX+1rCaps5)l*ooEk_4jYz9@5g1Ovr7(ZCm;Xz*2aB<9kP9 YDJEAls#CE7xW@C?S~(!<;eKiV2D`87@&Et; literal 0 HcmV?d00001 diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index 8dcb6fc..47d44b9 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -1,7 +1,7 @@ import {Fragment} from "react"; import {Button} from "react-bootstrap"; import {Link} from "react-router-dom"; -import {EditIcon, RemoveUserIcon} from "../UI/Icons"; +import {EditIcon, RemoveQuestionnaireIcon} from "../UI/Icons"; export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ { @@ -63,7 +63,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ className="ms-sm-2" onClick={() => handleDelete(row)} > - + ); diff --git a/src/components/UI/Icons.js b/src/components/UI/Icons.js index 03c29f8..981fcde 100644 --- a/src/components/UI/Icons.js +++ b/src/components/UI/Icons.js @@ -29,8 +29,21 @@ export const AddUserIcon = () => { export const AddQuestionnaireIcon = () => { return ( add + ); +}; + +export const RemoveQuestionnaireIcon = () => { + return ( + remove ); }; From afed351f02a45c087e923bbbdde6b06ed21265e7 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Sat, 22 Apr 2023 14:02:18 -0400 Subject: [PATCH 15/33] modified create & update pages --- .../Questionnaires/CreateQuestionnaire.js | 73 +++++-------------- .../Questionnaires/UpdateQuestionnaire.js | 43 ++++++----- src/components/Questionnaires/util.js | 44 ++--------- 3 files changed, 47 insertions(+), 113 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 4a564c6..66c09b9 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -5,11 +5,10 @@ import {useDispatch} from "react-redux"; import * as Yup from "yup"; import useAPI from "../../hooks/use-api"; import {alertActions} from "../../store/alert"; -import FormCheckboxGroup from "../UI/Form/FormCheckboxGroup"; import FormInput from "../UI/Form/FormInput"; import FormSelect from "../UI/Form/FormSelect"; -import {QUESTIONNAIRE_TYPES, questionnaireTypesOptions ,q_private,transformQuestionnaireRequest,transformTypesResponse,} from "./util"; -// import {FormCheckbox} from "react-bootstrap"; +import FormCheckbox from "../UI/Form/FormCheckbox"; +import {questionnaireTypesOptions,transformQuestionnaireRequest} from "./util"; // Get the logged-in user from the session @@ -17,33 +16,28 @@ const loggedInUser = null; const initialValues = { name: "", - instructor_id: "", + instructor_id: 0, private: false, min_question_score: 0, - max_question_score: null, - created_at: null, - updated_at: null, + max_question_score: 10, type: "", - display_type: "", - instruction_loc: "" }; - const validationSchema = Yup.object({ name: Yup.string() .required("Required") - .min(3, "Questionnaire name must be at least 3 characters") - .max(40, "Questionnaire name must be at most 40 characters"), - private: Yup.boolean().required(), - min_question_score: Yup.number().min(0).required(), - max_question_score: Yup.number().allow(null), - type: Yup.string().required(), - instruction_loc: Yup.string().required() - + .max(64, "Questionnaire name must be at most 64 characters"), + min_question_score: Yup.number() + .required("Required") + .moreThan(-1, "Must be 0 or greater.") + .integer("Must be integer."), + max_question_score: Yup.number() + .required("Required") + .moreThan(-1, "Must be 0 or greater.") + .moreThan(Yup.ref('min_question_score'), "Must be greater than the Minimum Question Score.") + .integer("Must be integer.") }); - - const CreateQuestionnaire = ({onClose}) => { const dispatch = useDispatch(); const [show, setShow] = useState(true); @@ -74,7 +68,7 @@ const CreateQuestionnaire = ({onClose}) => { createQuestionnaire({ url: "/questionnaires", method: "post", - data: {...values, parent: loggedInUser}, + data: {...values, instructor: loggedInUser}, transformRequest: transformQuestionnaireRequest, }); submitProps.resetForm(); @@ -114,24 +108,12 @@ const CreateQuestionnaire = ({onClose}) => { name="name" /> - {/* Instructor_id - } - /> */} - - - {/* - */} { Questionnaire Type} + // inputGroupPrepend={Questionnaire Type} /> - {/* Display Type - } - - /> */} -
-

Manage Questionnaire

+

Manage Questionnaires


diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js index b947ff7..bd6fcbc 100644 --- a/src/components/Questionnaires/util.js +++ b/src/components/Questionnaires/util.js @@ -18,8 +18,8 @@ export const QUESTIONNAIRE_TYPES = [ ]; export const questionnaireTypesOptions = QUESTIONNAIRE_TYPES.map((type) => ({ - key: QUESTIONNAIRE_TYPES.value, - value: QUESTIONNAIRE_TYPES.value + key: type, + value: type })); export const transformQuestionnaireRequest = (values, headers) => { From b760388d333e060e4f26a40ffa8ba499df783bbc Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Sat, 22 Apr 2023 15:09:32 -0400 Subject: [PATCH 17/33] updates for passing instructor --- src/components/Questionnaires/UpdateQuestionnaire.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index 0d3eb14..7491ea0 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -49,7 +49,7 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { const dispatch = useDispatch(); - // Close the modal if the user is updated successfully and pass the updated user to the parent component + // Close the modal if the questionnaire is updated successfully and pass the updated user to the instructor component useEffect(() => { if (updatedQuestionnaire.length > 0) { console.log("questionnaire updated"); @@ -72,7 +72,7 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { updateQuestionnaire({ url: `/questionnaires/${questionnaireId}`, method: "patch", - data: {...values, parent: loggedInUser}, + data: {...values, instructor: loggedInUser}, transformRequest: transformQuestionnaireRequest, }); submitProps.resetForm(); From df8ff1ca9003ab06d4ebf248c945887c688a3ba1 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Sat, 22 Apr 2023 15:33:34 -0400 Subject: [PATCH 18/33] default type none --- src/components/Questionnaires/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js index bd6fcbc..5766de3 100644 --- a/src/components/Questionnaires/util.js +++ b/src/components/Questionnaires/util.js @@ -1,4 +1,4 @@ -export const QUESTIONNAIRE_TYPES = [ +export const QUESTIONNAIRE_TYPES = ['', 'ReviewQuestionnaire', 'MetareviewQuestionnaire', 'Author FeedbackQuestionnaire', From b8f2684ae5821c1a0ffc2b9c95ca550edce65f13 Mon Sep 17 00:00:00 2001 From: Michael Fergione Date: Sun, 23 Apr 2023 18:21:26 -0400 Subject: [PATCH 19/33] Display Working, Using Local JSON object --- .../Questionnaires/Questionnaires.js | 4 +- .../Questionnaires/questionnaireColumns.js | 8 +-- src/components/Questionnaires/records.json | 67 +++++++++++++++++++ 3 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 src/components/Questionnaires/records.json diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index 7b57426..90cda30 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,7 +9,7 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; -//import record_data from './records.json'; // for testing +import DATA from './records.json'; // for testing const Questionnaires = () => { const dispatch = useDispatch(); @@ -143,7 +143,7 @@ const Questionnaires = () => {
diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index 47d44b9..794e475 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -26,22 +26,22 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ }, { Header: "Instructor", - accessor: (d) => d.instructor, + accessor: (d) => d.instructor.name, disableFilters: true, }, { Header: "Min Question Score", - accessor: (d) => d.min_question_score, + accessor: "min_question_score", disableFilters: true, }, { Header: "Max Question Score", - accessor: (d) => d.max_question_score, + accessor: "max_question_score", disableFilters: true, }, { Header: "Private", - accessor: (d) => d.private, + accessor: "private", disableFilters: true, }, { diff --git a/src/components/Questionnaires/records.json b/src/components/Questionnaires/records.json new file mode 100644 index 0000000..35d8438 --- /dev/null +++ b/src/components/Questionnaires/records.json @@ -0,0 +1,67 @@ +[ + { + "id": 1, + "name": "Generic Reveiw", + "min_question_score": 0, + "max_question_score": 5, + "instructor": { + "id" : 1, + "name" : "Fedrick Barbarosa" + }, + "updated_at" : "2023.10.10", + "type" : "ReviewQuestionnaire", + "private" : "Yes" + }, + { + "id": 2, + "name": "Generic Survey", + "min_question_score": 0, + "max_question_score": 5, + "instructor": { + "id" : 1, + "name" : "Fedrick Barbarosa" + }, + "updated_at" : "2023.10.17", + "type" : "ReviewQuestionnaire", + "private" : "Yes" + }, + { + "id": 3, + "name": "Program 1 Questionaire", + "min_question_score": 0, + "max_question_score": 5, + "instructor": { + "id" : 1, + "name" : "Fedrick Barbarosa" + }, + "updated_at" : "2023.10.10", + "type" : "ReviewQuestionnaire", + "private" : "Yes" + }, + { + "id": 4, + "name": "Test", + "min_question_score": 0, + "max_question_score": 5, + "instructor": { + "id" : 1, + "name" : "Fedrick Barbarosa" + }, + "updated_at" : "2023.02.22", + "type" : "ReviewQuestionnaire", + "private" : "Yes" + }, + { + "id": 5, + "name": "Teammate Review", + "min_question_score": 0, + "max_question_score": 5, + "instructor": { + "id" : 2, + "name" : "Ada Lovelace" + }, + "updated_at" : "2023.02.10", + "type" : "ReviewQuestionnaire", + "private" : "Yes" + } +] From b208e97b378143b3f97ee46766572a30d8e33bef Mon Sep 17 00:00:00 2001 From: Michael Fergione Date: Sun, 23 Apr 2023 21:46:45 -0400 Subject: [PATCH 20/33] Adding console logging of objects for POST, DELETE functions --- src/components/Questionnaires/CreateQuestionnaire.js | 1 + src/components/Questionnaires/Questionnaires.js | 4 ++-- src/components/Questionnaires/UpdateQuestionnaire.js | 1 + src/components/Questionnaires/records.json | 2 +- src/hooks/use-api.js | 5 +++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 6cb708d..2f52c77 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -58,6 +58,7 @@ const CreateQuestionnaire = ({onClose}) => { }, [questionnaireError, dispatch]); useEffect(() => { + console.log(createdQuestionnaire) if (createdQuestionnaire.length > 0) { setShow(false); onClose(createdQuestionnaire[0]); diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index 90cda30..5bf7cf7 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -31,7 +31,7 @@ const Questionnaires = () => { data: {}, }); - useEffect(() => fetchQuestionnaires({url: "", method: "get"}), [fetchQuestionnaires]); + useEffect(() => fetchQuestionnaires({url: "/questionnaires/", method: "get"}), [fetchQuestionnaires]); // Error alert useEffect(() => { @@ -104,7 +104,7 @@ const Questionnaires = () => { () => (isLoading ? [] : questionnaireData), [questionnaireData, isLoading] ); - const initialState = {hiddenColumns: ["id", "institution"]}; + const initialState = {hiddenColumns: ["id"]}; return ( diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index 7491ea0..fa521ff 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -51,6 +51,7 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { // Close the modal if the questionnaire is updated successfully and pass the updated user to the instructor component useEffect(() => { + console.log(updateQuestionnaire) if (updatedQuestionnaire.length > 0) { console.log("questionnaire updated"); onClose(updatedQuestionnaire[0]); diff --git a/src/components/Questionnaires/records.json b/src/components/Questionnaires/records.json index 35d8438..1d631bb 100644 --- a/src/components/Questionnaires/records.json +++ b/src/components/Questionnaires/records.json @@ -1,6 +1,6 @@ [ { - "id": 1, + "id": 6, "name": "Generic Reveiw", "min_question_score": 0, "max_question_score": 5, diff --git a/src/hooks/use-api.js b/src/hooks/use-api.js index 67f988d..3d81819 100644 --- a/src/hooks/use-api.js +++ b/src/hooks/use-api.js @@ -1,8 +1,8 @@ import axios from "axios"; import {useCallback, useState} from "react"; -//axios.defaults.baseURL = "http://localhost:3000/api/v1"; -axios.defaults.baseURL = "https://api.jsonbin.io/v3/b/64359edaebd26539d0a8ffd1"; +axios.defaults.baseURL = "http://localhost:3000/"; +//axios.defaults.baseURL = "https://api.jsonbin.io/v3/b/64359edaebd26539d0a8ffd1"; axios.defaults.headers.common["Accept"] = "application/json"; axios.defaults.headers.post["Content-Type"] = "application/json"; axios.defaults.headers.put["Content-Type"] = "application/json"; @@ -21,6 +21,7 @@ const useAPI = () => { axios(requestConfig) .then((response) => { // if response if from delete request, response.data is null + console.log(response) if (response.config && response.config.method === "delete") setData([response.status]); else From d854c2ca9d79296bafbc086f0325680f54ca5bcd Mon Sep 17 00:00:00 2001 From: Michael Fergione Date: Tue, 25 Apr 2023 16:55:34 -0400 Subject: [PATCH 21/33] Added Working JSON functionality --- db.json | 64 +++++++++++++++++++ .../Questionnaires/CreateQuestionnaire.js | 2 +- .../Questionnaires/Questionnaires.js | 6 +- .../Questionnaires/UpdateQuestionnaire.js | 7 +- .../Questionnaires/questionnaireColumns.js | 4 +- src/components/Questionnaires/util.js | 19 +++++- src/hooks/use-api.js | 2 +- 7 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 db.json diff --git a/db.json b/db.json new file mode 100644 index 0000000..bb175c0 --- /dev/null +++ b/db.json @@ -0,0 +1,64 @@ +{ + "instructors": [ + { + "id": 1, + "name": "Fedrick Barbarosa" + }, + { + "id": 1, + "name": "Ada Lovelace" + } + ], + "questionnaires": [ + { + "id": 6, + "name": "Generic Reveiw", + "min_question_score": 0, + "max_question_score": 5, + "instructor_id": 1, + "updated_at": "2023.10.10", + "type": "ReviewQuestionnaire", + "is_private": true + }, + { + "id": 2, + "name": "Generic Survey", + "min_question_score": 0, + "max_question_score": 5, + "instructor_id": 1, + "updated_at": "2023.10.17", + "type": "ReviewQuestionnaire", + "is_private": true + }, + { + "id": 3, + "name": "Program 1 Questionaire", + "min_question_score": 0, + "max_question_score": 5, + "instructor_id": 1, + "updated_at": "2023.10.10", + "type": "ReviewQuestionnaire", + "is_private": true + }, + { + "id": 4, + "name": "Test", + "min_question_score": 0, + "max_question_score": 5, + "instructor_id": 1, + "updated_at": "2023.02.22", + "type": "ReviewQuestionnaire", + "is_private": true + }, + { + "name": "Test2", + "instructor_id": "1", + "min_question_score": 0, + "max_question_score": "9", + "is_private": true, + "type": "MetareviewQuestionnaire", + "id": 7, + "updated_at": "4/25/2023" + } + ] +} \ No newline at end of file diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 2f52c77..2af2b45 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -12,7 +12,7 @@ import {questionnaireTypesOptions,transformQuestionnaireRequest} from "./util"; // Get the logged-in user from the session -const loggedInUser = null; +const loggedInUser = "1"; // set to 1 as logged-in user not implemented const initialValues = { name: "", diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index 5bf7cf7..ec711bb 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,7 +9,7 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; -import DATA from './records.json'; // for testing +//import DATA from './records.json'; // for testing const Questionnaires = () => { const dispatch = useDispatch(); @@ -31,7 +31,7 @@ const Questionnaires = () => { data: {}, }); - useEffect(() => fetchQuestionnaires({url: "/questionnaires/", method: "get"}), [fetchQuestionnaires]); + useEffect(() => fetchQuestionnaires({url: "/questionnaires", method: "get"}), [fetchQuestionnaires]); // Error alert useEffect(() => { @@ -143,7 +143,7 @@ const Questionnaires = () => {
diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index fa521ff..2219fc9 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -12,12 +12,17 @@ import FormCheckbox from "../UI/Form/FormCheckbox"; import {questionnaireTypesOptions,transformQuestionnaireRequest} from "./util"; // Get the logged-in user from the session -const loggedInUser = null; +const loggedInUser = "1"; // set to 1 as logged-in user not implemented + +const currDate = new Date().toLocaleDateString(); // current time + const initialValues = (questionnaire) => { return { name: questionnaire.name, private: questionnaire.private, + updated_at: currDate, + instructor_id: loggedInUser, min_question_score: questionnaire.min_question_score, max_question_score: questionnaire.max_question_score, type: questionnaire.type, diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index 794e475..a35080a 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -26,7 +26,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ }, { Header: "Instructor", - accessor: (d) => d.instructor.name, + accessor: (d) => d.instructor_id.name, disableFilters: true, }, { @@ -41,7 +41,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ }, { Header: "Private", - accessor: "private", + accessor: (d) => d.is_private.toString(), disableFilters: true, }, { diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js index bd6fcbc..1d49792 100644 --- a/src/components/Questionnaires/util.js +++ b/src/components/Questionnaires/util.js @@ -22,14 +22,27 @@ export const questionnaireTypesOptions = QUESTIONNAIRE_TYPES.map((type) => ({ value: type })); +export const transformInstructorResponse = (instructor) => { + let instructorData = [{key: "Select a Role", value: ""}]; + instructor = JSON.parse(instructor); + instructorData = instructorData.concat( + instructor.map((role) => ({ + key: role.name, + value: role.id, + })) + ); + return instructorData; +}; + export const transformQuestionnaireRequest = (values, headers) => { console.log("transformQuestionnaireRequest", values, headers); const questionnaire = { name: values.name, - instructor_id: values.instructor, + instructor_id: values.instructor_id, + updated_at: values.updated_at, min_question_score: values.min_question_score, - max_question_score: values.min_question_score, - private: values.private, + max_question_score: values.max_question_score, + is_private: values.private, type: values.type }; return JSON.stringify(questionnaire); diff --git a/src/hooks/use-api.js b/src/hooks/use-api.js index 3d81819..7e3de9c 100644 --- a/src/hooks/use-api.js +++ b/src/hooks/use-api.js @@ -1,7 +1,7 @@ import axios from "axios"; import {useCallback, useState} from "react"; -axios.defaults.baseURL = "http://localhost:3000/"; +axios.defaults.baseURL = "http://localhost:3030/"; //axios.defaults.baseURL = "https://api.jsonbin.io/v3/b/64359edaebd26539d0a8ffd1"; axios.defaults.headers.common["Accept"] = "application/json"; axios.defaults.headers.post["Content-Type"] = "application/json"; From 9a85174a196bdee5b56f6f75d5d1469feae00b33 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Tue, 25 Apr 2023 17:34:21 -0400 Subject: [PATCH 22/33] updated instructor column --- db.json | 10 +++++----- src/components/Questionnaires/questionnaireColumns.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db.json b/db.json index bb175c0..7b2952c 100644 --- a/db.json +++ b/db.json @@ -5,18 +5,18 @@ "name": "Fedrick Barbarosa" }, { - "id": 1, + "id": 2, "name": "Ada Lovelace" } ], "questionnaires": [ { "id": 6, - "name": "Generic Reveiw", + "name": "Generic Review", "min_question_score": 0, "max_question_score": 5, - "instructor_id": 1, - "updated_at": "2023.10.10", + "instructor_id": "1", + "updated_at": "4/25/2023", "type": "ReviewQuestionnaire", "is_private": true }, @@ -52,7 +52,7 @@ }, { "name": "Test2", - "instructor_id": "1", + "instructor_id": "2", "min_question_score": 0, "max_question_score": "9", "is_private": true, diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index a35080a..a8ffb6b 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -25,8 +25,8 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ accessor: "updated_at", }, { - Header: "Instructor", - accessor: (d) => d.instructor_id.name, + Header: "Instructor Id", + accessor: (d) => d.instructor_id, disableFilters: true, }, { From be43020941b6163ace059b257c750347b5ee7141 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Tue, 25 Apr 2023 20:07:37 -0400 Subject: [PATCH 23/33] render checkbox in update form --- db.json | 43 +++++++++++++------ .../Questionnaires/CreateQuestionnaire.js | 10 ++--- .../Questionnaires/UpdateQuestionnaire.js | 14 +++--- .../Questionnaires/questionnaireColumns.js | 2 + src/components/Questionnaires/util.js | 14 +----- src/components/UI/Form/FormCheckbox.js | 3 +- 6 files changed, 49 insertions(+), 37 deletions(-) diff --git a/db.json b/db.json index 7b2952c..0fc0bf4 100644 --- a/db.json +++ b/db.json @@ -12,10 +12,10 @@ "questionnaires": [ { "id": 6, - "name": "Generic Review", + "name": "Generic Reveiw", "min_question_score": 0, "max_question_score": 5, - "instructor_id": "1", + "instructor_id": 1, "updated_at": "4/25/2023", "type": "ReviewQuestionnaire", "is_private": true @@ -26,7 +26,7 @@ "min_question_score": 0, "max_question_score": 5, "instructor_id": 1, - "updated_at": "2023.10.17", + "updated_at": "4/25/2023", "type": "ReviewQuestionnaire", "is_private": true }, @@ -36,7 +36,7 @@ "min_question_score": 0, "max_question_score": 5, "instructor_id": 1, - "updated_at": "2023.10.10", + "updated_at": "10/10/2022", "type": "ReviewQuestionnaire", "is_private": true }, @@ -45,20 +45,39 @@ "name": "Test", "min_question_score": 0, "max_question_score": 5, - "instructor_id": 1, - "updated_at": "2023.02.22", - "type": "ReviewQuestionnaire", + "instructor_id": "2", + "updated_at": "4/25/2023", + "type": "Author FeedbackQuestionnaire", "is_private": true }, { - "name": "Test2", - "instructor_id": "2", + "name": "test1", + "instructor_id": "1", "min_question_score": 0, - "max_question_score": "9", - "is_private": true, - "type": "MetareviewQuestionnaire", + "max_question_score": 10, + "is_private": false, + "type": "", "id": 7, "updated_at": "4/25/2023" + }, + { + "name": "test2", + "instructor_id": 1, + "min_question_score": 0, + "max_question_score": 10, + "is_private": false, + "type": "CourseSurveyQuestionnaire", + "id": 8 + }, + { + "name": "test3", + "instructor_id": 1, + "min_question_score": 0, + "max_question_score": 10, + "is_private": false, + "type": "AuthorFeedbackQuestionnaire", + "id": 9, + "updated_at": "4/25/2023" } ] } \ No newline at end of file diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 2af2b45..4951bd1 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -12,12 +12,12 @@ import {questionnaireTypesOptions,transformQuestionnaireRequest} from "./util"; // Get the logged-in user from the session -const loggedInUser = "1"; // set to 1 as logged-in user not implemented +const loggedInUser = 1; // set to 1 as logged-in user not implemented const initialValues = { name: "", - instructor_id: 0, - private: false, + instructor_id: loggedInUser, + is_private: false, min_question_score: 0, max_question_score: 10, type: "", @@ -111,9 +111,9 @@ const CreateQuestionnaire = ({onClose}) => { /> diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index 2219fc9..f3c8f1f 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -12,7 +12,7 @@ import FormCheckbox from "../UI/Form/FormCheckbox"; import {questionnaireTypesOptions,transformQuestionnaireRequest} from "./util"; // Get the logged-in user from the session -const loggedInUser = "1"; // set to 1 as logged-in user not implemented +const loggedInUser = 1; // set to 1 as logged-in user not implemented const currDate = new Date().toLocaleDateString(); // current time @@ -20,7 +20,7 @@ const initialValues = (questionnaire) => { return { name: questionnaire.name, - private: questionnaire.private, + is_private: questionnaire.is_private, updated_at: currDate, instructor_id: loggedInUser, min_question_score: questionnaire.min_question_score, @@ -29,6 +29,8 @@ const initialValues = (questionnaire) => { }; }; + + const validationSchema = Yup.object({ name: Yup.string() .required("Required") @@ -121,11 +123,11 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { /> - + name="is_private" + /> [ accessor: "updated_at", }, { + id: "instructor_id", Header: "Instructor Id", accessor: (d) => d.instructor_id, disableFilters: true, @@ -40,6 +41,7 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ disableFilters: true, }, { + id: "is_private", Header: "Private", accessor: (d) => d.is_private.toString(), disableFilters: true, diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js index 73e2419..7cd728f 100644 --- a/src/components/Questionnaires/util.js +++ b/src/components/Questionnaires/util.js @@ -22,18 +22,6 @@ export const questionnaireTypesOptions = QUESTIONNAIRE_TYPES.map((type) => ({ value: type })); -export const transformInstructorResponse = (instructor) => { - let instructorData = [{key: "Select a Role", value: ""}]; - instructor = JSON.parse(instructor); - instructorData = instructorData.concat( - instructor.map((role) => ({ - key: role.name, - value: role.id, - })) - ); - return instructorData; -}; - export const transformQuestionnaireRequest = (values, headers) => { console.log("transformQuestionnaireRequest", values, headers); const questionnaire = { @@ -42,7 +30,7 @@ export const transformQuestionnaireRequest = (values, headers) => { updated_at: values.updated_at, min_question_score: values.min_question_score, max_question_score: values.max_question_score, - is_private: values.private, + is_private: values.is_private, type: values.type }; return JSON.stringify(questionnaire); diff --git a/src/components/UI/Form/FormCheckbox.js b/src/components/UI/Form/FormCheckbox.js index ede8d5c..8c97162 100644 --- a/src/components/UI/Form/FormCheckbox.js +++ b/src/components/UI/Form/FormCheckbox.js @@ -4,7 +4,7 @@ import {Form, InputGroup} from "react-bootstrap"; import InfoToolTip from "../InfoToolTip"; const FormCheckbox = (props) => { - const {controlId, label, name, disabled, tooltip} = props; + const {controlId, label, name, disabled, tooltip, defaultChecked} = props; const displayLabel = tooltip ? ( <> @@ -23,6 +23,7 @@ const FormCheckbox = (props) => { {...field} className="mx-md-2" type="checkbox" + defaultChecked={defaultChecked} disabled={disabled} label={displayLabel} isInvalid={form.touched[field.name] && form.errors[field.name]} From af80743f930bee1a16ad611e04eb3ee4c44fa2ae Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Tue, 25 Apr 2023 20:13:05 -0400 Subject: [PATCH 24/33] default behavior comment --- src/components/Questionnaires/UpdateQuestionnaire.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index f3c8f1f..76af0f8 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -122,6 +122,7 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { name="name" /> + {/* render default value of this checkbox based on the is_private value on existing record */} Date: Tue, 25 Apr 2023 20:31:07 -0400 Subject: [PATCH 25/33] Added JSON server steps --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index f7cfd7c..e53b691 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo In the project directory, you can run: +### `npm install` +To install necessary packages. ### `npm start` Runs the app in the development mode.\ @@ -14,6 +16,11 @@ Open [http://localhost:3000](http://localhost:3000) to view it in your browser. The page will reload when you make changes.\ You may also see any lint errors in the console. +### `npm install -g json-server` +Installs the JSON server. +### `json-server --watch db.json --port 3030` +Runs the JSON server. + ### `npm test` Launches the test runner in the interactive watch mode.\ From 0c1033a9dd4eb4476d377323a2c1a6c9d341763c Mon Sep 17 00:00:00 2001 From: Michael Fergione Date: Wed, 26 Apr 2023 16:22:42 -0400 Subject: [PATCH 26/33] Add additonal explanatory comments --- src/components/Questionnaires/Questionnaires.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Questionnaires/Questionnaires.js b/src/components/Questionnaires/Questionnaires.js index ec711bb..c2c5d65 100644 --- a/src/components/Questionnaires/Questionnaires.js +++ b/src/components/Questionnaires/Questionnaires.js @@ -9,8 +9,11 @@ import CreateQuestionnaire from "./CreateQuestionnaire"; import DeleteQuestionnaire from "./DeleteQuestionnaire"; import UpdateQuestionnaire from "./UpdateQuestionnaire"; import {QUESTIONNAIRE_COLUMNS} from "./questionnaireColumns"; -//import DATA from './records.json'; // for testing + +// Employs the use-api hook from src/hooks/use-api.js +// This employs axios tools to make restful calls to api +// This will handle promises, errors, and setting data const Questionnaires = () => { const dispatch = useDispatch(); const { @@ -31,6 +34,7 @@ const Questionnaires = () => { data: {}, }); + // Here we employ the useEffect hook to get questionnaire data from the base axios url + /questionnaire useEffect(() => fetchQuestionnaires({url: "/questionnaires", method: "get"}), [fetchQuestionnaires]); // Error alert @@ -43,6 +47,7 @@ const Questionnaires = () => { } }, [error, dispatch]); + // Handles the POST method create - invokes CreateQuestionnaire.js const onCreateQuestionnaireHandler = useCallback( (questionnaire) => { if (questionnaire && questionnaire.name) { @@ -58,6 +63,7 @@ const Questionnaires = () => { [setQuestionnaireData, dispatch] ); + // Handles the POST method update - invokes UpdateQuestionnaire.js const onUpdateQuestionnaireHandler = useCallback( (updatedQuestionnaire) => { if (updatedQuestionnaire && updatedQuestionnaire.name !== undefined) { @@ -75,6 +81,7 @@ const Questionnaires = () => { [setQuestionnaireData, dispatch] ); + // Handles the DELETE method update - invokes DeleteQuestionnaire.js const onDeleteQuestionnaireHandler = useCallback( (id, name, status) => { if (status) { @@ -106,6 +113,7 @@ const Questionnaires = () => { ); const initialState = {hiddenColumns: ["id"]}; + // Describe the render of data on the screen return ( From 17b6998d1c7eef307f5b163d1c0ab2f0227ca8ac Mon Sep 17 00:00:00 2001 From: dbaidya9006 <122830791+dbaidya9006@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:35:32 -0400 Subject: [PATCH 27/33] add comments --- src/components/Questionnaires/CreateQuestionnaire.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 4951bd1..4acfa6a 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -23,6 +23,8 @@ const initialValues = { type: "", }; +// Name, Minimum Question Score, and Maximum Question Score are Required. +// Minimum Question Score must be >= 0 and Maximum Question Score must be > Minimimum QUestion Score. const validationSchema = Yup.object({ name: Yup.string() .required("Required") @@ -65,6 +67,7 @@ const CreateQuestionnaire = ({onClose}) => { } }, [questionnaireError, createdQuestionnaire, onClose]); + // method to create the questionnaire record using HTTP method and URI on submit const onSubmit = (values, submitProps) => { createQuestionnaire({ url: "/questionnaires", From 69d356a01ca0e02c916ae319a4ff08cbcff79f1a Mon Sep 17 00:00:00 2001 From: dbaidya9006 <122830791+dbaidya9006@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:35:56 -0400 Subject: [PATCH 28/33] added comments --- src/components/Questionnaires/UpdateQuestionnaire.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index 76af0f8..ae60692 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -29,8 +29,8 @@ const initialValues = (questionnaire) => { }; }; - - +// Name, Minimum Question Score, and Maximum Question Score are Required. +// Minimum Question Score must be >= 0 and Maximum Question Score must be > Minimimum QUestion Score. const validationSchema = Yup.object({ name: Yup.string() .required("Required") @@ -75,6 +75,7 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { } }, [questionnaireError, dispatch]); + // method to update the questionnaire record using HTTP method and URI on submit const onSubmit = (values, submitProps) => { const questionnaireId = questionnaireData.id; updateQuestionnaire({ From 00f43b3ede2a583b32290c5ddd7a44995de6ac0e Mon Sep 17 00:00:00 2001 From: dbaidya9006 <122830791+dbaidya9006@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:36:20 -0400 Subject: [PATCH 29/33] added comment --- src/components/Questionnaires/DeleteQuestionnaire.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Questionnaires/DeleteQuestionnaire.js b/src/components/Questionnaires/DeleteQuestionnaire.js index e942b07..da02ff1 100644 --- a/src/components/Questionnaires/DeleteQuestionnaire.js +++ b/src/components/Questionnaires/DeleteQuestionnaire.js @@ -13,6 +13,7 @@ const DeleteQuestionnaire = ({questionnaireData, onClose}) => { } = useAPI(); const [show, setShow] = useState(true); + // methods to delete the questionnaire record using HTTP method and URI const deleteHandler = () => deleteQuestionnaire({url: `/questionnaires/${questionnaireData.id}`, method: "DELETE"}); From fbb13e398e464b482273286541b5caa01b4957bb Mon Sep 17 00:00:00 2001 From: varundeepakgudhe Date: Wed, 26 Apr 2023 18:14:51 -0400 Subject: [PATCH 30/33] update item min and item max and db.json --- db.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/db.json b/db.json index 0fc0bf4..6266d18 100644 --- a/db.json +++ b/db.json @@ -13,8 +13,8 @@ { "id": 6, "name": "Generic Reveiw", - "min_question_score": 0, - "max_question_score": 5, + "min_item_score": 0, + "max_item_score": 5, "instructor_id": 1, "updated_at": "4/25/2023", "type": "ReviewQuestionnaire", @@ -23,8 +23,8 @@ { "id": 2, "name": "Generic Survey", - "min_question_score": 0, - "max_question_score": 5, + "min_item_score": 0, + "max_item_score": 5, "instructor_id": 1, "updated_at": "4/25/2023", "type": "ReviewQuestionnaire", @@ -33,8 +33,8 @@ { "id": 3, "name": "Program 1 Questionaire", - "min_question_score": 0, - "max_question_score": 5, + "min_item_score": 0, + "max_item_score": 5, "instructor_id": 1, "updated_at": "10/10/2022", "type": "ReviewQuestionnaire", @@ -43,8 +43,8 @@ { "id": 4, "name": "Test", - "min_question_score": 0, - "max_question_score": 5, + "min_item_score": 0, + "max_item_score": 5, "instructor_id": "2", "updated_at": "4/25/2023", "type": "Author FeedbackQuestionnaire", @@ -53,8 +53,8 @@ { "name": "test1", "instructor_id": "1", - "min_question_score": 0, - "max_question_score": 10, + "min_item_score": 0, + "max_item_score": 10, "is_private": false, "type": "", "id": 7, @@ -63,8 +63,8 @@ { "name": "test2", "instructor_id": 1, - "min_question_score": 0, - "max_question_score": 10, + "min_item_score": 0, + "max_item_score": 10, "is_private": false, "type": "CourseSurveyQuestionnaire", "id": 8 @@ -72,8 +72,8 @@ { "name": "test3", "instructor_id": 1, - "min_question_score": 0, - "max_question_score": 10, + "min_item_score": 0, + "max_item_score": 10, "is_private": false, "type": "AuthorFeedbackQuestionnaire", "id": 9, From a9bc265b29b512d8a6a71c285e25ffd3bd8c8473 Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Wed, 26 Apr 2023 18:17:14 -0400 Subject: [PATCH 31/33] decreased size of min/max question score fields --- src/components/Questionnaires/CreateQuestionnaire.js | 4 +++- src/components/Questionnaires/UpdateQuestionnaire.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 4acfa6a..14cdabb 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -117,7 +117,7 @@ const CreateQuestionnaire = ({onClose}) => { controlId="questionnaire-is-private" label="Private" name="is_private" - /> + />

{ controlId="questionnaire-min-question-score" label="Minimum Question Score" name="min_question_score" + md="1" /> { controlId="questionnaire-is-private" label="Private" name="is_private" - /> + />

Date: Wed, 26 Apr 2023 18:37:20 -0400 Subject: [PATCH 32/33] updated headers and labels for min/max item score --- .../Questionnaires/CreateQuestionnaire.js | 26 +++++++++---------- .../Questionnaires/UpdateQuestionnaire.js | 26 +++++++++---------- .../Questionnaires/questionnaireColumns.js | 8 +++--- src/components/Questionnaires/util.js | 4 +-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/components/Questionnaires/CreateQuestionnaire.js b/src/components/Questionnaires/CreateQuestionnaire.js index 14cdabb..f0a9e8a 100644 --- a/src/components/Questionnaires/CreateQuestionnaire.js +++ b/src/components/Questionnaires/CreateQuestionnaire.js @@ -18,25 +18,25 @@ const initialValues = { name: "", instructor_id: loggedInUser, is_private: false, - min_question_score: 0, - max_question_score: 10, + min_item_score: 0, + max_item_score: 10, type: "", }; -// Name, Minimum Question Score, and Maximum Question Score are Required. -// Minimum Question Score must be >= 0 and Maximum Question Score must be > Minimimum QUestion Score. +// Name, Minimum Item Score, and Maximum Item Score are Required. +// Minimum Item Score must be >= 0 and Maximum Item Score must be > Minimimum Item Score. const validationSchema = Yup.object({ name: Yup.string() .required("Required") .max(64, "Questionnaire name must be at most 64 characters"), - min_question_score: Yup.number() + min_item_score: Yup.number() .required("Required") .moreThan(-1, "Must be 0 or greater.") .integer("Must be integer."), - max_question_score: Yup.number() + max_item_score: Yup.number() .required("Required") .moreThan(-1, "Must be 0 or greater.") - .moreThan(Yup.ref('min_question_score'), "Must be greater than the Minimum Question Score.") + .moreThan(Yup.ref('min_item_score'), "Must be greater than the Minimum Item Score.") .integer("Must be integer.") }); @@ -122,16 +122,16 @@ const CreateQuestionnaire = ({onClose}) => { diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index b071381..5152480 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -23,26 +23,26 @@ const initialValues = (questionnaire) => { is_private: questionnaire.is_private, updated_at: currDate, instructor_id: loggedInUser, - min_question_score: questionnaire.min_question_score, - max_question_score: questionnaire.max_question_score, + min_item_score: questionnaire.min_item_score, + max_item_score: questionnaire.max_item_score, type: questionnaire.type, }; }; -// Name, Minimum Question Score, and Maximum Question Score are Required. -// Minimum Question Score must be >= 0 and Maximum Question Score must be > Minimimum QUestion Score. +// Name, Minimum Item Score, and Maximum Item Score are Required. +// Minimum Item Score must be >= 0 and Maximum Item Score must be > Minimimum Item Score. const validationSchema = Yup.object({ name: Yup.string() .required("Required") .max(64, "Questionnaire name must be at most 64 characters"), - min_question_score: Yup.number() + min_item_score: Yup.number() .required("Required") .moreThan(-1, "Must be 0 or greater.") .integer("Must be integer."), - max_question_score: Yup.number() + max_item_score: Yup.number() .required("Required") .moreThan(-1, "Must be 0 or greater.") - .moreThan(Yup.ref('min_question_score'), "Must be greater than the Minimum Question Score.") + .moreThan(Yup.ref('min_item_score'), "Must be greater than the Minimum Question Score.") .integer("Must be integer.") }); @@ -133,16 +133,16 @@ const UpdateQuestionnaire = ({questionnaireData, onClose}) => { diff --git a/src/components/Questionnaires/questionnaireColumns.js b/src/components/Questionnaires/questionnaireColumns.js index c9a6420..12f2b6f 100644 --- a/src/components/Questionnaires/questionnaireColumns.js +++ b/src/components/Questionnaires/questionnaireColumns.js @@ -31,13 +31,13 @@ export const QUESTIONNAIRE_COLUMNS = (handleDelete, handleEdit) => [ disableFilters: true, }, { - Header: "Min Question Score", - accessor: "min_question_score", + Header: "Min Item Score", + accessor: "min_item_score", disableFilters: true, }, { - Header: "Max Question Score", - accessor: "max_question_score", + Header: "Max Item Score", + accessor: "max_item_score", disableFilters: true, }, { diff --git a/src/components/Questionnaires/util.js b/src/components/Questionnaires/util.js index 7cd728f..7f78e6d 100644 --- a/src/components/Questionnaires/util.js +++ b/src/components/Questionnaires/util.js @@ -28,8 +28,8 @@ export const transformQuestionnaireRequest = (values, headers) => { name: values.name, instructor_id: values.instructor_id, updated_at: values.updated_at, - min_question_score: values.min_question_score, - max_question_score: values.max_question_score, + min_item_score: values.min_item_score, + max_item_score: values.max_item_score, is_private: values.is_private, type: values.type }; From 71324457eeb4dd07544364bf3ad4961052d13d6e Mon Sep 17 00:00:00 2001 From: Dibya Baidya Date: Wed, 26 Apr 2023 18:38:36 -0400 Subject: [PATCH 33/33] updated validation message to include item --- src/components/Questionnaires/UpdateQuestionnaire.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Questionnaires/UpdateQuestionnaire.js b/src/components/Questionnaires/UpdateQuestionnaire.js index 5152480..acfa5ab 100644 --- a/src/components/Questionnaires/UpdateQuestionnaire.js +++ b/src/components/Questionnaires/UpdateQuestionnaire.js @@ -42,7 +42,7 @@ const validationSchema = Yup.object({ max_item_score: Yup.number() .required("Required") .moreThan(-1, "Must be 0 or greater.") - .moreThan(Yup.ref('min_item_score'), "Must be greater than the Minimum Question Score.") + .moreThan(Yup.ref('min_item_score'), "Must be greater than the Minimum Item Score.") .integer("Must be integer.") });