using NEducation.Controllers; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Web; namespace NEducation.Code { public class Question { public String id { get; set; } public String name { get; set; } public String description { get; set; } public String iconPath { get; set; } public String questionType { get; set; } public String content { get; set; } public String contentType { get; set; } public String answerTrue { get; set; } public String answer1 { get; set; } public String answer2 { get; set; } public String answer3 { get; set; } public String answer4 { get; set; } // parse data from JSON data public Question() { } public Question(string json) : this(JObject.Parse(json)) { } public Question(JObject jObject) { if (jObject != null) { id = (string)jObject["ID"]; name = (string)jObject["NAME"]; description = (string)jObject["DESCRIPTION"]; iconPath = UtilsController.GetContentPath.QuestionContentPath + (string)jObject["ICON_PATH"]; questionType = (string)jObject["QUESTION_TYPE"]; answerTrue = (string)jObject["ANSWER_TRUE"]; contentType = (string)jObject["CONTENT_TYPE"]; if (contentType == UtilsController.GetContentType.AUDIO_FILE || contentType == UtilsController.GetContentType.PICTURE_FILE || contentType == UtilsController.GetContentType.VIDEO_FILE) content = UtilsController.GetContentPath.QuestionContentPath + (string)jObject["CONTENT"]; else content = (string)jObject["CONTENT"]; answer1 = (string)jObject["ANSWER1"]; answer2 = (string)jObject["ANSWER2"]; answer3 = (string)jObject["ANSWER3"]; answer4 = (string)jObject["ANSWER4"]; } } } }