首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Moodle Block Upload

Moodle Block Upload
EN

Stack Overflow用户
提问于 2016-03-30 20:20:08
回答 1查看 102关注 0票数 2

我目前正在开发一个Moodle插件。我已经按照文档设置了moodle block,并安装了它。然而,在我将插件文件放入Moodle的block文件夹后,它并没有注册它,我也无法安装它。有没有人能告诉我,我的代码/文件结构是不是不正确,或者哪里出了问题?

提前感谢

File structure of Plugin

代码语言:javascript
复制
x<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <?php
//Block class Definition
    class block_QEIMS extends block_list {
//init method that gives values to any clas member variables that need instantiating
public function init() {
        $this->    title = get_string('QEIMS', 'block_QEIMS');
}

public function get_content() {
if ($this->content !== null) {
  return $this->content;
    }

$this->content         =  new stdClass;
$this->content->text   = array();
$this->content->icons  = array();
$this->content->footer = 'Footer here...';

$this->content->items[] = html_writer::tag('a', 'School', [href=>'School.php']);
$this->content->items[] = html_writer::tag('b', 'Teacher', [href=>'Teacher.php']);
$this->content->items[] = html_writer::tag('c', 'Pupils', [href=>'Pupils.php']);

return $this->content;
  }

   public function specialization() //Loads congifuration data
      { 
if (isset($this->config)) 
{
    if (empty($this->config->title)) 
    {
        $this->title = get_string('defaulttitle', 'block_qeims');            
    } else 
    {
        $this->title = $this->config->title;
    }

    if (empty($this->config->text)) 
    {
        $this->config->text = get_string('defaulttext', 'block_qeims');
    }    
}
}
    public function instance_allow_multiple() //This method allows the         user to add multiple versions of this block
    {
      return true;
    }

    function preferred_width() 
    {
      // Default case: the block wants to be 180 pixels wide
      return 180;
    } 
    function refresh_content() 
    {
        // Nothing special here, depends on content()
        $this->content = NULL;
        return $this->get_content();
    }
        /**
 * Allow the block to have a configuration page
 *
 * @return boolean
 */
        public function has_config() {
        return true;
        }
    public function instance_config_save($data, $nolongerused = false) //
    {
        $data = stripslashes_recursive($data);
        $this->config = $data;
        return set_field('block_instance', 
                         'configdata',
                          base64_encode(serialize($data)),
                         'id', 
                         $this->instance->id);
    }

      }

  // Here's the closing bracket for the class definition
    ?>
    <p> this is a test </p>

<form>
    <input type="button" name="Teacher" value="Teacher"> //These buttons are tests
</form>
<form>
    <input type="button" name="Pupil" value="Pupil"> //These buttons are tests
</form>
<form>
    <input type="button" name="School" value="School"> //These buttons are tests
</form>
</body>

EN

回答 1

Stack Overflow用户

发布于 2016-03-31 22:56:33

我想你忘了创建

block_QEUMS.php

目录树中的文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36308701

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档