From cb809af4128b15ebb5bc5c7b2af89fadd9b6234f Mon Sep 17 00:00:00 2001 From: eduardo Date: Thu, 13 Sep 2018 12:59:49 -0300 Subject: [PATCH] Alterado observer --- block_courses_verification.php | 0 classes/observer.php | 21 +++++++++++++++------ db/access.php | 0 lang/en/block_courses_verification.php | 0 version.php | 0 5 files changed, 15 insertions(+), 6 deletions(-) mode change 100755 => 100644 block_courses_verification.php mode change 100755 => 100644 db/access.php mode change 100755 => 100644 lang/en/block_courses_verification.php mode change 100755 => 100644 version.php diff --git a/block_courses_verification.php b/block_courses_verification.php old mode 100755 new mode 100644 diff --git a/classes/observer.php b/classes/observer.php index 22323f1..0aed90d 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -6,18 +6,27 @@ class block_courses_verification_observer { public static function created(\core\event\base $event) { global $DB, $CFG; $dados = $DB->get_record($event->objecttable,array('id'=>$event->objectid)); - $uri = 'http://localhost:3000/api/v1/courses/add_course/'; + $uri = 'http://localhost:3000/api/v1/courses/adicionar/'; $response = \Httpful\Request::post($uri) ->sendsJson() - ->body('{"course":{"name":"' . $dados->fullname . '"}}') // o json é {"curso":{"nome":"nome_curso"}} + ->body('{"course":{"name":"' . $dados->fullname . '","course_category_id":"' . "1" . '","ead_id":"' . $dados->id . '","school_id":"' . "1" . '","url":"' . "/course/view.php" . '","description":"' . $dados->summary . '"}}') // o json é {"curso":{"nome":"nome_curso"}} ->send(); } public static function updated(\core\event\base $event) { global $DB, $CFG; - $dados = new stdClass(); - $dados->article_title='TesteCurso'; - $dados->article_text='TesteCurso'; - $DB->insert_record('block_article', $dados); + $dados = $DB->get_record($event->objecttable,array('id'=>$event->objectid)); + $uri = 'http://localhost:3000/api/v1/courses/atualizar/'; + $response = \Httpful\Request::patch($uri) + ->sendsJson() + ->body('{"course":{ + "name":"' . $dados->fullname . '", + "course_category_id":"' . "1" . '", + "ead_id":"' . $dados->id . '", + "school_id":"' . "1" . '", + "description:"' . $dados->summary . '" + } + }') // o json é {"curso":{"nome":"nome_curso"}} + ->send(); } } \ No newline at end of file diff --git a/db/access.php b/db/access.php old mode 100755 new mode 100644 diff --git a/lang/en/block_courses_verification.php b/lang/en/block_courses_verification.php old mode 100755 new mode 100644 diff --git a/version.php b/version.php old mode 100755 new mode 100644