EssaysReportsGenerator::getGroupEssays()

Load all the essays from the courses belong to the group

Description

Source

File: bp-integrations/learndash/buddypress/generators/EssaysReportsGenerator.php

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
protected function getGroupEssays()
{
    if ($this->hasArg('course') && ! $this->args['course']) {
        $courseIds = learndash_group_enrolled_courses(
            bp_ld_sync('buddypress')->helpers->getLearndashGroupId($this->args['group'])
        );
    } else {
        $courseIds = [$this->args['course']];
    }
 
    $args = [
        'posts_per_page' => $this->args['length'],
        'page'           => $this->args['start'] / $this->args['length'] + 1,
        'post_type'      => learndash_get_post_type_slug('essays'),
        'post_status' => $this->args['completed']? 'graded' : 'not_graded',
        'meta_query' => [
            [
                'key' => 'course_id',
                'value' => $courseIds
            ]
        ]
    ];
 
    if ($this->hasArg('user') && $this->args['user']) {
        $args['author'] = $this->args['user'];
    }
 
    $this->registerQueryHooks();
    $query = new WP_Query($args);
    $this->unregisterQueryHooks();
 
    return $query;
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.