|
@ -6,18 +6,27 @@ class block_courses_verification_observer { |
|
|
public static function created(\core\event\base $event) { |
|
|
public static function created(\core\event\base $event) { |
|
|
global $DB, $CFG; |
|
|
global $DB, $CFG; |
|
|
$dados = $DB->get_record($event->objecttable,array('id'=>$event->objectid)); |
|
|
$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) |
|
|
$response = \Httpful\Request::post($uri) |
|
|
->sendsJson() |
|
|
->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(); |
|
|
->send(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
public static function updated(\core\event\base $event) { |
|
|
public static function updated(\core\event\base $event) { |
|
|
global $DB, $CFG; |
|
|
global $DB, $CFG; |
|
|
$dados = new stdClass(); |
|
|
$dados = $DB->get_record($event->objecttable,array('id'=>$event->objectid)); |
|
|
$dados->article_title='TesteCurso'; |
|
|
$uri = 'http://localhost:3000/api/v1/courses/atualizar/'; |
|
|
$dados->article_text='TesteCurso'; |
|
|
$response = \Httpful\Request::patch($uri) |
|
|
$DB->insert_record('block_article', $dados); |
|
|
->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(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |