Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70390

Enable usage of external log storage drivers in "report/outline" module

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.5.15, 3.7.9, 3.8.6, 3.9.3, 3.10, 4.0.8, 4.1.3, 4.2
    • Reports
    • MOODLE_310_STABLE, MOODLE_35_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-70390-main-latest
    • Hide

      Prerequisites

      1. Postgres server or MySQL/MariaDB
      2. User details for it

      Setup

      You only need to do one of POstgres or MySQL

      Postgres

      1. Create a new DB
        createdb -O [username] -Eutf8 mylogs
      2. Create a new table in it (postgres):

        psql mylogs
        CREATE TABLE newlogs (
            id SERIAL,
            eventname character varying(255) DEFAULT ''::character varying NOT NULL,
            component character varying(100) DEFAULT ''::character varying NOT NULL,
            action character varying(100) DEFAULT ''::character varying NOT NULL,
            target character varying(100) DEFAULT ''::character varying NOT NULL,
            objecttable character varying(50),
            objectid bigint,
            crud character varying(1) DEFAULT ''::character varying NOT NULL,
            edulevel smallint NOT NULL,
            contextid bigint NOT NULL,
            contextlevel bigint NOT NULL,
            contextinstanceid bigint NOT NULL,
            userid bigint NOT NULL,
            courseid bigint,
            relateduserid bigint,
            anonymous smallint DEFAULT 0 NOT NULL,
            other text,
            timecreated bigint NOT NULL,
            origin character varying(10),
            ip character varying(45),
            realuserid bigint
        );
        

      MySQL/MariaDB

      1. Create a new mysql database:
        CREATE DATABASE mylogs DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
        GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON mylogs.* TO [username]@'localhost';
        FLUSH PRIVILEGES;
      2. Create a new table in it:

        CREATE TABLE `newlogs` (
          `id` bigint(10) NOT NULL AUTO_INCREMENT,
          `eventname` varchar(255) NOT NULL DEFAULT '',
          `component` varchar(100) NOT NULL DEFAULT '',
          `action` varchar(100) NOT NULL DEFAULT '',
          `target` varchar(100) NOT NULL DEFAULT '',
          `objecttable` varchar(50) DEFAULT NULL,
          `objectid` bigint(10) DEFAULT NULL,
          `crud` varchar(1) NOT NULL DEFAULT '',
          `edulevel` tinyint(1) NOT NULL,
          `contextid` bigint(10) NOT NULL,
          `contextlevel` bigint(10) NOT NULL,
          `contextinstanceid` bigint(10) NOT NULL,
          `userid` bigint(10) NOT NULL,
          `courseid` bigint(10) DEFAULT NULL,
          `relateduserid` bigint(10) DEFAULT NULL,
          `anonymous` tinyint(1) NOT NULL DEFAULT 0,
          `other` longtext DEFAULT NULL,
          `timecreated` bigint(10) NOT NULL,
          `origin` varchar(10) DEFAULT NULL,
          `ip` varchar(45) DEFAULT NULL,
          `realuserid` bigint(10) DEFAULT NULL,
          PRIMARY KEY (`id`),
          KEY `mdl_logsstanlog_tim_ix` (`timecreated`),
          KEY `mdl_logsstanlog_couanotim_ix` (`courseid`,`anonymous`,`timecreated`),
          KEY `mdl_logsstanlog_useconconcr_ix` (`userid`,`contextlevel`,`contextinstanceid`,`crud`,`edulevel`,`timecreated`),
          KEY `mdl_logsstanlog_con_ix` (`contextid`)
        ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT='Standard log table external db server'; 

      Tests

      1. Navigate to site admin -> plugins -> loggins -> manage log stores
      2. Open settings for the "External database" log store
      3. Fill with:
        1. Driver: Postgresql or MySQL/MariaDB
        2. Host: Your db host
        3. User: Your DB user
        4. Database name: mylogs
        5. Database table: newlogs
      4. Save changes
      5. Enable the store by clicking on the eye on the overview page
      6. Disable the standard log store by clicking on the eye on the overview page
      7. Log in as a student
      8. Browse to a course and perform some actions - look at the course, activities, etc.
      9. Log out
      10. As a teacher navigate to Reports -> Logs
      11. Choose the user you have performed the actions as
      12. "Get these logs"
        1. Confirm that the logs are shown
      Show
      Prerequisites Postgres server or MySQL/MariaDB User details for it Setup You only need to do one of POstgres or MySQL Postgres Create a new DB createdb -O [username] -Eutf8 mylogs Create a new table in it (postgres): psql mylogs CREATE TABLE newlogs ( id SERIAL, eventname character varying(255) DEFAULT ''::character varying NOT NULL, component character varying(100) DEFAULT ''::character varying NOT NULL, action character varying(100) DEFAULT ''::character varying NOT NULL, target character varying(100) DEFAULT ''::character varying NOT NULL, objecttable character varying(50), objectid bigint, crud character varying(1) DEFAULT ''::character varying NOT NULL, edulevel smallint NOT NULL, contextid bigint NOT NULL, contextlevel bigint NOT NULL, contextinstanceid bigint NOT NULL, userid bigint NOT NULL, courseid bigint, relateduserid bigint, anonymous smallint DEFAULT 0 NOT NULL, other text, timecreated bigint NOT NULL, origin character varying(10), ip character varying(45), realuserid bigint ); MySQL/MariaDB Create a new mysql database: CREATE DATABASE mylogs DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON mylogs.* TO [username] @'localhost'; FLUSH PRIVILEGES; Create a new table in it: CREATE TABLE `newlogs` (   `id` bigint( 10 ) NOT NULL AUTO_INCREMENT,   `eventname` varchar( 255 ) NOT NULL DEFAULT '' ,   `component` varchar( 100 ) NOT NULL DEFAULT '' ,   `action` varchar( 100 ) NOT NULL DEFAULT '' ,   `target` varchar( 100 ) NOT NULL DEFAULT '' ,   `objecttable` varchar( 50 ) DEFAULT NULL,   `objectid` bigint( 10 ) DEFAULT NULL,   `crud` varchar( 1 ) NOT NULL DEFAULT '' ,   `edulevel` tinyint( 1 ) NOT NULL,   `contextid` bigint( 10 ) NOT NULL,   `contextlevel` bigint( 10 ) NOT NULL,   `contextinstanceid` bigint( 10 ) NOT NULL,   `userid` bigint( 10 ) NOT NULL,   `courseid` bigint( 10 ) DEFAULT NULL,   `relateduserid` bigint( 10 ) DEFAULT NULL,   `anonymous` tinyint( 1 ) NOT NULL DEFAULT 0 ,   `other` longtext DEFAULT NULL,   `timecreated` bigint( 10 ) NOT NULL,   `origin` varchar( 10 ) DEFAULT NULL,   `ip` varchar( 45 ) DEFAULT NULL,   `realuserid` bigint( 10 ) DEFAULT NULL,   PRIMARY KEY (`id`),   KEY `mdl_logsstanlog_tim_ix` (`timecreated`),   KEY `mdl_logsstanlog_couanotim_ix` (`courseid`,`anonymous`,`timecreated`),   KEY `mdl_logsstanlog_useconconcr_ix` (`userid`,`contextlevel`,`contextinstanceid`,`crud`,`edulevel`,`timecreated`),   KEY `mdl_logsstanlog_con_ix` (`contextid`) ) ENGINE=InnoDB AUTO_INCREMENT= 1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPACT COMMENT= 'Standard log table external db server' ; Tests Navigate to site admin -> plugins -> loggins -> manage log stores Open settings for the "External database" log store Fill with: Driver: Postgresql or MySQL/MariaDB Host: Your db host User: Your DB user Database name: mylogs Database table: newlogs Save changes Enable the store by clicking on the eye on the overview page Disable the standard log store by clicking on the eye on the overview page Log in as a student Browse to a course and perform some actions - look at the course, activities, etc. Log out As a teacher navigate to Reports -> Logs Choose the user you have performed the actions as "Get these logs" Confirm that the logs are shown

      The "report/outline" module currently checks whether legacy or internal log are enabled and refuses to proceed otherwise. Whether there is some technical reason to do so or not, it would be swell if external log support can be included.

      Relevant section of report/outline/index.php:

      // If no legacy and no internal log then don't proceed.
              if (!$uselegacyreader && !$useinternalreader) {
                  echo $OUTPUT->box_start('generalbox', 'notice');
                  echo $OUTPUT->notification(get_string('nologreaderenabled', 'report_outline'));
                  echo $OUTPUT->box_end();
                  echo $OUTPUT->footer();
                  die();
              }

       

      Following sections handle legacy and internal drivers differently as well. As far as I know, external logging is supposed to use the same table structure as internal logging, so this might be an entry point to tackling this.

       

      To reproduce:
      In Website-Administration -> Plugins -> Logging, disable all logstores but external, then go to Course Settings -> Reports -> Activity report.

      Request should fail with error message "No log reader enabled".

            melanie.treitinger@ruhr-uni-bochum.de Melanie Treitinger
            tsbartel Thorsten Bartel
            Andrew Lyons Andrew Lyons
            Shamim Rezaie Shamim Rezaie
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 2 hours, 20 minutes
                1d 2h 20m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.