diff --git a/main/templates/course_detail.html b/main/templates/course_detail.html index 05afda2..9a4403d 100644 --- a/main/templates/course_detail.html +++ b/main/templates/course_detail.html @@ -57,20 +57,42 @@ {% if course.type == 'multi' %} {% endif %} -
- {% csrf_token %} - - -
-
- {% csrf_token %} - - -
+ {% if export_options %} + + + + + {% endif %}
@@ -241,12 +263,48 @@ function getVisibleRows() { return JSON.stringify(rows); } -$('#exportCsvForm').on('submit', function(e) { - $('#csvRowsInput').val(getVisibleRows()); +// Handle custom export option buttons in the modal +$('.export-option-btn').on('click', function() { + var url = $(this).data('url'); + if (!url) return; + // Create a temporary form and submit POST with rows + var form = $('
'); + form.attr('action', url); + // Insert CSRF token from cookie + function getCookie(name) { + var cookieValue = null; + if (document.cookie && document.cookie !== '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = cookies[i].trim(); + if (cookie.substring(0, name.length + 1) === (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } + var csrf = getCookie('csrftoken'); + if (csrf) { + form.append($('').val(csrf)); + } + var input = $('').val(getVisibleRows()); + form.append(input); + // Append to body and submit + $('body').append(form); + form.submit(); }); -$('#exportPdfForm').on('submit', function(e) { - $('#pdfRowsInput').val(getVisibleRows()); +// Help button handler: show help text in a small modal +$(document).on('click', '.help-btn', function(e){ + e.stopPropagation(); // prevent triggering parent button + var helpText = $(this).data('help') || ''; + var modalHtml = '\n