Question.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using NEducation.Controllers;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Web;
  8. namespace NEducation.Code
  9. {
  10. public class Question
  11. {
  12. public String id { get; set; }
  13. public String name { get; set; }
  14. public String description { get; set; }
  15. public String iconPath { get; set; }
  16. public String questionType { get; set; }
  17. public String content { get; set; }
  18. public String contentType { get; set; }
  19. public String answerTrue { get; set; }
  20. public String answer1 { get; set; }
  21. public String answer2 { get; set; }
  22. public String answer3 { get; set; }
  23. public String answer4 { get; set; }
  24. // parse data from JSON data
  25. public Question() { }
  26. public Question(string json) : this(JObject.Parse(json))
  27. { }
  28. public Question(JObject jObject)
  29. {
  30. if (jObject != null)
  31. {
  32. id = (string)jObject["ID"];
  33. name = (string)jObject["NAME"];
  34. description = (string)jObject["DESCRIPTION"];
  35. iconPath = UtilsController.GetContentPath.QuestionContentPath + (string)jObject["ICON_PATH"];
  36. questionType = (string)jObject["QUESTION_TYPE"];
  37. answerTrue = (string)jObject["ANSWER_TRUE"];
  38. contentType = (string)jObject["CONTENT_TYPE"];
  39. if (contentType == UtilsController.GetContentType.AUDIO_FILE ||
  40. contentType == UtilsController.GetContentType.PICTURE_FILE ||
  41. contentType == UtilsController.GetContentType.VIDEO_FILE)
  42. content = UtilsController.GetContentPath.QuestionContentPath + (string)jObject["CONTENT"];
  43. else
  44. content = (string)jObject["CONTENT"];
  45. answer1 = (string)jObject["ANSWER1"];
  46. answer2 = (string)jObject["ANSWER2"];
  47. answer3 = (string)jObject["ANSWER3"];
  48. answer4 = (string)jObject["ANSWER4"];
  49. }
  50. }
  51. }
  52. }