UpData.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class UpData : MonoBehaviour
  8. {
  9. public GameObject canvas;
  10. public ShowPrefab showPrefab;
  11. public Transform showParent;
  12. private List<GameObject> createGameObjects;
  13. private ArrayData arrayData;
  14. public GameObject t1;
  15. public GameObject t2;
  16. public Text rightText;
  17. public Text topText;
  18. void Start()
  19. {
  20. }
  21. // Update is called once per frame
  22. void Update()
  23. {
  24. }
  25. public void Init(List<QuestionData> saveData, int state)
  26. {
  27. float rightNumber = 0;
  28. if (createGameObjects != null)
  29. {
  30. for (int i = 0; i < createGameObjects.Count; i++)
  31. {
  32. Destroy(createGameObjects[i]);
  33. }
  34. }
  35. canvas.SetActive(true);
  36. gameObject.SetActive(true);
  37. createGameObjects = new List<GameObject>();
  38. arrayData = new ArrayData();
  39. arrayData.wrongCount = 0;
  40. arrayData.correctCount = 0;
  41. arrayData.wrongQuestions = new List<WrongQuestionsItem>();
  42. arrayData.type = state;
  43. for (int i = 0; i < saveData.Count; i++)
  44. {
  45. if (saveData[i].isUpData)
  46. {
  47. ShowPrefab obj = Instantiate(showPrefab, showParent);
  48. obj.text.text = "题号" + i;
  49. createGameObjects.Add(obj.gameObject);
  50. if (saveData[i].isRight)
  51. {
  52. obj.falseObject.SetActive(false);
  53. obj.trueObject.SetActive(true);
  54. arrayData.correctCount += 1;
  55. }
  56. else
  57. {
  58. obj.falseObject.SetActive(true);
  59. obj.trueObject.SetActive(false);
  60. WrongQuestionsItem item = new WrongQuestionsItem();
  61. if (state == 1)
  62. {
  63. item.questionId = "KTXW" + (i + 1).ToString("D3");
  64. }
  65. else
  66. {
  67. item.questionId = "GJRZ" + (i + 1).ToString("D3");
  68. }
  69. item.userWrongOption = saveData[i].selectIndex;
  70. arrayData.wrongQuestions.Add(item);
  71. arrayData.wrongCount += 1;
  72. }
  73. }
  74. if (saveData[i].isRight)
  75. {
  76. rightNumber += 1;
  77. }
  78. }
  79. rightText.text = "答对:" + rightNumber;
  80. if (state == 1)
  81. {
  82. topText.text = "课堂行为管理";
  83. }
  84. else
  85. {
  86. topText.text = "高级认知提问";
  87. }
  88. }
  89. public void CallBack(string value)
  90. {
  91. JObject keyValuePairs;
  92. try
  93. {
  94. keyValuePairs = JObject.Parse(value);
  95. }
  96. catch
  97. {
  98. keyValuePairs = null;
  99. }
  100. if (keyValuePairs != null)
  101. {
  102. string code = keyValuePairs["code"].ToString();
  103. Debug.Log(code);
  104. if (code == "200")
  105. {
  106. t2.SetActive(true);
  107. }
  108. else
  109. {
  110. t1.SetActive(true);
  111. }
  112. }
  113. }
  114. public void StartUpDate()
  115. {
  116. Login.Instance.SendList(arrayData, CallBack);
  117. }
  118. }
粤ICP备19079148号