You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
309 lines
12 KiB
309 lines
12 KiB
using UnityEngine; |
|
using System.Collections; |
|
using System; |
|
using UnityEngine.UI; |
|
using AX.TrackRecord; |
|
using System.Collections.Generic; |
|
using AX.NetworkSystem; |
|
using System.IO; |
|
using System.Xml; |
|
using System.Text; |
|
using AX.MessageSystem; |
|
|
|
public class MakeScoreGenerateStudentsManager : BaseItemManager { |
|
public override void SetItemPrefab() |
|
{ |
|
ItemPrefab = Resources.Load<GameObject>("UIPrefab/Examination/QuestionScorePrefab"); |
|
} |
|
public override void CheckIfShowSubmitButton() |
|
{ |
|
|
|
} |
|
[HideInInspector] |
|
public GameObject EditSaveBtn; |
|
[HideInInspector] |
|
public GameObject EditGiveUpBtn; |
|
public override void Awake() |
|
{ |
|
SetItemPrefab(); |
|
ParentGrid = transform.Find("StudentSelectWin/ScrollView/Viewport/Content").gameObject; |
|
ExamNameText = transform.Find("CaptionText").GetComponent<Text>(); |
|
EditSaveBtn = transform.Find("EditSaveButton").gameObject; |
|
EditGiveUpBtn = transform.Find("EditGiveUpButton").gameObject; |
|
GetAnswerListFromServer(); |
|
|
|
} |
|
|
|
void Start() |
|
{ |
|
GenerateQuestionItem(); |
|
} |
|
|
|
private void GetAnswerListFromServer() |
|
{ |
|
//连接服务器,获取该场考试下该道考题的所有答案及对应考生信息,刷新到考生列表 |
|
//访问答案数据表,根据考试ID、考题ID获取答案信息列表。AnswerInfo字段跟Question字段基本一致,此处使用Question代替AnswerInfo |
|
//因为答案列表刷新的是附带Question属性的Item |
|
//列表每一项显示的是考生姓名 |
|
//所有的答案Xml文件下载到本地answer文件夹 |
|
//ToDo... |
|
|
|
//ExamNameText.text = CurExam.QuestionInfos.Find(delegate (QuestionInfo q) { return q.ID == CurQuestionID; }).Name;//获取考题题目 |
|
ExamNameText.text = CurExam.QuestionInfos.Find((q) => { return q.ID == CurQuestionID; }).Name; |
|
var ansList = CurExam.AnswerInfos;//答案列表,筛选属于该道考题的答案 |
|
exam = CurExam; |
|
items.Clear();//将符合条件的答案数据塞入questionList |
|
for (int i = 0; i < ansList.Count; i++) |
|
{ |
|
if (CurQuestionID == ansList[i].QuestionID) |
|
{ |
|
QuestionInfo question = new QuestionInfo(); |
|
question.Name = ansList[i].CreatorName;//获取该答案的考生姓名 |
|
question.FilePath = ansList[i].FilePath;//获取该答案的Xml文件路径 |
|
question.CreatorID = ansList[i].CreatorID;//获取该答案的考生ID |
|
question.ID = ansList[i].ID;//获取该答案的答案ID |
|
question.CreatorName = ansList[i].QuestionID.ToString();//获取该答案的考题ID |
|
items.Add(question); |
|
} |
|
} |
|
|
|
} |
|
/// <summary> |
|
/// 选中一条答案,开始评分 |
|
/// </summary> |
|
public void MakeScoreButton() |
|
{ |
|
Text funcInfo = transform.Find("MakeScoreButton").GetComponentInChildren<Text>(); |
|
GameObject AddTagBtn = GameObject.Find("Canvas").transform.Find("AddTag").gameObject; |
|
|
|
if (funcInfo.text == "打分") |
|
{ |
|
string filename = "Answers/" + question.ID + "/" + question.FilePath; |
|
Record_One_root record_Load = TrackRecordHelpClass.LoadRecord_DeserializeXMLToRecord(filename); |
|
if (!record_Load.AlreadyAnswered) |
|
{ |
|
MessageDispatcher.SendMessage( "Operatinghints", (object)"此条没有作答"); |
|
return; |
|
} |
|
funcInfo.text = "保存"; |
|
AddTagBtn.SetActive(true); |
|
//选中某一个考生,加载其答案开始打分记录 |
|
Debug.Log(CurQuestionID); |
|
|
|
NodeSet.Instance.LoadRecordFromFile(filename); |
|
TheBackView.instance.EndBtn.SetActive(true); |
|
LoadManager.Instance.IsMakeScore = true; |
|
//MakeSorceSet.instance.stopped = false;//右下时间开始计时 |
|
} |
|
else |
|
{ |
|
AddTagBtn.SetActive(false); |
|
//点击保存时暂停记录 |
|
if (!LoadManager.Instance.IsPause) |
|
{ |
|
TheBackView.instance.ZanTing(); |
|
} |
|
GameObject TipWindow = Instantiate(Resources.Load<GameObject>("UIPrefab/TipWindow")); |
|
TipWindow.GetComponent<TipWindowManager>().SetWindow( |
|
"确定保存?", new UnityEngine.Events.UnityAction(OKSaveScoreButton), new UnityEngine.Events.UnityAction(NOSaveScoreButton)); |
|
} |
|
} |
|
/// <summary> |
|
/// 保存评分 |
|
/// </summary> |
|
|
|
private void OKSaveScoreButton() |
|
{ |
|
transform.Find("MakeScoreButton").GetComponentInChildren<Text>().text = "打分"; |
|
//结束评分录制,保存Xml文件,放到本地score文件夹 |
|
//使用的是record_load |
|
//string filename = "Scores/" + question.ID + ".xml";//该条评分Xml文件以答案ID命名(answer数据塞入了question对象中) |
|
|
|
//自动算一下总分数 |
|
var list = LoadManager.Instance.record_Load.EventList; |
|
int sumScore = 100;//总分0,负数值//总分改为100分 |
|
|
|
for (int i = 0; i < list.Count; i++) |
|
{ |
|
if (list[i].eventType == eventTypeRecord.AddLoadTag || list[i].eventType == eventTypeRecord.AddGpcAUTOTag |
|
|| list[i].eventType == eventTypeRecord.ZongJiePingPanTag) |
|
{ |
|
|
|
var score=0; |
|
if (list[i].eventType == eventTypeRecord.AddLoadTag) |
|
{ |
|
if (list[i].objAttriList[0].ObjName == "") |
|
{ |
|
score = 0; |
|
} |
|
else |
|
{ |
|
score = int.Parse(list[i].objAttriList[0].ObjName); |
|
} |
|
} |
|
else if (list[i].eventType == eventTypeRecord.ZongJiePingPanTag) |
|
{ |
|
if(list[i].ScoreAttri.Count>0) |
|
{ |
|
score = list[i].ScoreAttri[0].AllScore; |
|
} |
|
} |
|
else if(list[i].eventType == eventTypeRecord.AddGpcAUTOTag) |
|
{ |
|
if (list[i].objAttriList[0].ObjName == "") |
|
{ |
|
score=0; |
|
}else |
|
{ |
|
score = int.Parse(list[i].objAttriList[0].ObjName); |
|
} |
|
|
|
} |
|
sumScore += -score; |
|
} |
|
} |
|
|
|
if (sumScore < 0) |
|
{ |
|
sumScore = 0; |
|
} |
|
|
|
//发送评分请求 |
|
ScoreInfo scoreI = new ScoreInfo(); |
|
scoreI.FilePath = question.ID + ".xml";//评分文件用答案ID命名 |
|
scoreI.CreatorName = MySelf.mySelf.Name; |
|
scoreI.CreatorID = MySelf.mySelf.ID; |
|
scoreI.AnswerID = question.ID; |
|
scoreI.QuestionID = long.Parse(question.CreatorName); |
|
scoreI.Score = sumScore.ToString();//ToDo... |
|
scoreI.ExaminationID = CurExam.ID; |
|
scoreI.PaperID = CurExam.PaperID; |
|
scoreI.ID = CheckScorIDTOXml(scoreI); |
|
|
|
//查找 |
|
//NetworkManager.Default.SendRequestAsync("MARKING_SAVE_REQUEST", scoreI);//评分请求 |
|
for (int i = 0; i < MakeSorceSet.instance.ScoreList.Count; i++) |
|
{ |
|
if (MakeSorceSet.instance.ScoreList[i].FilePath.Equals(scoreI.FilePath)) |
|
{ |
|
MakeSorceSet.instance.ScoreList.RemoveAt(i); |
|
} |
|
} |
|
MakeSorceSet.instance.ScoreList.Add(scoreI); |
|
//确定保存评分,调用回放结束模块 |
|
LoadManager.Instance.ExePlayBackOverEvent(true); |
|
|
|
string filename = "Scores/" + question.ID + ".xml"; |
|
LoadManager.Instance.SubmitScore(filename); |
|
string path = ExamInfoHelpClass.CurrentWorkPath + "/" + filename; |
|
if (File.Exists(path)) |
|
{ |
|
CurSelectedTrans.GetComponent<MakeScoreStudentQuestionItem>().ShowBtn(true); |
|
} |
|
|
|
//对于已评分的考生答案项,显示查看评分按钮 |
|
//ShowViewScoreButton(); |
|
//CurSelectedTrans.gameObject.SetActive(false); |
|
TheBackView.instance.ShowText.SetActive(false); |
|
transform.Find("MakeScoreButton").gameObject.SetActive(false); |
|
LoadManager.Instance.LoadTimer = 0; |
|
} |
|
public long CheckScorIDTOXml(ScoreInfo SCORE) |
|
{ |
|
string path = Application.dataPath + @"/ExtendFolder/xml/" + MySelf.mySelf.ID + "/" + "SocreData.xml"; |
|
if (File.Exists(path)) |
|
{ |
|
XmlDocument xmlDoc = new XmlDocument(); |
|
xmlDoc.Load(path); |
|
XmlNode root = xmlDoc.SelectSingleNode("ScoreAssets"); |
|
XmlNodeList nodeList = root.ChildNodes; |
|
|
|
foreach (XmlElement elem in nodeList) |
|
{ |
|
if (elem.Name == "Child") |
|
{ |
|
|
|
foreach (XmlElement sore in elem) |
|
{ |
|
if (sore.Name == "score") |
|
{ |
|
if (sore.GetAttribute("AnwserID") == SCORE.AnswerID.ToString() && sore.GetAttribute("CreatID") == SCORE.CreatorID.ToString()) |
|
{ |
|
return long.Parse(sore.GetAttribute("ScoreID")); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return long.Parse("0"); |
|
} |
|
return long.Parse("0"); |
|
} |
|
|
|
private void ShowViewScoreButton() |
|
{ |
|
//当前选中的已评分的项显示出查看按钮 |
|
CurSelectedTrans.Find("check").gameObject.SetActive(true); |
|
} |
|
public void EditSaveScoreButton() |
|
{ |
|
OKSaveScoreButton(); |
|
GameObject.Find("Canvas").transform.Find("AddTag").gameObject.SetActive(false); |
|
EditSaveBtn.SetActive(false); |
|
EditGiveUpBtn.SetActive(false); |
|
} |
|
public void EditGiveUpButton() |
|
{ |
|
GameObject TipWindow = Instantiate(Resources.Load<GameObject>("UIPrefab/TipWindow")); |
|
TipWindow.GetComponent<TipWindowManager>().SetWindow( |
|
"是否删除评分?", new UnityEngine.Events.UnityAction(OKEditScoreButton), new UnityEngine.Events.UnityAction(NOEditScoreButton)); |
|
TheBackView.instance.ZanTing(); |
|
} |
|
private void OKEditScoreButton() |
|
{ |
|
EditSaveBtn.SetActive(false); |
|
EditGiveUpBtn.SetActive(false); |
|
GameObject.Find("Canvas").transform.Find("AddTag").gameObject.SetActive(false); |
|
TheBackView.instance.MakeSoreEnd(); |
|
} |
|
private void NOEditScoreButton() |
|
{ |
|
TheBackView.instance.BoFang(); |
|
} |
|
private void NOSaveScoreButton() |
|
{ |
|
//继续开始记录 |
|
if (LoadManager.Instance.LoadTimer != 0) |
|
{ |
|
TheBackView.instance.BoFang(); |
|
if (GameObject.Find("Canvas").transform.Find("时间轴").gameObject.activeInHierarchy) |
|
{ |
|
GameObject.Find("Canvas").transform.Find("AddTag").gameObject.SetActive(true); |
|
} |
|
} |
|
} |
|
|
|
public override void CheckIfHasFile(List<QuestionInfo> items) |
|
{ |
|
//下载所有的答案文件 |
|
var fList = new List<string>(); |
|
for(int i = 0; i < items.Count; i++) |
|
{ |
|
var filename = "Answers/" + items[i].ID + "/" + items[i].FilePath; |
|
if (!File.Exists(ExamInfoHelpClass.CurrentWorkPath + filename)) |
|
{ |
|
fList.Add(filename); |
|
} |
|
} |
|
string[] files = fList.ToArray(); |
|
if (files.Length > 0) |
|
{ |
|
if (GameObject.Find("FileTransTipWindow"))//如果已经存在文件传输窗口,不再相应 |
|
return; |
|
//下载文件 |
|
GameObject FileTransTipWin = Instantiate(Resources.Load<GameObject>("UIPrefab/FileTransTipWin")); |
|
FileTransTipWin.GetComponent<FileTransTipWinManager>().SetWindow( |
|
"Download", files, TransferType.Download); |
|
} |
|
} |
|
}
|
|
|