Searching for users

Name

Quickfind User List

Module type

Block

Author

Mike Worth

Released

2009

Maintained

Limited

Languages

English

Compliance

Good

Documentation

Online documentation

Errors

None displayed

The phone ringsā€”it's a student with a question about the course. You want to quickly look up the student's profile and check their activity. To achieve this you have to go to the participants list, and because there you have a large number of students, they don't all fit on the same screen, so narrow down the search by name or skip from page to page. Eventually you get to a page containing the student's name; you have to scroll and visually search until you find the student's name. Once the name is found, you can click to show the student's profile. So a simple, quick search for a profile can take 30 seconds.

The Quickfind User List block allows you to track down a student, or any user associated with a course, quickly. Just start typing and the block matches users on the fly.

Getting ready

Unzip and copy the quickfindlist block directory into the /moodle/blocks/ directory, then visit the Notifications page.

How to do it...

Once installed, the block can be added by selecting Quickfind List from the Blocks menu.

The block can be added to course pages and also on the site's root page or My Moodle pages. When added to a course, the block searches among users in that course. When added to the site root page (the first page linked in the breadcrumb trail), the block searches globally.

How to do it...

Once added, the block can be used without changing any settings, but if you wish, the settings can be modified on the configuration page for the block.

How to do it...

The first setting controls which users will appear in search results. This allows searches to be limited to users of a particular role, for example teachers or students.

It is possible to add more than one instance of the block on the same page. This allows for the possibility to search for teachers or students from separate blocks on the same page. This would probably be more applicable when the block is used on the site's root page. When the role value in this setting changes, the title of the block changes accordingly to match it.

The second setting allows control over how users' names will appear in the search results. By default names are shown with firstname followed by lastname. This may not be appropriate in all cultures, so the order of these name parts can be rearranged. You can also add a user's username to their name. Where there is a long list of users and possible name duplication, this may provide a means of distinguishing users. To allow searching by user ID, the [[userid]] field must be included in this setting.

When a list of users is displayed, each user's name acts as a link to their profile. Leaving the third setting blank achieves this default behavior. If you want the link to direct to something other than a profile, you can put a URL in this setting, leaving space at the end of the URL for an appropriate user ID to be appended. For ideas on how to exploit this setting, see the There's more... section of this recipe.

The block functions in the same way for all users, including both teachers and students. If you wish to restrict access to the block so that only teachers can use it, click on the Assign roles icon, which is the top-left icon displayed on the block header, while editing is turned on. Click on the Override Permissions tab, then you can alter the View permission setting for each role as you see fit.

You may have to Turn editing off before you can test the block.

How it works...

The block initially appears blank except for a textbox to enter a search string. As the user types, the list of names containing characters corresponding to the user's search string appear. The list appears dynamically and quickly without reloading the page.

How it works...

Behind the scenes as the page loads, the block pre-loads a list of all users and hides them. As the user types, a JavaScript function matches users against the string provided and reveals any matching entries.

As names appear, they can be clicked and, by default, the user is taken to the profile page for that user.

There's more...

The block can be used for a number of applications:

  • Searching for teachers globally in a site
  • Searching for administrators who can assist you with technical problems
  • Allowing teachers to search for students, and students to search for fellow students

Directing to other user related resources

By default, clicking on a name in the search results directs you to the user profile for that user. It is possible to configure the block to direct to other pages.

In a reflective course or site, blogging may be a central part of the student experience. To direct to the blog of the user, use the following URL in the third block setting field. Replace localhost/moodle/ with the URL of your site's web root: http://localhost/moodle/blog/index.php?userid=.

In a social course, forums may be the focus of activity. To search for posts by user, use the following URL in the third setting field. Replace localhost/moodle/ with the URL of your site's web root and replace the value of the id attribute with the course code for the current course: http://localhost/moodle/mod/forum/search.php?id=2&search=userid:.

Tidying up the user list

The search results list appears with bullet points overhanging the block in some browsers or no bullets at all in other browsers. To bring the bullet points inside the block, the style for each item can be modified where it is changed. Open the file quickfindlist.js and find the last statement. It appears as follows:

person.style.display="list-item";

To bring bullets inside the block, add a statement immediately following the preceding one:

person.style.marginLeft="1em";

If you don't want bullets at all, you can replace the preceding list-item statement with the following statement:

person.style.display="block";
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.19.185