Even after upgrading to 3.1 [3.1.5+ (Build: 20170331) from 2.7.19 (Build: 20170313)] the problem persists. The system is Debian Jessie: PHP Version 5.6.30-0+deb8u1, MySQL 5.5.54.
The upgrade was bumpy https://moodle.org/mod/forum/discuss.php?d=350380, therefore can't say that the problem is in 3.1.5. One needs to reproduce this in a clean 3.1. (Not high priority for me right now.)