feat: 重做阅读找答案题与 AI 情境对话,并归拢本地识别、查词等既有改动
阅读"在对话里找到答案": - 16 道题全部重写,干扰项真实出现在对话里,靠说话人归属或否定句才能作答 - 选项按题目内容确定性打乱,答案不再固定排第一;听力环节同样处理 - 去掉超纲干扰项、重复题干,收紧自由作答匹配(过去单个字母也能判对) AI 情境对话: - 提示词区分"AI 这一句要做什么"与"学习者随后要完成什么",并下发已教词句清单 - JSON 只强制 reply,translation/feedback 可选;不再索要用不上的 slots/evidence - AI 不可用时页面明确提示当前回复来自内置示范脚本 - 删掉按 stage 下标猜中文翻译的兜底,避免译文与英文对不上 - 整课对话改用逐轮必需表达校验,替换"关键词沾边就算过";修正自由场景正则误伤 - 总结的"完成任务"按实际通过的轮次生成;模型点评只在结束页呈现一次 - 自由场景支持草稿续练(独立存储槽);修正回答轮数文案与永不解锁的场景标注 同时提交此前工作区中累积的改动:SenseVoice 本地识别、查词/句型解析卡、 复习与测评页调整等,并补充对话校验、选项分布和句子解析的测试。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -89,9 +89,15 @@ class _LessonFlowState extends State<LessonFlow> {
|
||||
onSkip: widget.state.completePreview,
|
||||
);
|
||||
case LessonStep.listening:
|
||||
final listeningOptions = shuffledOptions(
|
||||
activity.answers,
|
||||
'${activity.listening}-listening',
|
||||
);
|
||||
content = _ListeningStep(
|
||||
state: widget.state,
|
||||
activity: activity,
|
||||
options: listeningOptions,
|
||||
correctAnswer: activity.answers.first,
|
||||
selectedAnswer: selectedAnswer,
|
||||
audioPlayed: listeningAudioPlayed,
|
||||
onSelected: (value) => setState(() => selectedAnswer = value),
|
||||
@@ -101,7 +107,9 @@ class _LessonFlowState extends State<LessonFlow> {
|
||||
state: widget.state,
|
||||
initialText: activity.listening,
|
||||
),
|
||||
onContinue: selectedAnswer == 0
|
||||
onContinue:
|
||||
selectedAnswer >= 0 &&
|
||||
listeningOptions[selectedAnswer] == activity.answers.first
|
||||
? widget.state.completeListening
|
||||
: null,
|
||||
);
|
||||
@@ -333,6 +341,8 @@ class _ListeningStep extends StatelessWidget {
|
||||
const _ListeningStep({
|
||||
required this.state,
|
||||
required this.activity,
|
||||
required this.options,
|
||||
required this.correctAnswer,
|
||||
required this.selectedAnswer,
|
||||
required this.audioPlayed,
|
||||
required this.onSelected,
|
||||
@@ -343,6 +353,8 @@ class _ListeningStep extends StatelessWidget {
|
||||
|
||||
final LessonActivity activity;
|
||||
final AppState state;
|
||||
final List<String> options;
|
||||
final String correctAnswer;
|
||||
|
||||
final int selectedAnswer;
|
||||
final bool audioPlayed;
|
||||
@@ -353,7 +365,7 @@ class _ListeningStep extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final answers = activity.answers;
|
||||
final answers = options;
|
||||
return _LessonScaffold(
|
||||
step: 2,
|
||||
child: SpacedColumn(
|
||||
@@ -409,7 +421,7 @@ class _ListeningStep extends StatelessWidget {
|
||||
: (audioPlayed ? '请选择答案' : '先播放音频或选择答案'),
|
||||
onPressed: onContinue,
|
||||
),
|
||||
if (selectedAnswer >= 0 && selectedAnswer != 0)
|
||||
if (selectedAnswer >= 0 && answers[selectedAnswer] != correctAnswer)
|
||||
const Text(
|
||||
'再听一次,选择正确答案。',
|
||||
style: TextStyle(color: AppColors.warmInk),
|
||||
@@ -645,77 +657,299 @@ class _ReadingStep extends StatefulWidget {
|
||||
|
||||
class _ReadingStepState extends State<_ReadingStep> {
|
||||
final controller = TextEditingController();
|
||||
int? selectedOptionIndex;
|
||||
bool showAnswer = false;
|
||||
|
||||
/// 打乱后的选项:答案不再固定排在第一位,但同一道题顺序保持稳定。
|
||||
late final List<String> options = shuffledOptions(
|
||||
widget.activity.readingOptions,
|
||||
'${widget.activity.readingQuestion}-reading',
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool _isOptionCorrect(int index) {
|
||||
if (options.isEmpty || index < 0 || index >= options.length) {
|
||||
return false;
|
||||
}
|
||||
final option = options[index].trim();
|
||||
final answer = widget.activity.readingAnswer.trim();
|
||||
if (option.toLowerCase() == answer.toLowerCase()) return true;
|
||||
|
||||
final normOption = option
|
||||
.toLowerCase()
|
||||
.replaceAll(RegExp(r'[^a-z0-9\u4e00-\u9fa5]'), '');
|
||||
final normAnswer = answer
|
||||
.toLowerCase()
|
||||
.replaceAll(RegExp(r'[^a-z0-9\u4e00-\u9fa5]'), '');
|
||||
return normOption.isNotEmpty &&
|
||||
normAnswer.isNotEmpty &&
|
||||
(normOption.contains(normAnswer) || normAnswer.contains(normOption));
|
||||
}
|
||||
|
||||
bool get isOptionMode => options.isNotEmpty;
|
||||
|
||||
bool get isCorrect {
|
||||
if (isOptionMode) {
|
||||
return selectedOptionIndex != null && _isOptionCorrect(selectedOptionIndex!);
|
||||
}
|
||||
final answer = widget.activity.readingAnswer.toLowerCase().replaceAll(
|
||||
RegExp(r'[^a-z0-9]'),
|
||||
RegExp(r'[^a-z0-9\u4e00-\u9fa5]'),
|
||||
'',
|
||||
);
|
||||
final response = controller.text.toLowerCase().replaceAll(
|
||||
RegExp(r'[^a-z0-9]'),
|
||||
RegExp(r'[^a-z0-9\u4e00-\u9fa5]'),
|
||||
'',
|
||||
);
|
||||
return response.isNotEmpty && response.contains(answer);
|
||||
// 只接受写全了答案的输入:过去反向的 answer.contains(response) 让单个字母
|
||||
// 也能判对('a' 通过 'A book')。
|
||||
return response.isNotEmpty && answer.isNotEmpty && response.contains(answer);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _LessonScaffold(
|
||||
step: 4,
|
||||
child: SpacedColumn(
|
||||
children: [
|
||||
const Eyebrow('读一读'),
|
||||
Text('在对话里找到答案。', style: Theme.of(context).textTheme.headlineMedium),
|
||||
SectionCard(
|
||||
tint: AppColors.softGreen,
|
||||
child: LexiconText(
|
||||
widget.activity.reading,
|
||||
state: widget.state,
|
||||
style: TextStyle(fontSize: 16, height: 1.6),
|
||||
),
|
||||
),
|
||||
Text(widget.activity.readingQuestion),
|
||||
TextButton.icon(
|
||||
onPressed: widget.onLookup,
|
||||
icon: const Icon(Icons.menu_book_outlined),
|
||||
label: const Text('查词或短语'),
|
||||
),
|
||||
TextField(
|
||||
controller: controller,
|
||||
onChanged: (_) => setState(() {}),
|
||||
decoration: const InputDecoration(
|
||||
hintText: '用英文输入答案',
|
||||
filled: true,
|
||||
fillColor: AppColors.surface,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
if (showAnswer)
|
||||
Widget build(BuildContext context) {
|
||||
final hasSelected = selectedOptionIndex != null;
|
||||
final answeredCorrectly = isCorrect;
|
||||
|
||||
return _LessonScaffold(
|
||||
step: 4,
|
||||
child: SpacedColumn(
|
||||
children: [
|
||||
const Eyebrow('读一读'),
|
||||
Text('在对话里找到答案。', style: Theme.of(context).textTheme.headlineMedium),
|
||||
SectionCard(
|
||||
tint: AppColors.warm,
|
||||
child: Text(
|
||||
'答案:${widget.activity.readingAnswer}',
|
||||
style: const TextStyle(color: AppColors.warmInk),
|
||||
tint: AppColors.softGreen,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Row(
|
||||
children: [
|
||||
Icon(Icons.chat_bubble_outline, size: 16, color: AppColors.green),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'对话内容',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.green,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => VoiceService.instance.speak(widget.activity.reading),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.volume_up_outlined, size: 16, color: AppColors.green),
|
||||
SizedBox(width: 4),
|
||||
Text('朗读对话', style: TextStyle(fontSize: 13, color: AppColors.green)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
LexiconText(
|
||||
widget.activity.reading,
|
||||
state: widget.state,
|
||||
style: const TextStyle(fontSize: 16, height: 1.6),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!showAnswer && controller.text.isNotEmpty && !isCorrect)
|
||||
TextButton(
|
||||
onPressed: () => setState(() => showAnswer = true),
|
||||
child: const Text('查看答案后继续学习'),
|
||||
Row(
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: widget.onLookup,
|
||||
icon: const Icon(Icons.menu_book_outlined, size: 18),
|
||||
label: const Text('查词或短语'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
final lines = widget.activity.reading.split('\n');
|
||||
final target = lines.firstWhere(
|
||||
(l) => l.trim().isNotEmpty,
|
||||
orElse: () => widget.activity.reading,
|
||||
).replaceFirst(RegExp(r'^[A-Za-z]+:\s*'), '');
|
||||
showLexiconLookup(
|
||||
context,
|
||||
state: widget.state,
|
||||
initialText: target,
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.auto_stories_outlined, size: 18),
|
||||
label: const Text('句型深度解析'),
|
||||
),
|
||||
],
|
||||
),
|
||||
PrimaryButton(
|
||||
label: showAnswer ? '继续写一写' : '检查并继续',
|
||||
onPressed: showAnswer || isCorrect ? widget.onContinue : null,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
SectionCard(
|
||||
tint: AppColors.surfaceMuted,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.green.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: const Text(
|
||||
'问题',
|
||||
style: TextStyle(
|
||||
color: AppColors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.activity.readingQuestion,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.ink,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isOptionMode) ...[
|
||||
for (var index = 0; index < options.length; index++) ...[
|
||||
SectionCard(
|
||||
tint: selectedOptionIndex == index
|
||||
? (_isOptionCorrect(index) ? AppColors.softGreen : AppColors.warm)
|
||||
: null,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedOptionIndex = index;
|
||||
showAnswer = false;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
selectedOptionIndex == index
|
||||
? (_isOptionCorrect(index) ? Icons.check_circle : Icons.cancel_outlined)
|
||||
: Icons.radio_button_off,
|
||||
color: selectedOptionIndex == index
|
||||
? (_isOptionCorrect(index) ? AppColors.green : AppColors.warmInk)
|
||||
: AppColors.muted,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
options[index],
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: selectedOptionIndex == index ? FontWeight.w600 : FontWeight.normal,
|
||||
color: selectedOptionIndex == index
|
||||
? (_isOptionCorrect(index) ? AppColors.green : AppColors.warmInk)
|
||||
: AppColors.ink,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
if (hasSelected && answeredCorrectly)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.softGreen,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppColors.green.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.check_circle, color: AppColors.green, size: 20),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'回答正确!点击下方按钮继续',
|
||||
style: TextStyle(
|
||||
color: AppColors.green,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (hasSelected && !answeredCorrectly)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.warm,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: AppColors.warmInk.withValues(alpha: 0.2)),
|
||||
),
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(Icons.help_outline, color: AppColors.warmInk, size: 20),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'不对哦,再仔细观察对话中的关键句子~',
|
||||
style: TextStyle(color: AppColors.warmInk, fontSize: 13),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
TextField(
|
||||
controller: controller,
|
||||
onChanged: (_) => setState(() {}),
|
||||
decoration: const InputDecoration(
|
||||
hintText: '用英文输入答案',
|
||||
filled: true,
|
||||
fillColor: AppColors.surface,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (showAnswer)
|
||||
SectionCard(
|
||||
tint: AppColors.warm,
|
||||
child: Text(
|
||||
'答案:${widget.activity.readingAnswer}',
|
||||
style: const TextStyle(color: AppColors.warmInk),
|
||||
),
|
||||
),
|
||||
if (!showAnswer &&
|
||||
((isOptionMode && hasSelected && !answeredCorrectly) ||
|
||||
(!isOptionMode && controller.text.isNotEmpty && !answeredCorrectly)))
|
||||
TextButton(
|
||||
onPressed: () => setState(() => showAnswer = true),
|
||||
child: const Text('查看答案后继续学习'),
|
||||
),
|
||||
PrimaryButton(
|
||||
label: showAnswer || answeredCorrectly
|
||||
? '继续写一写'
|
||||
: (isOptionMode ? '请选择答案' : '检查并继续'),
|
||||
onPressed: showAnswer || answeredCorrectly ? widget.onContinue : null,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _WritingStep extends StatefulWidget {
|
||||
|
||||
Reference in New Issue
Block a user