Skip to content
Merged
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
10 changes: 10 additions & 0 deletions assets/src/js/front/course/_spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
parseInt(document.querySelector('input[name="tutor_assignment_upload_limit"]')?.value) || 0;
let message = '';
const maxAllowedFiles = window._tutorobject.assignment_max_file_allowed;
const allowedFileTypes = window._tutorobject.assignment_allowed_file_types;
let alreadyUploaded = document.querySelectorAll(
'#tutor-student-assignment-edit-file-preview .tutor-instructor-card'
).length;
Expand Down Expand Up @@ -315,6 +316,15 @@ document.addEventListener('DOMContentLoaded', (event) => {
if (!file) {
continue;
}
let extension = file.name.split('.').pop().toLowerCase();
if (!allowedFileTypes.includes(`${extension}`)) {
tutor_toast(
__('Warning', 'tutor'),
__(`File type .${extension} is not allowed.`, 'tutor'),
'error'
);
continue;
}
let editWrapClass = assignmentEditFilePreview ? 'tutor-col-sm-5 tutor-py-16 tutor-mr-16' : '';
fileCard += `<div class="tutor-instructor-card ${editWrapClass}">
<div class="tutor-icard-content">
Expand Down
1 change: 0 additions & 1 deletion classes/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
*
* @since 1.9.0
*/
add_action( 'admin_head', array( $this, 'tutor_add_mce_button' ) );

Check failure on line 77 in classes/Assets.php

View workflow job for this annotation

GitHub Actions / phpstan

Action callback returns void|null but should not return anything.

Check failure on line 77 in classes/Assets.php

View workflow job for this annotation

GitHub Actions / phpstan

Action callback returns void|null but should not return anything.
add_filter( 'get_the_generator_html', array( $this, 'tutor_generator_tag' ), 10, 2 );
add_filter( 'get_the_generator_xhtml', array( $this, 'tutor_generator_tag' ), 10, 2 );

Expand Down Expand Up @@ -174,7 +174,7 @@
function ( $file ) {
return basename( $file, '.svg' );
},
glob( tutor()->path . 'assets/icons/kids/*.svg' ) ?: array()

Check failure on line 177 in classes/Assets.php

View workflow job for this annotation

GitHub Actions / WPCS

Using short ternaries is not allowed as they are rarely used correctly
);
}

Expand All @@ -200,7 +200,6 @@
'current_user' => $current_user,
'content_change_event' => 'tutor_content_changed_event',
'is_tutor_course_edit' => isset( $_GET['action'] ) && 'edit' === $_GET['action'] && tutor()->course_post_type === get_post_type( get_the_ID() ) ? true : false,
'assignment_max_file_allowed' => 'tutor_assignments' === $post_type ? (int) tutor_utils()->get_assignment_option( $post_id, 'upload_files_limit' ) : 0,
'current_page' => $current_page,
'quiz_answer_display_time' => 1000 * (int) tutor_utils()->get_option( 'quiz_answer_display_time' ),
'is_ssl' => is_ssl(),
Expand Down
Loading