eduardo
6 years ago
commit
331a72f47a
7 changed files with 88 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
<?php |
|||
defined('MOODLE_INTERNAL') || die(); |
|||
|
|||
class block_courses_verification extends block_base |
|||
{ |
|||
public function init() { |
|||
$this->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; |
|||
} |
|||
} |
Binary file not shown.
@ -0,0 +1,23 @@ |
|||
<?php |
|||
|
|||
include('httpful.phar'); |
|||
|
|||
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/'; |
|||
$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); |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
<?php |
|||
$capabilities = array( |
|||
|
|||
'block/courses_verification:myaddinstance' => 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' |
|||
), |
|||
); |
@ -0,0 +1,11 @@ |
|||
<?php |
|||
$observers = array( |
|||
array( |
|||
'eventname' => '\core\event\course_created', |
|||
'callback' => 'block_courses_verification_observer::created' |
|||
), |
|||
array( |
|||
'eventname' => '\core\event\course_updated', |
|||
'callback' => 'block_courses_verification_observer::updated', |
|||
) |
|||
); |
@ -0,0 +1,3 @@ |
|||
<?php |
|||
$string['pluginname'] = 'Bloco de verificação de criação de cursos'; |
|||
$string['courses_verification'] = 'Verificação de criação de cursos'; |
@ -0,0 +1,4 @@ |
|||
<?php |
|||
$plugin->version = 2018061801; |
|||
$plugin->requires = 2017110800; |
|||
$plugin->component = 'block_courses_verification'; |
Loading…
Reference in new issue