CourseRecycler.class.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once 'Course.class.php';
  4. /**
  5. * Class to delete items from a Chamilo-course
  6. * @author Bart Mollet <bart.mollet@hogent.be>
  7. * @package chamilo.backup
  8. */
  9. class CourseRecycler
  10. {
  11. /**
  12. * A course-object with the items to delete
  13. */
  14. var $course;
  15. /**
  16. * Create a new CourseRecycler
  17. * @param course $course The course-object which contains the items to
  18. * delete
  19. */
  20. function CourseRecycler($course) {
  21. $this->course = $course;
  22. $this->course_info = api_get_course_info($this->course->code);
  23. $this->course_id = $course->info['real_id'];
  24. }
  25. /**
  26. * Delete all items from the course.
  27. * This deletes all items in the course-object from the current Chamilo-
  28. * course
  29. */
  30. function recycle() {
  31. $table_tool_intro = Database::get_course_table(TABLE_TOOL_INTRO);
  32. $table_linked_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
  33. $table_item_properties = Database::get_course_table(TABLE_ITEM_PROPERTY);
  34. $this->recycle_links();
  35. $this->recycle_link_categories();
  36. $this->recycle_events();
  37. $this->recycle_announcements();
  38. $this->recycle_documents();
  39. $this->recycle_forums(); //@todo does not work yet
  40. $this->recycle_forum_categories();
  41. $this->recycle_quizzes();
  42. $this->recycle_surveys();
  43. $this->recycle_learnpaths();
  44. $this->recycle_cours_description();
  45. $this->recycle_wiki();
  46. $this->recycle_glossary();
  47. $this->recycle_thematic();
  48. $this->recycle_attendance();
  49. foreach ($this->course->resources as $type => $resources) {
  50. foreach ($resources as $id => $resource) {
  51. $sql = "DELETE FROM ".$table_linked_resources." WHERE c_id = ".$this->course_id." AND (source_type = '".$type."' AND source_id = '".$id."') OR (resource_type = '".$type."' AND resource_id = '".$id."') ";
  52. Database::query($sql);
  53. if (is_numeric($id)) {
  54. $sql = "DELETE FROM ".$table_item_properties." WHERE c_id = ".$this->course_id." AND tool ='".$resource->get_tool()."' AND ref=".$id;
  55. Database::query($sql);
  56. } elseif ($type == RESOURCE_TOOL_INTRO) {
  57. $sql = "DELETE FROM $table_tool_intro WHERE c_id = ".$this->course_id." AND id='$id'";
  58. Database::query($sql);
  59. }
  60. }
  61. }
  62. }
  63. /**
  64. * Delete documents
  65. */
  66. function recycle_documents() {
  67. if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
  68. $table = Database :: get_course_table(TABLE_DOCUMENT);
  69. foreach ($this->course->resources[RESOURCE_DOCUMENT] as $id => $document) {
  70. rmdirr($this->course->backup_path.'/'.$document->path);
  71. }
  72. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_DOCUMENT])));
  73. $sql = "DELETE FROM ".$table." WHERE c_id = ".$this->course_id." AND id IN(".$ids.")";
  74. Database::query($sql);
  75. }
  76. }
  77. /**
  78. * Delete wiki
  79. */
  80. function recycle_wiki() {
  81. if ($this->course->has_resources(RESOURCE_WIKI)) {
  82. $table_wiki = Database::get_course_table(TABLE_WIKI);
  83. $table_wiki_conf = Database::get_course_table(TABLE_WIKI_CONF);
  84. //$table_wiki_discuss = Database::get_course_table(TABLE_WIKI_DISCUSS);
  85. //$table_wiki_mailcue = Database::get_course_table(TABLE_WIKI_MAILCUE);
  86. $pages = array();
  87. foreach ($this->course->resources[RESOURCE_WIKI] as $resource) {
  88. $pages[] = $resource->page_id;
  89. }
  90. $wiki_ids = implode(',', (array_keys($this->course->resources[RESOURCE_WIKI])));
  91. $page_ids = implode(',', $pages);
  92. $sql = "DELETE FROM ".$table_wiki." WHERE c_id = ".$this->course_id." AND id IN(".$wiki_ids.")";
  93. Database::query($sql);
  94. $sql = "DELETE FROM ".$table_wiki_conf." WHERE c_id = ".$this->course_id." AND page_id IN(".$page_ids.")";
  95. Database::query($sql);
  96. }
  97. }
  98. /**
  99. * Delete glossary
  100. */
  101. function recycle_glossary() {
  102. if ($this->course->has_resources(RESOURCE_GLOSSARY)) {
  103. $table_glossary = Database::get_course_table(TABLE_GLOSSARY);
  104. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_GLOSSARY])));
  105. $sql = "DELETE FROM ".$table_glossary." WHERE c_id = ".$this->course_id." AND glossary_id IN(".$ids.")";
  106. Database::query($sql);
  107. }
  108. }
  109. /**
  110. * Delete links
  111. */
  112. function recycle_links() {
  113. if ($this->course->has_resources(RESOURCE_LINK)) {
  114. $table = Database :: get_course_table(TABLE_LINK);
  115. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_LINK])));
  116. $sql = "DELETE FROM ".$table." WHERE c_id = ".$this->course_id." AND id IN(".$ids.")";
  117. Database::query($sql);
  118. }
  119. }
  120. /**
  121. * Delete forums
  122. */
  123. function recycle_forums() {
  124. if ($this->course->has_resources(RESOURCE_FORUM)) {
  125. //$table_category = Database :: get_course_table(TABLE_FORUM_CATEGORY);
  126. $table_forum = Database :: get_course_table(TABLE_FORUM);
  127. $table_thread = Database :: get_course_table(TABLE_FORUM_THREAD);
  128. $table_post = Database :: get_course_table(TABLE_FORUM_POST);
  129. $table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
  130. $table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
  131. $table_mail_queue = Database::get_course_table(TABLE_FORUM_MAIL_QUEUE);
  132. $table_thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
  133. $table_thread_qualify_log = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY_LOG);
  134. $forum_ids = implode(',', (array_keys($this->course->resources[RESOURCE_FORUM])));
  135. $sql = "DELETE FROM ".$table_attachment.
  136. " USING ".$table_attachment." INNER JOIN ".$table_post.
  137. " WHERE c_id = ".$this->course_id." AND ".$table_attachment.".post_id = ".$table_post.".post_id".
  138. " AND ".$table_post.".forum_id IN(".$forum_ids.");";
  139. Database::query($sql);
  140. $sql = "DELETE FROM ".$table_mail_queue.
  141. " USING ".$table_mail_queue." INNER JOIN ".$table_post.
  142. " WHERE c_id = ".$this->course_id." AND ".$table_mail_queue.".post_id = ".$table_post.".post_id".
  143. " AND ".$table_post.".forum_id IN(".$forum_ids.");";
  144. Database::query($sql);
  145. // Just in case, deleting in the same table using thread_id as record-linker.
  146. $sql = "DELETE FROM ".$table_mail_queue.
  147. " USING ".$table_mail_queue." INNER JOIN ".$table_thread.
  148. " WHERE c_id = ".$this->course_id." AND ".$table_mail_queue.".thread_id = ".$table_thread.".thread_id".
  149. " AND ".$table_thread.".forum_id IN(".$forum_ids.");";
  150. Database::query($sql);
  151. $sql = "DELETE FROM ".$table_thread_qualify.
  152. " USING ".$table_thread_qualify." INNER JOIN ".$table_thread.
  153. " WHERE c_id = ".$this->course_id." AND ".$table_thread_qualify.".thread_id = ".$table_thread.".thread_id".
  154. " AND ".$table_thread.".forum_id IN(".$forum_ids.");";
  155. Database::query($sql);
  156. $sql = "DELETE FROM ".$table_thread_qualify_log.
  157. " USING ".$table_thread_qualify_log." INNER JOIN ".$table_thread.
  158. " WHERE c_id = ".$this->course_id." AND ".$table_thread_qualify_log.".thread_id = ".$table_thread.".thread_id".
  159. " AND ".$table_thread.".forum_id IN(".$forum_ids.");";
  160. Database::query($sql);
  161. $sql = "DELETE FROM ".$table_notification." WHERE c_id = ".$this->course_id." AND forum_id IN(".$forum_ids.")";
  162. Database::query($sql);
  163. $sql = "DELETE FROM ".$table_post." WHERE c_id = ".$this->course_id." AND forum_id IN(".$forum_ids.")";
  164. Database::query($sql);
  165. $sql = "DELETE FROM ".$table_thread." WHERE c_id = ".$this->course_id." AND forum_id IN(".$forum_ids.")";
  166. Database::query($sql);
  167. $sql = "DELETE FROM ".$table_forum." WHERE c_id = ".$this->course_id." AND forum_id IN(".$forum_ids.")";
  168. Database::query($sql);
  169. }
  170. }
  171. /**
  172. * Delete forum-categories
  173. * Deletes all forum-categories from current course without forums
  174. */
  175. function recycle_forum_categories() {
  176. $table_forum = Database :: get_course_table(TABLE_FORUM);
  177. $table_forumcat = Database :: get_course_table(TABLE_FORUM_CATEGORY);
  178. $sql = "SELECT fc.cat_id FROM ".$table_forumcat." fc LEFT JOIN ".$table_forum." f ON fc.cat_id=f.forum_category
  179. WHERE fc.c_id = ".$this->course_id." AND f.c_id = ".$this->course_id." AND f.forum_id IS NULL";
  180. $res = Database::query($sql);
  181. while ($obj = Database::fetch_object($res)) {
  182. $sql = "DELETE FROM ".$table_forumcat." WHERE c_id = ".$this->course_id." AND cat_id = ".$obj->cat_id;
  183. Database::query($sql);
  184. }
  185. }
  186. /**
  187. * Delete link-categories
  188. * Deletes all empty link-categories (=without links) from current course
  189. */
  190. function recycle_link_categories() {
  191. $link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY);
  192. $link_table = Database :: get_course_table(TABLE_LINK);
  193. $sql = "SELECT lc.id FROM ".$link_cat_table." lc LEFT JOIN ".$link_table." l ON lc.id=l.category_id
  194. WHERE l.id IS NULL";
  195. $res = Database::query($sql);
  196. while ($obj = Database::fetch_object($res)) {
  197. $sql = "DELETE FROM ".$link_cat_table." WHERE c_id = ".$this->course_id." AND id = ".$obj->id;
  198. Database::query($sql);
  199. }
  200. }
  201. /**
  202. * Delete events
  203. */
  204. function recycle_events() {
  205. if ($this->course->has_resources(RESOURCE_EVENT)) {
  206. $table = Database :: get_course_table(TABLE_AGENDA);
  207. $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT);
  208. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_EVENT])));
  209. $sql = "DELETE FROM ".$table." WHERE c_id = ".$this->course_id." AND id IN(".$ids.")";
  210. Database::query($sql);
  211. $sql = "DELETE FROM ".$table_attachment." WHERE c_id = ".$this->course_id." AND agenda_id IN(".$ids.")";
  212. Database::query($sql);
  213. }
  214. }
  215. /**
  216. * Delete announcements
  217. */
  218. function recycle_announcements() {
  219. if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) {
  220. $table = Database :: get_course_table(TABLE_ANNOUNCEMENT);
  221. $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
  222. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_ANNOUNCEMENT])));
  223. $sql = "DELETE FROM ".$table." WHERE c_id = ".$this->course_id." AND id IN(".$ids.")";
  224. Database::query($sql);
  225. $sql = "DELETE FROM ".$table_attachment." WHERE c_id = ".$this->course_id." AND announcement_id IN(".$ids.")";
  226. Database::query($sql);
  227. }
  228. }
  229. /**
  230. * Recycle quizzes - doesn't remove the questions and their answers, as they might still be used later
  231. */
  232. function recycle_quizzes() {
  233. if ($this->course->has_resources(RESOURCE_QUIZ)) {
  234. $table_qui_que = Database :: get_course_table(TABLE_QUIZ_QUESTION);
  235. $table_qui_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
  236. $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
  237. $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
  238. $ids = array_keys($this->course->resources[RESOURCE_QUIZ]);
  239. $delete_orphan_questions = in_array(-1, $ids);
  240. $ids = implode(',', $ids);
  241. // Deletion of the normal tests, questions in them are not deleted, they become orphan at this moment.
  242. $sql = "DELETE FROM ".$table_qui." WHERE c_id = ".$this->course_id." AND id <> -1 AND id IN(".$ids.")";
  243. Database::query($sql);
  244. $sql = "DELETE FROM ".$table_rel." WHERE c_id = ".$this->course_id." AND exercice_id <> -1 AND exercice_id IN(".$ids.")";
  245. Database::query($sql);
  246. // Identifying again and deletion of the orphan questions, if it was desired.
  247. if ($delete_orphan_questions) {
  248. $sql = 'SELECT questions.id FROM '.$table_qui_que.' as questions LEFT JOIN '.$table_rel.' as quizz_questions
  249. ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.' as exercices
  250. ON exercice_id=exercices.id
  251. WHERE
  252. questions.c_id = '.$this->course_id.' AND
  253. quizz_questions.c_id = '.$this->course_id.' AND
  254. exercices.c_id = '.$this->course_id.' AND
  255. quizz_questions.exercice_id IS NULL OR exercices.active = -1'; // active = -1 means "deleted" test.
  256. $db_result = Database::query($sql);
  257. if (Database::num_rows($db_result) > 0) {
  258. $orphan_ids = array();
  259. while ($obj = Database::fetch_object($db_result)) {
  260. $orphan_ids[] = $obj->id;
  261. }
  262. $orphan_ids = implode(',', $orphan_ids);
  263. $sql = "DELETE FROM ".$table_rel." WHERE c_id = ".$this->course_id." AND question_id IN(".$orphan_ids.")";
  264. Database::query($sql);
  265. $sql = "DELETE FROM ".$table_qui_ans." WHERE c_id = ".$this->course_id." AND question_id IN(".$orphan_ids.")";
  266. Database::query($sql);
  267. $sql = "DELETE FROM ".$table_qui_que." WHERE c_id = ".$this->course_id." AND id IN(".$orphan_ids.")";
  268. Database::query($sql);
  269. }
  270. }
  271. }
  272. // Purge "deleted" tests (active = -1).
  273. $sql = "DELETE FROM ".$table_qui." WHERE c_id = ".$this->course_id." AND active = -1";
  274. Database::query($sql);
  275. }
  276. /**
  277. * Recycle surveys - removes everything
  278. */
  279. function recycle_surveys() {
  280. if ($this->course->has_resources(RESOURCE_SURVEY)) {
  281. $table_survey = Database :: get_course_table(TABLE_SURVEY);
  282. $table_survey_q = Database :: get_course_table(TABLE_SURVEY_QUESTION);
  283. $table_survey_q_o = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
  284. $table_survey_a = Database :: get_course_Table(TABLE_SURVEY_ANSWER);
  285. $table_survey_i = Database :: get_course_table(TABLE_SURVEY_INVITATION);
  286. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_SURVEY])));
  287. $sql = "DELETE FROM ".$table_survey_i." WHERE c_id = ".$this->course_id." ";
  288. Database::query($sql);
  289. $sql = "DELETE FROM ".$table_survey_a." WHERE c_id = ".$this->course_id." AND survey_id IN(".$ids.")";
  290. Database::query($sql);
  291. $sql = "DELETE FROM ".$table_survey_q_o." WHERE c_id = ".$this->course_id." AND survey_id IN(".$ids.")";
  292. Database::query($sql);
  293. $sql = "DELETE FROM ".$table_survey_q." WHERE c_id = ".$this->course_id." AND survey_id IN(".$ids.")";
  294. Database::query($sql);
  295. $sql = "DELETE FROM ".$table_survey." WHERE c_id = ".$this->course_id." AND survey_id IN(".$ids.")";
  296. Database::query($sql);
  297. }
  298. }
  299. /**
  300. * Recycle learnpaths
  301. */
  302. function recycle_learnpaths() {
  303. if ($this->course->has_resources(RESOURCE_LEARNPATH)) {
  304. $table_main = Database :: get_course_table(TABLE_LP_MAIN);
  305. $table_item = Database :: get_course_table(TABLE_LP_ITEM);
  306. $table_view = Database :: get_course_table(TABLE_LP_VIEW);
  307. $table_iv = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
  308. $table_iv_int = Database::get_course_table(TABLE_LP_IV_INTERACTION);
  309. $table_tool = Database::get_course_table(TABLE_TOOL_LIST);
  310. foreach($this->course->resources[RESOURCE_LEARNPATH] as $id => $learnpath) {
  311. // See task #875.
  312. if ($learnpath->lp_type == 2) {
  313. // This is a learning path of SCORM type.
  314. if (trim($learnpath->path) != '') // A sanity check for avoiding removal of the parent folder scorm/
  315. // when $learnpath->path value is incorrect for some reason.
  316. {
  317. // The directory trat contains files of the SCORM package is to be deleted.
  318. $scorm_package_dir = realpath($this->course->path . 'scorm/' . $learnpath->path);
  319. rmdirr($scorm_package_dir);
  320. }
  321. }
  322. //remove links from course homepage
  323. $sql = "DELETE FROM $table_tool WHERE c_id = ".$this->course_id." AND link LIKE '%lp_controller.php%lp_id=$id%' AND image='scormbuilder.gif'";
  324. Database::query($sql);
  325. //remove elements from lp_* tables (from bottom-up) by removing interactions, then item_view, then views and items, then paths
  326. $sql_items = "SELECT id FROM $table_item WHERE c_id = ".$this->course_id." AND lp_id=$id";
  327. $res_items = Database::query($sql_items);
  328. while ($row_item = Database::fetch_array($res_items)) {
  329. //get item views
  330. $sql_iv = "SELECT id FROM $table_iv WHERE c_id = ".$this->course_id." AND lp_item_id=".$row_item['id'];
  331. $res_iv = Database::query($sql_iv);
  332. while ($row_iv = Database::fetch_array($res_iv)) {
  333. //delete interactions
  334. $sql_iv_int_del = "DELETE FROM $table_iv_int WHERE c_id = ".$this->course_id." AND lp_iv_id = ".$row_iv['id'];
  335. $res_iv_int_del = Database::query($sql_iv_int_del);
  336. }
  337. //delete item views
  338. $sql_iv_del = "DELETE FROM $table_iv WHERE c_id = ".$this->course_id." AND lp_item_id=".$row_item['id'];
  339. $res_iv_del = Database::query($sql_iv_del);
  340. }
  341. //delete items
  342. $sql_items_del = "DELETE FROM $table_item WHERE c_id = ".$this->course_id." AND lp_id=$id";
  343. $res_items_del = Database::query($sql_items_del);
  344. //delete views
  345. $sql_views_del = "DELETE FROM $table_view WHERE c_id = ".$this->course_id." AND lp_id=$id";
  346. $res_views_del = Database::query($sql_views_del);
  347. //delete lps
  348. $sql_del = "DELETE FROM $table_main WHERE c_id = ".$this->course_id." AND id = $id";
  349. $res_del = Database::query($sql_del);
  350. }
  351. }
  352. }
  353. /**
  354. * Delete course description
  355. */
  356. function recycle_cours_description() {
  357. if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) {
  358. $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
  359. $ids = implode(',', (array_keys($this->course->resources[RESOURCE_COURSEDESCRIPTION])));
  360. $sql = "DELETE FROM ".$table." WHERE c_id = ".$this->course_id." AND id IN(".$ids.")";
  361. Database::query($sql);
  362. }
  363. }
  364. /**
  365. * Recycle Thematics
  366. */
  367. function recycle_thematic($session_id = 0) {
  368. if ($this->course->has_resources(RESOURCE_THEMATIC)) {
  369. $table_thematic = Database :: get_course_table(TABLE_THEMATIC);
  370. $table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
  371. $table_thematic_plan = Database :: get_course_table(TABLE_THEMATIC_PLAN);
  372. $resources = $this->course->resources;
  373. foreach ($resources[RESOURCE_THEMATIC] as $last_id => $thematic) {
  374. if (is_numeric($last_id)) {
  375. foreach($thematic->thematic_advance_list as $thematic_advance) {
  376. $cond = array('id = ? AND c_id = ?'=>array($thematic_advance['id'], $this->course_id));
  377. api_item_property_update($this->course_info, 'thematic_advance', $thematic_advance['id'],'ThematicAdvanceDeleted', api_get_user_id());
  378. Database::delete($table_thematic_advance, $cond);
  379. }
  380. foreach($thematic->thematic_plan_list as $thematic_plan) {
  381. $cond = array('id = ? AND c_id = ?'=>array($thematic_plan['id'], $this->course_id));
  382. api_item_property_update($this->course_info, 'thematic_plan', $thematic_advance['id'], 'ThematicPlanDeleted', api_get_user_id());
  383. Database::delete($table_thematic_plan, $cond);
  384. }
  385. $cond = array('id = ? AND c_id = ?'=>array($last_id, $this->course_id));
  386. api_item_property_update($this->course_info, 'thematic', $last_id,'ThematicDeleted', api_get_user_id());
  387. Database::delete($table_thematic,$cond);
  388. }
  389. }
  390. }
  391. }
  392. /**
  393. * Recycle Attendances
  394. */
  395. function recycle_attendance($session_id = 0) {
  396. if ($this->course->has_resources(RESOURCE_ATTENDANCE)) {
  397. $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE, $this->course->destination_db);
  398. $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR, $this->course->destination_db);
  399. $resources = $this->course->resources;
  400. foreach ($resources[RESOURCE_ATTENDANCE] as $last_id => $obj) {
  401. //print_r($obj);
  402. if (is_numeric($last_id)) {
  403. foreach($obj->attendance_calendar as $attendance_calendar) {
  404. $cond = array('id = ? AND c_id = ? '=>array($attendance_calendar['id'], $this->course_id));
  405. Database::delete($table_attendance_calendar, $cond);
  406. }
  407. $cond = array('id = ? AND c_id = ?'=>array($last_id, $this->course_id));
  408. Database::delete($table_attendance, $cond);
  409. api_item_property_update($this->destination_course_info, TOOL_ATTENDANCE, $last_id,'AttendanceDeleted', api_get_user_id());
  410. }
  411. }
  412. }
  413. }
  414. }