You are here

function qformat_xml::writeimage in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/question/format/xml/format.php \qformat_xml::writeimage()

Include an image encoded in base 64

Parameters

string imagepath The location of the image file:

Return value

string xml code segment

1 call to qformat_xml::writeimage()
qformat_xml::writequestion in includes/moodle/question/format/xml/format.php
Turns question into an xml segment

File

includes/moodle/question/format/xml/format.php, line 746

Class

qformat_xml

Code

function writeimage($imagepath) {
  global $CFG;
  if (empty($imagepath)) {
    return '';
  }
  $courseid = $this->course->id;
  if (!($binary = file_get_contents("{$CFG->dataroot}/{$courseid}/{$imagepath}"))) {
    return '';
  }
  $content = "    <image_base64>\n" . addslashes(base64_encode($binary)) . "\n" . "\n    </image_base64>\n";
  return $content;
}