lp_item.lib.php 4.6 KB

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