| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class UpData : MonoBehaviour
- {
- public GameObject canvas;
- public ShowPrefab showPrefab;
- public Transform showParent;
- private List<GameObject> createGameObjects;
- private ArrayData arrayData;
- public GameObject t1;
- public GameObject t2;
- public Text rightText;
- public Text topText;
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- public void Init(List<QuestionData> saveData, int state)
- {
- float rightNumber = 0;
- if (createGameObjects != null)
- {
- foreach (GameObject item in createGameObjects)
- {
- Destroy(item);
- }
- }
- canvas.SetActive(true);
- gameObject.SetActive(true);
- createGameObjects = new List<GameObject>();
- arrayData = new ArrayData();
- arrayData.wrongCount = 0;
- arrayData.correctCount = 0;
- arrayData.wrongQuestions = new List<WrongQuestionsItem>();
- for (int i = 0; i < saveData.Count; i++)
- {
- if (saveData[i].isUpData)
- {
- ShowPrefab obj = Instantiate(showPrefab, showParent);
- obj.text.text = "题号" + i;
- createGameObjects.Add(showPrefab.gameObject);
- if (saveData[i].isRight)
- {
- obj.falseObject.SetActive(false);
- obj.trueObject.SetActive(true);
- arrayData.correctCount += 1;
- }
- else
- {
- obj.falseObject.SetActive(true);
- obj.trueObject.SetActive(false);
- WrongQuestionsItem item = new WrongQuestionsItem();
- item.questionId = i.ToString();
- item.userWrongOption = saveData[i].selectIndex;
- arrayData.wrongQuestions.Add(item);
- arrayData.wrongCount += 1;
- }
- }
- if (saveData[i].isRight)
- {
- rightNumber += 1;
- }
- }
- rightText.text = "答对:" + rightNumber;
- if (state == 1)
- {
- topText.text = "课堂行为管理";
- }
- else
- {
- topText.text = "高级认知提问";
- }
- }
- public void CallBack(string value)
- {
- JObject keyValuePairs = JObject.Parse(value);
- string code = keyValuePairs["code"].ToString();
- Debug.Log(code);
- if (code == "200")
- {
- t2.SetActive(true);
- }
- else
- {
- t1.SetActive(true);
- }
- }
- public void StartUpDate()
- {
- Login.Instance.SendList(arrayData, CallBack);
- }
- }
|