MIDDAG for Moodle

lookerstudio extends deprecated_item

The lookerstudio class handles the creation, update, retrieval, and listing of Looker Studio dashboard instances.

It extends the base functionality provided by the item class.

Table of Contents

Constants

PERPAGE  = 50
STATUS_ACTIVE  = 'active'
STATUS_CANCELED  = 'canceled'
STATUS_COMPLETED  = 'completed'
STATUS_DELETED  = 'deleted'
STATUS_DISABLED  = 'disabled'
STATUS_DISAPPROVED  = 'disapproved'
STATUS_ENABLED  = 'enabled'
STATUS_EXPIRED  = 'expired'
STATUS_FAILED  = 'failed'
STATUS_FINISH  = 'finish'
STATUS_INACTIVE  = 'inactive'
STATUS_INPROGRESS  = 'inprogress'
STATUS_NEW  = 'new'
STATUS_PAUSED  = 'paused'
STATUS_PLAYED  = 'played'
STATUS_SYNC  = 'sync'
TYPE  = 'lookerstudio_dashboard'

Properties

$contextid  : mixed
$courseid  : mixed
$description  : mixed
$descriptionformat  : mixed
$embed_url  : mixed
$fullname  : mixed
$guid  : mixed
$id  : mixed
$idnumber  : mixed
$mapping_fields  : array<string|int, mixed>|string
$parent  : mixed
$shortname  : mixed
$sortorder  : mixed
$status  : mixed
$timecreated  : mixed
$timemodified  : mixed
$type  : mixed
$userid  : mixed
$usermodified  : mixed
$version  : mixed
$visible  : mixed
$fillable  : mixed
$table  : mixed
$table_metadata  : mixed

Methods

__clone()  : mixed
__construct()  : mixed
Constructor.
all()  : array<string|int, mixed>
create_or_update()  : self
Creates a new instance or updates an existing one with the provided data.
delete()  : bool
deleted()  : bool
disabled()  : bool
enabled()  : bool
get_all_metadata()  : array<string, mixed>
get_file()  : mixed
Get file associated with the model.
get_fileurl()  : mixed
Get file URL.
get_item_or_create()  : deprecated_item
Factory method to get existing or create a new item.
get_items()  : array<string|int, deprecated_item>
get_items_by_metadata()  : array<string|int, mixed>
get_meta()  : mixed
Get metadata value by key.
get_path()  : string|null
get_records()  : array<string|int, deprecated_model_interface>
get_table()  : string|null
get_table_metadata()  : string
get_user_cohorts_by_course_context()  : array<string|int, mixed>
list()  : array<string|int, mixed>
Retrieves a list of records with relevant details.
load()  : void
prepare_lookerstudio_iframe()  : string
Prepares an iframe embedding Looker Studio report with the provided parameters.
prepare_lookerstudio_params()  : array<string|int, mixed>
Prepares and returns the parameters for Looker Studio based on the mapping fields.
render()  : string
Renders a Looker Studio dashboard based on the provided attributes.
set_meta()  : void
Set metadata key-value pair.
set_metas()  : void
Set multiple metadata key-value pairs.
update()  : static
Update the model with form data.
url_generator()  : moodle_url
Generate a URL based on the Symfony route name and parameters.
webhook_url_generator()  : moodle_url
Generate a webhook URL.
from_record()  : static
get()  : false|mixed|stdClass
Get record by ID.
get_by_idnumber()  : false|mixed|stdClass
Get record by idnumber.
save()  : mixed

Constants

Properties

$mapping_fields

public array<string|int, mixed>|string $mapping_fields

$fillable

protected mixed $fillable = ['embed_url', 'mapping_fields']

Methods

__construct()

Constructor.

public __construct([mixed $id = null ]) : mixed
Parameters
$id : mixed = null

all()

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

create_or_update()

Creates a new instance or updates an existing one with the provided data.

public static create_or_update(object $data[, int $id = 0 ]) : self
Parameters
$data : object

An object containing the fields to create or update the instance. Expected properties include:

  • name (string): The name to assign to the instance.
  • embedUrl (string): The URL to embed.
  • mappings (array): The mapping fields to associate with the instance.
$id : int = 0

Optional. The ID of the instance to update. Defaults to 0 for creating a new instance.

Tags
throws
Exception

if an error occurs during the creation or update process

Return values
self

the created or updated instance

deleted()

public deleted() : bool
Tags
throws
dml_exception
Return values
bool

get_all_metadata()

public get_all_metadata() : array<string, mixed>
Return values
array<string, mixed>

get_file()

Get file associated with the model.

public get_file(mixed $context, mixed $component, mixed $filearea[, mixed $validimage = false ]) : mixed
Parameters
$context : mixed
$component : mixed
$filearea : mixed
$validimage : mixed = false
Tags
throws
coding_exception

get_fileurl()

Get file URL.

public static get_fileurl(mixed $file) : mixed
Parameters
$file : mixed

get_item_or_create()

Factory method to get existing or create a new item.

public static get_item_or_create(null|int|string $contextid[, string $type = '' ]) : deprecated_item
Parameters
$contextid : null|int|string
$type : string = ''
Tags
throws
dml_exception
Return values
deprecated_item

get_items()

public get_items(mixed $searchcriteria, mixed $page, mixed &$totalcount[, mixed $sort = '' ][, mixed $includedeleted = false ][, mixed $perpage = 0 ]) : array<string|int, deprecated_item>
Parameters
$searchcriteria : mixed
$page : mixed
$totalcount : mixed
$sort : mixed = ''
$includedeleted : mixed = false
$perpage : mixed = 0
Tags
throws
coding_exception
throws
dml_exception
Return values
array<string|int, deprecated_item>

get_items_by_metadata()

public get_items_by_metadata(array<string|int, mixed> $searchcriteriaitem, array<string|int, mixed> $searchcriteriameta, int $page, int &$totalcount[, null|string $sort = '' ][, bool $includedeleted = false ][, int $perpage = 0 ]) : array<string|int, mixed>

Migrate to core\repository\item_search_repository

Parameters
$searchcriteriaitem : array<string|int, mixed>
$searchcriteriameta : array<string|int, mixed>
$page : int
$totalcount : int
$sort : null|string = ''
$includedeleted : bool = false
$perpage : int = 0
Tags
throws
coding_exception
throws
dml_exception
Return values
array<string|int, mixed>

get_meta()

Get metadata value by key.

public get_meta(mixed $meta_key) : mixed
Parameters
$meta_key : mixed
Tags
throws
dml_exception

get_records()

public get_records(mixed $searchcriteria, mixed $page, mixed &$totalcount[, mixed $sort = '' ][, mixed $perpage = 0 ]) : array<string|int, deprecated_model_interface>
Parameters
$searchcriteria : mixed
$page : mixed
$totalcount : mixed
$sort : mixed = ''
$perpage : mixed = 0
Tags
throws
coding_exception
throws
dml_exception
Return values
array<string|int, deprecated_model_interface>

get_table_metadata()

public get_table_metadata() : string
Return values
string

get_user_cohorts_by_course_context()

public static get_user_cohorts_by_course_context(int $userid, int $courseid) : array<string|int, mixed>
Parameters
$userid : int
$courseid : int
Return values
array<string|int, mixed>

list()

Retrieves a list of records with relevant details.

public static list() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of records, where each record contains:

  • id (int): The unique identifier of the record.
  • fullname (string): The full name associated with the record, or 'N/A' if not available.
  • createdAt (mixed): The creation timestamp of the record.
  • updateUrl (string): The URL for updating the specific record.

load()

public load([mixed $reload = false ]) : void
Parameters
$reload : mixed = false

prepare_lookerstudio_iframe()

Prepares an iframe embedding Looker Studio report with the provided parameters.

public prepare_lookerstudio_iframe(array<string|int, mixed> $params) : string
Parameters
$params : array<string|int, mixed>

An associative array of parameters to be included in the report URL. These parameters are JSON-encoded and attached as a query string.

Return values
string

the HTML string for the iframe element embedding the Looker Studio report

prepare_lookerstudio_params()

Prepares and returns the parameters for Looker Studio based on the mapping fields.

public prepare_lookerstudio_params(mixed $courseid[, mixed $att = [] ]) : array<string|int, mixed>

This method iterates through the defined mapping fields, retrieves corresponding values for each field, and generates an associative array of parameters. The values are formatted to replace the character '°' with 'º'.

Parameters
$courseid : mixed
$att : mixed = []
Return values
array<string|int, mixed>

An associative array where the keys are variable names from the mapping fields and the values are the corresponding user data retrieved and formatted. If no mapping fields are defined, an empty array is returned.

render()

Renders a Looker Studio dashboard based on the provided attributes.

public static render(array<string|int, mixed> $att) : string
Parameters
$att : array<string|int, mixed>

An associative array of attributes. Expected keys include:

  • id (int): The ID of the Looker Studio dashboard to render. Required.
Return values
string

the HTML content for the Looker Studio iframe or an error message if rendering fails

set_meta()

Set metadata key-value pair.

public set_meta(mixed $meta_key, mixed $meta_value) : void
Parameters
$meta_key : mixed
$meta_value : mixed
Tags
throws
dml_exception

set_metas()

Set multiple metadata key-value pairs.

public set_metas(array<string, mixed> $metas) : void
Parameters
$metas : array<string, mixed>

update()

Update the model with form data.

public update([array<string, mixed> $formdata = [] ]) : static
Parameters
$formdata : array<string, mixed> = []
Return values
static

url_generator()

Generate a URL based on the Symfony route name and parameters.

public static url_generator(string $route[, array<string|int, mixed> $parameters = [] ][, int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ]) : moodle_url
Parameters
$route : string
$parameters : array<string|int, mixed> = []
$referenceType : int = UrlGeneratorInterface::ABSOLUTE_PATH
Return values
moodle_url

webhook_url_generator()

Generate a webhook URL.

public static webhook_url_generator(string $route[, array<string|int, mixed> $parameters = [] ][, int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ]) : moodle_url
Parameters
$route : string
$parameters : array<string|int, mixed> = []
$referenceType : int = UrlGeneratorInterface::ABSOLUTE_PATH
Return values
moodle_url

from_record()

protected static from_record(stdClass $r) : static
Parameters
$r : stdClass
Return values
static

get()

Get record by ID.

protected get(mixed $id) : false|mixed|stdClass
Parameters
$id : mixed
Tags
throws
dml_exception
Return values
false|mixed|stdClass

get_by_idnumber()

Get record by idnumber.

protected get_by_idnumber(mixed $idnumber) : false|mixed|stdClass
Parameters
$idnumber : mixed
Tags
throws
dml_exception
Return values
false|mixed|stdClass

        
On this page

Search results