AssignmentsReportsGenerator::getGroupAssignments()

Load all the assignments from the courses belong to the group

Description

Source

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

	protected function getGroupAssignments()
	{
		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('assignment'),
			'post_status' => 'publish',
			'meta_query' => [
				[
					'key' => 'course_id',
					'value' => $courseIds
				]
			]
		];

		if ($this->args['completed']) {
			$args['meta_query'][] = [
				'key' => 'approval_status',
				'value' => 1
			];
		} else {
			$args['meta_query'][] = [
				'key' => 'approval_status',
				'compare' => 'NOT EXISTS'
			];
		}

		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.