Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
6a55fb96
Commit
6a55fb96
authored
Jun 29, 2022
by
Jake Dallimore
Browse files
Merge branch 'MDL-74674-master' of
https://github.com/alfonso-salces/moodle
parents
fc5c6b92
db7178ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/behat/classes/behat_core_generator.php
View file @
6a55fb96
...
...
@@ -287,6 +287,12 @@ class behat_core_generator extends behat_generator_base {
'required'
=>
[
'user'
,
'course'
,
'lastaccess'
],
'switchids'
=>
[
'user'
=>
'userid'
,
'course'
=>
'courseid'
],
],
'notifications'
=>
[
'singular'
=>
'notification'
,
'datagenerator'
=>
'notification'
,
'required'
=>
[
'subject'
,
'userfrom'
,
'userto'
],
'switchids'
=>
[
'userfrom'
=>
'userfromid'
,
'userto'
=>
'usertoid'
],
],
];
return
$entities
;
...
...
@@ -1040,6 +1046,39 @@ class behat_core_generator extends behat_generator_base {
$DB
->
insert_record
(
'badge_backpack'
,
$backpack
);
}
/**
* Creates notifications to specific user.
*
* @param array $data
* @return void
*/
protected
function
process_notification
(
array
$data
)
{
global
$DB
;
$notification
=
new
stdClass
();
$notification
->
useridfrom
=
$data
[
'userfromid'
];
$notification
->
useridto
=
$data
[
'usertoid'
];
$notification
->
subject
=
$data
[
'subject'
];
$notification
->
fullmessage
=
$data
[
'subject'
]
.
' description'
;
$notification
->
smallmessage
=
$data
[
'subject'
]
.
' description'
;
$notification
->
fullmessagehtml
=
$data
[
'subject'
]
.
' description'
;
if
(
$data
[
'timecreated'
]
!==
'null'
)
{
$notification
->
timecreated
=
$data
[
'timecreated'
];
}
if
(
$data
[
'timeread'
]
!==
'null'
)
{
$notification
->
timeread
=
$data
[
'timeread'
];
}
if
(
!
empty
(
$data
))
{
$popupnotification
=
new
stdClass
();
$popupnotification
->
notificationid
=
$DB
->
insert_record
(
'notifications'
,
$notification
);
$DB
->
insert_record
(
'message_popup_notifications'
,
$popupnotification
);
}
}
/**
* Creates user last access data within given courses.
*
...
...
lib/behat/classes/behat_generator_base.php
View file @
6a55fb96
...
...
@@ -316,6 +316,36 @@ abstract class behat_generator_base {
return
$id
;
}
/**
* Gets the user id from it's username.
* @throws Exception
* @param string $username
* @return int
*/
protected
function
get_userfrom_id
(
string
$username
)
{
global
$DB
;
if
(
!
$id
=
$DB
->
get_field
(
'user'
,
'id'
,
[
'username'
=>
$username
]))
{
throw
new
Exception
(
'The specified user with username "'
.
$username
.
'" does not exist'
);
}
return
$id
;
}
/**
* Gets the user id from it's username.
* @throws Exception
* @param string $username
* @return int
*/
protected
function
get_userto_id
(
string
$username
)
{
global
$DB
;
if
(
!
$id
=
$DB
->
get_field
(
'user'
,
'id'
,
[
'username'
=>
$username
]))
{
throw
new
Exception
(
'The specified user with username "'
.
$username
.
'" does not exist'
);
}
return
$id
;
}
/**
* Gets the role id from it's shortname.
* @throws Exception
...
...
message/output/popup/tests/behat/notification_popover_unread.feature
View file @
6a55fb96
...
...
@@ -5,60 +5,41 @@ Feature: Notification popover unread notifications
I am notified about relevant events in Moodle
Background
:
# This will make sure popup notifications are enabled and create
# two assignment notifications. One for the student submitting their
# assignment and another for the teacher grading it.
Given the following "courses" exist
:
|
fullname
|
shortname
|
category
|
groupmode
|
|
Course
1
|
C1
|
0
|
1
|
# Make sure the popup notifications are enabled for assignments.
And the following config values are set as admin
:
|
popup_provider_mod_assign_assign_notification_locked
|
0
|
message
|
|
message_provider_mod_assign_assign_notification_enabled
|
popup
|
message
|
And the following "users" exist
:
Given 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 the following "activity" exists
:
|
activity
|
assign
|
|
course
|
C1
|
|
name
|
Test
assignment
name
|
|
assignsubmission_onlinetext_enabled
|
1
|
|
assignsubmission_file_enabled
|
0
|
|
submissiondrafts
|
0
|
# This should generate a notification.
And the following "mod_assign > submissions" exist
:
|
assign
|
user
|
onlinetext
|
|
Test
assignment
name
|
student1
|
I'm
the
student1
submission
|
|
student2
|
Student
|
2
|
student2@example.com
|
# This should generate some notifications
And the following "notifications" exist
:
|
subject
|
userfrom
|
userto
|
timecreated
|
timeread
|
|
Test
01
|
student2
|
student1
|
1654587996
|
null
|
|
Test
02
|
student2
|
student1
|
1654587997
|
null
|
Scenario
:
Notification popover shows correct unread count
Wh
en
I log in as
"student1"
Giv
en
I log in as
"student1"
# Confirm the popover is saying 1 unread notifications.
Then
I should see
"
1
"
in the
"#nav-notification-popover-container [data-region='count-container']"
"css_element"
And
I should see
"
2
"
in the
"#nav-notification-popover-container [data-region='count-container']"
"css_element"
# Open the popover.
And
I open the notification popover
# Confirm the submission notification is visible.
And
I should see
"You have submitted your assignment submission for Test assignment name"
in the
"#nav-notification-popover-container"
"css_element"
When
I open the notification popover
# Confirm the notifications are visible.
Then
I should see
"Test 01"
in the
"#nav-notification-popover-container"
"css_element"
And
I should see
"Test 02"
in the
"#nav-notification-popover-container"
"css_element"
@_bug_phantomjs
Scenario
:
Clicking a notification marks it as read
When
I log in as
"student1"
# Open the popover.
Given
I log in as
"student1"
# Open the notifications.
When
I open the notification popover
And
I follow
"Test 01"
And
I open the notification popover
# Click on the submission notification.
And
I follow
"You have submitted your assignment submission for Test assignment name"
And
I follow
"Test 02"
# Confirm the count element is hidden (i.e. there are no unread notifications).
Then
"[data-region='count-container']"
"css_element"
in the
"#nav-notification-popover-container"
"css_element"
should not be visible
Scenario
:
Mark all notifications as read
When
I log in as
"student1"
# Open the popover.
And
I open the notification popover
# Click the mark all as read button.
Given
I log in as
"student1"
When
I open the notification popover
And
I click on
"Mark all as read"
"link"
in the
"#nav-notification-popover-container"
"css_element"
# Refresh the page to make sure we send a new request for the unread count.
And
I reload the page
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment