声音功能
This commit is contained in:
@@ -6,6 +6,8 @@ import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../controllers/sqlite_storage_controller.dart';
|
||||
import '../../../controllers/history_controller.dart';
|
||||
import '../../../services/network_listener_service.dart';
|
||||
|
||||
/// 时间: 2026-03-28
|
||||
/// 功能: 答题记录页面
|
||||
@@ -177,28 +179,68 @@ class _DistinguishPageState extends State<DistinguishPage> {
|
||||
|
||||
// 标题
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor.withAlpha(20),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.analytics_outlined,
|
||||
color: AppConstants.primaryColor,
|
||||
size: 24,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor.withAlpha(20),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.analytics_outlined,
|
||||
color: AppConstants.primaryColor,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'本次答题记录',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'答题记录',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
// 复制内容按钮
|
||||
if (_answerRecords.isNotEmpty)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor.withAlpha(15),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: AppConstants.primaryColor.withAlpha(50),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
child: TextButton.icon(
|
||||
onPressed: _copyStatisticsContent,
|
||||
icon: Icon(
|
||||
Icons.copy,
|
||||
size: 16,
|
||||
color: Colors.orange[700],
|
||||
),
|
||||
label: Text(
|
||||
'添加笔记',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.orange[700],
|
||||
),
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
@@ -703,4 +745,153 @@ $_poetryLevel
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 写入统计数据到笔记
|
||||
Future<void> _copyStatisticsContent() async {
|
||||
try {
|
||||
// 生成完整的评估报告内容
|
||||
final StringBuffer content = StringBuffer();
|
||||
content.writeln('🎓 诗词答题记录评估报告');
|
||||
content.writeln('');
|
||||
content.writeln('📊 基础数据统计');
|
||||
content.writeln('━━━━━━━━━━━━━━━━');
|
||||
content.writeln('• 已答题数:$_totalQuestions 题');
|
||||
content.writeln('• 正确数量:$_correctAnswers 题');
|
||||
content.writeln('• 错误数量:$_wrongAnswers 题');
|
||||
content.writeln('• 正确率:${_correctRate.toStringAsFixed(1)}%');
|
||||
content.writeln('• 错误率:${_wrongRate.toStringAsFixed(1)}%');
|
||||
content.writeln('• 平均用时:${_averageTime.toStringAsFixed(1)} 秒/题');
|
||||
content.writeln('');
|
||||
content.writeln('📈 辅助数据');
|
||||
content.writeln('━━━━━━━━━━━━━━━━');
|
||||
content.writeln('• 提示次数:$_hintCount 次');
|
||||
content.writeln('• 跳过次数:$_skipCount 次');
|
||||
content.writeln('');
|
||||
content.writeln('🏆 诗词水平评估');
|
||||
content.writeln('━━━━━━━━━━━━━━━━');
|
||||
content.writeln('$_poetryLevel');
|
||||
content.writeln('');
|
||||
content.writeln('💡 AI评估提示');
|
||||
content.writeln('━━━━━━━━━━━━━━━━');
|
||||
content.writeln('请根据以上答题数据,综合评估我的诗词水平,并给出:');
|
||||
content.writeln('1. 当前诗词水平的详细分析');
|
||||
content.writeln('2. 薄弱环节和改进建议');
|
||||
content.writeln('3. 推荐学习的诗词类型或朝代');
|
||||
content.writeln('4. 适合的诗词学习路径建议');
|
||||
content.writeln('');
|
||||
content.writeln('感谢您的评估!');
|
||||
|
||||
// 保存到笔记
|
||||
final noteId = await HistoryController.saveNote(
|
||||
title: '诗词答题评估_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}',
|
||||
content: content.toString(),
|
||||
category: '答题评估',
|
||||
);
|
||||
|
||||
if (noteId != null) {
|
||||
NetworkListenerService().sendSuccessEvent(
|
||||
NetworkEventType.noteUpdate,
|
||||
data: noteId,
|
||||
);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('评估报告已保存到笔记'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('保存笔记失败: $e');
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('保存笔记失败: $e')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 从答题记录创建笔记
|
||||
Future<void> _createNoteFromRecords() async {
|
||||
try {
|
||||
// 生成答题记录的详细内容
|
||||
final StringBuffer content = StringBuffer();
|
||||
content.writeln('## 答题记录汇总');
|
||||
content.writeln(
|
||||
'生成时间: ${DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now())}',
|
||||
);
|
||||
content.writeln('总记录数: ${_answerRecords.length}');
|
||||
content.writeln('');
|
||||
|
||||
// 统计信息
|
||||
int correctCount = 0;
|
||||
int totalCount = _answerRecords.length;
|
||||
|
||||
for (final record in _answerRecords) {
|
||||
if (record['isCorrect'] == true) {
|
||||
correctCount++;
|
||||
}
|
||||
}
|
||||
|
||||
content.writeln('### 统计信息');
|
||||
content.writeln('- 总题数: $totalCount');
|
||||
content.writeln('- 答对数: $correctCount');
|
||||
content.writeln('- 答错数: ${totalCount - correctCount}');
|
||||
content.writeln(
|
||||
'- 正确率: ${totalCount > 0 ? (correctCount / totalCount * 100).toStringAsFixed(1) : 0}%',
|
||||
);
|
||||
content.writeln('');
|
||||
|
||||
content.writeln('### 详细记录');
|
||||
content.writeln('');
|
||||
|
||||
for (int i = 0; i < _answerRecords.length; i++) {
|
||||
final record = _answerRecords[i];
|
||||
final question = record['question'] ?? '未知题目';
|
||||
final userAnswer = record['userAnswer'] ?? '未知答案';
|
||||
final correctAnswer = record['correctAnswer'] ?? '未知答案';
|
||||
final isCorrect = record['isCorrect'] == true;
|
||||
final answerTime = record['answerTime'] ?? '未知时间';
|
||||
final tags = record['tags'] as List<dynamic>? ?? [];
|
||||
|
||||
content.writeln('#### ${i + 1}. $question');
|
||||
content.writeln('- **你的答案**: $userAnswer');
|
||||
content.writeln('- **正确答案**: $correctAnswer');
|
||||
content.writeln('- **答题结果**: ${isCorrect ? '✅ 正确' : '❌ 错误'}');
|
||||
content.writeln('- **答题时间**: ${_formatTime(answerTime)}');
|
||||
|
||||
if (tags.isNotEmpty) {
|
||||
content.writeln('- **标签**: ${tags.join(', ')}');
|
||||
}
|
||||
|
||||
content.writeln('');
|
||||
}
|
||||
|
||||
final noteId = await HistoryController.saveNote(
|
||||
title: '答题记录_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}',
|
||||
content: content.toString(),
|
||||
category: '答题记录',
|
||||
);
|
||||
|
||||
if (noteId != null) {
|
||||
NetworkListenerService().sendSuccessEvent(
|
||||
NetworkEventType.noteUpdate,
|
||||
data: noteId,
|
||||
);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('答题记录已保存到笔记')));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('创建笔记失败: $e');
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('创建笔记失败: $e')));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user