Skip to content

Commit

Permalink
MDL-82282 question: consider only editable flags in JS module.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jun 24, 2024
1 parent cd781ab commit 01d62cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
15 changes: 9 additions & 6 deletions mod/quiz/tests/behat/flag_questions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
9 changes: 5 additions & 4 deletions question/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 01d62cb

Please sign in to comment.