diff --git a/public/locales/en/assignments.json b/public/locales/en/assignments.json index 9aa97c70d..91b2c6c7d 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 10d4e5e33..90126b4c5 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/components/ReviewModal/DeliverModalContent.jsx b/src/common/components/ReviewModal/DeliverModalContent.jsx index c7a892f90..740376934 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, @@ -24,7 +23,7 @@ import bc from '../../services/breathecode'; import useStyle from '../../hooks/useStyle'; import Icon from '../Icon'; -function DeliverModal({ +function DeliverModalContent({ isStudent, currentTask, projectLink, @@ -215,7 +214,7 @@ function DeliverModal({ ); } -DeliverModal.propTypes = { +DeliverModalContent.propTypes = { isStudent: PropTypes.bool, currentTask: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.any])).isRequired, projectLink: PropTypes.string.isRequired, @@ -229,7 +228,7 @@ DeliverModal.propTypes = { loaders: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.any])), proceedToCommitFiles: PropTypes.func, }; -DeliverModal.defaultProps = { +DeliverModalContent.defaultProps = { isStudent: false, readOnly: false, showCodeReviews: false, @@ -239,4 +238,4 @@ DeliverModal.defaultProps = { proceedToCommitFiles: () => {}, }; -export default DeliverModal; +export default DeliverModalContent; diff --git a/src/common/components/ReviewModal/index.jsx b/src/common/components/ReviewModal/index.jsx index d7a61941d..417296764 100644 --- a/src/common/components/ReviewModal/index.jsx +++ b/src/common/components/ReviewModal/index.jsx @@ -84,7 +84,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; @@ -626,7 +626,7 @@ function ReviewModal({ isExternal, externalFiles, isOpen, isStudent, externalDat )} - {(!isAuthenticatedWithRigobot || !noFilesToReview) && hasFilesToReview && !disableRate && ( + {(!isAuthenticatedWithRigobot || !noFilesToReview) && hasFilesToReview && !disableRate && contextData?.commitFiles?.fileList?.length > 0 && ( diff --git a/src/common/services/breathecode.js b/src/common/services/breathecode.js index 5b7c812bd..e2cac253d 100644 --- a/src/common/services/breathecode.js +++ b/src/common/services/breathecode.js @@ -260,6 +260,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 = {