Skip to content
Open
25 changes: 1 addition & 24 deletions assets/images/illustrations/confetti.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/illustrations/dashboard-empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/src/scss/frontend/dashboard/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@forward 'layout/account';

// Dashboard components
@forward 'profile-completion';
@forward 'stat-card';
@forward 'progress-card';
@forward 'course-card';
Expand All @@ -20,6 +21,7 @@
@forward 'pages/courses';
@forward 'pages/announcements';
@forward 'pages/wishlist';
@forward 'pages/student-dashboard';
@forward 'pages/instructor-dashboard';

// Account Pages
Expand Down
38 changes: 38 additions & 0 deletions assets/src/scss/frontend/dashboard/_profile-completion.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@use '@Core/scss/mixins' as *;
@use '@Core/scss/tokens' as *;

.tutor-profile-completion {
position: relative;
margin-bottom: $tutor-spacing-7;

&-header {
@include tutor-flex(row, center, space-between);
padding: $tutor-spacing-5;
background-color: $tutor-surface-l1;
border: 1px solid $tutor-border-idle;
border-radius: $tutor-radius-2xl;

&.tutor-expanded {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}

&-body {
@include tutor-flex(column);
gap: $tutor-spacing-5;
padding: $tutor-spacing-5 26px;
border: 1px solid $tutor-border-idle;
border-top: none;
border-bottom-left-radius: $tutor-radius-2xl;
border-bottom-right-radius: $tutor-radius-2xl;
box-shadow: $tutor-shadow-lg;

position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: $tutor-surface-l1;
z-index: $tutor-z-dropdown;
}
}
2 changes: 0 additions & 2 deletions assets/src/scss/frontend/dashboard/_stat-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@
}

