commit 331a72f47a2be77555661109b3e25c5b3855ba1a Author: eduardo Date: Tue Aug 28 11:00:59 2018 -0300 Criado bloco de eventos de cursos diff --git a/block_courses_verification.php b/block_courses_verification.php new file mode 100755 index 0000000..b23dab4 --- /dev/null +++ b/block_courses_verification.php @@ -0,0 +1,21 @@ +title = get_string('courses_verification', 'block_courses_verification'); + } + public function get_content() { + if ($this->content !== null) { + return $this->content; + } + + $this->content = new stdClass; + $this->content->text = 'The content of our block!'; + //$url = new moodle_url('/blocks/article/new.php'); + //$url_index = new moodle_url('/blocks/article/index.php'); + + return $this->content; + } +} \ No newline at end of file diff --git a/classes/httpful.phar b/classes/httpful.phar new file mode 100644 index 0000000..87fb392 Binary files /dev/null and b/classes/httpful.phar differ diff --git a/classes/observer.php b/classes/observer.php new file mode 100644 index 0000000..22323f1 --- /dev/null +++ b/classes/observer.php @@ -0,0 +1,23 @@ +get_record($event->objecttable,array('id'=>$event->objectid)); + $uri = 'http://localhost:3000/api/v1/courses/add_course/'; + $response = \Httpful\Request::post($uri) + ->sendsJson() + ->body('{"course":{"name":"' . $dados->fullname . '"}}') // 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); + } +} \ No newline at end of file diff --git a/db/access.php b/db/access.php new file mode 100755 index 0000000..18d38e5 --- /dev/null +++ b/db/access.php @@ -0,0 +1,26 @@ + array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + + 'block/courses_verification:addinstance' => array( + 'riskbitmask' => RISK_SPAM | RISK_XSS, + + 'captype' => 'write', + 'contextlevel' => CONTEXT_BLOCK, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/site:manageblocks' + ), +); \ No newline at end of file diff --git a/db/events.php b/db/events.php new file mode 100644 index 0000000..1390e23 --- /dev/null +++ b/db/events.php @@ -0,0 +1,11 @@ + '\core\event\course_created', + 'callback' => 'block_courses_verification_observer::created' + ), + array( + 'eventname' => '\core\event\course_updated', + 'callback' => 'block_courses_verification_observer::updated', + ) +); \ No newline at end of file diff --git a/lang/en/block_courses_verification.php b/lang/en/block_courses_verification.php new file mode 100755 index 0000000..38dab6c --- /dev/null +++ b/lang/en/block_courses_verification.php @@ -0,0 +1,3 @@ +version = 2018061801; +$plugin->requires = 2017110800; +$plugin->component = 'block_courses_verification'; \ No newline at end of file