Plugins 测验尝试页面上每个角色的Moodle块可见性

Plugins 测验尝试页面上每个角色的Moodle块可见性,plugins,block,moodle,Plugins,Block,Moodle,我已经成功地遵循了教程,并创建了一个小的自定义块 我需要在Mathematics Quike/trument.php页面上显示此块,但我有两个问题 该块为管理员用户显示,但不为学生显示 如何仅在选定的测验(即数学测验而非英语测验)上显示该模块 代码: class block\u customfeedback扩展block\u基{ 公共函数init(){ $this->title=get_string('customfeedback','block_customfeedback'); } 公

我已经成功地遵循了教程,并创建了一个小的自定义块

我需要在Mathematics Quike/trument.php页面上显示此块,但我有两个问题

  • 该块为管理员用户显示,但不为学生显示
  • 如何仅在选定的测验(即数学测验而非英语测验)上显示该模块

    代码:

class block\u customfeedback扩展block\u基{
公共函数init(){
$this->title=get_string('customfeedback','block_customfeedback');
}
公共函数get_content(){
如果($this->content!==null){
返回$this->content;
}
$form.=”;
$form.=“问题ID”;
$form.=“测验名称”;
$form.=“您的反馈”;
$form.=”;
$form.=”;
$this->content=新的stdClass;
$this->content->text=$form;
//$this->content->footer='footer here…';
返回$this->content;
}
公共功能适用的_格式(){
返回数组(
“全部”=>正确
);
}
}//关闭类

您可以在测验尝试页面上显示您的区块

步骤:

  • 转到测验设置页面
  • 点击外观
  • 点击显示更多
  • 将“测验尝试期间显示块”的值更改为“是”

  • 现在使用学生登录并检查。

    您可以在测验尝试页面上显示您的区块

    步骤:

  • 转到测验设置页面
  • 点击外观
  • 点击显示更多
  • 将“测验尝试期间显示块”的值更改为“是”

  • 现在与学生一起登录并检查。

    你能显示代码吗?@RussellEngland:差不多一年了,我花了整整一个周期重新开发我的Moodle网站,结果还是遇到了同样的问题。对于延迟提供代码表示歉意,但如果您仍有兴趣提供帮助,我将非常感谢您的建议。您能展示代码吗?@RussellEngland:差不多一年了,我已经完成了整个周期的重新开发我的Moodle网站,但却遇到了同样的问题。对于延迟提供代码表示歉意,但如果您仍有兴趣提供帮助,我将非常感谢您的建议
    class block_customfeedback extends block_base {
        public function init() {
            $this->title = get_string('customfeedback', 'block_customfeedback');
        }
    
        public function get_content() {
            if ($this->content !== null) {
              return $this->content;
            }
    
            $form .= "<form action='http://www.remoteserver.com/response.php' method='post'>";
            $form .= "<label>Question ID</label>    <input name='QuestionID' id='questionid' type='text' />";
            $form .= "<label>Quiz Name</label>      <input name='QuizName' id='quizname' type='text' />";
            $form .= "<label>Your Feedback</label>  <textarea name='Feedback' id='feedback' type='text' ></textarea>";
            $form .= "<input type='submit' value='Submit' />";
            $form .= "</form>";
    
            $this->content         =  new stdClass;
            $this->content->text   = $form;
            // $this->content->footer = 'Footer here...';
    
            return $this->content;
        }
    
        public function applicable_formats() {
            return array(
                'all'   => true
            );
        }
    
    } // close class