Code Monkey home page Code Monkey logo

moodle-block-common_courses's Introduction

This block lists any courses you have in common (i.e. you are both enrolled in) with the user whose profile you are viewing.

This is very useful, for example, when a user with a teacher role receives a message from a user with a student role, if that teacher has many courses it is very difficult to know how to contextualize the user who sends a message, if you have this block installed you can limit the context a bit and it will be easier to know what course the student is writing to.


Este bloque enumera los cursos que tiene en común (es decir, ambos están matriculados) con el usuario cuyo perfil está viendo.

Esto es muy útil por ejemplo para cuándo un usuario con rol de profesor recibe un mensaje de un usuario con rol de estudiante, si ese profesor tiene muchos cursos es muy difícil saber contextualizar a el usuario que le manda un mensaje, si tiene este bloque instalado podrá limitar un poco el contexto y le será más fácil saber de que curso le viene el estudiante que le esta escribiendo.

moodle-block-common_courses's People

Contributors

sergiocomeron avatar izendegi avatar

Watchers

James Cloos avatar  avatar

Forkers

izendegi

moodle-block-common_courses's Issues

Suggested short description

Hello Sergio,

How about the following as a short description for your Common Courses block:

This block lists any courses you have in common (i.e. you are both enrolled in) with the user whose profile you are viewing.

So what page is this supposed to go?

From the description, I understood this block is aimed at being present on user's profile pages. So I would expect the applicable_formats() returns something like user-profile. How does it help to allow adding the block to the frontpage only?

Error on edit roles

On role edit page debug show:
Invalid get_string() identifier: 'common_courses:myaddinstance' or component 'block_common_courses'. Perhaps you are missing $string['common_courses:myaddinstance'] = ''; in /usr/local/moodle/sites/moodleeval/moodle_371/blocks/common_courses/lang/en/block_common_courses.php?
line 353 of /lib/classes/string_manager_standard.php: call to debugging()
line 7255 of /lib/moodlelib.php: call to core_string_manager_standard->get_string()
line 2529 of /lib/accesslib.php: call to get_string()
line 2374 of /lib/accesslib.php: call to get_capability_string()
line 118 of /admin/roles/classes/capability_table_base.php: call to get_capability_docs_link()
line 135 of /admin/roles/classes/capability_table_with_risks.php: call to core_role_capability_table_base->display()
line 676 of /admin/roles/classes/define_role_table_advanced.php: call to core_role_capability_table_with_risks->display()
line 268 of /admin/roles/define.php: call to core_role_define_role_table_advanced->display()
Invalid get_string() identifier: 'common_courses:addinstance' or component 'block_common_courses'. Perhaps you are missing $string['common_courses:addinstance'] = ''; in /usr/local/moodle/sites/moodleeval/moodle_371/blocks/common_courses/lang/en/block_common_courses.php?
line 353 of /lib/classes/string_manager_standard.php: call to debugging()
line 7255 of /lib/moodlelib.php: call to core_string_manager_standard->get_string()
line 2529 of /lib/accesslib.php: call to get_string()
line 2374 of /lib/accesslib.php: call to get_capability_string()
line 118 of /admin/roles/classes/capability_table_base.php: call to get_capability_docs_link()
line 135 of /admin/roles/classes/capability_table_with_risks.php: call to core_role_capability_table_base->display()
line 676 of /admin/roles/classes/define_role_table_advanced.php: call to core_role_capability_table_with_risks->display()
line 268 of /admin/roles/define.php: call to core_role_define_role_table_advanced->display()

Throws PHP notice - missing icons

I am getting

Notice: Undefined property: stdClass::$icons in blocks/moodleblock.class.php on line 712

when looking at a page with your block. It is caused by the "icons" property not set in the list of courses. I admit that the phpDoc block for the block_list mentions that icons are optional. However, it seems they must always be set to avoid the notice.

The following patch seems to fix it:

--- block_common_courses.php.orig       2018-12-10 17:37:48.163602997 +0100
+++ block_common_courses.php    2018-12-10 17:43:01.872600683 +0100
@@ -62,6 +62,7 @@
 
         $this->content = new stdClass();
         $this->content->items = array();
+        $this->content->icons = array();
         $myuserid = $USER->id;
         $hisuserid = optional_param('id', 0, PARAM_INT);
         $courseid = optional_param('course', 0, PARAM_INT);
@@ -78,8 +79,10 @@
                     if ($course != $courseid) {
                         $url = './view.php?id='.$hisuserid.'&course='.$common->id;
                         $this->content->items[] = '<a href="'.$url.'">'.$coursename.'</a>';
+                        $this->content->icons[] = '';
                     } else {
                         $this->content->items[] = $coursename;
+                        $this->content->icons[] = '';
                     }
                 }
             }

Better way to find common courses

The current implementation calls enrol_get_all_users_courses() twice for each user and then find the intersection.

The is already an existing Moodle core API function for finding such courses - please see enrol_get_shared_courses()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.