Skip to content

Commit

Permalink
Merge pull request #22 from bfh/preloadallstepusers
Browse files Browse the repository at this point in the history
Preloading all step users fixes #7.
  • Loading branch information
lucaboesch authored Nov 12, 2023
2 parents 9eea9d0 + 92d698f commit 3460e31
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 26 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ jobs:
- php: 7.4
moodle-branch: MOODLE_311_STABLE
database: mariadb
- php: 7.4
moodle-branch: MOODLE_310_STABLE
database: pgsql
- php: 7.4
moodle-branch: MOODLE_310_STABLE
database: mariadb
- php: 7.4
moodle-branch: MOODLE_39_STABLE
database: pgsql
Expand All @@ -121,25 +115,13 @@ jobs:
- php: 7.3
moodle-branch: MOODLE_311_STABLE
database: mariadb
- php: 7.3
moodle-branch: MOODLE_310_STABLE
database: pgsql
- php: 7.3
moodle-branch: MOODLE_310_STABLE
database: mariadb
- php: 7.3
moodle-branch: MOODLE_39_STABLE
database: pgsql
- php: 7.3
moodle-branch: MOODLE_39_STABLE
database: mariadb

- php: 7.2
moodle-branch: MOODLE_310_STABLE
database: pgsql
- php: 7.2
moodle-branch: MOODLE_310_STABLE
database: mariadb
- php: 7.2
moodle-branch: MOODLE_39_STABLE
database: pgsql
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ moodle-quiz_archive
Changes
-------

### Unreleased

* 2023-11-12 - Name the person who made a change in the question response history (if not the student)

### Release v4.3-r2

* 2023-11-09 - Add options to show/hide history & correct answer
Expand Down
17 changes: 15 additions & 2 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,13 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
// Cannot display grade.
echo '';
} else if (is_null($grade)) {
if (get_string_manager()->string_exists('gradenoun', 'moodle')) {
$gradenounstring = get_string('gradenoun');
} else {
$gradenounstring = get_string('grade', 'quiz');
}
$summarydata['grade'] = [
'title' => get_string('grade', 'quiz'),
'title' => $gradenounstring,
'content' => quiz_format_grade($quiz, $grade),
];

Expand All @@ -279,8 +284,13 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
} else {
$formattedgrade = get_string('outof', 'quiz', $a);
}
if (get_string_manager()->string_exists('gradenoun', 'moodle')) {
$gradenounstring = get_string('gradenoun');
} else {
$gradenounstring = get_string('grade', 'quiz');
}
$summarydata['grade'] = [
'title' => get_string('grade', 'quiz'),
'title' => $gradenounstring,
'content' => $formattedgrade,
];
}
Expand Down Expand Up @@ -334,6 +344,9 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) {
$attemptobj->get_question_attempt($originalslot)->get_max_mark());
}
$quba = question_engine::load_questions_usage_by_activity($attemptobj->get_uniqueid());
if (method_exists($quba, 'preload_all_step_users')) {
$quba->preload_all_step_users();
}
$string .= $quba->render_question($slot, $displayoptions, $number);

}
Expand Down
85 changes: 80 additions & 5 deletions tests/behat/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Feature: Basic use of the Archive report
As a teacher
I need to use the Archive report

@javascript
Scenario: Using the Archive report
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | T1 | Teacher1 | teacher1@example.com | T1000 |
Expand Down Expand Up @@ -33,11 +32,13 @@ Feature: Basic use of the Archive report
| Test questions | truefalse | TF2 | Second question |
And quiz "Quiz 1" contains the following questions:
| question | page | maxmark |
| TF1 | 1 | |
| TF2 | 1 | 3.0 |
| TF1 | 1 | 1.0 |
| TF2 | 1 | 1.0 |

@javascript
Scenario: Using the Archive report
# Add some attempts
And I log in as "student1"
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Quiz 1"
And I press "Attempt quiz"
Expand Down Expand Up @@ -65,3 +66,77 @@ Feature: Basic use of the Archive report
And I should see "S1 Student1"
# And student2's attempt
And I should see "S2 Student2"

@javascript
Scenario: Using the Archive report with teacher grade override for Moodle 3.9
# Add an attempt
Given the site is running Moodle version 3.9 or higher
And the site is running Moodle version 3.9 or lower
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Quiz 1"
And I press "Attempt quiz"
And I click on "True" "radio" in the "First question" "question"
And I click on "False" "radio" in the "Second question" "question"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I confirm the quiz submission in the modal dialog
And I log out
And I am on the "Quiz 1" "mod_quiz > Manual grading report" page logged in as "teacher1"
And I follow "Also show questions that have been graded automatically"
And I click on "update grades" "link" in the "TF1" "table_row"
And I set the field "Comment" to "I have adjusted your mark to 0.5"
And I set the field "Mark" to "0.5"
And I press "Save and show next"
And I follow "Results"
When I am on the "Quiz 1" "quiz_archive > Archive" page logged in as "teacher1"
Then I should see "T1 Teacher1" in the "I have adjusted your mark to 0.5" "table_row"

@javascript
Scenario: Using the Archive report with teacher grade override for Moodle 3.11
# Add an attempt
Given the site is running Moodle version 3.11 or higher
And the site is running Moodle version 3.11 or lower
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Quiz 1"
And I press "Attempt quiz"
And I click on "True" "radio" in the "First question" "question"
And I click on "False" "radio" in the "Second question" "question"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I confirm the quiz submission in the modal dialog
And I log out
And I am on the "Quiz 1" "mod_quiz > Manual grading report" page logged in as "teacher1"
And I follow "Also show questions that have been graded automatically"
And I click on "update grades" "link" in the "TF1" "table_row"
And I set the field "Comment" to "I have adjusted your mark to 0.5"
And I set the field "Mark" to "0.5"
And I press "Save and go to next page"
And I follow "Results"
When I am on the "Quiz 1" "quiz_archive > Archive" page logged in as "teacher1"
Then I should see "T1 Teacher1" in the "I have adjusted your mark to 0.5" "table_row"

@javascript
Scenario: Using the Archive report with teacher grade override for Moodle ≥ 4.0
# Add an attempt
Given the site is running Moodle version 4.0 or higher
And I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Quiz 1"
And I press "Attempt quiz"
And I click on "True" "radio" in the "First question" "question"
And I click on "False" "radio" in the "Second question" "question"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I confirm the quiz submission in the modal dialog
And I log out
And I am on the "Quiz 1" "mod_quiz > Manual grading report" page logged in as "teacher1"
And I follow "Also show questions that have been graded automatically"
And I click on "update grades" "link" in the "TF1" "table_row"
And I set the field "Comment" to "I have adjusted your mark to 0.5"
And I set the field "Mark" to "0.5"
And I press "Save and show next"
And I follow "Results"
When I am on the "Quiz 1" "quiz_archive > Archive" page logged in as "teacher1"
Then I should see "T1 Teacher1" in the "I have adjusted your mark to 0.5" "table_row"
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023111100;
$plugin->version = 2023111200;
$plugin->requires = 2017110800;
$plugin->component = 'quiz_archive';
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit 3460e31

Please sign in to comment.