diff --git a/block_courses_verification.php b/block_courses_verification.php deleted file mode 100644 index b23dab4..0000000 --- a/block_courses_verification.php +++ /dev/null @@ -1,21 +0,0 @@ -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/block_escola_modelo.php b/block_escola_modelo.php new file mode 100644 index 0000000..94b9133 --- /dev/null +++ b/block_escola_modelo.php @@ -0,0 +1,19 @@ +title = get_string('escola_modelo', 'block_escola_modelo'); + } + public function get_content() { + if ($this->content !== null) { + return $this->content; + } + + $this->content = new stdClass; + $this->content->text = ''; + + return $this->content; + } +} diff --git a/classes/observer.php b/classes/observer.php index 0aed90d..e46e4cb 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -2,8 +2,13 @@ include('httpful.phar'); -class block_courses_verification_observer { - public static function created(\core\event\base $event) { +class block_escola_modelo_observer { + + // + // EVENTOS RELACIONADOS A CURSOS + // + + public static function course_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/adicionar/'; @@ -13,20 +18,39 @@ class block_courses_verification_observer { ->send(); } - public static function updated(\core\event\base $event) { + + public static function course_updated(\core\event\base $event) { global $DB, $CFG; $dados = $DB->get_record($event->objecttable,array('id'=>$event->objectid)); - $uri = 'http://localhost:3000/api/v1/courses/atualizar/'; + + //echo "ID é " . $dados->id; + $uri = 'https://escolamodelows.interlegis.leg.br/api/v1/cursos/atualizar'; $response = \Httpful\Request::patch($uri) ->sendsJson() ->body('{"course":{ + "id":"1", "name":"' . $dados->fullname . '", - "course_category_id":"' . "1" . '", - "ead_id":"' . $dados->id . '", - "school_id":"' . "1" . '", - "description:"' . $dados->summary . '" + "course_category_id":"' . "1" . '" } }') // o json é {"curso":{"nome":"nome_curso"}} ->send(); + error_log("Retorno é " . $response->code); + + } + + public static function course_deleted(\core\event\base $event) { + + } -} \ No newline at end of file + + + // + // EVENTOS RELACIONADOS A MATRÍCULAS + // + + //public static function course_updated(\core\event\base $event) { + + + //} + +} diff --git a/db/access.php b/db/access.php index 18d38e5..d9a342e 100644 --- a/db/access.php +++ b/db/access.php @@ -1,7 +1,7 @@ array( + 'block/escola_modelo:myaddinstance' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( @@ -11,7 +11,7 @@ $capabilities = array( 'clonepermissionsfrom' => 'moodle/my:manageblocks' ), - 'block/courses_verification:addinstance' => array( + 'block/escola_modelo:addinstance' => array( 'riskbitmask' => RISK_SPAM | RISK_XSS, 'captype' => 'write', @@ -23,4 +23,4 @@ $capabilities = array( 'clonepermissionsfrom' => 'moodle/site:manageblocks' ), -); \ No newline at end of file +); diff --git a/db/events.php b/db/events.php index 1390e23..1323176 100644 --- a/db/events.php +++ b/db/events.php @@ -1,11 +1,29 @@ '\core\event\course_created', - 'callback' => 'block_courses_verification_observer::created' + 'callback' => 'block_escola_modelo_observer::course_created' ), array( 'eventname' => '\core\event\course_updated', - 'callback' => 'block_courses_verification_observer::updated', + 'callback' => 'block_escola_modelo_observer::course_updated' + ), + array( + 'eventname' => '\core\event\course_deleted', + 'callback' => 'block_escola_modelo_observer::course_deleted' + ), + // Eventos de matrícula a cursos + array( + 'eventname' => 'core\event\user_enrolment_created', + 'callback' => 'block_escola_modelo_observer::user_enrolment_created' + ), + array( + 'eventname' => 'core\event\user_enrolment_deleted', + 'callback' => 'block_escola_modelo_observer::user_enrolment_deleted' + ), + array( + 'eventname' => 'core\event\user_enrolment_updated', + 'callback' => 'block_escola_modelo_observer::user_enrolment_updated' ) -); \ No newline at end of file +); diff --git a/lang/en/block_courses_verification.php b/lang/en/block_courses_verification.php deleted file mode 100644 index 38dab6c..0000000 --- a/lang/en/block_courses_verification.php +++ /dev/null @@ -1,3 +0,0 @@ -version = 2018061801; $plugin->requires = 2017110800; -$plugin->component = 'block_courses_verification'; \ No newline at end of file +$plugin->component = 'block_escola_modelo';