Skip to content
Open
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
27 changes: 22 additions & 5 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5364,8 +5364,8 @@ public function get_random_question_by_quiz( $quiz_id = 0 ) {
public function get_random_questions_by_quiz( $quiz_id = 0 ) {
global $wpdb;

$quiz_id = $this->get_post_id( $quiz_id );
$attempt = $this->is_started_quiz( $quiz_id );
$quiz_id = $this->get_post_id( $quiz_id );
$attempt = $this->is_started_quiz( $quiz_id );
if ( ! $attempt ) {
return false;
}
Expand Down Expand Up @@ -7307,9 +7307,26 @@ public function tutor_pages() {
public function get_course_prev_next_contents_by_id( $content_id = 0 ) {

$course_id = $this->get_course_id_by_content( $content_id );
$course_contents = $this->get_course_contents_by_id( $course_id );
$previous_id = 0;
$next_id = 0;
$course_contents = array();
$topics = $this->get_topics( $course_id, array( 'fields' => 'ids' ) );
$topic_ids = $topics->posts ?? array();

/*
* Get course content based on topic ordering
* instead of ordering all the content through query.
*/
if ( $this->count( $topic_ids ) ) {
foreach ( $topic_ids as $topic_id ) {
$course_content = $this->get_course_contents_by_topic( $topic_id, -1 );
if ( ! $this->count( $course_content->posts ) ) {
continue;
}
array_push( $course_contents, ...$course_content->posts );
}
}

$previous_id = 0;
$next_id = 0;

if ( $this->count( $course_contents ) ) {
$ids = wp_list_pluck( $course_contents, 'ID' );
Expand Down
Loading