|
|
6 天之前 | |
|---|---|---|
| .. | ||
| README_DB_FIX.md | 3 周之前 | |
| fix_learning_analytics_db.sh | 3 周之前 | |
| migrate_learning_analytics_data.php | 6 天之前 | |
在提交评分时出现两类错误:
psycopg2.errors.DatatypeMismatch: column "ip_address" is of type inet but expression is of type character varying
原因:ip_address 字段类型为 INET,但应用传递字符串 '127.0.0.1'。
psycopg2.errors.NumericValueOutOfRange: numeric field overflow
DETAIL: A field with precision 5, scale 4 must round to an absolute value less than 10^1.
原因:partial_score 字段类型为 NUMERIC(5,4),只能存储 -9.9999 到 9.9999,但实际分数可能达到 7-10 分。
ip_address 字段类型为 VARCHAR(64)partial_score 字段类型为 NUMERIC(6,2)cd /Volumes/T9/code/math/apis/FilamentAdmin/scripts
bash fix_learning_analytics_db.sh
脚本会自动:
连接数据库:
docker exec -it learning_analytics_postgres psql -U rag_user -d learning_analytics
执行修复:
-- 修改 ip_address 字段类型
ALTER TABLE student_attempts
ALTER COLUMN ip_address TYPE VARCHAR(64);
-- 修改 partial_score 字段类型
ALTER TABLE student_attempts
ALTER COLUMN partial_score TYPE NUMERIC(6,2);
验证:
\d student_attempts | grep -E "ip_address|partial_score"
fix_learning_analytics_db.sh - 自动修复脚本../database/migrations/2025_12_02_fix_learning_analytics_ip_address_type.sql - SQL 脚本README_DB_FIX.md - 本说明文档执行成功后,应看到:
✓ 修复完成!
- ip_address: INET → VARCHAR(64)
- partial_score: NUMERIC(5,4) → NUMERIC(6,2)
INET (网络地址类型)VARCHAR(64) (字符串类型)NUMERIC(5,4) (1位整数 + 4位小数 = -9.9999 到 9.9999)NUMERIC(6,2) (4位整数 + 2位小数 = -9999.99 到 9999.99)docker-compose restart learning-analytics修复完成后,访问 http://fa.test/admin/upload-exam-paper 测试评分提交功能。应该能够正常为选择题、填空题、解答题评分并提交。