You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 15:37:39