&-time-spent {
cursor: pointer;

.tutor-stat-card-icon {
color: $tutor-text-exception4;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,6 @@
@use '@Core/scss/mixins' as *;
@use '@Core/scss/tokens' as *;

.tutor-profile-completion {
position: relative;
margin-bottom: $tutor-spacing-6;

&-header {
@include tutor-flex(row, center, space-between);
padding: $tutor-spacing-5;
background-color: $tutor-surface-l1;
border: 1px solid $tutor-border-idle;
border-radius: $tutor-radius-2xl;

&.tutor-expanded {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}

&-body {
@include tutor-flex(column);
gap: $tutor-spacing-5;
padding: $tutor-spacing-5 26px;
border: 1px solid $tutor-border-idle;
border-top: none;
border-bottom-left-radius: $tutor-radius-2xl;
border-bottom-right-radius: $tutor-radius-2xl;
box-shadow: $tutor-shadow-lg;

position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: $tutor-surface-l1;
z-index: $tutor-z-dropdown;
}
}

.tutor-stat-card-value {
@include tutor-text(h3);
}
Expand Down
47 changes: 47 additions & 0 deletions assets/src/scss/frontend/dashboard/pages/_student-dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@use '@Core/scss/tokens' as *;
@use '@Core/scss/mixins' as *;

.tutor-dashboard-welcome-card {
@include tutor-flex(row, center, space-between);
@include tutor-card-base();
@include tutor-card-radius(2xl);
padding: $tutor-spacing-8;
margin-bottom: $tutor-spacing-7;

@include tutor-breakpoint-down(sm) {
flex-direction: column;
align-items: start;
gap: $tutor-spacing-8;
}

.tutor-dashboard-welcome-content {
max-width: 270px;
}

.tutor-dashboard-welcome-badge {
@include tutor-typography(tiny, semibold, brand);
display: inline-flex;
align-items: center;
gap: $tutor-spacing-2;
background-color: $tutor-surface-brand-tertiary;
padding: $tutor-spacing-2 $tutor-spacing-5;
border-radius: $tutor-radius-6xl;
}

.tutor-dashboard-welcome-banner {
padding-inline-end: $tutor-spacing-6;
}
}

.tutor-dashboard-quick-tips-card {
@include tutor-flex(row, start, space-between);
@include tutor-card-base();
@include tutor-card-radius(2xl);
padding: $tutor-spacing-8;
margin-bottom: $tutor-spacing-7;

@include tutor-breakpoint-down(sm) {
flex-direction: column;
gap: $tutor-spacing-8;
}
}
15 changes: 15 additions & 0 deletions assets/src/scss/frontend/kids/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
@include tutor-kids-shadow;
}

.tutor-dashboard-welcome-card,
.tutor-dashboard-quick-tips-card,
.tutor-profile-completion-header {
@include tutor-kids-shadow(false);
}

.tutor-billing-card:hover {
@include tutor-kids-shadow;
&:not(:last-of-type) {
Expand All @@ -70,6 +76,15 @@
}

// home
.tutor-profile-completion-body {
border: none;
box-shadow:
0 2px 0 2px $tutor-border-idle,
0 5px 0 0 $tutor-border-idle;
border-bottom-left-radius: $tutor-radius-5xl;
border-bottom-right-radius: $tutor-radius-5xl;
}

.tutor-student-dashboard-courses {
.tutor-progress-card:not(:first-child) {
margin-top: $tutor-spacing-4;
Expand Down
24 changes: 17 additions & 7 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
global $wp_query;
$course_coming_soon_enabled = (int) get_post_meta( $content->ID, '_tutor_course_enable_coming_soon', true );
$is_instructor = tutor_utils()->is_instructor_of_this_course( get_current_user_id(), $content->ID, true );
if ( ! CourseModel::get_post_types( $content ) || current_user_can( 'administrator' ) || $is_instructor || $course_coming_soon_enabled ) {

Check failure on line 335 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

Capabilities should be used instead of roles. Found "administrator" in function call to current_user_can()
return $content;
}

Expand Down Expand Up @@ -663,7 +663,7 @@
} else {
$errors['pricing'] = __( 'Invalid product', 'tutor' );
}
} else {

Check failure on line 666 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

If control structure block found as the only statement within an "else" block. Use elseif instead.
/**
* If user does not select WC product
* Then automatic WC product will be create name with course title.
Expand Down Expand Up @@ -800,7 +800,7 @@
update_post_meta( $post_id, self::COURSE_PRICE_TYPE_META, $params['pricing']['type'] );
}
} catch ( \Throwable $th ) {
throw new \Exception( $th->getMessage() );

Check failure on line 803 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$th'.
}
}

Expand Down Expand Up @@ -2369,7 +2369,7 @@
}

// Check if user is only an instructor.
if ( ! current_user_can( 'administrator' ) ) {

Check failure on line 2372 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

Capabilities should be used instead of roles. Found "administrator" in function call to current_user_can()
// Check if instructor can trash course.
$can_trash_post = tutor_utils()->get_option( 'instructor_can_delete_course' );

Expand Down Expand Up @@ -3437,7 +3437,7 @@
}

/**
* Calculate the total course duration for a set of courses.
* Calculate the total course duration for a set of courses and returns the total time in hours, minutes, and seconds.
*
* @since 4.0.0
*
Expand All @@ -3455,19 +3455,29 @@
foreach ( $course_ids as $id ) {
$duration = tutor_utils()->get_course_duration( (int) $id, true );

$total_seconds += ( (int) $duration['durationHours'] * 3600 )
+ ( (int) $duration['durationMinutes'] * 60 )
$completion_percentage = tutor_utils()->is_completed_course( $id )
? 100
: (int) tutor_utils()->get_course_completed_percent( (int) $id );

if ( 0 === $completion_percentage ) {
continue;
}

$course_duration_in_seconds = ( (int) $duration['durationHours'] * HOUR_IN_SECONDS )
+ ( (int) $duration['durationMinutes'] * MINUTE_IN_SECONDS )
+ ( (int) $duration['durationSeconds'] );

// Calculate the time spent by a user based on the course completion percentage.
$total_seconds += $course_duration_in_seconds * ( $completion_percentage / 100 );
}

$hours = floor( $total_seconds / 3600 );
$minutes = floor( $total_seconds / 60 );
$seconds = $total_seconds;
$hours = floor( $total_seconds / HOUR_IN_SECONDS );
$minutes = floor( $total_seconds / MINUTE_IN_SECONDS );

return array(
'hours' => (int) $hours,
'minutes' => (int) $minutes,
'seconds' => (int) $seconds,
'seconds' => (int) $total_seconds,
);
}

Expand Down
23 changes: 20 additions & 3 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -7217,10 +7217,12 @@ public function user_profile_completion( $user_id = 0 ) {
$instructor_status = get_user_meta( $user_id, '_tutor_instructor_status', true );

$settings_url = Dashboard::get_account_page_url( 'settings' );
$social_settings_url = Dashboard::get_account_page_url( 'settings?tab=social-accounts' );
$withdraw_settings_url = Dashboard::get_account_page_url( 'settings?tab=withdraw' );

$required_fields = array(
'_tutor_profile_photo' => __( 'Set Your Profile Photo', 'tutor' ),
'_tutor_social_links' => __( 'Add Your Social Links', 'tutor' ),
'_tutor_profile_bio' => __( 'Set Your Bio', 'tutor' ),
);

Expand All @@ -7229,16 +7231,31 @@ public function user_profile_completion( $user_id = 0 ) {
$required_fields['_tutor_withdraw_method_data'] = __( 'Set Withdraw Method', 'tutor' );
}

// Check if any individual social link meta is set.
$social_meta_keys = array_keys( $this->tutor_user_social_icons() );
$has_social_link = false;
foreach ( $social_meta_keys as $social_key ) {
if ( get_user_meta( $user_id, $social_key, true ) ) {
$has_social_link = true;
break;
}
}

// url where user should redirect for profile completion.
$profile_completion_urls = array(
'_tutor_profile_photo' => $settings_url,
'_tutor_profile_bio' => $settings_url,
'_tutor_social_links' => $social_settings_url,
'_tutor_withdraw_method_data' => $withdraw_settings_url,
);
foreach ( $required_fields as $key => $field ) {
$is_set = '_tutor_social_links' === $key
? $has_social_link
: (bool) get_user_meta( $user_id, $key, true );

$required_fields[ $key ] = array(
'text' => $field,
'is_set' => get_user_meta( $user_id, $key, true ) ? true : false,
'is_set' => $is_set,
'url' => $profile_completion_urls[ $key ],
);
}
Expand Down Expand Up @@ -8120,10 +8137,10 @@ public function course_with_materials(): array {
* @since 2.0.0
*
* @param int $course_id course id.
* @param array $return_array return array.
* @param bool $return_array return array.
* @param array $texts texts.
*
* @return string
* @return string | array
*/
public function get_course_duration( $course_id, $return_array, $texts = array(
'h' => 'hr',
Expand Down
10 changes: 9 additions & 1 deletion components/EmptyState.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,16 @@ public function get(): string {
);
}

// Merge custom classes.
$wrapper_classes = 'tutor-px-9 tutor-py-10 tutor-flex-center-col';
if ( ! empty( $this->attributes['class'] ) ) {
$wrapper_classes .= ' ' . $this->attributes['class'];
unset( $this->attributes['class'] );
}
$this->attributes['class'] = $wrapper_classes;

$this->component_string = sprintf(
'<div class="tutor-px-9 tutor-py-10 tutor-flex-center-col" %s>
'<div %s>
%s
<div class="tutor-small tutor-text-subdued tutor-mt-4">%s</div>
%s
Expand Down
3 changes: 1 addition & 2 deletions templates/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,14 @@
} elseif ( User::is_instructor_view() ) {
tutor_load_template( 'dashboard.dashboard' );
} else {
tutor_load_template( 'dashboard.student-dashboard' );
tutor_load_template( 'dashboard.student.dashboard' );
}
?>
</div>
</div>
</div>
</div>
<?php do_action( 'tutor_dashboard/after/wrap' ); ?>
</body>
<?php if ( ! $is_by_short_code && ! defined( 'OTLMS_VERSION' ) ) : ?>
</body>
<?php wp_footer(); ?>
Expand Down
6 changes: 3 additions & 3 deletions templates/dashboard/courses/course-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
?>

<div class="tutor-progress-card">
<div class="tutor-progress-card-inner" onclick="window.location.href = '<?php echo esc_url( $course_learning_url ); ?>';">
<div class="tutor-progress-card-inner" onclick="window.location.href = '<?php echo esc_js( esc_url( $course_learning_url ) ); ?>';">
<div class="tutor-progress-card-thumbnail">
<?php do_action( 'tutor_courses_card_before_thumbnail', $course_id ); ?>
<?php if ( ! empty( $tutor_course_img ) ) : ?>
<img src="<?php echo esc_url( $tutor_course_img ); ?>" alt="<?php the_title(); ?>" />
<img src="<?php echo esc_url( $tutor_course_img ); ?>" alt="<?php the_title_attribute(); ?>" />
<?php endif; ?>
</div>

Expand All @@ -47,7 +47,7 @@
</div>
<?php endif; ?>
<h3 class="tutor-progress-card-title tutor-line-clamp-2">
<?php the_title(); ?>
<?php echo esc_html( $course_title ); ?>
</h3>
</div>

Expand Down
2 changes: 1 addition & 1 deletion templates/dashboard/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
defined( 'ABSPATH' ) || exit;

do_action( 'tutor_before_dashboard_content' );
tutor_load_template( 'dashboard.instructor.home.profile-completion' );
tutor_load_template( 'dashboard.components.profile-completion' );
tutor_load_template( 'dashboard.instructor.home' );
Loading
Loading