Skip to content

Commit 771378a

Browse files
committed
Merge branch '4.0.0-dev' into feat/quiz-type-pin-image
2 parents f837c63 + 94fa421 commit 771378a

24 files changed

Lines changed: 1133 additions & 97 deletions

File tree

assets/src/scss/frontend/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
@forward 'discussion-card.scss';
1313
@forward 'discussion-single.scss';
1414
@forward 'upcoming-lesson-card.scss';
15+
@forward 'quiz-attempts.scss';
1516
@forward 'player';

assets/src/scss/frontend/dashboard/_quiz-attempts.scss renamed to assets/src/scss/frontend/components/_quiz-attempts.scss

File renamed without changes.

assets/src/scss/frontend/dashboard/_index.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
@forward 'pages/my-courses';
2121
@forward 'pages/announcements';
2222
@forward 'assignments';
23-
@forward 'quiz-attempts';
2423
@forward 'certificates';
2524
@forward 'reviews';
2625
@forward 'settings';

assets/src/scss/frontend/learning-area/layout/_sidebar.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
a {
165165
@include tutor-button-reset();
166166
@include tutor-typography(small, medium, subdued);
167-
@include tutor-flex(row, center);
167+
@include tutor-flex(row);
168168
gap: $tutor-spacing-4;
169169
padding: $tutor-spacing-4 $tutor-spacing-5;
170170
min-height: 40px;

classes/Lesson.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Tutor\Helpers\ValidationHelper;
2020
use Tutor\Models\LessonModel;
2121
use Tutor\Traits\JsonResponse;
22+
use WP_Post;
2223

2324
/**
2425
* Lesson class
@@ -35,7 +36,7 @@ class Lesson extends Tutor_Base {
3536
* @var string
3637
*/
3738
const PREVIEW_META_KEY = '_is_preview';
38-
39+
3940
/**
4041
* Lesson post type
4142
*
@@ -1100,4 +1101,31 @@ public function load_lesson_comments() {
11001101
)
11011102
);
11021103
}
1104+
1105+
/**
1106+
* Get lesson content type info with video duration
1107+
*
1108+
* @since 4.0.0
1109+
*
1110+
* @param WP_Post $lesson Lesson post.
1111+
*
1112+
* @return string
1113+
*/
1114+
public static function get_content_type_info( WP_Post $lesson ) {
1115+
$video_info = tutor_utils()->get_video_info( $lesson->ID );
1116+
$lesson_type = __( 'Reading', 'tutor' );
1117+
1118+
if ( $video_info ) {
1119+
$lesson_type = __( 'Video', 'tutor' );
1120+
$playtime = $video_info->playtime ?? '';
1121+
1122+
// Check if the playtime is actually a valid, positive duration.
1123+
if ( ! empty( $playtime ) ) {
1124+
/* translators: %s: duration in minutes */
1125+
$lesson_type = sprintf( __( 'Video - %s mins', 'tutor' ), $playtime );
1126+
}
1127+
}
1128+
1129+
return $lesson_type;
1130+
}
11031131
}

classes/Quiz.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
exit;
1515
}
1616

17+
use Tutor\Components\Table;
1718
use Tutor\Helpers\HttpHelper;
1819
use Tutor\Helpers\QueryHelper;
1920
use Tutor\Models\CourseModel;
@@ -1451,4 +1452,65 @@ public function render_single_content( WP_Post $quiz ): void {
14511452
)
14521453
);
14531454
}
1455+
1456+
/**
1457+
* Render quiz summary
1458+
*
1459+
* @since 4.0.0
1460+
*
1461+
* @param int $total_questions Total questions.
1462+
* @param string $quiz_item_readable Readable time.
1463+
* @param string $passing_grade Passing grade.
1464+
*
1465+
* @return void
1466+
*/
1467+
public static function render_quiz_summary( $total_questions, $quiz_item_readable, $passing_grade ) {
1468+
$quiz_summary = array(
1469+
array(
1470+
'columns' => array(
1471+
array(
1472+
'content' => '<div class="tutor-flex tutor-gap-3 tutor-items-center">
1473+
' . tutor_utils()->get_svg_icon( Icon::QUESTION_CIRCLE ) . __( 'Questions', 'tutor' ) . '
1474+
</div>',
1475+
),
1476+
array( 'content' => $total_questions ),
1477+
),
1478+
),
1479+
array(
1480+
'columns' => array(
1481+
array(
1482+
'content' => '<div class="tutor-flex tutor-gap-3 tutor-items-center">
1483+
' . tutor_utils()->get_svg_icon( Icon::CLOCK ) . __( 'Quiz Time', 'tutor' ) . '
1484+
</div>',
1485+
),
1486+
array( 'content' => $quiz_item_readable ),
1487+
),
1488+
),
1489+
array(
1490+
'columns' => array(
1491+
array(
1492+
'content' => '<div class="tutor-flex tutor-gap-3 tutor-items-center">
1493+
' . tutor_utils()->get_svg_icon( Icon::PASSED ) . __( 'Passing Marks', 'tutor' ) . '
1494+
</div>',
1495+
),
1496+
array( 'content' => $passing_grade ),
1497+
),
1498+
),
1499+
);
1500+
1501+
Table::make()->contents( $quiz_summary )->render();
1502+
}
1503+
1504+
/**
1505+
* Render quiz attempts
1506+
*
1507+
* @since 4.0.0
1508+
*
1509+
* @param int $quiz_id Quiz ID.
1510+
*
1511+
* @return void
1512+
*/
1513+
public static function render_quiz_attempts( $quiz_id ) {
1514+
// @TODO.
1515+
}
14541516
}

