dousilie9522 2015-11-03 17:18
浏览 58

Moodle中已删除的用户仍会出现在课程完成表中

I have 2 courses with different activities in them where all my users are enrolled.

After I completely delete some user, the data for course completions of the user is still in the table mdl_course_completions.

The users don't appear enrolled in the course, neither the grades are kept, only the completion data.

I don't want every time to delete users manually from the mdl_course_completions table in the database. Is there any workaround in the code?

  • 写回答

1条回答 默认 最新

  • duanjianxiu9400 2015-11-05 13:06
    关注

    Are you removing users directly through an SQL query? I'd suggest always using the core methods (i.e. invoking a script that calls delete_user($user)) so that the plugins are able to remove any leftover data from their respective tables.

    Depending on how you're deleting the users and your version of Moodle the following could be of use:

    If you mean that the users are deleted through the front end then you may be able to hook into the core events API to run additional cleanup tasks

    Events API documentation

    Specifically there is an event for 'user_deleted' that you can use. You will need to set up an observer that sets up a callback to your custom script, i.e.

    $observers = array(
    
        array(
            'eventname'   => '\core\event\user_deleted',
            'includefile' => '/path/to/file',
            'callback'    => 'delete_cleanup',
        ),
    
    );
    

    More information on event observers

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