Course Contacts Block

Blocks ::: block_course_contacts
Maintained by Mark Ward, Richard Oelmann
The Course Contacts block displays a list of users on your course, various methods for communicating with them, and their current activity status.
Latest release:
1018 sites
171 downloads
47 fans
Current versions available: 2

The Course Contacts block displays a list of users on your course and various
methods for communicating with them.

The block is highly customisable and allows you to choose specific roles which
you wish to display users from. By default the block will show teachers on the
course but this can be changed however you wish.

You can also configure which communication types you wish to show, the block
can provide quick links to Email, Message or Telephone each user.

The block also shows whether the user has been active in the last five minutes.

Potential privacy issues

This block can publish contact details for users; be careful when using it on a course with guest access enabled.

Screenshots

Screenshot #0

Contributors

Mark Ward (Lead maintainer): Co-author
Richard Oelmann: Co-author
Mat Cannings: Tester
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • My picture
    Fri, 17 Aug 2012, 11:40 PM
    Hello Mark,
    First, that you very much for this smart block. I have used it in Moodle 2.0 and when I upgraded our Moodle site to 2.2., I installed the new version (2012052000), teachers have started to complain that they cannot see their own contact profile in their courses.
    I looked into this (an yes:'Roles to show->teacher' is active) and it is really weird because students are able to see the contact profiles of ALL the editing teachers in a course, I can be see all the teachers as administrator and each teacher in the course can see THE REST of the editing teachers in the course contacts block, except themselves.

    Is it something done on purpose, because a teacher cannot obviously send an email or message to himself? Is it that my teachers are like vampires smile and they don't reflect on mirrors? It is a pitfall of the code?

    Thank you very much for your help.
  • Mark Ward
    Sat, 18 Aug 2012, 12:49 AM
    Hi Mari,

    Our staff usually complain when they DO see a picture of themselves on the page :P

    The block has actually always actively filtered out the current user from the results. This is because, as you pointed out, we don't want the user to be sending messages to themselves. I could alter the code to only filter out the messaging icons when the contact is our user if people feel it is a problem?

    Glad you are finding it useful!

    Mark
  • Me and my fiance
    Mon, 20 Aug 2012, 1:22 PM
    Is it possible to be able to sort which trainer/teacher is displayed first? The issue we face is students automatically message the first trainer in the block. A handy feature would be to be able to sort who comes first perhaps using Ajax drag or a number sequence when editing is on.
  • My picture
    Tue, 21 Aug 2012, 11:58 PM
    Hello Mark,
    Thanks for replying. In our case, we have several tutors teaching the same module and the module leads like to see themselves to make sure that they appear as the first contact.

    Like Paul has suggested, it would be good if we could set up the order in which tutor appear.
    If you can tell me in which part of the code I can disable the filter, I can have a go trying to alter the code myself.

    Regard
  • Mark Ward
    Thu, 23 Aug 2012, 4:05 PM
    Paul, If there are teachers on a course which should be contacted before others then I would suggest assigning them a separate role on the course. The role definition system already has a method for "prioritising" roles so we should use that core functionality to handle this. I need to check that role types are being ordered using that weighting.

    Mari, the filter is in place in block_course_contacts.php at line 90, but I am happy to change this behaviour in the main block so long as nobody raises an objection.
  • My picture
    Mon, 27 Aug 2012, 4:55 PM
    Hello Mark,
    Thank you very much for the tip. I personally think that it would be useful if teacher could see their own profile so that they could see the order in which they are displayed in the block.

    As for Paul's suggestion: it is a very tricky one. We usually have a main tutor (module lead) and a second tutor who helps with the online teaching.

    I thought of playing around with the roles of the main tutor and the secondary tutor to get the effect that you propose.
  • Simon Hanmer
    Tue, 4 Sept 2012, 7:35 PM
    Hi, I've tried to install this block on our Moodle 2.1 site which is using SQLServer as the backend.

    The install works fine, but if I try and add an instance of the block, I get an 'Error reading from database' message and if I turn on debugging, I get the following:

    Debug info: The ntext data type cannot be selected as DISTINCT because it is not comparable.
    SELECT DISTINCT mdl_user.*

    FROM mdl_user
    LEFT JOIN mdl_role_assignments
    ON mdl_role_assignments.userid = mdl_user.id
    LEFT JOIN mdl_context
    ON mdl_context.id=mdl_role_assignments.contextid

    WHERE mdl_context.instanceid = ?
    AND mdl_context.contextlevel = 50
    AND mdl_role_assignments.roleid = ?

    ORDER BY LOWER(mdl_user.lastname)
    [array (
    0 => '8',
    1 => 3,
    )]
    Stack trace:
    line 394 of \lib\dml\moodle_database.php: dml_read_exception thrown
    line 255 of \lib\dml\mssql_native_moodle_database.php: call to moodle_database->query_end()
    line 711 of \lib\dml\mssql_native_moodle_database.php: call to mssql_native_moodle_database->query_end()
    line 740 of \lib\dml\mssql_native_moodle_database.php: call to mssql_native_moodle_database->get_recordset_sql()
    line 70 of \blocks\course_contacts\block_course_contacts.php: call to mssql_native_moodle_database->get_records_sql()
    line 280 of \blocks\moodleblock.class.php: call to block_course_contacts->get_content()
    line 232 of \blocks\moodleblock.class.php: call to block_base->formatted_contents()
    line 926 of \lib\blocklib.php: call to block_base->get_content_for_output()
    line 978 of \lib\blocklib.php: call to block_manager->create_block_contents()
    line 349 of \lib\blocklib.php: call to block_manager->ensure_content_created()
    line 7 of \theme\upstream_fluid\layout\general.php: call to block_manager->region_has_content()
    line 654 of \lib\outputrenderers.php: call to include()
    line 612 of \lib\outputrenderers.php: call to core_renderer->render_page_layout()
    line 206 of \course\view.php: call to core_renderer->header()
  • Simon Hanmer
    Tue, 4 Sept 2012, 8:16 PM
    Mark, I found that if I replaced the SQL Query with the following, the block worked for me:
    SELECT DISTINCT {user}.id, {user}.lastaccess, {user}.firstname, {user}.lastname, {user}.email, {user}.phone1, {user}.picture, {user}.imagealt

    FROM {user}
    LEFT JOIN {role_assignments}
    ON {role_assignments}.userid = {user}.id
    LEFT JOIN {context}
    ON {context}.id={role_assignments}.contextid

    WHERE {context}.instanceid = ?
    AND {context}.contextlevel = 50
    AND {role_assignments}.roleid = ?

    ORDER BY {user}.lastname
  • Mark Ward
    Tue, 4 Sept 2012, 8:53 PM
    Hi Simon,

    Could you give this a try and let me know if it works ok for you:

    "SELECT {user}.*
    FROM {user}
    LEFT JOIN {role_assignments}
    ON {role_assignments}.userid = {user}.id
    LEFT JOIN {context}
    ON {context}.id={role_assignments}.contextid
    WHERE {context}.instanceid = ?
    AND {context}.contextlevel = 50
    AND {role_assignments}.roleid = ?
    GROUP BY {user}.id
    ORDER BY LOWER({user}.lastname)"
  • Simon Hanmer
    Tue, 4 Sept 2012, 9:53 PM
    Mar,
    I tried that and get the error:

    Debug info: Column 'mdl_user.auth' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
    SELECT mdl_user.*
    FROM mdl_user
    LEFT JOIN mdl_role_assignments
    ON mdl_role_assignments.userid = mdl_user.id
    LEFT JOIN mdl_context
    ON mdl_context.id=mdl_role_assignments.contextid
    WHERE mdl_context.instanceid = ?
    AND mdl_context.contextlevel = 50
    AND mdl_role_assignments.roleid = ?
    GROUP BY mdl_user.id
    ORDER BY LOWER(mdl_user.lastname)

    I think the problem with the original query was that fields were being pulled in that aren't used - the description field in the user profile is an ntext datatype which stopped distinct working; so I changed the query to explicitly state the fields which the block requires.
  • Mark Ward
    Tue, 4 Sept 2012, 10:24 PM
    Yes, and selecting just the fields the block needs for each contact will be better for now. We will need to pull more fields out of the database if we decide to do anything with the contacts which relies on a proper USER object in the future though. It's just good to know what my options are while I have someone around to try things out on MS-SQL :P

    I've cleaned up my SQL builder a little and added your SELECT tweaks. I've also made a modification to handle Mari's request and I have verified that the roles are indeed being printed in the order that is defined within "Define Roles". I'm just waiting to hear back from Mat Canings regarding something he was working on and then I will be able to release an updated version.
  • Simon Hanmer
    Tue, 4 Sept 2012, 11:25 PM
    Mark, happy to help out on testing with MS-SQL
  • Simon Hanmer
    Tue, 4 Sept 2012, 11:44 PM
    Mark, I'd add a request as well - can we put an option on the configuration screen to choose whether the user is displayed in the list or not if they have an appropriate role - took me a while to work out why I couldn't see myself smile
  • Mark Ward
    Wed, 5 Sept 2012, 12:29 AM
    Hi Simon, that was Mari's request which I referred to above. I'm not sure it needs an option but I wanted to give people a chance to raise concerns before I changed the behaviour.
  • My picture
    Wed, 19 Sept 2012, 5:54 PM
    Hello Mat,
    I am also happy helping in the testing. We launched new online courses for the September presentation on Friday, so it has been very busy for the last two days.
    Please let me know where I could find the beta version. I work for the Medical School of the University of Dundee, we have our own learning platform in Moodle and course contacts is a very popular block among our tutors.
Please login to post comments