diff --git a/mod/quiz/tests/behat/flag_questions.feature b/mod/quiz/tests/behat/flag_questions.feature index 29a415d41c0..7870e199aaa 100644 --- a/mod/quiz/tests/behat/flag_questions.feature +++ b/mod/quiz/tests/behat/flag_questions.feature @@ -46,12 +46,10 @@ Feature: Flag quiz questions Scenario: Flag a quiz during and after quiz attempt Given I am on the "Quiz 1" "quiz activity" page logged in as student1 And I press "Attempt quiz" - # flag question 1 - When I press "Flag question" + When I click on "Flag question" "button" in the "First question" "question" + Then I should see "Remove flag" in the "First question" "question" # Confirm question 1 is flagged in navigation - Then "Question 1 This page Flagged" "link" should exist - # Confirm that link in question 1 is changed to Remove flag - And I should see "Remove flag" in the "First question" "question" + And "Question 1 This page Flagged" "link" should exist # Answer questions And I click on "True" "radio" in the "First question" "question" And I press "Next page" @@ -64,9 +62,14 @@ Feature: Flag quiz questions # Confirm only flagged question is flagged And I should see "Remove flag" in the "First question" "question" And I should see "Flag question" in the "Second question" "question" - And I should see "Flag question" in the "Third question" "question" And I click on "Flagged" "button" in the "Second question" "question" + And I should see "Remove flag" in the "Second question" "question" + And I should see "Flag question" in the "Third question" "question" And I am on the "Quiz 1" "mod_quiz > Grades report" page logged in as teacher1 And "Flagged" "icon" should exist in the "Student 1" "table_row" And I am on the "Quiz 1" "mod_quiz > Responses report" page And "Flagged" "icon" should exist in the "Student 1" "table_row" + And I am on the "Quiz 1 > student1 > Attempt 1" "mod_quiz > Attempt review" page + And I should see "Remove flag" in the "First question" "question" + And I should see "Remove flag" in the "Second question" "question" + And I should see "Flag question" in the "Third question" "question" diff --git a/question/flags.js b/question/flags.js index 3720d2409b1..a91d90cb2c1 100644 --- a/question/flags.js +++ b/question/flags.js @@ -29,12 +29,13 @@ M.core_question_flags = { flagattributes: null, actionurl: null, listeners: [], + editableSelector: 'div.questionflag.editable', init: function(Y, actionurl, flagattributes) { M.core_question_flags.flagattributes = flagattributes; M.core_question_flags.actionurl = actionurl; - Y.all('div.questionflag').each(function(flagdiv, i) { + Y.all(M.core_question_flags.editableSelector).each(function(flagdiv) { var checkbox = flagdiv.one('input[type=checkbox]'); if (!checkbox) { return; @@ -64,17 +65,17 @@ M.core_question_flags = { Y.delegate('click', function(e) { e.halt(); M.core_question_flags.process(this); - }, document.body, 'div.questionflag'); + }, document.body, M.core_question_flags.editableSelector); Y.delegate('key', function(e) { e.halt(); if (e.keyCode == 13) { M.core_question_flags.process(this); } - }, document.body, 'down:enter, space', 'div.questionflag'); + }, document.body, 'down:enter, space', M.core_question_flags.editableSelector); Y.delegate('key', function(e) { e.halt(); M.core_question_flags.process(this); - }, document.body, 'up:space', 'div.questionflag'); + }, document.body, 'up:space', M.core_question_flags.editableSelector); }, update_flag: function(input, toggle) {