Skip to content

Commit dff9450

Browse files
committed
Fix delete session if exist an assignments inside
1 parent 17aca50 commit dff9450

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

main/inc/lib/sessionmanager.lib.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,8 @@ public static function delete($id_checked, $from_ws = false)
15361536
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
15371537
$tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
15381538
$tbl_item_properties = Database::get_course_table(TABLE_ITEM_PROPERTY);
1539+
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
1540+
$tbl_student_publication_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
15391541
$em = Database::getManager();
15401542

15411543
$userId = api_get_user_id();
@@ -1568,8 +1570,26 @@ public static function delete($id_checked, $from_ws = false)
15681570
foreach ($courses as $courseId) {
15691571
$courseInfo = api_get_course_info_by_id($courseId);
15701572
DocumentManager::deleteDocumentsFromSession($courseInfo, $id_checked);
1573+
1574+
$works = Database::select(
1575+
'*',
1576+
$tbl_student_publication,
1577+
[
1578+
'where' => ['session_id = ? AND c_id = ?' => [$id_checked, $courseId]]
1579+
]
1580+
);
1581+
1582+
$currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/';
1583+
1584+
foreach ($works as $index => $work) {
1585+
if ($work['filetype'] = 'folder') {
1586+
Database::query("DELETE FROM $tbl_student_publication_assignment WHERE publication_id = $index");
1587+
}
1588+
my_delete($currentCourseRepositorySys.'/'.$work['url']);
1589+
}
15711590
}
15721591

1592+
Database::query("DELETE FROM $tbl_student_publication WHERE session_id IN($id_checked)");
15731593
Database::query("DELETE FROM $tbl_session_rel_course WHERE session_id IN($id_checked)");
15741594
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id IN($id_checked)");
15751595
Database::query("DELETE FROM $tbl_session_rel_user WHERE session_id IN($id_checked)");

0 commit comments

Comments
 (0)