如何以moodle形式显示课程列表?
How to display course list in moodle form?
我想以 moodle 形式显示课程列表并使用以下代码;
$options = array();
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
foreach ($allcourses as $course) {
$options[$course->id] = $course-fullname;
}
$mform->addElement('select', 'courseid', get_string('course'), $options);
$mform->setDefault('courseid', $currentcourseid);
$mform->setType(PARAM_INT);
但是它在 $allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
处显示错误,有任何指导或帮助吗?
谢谢
问候
您收到的错误消息是什么意思?
因为看起来你的括号不平衡:
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
试试这个:
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true));
如有疑问,请始终确保显示您的错误消息:
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
或者,在您的特定情况下,您可能想要修改 config.php
中的 Moodle $CFG
对象:
https://docs.moodle.org/20/en/Debugging
希望对您有所帮助
应该是:
array('recursive' => true));
代替(=
代替=>
)
array('recursive' = true));
我想以 moodle 形式显示课程列表并使用以下代码;
$options = array();
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
foreach ($allcourses as $course) {
$options[$course->id] = $course-fullname;
}
$mform->addElement('select', 'courseid', get_string('course'), $options);
$mform->setDefault('courseid', $currentcourseid);
$mform->setType(PARAM_INT);
但是它在 $allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
处显示错误,有任何指导或帮助吗?
谢谢 问候
您收到的错误消息是什么意思?
因为看起来你的括号不平衡:
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true);
试试这个:
$allcourses = coursecat::get(0)->get_courses(array('recursive' = true));
如有疑问,请始终确保显示您的错误消息:
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
或者,在您的特定情况下,您可能想要修改 config.php
中的 Moodle $CFG
对象:
https://docs.moodle.org/20/en/Debugging
希望对您有所帮助
应该是:
array('recursive' => true));
代替(=
代替=>
)
array('recursive' = true));