Skip to content

Commit

Permalink
MDL-42031 assginfeedback_editpdf: fix next/previous/select page
Browse files Browse the repository at this point in the history
  • Loading branch information
mouneyrac committed Nov 6, 2013
1 parent 5386f0b commit d40ce26
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
20 changes: 19 additions & 1 deletion mod/assign/feedback/editpdf/classes/document_services.php
Expand Up @@ -380,7 +380,25 @@ public static function get_page_images_for_attempt($assignment, $userid, $attemp
// Image files are stale - regenerate them.
$files = array();
} else {
return $files;

// Need to reorder the files following their name.
// because get_directory_files() return a different order than generate_page_images_for_attempt().
$orderedfiles = array();
foreach($files as $file) {
// Extract the page number from the file name image_pageXXXX.png.
preg_match('/page([\d]+)\./', $file->get_filename(), $matches);
if (empty($matches) or !is_numeric($matches[1])) {
throw new \coding_exception("'" . $file->get_filename()
. "' file hasn't the expected format filename: image_pageXXXX.png.");
}
$pagenumber = (int)$matches[1];

// Save the page in the ordered array.
$orderedfiles[$pagenumber] = $file;
}
ksort($orderedfiles);

return $orderedfiles;
}
}
return self::generate_page_images_for_attempt($assignment, $userid, $attemptnumber);
Expand Down
Expand Up @@ -3127,11 +3127,11 @@ EDITOR.prototype = {

this.refresh_button_state();
}

this.load_all_pages();
}
this.dialogue.centerDialogue();
this.dialogue.show();

this.load_all_pages();
},

/**
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -3127,11 +3127,11 @@ EDITOR.prototype = {

this.refresh_button_state();
}

this.load_all_pages();
}
this.dialogue.centerDialogue();
this.dialogue.show();

this.load_all_pages();
},

/**
Expand Down
4 changes: 2 additions & 2 deletions mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
Expand Up @@ -298,11 +298,11 @@ EDITOR.prototype = {

this.refresh_button_state();
}

this.load_all_pages();
}
this.dialogue.centerDialogue();
this.dialogue.show();

this.load_all_pages();
},

/**
Expand Down

0 comments on commit d40ce26

Please sign in to comment.