Show title and description fields when creating Learn English lesson practices.
Stop auto-filling lesson title and require story fields in the create/edit flow so lesson practices match module and course practice authoring. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
bc0fc8e3e5
commit
1f25ff9e4e
|
|
@ -27,8 +27,6 @@ export interface PracticeEditInput {
|
||||||
preservedQuestionSet: PreservedQuestionSetFields
|
preservedQuestionSet: PreservedQuestionSetFields
|
||||||
questions: PracticeEditQuestionInput[]
|
questions: PracticeEditQuestionInput[]
|
||||||
definitions: QuestionTypeDefinition[]
|
definitions: QuestionTypeDefinition[]
|
||||||
isLearnEnglishLessonPractice: boolean
|
|
||||||
lessonDefaultTitle?: string
|
|
||||||
parents?: PracticeParent[]
|
parents?: PracticeParent[]
|
||||||
parentsChanged?: boolean
|
parentsChanged?: boolean
|
||||||
}
|
}
|
||||||
|
|
@ -43,8 +41,6 @@ export async function executePracticeUpdate(
|
||||||
preservedQuestionSet: opts.preservedQuestionSet,
|
preservedQuestionSet: opts.preservedQuestionSet,
|
||||||
questions: opts.questions,
|
questions: opts.questions,
|
||||||
definitions: opts.definitions,
|
definitions: opts.definitions,
|
||||||
isLearnEnglishLessonPractice: opts.isLearnEnglishLessonPractice,
|
|
||||||
lessonDefaultTitle: opts.lessonDefaultTitle,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (opts.isExamPrep) {
|
if (opts.isExamPrep) {
|
||||||
|
|
@ -75,8 +71,6 @@ export interface SyncStimulusBlocksAfterCreateInput {
|
||||||
preservedQuestionSet: PreservedQuestionSetFields
|
preservedQuestionSet: PreservedQuestionSetFields
|
||||||
questions: PracticeEditQuestionInput[]
|
questions: PracticeEditQuestionInput[]
|
||||||
definitions: QuestionTypeDefinition[]
|
definitions: QuestionTypeDefinition[]
|
||||||
isLearnEnglishLessonPractice: boolean
|
|
||||||
lessonDefaultTitle?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** After multi-step create, apply authoring profile + stimulus blocks via full PUT. */
|
/** After multi-step create, apply authoring profile + stimulus blocks via full PUT. */
|
||||||
|
|
@ -109,8 +103,6 @@ export async function syncStimulusBlocksAfterCreate(
|
||||||
preservedQuestionSet: opts.preservedQuestionSet,
|
preservedQuestionSet: opts.preservedQuestionSet,
|
||||||
questions: questionsWithIds,
|
questions: questionsWithIds,
|
||||||
definitions: opts.definitions,
|
definitions: opts.definitions,
|
||||||
isLearnEnglishLessonPractice: opts.isLearnEnglishLessonPractice,
|
|
||||||
lessonDefaultTitle: opts.lessonDefaultTitle,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (opts.isExamPrep) {
|
if (opts.isExamPrep) {
|
||||||
|
|
|
||||||
|
|
@ -740,8 +740,6 @@ export interface BuildPracticeFullUpdateInput {
|
||||||
preservedQuestionSet: PreservedQuestionSetFields
|
preservedQuestionSet: PreservedQuestionSetFields
|
||||||
questions: PracticeEditQuestionInput[]
|
questions: PracticeEditQuestionInput[]
|
||||||
definitions: QuestionTypeDefinition[]
|
definitions: QuestionTypeDefinition[]
|
||||||
isLearnEnglishLessonPractice: boolean
|
|
||||||
lessonDefaultTitle?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildPracticeFullUpdateRequest(
|
export function buildPracticeFullUpdateRequest(
|
||||||
|
|
@ -764,16 +762,9 @@ export function buildPracticeFullUpdateRequest(
|
||||||
if (err) throw new Error(err)
|
if (err) throw new Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
const lessonTitle = opts.lessonDefaultTitle?.trim() || "Lesson practice"
|
const practiceTitle = opts.formData.title.trim() || "Untitled practice"
|
||||||
const practiceTitle = opts.isLearnEnglishLessonPractice
|
const storyDescription = opts.formData.description.trim()
|
||||||
? lessonTitle
|
const storyImage = opts.formData.storyImageUrl.trim()
|
||||||
: opts.formData.title.trim() || "Untitled practice"
|
|
||||||
const storyDescription = opts.isLearnEnglishLessonPractice
|
|
||||||
? ""
|
|
||||||
: opts.formData.description.trim()
|
|
||||||
const storyImage = opts.isLearnEnglishLessonPractice
|
|
||||||
? ""
|
|
||||||
: opts.formData.storyImageUrl.trim()
|
|
||||||
|
|
||||||
const byId = new Map(opts.definitions.map((d) => [d.id, d]))
|
const byId = new Map(opts.definitions.map((d) => [d.id, d]))
|
||||||
const toUpdate = opts.questions
|
const toUpdate = opts.questions
|
||||||
|
|
@ -868,12 +859,8 @@ export function buildPracticeFullUpdateRequest(
|
||||||
authoring_profile: opts.formData.authoringProfile,
|
authoring_profile: opts.formData.authoringProfile,
|
||||||
},
|
},
|
||||||
question_set: {
|
question_set: {
|
||||||
title: opts.isLearnEnglishLessonPractice
|
title: opts.formData.title.trim() || "Practice set",
|
||||||
? lessonTitle
|
description: opts.formData.description.trim() || null,
|
||||||
: opts.formData.title.trim() || "Practice set",
|
|
||||||
description: opts.isLearnEnglishLessonPractice
|
|
||||||
? null
|
|
||||||
: opts.formData.description.trim() || null,
|
|
||||||
time_limit_minutes: opts.preservedQuestionSet.timeLimitMinutes,
|
time_limit_minutes: opts.preservedQuestionSet.timeLimitMinutes,
|
||||||
passing_score: opts.preservedQuestionSet.passingScore,
|
passing_score: opts.preservedQuestionSet.passingScore,
|
||||||
shuffle_questions: opts.formData.shuffleQuestions,
|
shuffle_questions: opts.formData.shuffleQuestions,
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,6 @@ export function AddPracticeFlow() {
|
||||||
const lid = lessonId ? Number(lessonId) : NaN;
|
const lid = lessonId ? Number(lessonId) : NaN;
|
||||||
return Number.isFinite(lid) && lid > 0;
|
return Number.isFinite(lid) && lid > 0;
|
||||||
}, [lessonId]);
|
}, [lessonId]);
|
||||||
/** Learn English lesson practices skip story fields; exam prep lessons use the full form. */
|
|
||||||
const isLearnEnglishLessonPractice = isLessonPractice && !isExamPrep;
|
|
||||||
|
|
||||||
const parentContext = useMemo((): {
|
const parentContext = useMemo((): {
|
||||||
kind: PracticeParentKind;
|
kind: PracticeParentKind;
|
||||||
|
|
@ -386,10 +384,7 @@ export function AddPracticeFlow() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const createParents = buildCreatePracticeParentsPayload(parents);
|
const createParents = buildCreatePracticeParentsPayload(parents);
|
||||||
if (
|
if (!formData.title.trim() || !formData.description.trim()) {
|
||||||
!isLearnEnglishLessonPractice &&
|
|
||||||
(!formData.title.trim() || !formData.description.trim())
|
|
||||||
) {
|
|
||||||
toast.error("Title and story description are required", {
|
toast.error("Title and story description are required", {
|
||||||
description: "Complete the first step before publishing.",
|
description: "Complete the first step before publishing.",
|
||||||
});
|
});
|
||||||
|
|
@ -451,10 +446,6 @@ export function AddPracticeFlow() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lessonDefaultTitle =
|
|
||||||
lessonTitleDisplay?.trim() ||
|
|
||||||
(lessonId ? `Lesson ${lessonId} practice` : "Lesson practice");
|
|
||||||
|
|
||||||
const useExamPrepLessonApi =
|
const useExamPrepLessonApi =
|
||||||
isExamPrep &&
|
isExamPrep &&
|
||||||
isLessonPractice &&
|
isLessonPractice &&
|
||||||
|
|
@ -491,22 +482,12 @@ export function AddPracticeFlow() {
|
||||||
examPrepUnitId: useExamPrepUnitApi ? parentContext!.id : undefined,
|
examPrepUnitId: useExamPrepUnitApi ? parentContext!.id : undefined,
|
||||||
isExamPrep,
|
isExamPrep,
|
||||||
status,
|
status,
|
||||||
questionSetTitle: isLearnEnglishLessonPractice
|
questionSetTitle: formData.title.trim() || "Practice set",
|
||||||
? lessonDefaultTitle
|
questionSetDescription: formData.description.trim() || null,
|
||||||
: formData.title.trim() || "Practice set",
|
|
||||||
questionSetDescription: isLearnEnglishLessonPractice
|
|
||||||
? null
|
|
||||||
: formData.description.trim() || null,
|
|
||||||
shuffleQuestions: formData.shuffleQuestions,
|
shuffleQuestions: formData.shuffleQuestions,
|
||||||
practiceTitle: isLearnEnglishLessonPractice
|
practiceTitle: formData.title.trim() || "Untitled practice",
|
||||||
? lessonDefaultTitle
|
storyDescription: formData.description.trim(),
|
||||||
: formData.title.trim() || "Untitled practice",
|
storyImage: formData.storyImageUrl.trim(),
|
||||||
storyDescription: isLearnEnglishLessonPractice
|
|
||||||
? ""
|
|
||||||
: formData.description.trim(),
|
|
||||||
storyImage: isLearnEnglishLessonPractice
|
|
||||||
? ""
|
|
||||||
: formData.storyImageUrl.trim(),
|
|
||||||
quickTips: formData.tips.trim(),
|
quickTips: formData.tips.trim(),
|
||||||
personaName: persona?.name ?? null,
|
personaName: persona?.name ?? null,
|
||||||
personaId,
|
personaId,
|
||||||
|
|
@ -528,8 +509,6 @@ export function AddPracticeFlow() {
|
||||||
},
|
},
|
||||||
questions: mappedQuestions,
|
questions: mappedQuestions,
|
||||||
definitions: typeDefinitions,
|
definitions: typeDefinitions,
|
||||||
isLearnEnglishLessonPractice,
|
|
||||||
lessonDefaultTitle,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
toast.success("Practice created successfully");
|
toast.success("Practice created successfully");
|
||||||
|
|
@ -652,7 +631,6 @@ export function AddPracticeFlow() {
|
||||||
setFormData={setFormData}
|
setFormData={setFormData}
|
||||||
nextStep={nextStep}
|
nextStep={nextStep}
|
||||||
onCancel={goBack}
|
onCancel={goBack}
|
||||||
isLessonPractice={isLearnEnglishLessonPractice}
|
|
||||||
lessonTitle={lessonTitleDisplay}
|
lessonTitle={lessonTitleDisplay}
|
||||||
parentSummary={parentSummary}
|
parentSummary={parentSummary}
|
||||||
/>
|
/>
|
||||||
|
|
@ -688,7 +666,6 @@ export function AddPracticeFlow() {
|
||||||
formData={formData}
|
formData={formData}
|
||||||
selectedPersona={selectedPersona}
|
selectedPersona={selectedPersona}
|
||||||
personas={personas}
|
personas={personas}
|
||||||
isLessonPractice={isLearnEnglishLessonPractice}
|
|
||||||
lessonTitle={lessonTitleDisplay}
|
lessonTitle={lessonTitleDisplay}
|
||||||
programLabel={programLabel}
|
programLabel={programLabel}
|
||||||
courseLabel={courseId ? `Course ${courseId}` : null}
|
courseLabel={courseId ? `Course ${courseId}` : null}
|
||||||
|
|
@ -755,7 +732,6 @@ export function AddPracticeFlow() {
|
||||||
formData={formData}
|
formData={formData}
|
||||||
selectedPersona={selectedPersona}
|
selectedPersona={selectedPersona}
|
||||||
personas={personas}
|
personas={personas}
|
||||||
isLessonPractice={isLearnEnglishLessonPractice}
|
|
||||||
lessonTitle={lessonTitleDisplay}
|
lessonTitle={lessonTitleDisplay}
|
||||||
programLabel={programLabel}
|
programLabel={programLabel}
|
||||||
courseLabel={courseId ? `Course ${courseId}` : null}
|
courseLabel={courseId ? `Course ${courseId}` : null}
|
||||||
|
|
|
||||||
|
|
@ -448,10 +448,7 @@ export function EditPracticeFlow() {
|
||||||
toast.error("Invalid practice", { description: "Missing practice id in the URL." });
|
toast.error("Invalid practice", { description: "Missing practice id in the URL." });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (!formData.title.trim() || !formData.description.trim()) {
|
||||||
!isLearnEnglishLessonPractice &&
|
|
||||||
(!formData.title.trim() || !formData.description.trim())
|
|
||||||
) {
|
|
||||||
toast.error("Title and story description are required", {
|
toast.error("Title and story description are required", {
|
||||||
description: "Complete the first step before saving.",
|
description: "Complete the first step before saving.",
|
||||||
});
|
});
|
||||||
|
|
@ -510,10 +507,6 @@ export function EditPracticeFlow() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lessonDefaultTitle =
|
|
||||||
lessonTitleDisplay?.trim() ||
|
|
||||||
(lessonId ? `Lesson ${lessonId} practice` : "Lesson practice");
|
|
||||||
|
|
||||||
if (!isExamPrep) {
|
if (!isExamPrep) {
|
||||||
const parentsErr = validatePracticeParents(formData.parents, {
|
const parentsErr = validatePracticeParents(formData.parents, {
|
||||||
required: !parentsOptional,
|
required: !parentsOptional,
|
||||||
|
|
@ -544,8 +537,6 @@ export function EditPracticeFlow() {
|
||||||
},
|
},
|
||||||
questions: mappedQuestions,
|
questions: mappedQuestions,
|
||||||
definitions: typeDefinitions,
|
definitions: typeDefinitions,
|
||||||
isLearnEnglishLessonPractice,
|
|
||||||
lessonDefaultTitle,
|
|
||||||
parents: dedupeParents(formData.parents),
|
parents: dedupeParents(formData.parents),
|
||||||
parentsChanged: !practiceParentsEqual(
|
parentsChanged: !practiceParentsEqual(
|
||||||
formData.parents,
|
formData.parents,
|
||||||
|
|
@ -631,7 +622,6 @@ export function EditPracticeFlow() {
|
||||||
setFormData={setFormData}
|
setFormData={setFormData}
|
||||||
nextStep={nextStep}
|
nextStep={nextStep}
|
||||||
onCancel={() => goBack()}
|
onCancel={() => goBack()}
|
||||||
isLessonPractice={isLearnEnglishLessonPractice}
|
|
||||||
lessonTitle={lessonTitleDisplay}
|
lessonTitle={lessonTitleDisplay}
|
||||||
parentSummary={reviewParentSummary}
|
parentSummary={reviewParentSummary}
|
||||||
showParentsEditor={!isLearnEnglishLessonPractice}
|
showParentsEditor={!isLearnEnglishLessonPractice}
|
||||||
|
|
@ -683,7 +673,6 @@ export function EditPracticeFlow() {
|
||||||
formData={formData}
|
formData={formData}
|
||||||
selectedPersona={selectedPersona}
|
selectedPersona={selectedPersona}
|
||||||
personas={personas}
|
personas={personas}
|
||||||
isLessonPractice={isLearnEnglishLessonPractice}
|
|
||||||
lessonTitle={lessonTitleDisplay}
|
lessonTitle={lessonTitleDisplay}
|
||||||
programLabel={programLabel}
|
programLabel={programLabel}
|
||||||
courseLabel={courseId ? `Course ${courseId}` : null}
|
courseLabel={courseId ? `Course ${courseId}` : null}
|
||||||
|
|
@ -748,7 +737,6 @@ export function EditPracticeFlow() {
|
||||||
formData={formData}
|
formData={formData}
|
||||||
selectedPersona={selectedPersona}
|
selectedPersona={selectedPersona}
|
||||||
personas={personas}
|
personas={personas}
|
||||||
isLessonPractice={isLearnEnglishLessonPractice}
|
|
||||||
lessonTitle={lessonTitleDisplay}
|
lessonTitle={lessonTitleDisplay}
|
||||||
programLabel={programLabel}
|
programLabel={programLabel}
|
||||||
courseLabel={courseId ? `Course ${courseId}` : null}
|
courseLabel={courseId ? `Course ${courseId}` : null}
|
||||||
|
|
|
||||||
|
|
@ -83,24 +83,19 @@ export function ReviewStep({
|
||||||
if (moduleLabel?.trim()) {
|
if (moduleLabel?.trim()) {
|
||||||
items.push({ label: "Module", value: moduleLabel.trim() });
|
items.push({ label: "Module", value: moduleLabel.trim() });
|
||||||
}
|
}
|
||||||
if (isLessonPractice && lessonTitle?.trim()) {
|
if (lessonTitle?.trim()) {
|
||||||
items.push({ label: "Lesson", value: lessonTitle.trim() });
|
items.push({ label: "Lesson", value: lessonTitle.trim() });
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}, [programLabel, courseLabel, moduleLabel, isLessonPractice, lessonTitle]);
|
}, [programLabel, courseLabel, moduleLabel, lessonTitle]);
|
||||||
|
|
||||||
const practiceTitle = isLessonPractice
|
const practiceTitle =
|
||||||
? lessonTitle?.trim() || parentSummary || "Lesson practice"
|
formData.title?.trim() || lessonTitle?.trim() || parentSummary || "Untitled Practice";
|
||||||
: formData.title?.trim() || "Untitled Practice";
|
|
||||||
|
|
||||||
const guidanceText =
|
const guidanceText =
|
||||||
formData.tips?.trim() ||
|
formData.tips?.trim() || formData.description?.trim() || "unassigned";
|
||||||
(!isLessonPractice ? formData.description?.trim() : "") ||
|
|
||||||
"unassigned";
|
|
||||||
|
|
||||||
const thumbnailUrl = isLessonPractice
|
const thumbnailUrl = formData.storyImageUrl?.trim() || null;
|
||||||
? null
|
|
||||||
: formData.storyImageUrl?.trim() || null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PracticeSequentialReview
|
<PracticeSequentialReview
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user