feat(challenge-parser): add transcript to challenge parser (#57967)

This commit is contained in:
Tom
2025-01-09 00:17:22 -06:00
committed by GitHub
parent 8143bbbae1
commit 8ec9e5cc52
8 changed files with 74 additions and 16 deletions
+1
View File
@@ -305,6 +305,7 @@ exports.createSchemaCustomization = ({ actions }) => {
msTrophyId: String
fillInTheBlank: FillInTheBlank
scene: Scene
transcript: String
quizzes: [Quiz]
}
type FileContents {
@@ -428,6 +428,7 @@
"questions": "Questions",
"answered-mcq": "You have unanswered questions and/or incorrect answers.",
"explanation": "Explanation",
"transcript": "Read a transcript of this video",
"solution-link": "Solution Link",
"source-code-link": "Source Code Link",
"ms-link": "Microsoft Link",
+1
View File
@@ -221,6 +221,7 @@ export type ChallengeNode = {
template: string;
tests: Test[];
title: string;
transcript: string;
translationPending: boolean;
url: string;
usesMultifileEditor: boolean;
@@ -0,0 +1,3 @@
.challenge-transcript {
cursor: pointer;
}
@@ -0,0 +1,31 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Spacer } from '@freecodecamp/ui';
import PrismFormatted from './prism-formatted';
import './challenge-transcript.css';
interface ChallengeTranscriptProps {
transcript: string;
}
function ChallengeTranscript({
transcript
}: ChallengeTranscriptProps): JSX.Element {
const { t } = useTranslation();
return (
<>
<details className='challenge-transcript'>
<summary>{t('learn.transcript')}</summary>
<Spacer size='m' />
<PrismFormatted className={'line-numbers'} text={transcript} />
</details>
<Spacer size='m' />
</>
);
}
ChallengeTranscript.displayName = 'ChallengeTranscript';
export default ChallengeTranscript;
@@ -28,6 +28,7 @@ import { getChallengePaths } from '../utils/challenge-paths';
import Scene from '../components/scene/scene';
import MultipleChoiceQuestions from '../components/multiple-choice-questions';
import ChallengeExplanation from '../components/challenge-explanation';
import ChallengeTranscript from '../components/challenge-transcript';
import HelpModal from '../components/help-modal';
import { SceneSubject } from '../components/scene/scene-subject';
@@ -82,6 +83,7 @@ const ShowGeneric = ({
instructions,
questions,
title,
transcript,
translationPending,
scene,
superBlock,
@@ -204,6 +206,8 @@ const ShowGeneric = ({
{title}
</ChallengeTitle>
<Spacer size='m' />
{description && (
<Col md={8} mdOffset={2} sm={10} smOffset={1} xs={12}>
<ChallengeDescription
@@ -216,28 +220,34 @@ const ShowGeneric = ({
<Col lg={10} lgOffset={1} md={10} mdOffset={1}>
{videoId && (
<VideoPlayer
bilibiliIds={bilibiliIds}
onVideoLoad={handleVideoIsLoaded}
title={title}
videoId={videoId}
videoIsLoaded={videoIsLoaded}
videoLocaleIds={videoLocaleIds}
/>
<>
<VideoPlayer
bilibiliIds={bilibiliIds}
onVideoLoad={handleVideoIsLoaded}
title={title}
videoId={videoId}
videoIsLoaded={videoIsLoaded}
videoLocaleIds={videoLocaleIds}
/>
<Spacer size='m' />
</>
)}
</Col>
{scene && <Scene scene={scene} sceneSubject={sceneSubject} />}
<Col md={8} mdOffset={2} sm={10} smOffset={1} xs={12}>
{instructions && (
<ChallengeDescription
instructions={instructions}
superBlock={superBlock}
/>
)}
{transcript && <ChallengeTranscript transcript={transcript} />}
<Spacer size='m' />
{instructions && (
<>
<ChallengeDescription
instructions={instructions}
superBlock={superBlock}
/>
<Spacer size='m' />
</>
)}
{assignments.length > 0 && (
<Assignments
@@ -362,6 +372,7 @@ export const query = graphql`
}
superBlock
title
transcript
translationPending
videoId
videoId