Skip to content

Commit

Permalink
MOBILE-3671 assign: Remove ASSIGN_ATTEMPT_REOPEN_METHOD_NONE usage
Browse files Browse the repository at this point in the history
Deprecated on MDL-80741
  • Loading branch information
crazyserver committed Feb 19, 2025
1 parent 40ee496 commit 84a1207
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"addon.mod_assign.attempthistory": "assign",
"addon.mod_assign.attemptnumber": "assign",
"addon.mod_assign.attemptreopenmethod": "assign",
"addon.mod_assign.attemptreopenmethod_automatic": "assign",
"addon.mod_assign.attemptreopenmethod_manual": "assign",
"addon.mod_assign.attemptreopenmethod_untilpass": "assign",
"addon.mod_assign.attemptsettings": "assign",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h1>{{'addon.mod_assign.grade' | translate}}</h1>
</ion-item>

<!-- Attempt status. -->
@if (assign.attemptreopenmethod !== attemptReopenMethodNone) {
@if (assign.maxattempts !== 1) {
<ion-item class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ 'addon.mod_assign.attemptsettings' | translate }}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export class AddonModAssignEditFeedbackModalComponent implements OnDestroy, OnIn
gradeInfo?: AddonModAssignGradeInfo; // Grade data for the assignment, retrieved from the server.
allowAddAttempt = false; // Allow adding a new attempt when grading.

attemptReopenMethodNone = AddonModAssignAttemptReopenMethodValues.NONE;
unlimitedAttempts = ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS;
currentAttemptNumber = 0; // The current attempt number.
maxAttemptsText = Translate.instant('addon.mod_assign.unlimitedattempts'); // The text for maximum attempts.
Expand Down Expand Up @@ -150,7 +149,7 @@ export class AddonModAssignEditFeedbackModalComponent implements OnDestroy, OnIn
await this.treatGradeInfo(assign);

const isManual = assign.attemptreopenmethod == AddonModAssignAttemptReopenMethodValues.MANUAL;
const isUnlimited = assign.maxattempts == ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS;
const isUnlimited = assign.maxattempts === ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS;
const isLessThanMaxAttempts = !!this.userSubmission && (this.userSubmission.attemptnumber < (assign.maxattempts - 1));

this.allowAddAttempt = isManual && (!this.userSubmission || isUnlimited || isLessThanMaxAttempts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
<ion-item class="divider">
<ion-label>
<h2 class="big">
@if (currentAttemptNumber) {
{{ 'addon.mod_assign.attempt' | translate : { '$a' : currentAttemptNumber } }}
@if (assign.maxattempts !== 1 && currentAttemptNumber) {
@if (assign.maxattempts === unlimitedAttempts) {
{{ 'addon.mod_assign.attempt' | translate : { '$a' : currentAttemptNumber } }}
} @else {
{{ 'addon.mod_assign.attempt' | translate : { '$a' : 'addon.mod_assign.outof' | translate :
{'$a': {'current': currentAttemptNumber, 'total': assign.maxattempts} } } }}
}
} @else {
{{'addon.mod_assign.submission' | translate}}
}
Expand Down
5 changes: 3 additions & 2 deletions src/addons/mod/assign/components/submission/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
ADDON_MOD_ASSIGN_PAGE_NAME,
ADDON_MOD_ASSIGN_SUBMISSION_REMOVED_EVENT,
ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS,
AddonModAssignAttemptReopenMethodValues,

Check failure on line 54 in src/addons/mod/assign/components/submission/submission.ts

View workflow job for this annotation

GitHub Actions / test

'AddonModAssignAttemptReopenMethodValues' is defined but never used
AddonModAssignGradingStates,
AddonModAssignSubmissionStatusValues,
Expand Down Expand Up @@ -133,7 +134,7 @@ export class AddonModAssignSubmissionComponent implements OnInit {
// Some constants.
statusNew = AddonModAssignSubmissionStatusValues.NEW;
statusReopened = AddonModAssignSubmissionStatusValues.REOPENED;
attemptReopenMethodNone = AddonModAssignAttemptReopenMethodValues.NONE;
unlimitedAttempts = ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS;

previousAttempts: AddonModAssignSubmissionPreviousAttemptFormatted[] = []; // List of previous attempts.

Expand Down Expand Up @@ -853,7 +854,7 @@ export class AddonModAssignSubmissionComponent implements OnInit {

this.userSubmission = AddonModAssign.getSubmissionObjectFromAttempt(this.assign, lastAttempt);

if (this.assign.attemptreopenmethod !== this.attemptReopenMethodNone && this.userSubmission) {
if (this.assign.maxattempts !== 1 && this.userSubmission) {
this.currentAttemptNumber = this.userSubmission.attemptnumber + 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/assign/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export const enum AddonModAssignGradingStates {
* Constants on LMS starting with ASSIGN_ATTEMPT_REOPEN_METHOD_
*/
export const enum AddonModAssignAttemptReopenMethodValues {
NONE = 'none',
MANUAL = 'manual',
AUTOMATIC = 'automatic',
UNTILPASS = 'untilpass',
}

Expand Down
1 change: 1 addition & 0 deletions src/addons/mod/assign/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"attemptheading": "Attempt {{$a.attemptnumber}}: {{$a.submissionsummary}}",
"attempthistory": "Previous attempts",
"attemptnumber": "Attempt number",
"attemptreopenmethod_automatic": "Automatically",
"attemptreopenmethod_manual": "Manually",
"attemptreopenmethod_untilpass": "Automatically until pass",
"attemptreopenmethod": "Grant attempts",
Expand Down

0 comments on commit 84a1207

Please sign in to comment.