From f37cffb6a519992634968ae15e40a97ba4f763d8 Mon Sep 17 00:00:00 2001 From: Colin Chambers Date: Thu, 2 Feb 2017 14:36:34 +0000 Subject: [PATCH] MDL-48771 quiz edit: delete mulitiple tidy up & Behat tests --- mod/quiz/classes/output/edit_renderer.php | 113 +++++++--- mod/quiz/edit_rest.php | 52 +++-- mod/quiz/lang/en/quiz.php | 3 +- mod/quiz/styles.css | 92 ++++---- .../editing_remove_multiple_questions.feature | 170 +++++++++++++++ .../moodle-mod_quiz-repaginate-debug.js | 9 +- .../moodle-mod_quiz-repaginate-min.js | 2 +- .../moodle-mod_quiz-repaginate.js | 9 +- .../moodle-mod_quiz-toolboxes-debug.js | 205 +++++++++++------- .../moodle-mod_quiz-toolboxes-min.js | 6 +- .../moodle-mod_quiz-toolboxes.js | 205 +++++++++++------- mod/quiz/yui/src/repaginate/js/repaginate.js | 9 +- mod/quiz/yui/src/toolboxes/js/resource.js | 195 ++++++++++------- mod/quiz/yui/src/toolboxes/js/toolbox.js | 10 +- 14 files changed, 746 insertions(+), 334 deletions(-) create mode 100644 mod/quiz/tests/behat/editing_remove_multiple_questions.feature diff --git a/mod/quiz/classes/output/edit_renderer.php b/mod/quiz/classes/output/edit_renderer.php index ef23758214e..238a1a81f58 100644 --- a/mod/quiz/classes/output/edit_renderer.php +++ b/mod/quiz/classes/output/edit_renderer.php @@ -59,26 +59,24 @@ class edit_renderer extends \plugin_renderer_base { // Information at the top. $output .= $this->quiz_state_warnings($structure); + + $output .= html_writer::start_div('mod_quiz-edit-top-controls'); $output .= $this->quiz_information($structure); $output .= $this->maximum_grade_input($structure, $pageurl); + + $output .= html_writer::start_div('mod_quiz-edit-action-buttons btn-group edit-toolbar', ['role' => 'group']); $output .= $this->repaginate_button($structure, $pageurl); - $output .= $this->bulkaction_button($structure); + $output .= $this->selectmultiple_button($structure); + $output .= html_writer::end_tag('div'); + $output .= $this->total_marks($quizobj->get_quiz()); + $output .= $this->selectmultiple_controls($structure); + $output .= html_writer::end_tag('div'); + // Show the questions organised into sections and pages. $output .= $this->start_section_list($structure); - // Bulk action button delete and bulk action button cancel. - $output .= html_writer::tag('div', html_writer::empty_tag('input', array('type' => 'button', - 'id' => 'bulkactionsdeletecommand', 'value' => get_string('delete', 'moodle'))) . " " . - html_writer::empty_tag('input', array('type' => 'button', 'id' => 'bulkactionscancelcommand', - 'value' => get_string('cancel', 'moodle'))), array('class' => 'bulkactioncommand actions')); - - // Select all/deselect all questions. - $output .= html_writer::tag('div', html_writer::link('#', get_string('selectall', 'quiz'), - array('id' => 'questionselectall')) . " / " . html_writer::link('#', get_string('selectnone', 'quiz'), - array('id' => 'questiondeselectall')), array('class' => 'bulkactioncommandbuttons')); - foreach ($structure->get_sections() as $section) { $output .= $this->start_section($structure, $section); $output .= $this->questions_in_section($structure, $section, $contexts, $pagevars, $pageurl); @@ -199,12 +197,6 @@ class edit_renderer extends \plugin_renderer_base { $header = html_writer::tag('span', get_string('repaginatecommand', 'quiz'), array('class' => 'repaginatecommand')); $form = $this->repaginate_form($structure, $pageurl); - $containeroptions = array( - 'class' => 'rpcontainerclass', - 'cmid' => $structure->get_cmid(), - 'header' => $header, - 'form' => $form, - ); $buttonoptions = array( 'type' => 'submit', @@ -212,6 +204,8 @@ class edit_renderer extends \plugin_renderer_base { 'id' => 'repaginatecommand', 'value' => get_string('repaginatecommand', 'quiz'), 'class' => 'btn btn-secondary m-b-1', + 'data-header' => $header, + 'data-form' => $form, ); if (!$structure->can_be_repaginated()) { $buttonoptions['disabled'] = 'disabled'; @@ -219,26 +213,89 @@ class edit_renderer extends \plugin_renderer_base { $this->page->requires->yui_module('moodle-mod_quiz-repaginate', 'M.mod_quiz.repaginate.init'); } - return html_writer::start_tag('div', $containeroptions) . - html_writer::empty_tag('input', $buttonoptions); + return html_writer::empty_tag('input', $buttonoptions); } /** - * Generate the bulk action button + * Generate the bulk action button. + * * @param structure $structure the structure of the quiz being edited. * @return string HTML to output. */ - protected function bulkaction_button(structure $structure) { + protected function selectmultiple_button(structure $structure) { $buttonoptions = array( 'type' => 'button', - 'name' => 'repaginate', - 'id' => 'bulkactionscommand', - 'value' => get_string('bulkactions', 'quiz'), + 'name' => 'selectmultiple', + 'id' => 'selectmultiplecommand', + 'value' => get_string('selectmultipleitems', 'quiz'), + 'class' => 'btn btn-secondary m-b-1' ); - if (!$structure->can_be_repaginated()) { + if (!$structure->can_be_edited()) { $buttonoptions['disabled'] = 'disabled'; } - return html_writer::empty_tag('input', $buttonoptions) . html_writer::end_tag('div'); + + return html_writer::tag('button', get_string('selectmultipleitems', 'quiz'), $buttonoptions); + } + + /** + * Generate the controls that appear when the bulk action button is pressed. + * + * @param structure $structure the structure of the quiz being edited. + * @return string HTML to output. + */ + protected function selectmultiple_controls(structure $structure) { + $output = ''; + + // Bulk action button delete and bulk action button cancel. + $buttondeleteoptions = array( + 'type' => 'button', + 'id' => 'selectmultipledeletecommand', + 'value' => get_string('deleteselected', 'mod_quiz'), + 'class' => 'btn btn-secondary' + ); + $buttoncanceloptions = array( + 'type' => 'button', + 'id' => 'selectmultiplecancelcommand', + 'value' => get_string('cancel', 'moodle'), + 'class' => 'btn btn-secondary' + ); + + $groupoptions = array( + 'class' => 'btn-group selectmultiplecommand actions', + 'role' => 'group' + ); + + $output .= html_writer::tag('div', + html_writer::tag('button', get_string('deleteselected', 'mod_quiz'), $buttondeleteoptions) . + " " . + html_writer::tag('button', get_string('cancel', 'moodle'), + $buttoncanceloptions), $groupoptions); + + $toolbaroptions = array( + 'class' => 'btn-toolbar', + 'role' => 'toolbar', + 'aria-label' => get_string('selectmultipletoolbar', 'quiz'), + ); + + // Select all/deselect all questions. + $buttonselectalloptions = array( + 'role' => 'button', + 'id' => 'questionselectall', + 'class' => 'btn btn-link' + ); + $buttondeselectalloptions = array( + 'role' => 'button', + 'id' => 'questiondeselectall', + 'class' => 'btn btn-link' + ); + $output .= html_writer::tag('div', + html_writer::tag('div', + html_writer::link('#', get_string('selectall', 'quiz'), $buttonselectalloptions) . + html_writer::tag('span', "/", ['class' => 'separator']) . + html_writer::link('#', get_string('selectnone', 'quiz'), $buttondeselectalloptions), + array('class' => 'btn-group selectmultiplecommandbuttons')), + $toolbaroptions); + return $output; } /** @@ -672,7 +729,7 @@ class edit_renderer extends \plugin_renderer_base { $output .= html_writer::start_div('mod-indent-outer'); $output .= html_writer::tag('input', '', array('id' => 'selectquestion-' . $structure->get_displayed_number_for_slot($slot), 'name' => 'selectquestion[]', - 'type' => 'checkbox', 'class' => 'quiz-question-bulk-selector', + 'type' => 'checkbox', 'class' => 'select-multiple-checkbox', 'value' => $structure->get_displayed_number_for_slot($slot))); $output .= $this->question_number($structure->get_displayed_number_for_slot($slot)); diff --git a/mod/quiz/edit_rest.php b/mod/quiz/edit_rest.php index dd63ee88079..f06ca37f1c3 100644 --- a/mod/quiz/edit_rest.php +++ b/mod/quiz/edit_rest.php @@ -47,7 +47,7 @@ $maxmark = optional_param('maxmark', '', PARAM_FLOAT); $newheading = optional_param('newheading', '', PARAM_TEXT); $shuffle = optional_param('newshuffle', 0, PARAM_INT); $page = optional_param('page', '', PARAM_INT); -$bulkslots = optional_param('slots', '', PARAM_SEQUENCE); +$ids = optional_param('ids', '', PARAM_SEQUENCE); $PAGE->set_url('/mod/quiz/edit-rest.php', array('quizid' => $quizid, 'class' => $class)); @@ -63,6 +63,9 @@ $modcontext = context_module::instance($cm->id); echo $OUTPUT->header(); // Send headers. +// All these AJAX actions should be logically atomic. +$transaction = $DB->start_delegated_transaction(); + // OK, now let's process the parameters and do stuff // MDL-10221 the DELETE method is not allowed on some web servers, // so we simulate it with the action URL param. @@ -71,6 +74,8 @@ if ($pageaction == 'DELETE') { $requestmethod = 'DELETE'; } +$result = null; + switch($requestmethod) { case 'POST': case 'GET': // For debugging. @@ -81,17 +86,17 @@ switch($requestmethod) { switch ($field) { case 'getsectiontitle': require_capability('mod/quiz:manage', $modcontext); - echo json_encode(array('instancesection' => $section->heading)); + $result = array('instancesection' => $section->heading); break; case 'updatesectiontitle': require_capability('mod/quiz:manage', $modcontext); $structure->set_section_heading($id, $newheading); - echo json_encode(array('instancesection' => format_string($newheading))); + $result = array('instancesection' => format_string($newheading)); break; case 'updateshufflequestions': require_capability('mod/quiz:manage', $modcontext); $structure->set_section_shuffle($id, $shuffle); - echo json_encode(array('instanceshuffle' => $section->shufflequestions)); + $result = array('instanceshuffle' => $section->shufflequestions); break; } break; @@ -109,14 +114,13 @@ switch($requestmethod) { } $structure->move_slot($id, $previousid, $page); quiz_delete_previews($quiz); - echo json_encode(array('visible' => true)); + $result = array('visible' => true); break; case 'getmaxmark': require_capability('mod/quiz:manage', $modcontext); $slot = $DB->get_record('quiz_slots', array('id' => $id), '*', MUST_EXIST); - echo json_encode(array('instancemaxmark' => - quiz_format_question_grade($quiz, $slot->maxmark))); + $result = array('instancemaxmark' => quiz_format_question_grade($quiz, $slot->maxmark)); break; case 'updatemaxmark': @@ -130,8 +134,8 @@ switch($requestmethod) { quiz_update_all_final_grades($quiz); quiz_update_grades($quiz, 0, true); } - echo json_encode(array('instancemaxmark' => quiz_format_question_grade($quiz, $maxmark), - 'newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades))); + $result = array('instancemaxmark' => quiz_format_question_grade($quiz, $maxmark), + 'newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades)); break; case 'updatepagebreak': @@ -142,24 +146,25 @@ switch($requestmethod) { $json[$slot->slot] = array('id' => $slot->id, 'slot' => $slot->slot, 'page' => $slot->page); } - echo json_encode(array('slots' => $json)); + $result = array('slots' => $json); break; - case 'bulkdelete': + case 'deletemultiple': require_capability('mod/quiz:manage', $modcontext); - $bulkslots = explode(',', $bulkslots); - rsort($bulkslots); // Work backwards, since removing a question renumbers following slots. - - foreach ($bulkslots as $slot) { - if (quiz_has_question_use($quiz, $slot)) { - $structure->remove_slot($slot); + $ids = explode(',', $ids); + foreach ($ids as $id) { + $slot = $DB->get_record('quiz_slots', array('quizid' => $quiz->id, 'id' => $id), + '*', MUST_EXIST); + if (quiz_has_question_use($quiz, $slot->slot)) { + $structure->remove_slot($slot->slot); } } quiz_delete_previews($quiz); quiz_update_sumgrades($quiz); - echo json_encode(array('deleted' => true)); + $result = array('newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades), + 'deleted' => true, 'newnumquestions' => $structure->get_question_count()); break; case 'updatedependency': @@ -167,7 +172,7 @@ switch($requestmethod) { $slot = $structure->get_slot_by_id($id); $value = (bool) $value; $structure->update_question_dependency($slot->id, $value); - echo json_encode(array('requireprevious' => $value)); + $result = array('requireprevious' => $value); break; } break; @@ -179,7 +184,7 @@ switch($requestmethod) { case 'section': require_capability('mod/quiz:manage', $modcontext); $structure->remove_section_heading($id); - echo json_encode(array('deleted' => true)); + $result = array('deleted' => true); break; case 'resource': @@ -190,9 +195,12 @@ switch($requestmethod) { $structure->remove_slot($slot->slot); quiz_delete_previews($quiz); quiz_update_sumgrades($quiz); - echo json_encode(array('newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades), - 'deleted' => true, 'newnumquestions' => $structure->get_question_count())); + $result = array('newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades), + 'deleted' => true, 'newnumquestions' => $structure->get_question_count()); break; } break; } + +$transaction->allow_commit(); +echo json_encode($result); diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index 5287c995ee0..fac4f4f5b8d 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -121,7 +121,6 @@ $string['browsersecurity_help'] = 'If "Full screen pop-up with some JavaScript s * The quiz will only start if the student has a JavaScript-enabled web-browser * The quiz appears in a full screen popup window that covers all the other windows and has no navigation controls * Students are prevented, as far as is possible, from using facilities like copy and paste'; -$string['bulkactions'] = 'Bulk actions'; $string['calculated'] = 'Calculated'; $string['calculatedquestion'] = 'Calculated question not supported at line {$a}. The question will be ignored'; $string['cannotcreatepath'] = 'Path cannot be created ({$a})'; @@ -817,6 +816,8 @@ $string['select'] = 'Select'; $string['selectall'] = 'Select all'; $string['selectcategory'] = 'Select category'; $string['selectedattempts'] = 'Selected attempts...'; +$string['selectmultipleitems'] = 'Select multiple items'; +$string['selectmultipletoolbar'] = 'Select multiple toolbar'; $string['selectnone'] = 'Deselect all'; $string['selectquestiontype'] = '-- Select question type --'; $string['serveradded'] = 'Server added'; diff --git a/mod/quiz/styles.css b/mod/quiz/styles.css index ae06a0abad9..37316e7148e 100644 --- a/mod/quiz/styles.css +++ b/mod/quiz/styles.css @@ -633,10 +633,18 @@ table.quizreviewsummary td.cell { margin: 4px 0; } +#page-mod-quiz-edit .mod_quiz-edit-top-controls { + position: relative; +} +#page-mod-quiz-edit .mod_quiz-edit-action-buttons { + display: block; + min-height: 2.85em; +} + #page-mod-quiz-edit .maxgrade, #page-mod-quiz-edit .totalpoints { - display: block; - float: right; + position: absolute; + right: 0; margin: -2.85em 0 0; padding: .2em; } @@ -644,6 +652,9 @@ table.quizreviewsummary td.cell { #page-mod-quiz-edit .maxgrade label { display: inline; } +#page-mod-quiz-edit .maxgrade input[type="submit"] { + margin: 0; +} #page-mod-quiz-edit li.activity > div, #page-mod-quiz-edit li.pagenumber { @@ -879,6 +890,10 @@ table.quizreviewsummary td.cell { width: 100%; } +#page-mod-quiz-edit ul.slots li.section li.activity .mod-indent-outer { + padding-left: 22px; +} + #page-mod-quiz-edit ul.slots .activityinstance form { display: inline; } @@ -1115,58 +1130,72 @@ table#categoryquestions { /* Bulk edit actions */ -.bulkactioncommandbuttons { +.selectmultiplecommandbuttons { margin: 0.6em 0.4em; } -.bulkactioncommand, -.bulkactioncommandbuttons, -.quiz-question-bulk-selector { +.btn-group.selectmultiplecommand, +.btn-group.selectmultiplecommandbuttons, +.select-multiple-checkbox { display: none; } -body.quiz-bulk-action-mode .bulkactioncommand, -body.quiz-bulk-action-mode .bulkactioncommandbuttons, -body.quiz-bulk-action-mode .quiz-question-bulk-selector { +#page-mod-quiz-edit.select-multiple .selectmultiplecommand, +#page-mod-quiz-edit.select-multiple .selectmultiplecommandbuttons, +#page-mod-quiz-edit.select-multiple .select-multiple-checkbox { display: inherit; } -body.quiz-bulk-action-mode input.quiz-question-bulk-selector[type="checkbox"] { +#page-mod-quiz-edit.select-multiple .selectmultiplecommandbuttons .separator { + position: relative; + float: left; + padding: .5rem 0; +} + +#page-mod-quiz-edit #questionselectall { + padding-right: .1rem; +} + +#page-mod-quiz-edit #questiondeselectall { + padding-left: .1rem; +} + +#page-mod-quiz-edit.select-multiple input.select-multiple-checkbox[type="checkbox"] { display: inline; } -body.quiz-bulk-action-mode .mod-quiz-edit-content .section .activity .editing_move, -body.quiz-bulk-action-mode .mod-quiz-edit-content .section .activity .commands { +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section .activity .editing_move, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section .activity .commands { display: none; } -body.quiz-bulk-action-mode .mod-quiz-edit-content .section .page_split_join_wrapper { +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section .page_split_join_wrapper { display: none; } -body.quiz-bulk-action-mode .mod-quiz-edit-content .section .activity .actions { +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section .activity .actions .editing_delete, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section .activity .actions .editing_maxmark { display: none; } -body.quiz-bulk-action-mode#page-mod-quiz-edit .maxgrade, -body.quiz-bulk-action-mode#page-mod-quiz-edit .totalpoints, -body.quiz-bulk-action-mode .mod-quiz-edit-content .last-add-menu { +#page-mod-quiz-edit.select-multiple#page-mod-quiz-edit .maxgrade, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .last-add-menu { display: none; } -body.quiz-bulk-action-mode .mod-quiz-edit-content .section-heading, -body.quiz-bulk-action-mode .mod-quiz-edit-content .section-heading form, -body.quiz-bulk-action-mode .mod-quiz-edit-content .section-heading .instancesectioncontainer, -body.quiz-bulk-action-mode .mod-quiz-edit-content .section-heading .instanceshufflequestions, -body.quiz-bulk-action-mode .mod-quiz-edit-content .section-heading .instancesectioncontainer h3 { +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section-heading, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section-heading form, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section-heading .instancesectioncontainer, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section-heading .instanceshufflequestions, +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .section-heading .instancesectioncontainer h3 { display: none; } -body.quiz-bulk-action-mode .mod-quiz-edit-content .rpcontainerclass { +#page-mod-quiz-edit.select-multiple .mod-quiz-edit-content .edit-toolbar .m-b-1 { display: none; } -body.quiz-bulk-action-mode#page-mod-quiz-edit ul.slots li.section li.activity .mod-indent-outer { +#page-mod-quiz-edit.select-multiple#page-mod-quiz-edit ul.slots li.section li.activity .mod-indent-outer { padding-left: 3px; } @@ -1236,18 +1265,3 @@ body.quiz-bulk-action-mode#page-mod-quiz-edit ul.slots li.section li.activity .m page-break-inside: avoid; } } -/* Ajustments for mobile devices */ - -@media only screen and (max-width: 565px) { - #page-mod-quiz-edit .rpcontainerclass { - margin-top: 3em; - } - - #page-mod-quiz-edit .maxgrade { - margin-top: 0.1em; - } - - #page-mod-quiz-edit .statusbar { - padding: 0; - } -} diff --git a/mod/quiz/tests/behat/editing_remove_multiple_questions.feature b/mod/quiz/tests/behat/editing_remove_multiple_questions.feature new file mode 100644 index 00000000000..961f10699b3 --- /dev/null +++ b/mod/quiz/tests/behat/editing_remove_multiple_questions.feature @@ -0,0 +1,170 @@ +@mod @mod_quiz +Feature: Edit quiz page - remove multiple questions + In order to change the layout of a quiz I built efficiently + As a teacher + I need to be able to delete many questions questions. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | T1 | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "activities" exist: + | activity | name | course | idnumber | + | quiz | Quiz 1 | C1 | quiz1 | + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Quiz 1" + + @javascript + Scenario: Delete selected question using select multiple items feature. + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | Question A | This is question 01 | + | Test questions | truefalse | Question B | This is question 02 | + | Test questions | truefalse | Question C | This is question 03 | + And quiz "Quiz 1" contains the following questions: + | question | page | + | Question A | 1 | + | Question B | 1 | + | Question C | 2 | + And I navigate to "Edit quiz" in current page administration + + # Confirm the starting point. + Then I should see "Question A" on quiz page "1" + 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. No reordering. + When I click on "Select multiple items" "button" + Then I click on "selectquestion-3" "checkbox" + And I click on "Delete selected" "button" + And I click on "Yes" "button" in the "Confirm" "dialogue" + + 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" + + @javascript + Scenario: Delete first selected question using select multiple items feature. + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | Question A | This is question 01 | + | Test questions | truefalse | Question B | This is question 02 | + | Test questions | truefalse | Question C | This is question 03 | + And quiz "Quiz 1" contains the following questions: + | question | page | + | Question A | 1 | + | Question B | 2 | + | Question C | 2 | + And I navigate to "Edit quiz" in current page administration + + # Confirm the starting point. + Then I should see "Question A" on quiz page "1" + And I should see "Question B" on quiz page "2" + 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 first question in first page. Page contains multiple questions. No reordering. + When I click on "Select multiple items" "button" + Then I click on "selectquestion-1" "checkbox" + And I click on "Delete selected" "button" + And I click on "Yes" "button" in the "Confirm" "dialogue" + + Then I should not see "Question A" on quiz page "1" + And I should see "Question B" on quiz page "1" + And I should see "Question C" on quiz page "1" + And I should see "Total of marks: 2.00" + And I should see "Questions: 2" + + @javascript + Scenario: Can delete the last question in a quiz. + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | Question A | This is question 01 | + And quiz "Quiz 1" contains the following questions: + | question | page | + | Question A | 1 | + When I navigate to "Edit quiz" in current page administration + And I click on "Select multiple items" "button" + And I click on "selectquestion-1" "checkbox" + And I click on "Delete selected" "button" + And I click on "Yes" "button" in the "Confirm" "dialogue" + Then I should see "Questions: 0" + + @javascript + Scenario: Delete all questions by checking select all. + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | Question A | This is question 01 | + | Test questions | truefalse | Question B | This is question 02 | + | Test questions | truefalse | Question C | This is question 03 | + And quiz "Quiz 1" contains the following questions: + | question | page | + | Question A | 1 | + | Question B | 1 | + | Question C | 2 | + And I navigate to "Edit quiz" in current page administration + + # Confirm the starting point. + Then I should see "Question A" on quiz page "1" + 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 all questions in page. Page contains multiple questions + When I click on "Select multiple items" "button" + Then I click on "Select all" "link" + And I click on "Delete selected" "button" + And I click on "Yes" "button" in the "Confirm" "dialogue" + + Then I should not see "Question A" on quiz page "1" + And I should not 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: 0.00" + And I should see "Questions: 0" + + @javascript + Scenario: Deselect all questions by checking deselect all. + Given the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | Question A | This is question 01 | + | Test questions | truefalse | Question B | This is question 02 | + | Test questions | truefalse | Question C | This is question 03 | + And quiz "Quiz 1" contains the following questions: + | question | page | + | Question A | 1 | + | Question B | 1 | + | Question C | 2 | + And I navigate to "Edit quiz" in current page administration + + # Confirm the starting point. + Then I should see "Question A" on quiz page "1" + And I should see "Question B" on quiz page "1" + And I should see "Question C" on quiz page "2" + + # Delete last question in last page. Page contains multiple questions + When I click on "Select multiple items" "button" + And I click on "Select all" "link" + Then the field "selectquestion-3" matches value "1" + + When I click on "Deselect all" "link" + Then the field "selectquestion-3" matches value "0" + diff --git a/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-debug.js b/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-debug.js index 99092602a90..ad23f7a040d 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-debug.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-debug.js @@ -25,7 +25,6 @@ YUI.add('moodle-mod_quiz-repaginate', function (Y, NAME) { */ var CSS = { - REPAGINATECONTAINERCLASS: '.rpcontainerclass', REPAGINATECOMMAND: '#repaginatecommand' }; @@ -44,12 +43,12 @@ Y.extend(POPUP, Y.Base, { body: null, initializer: function() { - var rpcontainerclass = Y.one(CSS.REPAGINATECONTAINERCLASS); + var repaginatebutton = Y.one(CSS.REPAGINATECOMMAND); // Set popup header and body. - this.header = rpcontainerclass.getAttribute(PARAMS.HEADER); - this.body = rpcontainerclass.getAttribute(PARAMS.FORM); - Y.one(CSS.REPAGINATECOMMAND).on('click', this.display_dialog, this); + this.header = repaginatebutton.getData(PARAMS.HEADER); + this.body = repaginatebutton.getData(PARAMS.FORM); + repaginatebutton.on('click', this.display_dialog, this); }, display_dialog: function(e) { diff --git a/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-min.js b/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-min.js index 700c79f0526..9830b4a01b8 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-min.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate-min.js @@ -1 +1 @@ -YUI.add("moodle-mod_quiz-repaginate",function(e,t){var n={REPAGINATECONTAINERCLASS:".rpcontainerclass",REPAGINATECOMMAND:"#repaginatecommand"},r={CMID:"cmid",HEADER:"header",FORM:"form"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,e.Base,{header:null,body:null,initializer:function(){var t=e.one(n.REPAGINATECONTAINERCLASS);this.header=t.getAttribute(r.HEADER),this.body=t.getAttribute(r.FORM),e.one(n.REPAGINATECOMMAND).on("click",this.display_dialog,this)},display_dialog:function(e){e.preventDefault();var t={headerContent:this.header,bodyContent:this.body,draggable:!0,modal:!0,zIndex:1e3,context:[n.REPAGINATECOMMAND,"tr","br",["beforeShow"]],centered:!1,width:"30em",visible:!1,postmethod:"form",footerContent:null},r={dialog:null};r.dialog=new M.core.dialogue(t),r.dialog.show()}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.repaginate=M.mod_quiz.repaginate||{},M.mod_quiz.repaginate.init=function(){return new i}},"@VERSION@",{requires:["base","event","node","io","moodle-core-notification-dialogue"]}); +YUI.add("moodle-mod_quiz-repaginate",function(e,t){var n={REPAGINATECOMMAND:"#repaginatecommand"},r={CMID:"cmid",HEADER:"header",FORM:"form"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,e.Base,{header:null,body:null,initializer:function(){var t=e.one(n.REPAGINATECOMMAND);this.header=t.getData(r.HEADER),this.body=t.getData(r.FORM),t.on("click",this.display_dialog,this)},display_dialog:function(e){e.preventDefault();var t={headerContent:this.header,bodyContent:this.body,draggable:!0,modal:!0,zIndex:1e3,context:[n.REPAGINATECOMMAND,"tr","br",["beforeShow"]],centered:!1,width:"30em",visible:!1,postmethod:"form",footerContent:null},r={dialog:null};r.dialog=new M.core.dialogue(t),r.dialog.show()}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.repaginate=M.mod_quiz.repaginate||{},M.mod_quiz.repaginate.init=function(){return new i}},"@VERSION@",{requires:["base","event","node","io","moodle-core-notification-dialogue"]}); diff --git a/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate.js b/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate.js index 99092602a90..ad23f7a040d 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-repaginate/moodle-mod_quiz-repaginate.js @@ -25,7 +25,6 @@ YUI.add('moodle-mod_quiz-repaginate', function (Y, NAME) { */ var CSS = { - REPAGINATECONTAINERCLASS: '.rpcontainerclass', REPAGINATECOMMAND: '#repaginatecommand' }; @@ -44,12 +43,12 @@ Y.extend(POPUP, Y.Base, { body: null, initializer: function() { - var rpcontainerclass = Y.one(CSS.REPAGINATECONTAINERCLASS); + var repaginatebutton = Y.one(CSS.REPAGINATECOMMAND); // Set popup header and body. - this.header = rpcontainerclass.getAttribute(PARAMS.HEADER); - this.body = rpcontainerclass.getAttribute(PARAMS.FORM); - Y.one(CSS.REPAGINATECOMMAND).on('click', this.display_dialog, this); + this.header = repaginatebutton.getData(PARAMS.HEADER); + this.body = repaginatebutton.getData(PARAMS.FORM); + repaginatebutton.on('click', this.display_dialog, this); }, display_dialog: function(e) { diff --git a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js index bfa9f11a329..84ad28b5663 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-debug.js @@ -28,6 +28,7 @@ var CSS = { PAGE: 'page', SECTIONHIDDENCLASS: 'hidden', SECTIONIDPREFIX: 'section-', + SELECTMULTIPLE: 'select-multiple', SLOT: 'slot', SHOW: 'editing_show', TITLEEDITOR: 'titleeditor' @@ -45,7 +46,8 @@ var CSS = { COMMANDSPAN: '.commands', CONTENTAFTERLINK: 'div.contentafterlink', CONTENTWITHOUTLINK: 'div.contentwithoutlink', - DELETESECTIONICON: 'a.editing_delete .icon', + DELETESECTIONICON: 'a.editing_delete img', + DESELECTALL: '#questiondeselectall', EDITMAXMARK: 'a.editing_maxmark', EDITSECTION: 'a.editing_section', EDITSECTIONICON: 'a.editing_section .icon', @@ -65,6 +67,11 @@ var CSS = { SECTIONUL: 'ul.section', SECTIONFORM: '.instancesectioncontainer form', SECTIONINPUT: 'input[name=section]', + SELECTMULTIPLEBUTTON: '#selectmultiplecommand', + SELECTMULTIPLECANCELBUTTON: '#selectmultiplecancelcommand', + SELECTMULTIPLECHECKBOX: '.select-multiple-checkbox', + SELECTMULTIPLEDELETEBUTTON: '#selectmultipledeletecommand', + SELECTALL: '#questionselectall', SHOW: 'a.' + CSS.SHOW, SLOTLI: 'li.slot', SUMMARKS: '.mod_quiz_summarks' @@ -103,6 +110,7 @@ Y.extend(TOOLBOX, Y.Base, { if (!data) { data = {}; } + // Handle any variables which we must pass back through to var pageparams = this.get('config').pageparams, varname; @@ -289,6 +297,52 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { M.mod_quiz.quizbase.register_module(this); Y.delegate('click', this.handle_data_action, BODY, SELECTOR.ACTIVITYACTION, this); Y.delegate('click', this.handle_data_action, BODY, SELECTOR.DEPENDENCY_LINK, this); + this.initialise_select_multiple(); + }, + + /** + * Initialize the select multiple options + * + * Add actions to the buttons that enable multiple slots to be selected and managed at once. + * + * @method initialise_select_multiple + * @protected + */ + initialise_select_multiple: function() { + // Click select multiple button to show the select all options. + Y.one(SELECTOR.SELECTMULTIPLEBUTTON).on('click', function(e) { + e.preventDefault(); + Y.one('body').addClass(CSS.SELECTMULTIPLE); + }); + + // Click cancel button to show the select all options. + Y.one(SELECTOR.SELECTMULTIPLECANCELBUTTON).on('click', function(e) { + e.preventDefault(); + Y.one('body').removeClass(CSS.SELECTMULTIPLE); + }); + + // Click select all link to check all the checkboxes. + Y.one(SELECTOR.SELECTALL).on('click', function(e) { + e.preventDefault(); + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX).set('checked', 'checked'); + }); + + // Click deselect all link to show the select all checkboxes. + Y.one(SELECTOR.DESELECTALL).on('click', function(e) { + e.preventDefault(); + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX).set('checked', ''); + }); + + // Disable delete multiple button by default. + Y.one(SELECTOR.SELECTMULTIPLEDELETEBUTTON).setAttribute('disabled', 'disabled'); + + // Assign the delete method to the delete multiple button. + Y.delegate('click', this.delete_multiple_with_confirmation, BODY, SELECTOR.SELECTMULTIPLEDELETEBUTTON, this); + + // Enable the delete all button only when at least one slot is selected. + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.SELECTMULTIPLECHECKBOX, this); + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.SELECTALL, this); + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.DESELECTALL, this); }, /** @@ -361,6 +415,22 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { return null; }, + /** + * If a select multiple checkbox is checked enable the buttons in the select multiple + * toolbar otherwise disable it. + * + * @method toggle_select_all_buttons_enabled + */ + toggle_select_all_buttons_enabled: function() { + var checked = Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked'); + var deletebutton = Y.one(SELECTOR.SELECTMULTIPLEDELETEBUTTON); + if (checked && !checked.isEmpty()) { + deletebutton.removeAttribute('disabled'); + } else { + deletebutton.setAttribute('disabled', 'disabled'); + } + }, + /** * Deletes the given activity or resource after confirmation. * @@ -391,7 +461,6 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { // If it is confirmed. confirm.on('complete-yes', function() { - var spinner = this.add_spinner(element); var data = { 'class': 'resource', @@ -410,10 +479,66 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { }); }, this); - - return this; }, + /** + * Deletes the given activities or resources after confirmation. + * + * @protected + * @method delete_multiple_with_confirmation + * @param {EventFacade} ev The event that was fired. + * @chainable + */ + delete_multiple_with_confirmation: function(ev) { + ev.preventDefault(); + + var ids = ''; + var slots = []; + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) { + var slot = Y.Moodle.mod_quiz.util.slot.getSlotFromComponent(node); + ids += ids === '' ? '' : ','; + ids += Y.Moodle.mod_quiz.util.slot.getId(slot); + slots.push(slot); + }); + var element = Y.one('div.mod-quiz-edit-content'); + + // Do nothing if no slots are selected. + if (!slots || !slots.length) { + return; + } + + // Create the confirmation dialogue. + var confirm = new M.core.confirm({ + question: M.util.get_string('areyousureremoveselected', 'quiz'), + modal: true + }); + + // If it is confirmed. + confirm.on('complete-yes', function() { + var spinner = this.add_spinner(element); + var data = { + 'class': 'resource', + field: 'deletemultiple', + ids: ids + }; + // Delete items on server. + this.send_request(data, spinner, function(response) { + // Delete locally if deleted on server. + if (response.deleted) { + // Actually remove the element. + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) { + Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity')); + }); + // Update the page numbers and sections. + this.reorganise_edit_page(); + + // Remove the select multiple options. + Y.one('body').removeClass(CSS.SELECTMULTIPLE); + } + }); + + }, this); + }, /** * Edit the maxmark for the resource @@ -671,82 +796,12 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { 'value': 0 } } + }); M.mod_quiz.resource_toolbox = null; M.mod_quiz.init_resource_toolbox = function(config) { M.mod_quiz.resource_toolbox = new RESOURCETOOLBOX(config); - - var bulkactions = function() { - var CSS = { - QUIZBULKACTIONMODE: 'quiz-bulk-action-mode' - }, - SELECTOR = { - BULKACTIONS: '#bulkactionscommand', - CANCELBULKACTIONS: '#bulkactionscancelcommand', - SELECTALL: '#questionselectall', - DELETEACTION: '#bulkactionsdeletecommand', - DESELECTALL: '#questiondeselectall', - CHECKBOXES: '.quiz-question-bulk-selector' - - }; - Y.one(SELECTOR.BULKACTIONS).on('click', function(e) { - e.preventDefault(); - Y.one('body').addClass(CSS.QUIZBULKACTIONMODE); - }); - - Y.one(SELECTOR.CANCELBULKACTIONS).on('click', function(e) { - e.preventDefault(); - Y.one('body').removeClass(CSS.QUIZBULKACTIONMODE); - }); - - Y.one(SELECTOR.SELECTALL).on('click', function(e) { - e.preventDefault(); - Y.all(SELECTOR.CHECKBOXES).set('checked', 'checked'); - }); - - Y.one(SELECTOR.DESELECTALL).on('click', function(e) { - e.preventDefault(); - Y.all(SELECTOR.CHECKBOXES).set('checked', ''); - }); - - var submitdeletion = function() { - var slots = ''; - Y.all(SELECTOR.CHECKBOXES + ':checked').each(function(node) { - slots += slots === '' ? '' : ','; - slots += node.get('value'); - }); - var spinnercont = Y.one('div.mod-quiz-edit-content'), - spinner = M.mod_quiz.resource_toolbox.add_spinner(spinnercont), - data = { - 'class': 'resource', - field: 'bulkdelete', - slots: slots - }; - M.mod_quiz.resource_toolbox.send_request(data, spinner, function() { - Y.all(SELECTOR.CHECKBOXES + ':checked').each(function(node) { - node.ancestor('li.activity').remove(true); - }); - }); - }; - - Y.one(SELECTOR.DELETEACTION).on('click', function(e) { - e.preventDefault(); - // Create the confirmation dialogue. - var confirm = new M.core.confirm({ - question: M.util.get_string('areyousureremoveselected', 'quiz'), - modal: true - }); - - // If it is confirmed. - confirm.on('complete-yes', function() { - submitdeletion(); - }, self); - }); - }; - - bulkactions(); - return M.mod_quiz.resource_toolbox; }; /* global TOOLBOX, BODY, SELECTOR */ diff --git a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js index 81b8ec07fdd..958a11d9ca1 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes-min.js @@ -1,3 +1,3 @@ -YUI.add("moodle-mod_quiz-toolboxes",function(e,t){var n={ACTIVITYINSTANCE:"activityinstance",AVAILABILITYINFODIV:"div.availabilityinfo",CONTENTWITHOUTLINK:"contentwithoutlink",CONDITIONALHIDDEN:"conditionalhidden",DIMCLASS:"dimmed",DIMMEDTEXT:"dimmed_text",EDITINSTRUCTIONS:"editinstructions",EDITINGMAXMARK:"editor_displayed",HIDE:"hide",JOIN:"page_join",MODINDENTCOUNT:"mod-indent-",MODINDENTHUGE:"mod-indent-huge",PAGE:"page",SECTIONHIDDENCLASS:"hidden",SECTIONIDPREFIX:"section-",SLOT:"slot",SHOW:"editing_show",TITLEEDITOR:"titleeditor"},r={ACTIONAREA:".actions",ACTIONLINKTEXT:".actionlinktext",ACTIVITYACTION:"a.cm-edit-action[data-action], a.editing_maxmark, a.editing_section, input.shuffle_questions",ACTIVITYFORM:"span.instancemaxmarkcontainer form",ACTIVITYINSTANCE:"."+n.ACTIVITYINSTANCE,SECTIONINSTANCE:".sectioninstance",ACTIVITYLI:"li.activity, li.section",ACTIVITYMAXMARK:"input[name=maxmark]",COMMANDSPAN:".commands",CONTENTAFTERLINK:"div.contentafterlink",CONTENTWITHOUTLINK:"div.contentwithoutlink",DELETESECTIONICON:"a.editing_delete img",EDITMAXMARK:"a.editing_maxmark",EDITSECTION:"a.editing_section",EDITSECTIONICON:"a.editing_section img",EDITSHUFFLEQUESTIONSACTION:"input.cm-edit-action[data-action]",EDITSHUFFLEAREA:".instanceshufflequestions .shuffle-progress",HIDE:"a.editing_hide",HIGHLIGHT:"a.editing_highlight",INSTANCENAME:"span.instancename",INSTANCEMAXMARK:"span.instancemaxmark",INSTANCESECTION:"span.instancesection",INSTANCESECTIONAREA:"div.section-heading",MODINDENTDIV:".mod-indent",MODINDENTOUTER:".mod-indent-outer",NUMQUESTIONS:".numberofquestions",PAGECONTENT:"div#page-content",PAGELI:"li.page",SECTIONUL:"ul.section",SECTIONFORM:".instancesectioncontainer form",SECTIONINPUT:"input[name=section]",SHOW:"a."+n.SHOW,SLOTLI:"li.slot",SUMMARKS:".mod_quiz_summarks"},i=e.one(document.body);M.mod_quiz=M.mod_quiz||{};var s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,e.Base,{send_request:function(t,n,i,s){t||(t={});var o=this.get("config").pageparams,u;for(u in o)t[u]=o[u];t.sesskey=M.cfg.sesskey,t.courseid=this.get("courseid"),t.quizid=this.get("quizid");var a=M.cfg.wwwroot+this.get("ajaxurl"),f=[],l={method:"POST",data:t,on:{success:function(t,s){try{f=e.JSON.parse(s.responseText),f.error&&new M.core.ajaxException(f)}catch(o){}f.hasOwnProperty("newsummarks")&&e.one(r.SUMMARKS).setHTML(f.newsummarks),f.hasOwnProperty("newnumquestions")&&e.one(r.NUMQUESTIONS).setHTML(M.util.get_string("numquestionsx","quiz",f.newnumquestions)),i&&e.bind(i,this,f)(),n&&window.setTimeout(function(){n.hide()},400)},failure:function(e,t){n&&n.hide(),new M.core.ajaxException(t)}},context:this};if(s)for(u in s)l[u]=s[u];return n&&n.show(),e.io(a,l),this}},{NAME:"mod_quiz-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0},ajaxurl:{value:null},config:{value:{}}}});var o=function(){o.superclass.constructor.apply(this,arguments)};e.extend(o,s,{editmaxmarkevents:[],NODE_PAGE:1,NODE_SLOT:2,NODE_JOIN:3,initializer:function(){M.mod_quiz.quizbase.register_module(this),e.delegate("click",this.handle_data_action,i,r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,i,r.DEPENDENCY_LINK,this)},handle_data_action:function(e){var t=e.target;t.test("a")||(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")||!n||!i)return;switch(n){case"editmaxmark":this.edit_maxmark(e,t,i,n);break;case"delete":this.delete_with_confirmation(e,t,i,n);break;case"addpagebreak":case"removepagebreak":this.update_page_break(e,t,i,n);break;case"adddependency":case"removedependency":this.update_dependency(e,t,i,n);break;default:}},add_spinner:function(t){var n=t.one(r.ACTIONAREA);return n?M.util.add_spinner(e,n):null},delete_with_confirmation:function(t,n,r){t.preventDefault();var i=r,s="",o=M.util.get_string("pluginname","qtype_"+i.getAttribute("class").match(/qtype_([^\s]*)/)[1]);s=M.util.get_string("confirmremovequestion","quiz",o);var u=new M.core.confirm({question:s,modal:!0});return u.on("complete-yes",function(){var n=this.add_spinner(i),r={"class":"resource",action:"DELETE",id:e.Moodle.mod_quiz.util.slot.getId(i)};this.send_request(r,n,function(n){n.deleted&&(e.Moodle.mod_quiz.util.slot.remove(i),this.reorganise_edit_page(),M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t))})},this),this},edit_maxmark:function(t,i,s){var o=s.one(r.INSTANCEMAXMARK),u=s.one(r.ACTIVITYINSTANCE),a=o.get("firstChild"),f=a.get("data"),l=f,c,h=o,p={"class":"resource",field:"getmaxmark",id:e.Moodle.mod_quiz.util.slot.getId(s)};t.preventDefault(),this.send_request(p,null,function(r){M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t),r.instancemaxmark&&(l=r.instancemaxmark);var i=e.Node.create('
'),o=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),a=e.Node.create('').setAttrs({value:l,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"12",size:parseInt(this.get("config").questiondecimalpoints,10)+2});i.appendChild(a),i.setData("anchor",h),u.insert(o,"before"),h.replace(i),s.addClass(n.EDITINGMAXMARK),a.focus().select(),c=a.on("blur",this.edit_maxmark_cancel,this,s,!1),this.editmaxmarkevents.push(c),c=a.on("key",this.edit_maxmark_cancel,"esc",this,s,!0),this.editmaxmarkevents.push(c),c=i.on("submit",this.edit_maxmark_submit,this,s,f),this.editmaxmarkevents.push(c)})},edit_maxmark_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.ACTIVITYFORM+" "+r.ACTIVITYMAXMARK).get("value")),o=this.add_spinner(n);this.edit_maxmark_clear(n),n.one(r.INSTANCEMAXMARK).setContent(s);if(s!==null&&s!==""&&s!==i){var u={"class":"resource",field:"updatemaxmark",maxmark:s,id:e.Moodle.mod_quiz.util.slot.getId(n)};this.send_request(u,o,function(e){e.instancemaxmark&&n.one(r.INSTANCEMAXMARK).setContent(e.instancemaxmark -)})}},edit_maxmark_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_maxmark_clear(t)},edit_maxmark_clear:function(t){(new e.EventHandle(this.editmaxmarkevents)).detach();var i=t.one(r.ACTIVITYFORM),s=t.one("#id_editinstructions");i&&i.replace(i.getData("anchor")),s&&s.remove(),t.removeClass(n.EDITINGMAXMARK),e.later(100,this,function(){t.one(r.EDITMAXMARK).focus()}),e.one("input[name=maxmark")||e.one("body").append('')},update_page_break:function(t,n,r,i){t.preventDefault();var s=r.next("li.activity.slot"),o=this.add_spinner(s),u=i==="removepagebreak"?1:2,a={"class":"resource",field:"updatepagebreak",id:e.Moodle.mod_quiz.util.slot.getId(s),value:u};return this.send_request(a,o,function(t){if(t.slots){if(i==="addpagebreak")e.Moodle.mod_quiz.util.page.add(r);else{var n=r.next(e.Moodle.mod_quiz.util.page.SELECTORS.PAGE);e.Moodle.mod_quiz.util.page.remove(n,!0)}this.reorganise_edit_page()}}),this},update_dependency:function(t,n,r,i){t.preventDefault();var s=this.add_spinner(r),o={"class":"resource",field:"updatedependency",id:e.Moodle.mod_quiz.util.slot.getId(r),value:i==="adddependency"?1:0};return this.send_request(o,s,function(t){t.hasOwnProperty("requireprevious")&&e.Moodle.mod_quiz.util.slot.updateDependencyIcon(r,t.requireprevious)}),this},reorganise_edit_page:function(){e.Moodle.mod_quiz.util.slot.reorderSlots(),e.Moodle.mod_quiz.util.slot.reorderPageBreaks(),e.Moodle.mod_quiz.util.page.reorderPages(),e.Moodle.mod_quiz.util.slot.updateOneSlotSections(),e.Moodle.mod_quiz.util.slot.updateAllDependencyIcons()},NAME:"mod_quiz-resource-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0}}}),M.mod_quiz.resource_toolbox=null,M.mod_quiz.init_resource_toolbox=function(t){M.mod_quiz.resource_toolbox=new o(t);var n=function(){var t={QUIZBULKACTIONMODE:"quiz-bulk-action-mode"},n={BULKACTIONS:"#bulkactionscommand",CANCELBULKACTIONS:"#bulkactionscancelcommand",SELECTALL:"#questionselectall",DELETEACTION:"#bulkactionsdeletecommand",DESELECTALL:"#questiondeselectall",CHECKBOXES:".quiz-question-bulk-selector"};e.one(n.BULKACTIONS).on("click",function(n){n.preventDefault(),e.one("body").addClass(t.QUIZBULKACTIONMODE)}),e.one(n.CANCELBULKACTIONS).on("click",function(n){n.preventDefault(),e.one("body").removeClass(t.QUIZBULKACTIONMODE)}),e.one(n.SELECTALL).on("click",function(t){t.preventDefault(),e.all(n.CHECKBOXES).set("checked","checked")}),e.one(n.DESELECTALL).on("click",function(t){t.preventDefault(),e.all(n.CHECKBOXES).set("checked","")});var r=function(){var t="";e.all(n.CHECKBOXES+":checked").each(function(e){t+=t===""?"":",",t+=e.get("value")});var r=e.one("div.mod-quiz-edit-content"),i=M.mod_quiz.resource_toolbox.add_spinner(r),s={"class":"resource",field:"bulkdelete",slots:t};M.mod_quiz.resource_toolbox.send_request(s,i,function(){e.all(n.CHECKBOXES+":checked").each(function(e){e.ancestor("li.activity").remove(!0)})})};e.one(n.DELETEACTION).on("click",function(e){e.preventDefault();var t=new M.core.confirm({question:M.util.get_string("areyousureremoveselected","quiz"),modal:!0});t.on("complete-yes",function(){r()},self)})};return n(),M.mod_quiz.resource_toolbox};var u=function(){u.superclass.constructor.apply(this,arguments)};e.extend(u,s,{editsectionevents:[],initializer:function(){M.mod_quiz.quizbase.register_module(this),i.delegate("key",this.handle_data_action,"down:enter",r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,i,r.ACTIVITYACTION,this),e.delegate("change",this.handle_data_action,i,r.EDITSHUFFLEQUESTIONSACTION,this)},handle_data_action:function(e){var t=e.target;!t.test("a")&&!t.test("input[data-action]")&&(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")&&!t.test("input[data-action]")||!n||!i)return;switch(n){case"edit_section_title":this.edit_section_title(e,t,i,n);break;case"shuffle_questions":this.edit_shuffle_questions(e,t,i,n);break;case"deletesection":this.delete_section_with_confirmation(e,t,i,n);break;default:}},delete_section_with_confirmation:function(t,n,i){t.preventDefault();var s=new M.core.confirm({question:M.util.get_string("confirmremovesectionheading","quiz",i.get("aria-label")),modal:!0});s.on("complete-yes",function(){var t=M.util.add_spinner(e,i.one(r.ACTIONAREA)),n={"class":"section",action:"DELETE",id:i.get("id").replace("section-","")};this.send_request(n,t,function(e){e.deleted&&window.location.reload(!0)})},this)},edit_section_title:function(t,i,s){var o=s.get("id").replace("section-",""),u=s.one(r.INSTANCESECTION),a,f=u,l={"class":"section",field:"getsectiontitle",id:o};t.preventDefault(),this.send_request(l,null,function(t){var r=t.instancesection,i=e.Node.create(''),o=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),l=e.Node.create('').setAttrs({value:r,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"255"});i.appendChild(l),i.setData("anchor",f),u.insert(o,"before"),f.replace(i),l.focus().select(),a=l.on("blur",this.edit_section_title_cancel,this,s,!1),this.editsectionevents.push(a),a=l.on("key",this.edit_section_title_cancel,"esc",this,s,!0),this.editsectionevents.push(a),a=i.on("submit",this.edit_section_title_submit,this,s,r),this.editsectionevents.push(a)})},edit_section_title_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.SECTIONFORM+" "+r.SECTIONINPUT).get("value")),o=M.util.add_spinner(e,n.one(r.INSTANCESECTIONAREA));this.edit_section_title_clear(n);if(s!==null&&s!==i){n.one(r.INSTANCESECTION).setContent(s);var u={"class":"section",field:"updatesectiontitle",newheading:s,id:n.get("id").replace("section-","")};this.send_request(u,o,function(e){if(e){n.one(r.INSTANCESECTION).setContent(e.instancesection),n.one(r.EDITSECTIONICON).set("title",M.util.get_string("sectionheadingedit","quiz",e.instancesection)),n.one(r.EDITSECTIONICON -).set("alt",M.util.get_string("sectionheadingedit","quiz",e.instancesection));var t=n.one(r.DELETESECTIONICON);t&&(t.set("title",M.util.get_string("sectionheadingremove","quiz",e.instancesection)),t.set("alt",M.util.get_string("sectionheadingremove","quiz",e.instancesection)))}})}},edit_section_title_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_section_title_clear(t)},edit_section_title_clear:function(t){(new e.EventHandle(this.editsectionevents)).detach();var n=t.one(r.SECTIONFORM),i=t.one("#id_editinstructions");n&&n.replace(n.getData("anchor")),i&&i.remove(),e.later(100,this,function(){t.one(r.EDITSECTION).focus()}),e.one("input[name=section]")||e.one("body").append('')},edit_shuffle_questions:function(t,n,i){var s;i.one(r.EDITSHUFFLEQUESTIONSACTION).get("checked")?s=1:s=0;var o={"class":"section",field:"updateshufflequestions",id:i.get("id").replace("section-",""),newshuffle:s};t.preventDefault();var u=M.util.add_spinner(e,i.one(r.EDITSHUFFLEAREA));this.send_request(o,u)}},{NAME:"mod_quiz-section-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0}}}),M.mod_quiz.init_section_toolbox=function(e){return new u(e)}},"@VERSION@",{requires:["base","node","event","event-key","io","moodle-mod_quiz-quizbase","moodle-mod_quiz-util-slot","moodle-core-notification-ajaxexception"]}); +YUI.add("moodle-mod_quiz-toolboxes",function(e,t){var n={ACTIVITYINSTANCE:"activityinstance",AVAILABILITYINFODIV:"div.availabilityinfo",CONTENTWITHOUTLINK:"contentwithoutlink",CONDITIONALHIDDEN:"conditionalhidden",DIMCLASS:"dimmed",DIMMEDTEXT:"dimmed_text",EDITINSTRUCTIONS:"editinstructions",EDITINGMAXMARK:"editor_displayed",HIDE:"hide",JOIN:"page_join",MODINDENTCOUNT:"mod-indent-",MODINDENTHUGE:"mod-indent-huge",PAGE:"page",SECTIONHIDDENCLASS:"hidden",SECTIONIDPREFIX:"section-",SELECTMULTIPLE:"select-multiple",SLOT:"slot",SHOW:"editing_show",TITLEEDITOR:"titleeditor"},r={ACTIONAREA:".actions",ACTIONLINKTEXT:".actionlinktext",ACTIVITYACTION:"a.cm-edit-action[data-action], a.editing_maxmark, a.editing_section, input.shuffle_questions",ACTIVITYFORM:"span.instancemaxmarkcontainer form",ACTIVITYINSTANCE:"."+n.ACTIVITYINSTANCE,SECTIONINSTANCE:".sectioninstance",ACTIVITYLI:"li.activity, li.section",ACTIVITYMAXMARK:"input[name=maxmark]",COMMANDSPAN:".commands",CONTENTAFTERLINK:"div.contentafterlink",CONTENTWITHOUTLINK:"div.contentwithoutlink",DELETESECTIONICON:"a.editing_delete img",DESELECTALL:"#questiondeselectall",EDITMAXMARK:"a.editing_maxmark",EDITSECTION:"a.editing_section",EDITSECTIONICON:"a.editing_section .icon",EDITSHUFFLEQUESTIONSACTION:"input.cm-edit-action[data-action]",EDITSHUFFLEAREA:".instanceshufflequestions .shuffle-progress",HIDE:"a.editing_hide",HIGHLIGHT:"a.editing_highlight",INSTANCENAME:"span.instancename",INSTANCEMAXMARK:"span.instancemaxmark",INSTANCESECTION:"span.instancesection",INSTANCESECTIONAREA:"div.section-heading",MODINDENTDIV:".mod-indent",MODINDENTOUTER:".mod-indent-outer",NUMQUESTIONS:".numberofquestions",PAGECONTENT:"div#page-content",PAGELI:"li.page",SECTIONUL:"ul.section",SECTIONFORM:".instancesectioncontainer form",SECTIONINPUT:"input[name=section]",SELECTMULTIPLEBUTTON:"#selectmultiplecommand",SELECTMULTIPLECANCELBUTTON:"#selectmultiplecancelcommand",SELECTMULTIPLECHECKBOX:".select-multiple-checkbox",SELECTMULTIPLEDELETEBUTTON:"#selectmultipledeletecommand",SELECTALL:"#questionselectall",SHOW:"a."+n.SHOW,SLOTLI:"li.slot",SUMMARKS:".mod_quiz_summarks"},i=e.one(document.body);M.mod_quiz=M.mod_quiz||{};var s=function(){s.superclass.constructor.apply(this,arguments)};e.extend(s,e.Base,{send_request:function(t,n,i,s){t||(t={});var o=this.get("config").pageparams,u;for(u in o)t[u]=o[u];t.sesskey=M.cfg.sesskey,t.courseid=this.get("courseid"),t.quizid=this.get("quizid");var a=M.cfg.wwwroot+this.get("ajaxurl"),f=[],l={method:"POST",data:t,on:{success:function(t,s){try{f=e.JSON.parse(s.responseText),f.error&&new M.core.ajaxException(f)}catch(o){}f.hasOwnProperty("newsummarks")&&e.one(r.SUMMARKS).setHTML(f.newsummarks),f.hasOwnProperty("newnumquestions")&&e.one(r.NUMQUESTIONS).setHTML(M.util.get_string("numquestionsx","quiz",f.newnumquestions)),i&&e.bind(i,this,f)(),n&&window.setTimeout(function(){n.hide()},400)},failure:function(e,t){n&&n.hide(),new M.core.ajaxException(t)}},context:this};if(s)for(u in s)l[u]=s[u];return n&&n.show(),e.io(a,l),this}},{NAME:"mod_quiz-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0},ajaxurl:{value:null},config:{value:{}}}});var o=function(){o.superclass.constructor.apply(this,arguments)};e.extend(o,s,{editmaxmarkevents:[],NODE_PAGE:1,NODE_SLOT:2,NODE_JOIN:3,initializer:function(){M.mod_quiz.quizbase.register_module(this),e.delegate("click",this.handle_data_action,i,r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,i,r.DEPENDENCY_LINK,this),this.initialise_select_multiple()},initialise_select_multiple:function(){e.one(r.SELECTMULTIPLEBUTTON).on("click",function(t){t.preventDefault(),e.one("body").addClass(n.SELECTMULTIPLE)}),e.one(r.SELECTMULTIPLECANCELBUTTON).on("click",function(t){t.preventDefault(),e.one("body").removeClass(n.SELECTMULTIPLE)}),e.one(r.SELECTALL).on("click",function(t){t.preventDefault(),e.all(r.SELECTMULTIPLECHECKBOX).set("checked","checked")}),e.one(r.DESELECTALL).on("click",function(t){t.preventDefault(),e.all(r.SELECTMULTIPLECHECKBOX).set("checked","")}),e.one(r.SELECTMULTIPLEDELETEBUTTON).setAttribute("disabled","disabled"),e.delegate("click",this.delete_multiple_with_confirmation,i,r.SELECTMULTIPLEDELETEBUTTON,this),e.delegate("click",this.toggle_select_all_buttons_enabled,i,r.SELECTMULTIPLECHECKBOX,this),e.delegate("click",this.toggle_select_all_buttons_enabled,i,r.SELECTALL,this),e.delegate("click",this.toggle_select_all_buttons_enabled,i,r.DESELECTALL,this)},handle_data_action:function(e){var t=e.target;t.test("a")||(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")||!n||!i)return;switch(n){case"editmaxmark":this.edit_maxmark(e,t,i,n);break;case"delete":this.delete_with_confirmation(e,t,i,n);break;case"addpagebreak":case"removepagebreak":this.update_page_break(e,t,i,n);break;case"adddependency":case"removedependency":this.update_dependency(e,t,i,n);break;default:}},add_spinner:function(t){var n=t.one(r.ACTIONAREA);return n?M.util.add_spinner(e,n):null},toggle_select_all_buttons_enabled:function(){var t=e.all(r.SELECTMULTIPLECHECKBOX+":checked"),n=e.one(r.SELECTMULTIPLEDELETEBUTTON);t&&!t.isEmpty()?n.removeAttribute("disabled"):n.setAttribute("disabled","disabled")},delete_with_confirmation:function(t,n,r){t.preventDefault();var i=r,s="",o=M.util.get_string("pluginname","qtype_"+i.getAttribute("class").match(/qtype_([^\s]*)/)[1]);s=M.util.get_string("confirmremovequestion","quiz",o);var u=new M.core.confirm({question:s,modal:!0});u.on("complete-yes",function(){var n=this.add_spinner(i),r={"class":"resource",action:"DELETE",id:e.Moodle.mod_quiz.util.slot.getId(i)};this.send_request(r,n,function(n){n.deleted&&(e.Moodle.mod_quiz.util.slot.remove(i),this.reorganise_edit_page(),M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t))})},this)},delete_multiple_with_confirmation:function(t){t.preventDefault();var i="",s=[];e.all(r.SELECTMULTIPLECHECKBOX+":checked").each(function(t){var n=e.Moodle.mod_quiz.util.slot.getSlotFromComponent +(t);i+=i===""?"":",",i+=e.Moodle.mod_quiz.util.slot.getId(n),s.push(n)});var o=e.one("div.mod-quiz-edit-content");if(!s||!s.length)return;var u=new M.core.confirm({question:M.util.get_string("areyousureremoveselected","quiz"),modal:!0});u.on("complete-yes",function(){var t=this.add_spinner(o),s={"class":"resource",field:"deletemultiple",ids:i};this.send_request(s,t,function(t){t.deleted&&(e.all(r.SELECTMULTIPLECHECKBOX+":checked").each(function(t){e.Moodle.mod_quiz.util.slot.remove(t.ancestor("li.activity"))}),this.reorganise_edit_page(),e.one("body").removeClass(n.SELECTMULTIPLE))})},this)},edit_maxmark:function(t,i,s){var o=s.one(r.INSTANCEMAXMARK),u=s.one(r.ACTIVITYINSTANCE),a=o.get("firstChild"),f=a.get("data"),l=f,c,h=o,p={"class":"resource",field:"getmaxmark",id:e.Moodle.mod_quiz.util.slot.getId(s)};t.preventDefault(),this.send_request(p,null,function(r){M.core.actionmenu&&M.core.actionmenu.instance&&M.core.actionmenu.instance.hideMenu(t),r.instancemaxmark&&(l=r.instancemaxmark);var i=e.Node.create(''),o=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),a=e.Node.create('').setAttrs({value:l,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"12",size:parseInt(this.get("config").questiondecimalpoints,10)+2});i.appendChild(a),i.setData("anchor",h),u.insert(o,"before"),h.replace(i),s.addClass(n.EDITINGMAXMARK),a.focus().select(),c=a.on("blur",this.edit_maxmark_cancel,this,s,!1),this.editmaxmarkevents.push(c),c=a.on("key",this.edit_maxmark_cancel,"esc",this,s,!0),this.editmaxmarkevents.push(c),c=i.on("submit",this.edit_maxmark_submit,this,s,f),this.editmaxmarkevents.push(c)})},edit_maxmark_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.ACTIVITYFORM+" "+r.ACTIVITYMAXMARK).get("value")),o=this.add_spinner(n);this.edit_maxmark_clear(n),n.one(r.INSTANCEMAXMARK).setContent(s);if(s!==null&&s!==""&&s!==i){var u={"class":"resource",field:"updatemaxmark",maxmark:s,id:e.Moodle.mod_quiz.util.slot.getId(n)};this.send_request(u,o,function(e){e.instancemaxmark&&n.one(r.INSTANCEMAXMARK).setContent(e.instancemaxmark)})}},edit_maxmark_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_maxmark_clear(t)},edit_maxmark_clear:function(t){(new e.EventHandle(this.editmaxmarkevents)).detach();var i=t.one(r.ACTIVITYFORM),s=t.one("#id_editinstructions");i&&i.replace(i.getData("anchor")),s&&s.remove(),t.removeClass(n.EDITINGMAXMARK),e.later(100,this,function(){t.one(r.EDITMAXMARK).focus()}),e.one("input[name=maxmark")||e.one("body").append('')},update_page_break:function(t,n,r,i){t.preventDefault();var s=r.next("li.activity.slot"),o=this.add_spinner(s),u=i==="removepagebreak"?1:2,a={"class":"resource",field:"updatepagebreak",id:e.Moodle.mod_quiz.util.slot.getId(s),value:u};return this.send_request(a,o,function(t){if(t.slots){if(i==="addpagebreak")e.Moodle.mod_quiz.util.page.add(r);else{var n=r.next(e.Moodle.mod_quiz.util.page.SELECTORS.PAGE);e.Moodle.mod_quiz.util.page.remove(n,!0)}this.reorganise_edit_page()}}),this},update_dependency:function(t,n,r,i){t.preventDefault();var s=this.add_spinner(r),o={"class":"resource",field:"updatedependency",id:e.Moodle.mod_quiz.util.slot.getId(r),value:i==="adddependency"?1:0};return this.send_request(o,s,function(t){t.hasOwnProperty("requireprevious")&&e.Moodle.mod_quiz.util.slot.updateDependencyIcon(r,t.requireprevious)}),this},reorganise_edit_page:function(){e.Moodle.mod_quiz.util.slot.reorderSlots(),e.Moodle.mod_quiz.util.slot.reorderPageBreaks(),e.Moodle.mod_quiz.util.page.reorderPages(),e.Moodle.mod_quiz.util.slot.updateOneSlotSections(),e.Moodle.mod_quiz.util.slot.updateAllDependencyIcons()},NAME:"mod_quiz-resource-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0}}}),M.mod_quiz.resource_toolbox=null,M.mod_quiz.init_resource_toolbox=function(e){return M.mod_quiz.resource_toolbox=new o(e),M.mod_quiz.resource_toolbox};var u=function(){u.superclass.constructor.apply(this,arguments)};e.extend(u,s,{editsectionevents:[],initializer:function(){M.mod_quiz.quizbase.register_module(this),i.delegate("key",this.handle_data_action,"down:enter",r.ACTIVITYACTION,this),e.delegate("click",this.handle_data_action,i,r.ACTIVITYACTION,this),e.delegate("change",this.handle_data_action,i,r.EDITSHUFFLEQUESTIONSACTION,this)},handle_data_action:function(e){var t=e.target;!t.test("a")&&!t.test("input[data-action]")&&(t=t.ancestor(r.ACTIVITYACTION));var n=t.getData("action"),i=t.ancestor(r.ACTIVITYLI);if(!t.test("a")&&!t.test("input[data-action]")||!n||!i)return;switch(n){case"edit_section_title":this.edit_section_title(e,t,i,n);break;case"shuffle_questions":this.edit_shuffle_questions(e,t,i,n);break;case"deletesection":this.delete_section_with_confirmation(e,t,i,n);break;default:}},delete_section_with_confirmation:function(t,n,i){t.preventDefault();var s=new M.core.confirm({question:M.util.get_string("confirmremovesectionheading","quiz",i.get("aria-label")),modal:!0});s.on("complete-yes",function(){var t=M.util.add_spinner(e,i.one(r.ACTIONAREA)),n={"class":"section",action:"DELETE",id:i.get("id").replace("section-","")};this.send_request(n,t,function(e){e.deleted&&window.location.reload(!0)})},this)},edit_section_title:function(t,i,s){var o=s.get("id").replace("section-",""),u=s.one(r.INSTANCESECTION),a,f=u,l={"class":"section",field:"getsectiontitle",id:o};t.preventDefault(),this.send_request(l,null,function(t){var r=t.instancesection,i=e.Node.create(''),o=e.Node.create('').set("innerHTML",M.util.get_string("edittitleinstructions","moodle")),l=e.Node.create('').setAttrs({value:r,autocomplete:"off","aria-describedby":"id_editinstructions",maxLength:"255"});i.appendChild(l),i.setData("anchor",f),u.insert +(o,"before"),f.replace(i),l.focus().select(),a=l.on("blur",this.edit_section_title_cancel,this,s,!1),this.editsectionevents.push(a),a=l.on("key",this.edit_section_title_cancel,"esc",this,s,!0),this.editsectionevents.push(a),a=i.on("submit",this.edit_section_title_submit,this,s,r),this.editsectionevents.push(a)})},edit_section_title_submit:function(t,n,i){t.preventDefault();var s=e.Lang.trim(n.one(r.SECTIONFORM+" "+r.SECTIONINPUT).get("value")),o=M.util.add_spinner(e,n.one(r.INSTANCESECTIONAREA));this.edit_section_title_clear(n);if(s!==null&&s!==i){n.one(r.INSTANCESECTION).setContent(s);var u={"class":"section",field:"updatesectiontitle",newheading:s,id:n.get("id").replace("section-","")};this.send_request(u,o,function(e){if(e){n.one(r.INSTANCESECTION).setContent(e.instancesection),n.one(r.EDITSECTIONICON).set("title",M.util.get_string("sectionheadingedit","quiz",e.instancesection)),n.one(r.EDITSECTIONICON).set("alt",M.util.get_string("sectionheadingedit","quiz",e.instancesection));var t=n.one(r.DELETESECTIONICON);t&&(t.set("title",M.util.get_string("sectionheadingremove","quiz",e.instancesection)),t.set("alt",M.util.get_string("sectionheadingremove","quiz",e.instancesection)))}})}},edit_section_title_cancel:function(e,t,n){n&&e.preventDefault(),this.edit_section_title_clear(t)},edit_section_title_clear:function(t){(new e.EventHandle(this.editsectionevents)).detach();var n=t.one(r.SECTIONFORM),i=t.one("#id_editinstructions");n&&n.replace(n.getData("anchor")),i&&i.remove(),e.later(100,this,function(){t.one(r.EDITSECTION).focus()}),e.one("input[name=section]")||e.one("body").append('')},edit_shuffle_questions:function(t,n,i){var s;i.one(r.EDITSHUFFLEQUESTIONSACTION).get("checked")?s=1:s=0;var o={"class":"section",field:"updateshufflequestions",id:i.get("id").replace("section-",""),newshuffle:s};t.preventDefault();var u=M.util.add_spinner(e,i.one(r.EDITSHUFFLEAREA));this.send_request(o,u)}},{NAME:"mod_quiz-section-toolbox",ATTRS:{courseid:{value:0},quizid:{value:0}}}),M.mod_quiz.init_section_toolbox=function(e){return new u(e)}},"@VERSION@",{requires:["base","node","event","event-key","io","moodle-mod_quiz-quizbase","moodle-mod_quiz-util-slot","moodle-core-notification-ajaxexception"]}); diff --git a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js index bfa9f11a329..84ad28b5663 100644 --- a/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js +++ b/mod/quiz/yui/build/moodle-mod_quiz-toolboxes/moodle-mod_quiz-toolboxes.js @@ -28,6 +28,7 @@ var CSS = { PAGE: 'page', SECTIONHIDDENCLASS: 'hidden', SECTIONIDPREFIX: 'section-', + SELECTMULTIPLE: 'select-multiple', SLOT: 'slot', SHOW: 'editing_show', TITLEEDITOR: 'titleeditor' @@ -45,7 +46,8 @@ var CSS = { COMMANDSPAN: '.commands', CONTENTAFTERLINK: 'div.contentafterlink', CONTENTWITHOUTLINK: 'div.contentwithoutlink', - DELETESECTIONICON: 'a.editing_delete .icon', + DELETESECTIONICON: 'a.editing_delete img', + DESELECTALL: '#questiondeselectall', EDITMAXMARK: 'a.editing_maxmark', EDITSECTION: 'a.editing_section', EDITSECTIONICON: 'a.editing_section .icon', @@ -65,6 +67,11 @@ var CSS = { SECTIONUL: 'ul.section', SECTIONFORM: '.instancesectioncontainer form', SECTIONINPUT: 'input[name=section]', + SELECTMULTIPLEBUTTON: '#selectmultiplecommand', + SELECTMULTIPLECANCELBUTTON: '#selectmultiplecancelcommand', + SELECTMULTIPLECHECKBOX: '.select-multiple-checkbox', + SELECTMULTIPLEDELETEBUTTON: '#selectmultipledeletecommand', + SELECTALL: '#questionselectall', SHOW: 'a.' + CSS.SHOW, SLOTLI: 'li.slot', SUMMARKS: '.mod_quiz_summarks' @@ -103,6 +110,7 @@ Y.extend(TOOLBOX, Y.Base, { if (!data) { data = {}; } + // Handle any variables which we must pass back through to var pageparams = this.get('config').pageparams, varname; @@ -289,6 +297,52 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { M.mod_quiz.quizbase.register_module(this); Y.delegate('click', this.handle_data_action, BODY, SELECTOR.ACTIVITYACTION, this); Y.delegate('click', this.handle_data_action, BODY, SELECTOR.DEPENDENCY_LINK, this); + this.initialise_select_multiple(); + }, + + /** + * Initialize the select multiple options + * + * Add actions to the buttons that enable multiple slots to be selected and managed at once. + * + * @method initialise_select_multiple + * @protected + */ + initialise_select_multiple: function() { + // Click select multiple button to show the select all options. + Y.one(SELECTOR.SELECTMULTIPLEBUTTON).on('click', function(e) { + e.preventDefault(); + Y.one('body').addClass(CSS.SELECTMULTIPLE); + }); + + // Click cancel button to show the select all options. + Y.one(SELECTOR.SELECTMULTIPLECANCELBUTTON).on('click', function(e) { + e.preventDefault(); + Y.one('body').removeClass(CSS.SELECTMULTIPLE); + }); + + // Click select all link to check all the checkboxes. + Y.one(SELECTOR.SELECTALL).on('click', function(e) { + e.preventDefault(); + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX).set('checked', 'checked'); + }); + + // Click deselect all link to show the select all checkboxes. + Y.one(SELECTOR.DESELECTALL).on('click', function(e) { + e.preventDefault(); + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX).set('checked', ''); + }); + + // Disable delete multiple button by default. + Y.one(SELECTOR.SELECTMULTIPLEDELETEBUTTON).setAttribute('disabled', 'disabled'); + + // Assign the delete method to the delete multiple button. + Y.delegate('click', this.delete_multiple_with_confirmation, BODY, SELECTOR.SELECTMULTIPLEDELETEBUTTON, this); + + // Enable the delete all button only when at least one slot is selected. + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.SELECTMULTIPLECHECKBOX, this); + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.SELECTALL, this); + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.DESELECTALL, this); }, /** @@ -361,6 +415,22 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { return null; }, + /** + * If a select multiple checkbox is checked enable the buttons in the select multiple + * toolbar otherwise disable it. + * + * @method toggle_select_all_buttons_enabled + */ + toggle_select_all_buttons_enabled: function() { + var checked = Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked'); + var deletebutton = Y.one(SELECTOR.SELECTMULTIPLEDELETEBUTTON); + if (checked && !checked.isEmpty()) { + deletebutton.removeAttribute('disabled'); + } else { + deletebutton.setAttribute('disabled', 'disabled'); + } + }, + /** * Deletes the given activity or resource after confirmation. * @@ -391,7 +461,6 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { // If it is confirmed. confirm.on('complete-yes', function() { - var spinner = this.add_spinner(element); var data = { 'class': 'resource', @@ -410,10 +479,66 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { }); }, this); - - return this; }, + /** + * Deletes the given activities or resources after confirmation. + * + * @protected + * @method delete_multiple_with_confirmation + * @param {EventFacade} ev The event that was fired. + * @chainable + */ + delete_multiple_with_confirmation: function(ev) { + ev.preventDefault(); + + var ids = ''; + var slots = []; + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) { + var slot = Y.Moodle.mod_quiz.util.slot.getSlotFromComponent(node); + ids += ids === '' ? '' : ','; + ids += Y.Moodle.mod_quiz.util.slot.getId(slot); + slots.push(slot); + }); + var element = Y.one('div.mod-quiz-edit-content'); + + // Do nothing if no slots are selected. + if (!slots || !slots.length) { + return; + } + + // Create the confirmation dialogue. + var confirm = new M.core.confirm({ + question: M.util.get_string('areyousureremoveselected', 'quiz'), + modal: true + }); + + // If it is confirmed. + confirm.on('complete-yes', function() { + var spinner = this.add_spinner(element); + var data = { + 'class': 'resource', + field: 'deletemultiple', + ids: ids + }; + // Delete items on server. + this.send_request(data, spinner, function(response) { + // Delete locally if deleted on server. + if (response.deleted) { + // Actually remove the element. + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) { + Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity')); + }); + // Update the page numbers and sections. + this.reorganise_edit_page(); + + // Remove the select multiple options. + Y.one('body').removeClass(CSS.SELECTMULTIPLE); + } + }); + + }, this); + }, /** * Edit the maxmark for the resource @@ -671,82 +796,12 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { 'value': 0 } } + }); M.mod_quiz.resource_toolbox = null; M.mod_quiz.init_resource_toolbox = function(config) { M.mod_quiz.resource_toolbox = new RESOURCETOOLBOX(config); - - var bulkactions = function() { - var CSS = { - QUIZBULKACTIONMODE: 'quiz-bulk-action-mode' - }, - SELECTOR = { - BULKACTIONS: '#bulkactionscommand', - CANCELBULKACTIONS: '#bulkactionscancelcommand', - SELECTALL: '#questionselectall', - DELETEACTION: '#bulkactionsdeletecommand', - DESELECTALL: '#questiondeselectall', - CHECKBOXES: '.quiz-question-bulk-selector' - - }; - Y.one(SELECTOR.BULKACTIONS).on('click', function(e) { - e.preventDefault(); - Y.one('body').addClass(CSS.QUIZBULKACTIONMODE); - }); - - Y.one(SELECTOR.CANCELBULKACTIONS).on('click', function(e) { - e.preventDefault(); - Y.one('body').removeClass(CSS.QUIZBULKACTIONMODE); - }); - - Y.one(SELECTOR.SELECTALL).on('click', function(e) { - e.preventDefault(); - Y.all(SELECTOR.CHECKBOXES).set('checked', 'checked'); - }); - - Y.one(SELECTOR.DESELECTALL).on('click', function(e) { - e.preventDefault(); - Y.all(SELECTOR.CHECKBOXES).set('checked', ''); - }); - - var submitdeletion = function() { - var slots = ''; - Y.all(SELECTOR.CHECKBOXES + ':checked').each(function(node) { - slots += slots === '' ? '' : ','; - slots += node.get('value'); - }); - var spinnercont = Y.one('div.mod-quiz-edit-content'), - spinner = M.mod_quiz.resource_toolbox.add_spinner(spinnercont), - data = { - 'class': 'resource', - field: 'bulkdelete', - slots: slots - }; - M.mod_quiz.resource_toolbox.send_request(data, spinner, function() { - Y.all(SELECTOR.CHECKBOXES + ':checked').each(function(node) { - node.ancestor('li.activity').remove(true); - }); - }); - }; - - Y.one(SELECTOR.DELETEACTION).on('click', function(e) { - e.preventDefault(); - // Create the confirmation dialogue. - var confirm = new M.core.confirm({ - question: M.util.get_string('areyousureremoveselected', 'quiz'), - modal: true - }); - - // If it is confirmed. - confirm.on('complete-yes', function() { - submitdeletion(); - }, self); - }); - }; - - bulkactions(); - return M.mod_quiz.resource_toolbox; }; /* global TOOLBOX, BODY, SELECTOR */ diff --git a/mod/quiz/yui/src/repaginate/js/repaginate.js b/mod/quiz/yui/src/repaginate/js/repaginate.js index 2e6e0bc53be..c7a75d88838 100644 --- a/mod/quiz/yui/src/repaginate/js/repaginate.js +++ b/mod/quiz/yui/src/repaginate/js/repaginate.js @@ -23,7 +23,6 @@ */ var CSS = { - REPAGINATECONTAINERCLASS: '.rpcontainerclass', REPAGINATECOMMAND: '#repaginatecommand' }; @@ -42,12 +41,12 @@ Y.extend(POPUP, Y.Base, { body: null, initializer: function() { - var rpcontainerclass = Y.one(CSS.REPAGINATECONTAINERCLASS); + var repaginatebutton = Y.one(CSS.REPAGINATECOMMAND); // Set popup header and body. - this.header = rpcontainerclass.getAttribute(PARAMS.HEADER); - this.body = rpcontainerclass.getAttribute(PARAMS.FORM); - Y.one(CSS.REPAGINATECOMMAND).on('click', this.display_dialog, this); + this.header = repaginatebutton.getData(PARAMS.HEADER); + this.body = repaginatebutton.getData(PARAMS.FORM); + repaginatebutton.on('click', this.display_dialog, this); }, display_dialog: function(e) { diff --git a/mod/quiz/yui/src/toolboxes/js/resource.js b/mod/quiz/yui/src/toolboxes/js/resource.js index 02e2cea14cd..d88930353cb 100644 --- a/mod/quiz/yui/src/toolboxes/js/resource.js +++ b/mod/quiz/yui/src/toolboxes/js/resource.js @@ -64,6 +64,52 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { M.mod_quiz.quizbase.register_module(this); Y.delegate('click', this.handle_data_action, BODY, SELECTOR.ACTIVITYACTION, this); Y.delegate('click', this.handle_data_action, BODY, SELECTOR.DEPENDENCY_LINK, this); + this.initialise_select_multiple(); + }, + + /** + * Initialize the select multiple options + * + * Add actions to the buttons that enable multiple slots to be selected and managed at once. + * + * @method initialise_select_multiple + * @protected + */ + initialise_select_multiple: function() { + // Click select multiple button to show the select all options. + Y.one(SELECTOR.SELECTMULTIPLEBUTTON).on('click', function(e) { + e.preventDefault(); + Y.one('body').addClass(CSS.SELECTMULTIPLE); + }); + + // Click cancel button to show the select all options. + Y.one(SELECTOR.SELECTMULTIPLECANCELBUTTON).on('click', function(e) { + e.preventDefault(); + Y.one('body').removeClass(CSS.SELECTMULTIPLE); + }); + + // Click select all link to check all the checkboxes. + Y.one(SELECTOR.SELECTALL).on('click', function(e) { + e.preventDefault(); + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX).set('checked', 'checked'); + }); + + // Click deselect all link to show the select all checkboxes. + Y.one(SELECTOR.DESELECTALL).on('click', function(e) { + e.preventDefault(); + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX).set('checked', ''); + }); + + // Disable delete multiple button by default. + Y.one(SELECTOR.SELECTMULTIPLEDELETEBUTTON).setAttribute('disabled', 'disabled'); + + // Assign the delete method to the delete multiple button. + Y.delegate('click', this.delete_multiple_with_confirmation, BODY, SELECTOR.SELECTMULTIPLEDELETEBUTTON, this); + + // Enable the delete all button only when at least one slot is selected. + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.SELECTMULTIPLECHECKBOX, this); + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.SELECTALL, this); + Y.delegate('click', this.toggle_select_all_buttons_enabled, BODY, SELECTOR.DESELECTALL, this); }, /** @@ -136,6 +182,22 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { return null; }, + /** + * If a select multiple checkbox is checked enable the buttons in the select multiple + * toolbar otherwise disable it. + * + * @method toggle_select_all_buttons_enabled + */ + toggle_select_all_buttons_enabled: function() { + var checked = Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked'); + var deletebutton = Y.one(SELECTOR.SELECTMULTIPLEDELETEBUTTON); + if (checked && !checked.isEmpty()) { + deletebutton.removeAttribute('disabled'); + } else { + deletebutton.setAttribute('disabled', 'disabled'); + } + }, + /** * Deletes the given activity or resource after confirmation. * @@ -166,7 +228,6 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { // If it is confirmed. confirm.on('complete-yes', function() { - var spinner = this.add_spinner(element); var data = { 'class': 'resource', @@ -185,10 +246,66 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { }); }, this); - - return this; }, + /** + * Deletes the given activities or resources after confirmation. + * + * @protected + * @method delete_multiple_with_confirmation + * @param {EventFacade} ev The event that was fired. + * @chainable + */ + delete_multiple_with_confirmation: function(ev) { + ev.preventDefault(); + + var ids = ''; + var slots = []; + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) { + var slot = Y.Moodle.mod_quiz.util.slot.getSlotFromComponent(node); + ids += ids === '' ? '' : ','; + ids += Y.Moodle.mod_quiz.util.slot.getId(slot); + slots.push(slot); + }); + var element = Y.one('div.mod-quiz-edit-content'); + + // Do nothing if no slots are selected. + if (!slots || !slots.length) { + return; + } + + // Create the confirmation dialogue. + var confirm = new M.core.confirm({ + question: M.util.get_string('areyousureremoveselected', 'quiz'), + modal: true + }); + + // If it is confirmed. + confirm.on('complete-yes', function() { + var spinner = this.add_spinner(element); + var data = { + 'class': 'resource', + field: 'deletemultiple', + ids: ids + }; + // Delete items on server. + this.send_request(data, spinner, function(response) { + // Delete locally if deleted on server. + if (response.deleted) { + // Actually remove the element. + Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) { + Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity')); + }); + // Update the page numbers and sections. + this.reorganise_edit_page(); + + // Remove the select multiple options. + Y.one('body').removeClass(CSS.SELECTMULTIPLE); + } + }); + + }, this); + }, /** * Edit the maxmark for the resource @@ -446,81 +563,11 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, { 'value': 0 } } + }); M.mod_quiz.resource_toolbox = null; M.mod_quiz.init_resource_toolbox = function(config) { M.mod_quiz.resource_toolbox = new RESOURCETOOLBOX(config); - - var bulkactions = function() { - var CSS = { - QUIZBULKACTIONMODE: 'quiz-bulk-action-mode' - }, - SELECTOR = { - BULKACTIONS: '#bulkactionscommand', - CANCELBULKACTIONS: '#bulkactionscancelcommand', - SELECTALL: '#questionselectall', - DELETEACTION: '#bulkactionsdeletecommand', - DESELECTALL: '#questiondeselectall', - CHECKBOXES: '.quiz-question-bulk-selector' - - }; - Y.one(SELECTOR.BULKACTIONS).on('click', function(e) { - e.preventDefault(); - Y.one('body').addClass(CSS.QUIZBULKACTIONMODE); - }); - - Y.one(SELECTOR.CANCELBULKACTIONS).on('click', function(e) { - e.preventDefault(); - Y.one('body').removeClass(CSS.QUIZBULKACTIONMODE); - }); - - Y.one(SELECTOR.SELECTALL).on('click', function(e) { - e.preventDefault(); - Y.all(SELECTOR.CHECKBOXES).set('checked', 'checked'); - }); - - Y.one(SELECTOR.DESELECTALL).on('click', function(e) { - e.preventDefault(); - Y.all(SELECTOR.CHECKBOXES).set('checked', ''); - }); - - var submitdeletion = function() { - var slots = ''; - Y.all(SELECTOR.CHECKBOXES + ':checked').each(function(node) { - slots += slots === '' ? '' : ','; - slots += node.get('value'); - }); - var spinnercont = Y.one('div.mod-quiz-edit-content'), - spinner = M.mod_quiz.resource_toolbox.add_spinner(spinnercont), - data = { - 'class': 'resource', - field: 'bulkdelete', - slots: slots - }; - M.mod_quiz.resource_toolbox.send_request(data, spinner, function() { - Y.all(SELECTOR.CHECKBOXES + ':checked').each(function(node) { - node.ancestor('li.activity').remove(true); - }); - }); - }; - - Y.one(SELECTOR.DELETEACTION).on('click', function(e) { - e.preventDefault(); - // Create the confirmation dialogue. - var confirm = new M.core.confirm({ - question: M.util.get_string('areyousureremoveselected', 'quiz'), - modal: true - }); - - // If it is confirmed. - confirm.on('complete-yes', function() { - submitdeletion(); - }, self); - }); - }; - - bulkactions(); - return M.mod_quiz.resource_toolbox; }; diff --git a/mod/quiz/yui/src/toolboxes/js/toolbox.js b/mod/quiz/yui/src/toolboxes/js/toolbox.js index 22f626898f7..f2201cceda9 100644 --- a/mod/quiz/yui/src/toolboxes/js/toolbox.js +++ b/mod/quiz/yui/src/toolboxes/js/toolbox.js @@ -26,6 +26,7 @@ var CSS = { PAGE: 'page', SECTIONHIDDENCLASS: 'hidden', SECTIONIDPREFIX: 'section-', + SELECTMULTIPLE: 'select-multiple', SLOT: 'slot', SHOW: 'editing_show', TITLEEDITOR: 'titleeditor' @@ -43,7 +44,8 @@ var CSS = { COMMANDSPAN: '.commands', CONTENTAFTERLINK: 'div.contentafterlink', CONTENTWITHOUTLINK: 'div.contentwithoutlink', - DELETESECTIONICON: 'a.editing_delete .icon', + DELETESECTIONICON: 'a.editing_delete img', + DESELECTALL: '#questiondeselectall', EDITMAXMARK: 'a.editing_maxmark', EDITSECTION: 'a.editing_section', EDITSECTIONICON: 'a.editing_section .icon', @@ -63,6 +65,11 @@ var CSS = { SECTIONUL: 'ul.section', SECTIONFORM: '.instancesectioncontainer form', SECTIONINPUT: 'input[name=section]', + SELECTMULTIPLEBUTTON: '#selectmultiplecommand', + SELECTMULTIPLECANCELBUTTON: '#selectmultiplecancelcommand', + SELECTMULTIPLECHECKBOX: '.select-multiple-checkbox', + SELECTMULTIPLEDELETEBUTTON: '#selectmultipledeletecommand', + SELECTALL: '#questionselectall', SHOW: 'a.' + CSS.SHOW, SLOTLI: 'li.slot', SUMMARKS: '.mod_quiz_summarks' @@ -101,6 +108,7 @@ Y.extend(TOOLBOX, Y.Base, { if (!data) { data = {}; } + // Handle any variables which we must pass back through to var pageparams = this.get('config').pageparams, varname;