Skip to content

Commit

Permalink
Merge branch 'MDL-47959' of git://github.com/colchambers/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Oct 30, 2014
2 parents 08674d8 + 6375e98 commit f976c8e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions mod/quiz/classes/output/edit_renderer.php
Expand Up @@ -939,6 +939,7 @@ protected function initialise_editing_javascript($course, $quiz, structure $stru
'confirmremovequestion',
'dragtoafter',
'dragtostart',
'numquestionsx',
'removepagebreak',
), 'quiz');

Expand Down
2 changes: 2 additions & 0 deletions mod/quiz/classes/structure.php
Expand Up @@ -613,6 +613,8 @@ public function remove_slot($quiz, $slotnumber) {
question_delete_question($slot->questionid);
}

unset($this->questions[$slot->questionid]);

$this->refresh_page_numbers_and_update_db($quiz);

$trans->allow_commit();
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/edit_rest.php
Expand Up @@ -134,7 +134,7 @@
quiz_delete_previews($quiz);
quiz_update_sumgrades($quiz);
echo json_encode(array('newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades),
'deleted' => true));
'deleted' => true, 'newnumquestions' => $structure->get_question_count()));
break;
}
break;
Expand Down
3 changes: 3 additions & 0 deletions mod/quiz/tests/behat/editing_click_delete_icon.feature
Expand Up @@ -38,13 +38,16 @@ Feature: Edit quiz page - delete
And I should see "Question B" on quiz page "1"
And I should see "Question C" on quiz page "2"
And I should see "Total of marks: 3.00"
And I should see "Questions: 3"
And I should see "This quiz is open"

# Delete last question in last page. Page contains multiple questions
When I delete "Question C" in the quiz by clicking the delete icon
Then I should see "Question A" on quiz page "1"
And I should see "Question B" on quiz page "1"
And I should not see "Question C" on quiz page "2"
And I should see "Total of marks: 2.00"
And I should see "Questions: 2"

# Delete last question in last page. The page contains multiple questions and there are multiple pages.
When I click on the "Add" page break icon after question "Question A"
Expand Down
Expand Up @@ -53,6 +53,7 @@ YUI.add('moodle-mod_quiz-toolboxes', function (Y, NAME) {
INSTANCEMAXMARK : 'span.instancemaxmark',
MODINDENTDIV : '.mod-indent',
MODINDENTOUTER : '.mod-indent-outer',
NUMQUESTIONS : '.numberofquestions',
PAGECONTENT : 'div#page-content',
PAGELI : 'li.page',
SECTIONUL : 'ul.section',
Expand Down Expand Up @@ -126,6 +127,9 @@ Y.extend(TOOLBOX, Y.Base, {
if (responsetext.newsummarks) {
Y.one(SELECTOR.SUMMARKS).setHTML(responsetext.newsummarks);
}
if (responsetext.newnumquestions) {
Y.one(SELECTOR.NUMQUESTIONS).setHTML(M.util.get_string('numquestionsx', 'quiz', responsetext.newnumquestions));
}
if (success_callback) {
Y.bind(success_callback, this, responsetext)();
}
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -53,6 +53,7 @@ YUI.add('moodle-mod_quiz-toolboxes', function (Y, NAME) {
INSTANCEMAXMARK : 'span.instancemaxmark',
MODINDENTDIV : '.mod-indent',
MODINDENTOUTER : '.mod-indent-outer',
NUMQUESTIONS : '.numberofquestions',
PAGECONTENT : 'div#page-content',
PAGELI : 'li.page',
SECTIONUL : 'ul.section',
Expand Down Expand Up @@ -126,6 +127,9 @@ Y.extend(TOOLBOX, Y.Base, {
if (responsetext.newsummarks) {
Y.one(SELECTOR.SUMMARKS).setHTML(responsetext.newsummarks);
}
if (responsetext.newnumquestions) {
Y.one(SELECTOR.NUMQUESTIONS).setHTML(M.util.get_string('numquestionsx', 'quiz', responsetext.newnumquestions));
}
if (success_callback) {
Y.bind(success_callback, this, responsetext)();
}
Expand Down
4 changes: 4 additions & 0 deletions mod/quiz/yui/src/toolboxes/js/toolbox.js
Expand Up @@ -51,6 +51,7 @@
INSTANCEMAXMARK : 'span.instancemaxmark',
MODINDENTDIV : '.mod-indent',
MODINDENTOUTER : '.mod-indent-outer',
NUMQUESTIONS : '.numberofquestions',
PAGECONTENT : 'div#page-content',
PAGELI : 'li.page',
SECTIONUL : 'ul.section',
Expand Down Expand Up @@ -124,6 +125,9 @@ Y.extend(TOOLBOX, Y.Base, {
if (responsetext.newsummarks) {
Y.one(SELECTOR.SUMMARKS).setHTML(responsetext.newsummarks);
}
if (responsetext.newnumquestions) {
Y.one(SELECTOR.NUMQUESTIONS).setHTML(M.util.get_string('numquestionsx', 'quiz', responsetext.newnumquestions));
}
if (success_callback) {
Y.bind(success_callback, this, responsetext)();
}
Expand Down

0 comments on commit f976c8e

Please sign in to comment.