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