如何让Moodle导航中的出勤选项仅对教师可见?
问题
我已在导航区块中添加了出勤选项,但希望该选项仅对教师可见。
相关代码
lib.php
function local_newattendance_extend_navigation(global_navigation $navigation) { global $CFG; if (!has_capability('local/newattendance:viewnewattendance', \context_system::instance())) { return; } $main_node = $navigation->add(get_string('pluginname', 'local_newattendance'), $CFG->attendance); $main_node->nodetype = 1; $main_node->collapse = false; $main_node->force_open = true; $main_node->isexpandable = false; $main_node->showinflatnavigation = true; }
access.php
defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'local/newattendance:viewnewattendance' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( //'manager' => CAP_ALLOW, // 管理员 'teacher' => CAP_ALLOW, // 教师 //'student'=>CAP_PREVENT, // 学生 'editingteacher' => CAP_ALLOW, // 编辑教师 ), ), );
中文语言文件(lang/zh_cn/local_newattendance.php)
$string['pluginname'] = '出勤记录'; $string['newattendance:viewnewattendance'] = '查看本地出勤记录';
内容的提问来源于stack exchange,提问作者Tagnavi
相关产品推荐
相关产品推荐

