191 lines
5.8 KiB
C#
191 lines
5.8 KiB
C#
using SGUnitySDK.Etys;
|
|
using SGUnitySDK.Services.SGStartParams;
|
|
using SGUnitySDK;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using NPOI.OpenXml4Net.OPC.Internal;
|
|
using Newtonsoft.Json;
|
|
using SGUnitySDK.Services.HTTP;
|
|
using SGUnitySDK.Utils;
|
|
using System;
|
|
|
|
public class MyManage : MonoBehaviour
|
|
{
|
|
public static MyManage instance;
|
|
/// <summary>
|
|
/// 平台人员信息
|
|
/// </summary>
|
|
public MyUserData userData;
|
|
/// <summary>
|
|
/// 启动信息
|
|
/// </summary>
|
|
public SGAppStartMode startMode;
|
|
/// <summary>
|
|
/// 模式
|
|
/// </summary>
|
|
public PlayModeEnum playModeEnum;
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
//初始化
|
|
SGUConfig config = new SGUConfig();
|
|
SGUSdk.GetInstance().InitSDK(config);
|
|
startMode = SGUSdk.GetInstance().GetAppStartMode();
|
|
|
|
//获取用户信息
|
|
HttpAuthService getUserInfo = new HttpAuthService();
|
|
ResponObject responObject1 = getUserInfo.GetUserInfo();
|
|
if(responObject1.code=="200")
|
|
{
|
|
string data1 = responObject1.data.ToString();
|
|
Debug.Log("GetUserInfo:" + data1);
|
|
userData = JsonConvert.DeserializeObject<MyUserData>(data1);
|
|
|
|
//判断模式
|
|
if (startMode.examId > 0)
|
|
{
|
|
//考试
|
|
playModeEnum = PlayModeEnum.考试;
|
|
HttpExamService getPractiseInfo = new HttpExamService();
|
|
ResponObject responObject = getPractiseInfo.PrepareExam(startMode.examId, userData.id);
|
|
if(responObject.code=="200")
|
|
{
|
|
string data = responObject.data.ToString();
|
|
Debug.Log("考生获取考试题目" + data);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("获取考试失败:" + responObject.msg);
|
|
}
|
|
}
|
|
else if (startMode.practiseId > 0)
|
|
{
|
|
//练习
|
|
playModeEnum = PlayModeEnum.练习;
|
|
HttpPractiseService getPractiseInfo = new HttpPractiseService();
|
|
ResponObject responObject = getPractiseInfo.GetPractiseInfo(startMode.practiseId);
|
|
if(responObject.code=="200")
|
|
{
|
|
string data = responObject.data.ToString();
|
|
Debug.Log("GetPractiseInfo:" + data);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("获取练习失败:" + responObject.msg);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("获取用户失败:" + responObject1.msg);
|
|
return;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始练习
|
|
/// </summary>
|
|
/// <param name="practiseId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="startTime"></param>
|
|
public void GetStartPractise()
|
|
{
|
|
//try
|
|
{
|
|
HttpPractiseService getPractiseInfo = new HttpPractiseService();
|
|
ResponObject responObject = getPractiseInfo.StartPractise(startMode.practiseId, userData.id, DateTime.Now.ToString());
|
|
if(responObject.code=="200")
|
|
{
|
|
string data = responObject.data.ToString();
|
|
Debug.Log("返回" + data);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(responObject.msg);
|
|
}
|
|
}
|
|
//catch (System.Exception e)
|
|
//{
|
|
// throw;
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交练习
|
|
/// </summary>
|
|
/// <param name="practiseId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="answerList"></param>
|
|
public void GetUploadPracticeAnswer(List<SGAnswer> answerList)
|
|
{
|
|
HttpPractiseService getPractiseInfo = new HttpPractiseService();
|
|
ResponObject responObject = getPractiseInfo.UploadAnswer(startMode.practiseId, userData.id, answerList);
|
|
string data = responObject.data.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交练习
|
|
/// </summary>
|
|
/// <param name="practiseId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="endTime"></param>
|
|
public void GetEndPractise()
|
|
{
|
|
HttpPractiseService getPractiseInfo = new HttpPractiseService();
|
|
ResponObject responObject = getPractiseInfo.EndPractise(startMode.practiseId, userData.id, DateTime.Now.ToString());
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始考试
|
|
/// </summary>
|
|
/// <param name="examInfoId"></param>
|
|
/// <param name="userId"></param>
|
|
public void GetStartExam()
|
|
{
|
|
HttpExamService getPractiseInfo = new HttpExamService();
|
|
ResponObject responObject = getPractiseInfo.StartExam(startMode.examId, userData.id);
|
|
string data = responObject.data.ToString();
|
|
Debug.Log("开始考试" + data);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交考试
|
|
/// </summary>
|
|
/// <param name="examInfoId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <param name="answerList"></param>
|
|
public void GetUploadExamAnswer(List<SGAnswer> answerList)
|
|
{
|
|
HttpExamService getPractiseInfo = new HttpExamService();
|
|
ResponObject responObject = getPractiseInfo.UploadAnswer(startMode.examId, userData.id, answerList);
|
|
string data = responObject.data.ToString();
|
|
Debug.Log("提交答题数据" + data);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 结束考试
|
|
/// </summary>
|
|
/// <param name="examInfoId"></param>
|
|
/// <param name="userId"></param>
|
|
public void GetEndExam()
|
|
{
|
|
HttpExamService getPractiseInfo = new HttpExamService();
|
|
ResponObject responObject = getPractiseInfo.EndExam(startMode.examId, userData.id);
|
|
string data = responObject.data.ToString();
|
|
Debug.Log("结束考试" + data);
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 模式
|
|
/// </summary>
|
|
public enum PlayModeEnum
|
|
{
|
|
练习,
|
|
考试
|
|
} |