Skip to content

Commit

Permalink
MDL-68925 assignfeedback_editpdf: avoid hiding comments with a menu open
Browse files Browse the repository at this point in the history
Co-authored by: Jonathon Fowler <fowlerj@usq.edu.au>
  • Loading branch information
mdjnelson committed May 20, 2021
1 parent 0b69b37 commit e170f1c
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 17 deletions.
58 changes: 58 additions & 0 deletions mod/assign/feedback/editpdf/tests/behat/comment_popup_menu.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@mod @mod_assign @assignfeedback @assignfeedback_editpdf @javascript @_file_upload
Feature: Ensure that a comment remains visible if its popup menu is open
In order to insert quick list comments in the PDF editor
As a teacher
I need the comment to stay visible when its popup menu is open

Background:
Given ghostscript is installed
And the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Submit your PDF file |
| assignsubmission_file_enabled | 1 |
| assignfeedback_editpdf_enabled | 1 |
| Maximum number of uploaded files | 1 |
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment name"
And I press "Add submission"
And I upload "mod/assign/feedback/editpdf/tests/fixtures/submission.pdf" file to "File submissions" filemanager
And I press "Save changes"
And I should see "Submitted for grading"
And I should see "submission.pdf"
And I should see "Not graded"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test assignment name"
And I navigate to "View all submissions" in current page administration
And I click on "Grade" "link" in the "Submitted for grading" "table_row"
And I wait for the complete PDF to load

Scenario: Add an empty comment and open its menu
When I click on ".commentbutton" "css_element"
And I draw on the pdf
And I click on ".commentdrawable a" "css_element"
Then ".drawingcanvas .commentdrawable" "css_element" should exist

Scenario: Add text to a comment and open its menu
When I click on ".commentbutton" "css_element"
And I draw on the pdf
And I set the field with xpath "//div[@class='commentdrawable']//textarea" to "Comment"
And I click on ".commentdrawable a" "css_element"
Then ".drawingcanvas .commentdrawable" "css_element" should exist
And the "class" attribute of ".drawingcanvas .commentdrawable" "css_element" should not contain "commentcollapsed"
Original file line number Diff line number Diff line change
Expand Up @@ -2607,11 +2607,20 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
* @method delete_comment_later
*/
this.delete_comment_later = function() {
if (this.deleteme) {
if (this.deleteme && !this.is_menu_active()) {
this.remove();
}
};

/**
* Returns true if the menu is active, false otherwise.
*
* @return bool true if menu is active, else false.
*/
this.is_menu_active = function() {
return this.menu.get('visible');
};

/**
* Comment nodes have a bunch of event handlers attached to them directly.
* This is all done here for neatness.
Expand All @@ -2629,11 +2638,11 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
// Function to collapse a comment to a marker icon.
node.collapse = function(delay) {
node.collapse.delay = Y.later(delay, node, function() {
if (editor.collapsecomments) {
if (editor.collapsecomments && !this.is_menu_active()) {
container.addClass('commentcollapsed');
}
});
};
}.bind(this));
}.bind(this);

// Function to expand a comment.
node.expand = function() {
Expand Down
Loading

0 comments on commit e170f1c

Please sign in to comment.