This commit is contained in:
Sara Arjona 2022-12-07 17:17:23 +01:00
commit 592de63edb
5 changed files with 37 additions and 24 deletions

View File

@ -384,7 +384,7 @@ class quiz_grading_report extends quiz_default_report {
$row[] = $this->questions[$counts->slot]->number;
$row[] = $PAGE->get_renderer('question', 'bank')->qtype_icon($this->questions[$counts->slot]->type);
$row[] = $PAGE->get_renderer('question', 'bank')->qtype_icon($this->questions[$counts->slot]->qtype);
$row[] = format_string($counts->name);

View File

@ -203,7 +203,6 @@ class quiz_overview_report extends quiz_attempts_report {
if ($options->slotmarks) {
foreach ($questions as $slot => $question) {
// Ignore questions of zero length.
$columns[] = 'qsgrade' . $slot;
$header = get_string('qbrief', 'quiz', $question->number);
if (!$table->is_downloading()) {

View File

@ -30,28 +30,35 @@ Feature: Basic use of the Grades report
| activity | name | intro | course | idnumber |
| quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | TF1 | First question |
| Test questions | truefalse | TF2 | Second question |
| questioncategory | qtype | name | questiontext |
| Test questions | description | Intro | Welcome to this quiz |
| Test questions | truefalse | TF1 | First question |
| Test questions | truefalse | TF2 | Second question |
And quiz "Quiz 1" contains the following questions:
| question | page | maxmark |
| Intro | 1 | |
| TF1 | 1 | |
| TF2 | 1 | 3.0 |
And user "student1" has attempted "Quiz 1" with responses:
| slot | response |
| 1 | True |
| 2 | False |
| 2 | True |
| 3 | False |
And user "student2" has attempted "Quiz 1" with responses:
| slot | response |
| 1 | True |
| 2 | True |
| 3 | True |
@javascript
Scenario: Using the Grades report
# Basic check of the Grades report
When I am on the "Quiz 1" "quiz activity" page logged in as teacher1
And I navigate to "Results" in current page administration
Then I should see "Attempts: 2"
# Verify that the right columns are visible
And I should see "Q. 1"
And I should see "Q. 2"
And I should not see "Q. 3"
# Check student1's grade
And I should see "25.00" in the "S1 Student1" "table_row"
# And student2's grade

View File

@ -91,36 +91,36 @@ function quiz_has_questions($quizid) {
/**
* Get the slots of real questions (not descriptions) in this quiz, in order.
* @param object $quiz the quiz.
* @return array of slot => $question object with fields
* ->slot, ->id, ->maxmark, ->number, ->length.
* @return array of slot => objects with fields
* ->slot, ->id, ->qtype, ->length, ->number, ->maxmark, ->category (for random questions).
*/
function quiz_report_get_significant_questions($quiz) {
global $DB;
$qsbyslot = [];
$quizobj = \quiz::create($quiz->id);
$structure = \mod_quiz\structure::create_for_quiz($quizobj);
$slots = $structure->get_slots();
$qsbyslot = [];
$number = 1;
foreach ($slots as $slot) {
// Ignore 'questions' of zero length.
if ($slot->length == 0) {
continue;
}
$slotreport = new \stdClass();
$slotreport->slot = $slot->slot;
$slotreport->id = $slot->questionid;
$slotreport->qtype = $slot->qtype;
$slotreport->length = $slot->length;
$slotreport->number = $number;
$number += $slot->length;
$slotreport->maxmark = $slot->maxmark;
$slotreport->type = $slot->qtype;
if ($slot->qtype === 'random') {
$categoryobject = $DB->get_record('question_categories', ['id' => $slot->category]);
$slotreport->categoryobject = $categoryobject;
$slotreport->category = $slot->category;
}
$slotreport->category = $slot->category;
$qsbyslot[$slotreport->slot] = $slotreport;
}
ksort($qsbyslot);
$number = 1;
foreach ($qsbyslot as $question) {
$question->number = $number;
$number++;
}
return $qsbyslot;
}

View File

@ -2,6 +2,13 @@ This files describes API changes for quiz report plugins.
Overview of this plugin type at http://docs.moodle.org/dev/Quiz_reports
=== 4.2 ===
There was an ill-advised, never documented, API change in quiz_report_get_significant_questions
in Moodle 4.0. The API has now been reverted to how it was before 4.0. Hopefully this
will not cause anyone a problem. (The API revert did not require any changes in any automated tests
or standard quiz reports.)
=== 3.9 ===
* Quiz report plugins defining capabilities used to require an extra string like