Moodle版本:2.1
一、用戶登陸後導向到個人主頁
在Moodle中遍尋不到這個設置,我記得在2.3版本好像有。沒辦法只有仔細了看了下代碼。發現 login/index.php中有段代碼比較合符要求。
- /// Go to my-moodle page instead of site homepage if defaulthomepage set to homepage_my
- if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY && !is_siteadmin() && !isguestuser()) {
- if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') {
- $urltogo = $CFG->wwwroot.'/my/';
- }
- }
複製代碼
其中「defaulthomepage」這個單詞引發了個人注意,靈機一動,到數據庫中配置表「mdl_config」中搜了下,竟然發現了這個配置參數,默認值是0,將它修改爲1。
登陸後正常進入「個人主頁」。功能實現。
二、普通用戶在個人主頁中沒法返回網站首頁
這個問題是上一個問題引發的,若使用管理員賬號登陸,能正常回到首頁,當是不能對首頁再進行編輯;如果普通用戶,根本就沒有權限回首頁了。悲催的規則,沒搞明白是Moodle的bug,仍是我沒配置對。
處理的方式很簡單,就是把「網站首頁」先屏蔽吧。在lib目錄下找到navigationlib.php,在函數initialise中有一段代碼。
- if (get_home_page() == HOMEPAGE_SITE) {
- // The home element should be my moodle because the root element is the site
- if (isloggedin() && !isguestuser()) { // Makes no sense if you aren't logged in
- $this->rootnodes['home'] = $this->add(get_string('myhome'), new moodle_url('/my/'), self::TYPE_SETTING, null, 'home');
- }
- } else {
- // The home element should be the site because the root node is my moodle
- $this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home');
- if ($CFG->defaulthomepage == HOMEPAGE_MY) {
- // We need to stop automatic redirection
- $this->rootnodes['home']->action->param('redirect', '0');
- }
- }
複製代碼
將else語句後面的屏蔽掉吧。算是解決一個問題,功能完成。
三、成員列表中,屏蔽按字母搜索
在課程中,有個成員列表,其中的按字母搜索比較的有趣。爲了避免讓它妨礙使用的心情,決定把它先屏蔽掉。
在lib目錄下,其中有個tablelib.php,其中有段代碼。
- /**
- * This function is not part of the public api.
- */
- function print_initials_bar() {
- /* if ((!empty($this->sess->i_last) || !empty($this->sess->i_first) ||$this->use_initials)
- && isset($this->columns['fullname'])) {
- $alpha = explode(',', get_string('alphabet', 'langconfig'));
- // Bar of first initials
- if (!empty($this->sess->i_first)) {
- $ifirst = $this->sess->i_first;
- } else {
- $ifirst = '';
- }
- $this->print_one_initials_bar($alpha, $ifirst, 'firstinitial',
- get_string('firstname'), $this->request[TABLE_VAR_IFIRST]);
- // Bar of last initials
- if (!empty($this->sess->i_last)) {
- $ilast = $this->sess->i_last;
- } else {
- $ilast = '';
- }
- $this->print_one_initials_bar($alpha, $ilast, 'lastinitial',
- get_string('lastname'), $this->request[TABLE_VAR_ILAST]);
- }*/
- }
複製代碼
如上屏蔽掉它裏面的代碼,再次刷新頁面,功能完成。
四、屏蔽資源、活動中不要的選項
在課程中,添加活動或資源時,有不少選項,好比什麼SCORM、IMS這些,平時基本不用,太專業了。如何把它屏蔽掉呢?
開始想法是改代碼,後來發現一個好辦法,就是把這些插件卸載掉。Moodle在這方面作得比較好,大部分東西都是插件的形式,不像我常常動不動就考慮改代碼,改結構,差了不是一個檔次啊。
卸載了相應插件後,還須要把對應目錄所有刪除,不然登陸後沒法正常訪問,老是提示你插件安裝不全,須要升級。
(轉自:http://blog.csdn.net/36/article/details/8185606) |