From c31b957bdd6c0bd1b9f74a72851c87d4cf6c760a Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Wed, 17 Sep 2014 09:25:04 +0200 Subject: [PATCH 1/7] add new line --- plugins/moodle/modules/moodle_mod_forum.php | 2 +- plugins/moodle/moodle_modules_total.php | 2 +- plugins/moodle/moodle_users_online.php | 2 +- plugins/moodle/moodle_users_total.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/moodle/modules/moodle_mod_forum.php b/plugins/moodle/modules/moodle_mod_forum.php index bbca5516..02a31800 100644 --- a/plugins/moodle/modules/moodle_mod_forum.php +++ b/plugins/moodle/modules/moodle_mod_forum.php @@ -69,4 +69,4 @@ $nb = 0; if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_discussions WHERE timemodified > $graph_period")) != false) { $nb = $stmt->fetchColumn(); } -echo "forum_discussions.value $nb\n"; \ No newline at end of file +echo "forum_discussions.value $nb\n"; diff --git a/plugins/moodle/moodle_modules_total.php b/plugins/moodle/moodle_modules_total.php index 1407097b..a3e7be1d 100644 --- a/plugins/moodle/moodle_modules_total.php +++ b/plugins/moodle/moodle_modules_total.php @@ -67,4 +67,4 @@ if (count($argv) === 2 && $argv[1] === 'config') { foreach($data as $entry) { echo "modules_".$entry->modulename.".label ".$entry->modulename."\n"; echo "modules_".$entry->modulename.".value ".$entry->moduleinstance."\n"; -} \ No newline at end of file +} diff --git a/plugins/moodle/moodle_users_online.php b/plugins/moodle/moodle_users_online.php index 22316762..b7de9fd3 100644 --- a/plugins/moodle/moodle_users_online.php +++ b/plugins/moodle/moodle_users_online.php @@ -61,4 +61,4 @@ $nbusers = 0; if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}user WHERE lastaccess > $graph_period")) != false) { $nbusers = $stmt->fetchColumn(); } -echo "users_online.value $nbusers\n"; \ No newline at end of file +echo "users_online.value $nbusers\n"; diff --git a/plugins/moodle/moodle_users_total.php b/plugins/moodle/moodle_users_total.php index eda1d12b..aa0231d5 100644 --- a/plugins/moodle/moodle_users_total.php +++ b/plugins/moodle/moodle_users_total.php @@ -81,4 +81,4 @@ $nbusers = 0; if (($stmt = $dbh->query("SELECT COUNT(id) FROM {$table_prefix}user WHERE deleted=1")) != false) { $nbusers = $stmt->fetchColumn(); echo "users_deleted.value $nbusers\n"; -} \ No newline at end of file +} From 22bbbd5c23a5ca62bcd8125f6a3b2304a18658de Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Thu, 18 Sep 2014 13:29:27 +0200 Subject: [PATCH 2/7] change forum_discussion to forum_discussions in graph config --- plugins/moodle/modules/moodle_mod_forum.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/moodle/modules/moodle_mod_forum.php b/plugins/moodle/modules/moodle_mod_forum.php index 02a31800..e22db53b 100644 --- a/plugins/moodle/modules/moodle_mod_forum.php +++ b/plugins/moodle/modules/moodle_mod_forum.php @@ -45,9 +45,9 @@ if (count($argv) === 2 && $argv[1] === 'config') { echo "forum_posts.label posts\n"; echo "forum_posts.min 0\n"; echo "forum_posts.draw AREA\n"; - echo "forum_discussion.draw STACK\n"; - echo "forum_discussion.min 0\n"; - echo "forum_discussion.label discussions\n"; + echo "forum_discussions.draw STACK\n"; + echo "forum_discussions.min 0\n"; + echo "forum_discussions.label discussions\n"; exit(0); } From d39f06473fe6857bf447f1129533aa00251d35a9 Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Thu, 18 Sep 2014 13:48:38 +0200 Subject: [PATCH 3/7] fix column naming error in query to count new posts --- plugins/moodle/modules/moodle_mod_forum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/moodle/modules/moodle_mod_forum.php b/plugins/moodle/modules/moodle_mod_forum.php index e22db53b..c14c14de 100644 --- a/plugins/moodle/modules/moodle_mod_forum.php +++ b/plugins/moodle/modules/moodle_mod_forum.php @@ -60,7 +60,7 @@ try { } $nb = 0; -if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_posts WHERE timemodified > $graph_period")) != false) { +if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_posts WHERE modified > $graph_period")) != false) { $nb = $stmt->fetchColumn(); } echo "forum_posts.value $nb\n"; From 85d1b93c239b7c2cfd7ce3556032ec295238be4d Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Thu, 18 Sep 2014 13:49:22 +0200 Subject: [PATCH 4/7] add plugin for module quiz --- plugins/moodle/modules/moodle_mod_quiz.php | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 plugins/moodle/modules/moodle_mod_quiz.php diff --git a/plugins/moodle/modules/moodle_mod_quiz.php b/plugins/moodle/modules/moodle_mod_quiz.php new file mode 100644 index 00000000..3a6f9705 --- /dev/null +++ b/plugins/moodle/modules/moodle_mod_quiz.php @@ -0,0 +1,63 @@ +#!/usr/bin/php + + * @version 1.0 2014 + * + */ +$dbh = null; +$db = getenv('db'); +$type = getenv('type'); +$host = getenv('host'); +$user = getenv('user'); +$pass = getenv('pass'); +$table_prefix = getenv('table_prefix'); +$port = getenv('port'); +if (!$port) + $port = 3306; +//$graph_period = getenv('graph_period'); +$graph_period = time() - 5*60; + + +if (count($argv) === 2 && $argv[1] === 'config') { + echo "graph_title Moodle Quiz Attempts\n"; + echo "graph_args --base 1000 --lower-limit 0\n"; + echo "graph_vlabel attempts\n"; + echo "graph_category Moodle\n"; + echo "graph_scale no\n"; + echo "graph_info Displays the sum quiz attempts in your Moodle site\n"; + echo "quiz_attempts.label attempts\n"; + echo "quiz_attempts.min 0\n"; + echo "quiz_attempts.draw AREA\n"; + exit(0); +} + +try { + $dsn = $type . ':host=' . $host . ';port=' . $port . ';dbname=' . $db; + $dbh = new PDO($dsn, $user, $pass); +} catch (Exception $e) { + echo "Connection failed\n"; + exit(1); +} + +$nb = 0; +if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}quiz_attempts where timemodified > $graph_period")) != false) { + $nb = $stmt->fetchColumn(); +} +echo "quiz_attempts.value $nb\n"; From b9f9e90ab0ff9a33d7862020c0732d15f3b39a3f Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Mon, 22 Sep 2014 23:44:51 +0200 Subject: [PATCH 5/7] add graph for new log entries --- plugins/moodle/moodle_logs.php | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 plugins/moodle/moodle_logs.php diff --git a/plugins/moodle/moodle_logs.php b/plugins/moodle/moodle_logs.php new file mode 100644 index 00000000..28bef09a --- /dev/null +++ b/plugins/moodle/moodle_logs.php @@ -0,0 +1,62 @@ +#!/usr/bin/php + + * @version 1.0 2014 + * + */ +$dbh = null; +$db = getenv('db'); +$type = getenv('type'); +$host = getenv('host'); +$user = getenv('user'); +$pass = getenv('pass'); +$table_prefix = getenv('table_prefix'); +$port = getenv('port'); +if (!$port) + $port = 3306; +//$graph_period = getenv('graph_period'); +$graph_period = time() - 5*60; + +if (count($argv) === 2 && $argv[1] === 'config') { + echo "graph_title Moodle Logs\n"; + echo "graph_args --base 1000 --lower-limit 0\n"; + echo "graph_vlabel logs\n"; + echo "graph_category Moodle\n"; + echo "graph_scale no\n"; + echo "graph_info Displays the number of new logs written\n"; + echo "logs.label logs\n"; + echo "logs.min 0\n"; + exit(0); +} + +try { + $dsn = $type . ':host=' . $host . ';port=' . $port . ';dbname=' . $db; + $dbh = new PDO($dsn, $user, $pass); +} catch (Exception $e) { + echo "Connection failed\n"; + exit(1); +} + +//Online users +$nb = 0; +if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}log WHERE time > $graph_period")) != false) { + $nbusers = $stmt->fetchColumn(); +} +echo "logs.value $nb\n"; From 79e9b2b9dac48d4cb17b1acd6d510b6de1306d38 Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Mon, 22 Sep 2014 23:56:30 +0200 Subject: [PATCH 6/7] change drawing type to AREA --- plugins/moodle/moodle_logs.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/moodle/moodle_logs.php b/plugins/moodle/moodle_logs.php index 28bef09a..4c979717 100644 --- a/plugins/moodle/moodle_logs.php +++ b/plugins/moodle/moodle_logs.php @@ -43,6 +43,7 @@ if (count($argv) === 2 && $argv[1] === 'config') { echo "graph_info Displays the number of new logs written\n"; echo "logs.label logs\n"; echo "logs.min 0\n"; + echo "logs.draw AREA"; exit(0); } From 4a8a998519a52354a8b5c2616bc90616d8581a59 Mon Sep 17 00:00:00 2001 From: ak4t0sh Date: Tue, 23 Sep 2014 00:04:06 +0200 Subject: [PATCH 7/7] remove forum_discussions --- plugins/moodle/modules/moodle_mod_forum.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugins/moodle/modules/moodle_mod_forum.php b/plugins/moodle/modules/moodle_mod_forum.php index c14c14de..884e2789 100644 --- a/plugins/moodle/modules/moodle_mod_forum.php +++ b/plugins/moodle/modules/moodle_mod_forum.php @@ -45,9 +45,6 @@ if (count($argv) === 2 && $argv[1] === 'config') { echo "forum_posts.label posts\n"; echo "forum_posts.min 0\n"; echo "forum_posts.draw AREA\n"; - echo "forum_discussions.draw STACK\n"; - echo "forum_discussions.min 0\n"; - echo "forum_discussions.label discussions\n"; exit(0); } @@ -64,9 +61,3 @@ if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_posts WHERE $nb = $stmt->fetchColumn(); } echo "forum_posts.value $nb\n"; - -$nb = 0; -if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_discussions WHERE timemodified > $graph_period")) != false) { - $nb = $stmt->fetchColumn(); -} -echo "forum_discussions.value $nb\n";