lp_item.lib.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class lp_item
  5. * made to manipulate data of lp_item table
  6. *
  7. * This class is still incomplete
  8. * You can add lp_item database manipulation function here
  9. *
  10. */
  11. class LpItem
  12. {
  13. public $c_id = 0;
  14. public $id = 0;
  15. public $lp_id = 0;
  16. public $item_type = '';
  17. public $ref = '';
  18. public $title = '';
  19. public $description = '';
  20. public $path = '';
  21. public $min_score = 0;
  22. public $max_score = 0;
  23. public $mastery_score = 0;
  24. public $parent_item_id = 0;
  25. public $previous_item_id = 0;
  26. public $next_item_id = 0;
  27. public $display_order = 0;
  28. public $prerequisite = '';
  29. public $parameters = '';
  30. public $launch_data = '';
  31. public $max_time_allowed = '';
  32. public $terms = '';
  33. public $search_did = 0;
  34. public $audio = '';
  35. public function __construct($in_c_id = 0, $in_id = 0)
  36. {
  37. if ($in_c_id > 0 && $in_id > 0) {
  38. $item_view_table = Database::get_course_table(TABLE_LP_ITEM);
  39. $sql = "SELECT * FROM $item_view_table
  40. WHERE
  41. c_id=".intval($in_c_id)." AND
  42. id=".intval($in_id);
  43. $res = Database::query($sql);
  44. $data = Database::fetch_array($res);
  45. if (Database::num_rows($res) > 0) {
  46. $this->c_id = $data['c_id'];
  47. $this->id = $data['id'];
  48. $this->lp_id = $data['lp_id'];
  49. $this->item_type = $data['item_type'];
  50. $this->ref = $data['ref'];
  51. $this->title = $data['title'];
  52. $this->description = $data['description'];
  53. $this->path = $data['path'];
  54. $this->min_score = $data['min_score'];
  55. $this->max_score = $data['max_score'];
  56. $this->mastery_score = $data['mastery_score'];
  57. $this->parent_item_id = $data['parent_item_id'];
  58. $this->previous_item_id = $data['previous_item_id'];
  59. $this->next_item_id = $data['next_item_id'];
  60. $this->display_order = $data['display_order'];
  61. $this->prerequisite = $data['prerequisite'];
  62. $this->parameters = $data['parameters'];
  63. $this->launch_data = $data['launch_data'];
  64. $this->max_time_allowed = $data['max_time_allowed'];
  65. $this->terms = $data['terms'];
  66. $this->search_did = $data['search_did'];
  67. $this->audio = $data['audio'];
  68. }
  69. }
  70. }
  71. /**
  72. * Update in database
  73. */
  74. public function update_in_bdd()
  75. {
  76. $item_view_table = Database::get_course_table(TABLE_LP_ITEM);
  77. if ($this->c_id > 0 && $this->id > 0) {
  78. $sql = "UPDATE $item_view_table SET
  79. lp_id = '".intval($this->lp_id)."' ,
  80. item_type = '".Database::escape_string($this->item_type)."' ,
  81. ref = '".Database::escape_string($this->ref)."' ,
  82. title = '".Database::escape_string($this->title)."' ,
  83. description = '".Database::escape_string($this->description)."' ,
  84. path = '".Database::escape_string($this->path)."' ,
  85. min_score = '".Database::escape_string($this->min_score)."' ,
  86. max_score = '".Database::escape_string($this->max_score)."' ,
  87. mastery_score = '".Database::escape_string($this->mastery_score)."' ,
  88. parent_item_id = '".Database::escape_string($this->parent_item_id)."' ,
  89. previous_item_id = '".Database::escape_string($this->previous_item_id)."' ,
  90. next_item_id = '".Database::escape_string($this->next_item_id)."' ,
  91. display_order = '".Database::escape_string($this->display_order)."' ,
  92. prerequisite = '".Database::escape_string($this->prerequisite)."' ,
  93. parameters = '".Database::escape_string($this->parameters)."' ,
  94. launch_data = '".Database::escape_string($this->launch_data)."' ,
  95. max_time_allowed = '".Database::escape_string($this->max_time_allowed)."' ,
  96. terms = '".Database::escape_string($this->terms)."' ,
  97. search_did = '".Database::escape_string($this->search_did)."' ,
  98. audio = '".Database::escape_string($this->audio)."'
  99. WHERE c_id=".$this->c_id." AND id=".$this->id;
  100. Database::query($sql);
  101. }
  102. }
  103. }