【问题标题】:Moodle 1.9.7: Uploading file in assignment admin panelMoodle 1.9.7:在作业管理面板中上传文件
【发布时间】:2010-03-10 11:39:28
【问题描述】:

在 Moodle 1.9.7 中,我需要允许老师在一个全新的作业插件的管理面板中上传文件。

在我的 assignment.class.php 中覆盖 setup_elements 函数时,我正在执行以下操作:

$mform->addElement('file', 'foo', 'Label');
$mform->setHelpButton('foo', array('foo', 'Label', 'assignment/type/my_assignment'));

表单是用一个不错的文件选择器上传的,但我应该如何管理上传的文件?应该重写哪个函数?如何指定上传文件的位置?

Moodle 中完全缺乏关于此的文档(混杂着一点混乱):(

我正在深入研究代码以查看幕后发生的情况。与此同时,我认为你们中的一些人过去也可以这样做。

我知道这是高度具体的,但也许 Moodle 开发人员正在研究这个 :)

【问题讨论】:

    标签: php file forms upload moodle


    【解决方案1】:

    好吧,在挖掘代码之后,这就是我所做的。

    我已经覆盖了以下赋值函数:

    function add_instance($submission)
    {
      return (save_uploaded_files($submission)) ? parent::add_instance($submission) : false;
    }
    
    function update_instance($submission)
    {
      return (save_uploaded_files($submission)) ? parent::update_instance($submission) : false;
    }
    

    save_uploaded_files($submission) 函数如下所示:

    function save_uploaded_files($submission)
    {
      global $CFG;
    
      $um = new upload_manager('my_file', ... [OPTIONS HERE] ... );
      return $um->process_file_uploads("my/upload/path");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-14
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 2010-12-20
      • 1970-01-01
      • 2016-09-13
      • 1970-01-01
      相关资源
      最近更新 更多