Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions main/lp/lp_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,63 @@ function(reponse) {
require 'lp_list.php';
}
break;
case 'reorder_categories':
if (!api_is_allowed_to_edit(null, true)) {
api_not_allowed(true);
}
$courseId = api_get_course_int_id();
$tableCategory = Database::get_course_table(TABLE_LP_CATEGORY);

$catOrder = isset($_POST['order']) ? (array) $_POST['order'] : [];

$pos = 1;
foreach ($catOrder as $catIid) {
$catIid = (int) $catIid;
if ($catIid <= 0) {
continue;
}

$sql = "UPDATE $tableCategory
SET position = $pos
WHERE c_id = $courseId
AND iid = $catIid";
Database::query($sql);
$pos++;
}

header('Content-Type: application/json');
echo json_encode(['ok' => true]);
exit;
case 'reorder_lps':
if (!api_is_allowed_to_edit(null, true)) {
api_not_allowed(true);
}
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$tableLp = Database::get_course_table(TABLE_LP_MAIN);

$lists = isset($_POST['lists']) ? (array) $_POST['lists'] : [];

foreach ($lists as $categoryIdStr => $lpIds) {
$categoryId = (int) $categoryIdStr;
$pos = 1;

foreach ((array) $lpIds as $lpId) {
$lpId = (int) $lpId;
if ($lpId <= 0) {
continue;
}
$sql = "UPDATE $tableLp
SET category_id = ".($categoryId ?: 0).", display_order = $pos
WHERE c_id = $courseId AND id = $lpId";
Database::query($sql);
$pos++;
}
}

header('Content-Type: application/json');
echo json_encode(['ok' => true]);
exit;
case 'edit':
if (!$is_allowed_to_edit) {
api_not_allowed(true);
Expand Down
2 changes: 2 additions & 0 deletions main/lp/lp_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ function confirmation(name) {
);

$listData[] = [
'lp_id' => $id,
'learnpath_icon' => $icon_learnpath,
'url_start' => $url_start_lp,
'title' => $my_title,
Expand Down Expand Up @@ -1049,6 +1050,7 @@ function confirmation(name) {
$template->assign('filtered_category', $filteredCategoryId);
$template->assign('allow_min_time', $allowMinTime);
$template->assign('allow_dates_for_student', $allowDatesForStudent);
$template->assign('sec_token', $token);

$templateName = $template->get_template('learnpath/list.tpl');
$content = $template->fetch($templateName);
Expand Down
Loading
Loading