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
Plugins bot
moodle-plugins-snapshots
Commits
75cb891b
Commit
75cb891b
authored
Jan 16, 2017
by
Dan Poltawski
Browse files
Merge branch 'MDL-57601-master' of
https://github.com/sammarshallou/moodle
parents
42d80f2b
b5f661b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
grade/report/grader/lib.php
View file @
75cb891b
...
...
@@ -919,6 +919,11 @@ class grade_report_grader extends grade_report {
// user.
if
(
!
$this
->
canviewhidden
)
{
$allgradeitems
=
grade_item
::
fetch_all
(
array
(
'courseid'
=>
$this
->
courseid
));
// But hang on - don't include ones which are set to not show the grade at all.
$allgradeitems
=
array_filter
(
$allgradeitems
,
function
(
$item
)
{
return
$item
->
gradetype
!=
GRADE_TYPE_NONE
;
});
}
foreach
(
$this
->
users
as
$userid
=>
$user
)
{
...
...
grade/tests/report_graderlib_test.php
View file @
75cb891b
...
...
@@ -230,6 +230,74 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
$this
->
assertEquals
(
count
(
$toobigvalue
[
'gradesonly'
])
-
1
,
count
(
$report1
->
collapsed
[
'gradesonly'
]));
}
/**
* Tests the get_right_rows function with one 'normal' and one 'ungraded' quiz.
*
* Previously, with an ungraded quiz (which results in a grade item with type GRADETYPE_NONE)
* there was a bug in get_right_rows in some situations.
*/
public
function
test_get_right_rows
()
{
global
$USER
,
$DB
;
$this
->
resetAfterTest
(
true
);
// Create manager and student on a course.
$generator
=
$this
->
getDataGenerator
();
$manager
=
$generator
->
create_user
();
$student
=
$generator
->
create_user
();
$course
=
$generator
->
create_course
();
$generator
->
enrol_user
(
$manager
->
id
,
$course
->
id
,
'manager'
);
$generator
->
enrol_user
(
$student
->
id
,
$course
->
id
,
'student'
);
// Create a couple of quizzes on the course.
$normalquiz
=
$generator
->
create_module
(
'quiz'
,
array
(
'course'
=>
$course
->
id
,
'name'
=>
'NormalQuiz'
));
$ungradedquiz
=
$generator
->
create_module
(
'quiz'
,
array
(
'course'
=>
$course
->
id
,
'name'
=>
'UngradedQuiz'
));
// Set the grade for the second one to 0 (note, you have to do this after creating it,
// otherwise it doesn't create an ungraded grade item).
$ungradedquiz
->
instance
=
$ungradedquiz
->
id
;
quiz_set_grade
(
0
,
$ungradedquiz
);
// Set current user.
$this
->
setUser
(
$manager
);
$USER
->
gradeediting
[
$course
->
id
]
=
false
;
// Get the report.
$report
=
$this
->
create_report
(
$course
);
$report
->
load_users
();
$report
->
load_final_grades
();
$result
=
$report
->
get_right_rows
(
false
);
// There should be 3 rows (2 header rows, plus the grades for the first user).
$this
->
assertCount
(
3
,
$result
);
// The second row should contain 2 cells - one for the graded quiz and course total.
$this
->
assertCount
(
2
,
$result
[
1
]
->
cells
);
$this
->
assertContains
(
'NormalQuiz'
,
$result
[
1
]
->
cells
[
0
]
->
text
);
$this
->
assertContains
(
'Course total'
,
$result
[
1
]
->
cells
[
1
]
->
text
);
// User row should contain grade values '-'.
$this
->
assertCount
(
2
,
$result
[
2
]
->
cells
);
$this
->
assertContains
(
'>-<'
,
$result
[
2
]
->
cells
[
0
]
->
text
);
$this
->
assertContains
(
'>-<'
,
$result
[
2
]
->
cells
[
1
]
->
text
);
// Supposing the user cannot view hidden grades, this shouldn't make any difference (due
// to a bug, it previously did).
$context
=
context_course
::
instance
(
$course
->
id
);
$managerroleid
=
$DB
->
get_field
(
'role'
,
'id'
,
array
(
'shortname'
=>
'manager'
));
assign_capability
(
'moodle/grade:viewhidden'
,
CAP_PROHIBIT
,
$managerroleid
,
$context
->
id
,
true
);
$context
->
mark_dirty
();
$this
->
assertFalse
(
has_capability
(
'moodle/grade:viewhidden'
,
$context
));
// Recreate the report. Confirm it returns successfully still.
$report
=
$this
->
create_report
(
$course
);
$report
->
load_users
();
$report
->
load_final_grades
();
$result
=
$report
->
get_right_rows
(
false
);
$this
->
assertCount
(
3
,
$result
);
}
private
function
create_grade_category
(
$course
)
{
static
$cnt
=
0
;
$cnt
++
;
...
...
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