QuizQuestion.class.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once 'Resource.class.php';
  4. /**
  5. * Exercises questions backup script
  6. * Class QuizQuestion
  7. * @author Bart Mollet <bart.mollet@hogent.be>
  8. * @package chamilo.backup
  9. */
  10. class QuizQuestion extends Resource
  11. {
  12. /**
  13. * The question
  14. */
  15. public $question;
  16. /**
  17. * The description
  18. */
  19. public $description;
  20. /**
  21. * Ponderation
  22. */
  23. public $ponderation;
  24. /**
  25. * Type
  26. */
  27. public $quiz_type;
  28. /**
  29. * Position
  30. */
  31. public $position;
  32. /**
  33. * Level
  34. */
  35. public $level;
  36. /**
  37. * Answers
  38. */
  39. public $answers;
  40. /**
  41. * Picture
  42. */
  43. public $picture;
  44. public $extra;
  45. /**
  46. * @var int the question category if any, 0 by default
  47. */
  48. public $question_category;
  49. /**
  50. * Create a new QuizQuestion
  51. * @param string $question
  52. * @param string $description
  53. * @param int $ponderation
  54. * @param int $type
  55. * @param int $position
  56. */
  57. public function __construct(
  58. $id,
  59. $question,
  60. $description,
  61. $ponderation,
  62. $type,
  63. $position,
  64. $picture,
  65. $level,
  66. $extra,
  67. $question_category = 0
  68. ) {
  69. parent::__construct($id, RESOURCE_QUIZQUESTION);
  70. $this->question = $question;
  71. $this->description = $description;
  72. $this->ponderation = $ponderation;
  73. $this->quiz_type = $type;
  74. $this->position = $position;
  75. $this->picture = $picture;
  76. $this->level = $level;
  77. $this->answers = array();
  78. $this->extra = $extra;
  79. $this->question_category = $question_category;
  80. }
  81. /**
  82. * Add an answer to this QuizQuestion
  83. */
  84. public function add_answer(
  85. $answer_id,
  86. $answer_text,
  87. $correct,
  88. $comment,
  89. $ponderation,
  90. $position,
  91. $hotspot_coordinates,
  92. $hotspot_type
  93. ) {
  94. $answer = array();
  95. $answer['id'] = $answer_id;
  96. $answer['answer'] = $answer_text;
  97. $answer['correct'] = $correct;
  98. $answer['comment'] = $comment;
  99. $answer['ponderation'] = $ponderation;
  100. $answer['position'] = $position;
  101. $answer['hotspot_coordinates'] = $hotspot_coordinates;
  102. $answer['hotspot_type'] = $hotspot_type;
  103. $this->answers[] = $answer;
  104. }
  105. public function add_option($option_obj)
  106. {
  107. $this->question_options[$option_obj->obj->id] = $option_obj;
  108. }
  109. /**
  110. * Show this question
  111. */
  112. public function show()
  113. {
  114. parent::show();
  115. echo $this->question;
  116. }
  117. }