From 2ff0fd19b056de2c3a017fc630229f241bd1641c Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Thu, 5 Sep 2024 12:34:07 +0000 Subject: [PATCH 1/5] add button on no info modal to sync cohorts tasks --- public/locales/en/assignments.json | 6 ++ public/locales/es/assignments.json | 5 ++ src/common/services/breathecode.js | 1 + src/common/views/StudentAssignments.jsx | 1 + src/js_modules/assignmentHandler/index.jsx | 71 ++++++++++++++++++++-- 5 files changed, 80 insertions(+), 4 deletions(-) diff --git a/public/locales/en/assignments.json b/public/locales/en/assignments.json index a343fce79..8859ef35d 100644 --- a/public/locales/en/assignments.json +++ b/public/locales/en/assignments.json @@ -8,6 +8,12 @@ "no-upload-students": "The following students are still pending to upload their final project information.", "see-students": "See students", "no-information": "It is possible that the student never opened this assignment. No information was found about this student assignment", + "sync-cohort": "You can synchronize all the students tasks in the cohort", + "sync": "Synchronize", + "sync-cohort-title": "Synchronize cohort", + "sync-warning": "WARNING: This operation should only be performed on cohorts with serious synchronization problems", + "cancel": "Cancel", + "error-msg": "Something went wrong while synchronizing the cohort", "educational-status": "Educational Status", "delivered-percentage": "% delivered", "last-deliver": "Last delivery: {{date}} ago", diff --git a/public/locales/es/assignments.json b/public/locales/es/assignments.json index 566331d0c..0ea6f2ced 100644 --- a/public/locales/es/assignments.json +++ b/public/locales/es/assignments.json @@ -8,6 +8,11 @@ "no-upload-students": "Los siguientes estudiantes aún están pendientes de subir la información de su proyecto final.", "see-students": "Ver estudiantes", "no-information": "Es posible que el estudiante nunca haya abierto esta tarea. No se encontró información sobre la tarea de este estudiante.", + "sync-cohort": "Puedes sincronizar todas las asignaciones de los estudiantes de la cohorte", + "sync": "Sincronizar", + "sync-cohort-title": "Sincronizar la cohorte", + "sync-warning": "ADVERTENCIA: Esta operación solo debe realizarse en cohortes con problemas graves de sincronización.", + "cancel": "Cancelar", "educational-status": "Estatus eduacional", "delivered-percentage": "% de entregado", "last-deliver": "Última entrega: hace {{date}}", diff --git a/src/common/services/breathecode.js b/src/common/services/breathecode.js index 2e2612ecd..8aca6f82a 100644 --- a/src/common/services/breathecode.js +++ b/src/common/services/breathecode.js @@ -259,6 +259,7 @@ const breathecode = { personalFiles: (taskId) => breathecode.get(`${url}/me/task/${taskId}/commitfile${qs}`), personalFile: (commitId) => breathecode.get(`${url}/me/commitfile/${commitId}${qs}`), rateCodeRevision: (coderevisionId, data) => axios.post(`${url}/me/coderevision/${coderevisionId}/rate`, data), + syncCohort: (cohortId) => axios.get(`${url}/academy/cohort/${cohortId}/synctasks`), }; }, feedback: () => { diff --git a/src/common/views/StudentAssignments.jsx b/src/common/views/StudentAssignments.jsx index 814b43fdd..2b691e97e 100644 --- a/src/common/views/StudentAssignments.jsx +++ b/src/common/views/StudentAssignments.jsx @@ -195,6 +195,7 @@ function StudentAssignments({ currentStudentList, updpateAssignment, syllabusDat setCurrentTask(null)} + selectedCohort={selectedCohort} /> { + try { + const resp = await bc.assignments().syncCohort(selectedCohort.id); + if (resp.status >= 400) throw new Error('Sync error'); + + const { message } = resp.data; + + toast({ + position: 'top', + title: 'Success', + description: message, + status: 'success', + duration: 5000, + }); + } catch (e) { + console.log(e); + toast({ + position: 'top', + title: t('error-msg'), + status: 'error', + duration: 6000, + isClosable: true, + }); + } finally { + setIsSyncOpen(false); + onClose(); + } + }; + return ( @@ -227,8 +260,33 @@ export function NoInfoModal({ isOpen, onClose }) { - - {t('no-information')} + + {t('no-information')} + {selectedCohort && ( + <> + {t('sync-cohort')} + + + )} + + {t('sync-warning')} + + + + + @@ -393,6 +451,11 @@ ReviewModal.defaultProps = { NoInfoModal.propTypes = { isOpen: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired, + selectedCohort: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.any])), +}; + +NoInfoModal.defaultProps = { + selectedCohort: null, }; DetailsModal.propTypes = { From a9a0e907b6bdb270a5a0fef8baa923742c966ea4 Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Thu, 5 Sep 2024 17:10:52 +0000 Subject: [PATCH 2/5] remove option to start code review if there is no commit files --- .../components/ReviewModal/DeliverModalContent.jsx | 13 +++++++++---- src/common/components/ReviewModal/index.jsx | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common/components/ReviewModal/DeliverModalContent.jsx b/src/common/components/ReviewModal/DeliverModalContent.jsx index c7a892f90..13a3af68a 100644 --- a/src/common/components/ReviewModal/DeliverModalContent.jsx +++ b/src/common/components/ReviewModal/DeliverModalContent.jsx @@ -37,6 +37,7 @@ function DeliverModal({ setStage, loaders, proceedToCommitFiles, + hasCommitFiles, }) { const { t } = useTranslation('assignments'); const { modal, borderColor2, featuredColor, hexColor } = useStyle(); @@ -133,10 +134,12 @@ function DeliverModal({ )} - + {hasCommitFiles && ( + + )} )} {!readOnly && ( @@ -228,6 +231,7 @@ DeliverModal.propTypes = { setStage: PropTypes.func, loaders: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.any])), proceedToCommitFiles: PropTypes.func, + hasCommitFiles: PropTypes.bool, }; DeliverModal.defaultProps = { isStudent: false, @@ -237,6 +241,7 @@ DeliverModal.defaultProps = { setStage: () => {}, loaders: {}, proceedToCommitFiles: () => {}, + hasCommitFiles: true, }; export default DeliverModal; diff --git a/src/common/components/ReviewModal/index.jsx b/src/common/components/ReviewModal/index.jsx index cbd3c2a45..cbfc34a0a 100644 --- a/src/common/components/ReviewModal/index.jsx +++ b/src/common/components/ReviewModal/index.jsx @@ -774,6 +774,7 @@ function ReviewModal({ isExternal, externalFiles, isOpen, isStudent, externalDat showCodeReviews={(!isAuthenticatedWithRigobot || !noFilesToReview) && hasFilesToReview && !disableRate} loaders={loaders} proceedToCommitFiles={proceedToCommitFiles} + hasCommitFiles={contextData.commitFiles?.fileList?.length > 0} {...rest} /> )} From c7a9ae581ea3c1d9c01d4e2e48c47f124b2d9c2f Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Thu, 5 Sep 2024 17:16:22 +0000 Subject: [PATCH 3/5] remove comment to force redeploy --- src/common/components/ReviewModal/DeliverModalContent.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/components/ReviewModal/DeliverModalContent.jsx b/src/common/components/ReviewModal/DeliverModalContent.jsx index 13a3af68a..2fa98ccf2 100644 --- a/src/common/components/ReviewModal/DeliverModalContent.jsx +++ b/src/common/components/ReviewModal/DeliverModalContent.jsx @@ -1,4 +1,3 @@ -/* eslint-disable react/no-unstable-nested-components */ import { useEffect, useState, useRef } from 'react'; import { Box, From 2d7f652ef40bc2a60e2c6f3d17e223c4c2a57461 Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Wed, 11 Sep 2024 09:37:51 +0000 Subject: [PATCH 4/5] fix bug with modal layout --- .../ReviewModal/DeliverModalContent.jsx | 21 +++++++------------ src/common/components/ReviewModal/index.jsx | 3 +-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/common/components/ReviewModal/DeliverModalContent.jsx b/src/common/components/ReviewModal/DeliverModalContent.jsx index 2fa98ccf2..740376934 100644 --- a/src/common/components/ReviewModal/DeliverModalContent.jsx +++ b/src/common/components/ReviewModal/DeliverModalContent.jsx @@ -23,7 +23,7 @@ import bc from '../../services/breathecode'; import useStyle from '../../hooks/useStyle'; import Icon from '../Icon'; -function DeliverModal({ +function DeliverModalContent({ isStudent, currentTask, projectLink, @@ -36,7 +36,6 @@ function DeliverModal({ setStage, loaders, proceedToCommitFiles, - hasCommitFiles, }) { const { t } = useTranslation('assignments'); const { modal, borderColor2, featuredColor, hexColor } = useStyle(); @@ -133,12 +132,10 @@ function DeliverModal({ )} - {hasCommitFiles && ( - - )} + )} {!readOnly && ( @@ -217,7 +214,7 @@ function DeliverModal({ ); } -DeliverModal.propTypes = { +DeliverModalContent.propTypes = { isStudent: PropTypes.bool, currentTask: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.any])).isRequired, projectLink: PropTypes.string.isRequired, @@ -230,9 +227,8 @@ DeliverModal.propTypes = { setStage: PropTypes.func, loaders: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.any])), proceedToCommitFiles: PropTypes.func, - hasCommitFiles: PropTypes.bool, }; -DeliverModal.defaultProps = { +DeliverModalContent.defaultProps = { isStudent: false, readOnly: false, showCodeReviews: false, @@ -240,7 +236,6 @@ DeliverModal.defaultProps = { setStage: () => {}, loaders: {}, proceedToCommitFiles: () => {}, - hasCommitFiles: true, }; -export default DeliverModal; +export default DeliverModalContent; diff --git a/src/common/components/ReviewModal/index.jsx b/src/common/components/ReviewModal/index.jsx index cc1a521de..2ab91e34b 100644 --- a/src/common/components/ReviewModal/index.jsx +++ b/src/common/components/ReviewModal/index.jsx @@ -85,7 +85,7 @@ function ReviewModal({ isExternal, externalFiles, isOpen, isStudent, externalDat const hasNotBeenReviewed = revisionStatus === PENDING; const hasBeenApproved = revisionStatus === APPROVED; const hasBeenRejected = revisionStatus === REJECTED; - const noFilesToReview = !hasBeenApproved && contextData?.commitFiles?.fileList?.length === 0; + const noFilesToReview = !hasBeenApproved && (contextData?.commitFiles?.fileList?.length === 0 || !('commitFiles' in contextData)); const codeRevisionsNotExists = typeof contextData?.code_revisions === 'undefined'; const hasFilesToReview = contextData?.code_revisions?.length > 0 || !isStudent; // Used to show rigobot files content const stage = stageHistory?.current; @@ -782,7 +782,6 @@ function ReviewModal({ isExternal, externalFiles, isOpen, isStudent, externalDat showCodeReviews={(!isAuthenticatedWithRigobot || !noFilesToReview) && hasFilesToReview && !disableRate} loaders={loaders} proceedToCommitFiles={proceedToCommitFiles} - hasCommitFiles={contextData.commitFiles?.fileList?.length > 0} {...rest} /> )} From a257de959f075f3e96c825d16dae0cdee3485de3 Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Thu, 19 Sep 2024 11:33:11 +0000 Subject: [PATCH 5/5] do not show option to start code review if there is no commit files --- src/common/components/ReviewModal/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/components/ReviewModal/index.jsx b/src/common/components/ReviewModal/index.jsx index 8aba29137..417296764 100644 --- a/src/common/components/ReviewModal/index.jsx +++ b/src/common/components/ReviewModal/index.jsx @@ -626,7 +626,7 @@ function ReviewModal({ isExternal, externalFiles, isOpen, isStudent, externalDat )} - {(!isAuthenticatedWithRigobot || !noFilesToReview) && hasFilesToReview && !disableRate && ( + {(!isAuthenticatedWithRigobot || !noFilesToReview) && hasFilesToReview && !disableRate && contextData?.commitFiles?.fileList?.length > 0 && (