Skip to content

Commit

Permalink
Merge pull request #3739 from NoelDeMartin/MOBILE-4339
Browse files Browse the repository at this point in the history
MOBILE-4339 quiz: Add unanswered questions warning
  • Loading branch information
crazyserver authored Jul 17, 2023
2 parents 8ae30ab + 3faa55e commit 7953f41
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 10 deletions.
1 change: 1 addition & 0 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@
"addon.mod_quiz.stateoverdue": "quiz",
"addon.mod_quiz.stateoverduedetails": "quiz",
"addon.mod_quiz.status": "quiz",
"addon.mod_quiz.submission_confirmation_unanswered": "quiz",
"addon.mod_quiz.submitallandfinish": "quiz",
"addon.mod_quiz.summaryofattempt": "quiz",
"addon.mod_quiz.summaryofattempts": "quiz",
Expand Down
1 change: 1 addition & 0 deletions src/addons/mod/quiz/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"stateoverdue": "Overdue",
"stateoverduedetails": "Must be submitted by {{$a}}",
"status": "Status",
"submission_confirmation_unanswered": "Questions without a response: {{$a}}",
"submitallandfinish": "Submit all and finish",
"summaryofattempt": "Summary of attempt",
"summaryofattempts": "Summary of your previous attempts",
Expand Down
29 changes: 28 additions & 1 deletion src/addons/mod/quiz/pages/player/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,34 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
try {
// Show confirm if the user clicked the finish button and the quiz is in progress.
if (!timeUp && this.attempt.state == AddonModQuizProvider.ATTEMPT_IN_PROGRESS) {
await CoreDomUtils.showConfirm(Translate.instant('addon.mod_quiz.confirmclose'));
let message = Translate.instant('addon.mod_quiz.confirmclose');

const unansweredCount = this.summaryQuestions
.filter(question => question.state === 'todo' || question.state === 'invalid')
.length;

if (unansweredCount > 0) {
const warning = Translate.instant(
'addon.mod_quiz.submission_confirmation_unanswered',
{ $a: unansweredCount },
);

message += `
<ion-card class="core-warning-card">
<ion-item>
<ion-label>
${ warning }
</ion-label>
</ion-item>
</ion-card>
`;
}

await CoreDomUtils.showConfirm(
message,
Translate.instant('addon.mod_quiz.submitallandfinish'),
Translate.instant('core.submit'),
);
}

modal = await CoreDomUtils.showModalLoading('core.sending', true);
Expand Down
6 changes: 3 additions & 3 deletions src/addons/mod/quiz/tests/behat/basic_usage-311.feature
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Feature: Attempt a quiz in app
Then I should find "Summary of attempt" in the app

When I press "Submit all and finish" in the app
And I press "OK" near "Once you submit" in the app
And I press "Submit" near "Once you submit" in the app
Then I should find "Review" in the app
And I should find "Started on" in the app
And I should find "State" in the app
Expand Down Expand Up @@ -184,7 +184,7 @@ Feature: Attempt a quiz in app
But I should not find "Not yet answered" in the app

When I press "Submit all and finish" in the app
And I press "OK" in the app
And I press "Submit" in the app
Then I should find "Review" in the app
And I should find "Finished" in the app
And I should find "Not yet graded" in the app
Expand All @@ -203,7 +203,7 @@ Feature: Attempt a quiz in app
And I press "False" in the app
And I press "Submit" in the app
And I press "Submit all and finish" in the app
And I press "OK" in the app
And I press "Submit" in the app
Then I should find "Review" in the app

When I replace "/.*/" within "page-addon-mod-quiz-review core-loading > ion-card ion-item:nth-child(1) p:nth-child(2)" with "[Started on date]"
Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/quiz/tests/behat/basic_usage-39.feature
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Feature: Attempt a quiz in app
And I should find "Incomplete answer" within "9" "ion-item" in the app

When I press "Submit all and finish" in the app
And I press "OK" in the app
And I press "Submit" in the app
Then I should find "Review" in the app
And I should find "Finished" in the app
And I should find "Not yet graded" in the app
6 changes: 3 additions & 3 deletions src/addons/mod/quiz/tests/behat/basic_usage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Feature: Attempt a quiz in app
Then I should find "Summary of attempt" in the app

When I press "Submit all and finish" in the app
And I press "OK" near "Once you submit" in the app
And I press "Submit" near "Once you submit" in the app
Then I should find "Review" in the app
And I should find "Started on" in the app
And I should find "State" in the app
Expand Down Expand Up @@ -181,7 +181,7 @@ Feature: Attempt a quiz in app
But I should not find "Not yet answered" in the app

When I press "Submit all and finish" in the app
And I press "OK" in the app
And I press "Submit" in the app
Then I should find "Review" in the app
And I should find "Finished" in the app
And I should find "Not yet graded" in the app
Expand All @@ -201,7 +201,7 @@ Feature: Attempt a quiz in app
And I press "False" in the app
And I press "Submit" in the app
And I press "Submit all and finish" in the app
And I press "OK" in the app
And I press "Submit" in the app
Then I should find "Review" in the app

When I replace "/.*/" within "page-addon-mod-quiz-review core-loading > ion-card ion-item:nth-child(1) p:nth-child(2)" with "[Started on date]"
Expand Down
4 changes: 2 additions & 2 deletions src/addons/mod/quiz/tests/behat/quiz_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Feature: Attempt a quiz in app
Then I should find "Summary of attempt" in the app

When I press "Submit all and finish" in the app
And I press "OK" near "Once you submit" in the app
And I press "Submit" near "Once you submit" in the app
Then I should find "Review" in the app
And I should find "Text of the first question" in the app
And I should find "Text of the second question" in the app
Expand Down Expand Up @@ -131,7 +131,7 @@ Feature: Attempt a quiz in app
# And I should find "Not yet answered" within "3" "ion-item" in the app

When I press "Submit all and finish" in the app
And I press "OK" near "Once you submit" in the app
And I press "Submit" near "Once you submit" in the app
Then I should find "Review" in the app
# @todo MOBILE-4350: Uncomment these.
# And I should find "Text of the first question" in the app
Expand Down
6 changes: 6 additions & 0 deletions src/theme/theme.base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ ion-alert {
.alert-message {
user-select: text;
flex-shrink: 0;

ion-card {
margin: 0;
margin-top: 10px;
}

}
}

Expand Down

0 comments on commit 7953f41

Please sign in to comment.