From bba55eda747421640e1889ed49defe67fb8146a9 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 13:17:16 +0100 Subject: [PATCH 01/31] wip --- classes/grades/synchronization/context/context_provider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/context/context_provider.php b/classes/grades/synchronization/context/context_provider.php index 46f4a5d..1025e90 100644 --- a/classes/grades/synchronization/context/context_provider.php +++ b/classes/grades/synchronization/context/context_provider.php @@ -57,7 +57,7 @@ public static function get_context(array $mumietasks, array $users): context { * @return bool */ public static function requires_context(stdClass $mumie): bool { - return str_starts_with($mumie->taskurl, "worksheet_") + substr( $mumie->taskurl, 0, 10 ) === "worksheet_" && $mumie->duedate > 0; } From 910e3b4134059bdfa7ed164730b5eb472eb2d7db Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 13:19:53 +0100 Subject: [PATCH 02/31] wip --- classes/grades/synchronization/context/context_provider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/context/context_provider.php b/classes/grades/synchronization/context/context_provider.php index 1025e90..442f5e2 100644 --- a/classes/grades/synchronization/context/context_provider.php +++ b/classes/grades/synchronization/context/context_provider.php @@ -57,7 +57,7 @@ public static function get_context(array $mumietasks, array $users): context { * @return bool */ public static function requires_context(stdClass $mumie): bool { - substr( $mumie->taskurl, 0, 10 ) === "worksheet_" + return substr( $mumie->taskurl, 0, 10 ) === "worksheet_" && $mumie->duedate > 0; } From ea859f79481ce4a619fe663f4700c95ba77d8929 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 13:56:36 +0100 Subject: [PATCH 03/31] wip --- gradesync.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradesync.php b/gradesync.php index ad03897..d437799 100644 --- a/gradesync.php +++ b/gradesync.php @@ -262,10 +262,12 @@ function ($user) { $mumieusers ); $payload = new payload($syncids, $mumie->mumie_coursefile, $mumieids, $mumie->lastsync, true); + $test = context_provider::requires_context($mumie); if (context_provider::requires_context($mumie)) { $context = context_provider::get_context(array($mumie), $mumieusers); $payload->with_context($context); } + print_object($test); $request = new xapi_request($mumieserver, $payload); return $request->send(); } From 8278fa552cdefbf250db4c7e7aa44a8071ff8054 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 14:07:01 +0100 Subject: [PATCH 04/31] wip --- gradesync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradesync.php b/gradesync.php index d437799..ffb6d73 100644 --- a/gradesync.php +++ b/gradesync.php @@ -267,7 +267,7 @@ function ($user) { $context = context_provider::get_context(array($mumie), $mumieusers); $payload->with_context($context); } - print_object($test); + error_log("TEST: " . print_r($test, true)); $request = new xapi_request($mumieserver, $payload); return $request->send(); } From a68872b67820ca4d414057276b11353cbaa55d4a Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 14:38:37 +0100 Subject: [PATCH 05/31] wip --- classes/grades/synchronization/context/context_provider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/context/context_provider.php b/classes/grades/synchronization/context/context_provider.php index 442f5e2..490314e 100644 --- a/classes/grades/synchronization/context/context_provider.php +++ b/classes/grades/synchronization/context/context_provider.php @@ -57,7 +57,7 @@ public static function get_context(array $mumietasks, array $users): context { * @return bool */ public static function requires_context(stdClass $mumie): bool { - return substr( $mumie->taskurl, 0, 10 ) === "worksheet_" + return (substr( $mumie->taskurl, 0, 10 ) === "worksheet_") && $mumie->duedate > 0; } From 5041b644513b47c936fb7392b904ad83ec58ae1e Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:20:28 +0100 Subject: [PATCH 06/31] wip --- classes/grades/synchronization/xapi_request.php | 1 + gradesync.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 5e0de24..7dfdb33 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,6 +53,7 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); + error_log("TEST2".$ch); curl_close($ch); if ($this->has_error($result)) { return array(); diff --git a/gradesync.php b/gradesync.php index ffb6d73..3802289 100644 --- a/gradesync.php +++ b/gradesync.php @@ -267,7 +267,7 @@ function ($user) { $context = context_provider::get_context(array($mumie), $mumieusers); $payload->with_context($context); } - error_log("TEST: " . print_r($test, true)); + error_log("TEST: " . $test); $request = new xapi_request($mumieserver, $payload); return $request->send(); } From 9a6508b5dabdb4b80cbeeeaf8f8131f5c9392dfc Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:28:58 +0100 Subject: [PATCH 07/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- gradesync.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 7dfdb33..f30f81b 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,7 +53,7 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); - error_log("TEST2".$ch); + error_log("TEST2".printr($ch)); curl_close($ch); if ($this->has_error($result)) { return array(); diff --git a/gradesync.php b/gradesync.php index 3802289..8bfe3f2 100644 --- a/gradesync.php +++ b/gradesync.php @@ -267,7 +267,7 @@ function ($user) { $context = context_provider::get_context(array($mumie), $mumieusers); $payload->with_context($context); } - error_log("TEST: " . $test); + error_log("TEST: " . print_r($test)); $request = new xapi_request($mumieserver, $payload); return $request->send(); } From 3825c84abeb12dabc2cced8a69f1d8ae9c513127 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:31:20 +0100 Subject: [PATCH 08/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index f30f81b..6189bdb 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,7 +53,7 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); - error_log("TEST2".printr($ch)); + error_log("TEST2".print_r($ch)); curl_close($ch); if ($this->has_error($result)) { return array(); From d3aa3f93eded67501b6190db36890a94a93c83d2 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:33:53 +0100 Subject: [PATCH 09/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 6189bdb..fad3654 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,7 +53,7 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); - error_log("TEST2".print_r($ch)); + error_log("TEST2".print_r(json_decode(curl_exec($ch)))); curl_close($ch); if ($this->has_error($result)) { return array(); From aaba5acbaefd5ba61f190d1bbcf55c29785ac78c Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:36:20 +0100 Subject: [PATCH 10/31] wip --- classes/grades/synchronization/xapi_request.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index fad3654..08fe611 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,7 +53,8 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); - error_log("TEST2".print_r(json_decode(curl_exec($ch)))); + error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + error_log(json_decode(curl_exec($ch))); curl_close($ch); if ($this->has_error($result)) { return array(); From 1020d498af365aeebbfa69e712c672d0996d70dc Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:44:40 +0100 Subject: [PATCH 11/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 08fe611..53c019c 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -54,7 +54,7 @@ public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - error_log(json_decode(curl_exec($ch))); + error_log(curl_exec($ch)); curl_close($ch); if ($this->has_error($result)) { return array(); From 427b4ed383dda3f9895806262efd98a9e7f3ff2b Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 15:47:44 +0100 Subject: [PATCH 12/31] w --- classes/grades/synchronization/xapi_request.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 53c019c..5165a54 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -81,6 +81,8 @@ public function create_post_curl_request() { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->payload)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + error_log(json_encode($this->payload)); curl_setopt( $ch, CURLOPT_HTTPHEADER, From 0605ab90039b725433270ea6f89a0e14685184d6 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 16:25:30 +0100 Subject: [PATCH 13/31] wip --- classes/grades/synchronization/xapi_request.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 5165a54..8c1970f 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -77,9 +77,10 @@ private function has_error(array $response): bool { * @return mixed curl handle for json payload */ public function create_post_curl_request() { + $escaped= stripslashes(json_encode($this->payload)); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->payload)); + curl_setopt($ch, CURLOPT_POSTFIELDS, escaped); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); error_log(json_encode($this->payload)); @@ -88,7 +89,7 @@ public function create_post_curl_request() { CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen(json_encode($this->payload)), + 'Content-Length: ' . strlen(escaped), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); From efdaf42047973828fa1cef76342efa8d0040c1e0 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 16:27:24 +0100 Subject: [PATCH 14/31] wip --- classes/grades/synchronization/xapi_request.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 8c1970f..902c053 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -80,7 +80,7 @@ public function create_post_curl_request() { $escaped= stripslashes(json_encode($this->payload)); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, escaped); + curl_setopt($ch, CURLOPT_POSTFIELDS, $escaped); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); error_log(json_encode($this->payload)); @@ -89,7 +89,7 @@ public function create_post_curl_request() { CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen(escaped), + 'Content-Length: ' . strlen($escaped), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); From 0ff7352b1e493be294a064dbcac54021681a8a68 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 16:49:50 +0100 Subject: [PATCH 15/31] wip --- classes/grades/synchronization/xapi_request.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 902c053..9c80afe 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -77,19 +77,19 @@ private function has_error(array $response): bool { * @return mixed curl handle for json payload */ public function create_post_curl_request() { - $escaped= stripslashes(json_encode($this->payload)); + $payload= json_encode($this->payload, JSON_UNESCAPED_SLASHES); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $escaped); + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - error_log(json_encode($this->payload)); + error_log(json_encode($this-payload)); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen($escaped), + 'Content-Length: ' . strlen($payload), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); From 746d4391a2ecb0f8cec398c6ce0da83757fa4e93 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 16:53:16 +0100 Subject: [PATCH 16/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 9c80afe..065065e 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -83,7 +83,7 @@ public function create_post_curl_request() { curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - error_log(json_encode($this-payload)); + error_log(json_encode($this->payload)); curl_setopt( $ch, CURLOPT_HTTPHEADER, From e8a1c236dc696f4e12b81f98ce0d2428a42c9d9c Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 16:56:29 +0100 Subject: [PATCH 17/31] wip --- classes/grades/synchronization/xapi_request.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 065065e..69055b0 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -77,19 +77,19 @@ private function has_error(array $response): bool { * @return mixed curl handle for json payload */ public function create_post_curl_request() { - $payload= json_encode($this->payload, JSON_UNESCAPED_SLASHES); + $hallo_json= json_encode($this->payload, JSON_UNESCAPED_SLASHES); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); + curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - error_log(json_encode($this->payload)); + error_log($hallo_json); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen($payload), + 'Content-Length: ' . strlen($hallo_json), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); From e196ed696ded78c5dd32b6df6e951392ebc34aad Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 17:06:48 +0100 Subject: [PATCH 18/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 69055b0..4240ade 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -89,7 +89,7 @@ public function create_post_curl_request() { CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen($hallo_json), + //'Content-Length: ' . strlen($hallo_json), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); From 12f670ee77489cf11e1ace0c46e081ce265bcf7e Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 17:11:40 +0100 Subject: [PATCH 19/31] wip --- classes/grades/synchronization/xapi_request.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 4240ade..41f6123 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -83,6 +83,7 @@ public function create_post_curl_request() { curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + error_log(get_config('auth_mumie', 'mumie_api_key')); error_log($hallo_json); curl_setopt( $ch, From 1c6b34d46e41523a062be08ade5e065811ea9042 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 17:28:35 +0100 Subject: [PATCH 20/31] wip --- classes/grades/synchronization/xapi_request.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 41f6123..f77c0c7 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -78,10 +78,11 @@ private function has_error(array $response): bool { */ public function create_post_curl_request() { $hallo_json= json_encode($this->payload, JSON_UNESCAPED_SLASHES); + error_log($this->server->get_grade_sync_url()); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); error_log(get_config('auth_mumie', 'mumie_api_key')); error_log($hallo_json); From 19a1d37883981433634467ea946e35bd376b495c Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 17:53:56 +0100 Subject: [PATCH 21/31] wip --- classes/grades/synchronization/xapi_request.php | 4 ++-- gradesync.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index f77c0c7..73630fd 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,8 +53,8 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); - error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - error_log(curl_exec($ch)); + error_log("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); + error_log($ch); curl_close($ch); if ($this->has_error($result)) { return array(); diff --git a/gradesync.php b/gradesync.php index 8bfe3f2..8d4141f 100644 --- a/gradesync.php +++ b/gradesync.php @@ -189,6 +189,7 @@ public static function get_all_grades_for_user(stdClass $mumie, int $userid) : ? */ private static function xapi_to_moodle_grade($xapigrade) : stdClass { $grade = new stdClass(); + error_log($xapigrade); $grade->userid = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name)->get_moodle_id(); $grade->rawgrade = 100 * $xapigrade->result->score->raw; $grade->timecreated = strtotime($xapigrade->timestamp); From 2bacb2e1164a1bb9002edf2b1486ef969c901cb0 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 18:41:40 +0100 Subject: [PATCH 22/31] wip --- classes/grades/synchronization/xapi_request.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 73630fd..560e775 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -82,6 +82,7 @@ public function create_post_curl_request() { $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); + curl_setopt($ch, CURLOPT_USERAGENT, ""); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); error_log(get_config('auth_mumie', 'mumie_api_key')); From 8172e2952dead4a499aabcf358c3dcacef8312b1 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 18:43:57 +0100 Subject: [PATCH 23/31] wip --- classes/grades/synchronization/xapi_request.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 560e775..eeb47f9 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -53,8 +53,6 @@ public function __construct(mumie_server $server, payload $payload) { public function send(): array { $ch = $this->create_post_curl_request(); $result = (array) json_decode(curl_exec($ch)); - error_log("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); - error_log($ch); curl_close($ch); if ($this->has_error($result)) { return array(); From bbab665f4610f7385f6e41ec53704bd856c79a3c Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 18:50:42 +0100 Subject: [PATCH 24/31] wip --- gradesync.php | 1 + 1 file changed, 1 insertion(+) diff --git a/gradesync.php b/gradesync.php index 8d4141f..d6d342e 100644 --- a/gradesync.php +++ b/gradesync.php @@ -203,6 +203,7 @@ private static function xapi_to_moodle_grade($xapigrade) : stdClass { * @throws \dml_exception */ private static function get_mumie_user_from_sync_id(string $syncid): ?mumie_user { + error_log($syncid); $mumieid = substr(strrchr($syncid, "_"), 1); return mumie_user_service::get_user_from_mumie_id($mumieid); } From 157d740f321bf37eec9f4d90d257b4544861a9b1 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 18:54:22 +0100 Subject: [PATCH 25/31] wip --- classes/grades/synchronization/xapi_request.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index eeb47f9..392580c 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -80,7 +80,7 @@ public function create_post_curl_request() { $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); - curl_setopt($ch, CURLOPT_USERAGENT, ""); + curl_setopt($ch, CURLOPT_USERAGENT, "My User Agent Name"); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); error_log(get_config('auth_mumie', 'mumie_api_key')); @@ -90,7 +90,7 @@ public function create_post_curl_request() { CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - //'Content-Length: ' . strlen($hallo_json), + 'Content-Length: ' . strlen($hallo_json), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); From 566b3860a109d8eea49aedacb2e9b85dd2544fc5 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 19:10:55 +0100 Subject: [PATCH 26/31] wip --- gradesync.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradesync.php b/gradesync.php index d6d342e..4a67b2e 100644 --- a/gradesync.php +++ b/gradesync.php @@ -190,7 +190,8 @@ public static function get_all_grades_for_user(stdClass $mumie, int $userid) : ? private static function xapi_to_moodle_grade($xapigrade) : stdClass { $grade = new stdClass(); error_log($xapigrade); - $grade->userid = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name)->get_moodle_id(); + $sync_id = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name); + $grade->userid = $sync_id->get_moodle_id(); $grade->rawgrade = 100 * $xapigrade->result->score->raw; $grade->timecreated = strtotime($xapigrade->timestamp); return $grade; From 822eddec3a195bb1409eed07eea1812db8437059 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 19:13:52 +0100 Subject: [PATCH 27/31] wip --- classes/grades/synchronization/xapi_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 392580c..1ed2066 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -81,7 +81,7 @@ public function create_post_curl_request() { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); curl_setopt($ch, CURLOPT_USERAGENT, "My User Agent Name"); - //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); error_log(get_config('auth_mumie', 'mumie_api_key')); error_log($hallo_json); From dbfe3805f420fc68273138f9daea4ab5c224afad Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 19:15:20 +0100 Subject: [PATCH 28/31] wip --- gradesync.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/gradesync.php b/gradesync.php index 4a67b2e..a90e7d2 100644 --- a/gradesync.php +++ b/gradesync.php @@ -189,7 +189,6 @@ public static function get_all_grades_for_user(stdClass $mumie, int $userid) : ? */ private static function xapi_to_moodle_grade($xapigrade) : stdClass { $grade = new stdClass(); - error_log($xapigrade); $sync_id = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name); $grade->userid = $sync_id->get_moodle_id(); $grade->rawgrade = 100 * $xapigrade->result->score->raw; @@ -204,7 +203,6 @@ private static function xapi_to_moodle_grade($xapigrade) : stdClass { * @throws \dml_exception */ private static function get_mumie_user_from_sync_id(string $syncid): ?mumie_user { - error_log($syncid); $mumieid = substr(strrchr($syncid, "_"), 1); return mumie_user_service::get_user_from_mumie_id($mumieid); } From 5b6b23f47394dde8ae39299dd1df6a8896dfb9da Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 19:22:15 +0100 Subject: [PATCH 29/31] wip --- classes/grades/synchronization/xapi_request.php | 10 +++------- gradesync.php | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 1ed2066..666e1fc 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -75,22 +75,18 @@ private function has_error(array $response): bool { * @return mixed curl handle for json payload */ public function create_post_curl_request() { - $hallo_json= json_encode($this->payload, JSON_UNESCAPED_SLASHES); - error_log($this->server->get_grade_sync_url()); + $post_fields= json_encode($this->payload); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $hallo_json); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_USERAGENT, "My User Agent Name"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - error_log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - error_log(get_config('auth_mumie', 'mumie_api_key')); - error_log($hallo_json); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen($hallo_json), + 'Content-Length: ' . strlen($post_fields), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); diff --git a/gradesync.php b/gradesync.php index a90e7d2..3d72926 100644 --- a/gradesync.php +++ b/gradesync.php @@ -263,12 +263,10 @@ function ($user) { $mumieusers ); $payload = new payload($syncids, $mumie->mumie_coursefile, $mumieids, $mumie->lastsync, true); - $test = context_provider::requires_context($mumie); if (context_provider::requires_context($mumie)) { $context = context_provider::get_context(array($mumie), $mumieusers); $payload->with_context($context); } - error_log("TEST: " . print_r($test)); $request = new xapi_request($mumieserver, $payload); return $request->send(); } From 0eb46ac6345584fe5440affd1b410e719f768130 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 19:55:43 +0100 Subject: [PATCH 30/31] fix styling --- classes/grades/synchronization/xapi_request.php | 6 +++--- gradesync.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/grades/synchronization/xapi_request.php b/classes/grades/synchronization/xapi_request.php index 666e1fc..f5185d4 100644 --- a/classes/grades/synchronization/xapi_request.php +++ b/classes/grades/synchronization/xapi_request.php @@ -75,10 +75,10 @@ private function has_error(array $response): bool { * @return mixed curl handle for json payload */ public function create_post_curl_request() { - $post_fields= json_encode($this->payload); + $postfields = json_encode($this->payload); $ch = curl_init($this->server->get_grade_sync_url()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); + curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_USERAGENT, "My User Agent Name"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt( @@ -86,7 +86,7 @@ public function create_post_curl_request() { CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', - 'Content-Length: ' . strlen($post_fields), + 'Content-Length: ' . strlen($postfields), "X-API-Key: " . get_config('auth_mumie', 'mumie_api_key'), ) ); diff --git a/gradesync.php b/gradesync.php index 3d72926..cc090f7 100644 --- a/gradesync.php +++ b/gradesync.php @@ -189,8 +189,8 @@ public static function get_all_grades_for_user(stdClass $mumie, int $userid) : ? */ private static function xapi_to_moodle_grade($xapigrade) : stdClass { $grade = new stdClass(); - $sync_id = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name); - $grade->userid = $sync_id->get_moodle_id(); + $syncid = self::get_mumie_user_from_sync_id($xapigrade->actor->account->name); + $grade->userid = $syncid->get_moodle_id(); $grade->rawgrade = 100 * $xapigrade->result->score->raw; $grade->timecreated = strtotime($xapigrade->timestamp); return $grade; From 279b206bbd7dd5a0ebcdce34bbb5a9ce5cbcb0e4 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 9 Nov 2023 22:23:47 +0100 Subject: [PATCH 31/31] Update changelog and version.php --- changelog.md | 5 +++++ version.php | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 9bb08eb..61c29c0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,11 @@ # MumieTask - Changelog All important changes to this plugin will be documented in this file. +## [v1.6.2] - 2023-11-09 +### Fixed +- Grade synchronisation bug fixed +- Support php:7.4 + ## [v1.6.1] - 2023-10-31 ### Added - The language is sent with the worksheet during the note synchronization request. diff --git a/version.php b/version.php index fbbbd68..dc75376 100644 --- a/version.php +++ b/version.php @@ -25,11 +25,11 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2023103100; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2023110900; // The current module version (Date: YYYYMMDDXX). $plugin->component = 'mod_mumie'; // Full name of the plugin (used for diagnostics). $plugin->requires = 2022041900; -$plugin->release = "v1.6.1"; +$plugin->release = "v1.6.2"; $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = array( - 'auth_mumie' => 2023103100, + 'auth_mumie' => 2023110900, );