私はあなたのアドバイス@FMCに従い、コースの特定のセクションのグループに許可を与える責任があるスクリプトにこの機能を実行しました
これはコードです:
/**
* giving permits to a group for a particular section of a course
*
* @param $course course that contains the section to restrict access
* @param $sectionid id of the section to restrict access
* @param $groupid id of the group will have access
* @param $module id of the mdl_module to restrict access
*
*/
function grantPermission($course, $sectionid, $groupid, $module ){
global $DB;
$restriction = '{"op":"&","c":[{"type":"group","id":'. $groupid .'}],"showc":[true]}';
$cm= $DB->get_record('course_modules', array('course' => $course , 'section' => $sectionid, 'module' => $module ), '*', MUST_EXIST);
$course_module = new stdClass();
$course_module->id = $cm->id;
$course_module->course = $course;
$course_module->section = $sectionid;
$course_module->availability = $restriction;
$res = $DB->update_record('course_modules', $course_module);
if($res)
rebuild_course_cache($course, true);
return $res;
}
これが@FMCの意味かどうか確認できますか? 動作しますが、これが最善の方法かどうかはわかりません。
ありがとうございました!