班级积分管理系统

CSCT4e 集成文档

CSCT4e(Class Score Controller)是一款基于 Unity 的班级积分管理系统,支持学生积分录入、分组统计、积分明细、图表可视化与数据持久化。适用于课堂教学、竞赛活动与小组合作场景。

2. 文件结构

CSCT4eProfessional/
│── Assets/
│   ├── Art/
│   │   └── Icon/
│   │       └── Icon
│   ├── Data/
│   │   └── StudentDatabase.asset
│   ├── Html/
│   ├── NuGetForUnity/
│   ├── Packages/
│   └── Prefabs/
│       ├── Bar.prefab
│       ├── Bar2.prefab
│       ├── barPrefabs.prefab
│       ├── linePointPrefab.prefab
│       ├── linePrefab.prefab
│       ├── NameButton.prefab
│       ├── ScoreEntry.prefab
│       ├── StudentEntry.prefab
│       └── Tip.prefab
│
│── Scenes/
│   ├── ChartAnalysisScene 1.unity
│   ├── ChartAnalysisScene.unity
│   ├── ExportScene.unity
│   ├── GroupScene.unity
│   ├── ScoreInputScene.unity
│   ├── StartScene.unity
│   └── StudentPerformanceScene.unity
│
│── Scripts/
│   ├── Data/
│   │   ├── StudentDatabase.cs
│   │   └── StudentMath.cs
│   ├── LoadScene/
│   │   ├── GroupButtonLoader.cs
│   │   └── ReturnButtonLoader.cs
│   ├── Manager/
│   │   ├── EscQuitGame.cs
│   │   └── SaveLoadManager.cs
│   ├── UI/
│   │   ├── DateDisplay.cs
│   │   ├── GroupAssignerUI.cs
│   │   ├── HomeUIEffects.cs
│   │   ├── MoveObjectX.cs
│   │   ├── PageSwitcher.cs
│   │   ├── RankingUl.cs
│   │   ├── ScoreEntryIndexControl.cs
│   │   ├── ScoreViewerUl.cs
│   │   ├── StudentDatalnputUl.cs
│   │   ├── TodayScoreChangeDisplay.cs
│   │   ├── Top3BarChart.cs
│   │   ├── WeeklyStarGroupUl.cs
│   │   ├── WeeklyStarUl.cs
│   │   └── ExcelImporter.cs
│   └── Web/
│       ├── CloudDatabaseManager.cs
│       ├── Data.meta
│       └── Manager.meta
│
└── CSCT4e_demo.zip / README.md / IntegrationGuide.html

3. 集成步骤

  1. Scripts/Prefabs/Resources/ 拖入 Unity 工程 Assets/
  2. Build Settings 中添加 Scenes/ 下四个场景(索引 0~3)。
  3. Resources/StudentDatabase.asset 中录入学生:姓名、学号、小组、初始积分。
提示:你也可以运行后在 UI 中录入与分组,数据会被持久化存到 JSON,重启自动恢复。

4. UI 绑定

4.1 积分录入(StudentDataInputUI)

  • 输入:学号、事件、分数变动、日期(默认今天)
  • 按钮:写入数据 + 提示框(ConfirmationPopup)
  • 学号解析:支持 5,6-11 区间/多选

4.2 小组管理(GroupManagerUI)

  • 输入:学号、小组
  • 按钮:确认分组 → 计算小组统计
  • 显示:TMP_Text 或 ScrollView 展示分组

4.3 积分查看(ScoreViewerUI)

  • 下拉:按学号升序列出学生
  • Content:实例化 ScoreEntry.prefab
  • 滚动条:完整查看,时间倒序排列
  • 额外:显示当前学生小组与总分

4.4 排行榜(RankingUI)

  • 排序:学号/积分 升降序 + 分数排名显示
  • 前三名:金/银/铜高亮,其他交错底色

4.5 图表(Top3BarChart / GroupAverageChart)

  • Top3:第一名在中间,淡入/数值标签定位
  • 小组平均:支持负值,自动平移零点;班级均值红色,组间颜色区分

4.6 跨场景与退出

  • SaveLoadManagerDontDestroyOnLoad
  • EscQuitGame:按 ESC 退出

5. 数据持久化(JSON)

系统在运行时自动检测 StudentDatabase 的变化并保存到 Application.persistentDataPath/studentDatabase.json;启动时自动读取。

关键脚本:SaveLoadManager.cs

public class SaveLoadManager : MonoBehaviour
{
    public StudentDatabase studentDatabase;
    string savePath; string lastJson;

    void Awake(){
        DontDestroyOnLoad(gameObject);
        savePath = Path.Combine(Application.persistentDataPath, "studentDatabase.json");
        Load();
        lastJson = JsonUtility.ToJson(studentDatabase);
    }
    void Update(){
        var cur = JsonUtility.ToJson(studentDatabase);
        if(cur != lastJson){ Save(); lastJson = cur; }
    }
    void OnApplicationQuit(){ Save(); }
    public void Save(){ File.WriteAllText(savePath, JsonUtility.ToJson(studentDatabase, true)); }
    public void Load(){ if(File.Exists(savePath)) JsonUtility.FromJsonOverwrite(File.ReadAllText(savePath), studentDatabase); }
}
路径提示:Windows:C:\\Users\\你\\AppData\\LocalLow\\公司名\\游戏名;macOS:~/Library/Application Support/公司名/游戏名

6. 使用流程

  1. 进入主菜单 → 打开「分组管理」场景设置小组。
  2. 打开「积分录入」界面:录入 学号、事件、分数、日期 → 写入。
  3. 在「积分查看」中选择学生,下拉查看分数明细,支持删除条目。
  4. 在「排行榜」查看排名,支持排序与高亮。
  5. 打开「图表」查看 Top3 与小组平均分图表。
  6. 退出游戏:数据自动写入 JSON。

7. 注意事项

  • 确保所有 UI 引用在 Inspector 中绑定完整。
  • 首次运行若无 JSON,将以 StudentDatabase.asset 作为初始数据。
  • 图表预制体需包含 LabelTextScoreText(位置可在 Inspector 调整为 168.5 / -159)。
  • 小组平均图表:班级平均柱为红色,其余组使用循环色。

8. 二次开发建议

  • 新增图表类型(折线、饼图、雷达)。
  • 导入/导出:CSV、Excel;或对接校内系统。
  • 网络同步与多端协作(教师端/学生端)。
  • 权限与日志审计:记录谁在何时改动了哪些积分。

快速开始(命令速查)

// 重新计算统计
StudentMath.CalculateGroupStats(studentDatabase);
StudentMath.CalculateClassAverage(studentDatabase);

// 载入/保存(手动)
FindObjectOfType().Load();
FindObjectOfType().Save();