Skip to content

Commit 6acc272

Browse files
authored
Merge pull request #2130 from themeum/dev
3.8.2
2 parents f4a3ba5 + 49b03a8 commit 6acc272

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+704
-920
lines changed

assets/react/front/course/_wishlist.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
window.jQuery(document).ready(($) => {
22
const { __ } = wp.i18n;
3-
4-
$(document).on('click', '.tutor-course-wishlist-btn', function(e) {
3+
$(document).on('click', '.tutor-course-wishlist-btn', function (e) {
54
e.preventDefault();
65
var $that = $(this);
76
var course_id = $that.attr('data-course-id');
@@ -13,10 +12,10 @@ window.jQuery(document).ready(($) => {
1312
course_id,
1413
action: 'tutor_course_add_to_wishlist',
1514
},
16-
beforeSend: function() {
15+
beforeSend: function () {
1716
$that.attr('disabled', 'disabled').addClass('is-loading');
1817
},
19-
success: function(data) {
18+
success: function (data) {
2019
if (data.success) {
2120
if (data.data.status === 'added') {
2221
$that
@@ -28,13 +27,19 @@ window.jQuery(document).ready(($) => {
2827
.find('i')
2928
.addClass('tutor-icon-bookmark-line')
3029
.removeClass('tutor-icon-bookmark-bold');
30+
$that.blur();
3131
}
3232
} else {
33-
//window.location = data.data.redirect_to;
33+
tutor_toast(__('Error', 'tutor-pro'), data?.data?.message ?? 'Something went wrong!!', 'error');
3434
$('.tutor-login-modal').addClass('tutor-is-active');
35+
$that.blur();
3536
}
3637
},
37-
complete: function() {
38+
error: function (xhr, status, error) {
39+
tutor_toast(__('Error', 'tutor-pro'), 'Something went wrong!!', 'error');
40+
$that.blur();
41+
},
42+
complete: function () {
3843
$that.removeAttr('disabled').removeClass('is-loading');
3944
},
4045
});

assets/react/v3/entries/course-builder/components/modals/AssignmentModal.tsx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { useFormWithGlobalError } from '@TutorShared/hooks/useFormWithGlobalErro
3939
import { type WPMedia } from '@TutorShared/hooks/useWpMedia';
4040
import { type ID } from '@TutorShared/utils/types';
4141
import { findSlotFields, isAddonEnabled, normalizeLineEndings } from '@TutorShared/utils/util';
42-
import { maxLimitRule } from '@TutorShared/utils/validation';
42+
import { maxLimitRule, requiredRule } from '@TutorShared/utils/validation';
4343

4444
interface AssignmentModalProps extends ModalProps {
4545
assignmentId?: ID;
@@ -63,6 +63,8 @@ export interface AssignmentForm {
6363
pass_mark: number;
6464
upload_files_limit: number;
6565
upload_file_size_limit: number;
66+
is_retry_allowed: boolean;
67+
attempts_allowed: number;
6668
content_drip_settings: {
6769
unlock_date: string;
6870
after_xdays_of_enroll: string;
@@ -123,6 +125,8 @@ const AssignmentModal = ({
123125
pass_mark: 5,
124126
upload_files_limit: 1,
125127
upload_file_size_limit: 2,
128+
is_retry_allowed: true,
129+
attempts_allowed: 5,
126130
content_drip_settings: {
127131
unlock_date: '',
128132
after_xdays_of_enroll: '',
@@ -134,6 +138,7 @@ const AssignmentModal = ({
134138
});
135139

136140
const isFormDirty = form.formState.dirtyFields && Object.keys(form.formState.dirtyFields).length > 0;
141+
const isRetryAllowed = form.watch('is_retry_allowed');
137142

138143
useEffect(() => {
139144
if (assignmentDetails) {
@@ -151,6 +156,8 @@ const AssignmentModal = ({
151156
pass_mark: assignmentDetails.assignment_option.pass_mark || 5,
152157
upload_files_limit: assignmentDetails.assignment_option.upload_files_limit || 1,
153158
upload_file_size_limit: assignmentDetails.assignment_option.upload_file_size_limit || 2,
159+
is_retry_allowed: assignmentDetails.assignment_option.is_retry_allowed === '1' ? true : false,
160+
attempts_allowed: assignmentDetails.assignment_option.attempts_allowed || 10,
154161
content_drip_settings: {
155162
unlock_date: assignmentDetails?.content_drip_settings?.unlock_date || '',
156163
after_xdays_of_enroll: assignmentDetails?.content_drip_settings?.after_xdays_of_enroll || '',
@@ -478,6 +485,39 @@ const AssignmentModal = ({
478485
)}
479486
/>
480487

488+
<Controller
489+
name="is_retry_allowed"
490+
control={form.control}
491+
render={(controllerProps) => (
492+
<FormSwitch {...controllerProps} label={__('Allow Assignment Resubmission', 'tutor')} />
493+
)}
494+
/>
495+
496+
<Show when={isRetryAllowed}>
497+
<Controller
498+
name="attempts_allowed"
499+
control={form.control}
500+
rules={{
501+
...requiredRule(),
502+
validate: (value) => {
503+
if (value >= 1 && value <= 20) {
504+
return true;
505+
}
506+
return __('Allowed attempts must be between 1 and 20', 'tutor');
507+
},
508+
}}
509+
render={(controllerProps) => (
510+
<FormInput
511+
{...controllerProps}
512+
type="number"
513+
label={__('Maximum Resubmission Attempts', 'tutor')}
514+
helpText={__('Set how many times students can resubmit even after the deadline.', 'tutor')}
515+
selectOnFocus
516+
/>
517+
)}
518+
/>
519+
</Show>
520+
481521
<CourseBuilderInjectionSlot section="Curriculum.Assignment.bottom_of_sidebar" form={form} />
482522
</div>
483523
</Show>

assets/react/v3/entries/course-builder/services/curriculum.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export interface Assignment extends Content {
5656
pass_mark: number;
5757
upload_files_limit: number;
5858
upload_file_size_limit: number;
59+
is_retry_allowed: '0' | '1';
60+
attempts_allowed: number;
5961
};
6062
content_drip_settings: {
6163
unlock_date: string;
@@ -125,6 +127,8 @@ export interface AssignmentPayload {
125127
'assignment_option[pass_mark]': number;
126128
'assignment_option[upload_files_limit]': number;
127129
'assignment_option[upload_file_size_limit]': number;
130+
'assignment_option[is_retry_allowed]': '0' | '1';
131+
'assignment_option[attempts_allowed]'?: number;
128132

129133
'content_drip_settings[unlock_date]'?: string;
130134
'content_drip_settings[after_xdays_of_enroll]'?: string;
@@ -224,7 +228,11 @@ export const convertAssignmentDataToPayload = (
224228
'assignment_option[pass_mark]': data.pass_mark,
225229
'assignment_option[upload_files_limit]': data.upload_files_limit,
226230
'assignment_option[upload_file_size_limit]': data.upload_file_size_limit,
231+
'assignment_option[is_retry_allowed]': data.is_retry_allowed ? '1' : '0',
227232

233+
...(data.is_retry_allowed && {
234+
'assignment_option[attempts_allowed]': data.attempts_allowed,
235+
}),
228236
...(isAddonEnabled(Addons.CONTENT_DRIP) &&
229237
contentDripType === 'unlock_by_date' && {
230238
'content_drip_settings[unlock_date]': data.content_drip_settings.unlock_date || '',

assets/react/v3/entries/payment-settings/components/PaymentItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ const PaymentItem = ({ data, paymentIndex, isOverlay = false }: PaymentItemProps
270270
label={field.label}
271271
helpText={field.hint}
272272
toolbar1="formatselect bold italic underline | bullist numlist | blockquote | alignleft aligncenter alignright | link unlink"
273+
toolbar2=""
273274
/>
274275
);
275276

assets/react/v3/entries/payment-settings/components/modals/ManualPaymentModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const ManualPaymentModal = ({ closeModal, title, paymentForm }: ManualPaymentMod
118118
{...controllerProps}
119119
label={field.label}
120120
toolbar1="formatselect bold italic underline | bullist numlist | blockquote | alignleft aligncenter alignright | link unlink"
121+
toolbar2=""
121122
/>
122123
)}
123124
/>

assets/react/v3/entries/payment-settings/services/payment.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ export interface PaymentSettings {
3636
}
3737

3838
export const getWebhookUrl = (gateway: string) => {
39-
if (gateway === 'authorizenet') {
40-
return `${tutorConfig.home_url}/wp-json/tutor/v1/ecommerce-webhook/${gateway}`;
41-
}
42-
return `${tutorConfig.home_url}/wp-json/tutor/v1/ecommerce-webhook?payment_method=${gateway}`;
39+
return `${tutorConfig.home_url}/wp-json/tutor/v1/ecommerce-webhook/${gateway}`;
4340
};
4441

4542
export const initialPaymentSettings: PaymentSettings = {

assets/react/v3/shared/atoms/WPEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ function editorConfig(
4646
propsToolbar2?: string,
4747
) {
4848
let toolbar1 =
49-
propsToolbar1 ||
49+
propsToolbar1 ??
5050
(isMinimal
5151
? `bold italic underline | image | ${isTutorPro ? 'codesample' : ''}`
5252
: `formatselect bold italic underline | bullist numlist | blockquote | alignleft aligncenter alignright | link unlink | wp_more ${
5353
isTutorPro ? ' codesample' : ''
5454
} | wp_adv`);
5555

5656
const toolbar2 =
57-
propsToolbar2 ||
57+
propsToolbar2 ??
5858
'strikethrough hr | forecolor pastetext removeformat | charmap | outdent indent | undo redo | wp_help | fullscreen | tutor_button | undoRedoDropdown';
5959

6060
toolbar1 = isAboveMobile ? toolbar1 : toolbar1.replaceAll(' | ', ' ');

assets/react/v3/shared/components/fields/FormInput.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,9 @@ const styles = {
250250
${styleUtils.inputClearButton};
251251
${type !== 'password' &&
252252
css`
253-
color: ${colorTokens.icon.brand};
253+
svg {
254+
color: ${colorTokens.icon.brand};
255+
}
254256
`}
255-
256-
&:focus,
257-
&:active,
258-
&:hover {
259-
color: ${colorTokens.icon.default};
260-
}
261257
`,
262258
};

assets/react/v3/shared/components/modals/Modal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ export const ModalProvider: React.FunctionComponent<{ children: ReactNode }> = (
172172
useEffect(() => {
173173
const handleKeyDown = (event: KeyboardEvent) => {
174174
const currentlyOpenPopovers = document.querySelectorAll('.tutor-portal-popover');
175+
const isWPModalOpen = !!document.body.classList.contains('modal-open');
175176

176177
if (
177178
event.key === 'Escape' &&
178179
state.modals[state.modals.length - 1]?.closeOnEscape &&
179-
!currentlyOpenPopovers.length
180+
!currentlyOpenPopovers.length &&
181+
!isWPModalOpen
180182
) {
181183
closeModal({ action: 'CLOSE' });
182184
}

assets/scss/front/course-spotlight/course-assignment.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.tutor-assignment-detail-info {
1717
> div {
1818
&:not(:last-child) {
19-
margin-right: 50px;
19+
margin-right: 16px;
2020
}
2121
}
2222
@include breakpoint-minmax(576, 1192) {

0 commit comments

Comments
 (0)