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
bd1c9645
Commit
bd1c9645
authored
Mar 19, 2019
by
Adrian Greeve
Browse files
Merge branch 'MDL-64898-progress-teachers' of
https://github.com/dmitriim/moodle
parents
d0c649b3
34945fa3
Changes
2
Hide whitespace changes
Inline
Side-by-side
completion/classes/progress.php
View file @
bd1c9645
...
...
@@ -60,6 +60,10 @@ class progress {
return
null
;
}
if
(
!
$completion
->
is_tracked_user
(
$userid
))
{
return
null
;
}
// Before we check how many modules have been completed see if the course has.
if
(
$completion
->
is_course_complete
(
$userid
))
{
return
100
;
...
...
completion/tests/progress_test.php
View file @
bd1c9645
...
...
@@ -151,4 +151,33 @@ class core_completion_progress_testcase extends advanced_testcase {
// Check that the result was null.
$this
->
assertNull
(
\
core_completion\progress
::
get_course_progress_percentage
(
$course
));
}
/**
* Tests that the course progress returns null for a not tracked for completion user in a course.
*/
public
function
test_course_progress_not_tracked_user
()
{
global
$DB
;
// Add a course that supports completion.
$course
=
$this
->
getDataGenerator
()
->
create_course
(
array
(
'enablecompletion'
=>
1
));
// Enrol a user in the course.
$user
=
$this
->
getDataGenerator
()
->
create_user
();
$studentrole
=
$DB
->
get_record
(
'role'
,
array
(
'shortname'
=>
'student'
));
$this
->
getDataGenerator
()
->
enrol_user
(
$user
->
id
,
$course
->
id
,
$studentrole
->
id
);
// Now, mark the course as completed.
$ccompletion
=
new
completion_completion
(
array
(
'course'
=>
$course
->
id
,
'userid'
=>
$user
->
id
));
$ccompletion
->
mark_complete
();
// The course completion should return 100.
$this
->
assertEquals
(
'100'
,
\
core_completion\progress
::
get_course_progress_percentage
(
$course
,
$user
->
id
));
// Now make the user's role to be not tracked for completion.
unassign_capability
(
'moodle/course:isincompletionreports'
,
$studentrole
->
id
);
// Check that the result is null now.
$this
->
assertNull
(
\
core_completion\progress
::
get_course_progress_percentage
(
$course
,
$user
->
id
));
}
}
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