What is the course_display table for?

What is the course_display table for?

by Lucia Siochi -
Number of replies: 6

Hello,

I'm trying to find out what the course_display table is used for.  It does not seem to have anything to do with setting the visibility of the course to students, which as far as I can tell is solely controlled by the visible field in the course table.

I've looked in our database, and I see that the table is populated, but it's not obvious (to me, at least!) what that data means or how to get such data there.  It seems to be setting a display attribute for different combinations or users and courses, but what exactly is the thing that is displayed or not displayed?

Thanks,
Lucia Siochi

Average of ratings: -
In reply to Lucia Siochi

Re: What is the course_display table for?

by Alejandro Michavila Pallarés -
Hi,

I also want to know what is table mdl_course_display for.

I want to get the teachers within a course and I don't know if I could use mdl_course_display table.

Thanks.
In reply to Alejandro Michavila Pallarés

Re: What is the course_display table for?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
teachers in a course is stored in role_assignments, but in a non-obvious way. However, this has been asked and answered many times before, so you should be able to find the answer.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: What is the course_display table for?

by Alejandro Michavila Pallarés -
Hi Tim,

Thanks for your answer. I can see that there are at least two ways of getting teachers, as an array of objects, enrolled within a course.

1. By API:

$role = $DB->get_record('role', array('shortname' => 'teacher'));
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$teachers = get_role_users($role->id, $context);

2. By SQL:

SELECT u.username, u.firstname, u.lastname, u.email
FROM mdl_role_assignments ra, mdl_user u, mdl_course c, mdl_context cxt, mdl_role r
WHERE ra.userid=u.id AND ra.contextid=cxt.id AND cxt.contextlevel=50 AND cxt.instanceid=c.id AND c.shortname ='CouseShortName' AND r.shortname = 'teacher';


Which way do you recommend me to do it?. I'm developing a new module for Moodle 2.0.
In reply to Alejandro Michavila Pallarés

Re: What is the course_display table for?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you are working in PHP code, use the API method.

Only use the SQL method if you are using some other tool that can only cope with SQL.
Average of ratings: Useful (1)