function get_question_image in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/lib/questionlib.php \get_question_image()
Returns a html link to the question image if there is one
Parameters
object $question The question object:
Return value
string The html image tag or the empy string if there is no image.
File
- includes/
moodle/ lib/ questionlib.php, line 1500
Code
function get_question_image($question) {
global $CFG;
$img = '';
if (!($category = get_record('question_categories', 'id', $question->category))) {
error('invalid category id ' . $question->category);
}
$coursefilesdir = get_filesdir_from_context(get_context_instance_by_id($category->contextid));
if ($question->image) {
if (substr(strtolower($question->image), 0, 7) == 'http://') {
$img .= $question->image;
}
else {
require_once $CFG->libdir . '/filelib.php';
$img = get_file_url("{$coursefilesdir}/{$question->image}");
}
}
return $img;
}