-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock_natural_learning.php
More file actions
54 lines (41 loc) · 1.93 KB
/
Copy pathblock_natural_learning.php
File metadata and controls
54 lines (41 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
defined('MOODLE_INTERNAL') || die();
class block_natural_learning extends block_base {
public function init() {
$this->title = get_string('natural_learning', 'block_natural_learning');
}
public function get_content(){
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass;
if (! empty($this->config->text)) {
$this->content->text = $this->config->text;
}
else{
$this->content->text = 'Extracts DB content';
}
$this->content2 = new stdClass;
global $COURSE, $DB, $CONTEXT_COURSE;
//link to a URL with that displays the data
$updateState = 0;
$url = new moodle_url('/blocks/natural_learning/view.php', array('blockid' => $this->instance->id, 'courseid' => $COURSE->id, 'updateState' => $updateState));
$this->content->footer = html_writer::link($url, get_string('generate', 'natural_learning'));
$naturalLearningTable = 'block_natural_learning';
$coursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
if(has_capability('moodle/site:config', $coursecontext)){
if ($DB->record_exists($naturalLearningTable, array('courseid' => $COURSE->id))){
$updateState = 1;
$url2 = new moodle_url('/blocks/natural_learning/view.php', array('blockid' => $this->instance->id, 'courseid' => $COURSE->id, 'updateState' => $updateState));
$this->content->text = html_writer::link($url2, get_string('update', 'natural_learning'));
}
}
return $this->content;
}
public function specialization() {
}
// allow block only on course pages, not main page or in activities etc.
function applicable_formats() {
return array('all' => false, 'course-view' => true);
}
}