0
我想從Moodle獲取羣組/羣ID以定製課程的用戶界面。我需要向特定的羣組/分組顯示資源。我已經設置了Moodle。我已登錄,因爲不同的用戶只能訪問分配給該用戶組的資源。如何從Moodle中獲取羣組/羣ID 1.9
我的主題有一個自定義邊欄菜單,其中包含指向該用戶的Pages,Assignments和所有其他資源的鏈接。我需要使用PHP if/else語句在菜單中向用戶顯示正確的資源,具體取決於Group/Grouping ID的值。我在Moodle.com上找到了一些文檔。我想出了這個破壞我主題的代碼。
<?php
// Get the course module id from a post or get request.
$id = required_param('id', PARAM_INT);
// Get the course module.
$cm = get_coursemodule_from_id('forum', $id, 0, false, MUST_EXIST)
// Get the current group id.
$currentgroupingid = groups_get_activity_grouping($cm);
switch($currentgroupingid) {
case "1":
echo "Group 1";
break;
case "2":
echo "Group 2";
break;
case "3":
echo "Group 3";
break;
default:
break;
}?>
此代碼不起作用,我不知道爲什麼。在文檔中有關於如何訪問關於組和分組的信息的例子。 Moodle Group API