如何获得课程老师的名字 [英] How to get the name of a course's teacher

查看:70
本文介绍了如何获得课程老师的名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能帮我创建一个查询来显示课程的老师吗

Could you help me create a query that shows the teacher(s) of a course

示例:

课程名称:课程 1老师:詹姆斯·安德森

Title of course: Course 1 Teacher: James Anderson

我有这个查询:

SELECT DISTINCT ldm_user.id,
ldm_user.firstname, 
ldm_user.lastname,
ldm_course.shortname,
ldm_course.fullname,
ldm_role.id as role_id, 
ldm_role_assignments.id

FROM ldm_course,ldm_user,ldm_role,ldm_context,ldm_role_assignments

WHERE ldm_course.fullname = "i-ONS001 Taller de Lectura y Redacción IV" and ldm_role_assignments.id = 4

但这并没有像预期的那样返回老师的名字.

But this is not returning the name of the teacher as expected.

推荐答案

您的问题不完整,因为确切的查询会因您的 Moodle 版本而异,无论您使用的是 SQL 还是 MySQL,我们也不能在不了解您的表结构的情况下为您提供全面的答案.

Your question is incomplete, because the exact query will vary depending on your version of Moodle, whether you're using SQL or MySQL, and also we can't give you a comprehensive answer without knowing your table structures.

但是,在 Moodle 2.x 中,您可以使用如下所示的 API 查询 (PHP):

However, in Moodle 2.x you can use an API query (PHP) which looks something like this:

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

然后执行 return $teachers;echo $teachers; 以输出所述结果.

and then doing a return $teachers; or echo $teachers; to output said results.

就像我说的那样,在不知道您确切的系统详细信息的情况下,我无法为您提供准确的响应和有效的查询,因此请稍加保留;您可能需要使用它才能使其正常工作.

Like I said, without knowing your exact system details I can't give you an accurate response and a functioning query so take that with a pinch of salt; you might need to play around with it to get it to work.

参考:https://moodle.org/mod/forum/discuss.php?d=115636

这篇关于如何获得课程老师的名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