2023-12-10 12:28:20 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace ZXL.Excel
|
|
|
|
|
{
|
|
|
|
|
public enum QuestionType
|
|
|
|
|
{
|
|
|
|
|
单选题,
|
|
|
|
|
多选题,
|
|
|
|
|
判断题
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class SingleChoice_QuestionBank_A_Data
|
|
|
|
|
{
|
|
|
|
|
private readonly QuestionType questionType = QuestionType.单选题;
|
|
|
|
|
private List<SingleChoice_QuestionBank_A_DataInfo> _list;
|
|
|
|
|
|
|
|
|
|
public List<SingleChoice_QuestionBank_A_DataInfo> data => _list;
|
|
|
|
|
|
|
|
|
|
public SingleChoice_QuestionBank_A_Data(List<SingleChoice_QuestionBank_A_DataInfo> list)
|
|
|
|
|
{
|
|
|
|
|
_list = list;
|
|
|
|
|
foreach (var infos in _list)
|
|
|
|
|
{
|
|
|
|
|
List<string> strings = new List<string>();
|
2023-12-30 14:20:55 +08:00
|
|
|
|
for (int i = 0; i < infos.options.Length; i++)
|
2023-12-10 12:28:20 +08:00
|
|
|
|
{
|
2023-12-30 14:20:55 +08:00
|
|
|
|
var infosOption = infos.options[i].Trim();
|
2023-12-10 12:28:20 +08:00
|
|
|
|
strings.Add(infosOption);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infos.options = strings.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-30 14:20:55 +08:00
|
|
|
|
public void Remove(string id)
|
|
|
|
|
{
|
|
|
|
|
for (var i = 0; i < _list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (_list[i].id == id)
|
|
|
|
|
_list.Remove(_list[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-10 12:28:20 +08:00
|
|
|
|
public SingleChoice_QuestionBank_A_DataInfo RandomGet()
|
|
|
|
|
{
|
|
|
|
|
SingleChoice_QuestionBank_A_DataInfo info = null;
|
2023-12-30 14:20:55 +08:00
|
|
|
|
if (_list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-10 12:28:20 +08:00
|
|
|
|
var range = Random.Range(0, _list.Count);
|
|
|
|
|
info = _list[range];
|
|
|
|
|
_list.RemoveAt(range);
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SingleChoice_QuestionBank_A_DataInfo RandomGet(bool isAutoRemove)
|
|
|
|
|
{
|
|
|
|
|
SingleChoice_QuestionBank_A_DataInfo info = null;
|
2023-12-30 14:20:55 +08:00
|
|
|
|
if (_list.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-10 12:28:20 +08:00
|
|
|
|
var range = Random.Range(0, _list.Count);
|
|
|
|
|
info = _list[range];
|
|
|
|
|
if (isAutoRemove)
|
|
|
|
|
_list.RemoveAt(range);
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class SingleChoice_QuestionBank_A_DataInfo
|
|
|
|
|
{
|
|
|
|
|
public string id;
|
|
|
|
|
public string topic;
|
|
|
|
|
public string[] options;
|
|
|
|
|
public string[] answer;
|
|
|
|
|
|
|
|
|
|
public SingleChoice_QuestionBank_A_DataInfo(string id, string topic, string[] options, string[] answer)
|
|
|
|
|
{
|
|
|
|
|
this.id = id;
|
|
|
|
|
this.topic = topic;
|
|
|
|
|
this.options = options;
|
|
|
|
|
this.answer = answer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|