UpData.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. foreach (GameObject item in createGameObjects)
  31. {
  32. Destroy(item);
  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(showPrefab.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. item.questionId = i.ToString();
  61. item.userWrongOption = saveData[i].selectIndex;
  62. arrayData.wrongQuestions.Add(item);
  63. arrayData.wrongCount += 1;
  64. }
  65. }
  66. if (saveData[i].isRight)
  67. {
  68. rightNumber += 1;
  69. }
  70. }
  71. rightText.text = "答对:" + rightNumber;
  72. if (state == 1)
  73. {
  74. topText.text = "课堂行为管理";
  75. }
  76. else
  77. {
  78. topText.text = "高级认知提问";
  79. }
  80. }
  81. public void CallBack(string value)
  82. {
  83. JObject keyValuePairs = JObject.Parse(value);
  84. string code = keyValuePairs["code"].ToString();
  85. Debug.Log(code);
  86. if (code == "200")
  87. {
  88. t2.SetActive(true);
  89. }
  90. else
  91. {
  92. t1.SetActive(true);
  93. }
  94. }
  95. public void StartUpDate()
  96. {
  97. Login.Instance.SendList(arrayData, CallBack);
  98. }
  99. }
粤ICP备19079148号