Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
core_analytics\course Class Reference

Moodle course analysable. More...

Inheritance diagram for core_analytics\course:
core_analytics\analysable

Public Member Functions

 __construct ($course, ?\context $context=null)
 Course manager constructor. More...
 
 get_all_activities ($activitytype)
 Returns all the activities of the provided type the course has. More...
 
 get_context ()
 get_context More...
 
 get_course_data ()
 Returns a course plain object. More...
 
 get_end ()
 Get the course end timestamp. More...
 
 get_id ()
 get_id More...
 
 get_name ()
 The course short name. More...
 
 get_start ()
 Get the course start timestamp. More...
 
 get_student_grades ($courseactivities)
 Returns the course students grades. More...
 
 get_students ()
 Returns the course students. More...
 
 get_total_logs ()
 Returns the total number of student logs in the course. More...
 
 get_user_ids ($roleids)
 Returns a list of user ids matching the specified roles in this course. More...
 
 guess_end ()
 Get the course end timestamp. More...
 
 guess_start ()
 Guesses the start of the course based on students' activity and enrolment start dates. More...
 
 is_finished ()
 Has the course finished? More...
 
 was_started ()
 Has the course started? More...
 

Static Public Member Functions

static instance ($course, ?\context $context=null)
 Returns an analytics course instance. More...
 

Public Attributes

const MAX_TIME = 9999999999
 Max timestamp.
 

Protected Member Functions

 course_students_query_filter ($prefix=false)
 Returns the query and params used to filter the logstore by this course students. More...
 
 filter_user_id ($record)
 Used by get_user_ids to extract the user id. More...
 
 load ()
 Loads the analytics course object. More...
 
 median ($values)
 Calculate median. More...
 
 update_loop_times ($start, $end)
 Returns the average time between 2 timestamps. More...
 

Protected Attributes

stdClass $course = null
 Course object.
 
array $courseactivities = array()
 The course activities organized by activity type.
 
context_course $coursecontext = null
 The course context.
 
int $endtime = null
 Course end time.
 
bool $finished = null
 Is the course finished?
 
bool $loaded = false
 Has this course data been already loaded.
 
int $ntotallogs = null
 Cached copy of the total number of logs in the course.
 
bool $started = null
 Has the course already started?
 
int $starttime = null
 Course start time.
 
int[] $studentids = []
 Course students ids.
 
int[] $teacherids = []
 Course teachers ids.
 

Static Protected Attributes

static int $cachedid = 0
 $cachedid self::$cachedinstance analysable id.
 
static core_analytics course $cachedinstance = null
 $cachedinstance
 

Detailed Description

Moodle course analysable.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_analytics\course::__construct (   $course,
?\context  $context = null 
)

Course manager constructor.

Use self::instance() instead to get cached copies of the course. Instances obtained through this constructor will not be cached.

Parameters
int | stdClass$courseCourse id or mdl_course record
context | null$context
Return values
void

Member Function Documentation

◆ course_students_query_filter()

core_analytics\course::course_students_query_filter (   $prefix = false)
protected

Returns the query and params used to filter the logstore by this course students.

Parameters
string$prefix
Return values
array

◆ filter_user_id()

core_analytics\course::filter_user_id (   $record)
protected

Used by get_user_ids to extract the user id.

Parameters
stdClass$record
Return values
intThe user id.

◆ get_all_activities()

core_analytics\course::get_all_activities (   $activitytype)

Returns all the activities of the provided type the course has.

Parameters
string$activitytype
Return values
array

◆ get_context()

core_analytics\course::get_context ( )

get_context

Return values
context

Implements core_analytics\analysable.

◆ get_course_data()

core_analytics\course::get_course_data ( )

Returns a course plain object.

Return values
stdClass

◆ get_end()

core_analytics\course::get_end ( )

Get the course end timestamp.

Return values
intTimestamp or 0 if time end was not set.

Implements core_analytics\analysable.

◆ get_id()

core_analytics\course::get_id ( )

get_id

Return values
int

Implements core_analytics\analysable.

◆ get_name()

core_analytics\course::get_name ( )

The course short name.

Return values
string

Implements core_analytics\analysable.

◆ get_start()

core_analytics\course::get_start ( )

Get the course start timestamp.

Return values
intTimestamp or 0 if has not started yet.

Implements core_analytics\analysable.

◆ get_student_grades()

core_analytics\course::get_student_grades (   $courseactivities)

Returns the course students grades.

Parameters
array$courseactivities
Return values
array

◆ get_students()

core_analytics\course::get_students ( )

Returns the course students.

Return values
int[]

◆ get_total_logs()

core_analytics\course::get_total_logs ( )

Returns the total number of student logs in the course.

Return values
int

◆ get_user_ids()

core_analytics\course::get_user_ids (   $roleids)

Returns a list of user ids matching the specified roles in this course.

Parameters
array$roleids
Return values
array

◆ guess_end()

core_analytics\course::guess_end ( )

Get the course end timestamp.

Return values
intTimestamp, core_analytics\analysable::MAX_TIME if we don't know but ongoing and 0 if we can not work it out.

◆ guess_start()

core_analytics\course::guess_start ( )

Guesses the start of the course based on students' activity and enrolment start dates.

Return values
int

◆ instance()

static core_analytics\course::instance (   $course,
?\context  $context = null 
)
static

Returns an analytics course instance.

Lazy load of course data, students and teachers.

Parameters
int | stdClass$courseCourse object or course id
context | null$context
Return values
core_analytics

◆ is_finished()

core_analytics\course::is_finished ( )

Has the course finished?

Return values
bool

◆ load()

core_analytics\course::load ( )
protected

Loads the analytics course object.

Return values
void

◆ median()

core_analytics\course::median (   $values)
protected

Calculate median.

Keys are ignored.

Parameters
int[] | float[]$valuesSorted array of values
Return values
int

◆ update_loop_times()

core_analytics\course::update_loop_times (   $start,
  $end 
)
protected

Returns the average time between 2 timestamps.

Parameters
int$start
int$end
Return values
array[starttime, averagetime, endtime]

◆ was_started()

core_analytics\course::was_started ( )

Has the course started?

Return values
bool

The documentation for this class was generated from the following file: