Browse Source

Alterado observer

master
eduardo 6 years ago
parent
commit
cb809af412
  1. 0
      block_courses_verification.php
  2. 21
      classes/observer.php
  3. 0
      db/access.php
  4. 0
      lang/en/block_courses_verification.php
  5. 0
      version.php

0
block_courses_verification.php

21
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();
}
}

0
db/access.php

0
lang/en/block_courses_verification.php

0
version.php

Loading…
Cancel
Save