Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

report/analytics/api: Difference between revisions

From MoodleDocs
(Bare bones entry)
 
(→‎The indicator class: Add file list for indicators)
Line 5: Line 5:
'''IMPORTANT''' This page is a WIP and does not reflect the final state of the engagement analytics API!
'''IMPORTANT''' This page is a WIP and does not reflect the final state of the engagement analytics API!


== The indicator class ==
==Indicator==
 
===File Layout===
Indicators live in a folder in <tt>mod/analytics/indicator</tt>. The layout inside this folder follows the typical layout for a Moodle plugin. For example, inside the <tt>mod/analytics/indicator/myind</tt> folder we would have:
 
; indicator.class.php : Defines the <tt>indicator_myind</tt> class, which should extend the <tt>indicator</tt> base class.
; renderer.php : This contains the definition of the <tt>analyticsindicator_myind_renderer</tt> class, which should extend the <tt>analyticsindicator_renderer</tt> base class.
; thresholds_form.php : Defines the <tt>analyticsindicator_myind_thresholds_form</tt> which contains a function <tt>definition_inner</tt> for including on the report settings page.
; lang/en/analyticsindicator_myind.php : English language strings for this indicator. You can, of course, include other languages too. The language file must define at least the string giving the indicator a name, for example <tt>$string['pluginname'] = 'My Indicator';</tt>
; db/install.xml, db/upgrade.php : For creating any database tables required, [[Installing_and_upgrading_plugin_database_tables|as normal]]. See [[#Database_tables]] below.
; db/access.php : Defines any capabilities required by this question type. This is very rarely needed.


===Functions===
===Functions===

Revision as of 01:05, 13 August 2012

Moodle 2.2 This page describes the API used by the Engagement Analytics indicators and reporting mechanisms.

Main info

IMPORTANT This page is a WIP and does not reflect the final state of the engagement analytics API!

Indicator

File Layout

Indicators live in a folder in mod/analytics/indicator. The layout inside this folder follows the typical layout for a Moodle plugin. For example, inside the mod/analytics/indicator/myind folder we would have:

indicator.class.php
Defines the indicator_myind class, which should extend the indicator base class.
renderer.php
This contains the definition of the analyticsindicator_myind_renderer class, which should extend the analyticsindicator_renderer base class.
thresholds_form.php
Defines the analyticsindicator_myind_thresholds_form which contains a function definition_inner for including on the report settings page.
lang/en/analyticsindicator_myind.php
English language strings for this indicator. You can, of course, include other languages too. The language file must define at least the string giving the indicator a name, for example $string['pluginname'] = 'My Indicator';
db/install.xml, db/upgrade.php
For creating any database tables required, as normal. See #Database_tables below.
db/access.php
Defines any capabilities required by this question type. This is very rarely needed.

Functions

Examples

indicator_random

Return a random risk score for each user.

defined('MOODLE_INTERNAL') || die(); require_once(dirname(__FILE__).'/../indicator.class.php');

class indicator_random extends indicator {

   protected function get_risk_for_users($userids, $courseid, $startdate, $enddate) {
       // TODO: Fill this in.
   }
   public function get_defaults() {
       // TODO: Fill this in.
   }
   // TODO: Complete class definition.

}

Helper Functions

See also