moodle local plugin 开发小记

这次开发主要要实现的功能是:

  • 对课程的活跃度进行统计
  • 对课程根据活跃度进行排名
  • 统计课程中最活跃的用户
  • 等等
  • 添加一个local plugin的几个文件

  • index.php
  • version.php
  • lang
  • renderer.php
  • 遇到的困难

  • 插件不能安装——修改程序目录修正
  • 不能get_renderer——更改renderer的名字 前缀加上local后搞定
  • 一个比较恶心的SQL

    1
    2
    3
    4
    5
    6
    7
    8
    
    SELECT c.id AS id, c.fullname, u.username, u.firstname, u.lastname, u.email
    FROM mdl_role_assignments ra, mdl_user u, mdl_course c, mdl_context cxt
    WHERE ra.userid = u.id
    AND ra.contextid = cxt.id
    AND cxt.contextlevel =50
    AND cxt.instanceid = c.id
    AND c.id = 2
    AND (roleid =5 OR roleid=3)

    linux 常见缩写的来源

    bin = BINaries
    /dev = DEVices
    /etc = ETCetera
    /lib = LIBrary
    /proc = PROCesses
    /sbin = Superuser BINaries
    /tmp = TeMPorary
    /usr = Unix Shared Resources
    /var = VARiable ?

    FIFO = First In, First Out
    GRUB = GRand Unified Bootloader
    IFS = Internal Field Seperators
    LILO = LInux LOader
    MySQL = My是最初作者女儿的名字,SQL = Structured Query Language
    PHP = Personal Home Page Tools = PHP Hypertext Preprocessor
    PS = Prompt String
    Perl = “Pratical Extraction and Report Language” = “Pathologically Eclectic Rubbish Lister”
    Python 得名于电视剧Monty Python’s Flying Circus [......]

    Read more

    mac 配置ruby on rails 环境

    1、首先安装rvm 在bash中输入以下命令

    1
    
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

    2、重启bash使配置生效
    3、执行命令

    1
    
    rvm list known

    4、执行命令选择安装版本

    1
    
    rvm install 1.9.3

    5、执行命令 安装rails

    1
    2
    3
    
    rvm use 1.9.3
    ruby -v
    gem install rails

    2012.2.25测试结果

    当你想控制文件下载权限的时候该怎么整

    经常遇到这种问题 很多文件不希望所有人都能下载 只有获得权限的用户才能访问文件 这样文件可不必放在web目录下 文件可以放到任意的地方
    php代码如下

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    <?php
    $file = 'monkey.gif';
     
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile($file);
    }
    ?>