classes/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5208,7 +5208,7 @@ public function total_questions_for_student_by_quiz( $quiz_id ) {
52085208
$quiz_id = $this->get_post_id( $quiz_id );
52095209
global $wpdb;
52105210

5211-
$max_questions_count = (int) $this->get_quiz_option( get_the_ID(), 'max_questions_for_answer' );
5211+
$max_questions_count = (int) $this->get_quiz_option( $quiz_id, 'max_questions_for_answer' );
52125212
$total_question = (int) $wpdb->get_var(
52135213
$wpdb->prepare(
52145214
"SELECT count(question_id)

components/Table.php

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,6 @@ class Table extends BaseComponent {
9191
*/
9292
protected $cell_content;
9393

94-
/**
95-
* Table class names.
96-
*
97-
* @var string
98-
*/
99-
protected $attribute;
100-
10194
/**
10295
* Set table column headings.
10396
*
@@ -122,20 +115,6 @@ public function headings( array $headings ): self {
122115
return $this;
123116
}
124117

125-
/**
126-
* Sets the custom table class.
127-
*
128-
* @since 4.0.0
129-
*
130-
* @param string $attribute the attribute string.
131-
*
132-
* @return self
133-
*/
134-
public function attributes( string $attribute ): self {
135-
$this->attribute = $attribute;
136-
return $this;
137-
}
138-
139118
/**
140119
* Set table cell contents.
141120
*
@@ -222,18 +201,26 @@ protected function render_table_body(): string {
222201
* @return string HTML
223202
*/
224203
public function get(): string {
204+
if ( isset( $this->attributes['class'] ) && ! empty( $this->attributes['class'] ) ) {
205+
$this->attributes['class'] = 'tutor-table ' . $this->attributes['class'];
206+
} else {
207+
$this->attributes['class'] = 'tutor-table';
208+
}
209+
210+
ob_start();
211+
$this->render_attributes();
212+
$attrs = ob_get_clean();
225213
return sprintf(
226-
'<div class="%s">
227-
<table class="tutor-table">
214+
'<table %s>
228215
<thead>
229216
%s
230217
</thead>
231218
<tbody>
232219
%s
233220
</tbody>
234221
</table>
235-
</div>',
236-
esc_attr( $this->attribute ),
222+
',
223+
$attrs,
237224
$this->render_table_headings(),
238225
$this->render_table_body()
239226
);

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
<testsuite name="course-model-test">
2828
<directory>tests/phpunit/CourseModelTest.php</directory>
2929
</testsuite>
30+
<testsuite name="lesson-test">
31+
<directory>tests/phpunit/LessonContentInfoTest.php</directory>
32+
</testsuite>
3033
</testsuites>
3134
</phpunit>

templates/demo-components/dynamic-components.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@
452452
Table::make()
453453
->headings( $heading )
454454
->contents( $content )
455-
->attributes( 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
455+
->attr( 'class', 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
456456
->render();
457457
</code></pre>
458458
<?php
@@ -481,7 +481,7 @@
481481
Table::make()
482482
->headings( $heading )
483483
->contents( $content )
484-
->attributes( 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
484+
->attr( 'class', 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
485485
->render();
486486
?>
487487
<pre><code>&lt;php
@@ -510,7 +510,7 @@
510510

511511
Table::make()
512512
->contents( $content )
513-
->attributes( 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
513+
->attr( 'class', 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
514514
->render();php&gt;
515515
</code></pre>
516516

@@ -540,7 +540,7 @@
540540

541541
Table::make()
542542
->contents( $content )
543-
->attributes( 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
543+
->attr( 'class', 'tutor-table-wrapper tutor-table-column-borders tutor-mb-6' )
544544
->render();
545545
?>
546546

0 commit comments

Comments
 (0)