diff --git a/main/lp/lp_controller.php b/main/lp/lp_controller.php index c4700ef2198..59d6c5d2483 100755 --- a/main/lp/lp_controller.php +++ b/main/lp/lp_controller.php @@ -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); diff --git a/main/lp/lp_list.php b/main/lp/lp_list.php index c1ff10f2292..4f6913f4171 100755 --- a/main/lp/lp_list.php +++ b/main/lp/lp_list.php @@ -942,6 +942,7 @@ function confirmation(name) { ); $listData[] = [ + 'lp_id' => $id, 'learnpath_icon' => $icon_learnpath, 'url_start' => $url_start_lp, 'title' => $my_title, @@ -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); diff --git a/main/template/default/learnpath/list.tpl b/main/template/default/learnpath/list.tpl index 571cf3794ce..1909a9d95bd 100644 --- a/main/template/default/learnpath/list.tpl +++ b/main/template/default/learnpath/list.tpl @@ -1,690 +1,656 @@ + {% set configuration = 'lp_category_accordion'|api_get_configuration_value %}
+ {% set number = 0 %} {% for lp_data in data %} - {% set show_category = true %} + {% set show_category = true %} + {% if filtered_category and filtered_category != lp_data.category.id %} + {% set show_category = false %} + {% endif %} - {% if filtered_category and filtered_category != lp_data.category.id %} - {% set show_category = false %} - {% endif %} + {% if show_category %} + {% if configuration == 0 %} + +
+ {% if categories|length > 1 and lp_data.category.id %} + {% if is_allowed_to_edit %} + + {% elseif lp_data.lp_list is not empty %} + + {% endif %} + {% elseif lp_data.lp_list is not empty %} + + {% endif %} - {% if lp_data.category.sessionId == _c.session_id %} - - {{ - - {% endif %} - {% endif %} - - {% elseif lp_data.lp_list is not empty %} - + {% if lp_data.lp_list %} +
+ + + + + {% if is_allowed_to_edit %} + + + + {% if allow_min_time %}{% endif %} + + {% else %} + {% if allow_dates_for_student %} + + {% endif %} - {% endif %} + {% if not is_invitee %}{% endif %} + {% if allow_min_time %}{% endif %} + + {% endif %} + + - {% if lp_data.lp_list %} -
-
{{ "Title"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "Actions"|get_lang }}
- - - - {% if is_allowed_to_edit %} - - - - {% if allow_min_time %} - - {% endif %} - - {% else %} - {% if allow_dates_for_student %} - - - {% endif %} - {% if not is_invitee %} - - {% endif %} - {% if allow_min_time %} - - {% endif %} - - {% endif %} - - - - {% for row in lp_data.lp_list %} - - - {% if is_allowed_to_edit %} - - - - {% if allow_min_time %} - - {% endif %} - {% else %} - {% if allow_dates_for_student %} - - - {% endif %} - {% if not is_invitee %} - - {% endif %} - {% if allow_min_time %} - - {% endif %} - {% endif %} - - - {% endfor %} - -
- {{ "Title"|get_lang }} - {{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "Actions"|get_lang }}
- {{ row.learnpath_icon }} - - {{ row.title }} - {{ row.session_image }} - - {{ row.extra }} - - {% if row.start_time %} - {{ row.start_time }} - {% endif %} - - {{ row.end_time }} - - {{ row.dsp_progress }} - - {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} - - {% if row.start_time %} - {{ row.start_time }} - {% endif %} - - {{ row.end_time }} - - {{ row.dsp_progress }} - - {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} - - {{ row.action_build }} - {{ row.action_edit }} - {{ row.action_visible }} - {{ row.action_tracking }} - {{ row.action_publish }} - {{ row.action_subscribe_users }} - {{ row.action_serious_game }} - {{ row.action_reinit }} - {{ row.action_default_view }} - {{ row.action_debug }} - {{ row.action_export }} - {{ row.action_copy }} - {{ row.action_auto_launch }} - {{ row.action_pdf }} - {{ row.action_delete }} - {{ row.action_order }} - {{ row.action_update_scorm }} - {{ row.action_export_to_course_build }} -
-
- {% endif %} - - {% else %} - - {% if lp_data.category.id == 0 %} - {% if is_allowed_to_edit %} - {% if lp_data.lp_list %} -
- - - - - {% if is_allowed_to_edit %} - - - - {% if allow_min_time %} - - {% endif %} - - {% else %} - {% if allow_dates_for_student %} - - - {% endif %} - {% if not is_invitee %} - - {% endif %} - {% if allow_min_time %} - - {% endif %} - - {% endif %} - - - - {% for row in lp_data.lp_list %} - - - {% if is_allowed_to_edit %} - - - - {% if allow_min_time %} - - {% endif %} - {% else %} - {% if allow_dates_for_student %} - - - {% endif %} - {% if not is_invitee %} - - {% endif %} - {% if allow_min_time %} - - {% endif %} - {% endif %} - - - {% endfor %} - -
{{ "Title"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "Actions"|get_lang }}
- {{ row.learnpath_icon }} - - {{ row.title }} - {{ row.session_image }} - {{ row.extra }} - - - {% if row.start_time %} - {{ row.start_time }} - {% endif %} - - {{ row.end_time }} - - {{ row.dsp_progress }} - - {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} - - {% if row.start_time %} - {{ row.start_time }} - {% endif %} - - {{ row.end_time }} - - {{ row.dsp_progress }} - - {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} - - {{ row.action_build }} - {{ row.action_edit }} - {{ row.action_visible }} - {{ row.action_tracking }} - {{ row.action_publish }} - {{ row.action_subscribe_users }} - {{ row.action_serious_game }} - {{ row.action_reinit }} - {{ row.action_default_view }} - {{ row.action_debug }} - {{ row.action_export }} - {{ row.action_copy }} - {{ row.action_auto_launch }} - {{ row.action_pdf }} - {{ row.action_delete }} - {{ row.action_order }} - {{ row.action_update_scorm }} - {{ row.action_export_to_course_build }} -
-
+ + {% for row in lp_data.lp_list %} + + + {% if is_allowed_to_edit %} + + + drag + {% endif %} + {{ row.learnpath_icon }} + {{ row.title }} {{ row.session_image }} + {{ row.extra }} + + {% if is_allowed_to_edit %} + {% if row.start_time %}{{ row.start_time }}{% endif %} + {{ row.end_time }} + {{ row.dsp_progress }} + {% if allow_min_time %}{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}{% endif %} {% else %} -
-
- {% for row in lp_data.lp_list %} -
-
- -
- {{ row.dsp_progress }} -
- - {% if allow_dates_for_student %} -
- {% if row.start_time %} - {{ row.start_time }} - {% endif %} - {{ row.end_time }} -
- {% endif %} - - {% if allow_min_time %} -
- {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} -
- {% endif %} -
- {{ row.action_pdf }} - {{ row.action_export }} -
-
-
- {% endfor %} -
-
+ {% if allow_dates_for_student %} + {% if row.start_time %}{{ row.start_time }}{% endif %} + {{ row.end_time }} {% endif %} + {% if not is_invitee %}{{ row.dsp_progress }}{% endif %} + {% if allow_min_time %}{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}{% endif %} + {% endif %} + + {{ row.action_build }} + {{ row.action_edit }} + {{ row.action_visible }} + {{ row.action_tracking }} + {{ row.action_publish }} + {{ row.action_subscribe_users }} + {{ row.action_serious_game }} + {{ row.action_reinit }} + {{ row.action_default_view }} + {{ row.action_debug }} + {{ row.action_export }} + {{ row.action_copy }} + {{ row.action_auto_launch }} + {{ row.action_pdf }} + {{ row.action_delete }} + {{ row.action_order }} {# keep arrows, hide via CSS #} + {{ row.action_update_scorm }} + {{ row.action_export_to_course_build }} + + + {% endfor %} + + +
+ {% elseif is_allowed_to_edit %} + +
+ + + + + {% if allow_min_time %}{% endif %} + + + + + + +
{{ "Title"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ is_allowed_to_edit ? "AuthoringOptions"|get_lang : "Actions"|get_lang }}
Drop a learning path here
+
+ {% endif %} +
+ + {% else %} + + {% if lp_data.category.id == 0 %} + {% if is_allowed_to_edit %} + {% if lp_data.lp_list %} +
+ + + + + {% if is_allowed_to_edit %} + + + + {% if allow_min_time %}{% endif %} + + {% else %} + {% if allow_dates_for_student %} + + {% endif %} + {% if not is_invitee %}{% endif %} + {% if allow_min_time %}{% endif %} + + {% endif %} + + - {% if categories|length > 1 and lp_data.category.id %} - {% set number = number + 1 %} -
-
+ {% for row in lp_data.lp_list %} + + + {% if is_allowed_to_edit %} + + + + {% if allow_min_time %}{% endif %} + {% else %} + {% if allow_dates_for_student %} + + + {% endif %} + {% if not is_invitee %}{% endif %} + {% if allow_min_time %}{% endif %} + {% endif %} + + + {% endfor %} + +
{{ "Title"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "Actions"|get_lang }}
+ {% if is_allowed_to_edit %} + + + drag + + {% endif %} + {{ row.learnpath_icon }} + {{ row.title }} {{ row.session_image }} {{ row.extra }} + {% if row.start_time %}{{ row.start_time }}{% endif %}{{ row.end_time }}{{ row.dsp_progress }}{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}{% if row.start_time %}{{ row.start_time }}{% endif %}{{ row.end_time }}{{ row.dsp_progress }}{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %} + {{ row.action_build }} + {{ row.action_edit }} + {{ row.action_visible }} + {{ row.action_tracking }} + {{ row.action_publish }} + {{ row.action_subscribe_users }} + {{ row.action_serious_game }} + {{ row.action_reinit }} + {{ row.action_default_view }} + {{ row.action_debug }} + {{ row.action_export }} + {{ row.action_copy }} + {{ row.action_auto_launch }} + {{ row.action_pdf }} + {{ row.action_delete }} + {{ row.action_order }} + {{ row.action_update_scorm }} + {{ row.action_export_to_course_build }} +
+
+ {% else %} + +
+ + + + + {% if allow_min_time %}{% endif %} + + + + + + +
{{ "Title"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}
Drop a learning path here
+
+ {% endif %} + {% else %} +
+
+ {% for row in lp_data.lp_list %} +
+
+ +
{{ row.dsp_progress }}
+ {% if allow_dates_for_student %} +
+ {% if row.start_time %}{{ row.start_time }}{% endif %} + {{ row.end_time }} +
+ {% endif %} + {% if allow_min_time %} +
{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}
+ {% endif %} +
{{ row.action_pdf }} {{ row.action_export }}
+
+
+ {% endfor %} +
+
+ {% endif %} + {% endif %} - {% if subscription_settings.allow_add_users_to_lp_category %} - - {{ - - {% endif %} + {% if categories|length > 1 and lp_data.category.id %} + {% set number = number + 1 %} + +
+ + {% endif %} +

+ {% if is_allowed_to_edit %} + + + drag + + {% endif %} + + {{ lp_data.category.getName() }} + {% if lp_data.category.sessionId %}{{ session_star_icon }}{% endif %} + +

+
+
+
+ {% if lp_data.lp_list %} + {% if is_allowed_to_edit %} +
+ + + + + {% if is_allowed_to_edit %} + + + + {% if allow_min_time %}{% endif %} + + {% else %} + {% if allow_dates_for_student %} + + {% endif %} -

- - {{ lp_data.category.getName() }} - - {% if lp_data.category.sessionId %} - {{ session_star_icon }} - {% endif %} - -

- -
-
- {% if lp_data.lp_list %} - {% if is_allowed_to_edit %} -
-
{{ "Title"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}
- - - - {% if is_allowed_to_edit %} - - - - {% if allow_min_time %} - - {% endif %} - - {% else %} - {% if allow_dates_for_student %} - - - {% endif %} - {% if not is_invitee %} - - {% endif %} - {% if allow_min_time %} - - {% endif %} - - - {% endif %} - - - - {% for row in lp_data.lp_list %} - - - {% if is_allowed_to_edit %} - - - - {% if allow_min_time %} - - {% endif %} - {% else %} - {% if allow_dates_for_student %} - - - {% endif %} - {% if not is_invitee %} - - {% endif %} - {% if allow_min_time %} - - {% endif %} - {% endif %} - - - {% endfor %} - -
{{ "Title"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}{{ "PublicationDate"|get_lang }}{{ "ExpirationDate"|get_lang }}{{ "Progress"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "Actions"|get_lang }}
- {{ row.learnpath_icon }} - - {{ row.title }} - {{ row.session_image }} - {{ row.extra }} - - - {% if row.start_time %} - {{ row.start_time }} - {% endif %} - - {{ row.end_time }} - - {{ row.dsp_progress }} - - {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} - - {% if row.start_time %} - {{ row.start_time }} - {% endif %} - - {{ row.end_time }} - - {{ row.dsp_progress }} - - {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} - - {{ row.action_build }} - {{ row.action_edit }} - {{ row.action_visible }} - {{ row.action_tracking }} - {{ row.action_publish }} - {{ row.action_subscribe_users }} - {{ row.action_serious_game }} - {{ row.action_reinit }} - {{ row.action_default_view }} - {{ row.action_debug }} - {{ row.action_export }} - {{ row.action_copy }} - {{ row.action_auto_launch }} - {{ row.action_pdf }} - {{ row.action_delete }} - {{ row.action_order }} - {{ row.action_update_scorm }} - {{ row.action_export_to_course_build }} -
-
- {% else %} - {% for row in lp_data.lp_list %} -
-
- -
- {{ row.dsp_progress }} -
- - {% if allow_dates_for_student %} -
- {% if row.start_time %} - {{ row.start_time }} - {% endif %} - {{ row.end_time }} -
- {% endif %} + {% if not is_invitee %}{{ "Progress"|get_lang }}{% endif %} + {% if allow_min_time %}{{ "TimeSpentTimeRequired"|get_lang }}{% endif %} + {{ "Actions"|get_lang }} + {% endif %} + + - {% if allow_min_time %} -
- {% if row.info_time_prerequisite %} - {{ row.info_time_prerequisite }} - {% endif %} -
- {% endif %} -
- {{ row.action_pdf }} - {{ row.action_export }} -
-
-
- {% endfor %} - {% endif %} + + {% for row in lp_data.lp_list %} + + + {% if is_allowed_to_edit %} + + drag + {% endif %} -
+ {{ row.learnpath_icon }} + {{ row.title }} {{ row.session_image }} {{ row.extra }} + + {% if is_allowed_to_edit %} + {% if row.start_time %}{{ row.start_time }}{% endif %} + {{ row.end_time }} + {{ row.dsp_progress }} + {% if allow_min_time %}{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}{% endif %} + {% else %} + {% if allow_dates_for_student %} + {% if row.start_time %}{{ row.start_time }}{% endif %} + {{ row.end_time }} + {% endif %} + {% if not is_invitee %}{{ row.dsp_progress }}{% endif %} + {% if allow_min_time %}{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}{% endif %} + {% endif %} + + {{ row.action_build }} + {{ row.action_edit }} + {{ row.action_visible }} + {{ row.action_tracking }} + {{ row.action_publish }} + {{ row.action_subscribe_users }} + {{ row.action_serious_game }} + {{ row.action_reinit }} + {{ row.action_default_view }} + {{ row.action_debug }} + {{ row.action_export }} + {{ row.action_copy }} + {{ row.action_auto_launch }} + {{ row.action_pdf }} + {{ row.action_delete }} + {{ row.action_order }} + {{ row.action_update_scorm }} + {{ row.action_export_to_course_build }} + + + {% endfor %} + + +
+ {% else %} + {% for row in lp_data.lp_list %} +
+
+ +
{{ row.dsp_progress }}
+ {% if allow_dates_for_student %} +
+ {% if row.start_time %}{{ row.start_time }}{% endif %} + {{ row.end_time }}
+ {% endif %} + {% if allow_min_time %} +
{% if row.info_time_prerequisite %}{{ row.info_time_prerequisite }}{% endif %}
+ {% endif %} +
{{ row.action_pdf }} {{ row.action_export }}
+
+ {% endfor %} {% endif %} - - {% endif %} - {% endif %} + {% elseif is_allowed_to_edit %} + +
+ + + + + {% if allow_min_time %}{% endif %} + + + + + + +
{{ "Title"|get_lang }}{{ "TimeSpentTimeRequired"|get_lang }}{{ "AuthoringOptions"|get_lang }}
Drop a learning path here
+
+ {% endif %} + + + + {% endif %} + + {% endif %} + {% endif %} {% endfor %} {% if not is_invitee and lp_is_shown and allow_min_time %} -
- {% if not is_ending %} - - {% else %} - - {{ 'IHaveFinishedTheLessonsNotifyTheTeacher'|get_lang }} - - {% endif %} -
+
+ {% if not is_ending %} + + {% else %} + + {{ 'IHaveFinishedTheLessonsNotifyTheTeacher'|get_lang }} + + {% endif %} +
{% endif %} {% if not is_invitee and lp_is_shown and allow_min_time and is_ending %} -
- {{ download_files_after_finish }} -
+
+ {{ download_files_after_finish }} +
{% endif %} {% if is_allowed_to_edit and not lp_is_shown %} -
-

{{ "LearningPaths"|get_lang }}

- -
- - {{ "LearnpathAddLearnpath"|get_lang }} - -
+
+

{{ "LearningPaths"|get_lang }}

+ + +
{% endif %} +