UpData.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. for (int i = 0; i < saveData.Count; i++)
  43. {
  44. if (saveData[i].isUpData)
  45. {
  46. ShowPrefab obj = Instantiate(showPrefab, showParent);
  47. obj.text.text = "题号" + i;
  48. createGameObjects.Add(obj.gameObject);
  49. if (saveData[i].isRight)
  50. {
  51. obj.falseObject.SetActive(false);
  52. obj.trueObject.SetActive(true);
  53. arrayData.correctCount += 1;
  54. }
  55. else
  56. {
  57. obj.falseObject.SetActive(true);
  58. obj.trueObject.SetActive(false);
  59. WrongQuestionsItem item = new WrongQuestionsItem();
  60. if (state == 1)
  61. {
  62. item.questionId = "KTXW" + i.ToString("D3");
  63. }
  64. else
  65. {
  66. item.questionId = "GJRZ" + i.ToString("D3");
  67. }
  68. item.userWrongOption = saveData[i].selectIndex;
  69. arrayData.wrongQuestions.Add(item);
  70. arrayData.wrongCount += 1;
  71. }
  72. }
  73. if (saveData[i].isRight)
  74. {
  75. rightNumber += 1;
  76. }
  77. }
  78. rightText.text = "答对:" + rightNumber;
  79. if (state == 1)
  80. {
  81. topText.text = "课堂行为管理";
  82. }
  83. else
  84. {
  85. topText.text = "高级认知提问";
  86. }
  87. }
  88. public void CallBack(string value)
  89. {
  90. JObject keyValuePairs;
  91. try
  92. {
  93. keyValuePairs = JObject.Parse(value);
  94. }
  95. catch
  96. {
  97. keyValuePairs = null;
  98. }
  99. if (keyValuePairs!=null)
  100. {
  101. string code = keyValuePairs["code"].ToString();
  102. Debug.Log(code);
  103. if (code == "200")
  104. {
  105. t2.SetActive(true);
  106. }
  107. else
  108. {
  109. t1.SetActive(true);
  110. }
  111. }
  112. }
  113. public void StartUpDate()
  114. {
  115. Login.Instance.SendList(arrayData, CallBack);
  116. }
  117. }
粤ICP备19079148号