MDL-66946 quiz reports: incorrectly show teachers sometimes

This commit is contained in:
Tim Hunt
2019-10-18 17:43:23 +01:00
parent f2d10a9bb9
commit ee2c305e37
3 changed files with 13 additions and 6 deletions
+2 -1
View File
@@ -125,7 +125,8 @@ abstract class quiz_attempts_report extends quiz_default_report {
return array($currentgroup, $empty, $empty, $empty);
}
$studentsjoins = get_enrolled_with_capabilities_join($this->context);
$studentsjoins = get_enrolled_with_capabilities_join($this->context, '',
array('mod/quiz:attempt', 'mod/quiz:reviewmyattempts'));
if (empty($currentgroup)) {
return array($currentgroup, $studentsjoins, $empty, $studentsjoins);
@@ -58,8 +58,7 @@ Feature: Basic use of the Grades report
# Check changing the form parameters
And I set the field "Attempts from" to "enrolled users who have not attempted the quiz"
And I press "Show report"
# Check teacher1's grade
And I should see "-" in the "T1 Teacher1" "table_row"
# Note: teachers should not appear in the report.
# Check student3's grade
And I should see "-" in the "S3 Student3" "table_row"
@@ -69,8 +68,8 @@ Feature: Basic use of the Grades report
And I should see "25.00" in the "S1 Student1" "table_row"
# Check student2's grade
And I should see "100.00" in the "S2 Student2" "table_row"
# Check teacher1's grade
And I should see "-" in the "T1 Teacher1" "table_row"
# Check student3's grade
And I should see "-" in the "S3 Student3" "table_row"
And I set the field "Attempts from" to "all users who have attempted the quiz"
And I press "Show report"
@@ -87,6 +87,12 @@ class quiz_overview_report_testcase extends advanced_testcase {
// student enrolment does not cause duplicate records in this query.
$generator->enrol_user($student2->id, $course->id, null, 'self');
// Also create a user who should not appear in the reports,
// because they have a role with neither 'mod/quiz:attempt'
// nor 'mod/quiz:reviewmyattempts'.
$tutor = $generator->create_user();
$generator->enrol_user($tutor->id, $course->id, 'teacher');
// The test data.
$timestamp = 1234567890;
$attempts = array(
@@ -154,7 +160,8 @@ class quiz_overview_report_testcase extends advanced_testcase {
$context = context_module::instance($quiz->cmid);
$cm = get_coursemodule_from_id('quiz', $quiz->cmid);
$qmsubselect = quiz_report_qm_filter_select($quiz);
$studentsjoins = get_enrolled_with_capabilities_join($context);
$studentsjoins = get_enrolled_with_capabilities_join($context, '',
array('mod/quiz:attempt', 'mod/quiz:reviewmyattempts'));
$empty = new \core\dml\sql_join();
// Set the options.