Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display notification if there are no attempts to show #17

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ public function display($quiz, $cm, $course) {
* Display all attempts.
*/
protected function display_archive() {
global $OUTPUT;
$studentattempts = $this->quizreportgetstudentandattempts($this->quizobj);
if (count($studentattempts) === 0) {
echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
}
foreach ($studentattempts as $studentattempt) {
echo $this->quiz_report_get_student_attempt($studentattempt['attemptid'], $studentattempt['userid']);
}
Expand Down
51 changes: 51 additions & 0 deletions tests/behat/noattempts.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@mod @mod_quiz @quiz @quiz_archive @javascript
Feature: Showing a message if there are no attempts to show
If there are no attempts to show
As a teacher
I need to see a notification

Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | T1 | Teacher1 | [email protected] | T1000 |
| student1 | S1 | Student1 | [email protected] | S1000 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "activities" exist:
| 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 |
And quiz "Quiz 1" contains the following questions:
| question | page | maxmark |
| TF1 | 1 | |

And I am on the "Quiz 1" "quiz_archive > Archive" page logged in as "teacher1"

Scenario: Check handling of no attempts situation
# Check if no attempt
Then I should see "There are no attempts to show"

# Add an attempt
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 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" "quiz_archive > Archive" page logged in as "teacher1"

# Check that the message is gone
Then I should not see "There are no attempts to show"