/// <summary> /// loads the annotations /// is called when the rest query has finished /// </summary> /// <param name="res">The finished web request</param> /// <param name="args">Additional arguments which have been passed through the rest-query</param> protected void Load(UnityWebRequest res, object[] args) { if (res.responseCode == 200) { JsonAnnotationArray array = JsonUtility.FromJson <JsonAnnotationArray>(res.downloadHandler.text); annotations = array.array; ShowAllAnnotations(); } }
/// <summary> /// saves the current set of annotations as a quiz /// </summary> /// <param name="name">The name of the quiz</param> public void SaveAsQuiz(string name) { string subQuizPathName = "/resources/quiz/save/" + objectInfo.ModelName + "/"; JsonAnnotationArray array = new JsonAnnotationArray(); array.array = annotations; string jsonPost = JsonUtility.ToJson(array); RestManager.Instance.POST(InformationManager.Instance.FullBackendAddress + subQuizPathName + name, jsonPost); }
/// <summary> /// Saves the quiz if the PlayerType is not STUDENT /// </summary> protected override void Save(bool synchronize) { if (InformationManager.Instance.playerType != PlayerType.STUDENT) { // if not student => save the quiz itself JsonAnnotationArray array = new JsonAnnotationArray(); array.array = annotations; string jsonPost = JsonUtility.ToJson(array); RestManager.Instance.POST(InformationManager.Instance.FullBackendAddress + subPathSave + QuizName, jsonPost); // also save the gamification SaveGamification(); } }
/// <summary> /// loads the annotations /// is called when the rest query has finished /// </summary> /// <param name="res">The finished web request</param> /// <param name="args">Additional arguments which have been passed through the rest-query</param> protected void Load(UnityWebRequest res, object[] args) { if (res.responseCode == 200) { JsonAnnotationArray array = JsonUtility.FromJson <JsonAnnotationArray>(res.downloadHandler.text); annotations = array.array; ShowAllAnnotations(); Debug.Log("Loaded annotations. Show them"); if (InformationManager.Instance.playerType == PlayerType.STUDENT) { } } else { Debug.Log("Could not load annotations: " + res.error); } }
/// <summary> /// saves all annotations by communicating the list of annotations to the backend /// </summary> protected virtual void Save(bool synchronize = true) { JsonAnnotationArray array = new JsonAnnotationArray(); array.array = annotations; string jsonPost = JsonUtility.ToJson(array); RestManager.Instance.POST(InformationManager.Instance.FullBackendAddress + subPathSave, jsonPost, (req) => { if (synchronize && CustomMessages.Instance != null) { CustomMessages.Instance.SendAnnotationsUpdated(objectInfo.ModelName); } } ); }