Skip to content

Commit

Permalink
features improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-vrps committed Jul 9, 2024
1 parent a1514a8 commit 8ae1953
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 69 deletions.
5 changes: 4 additions & 1 deletion server/controllers/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ questionController.put({ path: '/:id', userType: UserType.CLASS }, async (req, r
logger.info(`dataStatus: ${dataStatus}`);
if (dataStatus !== undefined && dataStatus !== null) {
question.status = dataStatus;
question.feedback = [QuestionStatus.ONGOING, QuestionStatus.PREMOUNTING].includes(dataStatus) && data.feedback ? data.feedback : null;
question.feedbacks =
[QuestionStatus.ONGOING, QuestionStatus.PREMOUNTING].includes(dataStatus) && data.feedback
? [...(question.feedbacks || []), data.feedback]
: question.feedbacks || [];
}
await getRepository(Question).save(question);
res.sendJSON(question);
Expand Down
11 changes: 9 additions & 2 deletions server/entities/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export class Question implements QuestionInterface {
})
status: QuestionStatus;

@Column({ type: 'varchar', length: 2000, nullable: true })
public feedback: string | null;
@Column({
type: 'text',
nullable: true,
transformer: {
to: (value: string[] | null) => (value ? JSON.stringify(value) : null),
from: (value: string | null) => (value ? JSON.parse(value) : null),
},
})
public feedbacks: string[] | null;
}
6 changes: 1 addition & 5 deletions server/translations/defaultLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,8 @@ export const locales = {
part6_subtitle1: 'À cette étape, vous pouvez pré-visualiser votre diaporama sonore achevé.',
part6_pdf_button: 'Télécharger le storyboard',
part6_mlt_button: 'Télécharger le fichier de montage',
part6_mp4_button: 'Générer votre vidéo',
part6_mp4_download_button: 'Télécharger votre vidéo !',
part6_mp4_generate_button: 'Générer une nouvelle vidéo',
part6_mp4_loading: 'Création de votre vidéo...',
part6_mp4_description_1: 'La génération de votre vidéo peut prendre du temps.',
part6_mp4_description_2: "Vous pouvez quitter et suivre à tout moment l'avancement du montage de votre vidéo sur cette page.",
part6_mp4_description_3: 'Votre vidéo sera disponible pendant 2 jours. Passé ce delai elle sera supprimée.',
part6_mp4_user_disabled: 'Connectez-vous et créez un projet pour générer une vidéo.',
part6_mp4_project_disabled: 'Créez un projet pour générer une vidéo.',
part6_subtitle2:
Expand Down Expand Up @@ -297,6 +292,7 @@ export const locales = {
collaboration_form_feedback_btn_feedback: 'Envoyer le retour',
collaboration_form_feedback_btn_ok: 'Valider le travail',
collaboration_form_feedback_error: 'Veuillez renseigner un message de retour.',
collaboration_previous_feedbacks_label: 'Retours précédents',
collaboration_form_feedback_label: 'Retours',
collaboration_form_feedback_placeholder: 'Vos retours (Raccourcir la durée de la séquence, monter le son, ...)',
collaboration_form_feedback_title: 'Travail à vérifier',
Expand Down
13 changes: 12 additions & 1 deletion src/components/collaboration/FormFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const FormFeedback: React.FunctionComponent<FormFeedbackProps> = ({ quest
newQuestions[question.index] = {
...newQuestions[question.index],
status,
feedback: feedbackData,
feedbacks: feedbackData ? [...(question.feedbacks ?? []), feedbackData] : question.feedbacks,
};
const updatedProject = updateProject({ questions: newQuestions });
if (updatedProject) {
Expand Down Expand Up @@ -87,6 +87,17 @@ export const FormFeedback: React.FunctionComponent<FormFeedbackProps> = ({ quest
{t('collaboration_form_feedback_title')}
</h2>

{question.feedbacks && question.feedbacks.length > 0 && (
<div>
<div style={{ fontSize: '14px' }}>{t('collaboration_previous_feedbacks_label')} :</div>
<ul>
{question.feedbacks.map((feedbackItem, index) => (
<li key={index}>{feedbackItem}</li>
))}
</ul>
</div>
)}

<Field
marginTop="sm"
name="feedback"
Expand Down
2 changes: 1 addition & 1 deletion src/components/create/DiaporamaPlayer/DiaporamaPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export const DiaporamaPlayer = ({
setVolume(newValue);
onUpdateVolume(newValue);
}}
max={200}
max={300}
min={0}
orientation="vertical"
/>
Expand Down
1 change: 0 additions & 1 deletion src/components/layout/Form/input.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.inputContainer {
display: block;
position: relative;
width: 300px;

&--is-full-width {
width: 100%;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/create/3-storyboard/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const EditPlan = () => {
const { user } = React.useContext(userContext);
const isStudent = user?.type === UserType.STUDENT;
const [showButtonFeedback, setShowButtonFeedback] = React.useState(
(isStudent && sequence && sequence.feedback && QuestionStatus.ONGOING === sequence.status) as boolean,
(isStudent && sequence && sequence.feedbacks && QuestionStatus.ONGOING === sequence.status) as boolean,
);
const [showFeedback, setShowFeedback] = React.useState(false);
const imageUrl = React.useMemo(() => {
Expand All @@ -165,7 +165,7 @@ const EditPlan = () => {
}, [imageBlob, plan]);

React.useEffect(() => {
if (isStudent && sequence && sequence.feedback && QuestionStatus.ONGOING === sequence.status) {
if (isStudent && sequence && sequence.feedbacks && QuestionStatus.ONGOING === sequence.status) {
setShowButtonFeedback(true);
}
}, [isStudent, sequence]);
Expand Down Expand Up @@ -531,7 +531,7 @@ const EditPlan = () => {
<FeedbackModal
isOpen={showFeedback}
onClose={() => setShowFeedback(false)}
feedback={sequence && sequence.feedback ? sequence.feedback : ''}
feedback={sequence && sequence.feedbacks && sequence.feedbacks.length > 0 ? sequence.feedbacks[sequence.feedbacks.length - 1] : ''}
/>
</Container>
);
Expand Down
6 changes: 4 additions & 2 deletions src/pages/create/3-storyboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Scenario = ({

const plans = React.useMemo(() => sequence.plans || [], [sequence]);
const [showFeedback, setShowFeedback] = React.useState(false);
const showButtonFeedback = isStudent && sequence.feedback && QuestionStatus.ONGOING === sequence.status;
const showButtonFeedback = isStudent && sequence.feedbacks && QuestionStatus.ONGOING === sequence.status;
const studentColor = COLORS[sequenceIndex];

const { project, isLoading: isProjectLoading, questions, updateProject } = useCurrentProject();
Expand Down Expand Up @@ -267,7 +267,9 @@ const Scenario = ({
<FeedbackModal
isOpen={showFeedback}
onClose={() => setShowFeedback(false)}
feedback={sequence && sequence.feedback ? sequence.feedback : ''}
feedback={
sequence && sequence.feedbacks && sequence.feedbacks.length > 0 ? sequence.feedbacks[sequence.feedbacks.length - 1] : ''
}
/>
</div>
{isCollaborationActive && !isStudent && sequence.status === QuestionStatus.STORYBOARD && (
Expand Down
6 changes: 3 additions & 3 deletions src/pages/create/3-storyboard/title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ const TitlePlan = () => {

const isStudent = user?.type === UserType.STUDENT;
const [showButtonFeedback, setShowButtonFeedback] = React.useState(
(isStudent && sequence && sequence.feedback && QuestionStatus.ONGOING === sequence.status) as boolean,
(isStudent && sequence && sequence.feedbacks && QuestionStatus.ONGOING === sequence.status) as boolean,
);
const [showFeedback, setShowFeedback] = React.useState(false);

React.useEffect(() => {
if (isStudent && sequence && sequence.feedback && QuestionStatus.ONGOING === sequence.status) {
if (isStudent && sequence && sequence.feedbacks && QuestionStatus.ONGOING === sequence.status) {
setShowButtonFeedback(true);
}
}, [isStudent, sequence]);
Expand Down Expand Up @@ -165,7 +165,7 @@ const TitlePlan = () => {
<FeedbackModal
isOpen={showFeedback}
onClose={() => setShowFeedback(false)}
feedback={sequence && sequence.feedback ? sequence.feedback : ''}
feedback={sequence && sequence.feedbacks && sequence.feedbacks.length > 0 ? sequence.feedbacks[sequence.feedbacks.length - 1] : ''}
/>
</Container>
);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/create/4-pre-mounting/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ const PreMountSequence = () => {
const { user } = React.useContext(userContext);
const isStudent = user?.type === UserType.STUDENT;
const [showButtonFeedback, setShowButtonFeedback] = React.useState(
(isStudent && sequence && sequence.feedback && QuestionStatus.PREMOUNTING === sequence.status) as boolean,
(isStudent && sequence && sequence.feedbacks && QuestionStatus.PREMOUNTING === sequence.status) as boolean,
);
const [showFeedback, setShowFeedback] = React.useState(false);

React.useEffect(() => {
if (isStudent && sequence && sequence.feedback && QuestionStatus.PREMOUNTING === sequence.status) {
if (isStudent && sequence && sequence.feedbacks && QuestionStatus.PREMOUNTING === sequence.status) {
setShowButtonFeedback(true);
}
}, [isStudent, sequence]);
Expand Down Expand Up @@ -337,7 +337,7 @@ const PreMountSequence = () => {
<FeedbackModal
isOpen={showFeedback}
onClose={() => setShowFeedback(false)}
feedback={sequence && sequence.feedback ? sequence.feedback : ''}
feedback={sequence && sequence.feedbacks && sequence.feedbacks.length > 0 ? sequence.feedbacks[sequence.feedbacks.length - 1] : ''}
/>
</Container>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/create/4-pre-mounting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const PreMountingPage = () => {
{questions.map((q, index) => {
if (isStudent && sequencyId !== q.id) return null;
const hasBeenEdited = q.title !== null || (q.plans || []).some((plan) => plan.description || plan.imageUrl);
const showButtonFeedback = isStudent && q.id === sequencyId && q.feedback && QuestionStatus.PREMOUNTING === q.status;
const showButtonFeedback = isStudent && q.id === sequencyId && q.feedbacks && QuestionStatus.PREMOUNTING === q.status;
return (
<div key={index}>
<Title color="primary" variant="h2" marginTop="lg" style={{ marginTop: '2rem', display: 'flex', alignItems: 'center' }}>
Expand All @@ -110,7 +110,7 @@ const PreMountingPage = () => {
<FeedbackModal
isOpen={showFeedback}
onClose={() => setShowFeedback(false)}
feedback={q && q.feedback ? q.feedback : ''}
feedback={q && q.feedbacks && q.feedbacks.length > 0 ? q.feedbacks[q.feedbacks.length - 1] : ''}
/>
</div>
);
Expand Down
55 changes: 11 additions & 44 deletions src/pages/create/6-result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Button } from 'src/components/layout/Button';
import { Container } from 'src/components/layout/Container';
import { Flex } from 'src/components/layout/Flex';
import { LinearProgress } from 'src/components/layout/LinearProgress';
import { Modal } from 'src/components/layout/Modal';
import { Tooltip } from 'src/components/layout/Tooltip';
import { Title, Text } from 'src/components/layout/Typography';
import { Steps } from 'src/components/navigation/Steps';
Expand Down Expand Up @@ -81,7 +80,6 @@ const ResultPage = () => {
const { isCollaborationActive } = useCollaboration();
const { socket, connectTeacher } = useSocket();
const [isLoading, setIsLoading] = React.useState(false);
const [isVideoModalOpen, setIsVideoModalOpen] = React.useState(false);
const {
projectVideo,
isLoading: isLoadingProjectVideo,
Expand Down Expand Up @@ -164,9 +162,16 @@ const ResultPage = () => {
data,
},
{
onSettled: () => {
setIsVideoModalOpen(false);
onSuccess: (data) => {
setIsDownloading(true);
if (data && data.url) {
const a = document.createElement('a');
a.href = data.url;
a.download = 'project_video.mp4';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
},
onError: () => {
sendToast({ message: t('unknown_error'), type: 'error' });
Expand All @@ -175,7 +180,6 @@ const ResultPage = () => {
);
};

const videoUrl = projectVideo?.url;
const videoProgress = projectVideo?.progress;
const hasProject = project !== undefined && project.id !== 0;

Expand Down Expand Up @@ -221,22 +225,6 @@ const ResultPage = () => {
<div>loading</div>
) : (
<>
{videoUrl && (
<>
<Button
label={t('part6_mp4_download_button')}
as="a"
href={videoUrl}
className="full-width"
variant="contained"
color="secondary"
style={{ width: '100%' }}
leftIcon={<VideoIcon style={{ marginRight: '10px', width: '24px', height: '24px' }} />}
download
></Button>
<Or />
</>
)}
{videoProgress && videoProgress !== 100 ? (
<div
style={{
Expand All @@ -261,13 +249,11 @@ const ResultPage = () => {
hasArrow
>
<Button
label={t(videoUrl ? 'part6_mp4_generate_button' : 'part6_mp4_button')}
label={t('part6_mp4_download_button')}
className="full-width"
variant="contained"
color="secondary"
onClick={() => {
setIsVideoModalOpen(true);
}}
onClick={generateMP4}
disabled={user === null || !hasProject}
style={{ width: '100%' }}
leftIcon={<VideoIcon style={{ marginRight: '10px', width: '24px', height: '24px' }} />}
Expand All @@ -287,25 +273,6 @@ const ResultPage = () => {
style={{ width: '100%' }}
></Button>
</Flex>
<Modal
isOpen={isVideoModalOpen}
onClose={() => {
setIsVideoModalOpen(false);
}}
isLoading={createProjectVideoMutation.isLoading}
title={t('part6_mp4_button')}
confirmLabel={t('generate')}
onConfirm={generateMP4}
width="md"
isFullWidth
confirmLevel="secondary"
>
<ul style={{ margin: 0 }}>
<li style={{ marginBottom: '0.5rem' }}>{t('part6_mp4_description_1')}</li>
<li style={{ marginBottom: '0.5rem' }}>{t('part6_mp4_description_2')}</li>
<li style={{ marginBottom: '0.5rem' }}>{t('part6_mp4_description_3')}</li>
</ul>
</Modal>
</div>
<Loader isLoading={isLoading} />
</Container>
Expand Down
2 changes: 1 addition & 1 deletion types/models/question.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Question {
soundUrl: string | null;
soundVolume: number | null;
status?: QuestionStatus;
feedback?: string | null;
feedbacks?: string[] | null;
}

export interface QuestionTemplate {
Expand Down

0 comments on commit 8ae1953

Please sign in to comment.