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