Skip to content

Commit e05749b

Browse files
committed
add viewblock capabilities
1 parent d6e9bb5 commit e05749b

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

block_grade_me.php

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ public function init() {
3939
public function get_content() {
4040
global $CFG, $USER, $COURSE, $DB, $OUTPUT, $PAGE;
4141

42+
$context = context_course::instance($this->page->course->id);
43+
$isteacher = has_capability('block/grade_me:viewblock', $context);
44+
45+
if(!$isteacher) {
46+
return $this->content;
47+
}
48+
4249
if ($this->content !== null) {
4350
return $this->content;
4451
}

db/access.php

+12
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,17 @@
4747
),
4848

4949
'clonepermissionsfrom' => 'moodle/site:manageblocks'
50+
),
51+
52+
'block/grade_me:viewblock' => array(
53+
'riskbitmask' => RISK_SPAM | RISK_XSS,
54+
55+
'captype' => 'read',
56+
'contextlevel' => CONTEXT_BLOCK,
57+
'archetypes' => array(
58+
'user' => CAP_ALLOW
59+
),
60+
61+
'clonepermissionsfrom' => 'moodle/block:view'
5062
)
5163
);

lang/en/block_grade_me.php

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
$string['grade_me:addinstance'] = 'Add a new Grade Me block';
4747
$string['grade_me:myaddinstance'] = 'Add a new Grade Me block to the My Moodle page';
48+
$string['grade_me:viewblock'] = 'View block';
4849
$string['expand'] = 'Collapse / Expand All';
4950

5051
$string['grade_me_tools'] = 'Tools';

lang/es/block_grade_me.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
$string['settings_configenablepre'] = '¿Debería el bloque Califícame mostrar actividades sin evaluar del módulo "{$a->plugin_name}" ?';
3737
$string['grade_me:addinstance'] = 'Añadir un nuevo bloque Califícame';
3838
$string['grade_me:myaddinstance'] = 'Añadir un nuevo bloque Califícame a mi página personal';
39+
$string['grade_me:viewblock'] = 'Ver bloque';

0 commit comments

Comments
 (0)