mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-29176 quiz editing: can't move questions onto a new page.
This commit is contained in:
parent
73c0d46416
commit
800944b015
@ -356,11 +356,19 @@ if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
//move to the end of the selected page
|
||||
$pagebreakpositions = array_keys($questions, 0);
|
||||
$numpages = count($pagebreakpositions);
|
||||
|
||||
// Ensure the target page number is in range.
|
||||
$moveselectedonpage = max(1, min($moveselectedonpage, $pagebreakpositions));
|
||||
for ($i = $moveselectedonpage; $i > $numpages; $i--) {
|
||||
$questions[] = 0;
|
||||
$pagebreakpositions[] = count($questions) - 1;
|
||||
}
|
||||
$moveselectedpos = $pagebreakpositions[$moveselectedonpage - 1];
|
||||
|
||||
// Do the move.
|
||||
array_splice($questions, $moveselectedpos, 0, $selectedquestionids);
|
||||
$quiz->questions = implode(',', $questions);
|
||||
|
||||
// Update the database.
|
||||
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
||||
$deletepreviews = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user