LLMS_Table_Student_Courses::get_data( string $key, int $course_id )

Retrieve data for the columns


Parameters Parameters

$key

(string) (Required) the column id / key

$course_id

(int) (Required) ID of the course


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/admin/reporting/tables/llms.table.student.courses.php

	public function get_data( $key, $course_id ) {

		$course = new LLMS_Course( $course_id );

		switch ( $key ) {

			case 'progress':
				$value = $this->student->get_progress( $course->get( 'id' ), 'course' ) . '%';
				break;

			case 'completed':
				$date  = $this->student->get_completion_date( $course->get( 'id' ) );
				$value = $date ? $date : '–';
				break;

			case 'grade':
				$grade = $this->student->get_grade( $course->get( 'id' ) );
				$value = is_numeric( $grade ) ? $grade . '%' : $grade;

				break;

			case 'id':
				$value = $course->get( 'id' );
				if ( current_user_can( 'edit_post', $value ) ) {
					$value = $this->get_post_link( $value );
				}
				break;

			case 'name':
				$id = $course->get( 'id' );
				if ( current_user_can( 'edit_post', $id ) ) {
					$url   = esc_url(
						add_query_arg(
							array(
								'course_id'  => $course->get( 'id' ),
								'page'       => 'llms-reporting',
								'stab'       => 'courses',
								'student_id' => $this->student->get_id(),
							),
							admin_url( 'admin.php' )
						)
					);
					$value = '<a href="' . $url . '">' . $course->get( 'title' ) . '</a>';
				} else {
					$value = $course->get( 'title' );
				}
				break;

			case 'status':
				$value = llms_get_enrollment_status_name( $this->student->get_enrollment_status( $course->get( 'id' ) ) );
				break;

			case 'updated':
				$value = $this->student->get_enrollment_date( $course->get( 'id' ), 'updated' );
				break;

			default:
				$value = $key;

		}// End switch().

		return $this->filter_get_data( $value, $key, $course_id );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.