mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
quiz editing: MDL-17284 Add question here garbled layout when adding to an empty quiz.
That then lead to an incorrect display of the number of questions in the quiz.
This commit is contained in:
parent
ac250ad54a
commit
78634f1e06
@ -90,7 +90,7 @@ function quiz_delete_empty_page($layout, $index) {
|
||||
*/
|
||||
function quiz_add_quiz_question($id, &$quiz, $page = 0) {
|
||||
global $DB;
|
||||
$questions = explode(',', $quiz->questions);
|
||||
$questions = explode(',', quiz_clean_layout($quiz->questions));
|
||||
if (in_array($id, $questions)) {
|
||||
return false;
|
||||
}
|
||||
@ -101,7 +101,7 @@ function quiz_add_quiz_question($id, &$quiz, $page = 0) {
|
||||
$end = end($breaks);
|
||||
$last = prev($breaks);
|
||||
$last = $last ? $last : -1;
|
||||
if (!$quiz->questionsperpage || (($end - $last -1) < $quiz->questionsperpage)) {
|
||||
if (!$quiz->questionsperpage || (($end - $last - 1) < $quiz->questionsperpage)) {
|
||||
array_pop($questions);
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ function quiz_number_of_pages($layout) {
|
||||
* @return integer The number of questions in the quiz.
|
||||
*/
|
||||
function quiz_number_of_questions_in_quiz($layout) {
|
||||
$layout = quiz_questions_in_quiz($layout);
|
||||
$layout = quiz_questions_in_quiz(quiz_clean_layout($layout));
|
||||
$count = substr_count($layout, ',');
|
||||
if ($layout !== '') {
|
||||
$count++;
|
||||
|
@ -48,6 +48,7 @@ class quiz_locallib_test extends UnitTestCase {
|
||||
$this->assertEqual(quiz_number_of_questions_in_quiz('1,2,3,0'), 3);
|
||||
$this->assertEqual(quiz_number_of_questions_in_quiz('1,2,3,0'), 3);
|
||||
$this->assertEqual(quiz_number_of_questions_in_quiz('0,1,0,0,2,0'), 2);
|
||||
$this->assertEqual(quiz_number_of_questions_in_quiz('10,,0,0'), 1);
|
||||
}
|
||||
|
||||
function test_quiz_clean_layout() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user