MDL-82100 Quiz\report: Show customised question numbers

This commit is contained in:
Hieu Nguyen Dang 2024-07-03 13:47:27 +07:00
parent 5aef789ac6
commit f06a670a64
9 changed files with 30 additions and 22 deletions

View File

@ -383,7 +383,7 @@ class quiz_grading_report extends report_base {
$row = [];
$row[] = $this->questions[$counts->slot]->number;
$row[] = $this->questions[$counts->slot]->displaynumber;
$row[] = $PAGE->get_renderer('question', 'bank')->qtype_icon($this->questions[$counts->slot]->qtype);

View File

@ -55,8 +55,8 @@ Feature: Basic use of the Manual grading report
| quiz | Quiz 1 | C1 | quiz1 | 1 | tging |
| quiz | Quiz 2 | C1 | quiz2 | 1 | tging |
And quiz "Quiz 1" contains the following questions:
| question | page |
| Short answer 001 | 1 |
| question | page | displaynumber |
| Short answer 001 | 1 | 1a |
Scenario: Manual grading report without attempts
When I am on the "Quiz 1" "mod_quiz > Manual grading report" page logged in as "teacher1"
@ -98,6 +98,7 @@ Feature: Basic use of the Manual grading report
And I set the field "Mark" to "0.6"
And I press "Save and show next"
And I should see "All selected attempts have been graded. Returning to the list of questions."
And "Short answer 001" row "Q #" column of "questionstograde" table should contain "1a"
And "Short answer 001" row "To grade" column of "questionstograde" table should contain "0"
And "Short answer 001" row "Already graded" column of "questionstograde" table should contain "1"

View File

@ -149,7 +149,7 @@ class quiz_overview_report extends attempts_report {
if ($options->slotmarks) {
foreach ($questions as $slot => $question) {
$columns[] = 'qsgrade' . $slot;
$header = get_string('qbrief', 'quiz', $question->number);
$header = get_string('qbrief', 'quiz', $question->displaynumber);
if (!$table->is_downloading()) {
$header .= '<br />';
} else {

View File

@ -46,10 +46,10 @@ Feature: Basic use of the Grades report
| 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 |
| question | page | maxmark | displaynumber |
| Intro | 1 | | |
| TF1 | 1 | | |
| TF2 | 1 | 3.0 | 2a |
And user "student1" has attempted "Quiz 1" with responses:
| slot | response |
| 2 | True |
@ -68,7 +68,7 @@ Feature: Basic use of the Grades report
# Verify that the right columns are visible
And I should see "Q. 1"
And I should see "Q. 2"
And I should see "Q. 2a"
And I should not see "Q. 3"
# Check student1's grade

View File

@ -113,6 +113,7 @@ function quiz_report_get_significant_questions($quiz) {
$slotreport->qtype = $slot->qtype;
$slotreport->length = $slot->length;
$slotreport->number = $number;
$slotreport->displaynumber = $slot->displaynumber ?? $number;
$number += $slot->length;
$slotreport->maxmark = $slot->maxmark;
$slotreport->category = $slot->category;

View File

@ -158,15 +158,15 @@ class quiz_responses_report extends attempts_report {
foreach ($questions as $id => $question) {
if ($options->showqtext) {
$columns[] = 'question' . $id;
$headers[] = get_string('questionx', 'question', $question->number);
$headers[] = get_string('questionx', 'question', $question->displaynumber);
}
if ($options->showresponses) {
$columns[] = 'response' . $id;
$headers[] = get_string('responsex', 'quiz_responses', $question->number);
$headers[] = get_string('responsex', 'quiz_responses', $question->displaynumber);
}
if ($options->showright) {
$columns[] = 'right' . $id;
$headers[] = get_string('rightanswerx', 'quiz_responses', $question->number);
$headers[] = get_string('rightanswerx', 'quiz_responses', $question->displaynumber);
}
}

View File

@ -28,8 +28,8 @@ Feature: Basic use of the Responses report
| questioncategory | qtype | name | template |
| Test questions | numerical | NQ | pi3tries |
And quiz "Quiz 1" contains the following questions:
| question | page | maxmark |
| NQ | 1 | 3.0 |
| question | page | maxmark | displaynumber |
| NQ | 1 | 3.0 | 1a |
@javascript
Scenario: Report works when there are no attempts
@ -58,13 +58,14 @@ Feature: Basic use of the Responses report
And I should not see "Student Two"
And I set the field "Attempts from" to "enrolled users who have, or have not, attempted the quiz"
And I set the field "Which tries" to "All tries"
And I should see "Response 1a"
And I press "Show report"
And "Student OneReview attempt" row "Response 1Sort by Response 1 Ascending" column of "responses" table should contain "1.0"
And "Student OneReview attempt" row "Response 1aSort by Response 1a Ascending" column of "responses" table should contain "1.0"
And "Student OneReview attempt" row "Status" column of "responses" table should contain ""
And "Finished" row "Grade/100.00Sort by Grade/100.00 Ascending" column of "responses" table should contain "33.33"
And "Finished" row "Response 1Sort by Response 1 Ascending" column of "responses" table should contain "3.14"
And "Finished" row "Response 1aSort by Response 1a Ascending" column of "responses" table should contain "3.14"
And "Student Two" row "Status" column of "responses" table should contain "-"
And "Student Two" row "Response 1Sort by Response 1 Ascending" column of "responses" table should contain "-"
And "Student Two" row "Response 1aSort by Response 1a Ascending" column of "responses" table should contain "-"
@javascript
Scenario: Report does not allow strange combinations of options

View File

@ -890,11 +890,13 @@ class quiz_statistics_report extends report_base {
$questions = quiz_report_get_significant_questions($quiz);
$questiondata = [];
foreach ($questions as $qs => $question) {
$displaynumber = $question->displaynumber;
if ($question->qtype === 'random') {
$question->id = 0;
$question->name = get_string('random', 'quiz');
$question->questiontext = get_string('random', 'quiz');
$question->parenttype = 'random';
$question->number = $displaynumber;
$questiondata[$question->slot] = $question;
} else if ($question->qtype === 'missingtype') {
$question->id = is_numeric($question->id) ? (int) $question->id : 0;
@ -905,7 +907,7 @@ class quiz_statistics_report extends report_base {
$q = question_bank::load_question_data($question->id);
$q->maxmark = $question->maxmark;
$q->slot = $question->slot;
$q->number = $question->number;
$q->number = $displaynumber;
$q->parenttype = null;
$questiondata[$question->slot] = $q;
}

View File

@ -32,10 +32,10 @@ Feature: Basic use of the Statistics report
| activity | name | course | idnumber |
| quiz | Quiz 1 | C1 | quiz1 |
And quiz "Quiz 1" contains the following questions:
| question | page |
| Question A | 1 |
| Question B | 1 |
| Question C | 2 |
| question | page | displaynumber |
| Question A | 1 | |
| Question B | 1 | |
| Question C | 2 | 3c |
@javascript
Scenario: Report works when there are no attempts
@ -64,6 +64,7 @@ Feature: Basic use of the Statistics report
And "Show chart data" "link" should exist
# Question A statistics breakdown.
And "1" row "Q#" column of "questionstatistics" table should contain "1"
And "1" row "Question name" column of "questionstatistics" table should contain "Question A"
And "1" row "Attempts" column of "questionstatistics" table should contain "3"
And "1" row "Facility index" column of "questionstatistics" table should contain "66.67%"
@ -74,6 +75,7 @@ Feature: Basic use of the Statistics report
And "1" row "Discrimination index" column of "questionstatistics" table should contain "50.00%"
# Question B statistics breakdown.
And "2" row "Q#" column of "questionstatistics" table should contain "2"
And "2" row "Question name" column of "questionstatistics" table should contain "Question B"
And "2" row "Attempts" column of "questionstatistics" table should contain "3"
And "2" row "Facility index" column of "questionstatistics" table should contain "33.33%"
@ -84,6 +86,7 @@ Feature: Basic use of the Statistics report
And "2" row "Discrimination index" column of "questionstatistics" table should contain "86.60%"
# Question C statistics breakdown.
And "3" row "Q#" column of "questionstatistics" table should contain "3c"
And "3" row "Question name" column of "questionstatistics" table should contain "Question C"
And "3" row "Attempts" column of "questionstatistics" table should contain "3"
And "3" row "Facility index" column of "questionstatistics" table should contain "33.33%"