Permalink
Browse files

MDL-37934 Blackboard_six question import fails in some cases

Import fails if the same image is used several times
in the same field of the same question.
  • Loading branch information...
1 parent 09de5eb commit 58a43ebebe46715147d2ae3910d2b9b47a07c9d9 Jean-Michel Vedrine committed Feb 11, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 question/format/blackboard_six/formatbase.php
@@ -123,15 +123,16 @@ public function text_field($text) {
$data = array();
// Step one, find all file refs then add to array.
preg_match_all('|<img[^>]+src="([^"]*)"|i', $text, $out); // Find all src refs.
-
+ $filepaths = array();
foreach ($out[1] as $path) {
$fullpath = $this->filebase . '/' . $path;
- if (is_readable($fullpath)) {
+ if (is_readable($fullpath) && !in_array($path, $filepaths)) {
$dirpath = dirname($path);
$filename = basename($path);
$newfilename = $this->store_file_for_text_field($data, $this->filebase, $dirpath, $filename);
$text = preg_replace("|$path|", "@@PLUGINFILE@@/" . $newfilename, $text);
+ $filepaths[] = $path;
}
}

0 comments on commit 58a43eb

Please sign in to comment.